Changeset 21916 for trunk/src/kernel32/hmparport.cpp
- Timestamp:
- Dec 18, 2011, 10:28:22 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 bin 2 Makefile.inc 1 env.cmd 2 LocalConfig.kmk
-
-
Property svn:mergeinfo
set to
/branches/gcc-kmk merged eligible
- Property svn:ignore
-
trunk/src/kernel32/hmparport.cpp
r8404 r21916 60 60 61 61 #define MAX_PARALLEL_PORTS_CONFIGURATION 3 62 static PARALLELPORTCONFIGURATION arrParallelPorts[MAX_PARALLEL_PORTS_CONFIGURATION] = 62 static PARALLELPORTCONFIGURATION arrParallelPorts[MAX_PARALLEL_PORTS_CONFIGURATION] = 63 63 { 64 64 {1, 0x378, 8, 0x778, 3}, … … 71 71 { 72 72 ULONG ulMagic; 73 73 74 74 // Win32 Device Control Block 75 75 COMMCONFIG CommCfg; 76 76 77 77 // hardware configuration block 78 78 PPARALLELPORTCONFIGURATION pHardwareConfiguration; … … 83 83 static VOID *CreateDevData() 84 84 { 85 HFILE hfFileHandle = 0L; 86 UCHAR uchParms[2] = {0, RM_COMMAND_PHYS}; 87 ULONG ulParmLen = 0; 85 HFILE hfFileHandle = 0L; 86 UCHAR uchParms[2] = {0, RM_COMMAND_PHYS}; 87 ULONG ulParmLen = 0; 88 88 UCHAR uchDataArea[MAX_ENUM_SIZE] = {0}; 89 UCHAR uchDataArea2[MAX_RM_NODE_SIZE] = {0}; 90 ULONG ulDataLen = 0; 89 UCHAR uchDataArea2[MAX_RM_NODE_SIZE] = {0}; 90 ULONG ulDataLen = 0; 91 91 int rc,portCount = 0; 92 92 93 93 PRM_ENUMNODES_DATA enumData; 94 94 PNODEENTRY pNode; … … 105 105 } 106 106 else 107 { 107 { 108 108 dprintf(("HMDeviceParPortClass: Succesfully opened Resource Manager")); 109 109 … … 114 114 CAT_RM,FUNC_RM_ENUM_NODES, uchParms, sizeof(uchParms), 115 115 &ulParmLen, 116 uchDataArea, 117 sizeof(uchDataArea), 118 &ulDataLen); 119 116 uchDataArea, 117 sizeof(uchDataArea), 118 &ulDataLen); 119 120 120 if (rc) 121 121 { 122 dprintf(("HMDeviceParPortClass: Failed to get resource list (IOCTL)")); 122 dprintf(("HMDeviceParPortClass: Failed to get resource list (IOCTL)")); 123 123 goto resourceLoopEnd; 124 124 } 125 125 126 126 enumData = (PRM_ENUMNODES_DATA)uchDataArea; 127 127 128 128 inputData.RMHandle = enumData->NodeEntry[0].RMHandle; 129 129 inputData.Linaddr = (ULONG)&uchDataArea2[0]; 130 130 131 131 for (int i=0;i<enumData->NumEntries;i++) 132 132 { 133 133 ulParmLen = sizeof(inputData); /* Length of input parameters */ 134 134 ulDataLen = sizeof(uchDataArea2); /* Length of data */ 135 135 136 136 rc = OSLibDosDevIOCtl(hfFileHandle, /* Handle to device */ 137 137 CAT_RM,FUNC_RM_GET_NODEINFO, … … 146 146 if (rc) 147 147 { 148 dprintf(("HMDeviceParPortClass: Failed to get resource node (IOCTL)")); 149 break; 148 dprintf(("HMDeviceParPortClass: Failed to get resource node (IOCTL)")); 149 break; 150 150 } 151 151 inputData.RMHandle = enumData->NodeEntry[i].RMHandle; … … 163 163 // @@PF Hack, but what to do no ECP info from Resource Manager! 164 164 if (arrParallelPorts[portCount].ulPortBase == 0x378) 165 { 165 { 166 166 arrParallelPorts[portCount].ulEcpPortBase = 0x778; 167 167 arrParallelPorts[portCount].ulEcpPortSpan = 3; 168 168 } 169 else 169 else 170 170 if (arrParallelPorts[portCount].ulPortBase == 0x278) 171 { 171 { 172 172 arrParallelPorts[portCount].ulEcpPortBase = 0x678; 173 173 arrParallelPorts[portCount].ulEcpPortSpan = 3; … … 178 178 arrParallelPorts[portCount].ulEcpPortSpan = 0; 179 179 dprintf(("HMDeviceParPortClass: Found and registered LPT%d with Base I/O: 0x%x",portCount,arrParallelPorts[portCount].ulPortBase)); 180 portCount ++ ; 180 portCount ++ ; 181 181 } 182 182 } 183 183 } 184 184 resourceLoopEnd: 185 OSLibDosClose(hfFileHandle); 185 OSLibDosClose(hfFileHandle); 186 186 187 187 pData = new HMDEVPARPORTDATA(); … … 194 194 pData->CommCfg.dwProviderSubType = PST_PARALLELPORT; 195 195 } 196 196 197 197 return pData; 198 198 } 199 199 //****************************************************************************** 200 200 //****************************************************************************** 201 HMDeviceParPortClass::HMDeviceParPortClass(LPCSTR lpDeviceName) : 201 HMDeviceParPortClass::HMDeviceParPortClass(LPCSTR lpDeviceName) : 202 202 HMDeviceHandler(lpDeviceName) 203 203 { 204 204 dprintf(("HMDeviceParPortClass::HMDevParPortClass(%s)\n", 205 205 lpDeviceName)); 206 206 207 207 #ifndef DEVINFO_PRINTER 208 208 #define DEVINFO_PRINTER 0 209 209 #endif 210 210 211 211 // first, we determine the number of parallel port devices available 212 212 213 213 // PH 2001-12-04 Note: 214 214 // This call will not return any information about redirected LPT ports. … … 223 223 if (0 == bNumberOfParallelPorts) 224 224 return; 225 225 226 226 VOID *pData; 227 227 dprintf(("HMDeviceParPortClass: Registering LPTs with Handle Manager\n")); 228 228 229 229 pData = CreateDevData(); 230 230 if(pData!= NULL) 231 231 HMDeviceRegisterEx("LPT1", this, pData); 232 232 233 233 // add symbolic links to the "real name" of the device 234 234 if (bNumberOfParallelPorts > 0) … … 246 246 free(pszLPT); 247 247 free(pszLPT2); 248 248 249 249 // add "PRN" device 250 250 HandleNamesAddSymbolicLink("PRN", "LPT1"); … … 272 272 if (bNumberOfParallelPorts == 0) 273 273 return FALSE; 274 274 275 275 // can be both, "LPT1" and "LPT1:" 276 276 if(namelength > 5) … … 283 283 if(namelength == 5 && lpDeviceName[4] != ':') 284 284 return FALSE; 285 285 286 286 // can support up tp LPT9 287 287 if ( (lpDeviceName[3] >= '1') && … … 305 305 lpSecurityAttributes, 306 306 pHMHandleDataTemplate)); 307 307 308 308 char lptname[6]; 309 309 310 310 dprintf(("HMDeviceParPortClass: Parallel port %s open request\n", lpFileName)); 311 311 312 312 // Don't accept any name if no parallel ports have been detected 313 313 if (bNumberOfParallelPorts == 0) … … 315 315 return ERROR_DEV_NOT_EXIST; 316 316 } 317 317 318 318 strcpy(lptname, lpFileName); 319 319 lptname[4] = 0; //get rid of : (if present) (eg LPT1:) … … 326 326 OSLIB_ACCESS_SHAREDENYWRITE); 327 327 SetErrorMode(oldmode); 328 328 329 329 // check if handle could be opened properly 330 330 if (0 == pHMHandleData->hHMHandle) … … 337 337 APIRET rc; 338 338 pHMHandleData->lpHandlerData = new HMDEVPARPORTDATA(); 339 339 340 340 // Init The handle instance with the default default device config 341 341 memcpy( pHMHandleData->lpHandlerData, 342 342 pHMHandleData->lpDeviceData, 343 343 sizeof(HMDEVPARPORTDATA)); 344 344 345 345 // determine which port was opened 346 346 ULONG ulPortNo = lptname[3] - '1'; 347 347 348 348 // safety check (device no 0..8 -> LPT1..9) 349 349 if (ulPortNo > MAX_PARALLEL_PORTS_CONFIGURATION) … … 352 352 return ERROR_DEV_NOT_EXIST; 353 353 } 354 354 355 355 // and save the hardware information 356 356 PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData; 357 357 pPPD->pHardwareConfiguration = &arrParallelPorts[ulPortNo]; 358 358 359 359 return NO_ERROR; 360 360 } … … 387 387 dprintf(("HMDeviceParPortClass: Parallel port close request(%08xh)\n", 388 388 pHMHandleData)); 389 390 delete pHMHandleData->lpHandlerData;389 390 delete (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData; 391 391 return OSLibDosClose(pHMHandleData->hHMHandle); 392 392 } … … 511 511 //****************************************************************************** 512 512 //****************************************************************************** 513 BOOL HMDeviceParPortClass::DeviceIoControl(PHMHANDLEDATA pHMHandleData, 513 BOOL HMDeviceParPortClass::DeviceIoControl(PHMHANDLEDATA pHMHandleData, 514 514 DWORD dwIoControlCode, 515 LPVOID lpInBuffer, 515 LPVOID lpInBuffer, 516 516 DWORD nInBufferSize, 517 LPVOID lpOutBuffer, 517 LPVOID lpOutBuffer, 518 518 DWORD nOutBufferSize, 519 LPDWORD lpBytesReturned, 519 LPDWORD lpBytesReturned, 520 520 LPOVERLAPPED lpOverlapped) 521 521 { 522 522 #ifdef DEBUG 523 c har *msg = NULL;523 const char *msg = NULL; 524 524 525 525 switch(dwIoControlCode) … … 528 528 msg = "IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO"; 529 529 break; 530 530 531 531 case IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO: 532 532 msg = "IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO"; 533 533 break; 534 534 } 535 535 536 536 if(msg) { 537 537 dprintf(("HMDeviceParPortClass::DeviceIoControl %s %x %d %x %d %x %x", msg, lpInBuffer, nInBufferSize, … … 545 545 { 546 546 PPARALLEL_PORT_INFORMATION pPPI = (PPARALLEL_PORT_INFORMATION)lpOutBuffer; 547 548 if(nOutBufferSize < sizeof(PARALLEL_PORT_INFORMATION) || !pPPI) 547 548 if(nOutBufferSize < sizeof(PARALLEL_PORT_INFORMATION) || !pPPI) 549 549 { 550 550 SetLastError(ERROR_INSUFFICIENT_BUFFER); 551 551 return FALSE; 552 552 } 553 553 554 554 if(lpBytesReturned) 555 555 *lpBytesReturned = sizeof(PARALLEL_PORT_INFORMATION); 556 556 557 557 // fill in the data values 558 558 PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData; 559 559 560 560 // @@@PH 561 561 // Specifies the bus relative base I/O address of the parallel port registers. 562 562 pPPI->OriginalController.LowPart = pPPD->pHardwareConfiguration->ulPortBase; 563 563 pPPI->OriginalController.HighPart = 0; 564 564 565 565 // Pointer to the system-mapped base I/O location of the parallel port registers. 566 566 pPPI->Controller = NULL; 567 567 568 568 // Specifies the size, in bytes, of the I/O space, allocated to the parallel port. 569 569 pPPI->SpanOfController = pPPD->pHardwareConfiguration->ulPortSpan; 570 570 571 571 // Pointer to a callback routine that a kernel-mode driver can use to try to allocate the parallel port. 572 572 pPPI->TryAllocatePort = NULL; 573 573 574 574 // Pointer to a callback routine that a kernel-mode driver can use to free the parallel port. 575 575 pPPI->FreePort = NULL; 576 576 577 577 // Pointer to a callback routine that a kernel-mode driver can use to determine the number of requests on the work queue of the parallel port. 578 578 pPPI->QueryNumWaiters = NULL; 579 579 580 580 // Pointer to the device extension of parallel port. 581 581 pPPI->Context = NULL; … … 583 583 return TRUE; 584 584 } 585 586 585 586 587 587 case IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO: 588 588 { 589 589 PPARALLEL_PNP_INFORMATION pPPI = (PPARALLEL_PNP_INFORMATION)lpOutBuffer; 590 590 591 591 if(nOutBufferSize < sizeof(PARALLEL_PNP_INFORMATION) || !pPPI) 592 592 { … … 594 594 return FALSE; 595 595 } 596 596 597 597 if(lpBytesReturned) 598 598 *lpBytesReturned = sizeof(PARALLEL_PNP_INFORMATION); 599 599 600 600 // fill in the data values 601 601 PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData; 602 602 603 603 // @@@PH 604 // Specifies the base physical address that the system-supplied 605 // function driver for parallel ports uses to control the ECP 604 // Specifies the base physical address that the system-supplied 605 // function driver for parallel ports uses to control the ECP 606 606 // operation of the parallel port. 607 607 pPPI->OriginalEcpController.LowPart = pPPD->pHardwareConfiguration->ulEcpPortBase; 608 608 pPPI->OriginalEcpController.HighPart = 0; 609 610 // Pointer to the I/O port resource that is used to control the 609 610 // Pointer to the I/O port resource that is used to control the 611 611 // port in ECP mode. 612 612 pPPI->EcpController = NULL; 613 613 614 614 // Specifies the size, in bytes, of the I/O port resource. 615 615 pPPI->SpanOfEcpController = pPPD->pHardwareConfiguration->ulEcpPortSpan; 616 616 617 617 // Not used. 618 618 pPPI->PortNumber = 0; 619 619 620 620 // Specifies the hardware capabilities of the parallel port. The following capabilities can be set using a bitwise OR of the following constants: 621 621 pPPI->HardwareCapabilities = 0; … … 626 626 // PPT_EPP_PRESENT 627 627 // PT_NO_HARDWARE_PRESENT 628 628 629 629 // Pointer to a callback routine that a kernel-mode driver can use to change the operating mode of the parallel port. 630 630 pPPI->TrySetChipMode = 0; 631 631 632 632 // Pointer to a callback routine that a kernel-mode driver can use to clear the operating mode of the parallel port. 633 633 pPPI->ClearChipMode = 0; 634 634 635 635 // Specifies the size, in words, of the hardware first in/first out (FIFO) buffer. The FIFO word size, in bits, is the value of FifoWidth. 636 636 pPPI->FifoDepth = 0; 637 637 638 638 // Specifies the FIFO word size, in bits, which is the number of bits handled in parallel. 639 639 pPPI->FifoWidth = 0; 640 640 641 641 // Not used. 642 642 pPPI->EppControllerPhysicalAddress.LowPart = 0; 643 643 pPPI->EppControllerPhysicalAddress.HighPart = 0; 644 644 645 645 // Not used. 646 646 pPPI->SpanOfEppController = 0; 647 647 648 648 // Specifies the number of daisy-chain devices currently attached to a parallel port. In Microsoftÿ Windowsÿ XP, from zero to two devices can be simultaneously connected to a 649 649 // parallel port. In Windows 2000, from zero to four devices can be simultaneously connected to a parallel port. 650 650 pPPI->Ieee1284_3DeviceCount = 0; 651 651 652 652 // Pointer to a callback routine that a kernel-mode driver can use to try to select an IEEE 1284.3 device. 653 653 pPPI->TrySelectDevice = 0; 654 654 655 655 // Pointer to a callback routine that a kernel-mode driver can use to deselect an IEEE 1284.3 device. 656 656 pPPI->DeselectDevice = 0; 657 657 658 658 // Pointer to the device extension of a parallel port's function device object (FDO). 659 659 pPPI->Context = 0; 660 660 661 661 // The current operating mode of the parallel port. 662 662 pPPI->CurrentMode = 0; 663 663 664 664 // The symbolic link name of the parallel port. 665 665 pPPI->PortName = 0; 666 666 667 667 return TRUE; 668 668 }
Note:
See TracChangeset
for help on using the changeset viewer.