Changeset 7542 for trunk/src/kernel32/hmparport.cpp
- Timestamp:
- Dec 4, 2001, 1:58:02 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmparport.cpp
r7538 r7542 1 /* $Id: hmparport.cpp,v 1.1 4 2001-12-04 00:07:25phaller Exp $ */1 /* $Id: hmparport.cpp,v 1.15 2001-12-04 12:56:52 phaller Exp $ */ 2 2 3 3 /* … … 91 91 92 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. 93 // @@@PH better query the Resource Manager 95 94 typedef struct tagParallelPortConfiguration 96 95 { … … 98 97 ULONG ulPortBase; 99 98 ULONG ulPortSpan; 99 ULONG ulEcpPortBase; 100 ULONG ulEcpPortSpan; 100 101 } PARALLELPORTCONFIGURATION, *PPARALLELPORTCONFIGURATION; 101 102 102 #define NUM_PARALLELPORTS 3 103 static PARALLELPORTCONFIGURATION arrParallelPorts[NUM_PARALLELPORTS] = { 104 {1, 0x378, 8}, 105 {2, 0x278, 8}, 106 {3, 0x3bc, 8} 103 #define MAX_PARALLEL_PORTS_CONFIGURATION 3 104 static PARALLELPORTCONFIGURATION arrParallelPorts[MAX_PARALLEL_PORTS_CONFIGURATION] = 105 { 106 {1, 0x378, 8, 0x778, 3}, 107 {2, 0x278, 8, 0x678, 3}, 108 {3, 0x3bc, 8, 0x000, 0} 107 109 }; 108 110 … … 135 137 136 138 137 HMDeviceParPortClass::HMDeviceParPortClass(LPCSTR lpDeviceName) : HMDeviceHandler(lpDeviceName) 139 HMDeviceParPortClass::HMDeviceParPortClass(LPCSTR lpDeviceName) : 140 HMDeviceHandler(lpDeviceName) 138 141 { 139 142 dprintf(("HMDeviceParPortClass::HMDevParPortClass(%s)\n", … … 145 148 146 149 // first, we determine the number of parallel port devices available 147 BYTE bParallelPorts = NUM_PARALLELPORTS; 148 149 #if 0 150 // Note: 151 // OSLibDosDevConfig does *NOT* report any OS/2 related information 152 // about the parallel ports such as LPT redirections or even an 153 // installed LPT device driver, it appears to just report what the 154 // BIOS told. 155 156 DWORD rc = OSLibDosDevConfig(&bParallelPorts, 150 151 // PH 2001-12-04 Note: 152 // This call will not return any information about redirected LPT ports. 153 // We have a specific application requiring exactly this behaviour as it 154 // cannot talk to redirected LPTs anyway. 155 // For any change in this behaviour, we'd require a configuration switch. 156 bNumberOfParallelPorts = 0; 157 DWORD rc = OSLibDosDevConfig(&bNumberOfParallelPorts, 157 158 DEVINFO_PRINTER); 158 159 dprintf(("HMDeviceParPortClass: Parallel ports reported: %d\n", 159 b ParallelPorts));160 if (0 == b ParallelPorts)160 bNumberOfParallelPorts)); 161 if (0 == bNumberOfParallelPorts) 161 162 return; 162 163 // @@@PH164 // query configuration data from Resource Manager165 // (base i/o ports, etc. for the IOCTL_INTERNAL_GET_xxx)166 #endif167 163 168 164 VOID *pData; … … 174 170 175 171 // add symbolic links to the "real name" of the device 172 if (bNumberOfParallelPorts > 0) 176 173 { 177 174 // Note: \\.\LPTx: is invalid (NT4SP6) 178 175 PSZ pszLPT = strdup("\\\\.\\LPTx"); 179 176 PSZ pszLPT2 = strdup("\\Device\\ParallelPort0"); 180 for (char ch = '1'; ch <= '1' + (b ParallelPorts - 1); ch++)177 for (char ch = '1'; ch <= '1' + (bNumberOfParallelPorts - 1); ch++) 181 178 { 182 179 pszLPT[7] = ch; … … 210 207 BOOL HMDeviceParPortClass::FindDevice(LPCSTR lpClassDevName, LPCSTR lpDeviceName, int namelength) 211 208 { 209 // Don't accept any name if no parallel ports have been detected 210 if (bNumberOfParallelPorts == 0) 211 return FALSE; 212 212 213 // can be both, "LPT1" and "LPT1:" 213 if(namelength > 5) 214 return FALSE; //can't be lpt name 215 216 //first 3 letters 'LPT'? 217 if(lstrncmpiA(lpDeviceName, lpClassDevName, 3) != 0) { 218 return FALSE; 219 } 220 221 if(namelength == 5 && lpDeviceName[4] != ':') { 222 return FALSE; 223 } 224 225 // can support up tp LPT9 226 if ( (lpDeviceName[3] >= '1') && 227 (lpDeviceName[3] <= '1' + NUM_PARALLELPORTS) ) 228 { 229 return TRUE; 230 } 231 232 return FALSE; 214 if(namelength > 5) 215 return FALSE; //can't be lpt name 216 217 //first 3 letters 'LPT'? 218 if(lstrncmpiA(lpDeviceName, lpClassDevName, 3) != 0) 219 return FALSE; 220 221 if(namelength == 5 && lpDeviceName[4] != ':') 222 return FALSE; 223 224 // can support up tp LPT9 225 if ( (lpDeviceName[3] >= '1') && 226 (lpDeviceName[3] <= '1' + bNumberOfParallelPorts) ) 227 { 228 return TRUE; 229 } 230 231 return FALSE; 233 232 } 234 233 … … 245 244 pHMHandleDataTemplate)); 246 245 247 char lptname[6];246 char lptname[6]; 248 247 249 248 dprintf(("HMDeviceParPortClass: Parallel port %s open request\n", lpFileName)); 250 249 250 // Don't accept any name if no parallel ports have been detected 251 if (bNumberOfParallelPorts == 0) 252 { 253 return ERROR_DEV_NOT_EXIST; 254 } 255 251 256 strcpy(lptname, lpFileName); 252 257 lptname[4] = 0; //get rid of : (if present) (eg LPT1:) … … 280 285 281 286 // safety check (device no 0..8 -> LPT1..9) 282 if (ulPortNo > 8)287 if (ulPortNo > MAX_PARALLEL_PORTS_CONFIGURATION) 283 288 { 284 delete pHMHandleData->lpHandlerData;289 HMDeviceParPortClass::CloseHandle(pHMHandleData); 285 290 return ERROR_DEV_NOT_EXIST; 286 291 } … … 719 724 // function driver for parallel ports uses to control the ECP 720 725 // operation of the parallel port. 721 pPPI->OriginalEcpController.LowPart = pPPD->pHardwareConfiguration->ul PortBase;726 pPPI->OriginalEcpController.LowPart = pPPD->pHardwareConfiguration->ulEcpPortBase; 722 727 pPPI->OriginalEcpController.HighPart = 0; 723 728 … … 727 732 728 733 // Specifies the size, in bytes, of the I/O port resource. 729 pPPI->SpanOfEcpController = pPPD->pHardwareConfiguration->ul PortSpan;734 pPPI->SpanOfEcpController = pPPD->pHardwareConfiguration->ulEcpPortSpan; 730 735 731 736 // Not used.
Note:
See TracChangeset
for help on using the changeset viewer.