Changeset 7538 for trunk/src/kernel32/hmparport.cpp
- Timestamp:
- Dec 4, 2001, 1:07:59 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmparport.cpp
r7483 r7538 1 /* $Id: hmparport.cpp,v 1.1 3 2001-11-29 10:58:44phaller Exp $ */1 /* $Id: hmparport.cpp,v 1.14 2001-12-04 00:07:25 phaller Exp $ */ 2 2 3 3 /* … … 90 90 91 91 92 #if 0 93 94 typedef struct _PARALLEL_PNP_INFORMATION { 95 PHYSICAL_ADDRESS OriginalEcpController; 96 PUCHAR EcpController; 97 ULONG SpanOfEcpController; 98 ULONG PortNumber; 99 ULONG HardwareCapabilities; 100 PPARALLEL_SET_CHIP_MODE TrySetChipMode; 101 PPARALLEL_CLEAR_CHIP_MODE ClearChipMode; 102 ULONG FifoDepth; 103 ULONG FifoWidth; 104 PHYSICAL_ADDRESS EppControllerPhysicalAddress; 105 ULONG SpanOfEppController; 106 ULONG Ieee1284_3DeviceCount; 107 PPARALLEL_TRY_SELECT_ROUTINE TrySelectDevice; 108 PPARALLEL_DESELECT_ROUTINE DeselectDevice; 109 PVOID Context; 110 ULONG CurrentMode; 111 PWSTR PortName; 112 } PARALLEL_PNP_INFORMATION, *PPARALLEL_PNP_INFORMATION; 113 #endif 114 92 // Hardwired parallel port configuration information. 93 // Yet unsure if it's beneficial to query Resource Manager 94 // for these values as direct port i/o is not allowed anyway. 95 typedef struct tagParallelPortConfiguration 96 { 97 ULONG ulNumber; 98 ULONG ulPortBase; 99 ULONG ulPortSpan; 100 } PARALLELPORTCONFIGURATION, *PPARALLELPORTCONFIGURATION; 101 102 #define NUM_PARALLELPORTS 3 103 static PARALLELPORTCONFIGURATION arrParallelPorts[NUM_PARALLELPORTS] = { 104 {1, 0x378, 8}, 105 {2, 0x278, 8}, 106 {3, 0x3bc, 8} 107 }; 115 108 116 109 … … 118 111 { 119 112 ULONG ulMagic; 113 120 114 // Win32 Device Control Block 121 115 COMMCONFIG CommCfg; 122 //OS/2 Device Control Block 116 117 // hardware configuration block 118 PPARALLELPORTCONFIGURATION pHardwareConfiguration; 123 119 } HMDEVPARPORTDATA, *PHMDEVPARPORTDATA; 124 120 … … 149 145 150 146 // first, we determine the number of parallel port devices available 151 BYTE bParallelPorts = 9;147 BYTE bParallelPorts = NUM_PARALLELPORTS; 152 148 153 149 #if 0 … … 181 177 // Note: \\.\LPTx: is invalid (NT4SP6) 182 178 PSZ pszLPT = strdup("\\\\.\\LPTx"); 183 PSZ pszLPT2 = strdup("\\Device\\ParallelPort 1");179 PSZ pszLPT2 = strdup("\\Device\\ParallelPort0"); 184 180 for (char ch = '1'; ch <= '1' + (bParallelPorts - 1); ch++) 185 181 { 186 182 pszLPT[7] = ch; 187 pszLPT2[20] = ch ;183 pszLPT2[20] = ch - 1; // \DeviceParallelPort0 -> LPT1 188 184 HandleNamesAddSymbolicLink(pszLPT, pszLPT+4); 189 185 HandleNamesAddSymbolicLink(pszLPT2, pszLPT+4); … … 226 222 return FALSE; 227 223 } 228 switch(lpDeviceName[3]) { 229 case '1': 230 case '2': 231 case '3': 232 return TRUE; //we support up to LPT3 224 225 // can support up tp LPT9 226 if ( (lpDeviceName[3] >= '1') && 227 (lpDeviceName[3] <= '1' + NUM_PARALLELPORTS) ) 228 { 229 return TRUE; 233 230 } 231 234 232 return FALSE; 235 233 } … … 265 263 if (0 == pHMHandleData->hHMHandle) 266 264 { 267 // @@@PH we need to get an OS/2 return code from OSLibDosOpen!268 // and translate it via error2WinError269 265 return ERROR_ACCESS_DENIED; // signal failure 270 266 } 271 272 #if 0 273 if (pHMHandleData->hHMHandle != 0) 267 else 274 268 { 275 269 ULONG ulLen; 276 270 APIRET rc; 277 271 pHMHandleData->lpHandlerData = new HMDEVPARPORTDATA(); 272 278 273 // Init The handle instance with the default default device config 279 274 memcpy( pHMHandleData->lpHandlerData, … … 281 276 sizeof(HMDEVPARPORTDATA)); 282 277 283 ulLen = sizeof(DCBINFO); 284 285 rc = OSLibDosDevIOCtl( pHMHandleData->hHMHandle, 286 IOCTL_ASYNC, 287 ASYNC_GETDCBINFO, 288 0,0,0, 289 &((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2,ulLen,&ulLen); 290 dprintf(("DCB Of %s :\n" 291 " WriteTimeout : %d\n" 292 " ReadTimeout : %d\n" 293 " CtlHandshake : 0x%x\n" 294 " FlowReplace : 0x%x\n" 295 " Timeout : 0x%x\n" 296 " Error replacement Char : 0x%x\n" 297 " Break replacement Char : 0x%x\n" 298 " XON Char : 0x%x\n" 299 " XOFF Char : 0x%x\n", 300 lptname, 301 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.usWriteTimeout, 302 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.usReadTimeout, 303 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.fbCtlHndShake, 304 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.fbFlowReplace, 305 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.fbTimeOut, 306 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.bErrorReplacementChar, 307 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.bBreakReplacementChar, 308 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.bXONChar, 309 ((PHMDEVCOMDATA)pHMHandleData->lpHandlerData)->dcbOS2.bXOFFChar)); 310 311 if(rc) 278 // determine which port was opened 279 ULONG ulPortNo = lptname[3] - '1'; 280 281 // safety check (device no 0..8 -> LPT1..9) 282 if (ulPortNo > 8) 312 283 { 313 return -1; 284 delete pHMHandleData->lpHandlerData; 285 return ERROR_DEV_NOT_EXIST; 314 286 } 315 rc = SetBaud(pHMHandleData,9600); 316 dprintf(("Init Baud to 9600 rc = %d",rc)); 317 rc = SetLine(pHMHandleData,8,0,0); 318 dprintf(("Set Line to 8/N/1 rc = %d",rc)); 319 return 0; 320 } 321 else 322 return -1; 323 #endif 324 325 return NO_ERROR; 287 288 // and save the hardware information 289 PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData; 290 pPPD->pHardwareConfiguration = &arrParallelPorts[ulPortNo]; 291 292 return NO_ERROR; 293 } 326 294 } 327 295 … … 331 299 { 332 300 dprintf(("HMDeviceParPortClass: Parallel port close request(%08xh)\n", 333 pHMHandleData)); 301 pHMHandleData)); 302 334 303 delete pHMHandleData->lpHandlerData; 335 304 return OSLibDosClose(pHMHandleData->hHMHandle); … … 701 670 702 671 // fill in the data values 703 672 PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData; 673 674 // @@@PH 704 675 // Specifies the bus relative base I/O address of the parallel port registers. 705 pPPI->OriginalController.LowPart = 0; // @@@PH706 pPPI->OriginalController.HighPart = 0; // @@@PH676 pPPI->OriginalController.LowPart = pPPD->pHardwareConfiguration->ulPortBase; 677 pPPI->OriginalController.HighPart = 0; 707 678 708 679 // Pointer to the system-mapped base I/O location of the parallel port registers. 709 pPPI->Controller = 0; // @@@PH680 pPPI->Controller = NULL; 710 681 711 682 // Specifies the size, in bytes, of the I/O space, allocated to the parallel port. 712 pPPI->SpanOfController = 0; // @@@PH683 pPPI->SpanOfController = pPPD->pHardwareConfiguration->ulPortSpan; 713 684 714 685 // Pointer to a callback routine that a kernel-mode driver can use to try to allocate the parallel port. … … 742 713 743 714 // fill in the data values 744 745 // Specifies the base physical address that the system-supplied function driver for parallel ports uses to control the ECP operation of the parallel port. 746 pPPI->OriginalEcpController.LowPart = 0; 715 PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData; 716 717 // @@@PH 718 // Specifies the base physical address that the system-supplied 719 // function driver for parallel ports uses to control the ECP 720 // operation of the parallel port. 721 pPPI->OriginalEcpController.LowPart = pPPD->pHardwareConfiguration->ulPortBase; 747 722 pPPI->OriginalEcpController.HighPart = 0; 748 723 749 // Pointer to the I/O port resource that is used to control the port in ECP mode. 750 pPPI->EcpController = 0; 724 // Pointer to the I/O port resource that is used to control the 725 // port in ECP mode. 726 pPPI->EcpController = NULL; 751 727 752 728 // Specifies the size, in bytes, of the I/O port resource. 753 pPPI->SpanOfEcpController = 0;729 pPPI->SpanOfEcpController = pPPD->pHardwareConfiguration->ulPortSpan; 754 730 755 731 // Not used.
Note:
See TracChangeset
for help on using the changeset viewer.