bool Baud( int index ) { USHORT temp; BYTE lc[3]; APIRET rc; BYTE command; ULONG ulParmLen; if( index == MIN_BAUD ) return( TRUE ); if( index == CurrentBaud ) return( TRUE ); temp = Rate[index]; command = 0; ulParmLen = sizeof( temp ); rc = DosDevIOCtl( ComPort, IOCTL_ASYNC, ASYNC_SETBAUDRATE, &temp, sizeof( temp ), &ulParmLen, NULL, 0, NULL ); if( rc != 0 ) { return( FALSE ); } lc[ 0 ] = DATA_BITS_8; lc[ 1 ] = PARITY_NONE; lc[ 2 ] = STOP_BITS_1; ulParmLen = sizeof( lc ); rc = DosDevIOCtl( ComPort, IOCTL_ASYNC, ASYNC_SETLINECTRL, &lc, sizeof( lc ), &ulParmLen, NULL, 0, NULL ); if( rc != 0 ) { return( FALSE ); } CurrentBaud = index; return( TRUE ); }
bool CD_drive::readTrackInfo(char track, CDTRACKINFO *trackInfo2) { ULONG ulParamLen; ULONG ulDataLen; ULONG rc; BOOL returnBool = FALSE; CDAUDIOTRACKINFOPARAM trackParam; CDAUDIOTRACKINFODATA trackInfo[2]; memcpy(trackParam.signature,TAG,4); trackParam.trackNum = track; rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, &trackParam, sizeof(trackParam), &ulParamLen, &trackInfo[0], sizeof(trackInfo[0]), &ulDataLen); if(rc) updateError("DosDevIOCtl failed with return code 0x%x reading track %d info",rc,track); else { trackParam.trackNum = track+1; rc = 0; if(trackParam.trackNum <= cdInfo.lastTrack) { rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, &trackParam, sizeof(trackParam), &ulParamLen, &trackInfo[1], sizeof(trackInfo[1]), &ulDataLen); if(rc) updateError("DosDevIOCtl failed with return code 0x%x",rc); } else trackInfo[1].address = cdInfo.leadOutAddress; if(!rc) { ULONG LBA[2]; MSF length; LBA[0] = getLBA(trackInfo[0].address); LBA[1] = getLBA(trackInfo[1].address); /* -150 because we want length, not an address */ length = getMSF(LBA[1]-LBA[0]-150); trackInfo2->start = trackInfo[0].address; trackInfo2->end = trackInfo[1].address; trackInfo2->length = length; trackInfo2->size = (LBA[1]-LBA[0])*2352; trackInfo2->data = (trackInfo[0].info & 0x40) ? TRUE : FALSE; trackInfo2->channels = (trackInfo[0].info & 0x80) ? 4 : 2; trackInfo2->number = track; returnBool = TRUE; } } return returnBool; }
int SERIAL_getextchar(COMPORT port) { ULONG dwRead = 0; // Number of chars read char chRead; int retval = 0; // receive a byte; TODO communicate failure if (DosRead(port->porthandle, &chRead, 1, &dwRead) == NO_ERROR) { if (dwRead) { // check for errors; will OS/2 clear the error on reading its data? // if yes then this is in wrong order USHORT errors = 0, event = 0; ULONG ulParmLen = sizeof(errors); DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMEVENT, 0, 0, 0, &event, ulParmLen, &ulParmLen); if (event & (64 + 128) ) { // Break (Bit 6) or Frame or Parity (Bit 7) error Bit8u errreg = 0; if (event & 64) retval |= SERIAL_BREAK_ERR; if (event & 128) { DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMERROR, 0, 0, 0, &errors, ulParmLen, &ulParmLen); if (errors & 8) retval |= SERIAL_FRAMING_ERR; if (errors & 4) retval |= SERIAL_PARITY_ERR; } } retval |= (chRead & 0xff); retval |= 0x10000; } } return retval; }
int mpioctl(HFILE fd, int func,struct map_ioctl* data) { struct xf86_pmap_param par; struct xf86_pmap_data dta; ULONG len; APIRET rc; switch (func) { case IOCTL_MAP: par.u.physaddr = data->a.phys; par.size = data->size; rc = DosDevIOCtl(fd, XFREE86_PMAP, PMAP_MAP, (ULONG*)&par, sizeof(par), &len, (ULONG*)&dta, sizeof(dta), &len); if (!rc) data->a.user = (void*)dta.addr; return rc ? -1 : 0; case IOCTL_UMAP: par.u.physaddr = (ULONG)data->a.user; par.size = 0; rc = DosDevIOCtl(fd, XFREE86_PMAP, PMAP_UNMAP, (ULONG*)&par, sizeof(par), &len, NULL, 0, NULL); return rc ? -1 : 0; default: return -1; } }
void CDirectSerial::updateModemControlLines ( /*Bit8u mcr */ ) { bool change = false; DCBINFO dcb; ULONG ulParmLen = sizeof(dcb); DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETDCBINFO, 0, 0, 0, &dcb, ulParmLen, &ulParmLen); /*** DTR ***/ if (CSerial::getDTR ()) { // DTR on if (dcb.fbCtlHndShake && 3 == 0) { // DTR disabled dcb.fbCtlHndShake |= 1; change = true; } } else { if (dcb.fbCtlHndShake && 3 == 1) { // DTR enabled dcb.fbCtlHndShake &= ~3; change = true; } } /*** RTS ***/ if (CSerial::getRTS ()) { // RTS on if (dcb.fbFlowReplace && 192 == 0) { //RTS disabled dcb.fbFlowReplace |= 64; change = true; } } else { if (dcb.fbFlowReplace && 192 == 1) { // RTS enabled dcb.fbFlowReplace &= ~192; change = true; } } if (change) DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb, ulParmLen, &ulParmLen, 0, 0, 0); }
void Set_IOCTL_Bit_Rate(USHORT BitRate,HWND hwnd) { APIRET rc; ULONG ParmPacketLen; ParmPacketLen = 2; //size of Parmpacket rc = DosDevIOCtl (HandleComm, IOCTL_ASYNC, ASYNC_SETBAUDRATE, (PULONG) &BitRate, sizeof(BitRate), //size input parm packet &ParmPacketLen, // length of parm packet NULL, 0, NULL); rc = DosDevIOCtl (HandleComm, IOCTL_ASYNC, ASYNC_SETBAUDRATE, (PULONG) &BitRate, sizeof(BitRate), //size input parm packet &ParmPacketLen, // length of parm packet NULL, 0, NULL); if (rc) { sprintf(PrintBuf,"RC=%u Line=%u\nFile: %s",rc,__LINE__,__FILE__); WinDebugMsg(PrintBuf,hwnd); } }
APIRET InitLineBits(HWND hwnd) { APIRET rc; ULONG DataPacketLen; rc = DosDevIOCtl (HandleComm, IOCTL_ASYNC, ASYNC_GETLINECTRL, NULL, //no parameter packet 0, // = 0 NULL, // length of parm packet (PULONG) &DataPacket, sizeof(DataPacket), &DataPacketLen); rc = DosDevIOCtl (HandleComm, IOCTL_ASYNC, ASYNC_GETLINECTRL, NULL, //no parameter packet 0, // = 0 NULL, // length of parm packet (PULONG) &DataPacket, sizeof(DataPacket), &DataPacketLen); if (rc) { sprintf(PrintBuf,"RC=%u Line=%u\nFile: %s",rc,__LINE__,__FILE__); WinDebugMsg(PrintBuf,hwnd); } WinSendDlgItemMsg(hwnd, (ULONG) IDC_DATA_BIT5 + (DataPacket.bDataBits - 5), (ULONG) BM_SETCHECK, MPFROM2SHORT(TRUE,0), NULL); WinSendDlgItemMsg(hwnd,IDC_PARITY_NO + DataPacket.bParity, BM_SETCHECK, MPFROM2SHORT(TRUE,0), NULL); WinSendDlgItemMsg(hwnd,IDC_STOP_BIT1 + DataPacket.bStopBits, BM_SETCHECK, MPFROM2SHORT(TRUE,0), NULL); WinSetFocus (HWND_DESKTOP, WinWindowFromID(hwnd,DID_OK)); return 0; }
bool SERIAL_setCommParameters(COMPORT port, int baudrate, char parity, int stopbits, int length) { // baud struct { ULONG baud; BYTE fraction; } setbaud; setbaud.baud = baudrate; setbaud.fraction = 0; ULONG ulParmLen = sizeof(setbaud); APIRET rc = DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_EXTSETBAUDRATE, &setbaud, ulParmLen, &ulParmLen, 0, 0, 0); if (rc != NO_ERROR) { return false; } struct { UCHAR data; UCHAR parity; UCHAR stop; } paramline; // byte length if(length > 8 || length < 5) { // TODO SetLastError(ERROR_INVALID_PARAMETER); return false; } paramline.data = length; // parity switch (parity) { case 'n': paramline.parity = 0; break; case 'o': paramline.parity = 1; break; case 'e': paramline.parity = 2; break; case 'm': paramline.parity = 3; break; case 's': paramline.parity = 4; break; default: // TODO SetLastError(ERROR_INVALID_PARAMETER); return false; } // stopbits switch(stopbits) { case SERIAL_1STOP: paramline.stop = 0; break; case SERIAL_2STOP: paramline.stop = 2; break; case SERIAL_15STOP: paramline.stop = 1; break; default: // TODO SetLastError(ERROR_INVALID_PARAMETER); return false; } // set it ulParmLen = sizeof(paramline); rc = DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_SETLINECTRL, ¶mline, ulParmLen, &ulParmLen, 0, 0, 0); if ( rc != NO_ERROR) return false; return true; }
void ClearCom( void ) { BYTE command; command = 0; DosDevIOCtl( 0L, &command, INPUT, FLUSH, ComPort ); command = 0; DosDevIOCtl( 0L, &command, OUTPUT, FLUSH, ComPort ); }
CDirectSerial::CDirectSerial (IO_ReadHandler * rh, IO_WriteHandler * wh, TIMER_TickHandler th, Bit16u baseAddr, Bit8u initIrq, Bit32u initBps, Bit8u bytesize, const char *parity, Bit8u stopbits,const char *realPort) :CSerial (rh, wh, th,baseAddr,initIrq, initBps, bytesize, parity,stopbits) { InstallationSuccessful = false; InstallTimerHandler(th); lastChance = 0; LOG_MSG ("OS/2 Serial port at %x: Opening %s", base, realPort); LOG_MSG("Opening OS2 serial port"); ULONG ulAction = 0; APIRET rc = DosOpen((unsigned char*)realPort, &hCom, &ulAction, 0L, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_SEQUENTIAL, 0L); if (rc != NO_ERROR) { LOG_MSG ("Serial port \"%s\" could not be opened.", realPort); if (rc == 2) { LOG_MSG ("The specified port does not exist."); } else if (rc == 99) { LOG_MSG ("The specified port is already in use."); } else { LOG_MSG ("OS/2 error %d occurred.", rc); } hCom = 0; return; } DCBINFO dcb; ULONG ulParmLen = sizeof(DCBINFO); rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETDCBINFO, 0, 0, 0, &dcb, ulParmLen, &ulParmLen); if ( rc != NO_ERROR) { DosClose(hCom); hCom = 0; return; } dcb.usWriteTimeout = 0; dcb.usReadTimeout = 0; //65535; dcb.fbTimeout |= 6; rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb, ulParmLen, &ulParmLen, 0, 0, 0); if ( rc != NO_ERROR) { DosClose(hCom); hCom = 0; return; } CSerial::Init_Registers (initBps, bytesize, parity, stopbits); InstallationSuccessful = true; //LOG_MSG("InstSuccess"); }
void CDirectSerial::setBreak (bool value) { //#ifdef SERIALPORT_DEBUGMSG //LOG_MSG("UART 0x%x: Break toggeled: %d", base, value); //#endif USHORT error; ULONG ulParmLen = sizeof(error); if (value) DosDevIOCtl (hCom, IOCTL_ASYNC, ASYNC_SETBREAKON, 0,0,0, &error, ulParmLen, &ulParmLen); else DosDevIOCtl (hCom, IOCTL_ASYNC, ASYNC_SETBREAKOFF, 0,0,0, &error, ulParmLen, &ulParmLen); }
bool SERIAL_open(const char* portname, COMPORT* port) { // allocate COMPORT structure COMPORT cp = (_COMPORT*)malloc(sizeof(_COMPORT)); if(cp == NULL) return false; cp->porthandle=0; cp->breakstatus=false; ULONG ulAction = 0; APIRET rc = DosOpen(portname, &cp->porthandle, &ulAction, 0L, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_SEQUENTIAL, 0L); if (rc != NO_ERROR) { goto cleanup_error; } ULONG ulParmLen = sizeof(DCBINFO); rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETDCBINFO, 0, 0, 0, &cp->orig_dcb, ulParmLen, &ulParmLen); if ( rc != NO_ERROR) { goto cleanup_error; } // configure the port for polling DCBINFO newdcb; memcpy(&newdcb,&cp->orig_dcb,sizeof(DCBINFO)); newdcb.usWriteTimeout = 0; newdcb.usReadTimeout = 0; //65535; newdcb.fbCtlHndShake = dcb.fbFlowReplace = 0; newdcb.fbTimeout = 6; rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_SETDCBINFO, &newdcb, ulParmLen, &ulParmLen, 0, 0, 0); if ( rc != NO_ERROR) { goto cleanup_error; } USHORT errors = 0; ulParmLen = sizeof(errors); rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETCOMMERROR, 0, 0, 0, &errors, ulParmLen, &ulParmLen); if ( rc != NO_ERROR) { goto cleanup_error; } *port = cp; return true; cleanup_error: // TODO error string - rc value if (cp->porthandle != 0) CloseHandle(cp->porthandle); free(cp); return false; }
/*! Set the volume of an audio CD. @param p_cdio the CD object to be acted upon. */ static driver_return_code_t audio_set_volume_os2 ( void *p_user_data, cdio_audio_volume_t *p_volume) { _img_private_t *p_env = p_user_data; struct { UCHAR auch_sign[4]; } s_param = {{'C', 'D', '0', '1'}}; struct { struct { BYTE uc_in_ch; BYTE uc_vol; } as_out_ch[4]; } s_data; ULONG ul_param_len; ULONG ul_data_len; ULONG rc; int i; /* first retrive current input ch. */ rc = DosDevIOCtl( p_env->h_cd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETCHANNEL, &s_param, sizeof( s_param ), &ul_param_len, &s_data, sizeof( s_data ), &ul_data_len ); if( rc ) { cdio_warn("audio_set_volume_os2 : DosDevIOCtl(GETCHANNEL) = 0x%lx\n", rc ); return DRIVER_OP_ERROR; } for( i = 0; i < 4; i++ ) s_data.as_out_ch[ i ].uc_vol = p_volume->level[ i ]; /* now set volumes */ rc = DosDevIOCtl( p_env->h_cd, IOCTL_CDROMAUDIO, CDROMAUDIO_SETCHANNELCTRL, &s_param, sizeof( s_param ), &ul_param_len, &s_data, sizeof( s_data ), &ul_data_len ); if( rc ) { cdio_warn("audio_set_volume_os2 : DosDevIOCtl(SETCHANNELCTRL) = 0x%lx\n", rc ); return DRIVER_OP_ERROR; } return DRIVER_OP_SUCCESS; }
static int _get_modem_state(int fd,ULONG* state) { ULONG state1,len; if (DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMOUTPUT, NULL,0,NULL, state, sizeof(BYTE), &len) != 0 || DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMINPUT, NULL,0,NULL, &state1, sizeof(BYTE), &len) != 0) return -1; *state |= state1; *state &= 0xff; return 0; }
static APIRET QueryCDROMDMDInfo(struct CDROMDMDInfo_t* pxInfo) { APIRET rc; HFILE hfDMD; ULONG ulDataLen; union { struct DriveLetters_Data xDRIVELETTERS; struct Features_Data xFEATURES; } xData; rc = DosOpen(CDROMDMD_NAME, &hfDMD, &ulDataLen, (ULONG)0, FILE_NORMAL, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, (PEAOP2)NULL); if(rc == NO_ERROR) { rc = DosDevIOCtl(hfDMD, IOCTL_CDROMDISK2, CDROMDISK2_DRIVELETTERS, (PVOID)NULL, (ULONG)0, (PULONG)NULL, (PVOID)&xData.xDRIVELETTERS, ulDataLen = (ULONG)sizeof(xData.xDRIVELETTERS), &ulDataLen); if(rc == NO_ERROR) { pxInfo->ucDriveFirst = (UCHAR)xData.xDRIVELETTERS.first_drive + (UCHAR)'A'; pxInfo->ulDriveCount = (ULONG)xData.xDRIVELETTERS.drive_count; pxInfo->ulFeatureFlags = (ULONG)0; if(DosDevIOCtl(hfDMD, IOCTL_CDROMDISK2, CDROMDISK2_FEATURES, (PVOID)NULL, (ULONG)0, (PULONG)NULL, (PVOID)&xData.xFEATURES, ulDataLen = (ULONG)sizeof(xData.xFEATURES), &ulDataLen) == NO_ERROR) pxInfo->ulFeatureFlags = xData.xFEATURES.driver_status; } (VOID)DosClose(hfDMD); } return rc; }
void nflowcontrol( KWBoolean flow ) { APIRET rc; #ifdef __OS2__ ULONG ParmLengthInOut; ULONG DataLengthInOut; #endif if ( flow ) com_dcbinfo.fbFlowReplace = (char) (com_dcbinfo.fbFlowReplace | (MODE_AUTO_TRANSMIT | MODE_AUTO_RECEIVE)); else com_dcbinfo.fbFlowReplace = (char) (com_dcbinfo.fbFlowReplace & (0xff - MODE_AUTO_TRANSMIT - MODE_AUTO_RECEIVE)); #ifdef __OS2__ ParmLengthInOut = sizeof(com_dcbinfo); DataLengthInOut = 0; rc = DosDevIOCtl( commHandle, IOCTL_ASYNC, ASYNC_SETDCBINFO, (PVOID) &com_dcbinfo, sizeof(com_dcbinfo), &ParmLengthInOut, NULL, 0L, &DataLengthInOut); #else rc = DosDevIOCtl( FAR_NULL, &com_dcbinfo, ASYNC_SETDCBINFO, IOCTL_ASYNC, commHandle); #endif if ( rc ) { printOS2error( "ASYNC_SETDCBINFO", rc ); panic(); } /*if */ } /* nflowcontrol */
/**************************************************************************** REMARKS: This function returns a pointer to the common graphics driver loaded in the helper VxD. The memory for the VxD is shared between all processes via the VxD, so that the VxD, 16-bit code and 32-bit code all see the same state when accessing the graphics binary portable driver. ****************************************************************************/ GA_sharedInfo * NAPI GA_getSharedInfo( int device) { /* Initialise the PM library and connect to our runtime DLL's */ PM_init(); /* Open our helper device driver */ if (DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0, FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, NULL)) PM_fatalError("Unable to open SDDHELP$ helper device driver!"); outLen = sizeof(result); DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,PMHELP_GETSHAREDINFO, NULL, 0, NULL, &result, outLen, &outLen); DosClose(hSDDHelp); if (result) { /* We have found the shared Nucleus packet. Because not all processes * map to SDDPMI.DLL, we need to ensure that we connect to this * DLL so that it gets mapped into our address space (that is * where the shared Nucleus packet is located). Simply doing a * DosLoadModule on it is enough for this. */ HMODULE hModSDDPMI; char buf[80]; DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI); } return (GA_sharedInfo*)result; }
UCHAR lookup_bios(HFILE filehandle,USHORT deviceid,USHORT func,USHORT bus,USHORT index) { APIRET rc; struct _READPCI_CONF { UCHAR sub_func; UCHAR bus_number; UCHAR dev_funcnum; UCHAR conf_reg; UCHAR size; } rpci_conf; struct _READPCI_CONF_RESP { UCHAR ret_code; ULONG data; } rpci_conf_resp; rpci_conf.sub_func = 3; rpci_conf.bus_number = bus; rpci_conf.dev_funcnum = deviceid * 8 + func; rpci_conf.conf_reg = index; rpci_conf.size = sizeof(UCHAR); rc = DosDevIOCtl( (PVOID) &rpci_conf_resp,(PVOID)&rpci_conf,OEMHLP_PCI,IOCTL_OEMHLP,filehandle); if (rc != 0) return 0xff; return rpci_conf_resp.data; }
static int u_ioctl(HFILE fd, ULONG data) { APIRET rc = DosDevIOCtl(fd,XFREE86_USER, data, NULL, 0, NULL, NULL, 0, NULL); return rc ? -1 : 0; }
static int x_ioctl(HFILE fd, int func) { APIRET rc = DosDevIOCtl(fd,XFREE86_PTY, func, NULL, 0, NULL, NULL, 0, NULL); return rc ? -1 : 0; }
/* ARGSUSED */ void * map_phys_mem(unsigned long base, unsigned long size) { DIOParPkt par; ULONG plen; DIODtaPkt dta; ULONG dlen; static BOOL ErrRedir = FALSE; APIRET rc; par.addr = (ULONG)base; par.size = (ULONG)size; plen = sizeof(par); dlen = sizeof(dta); open_mmap(); if (mapdev == -1) { perror("libdha: device xf86sup.sys is not installed"); exit(1); } if ((rc=DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x44, (PVOID)&par, (ULONG)plen, (PULONG)&plen, (PVOID)&dta, (ULONG)dlen, (PULONG)&dlen)) == 0) { if (dlen==sizeof(dta)) { callcount++; return (void *)dta.addr; } /*else fail*/ } return (void *)-1; }
/* ARGSUSED */ void unmap_phys_mem(void * base, unsigned long size) { DIOParPkt par; ULONG plen,vmaddr; /* We need here the VIRTADDR for unmapping, not the physical address */ /* This should be taken care of either here by keeping track of allocated */ /* pointers, but this is also already done in the driver... Thus it would */ /* be a waste to do this tracking twice. Can this be changed when the fn. */ /* is called? This would require tracking this function in all servers, */ /* and changing it appropriately to call this with the virtual adress */ /* If the above mapping function is only called once, then we can store */ /* the virtual adress and use it here.... */ par.addr = (ULONG)base; par.size = 0xffffffff; /* This is the virtual address parameter. Set this to ignore */ plen = sizeof(par); if (mapdev != -1) { DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x46, (PVOID)&par, (ULONG)plen, (PULONG)&plen, &vmaddr, sizeof(ULONG), &plen); callcount--; } /* Now if more than one region has been allocated and we close the driver, * the other pointers will immediately become invalid. We avoid closing * driver for now, but this should be fixed for server exit */ if(!callcount) close_mmap(); }
static int _set_baudrate(HFILE fd,int baud) { USHORT br = baud; ULONG plen; return DosDevIOCtl(fd,IOCTL_ASYNC,ASYNC_SETBAUDRATE, (PULONG)&br,sizeof(br),&plen,NULL,0,NULL); }
/*! Close tray on CD-ROM. @param p_user_data the CD object to be acted upon. */ driver_return_code_t close_tray_os2 (const char *psz_os2_drive) { #ifdef HAVE_OS2_CDROM struct { BYTE uc_cmd_info; BYTE uc_drive; } s_param; ULONG ul_param_len; ULONG ul_data_len; ULONG rc; s_param.uc_cmd_info = 3; s_param.uc_drive = toupper(psz_os2_drive[0]) - 'A'; rc = DosDevIOCtl( ( HFILE )-1, IOCTL_DISK, DSK_UNLOCKEJECTMEDIA, &s_param, sizeof( s_param ), &ul_param_len, NULL, 0, &ul_data_len ); if( rc && rc != 99 /* device in use */ ) { cdio_warn("close_tray_os2 : DosDevIOCtl(UNLOCKEJECTMEDIA) = 0x%lx\n", rc ); return DRIVER_OP_ERROR; } return DRIVER_OP_SUCCESS; #else return DRIVER_OP_UNSUPPORTED; #endif /* HAVE_OS2_CDROM */ }
bool CD_drive::play(char track) { ULONG ulParamLen; ULONG ulDataLen; ULONG rc; BOOL returnBool = FALSE; CDPLAYAUDIOPARAM playParam; CDTRACKINFO trackInfo; memcpy(playParam.signature,TAG,4); playParam.addressingMode = MODE_MSF; if(!readTrackInfo(track, &trackInfo)) return FALSE; playParam.start = trackInfo.start; playParam.end = trackInfo.end; rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_PLAYAUDIO, &playParam, sizeof(playParam), &ulParamLen, NULL, 0, &ulDataLen); if(rc) updateError("DosDevIOCtl failed with return code 0x%x playing track %d",rc,track); else returnBool = TRUE; return returnBool; }
static driver_return_code_t audio_stop_os2 (void *p_user_data) { _img_private_t *p_env = p_user_data; struct { UCHAR auch_sign[4]; } s_param = {{'C', 'D', '0', '1'}}; ULONG ul_param_len; ULONG ul_data_len; ULONG rc; rc = DosDevIOCtl( p_env->h_cd, IOCTL_CDROMAUDIO, CDROMAUDIO_STOPAUDIO, &s_param, sizeof( s_param ), &ul_param_len, NULL, 0, &ul_data_len ); if( rc ) { cdio_warn("audio_stop_os2 : DosDevIOCtl(STOPAUDIO) = 0x%lx\n", rc ); return DRIVER_OP_ERROR; } return DRIVER_OP_SUCCESS; }
/****************************************************************** * NAME: tell_LVM * * FUNCTION: Notify the LVM that it can remove, from its bad block list, * the entries describing the bad LV blocks contained in the * given file system block. * * PARAMETERS: * bdblk_recptr ptr to the bad block record describing the file * system block which is now allocated to the Bad * Block inode. * * NOTES: Each bad block record describes one file system block * which contains one or more bad LV blocks. * * RETURNS: * success: 0 * failure: something else */ int32 tell_LVM( cbbl_bdblk_recptr thisrec ) { int32 tl_rc = 0; int32 lvidx; int32 bufsize = 0; DDI_OS2LVM_param LVMpp; DDI_OS2LVM_param *pLVMpp = &LVMpp; DDI_OS2LVM_data LVMdp; DDI_OS2LVM_data *pLVMdp = &LVMdp; ULONG ppLen = 0; ULONG dpLen = 0; /* * initialize the LVM DosDevIOCtl parm and data packets */ pLVMpp->Command = REMOVE_TBL_ENTRY; pLVMpp->DriveUnit = 0; pLVMpp->TableNumber = thisrec->LV_table; pLVMdp->ReturnData = 0; pLVMdp->UserBuffer = NULL; /* * process each LV block contained in the given * FS block. * * N.B. We'll exit the loop if the DosDevIOCtl fails, * but not if the LVM fails to execute the request * successfully. */ for( lvidx = 0; ((lvidx < MAX_LVBLKS_PER_FSBLK) && (tl_rc == 0)); lvidx++ ) { if( thisrec->LV_blkno[lvidx] != 0 ) { /* * 0 can never be an actual LV block number * in this context since the 1st block in * the file system is NEVER relocated. */ /* * tell the LVM to forget this one */ pLVMpp->LSN = thisrec->LV_blkno[lvidx]; tl_rc = DosDevIOCtl( LVHandle, IOC_DC, IODC_LV, (void *) pLVMpp, sizeof(DDI_OS2LVM_param), &ppLen, (void *) pLVMdp, sizeof(DDI_OS2LVM_data), &dpLen ); } /* end if */ } /* end for lvidx = ... */ if( tl_rc != 0 ) { return( CBBL_LVMRC_7 - tl_rc ); } else { thisrec->LVM_notified = -1; agg_recptr->resolved_blocks += 1; } return( tl_rc ); } /* end tell_LVM() */
/*! Return the size of the CD in logical block address (LBA) units. */ static lsn_t get_disc_last_lsn_os2 (void *p_user_data) { _img_private_t *p_env = p_user_data; struct { UCHAR auch_sign[4]; } s_param = {{'C', 'D', '0', '1'}}; ULONG ul_data_volume_size; ULONG ul_param_len; ULONG ul_data_len; ULONG rc; rc = DosDevIOCtl( p_env->h_cd, IOCTL_CDROMDISK, CDROMDISK_GETVOLUMESIZE, &s_param, sizeof( s_param ), &ul_param_len, &ul_data_volume_size, sizeof( ul_data_volume_size ), &ul_data_len ); if( rc ) { cdio_warn("get_disc_last_lsn_os2 : DosDevIOCtl(GETVOLUMESIZE) = 0x%lx\n", rc ); return CDIO_INVALID_LSN; } return ul_data_volume_size; }
APIRET DosKillFastIo( PID pid ) { APIRET rc; HFILE hfd; ULONG action, plen; if(( rc = DosOpen((PSZ)"/dev/fastio$", (PHFILE)&hfd, (PULONG)&action, (ULONG)0, FILE_SYSTEM, FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, (ULONG)0)) != NO_ERROR ) { return rc; } if(( rc = DosDevIOCtl( hfd, (ULONG)0x76, (ULONG)0x65, (PULONG*)&pid, sizeof(USHORT), &plen, NULL, 0, NULL)) != 0 ) { DosClose( hfd ); return rc; } DosClose(hfd); return NO_ERROR; }
void main() { USHORT rc, Action; HFILE FileHandle; DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLC); DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_KILLPROCESS); DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLBREAK); DosSetPrty(PRTYS_PROCESS, PRTYC_IDLETIME, 0, 0); rc = DosOpen("Idlehlt$", &FileHandle, &Action, 0L, FILE_NORMAL, FILE_OPEN, OPEN_SHARE_DENYNONE, 0L); if(!rc) { while(!ExitWhile) DosDevIOCtl(NULL, NULL, 0x01, 0x91, FileHandle); DosClose(FileHandle); } else { char buf[6], Message[36] = "HLT Driver not installed? rc="; char *src = buf, *dst = &Message[29]; int len; utoa(rc, buf, 10); while(*dst++ = *src++); len = dst - Message; Message[len-1] = '\r'; Message[len] = '\n'; DosWrite(STDERR_FILENO, Message, len+1, &Action); } }