Changeset 8404 for trunk/src/kernel32/hmparport.cpp
- Timestamp:
- May 13, 2002, 2:12:42 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmparport.cpp
r7564 r8404 1 /* $Id: hmparport.cpp,v 1.1 8 2001-12-07 11:28:10sandervl Exp $ */1 /* $Id: hmparport.cpp,v 1.19 2002-05-13 12:12:42 sandervl Exp $ */ 2 2 3 3 /* … … 21 21 #include "hmparport.h" 22 22 #include "oslibdos.h" 23 23 #include "rmioctl.h" 24 24 #define DBG_LOCALLOG DBG_hmparport 25 25 #include "dbglocal.h" … … 49 49 50 50 // Hardwired parallel port configuration information. 51 // @@@PH better query the Resource Manager51 // for the cases where real thing will fail 52 52 typedef struct tagParallelPortConfiguration 53 53 { … … 83 83 static VOID *CreateDevData() 84 84 { 85 PHMDEVPARPORTDATA pData; 86 pData = new HMDEVPARPORTDATA(); 87 if(NULL!=pData) 88 { 89 memset(pData,0,sizeof(HMDEVPARPORTDATA)); 90 pData->ulMagic = MAGIC_PARPORT; 91 pData->CommCfg.dwSize = sizeof(COMMCONFIG); 92 pData->CommCfg.wVersion = 1; 93 pData->CommCfg.dwProviderSubType = PST_PARALLELPORT; 94 } 95 return pData; 85 HFILE hfFileHandle = 0L; 86 UCHAR uchParms[2] = {0, RM_COMMAND_PHYS}; 87 ULONG ulParmLen = 0; 88 UCHAR uchDataArea[MAX_ENUM_SIZE] = {0}; 89 UCHAR uchDataArea2[MAX_RM_NODE_SIZE] = {0}; 90 ULONG ulDataLen = 0; 91 int rc,portCount = 0; 92 93 PRM_ENUMNODES_DATA enumData; 94 PNODEENTRY pNode; 95 RM_GETNODE_PARM inputData; 96 PRM_GETNODE_DATA poutputData; 97 PHMDEVPARPORTDATA pData; 98 99 hfFileHandle = OSLibDosOpen("RESMGR$", 100 OSLIB_ACCESS_READWRITE | 101 OSLIB_ACCESS_SHAREDENYNONE); 102 103 if (!hfFileHandle) { 104 dprintf(("HMDeviceParPortClass: Failed to open Resource Manager device %d\n", GetLastError())); 105 } 106 else 107 { 108 dprintf(("HMDeviceParPortClass: Succesfully opened Resource Manager")); 109 110 ulParmLen = sizeof(uchParms); /* Length of input parameters */ 111 ulDataLen = sizeof(uchDataArea); /* Length of data */ 112 113 rc = OSLibDosDevIOCtl(hfFileHandle, /* Handle to device */ 114 CAT_RM,FUNC_RM_ENUM_NODES, uchParms, sizeof(uchParms), 115 &ulParmLen, 116 uchDataArea, 117 sizeof(uchDataArea), 118 &ulDataLen); 119 120 if (rc) 121 { 122 dprintf(("HMDeviceParPortClass: Failed to get resource list (IOCTL)")); 123 goto resourceLoopEnd; 124 } 125 126 enumData = (PRM_ENUMNODES_DATA)uchDataArea; 127 128 inputData.RMHandle = enumData->NodeEntry[0].RMHandle; 129 inputData.Linaddr = (ULONG)&uchDataArea2[0]; 130 131 for (int i=0;i<enumData->NumEntries;i++) 132 { 133 ulParmLen = sizeof(inputData); /* Length of input parameters */ 134 ulDataLen = sizeof(uchDataArea2); /* Length of data */ 135 136 rc = OSLibDosDevIOCtl(hfFileHandle, /* Handle to device */ 137 CAT_RM,FUNC_RM_GET_NODEINFO, 138 &inputData, /* Input/Output parameter list */ 139 sizeof(inputData), /* Maximum output parameter size */ 140 &ulParmLen, /* Input: size of parameter list */ 141 /* Output: size of parameters returned */ 142 uchDataArea2, /* Input/Output data area */ 143 sizeof(uchDataArea2), /* Maximum output data size */ 144 &ulDataLen); /* Input: size of input data area */ 145 /* Output: size of data returned */ 146 if (rc) 147 { 148 dprintf(("HMDeviceParPortClass: Failed to get resource node (IOCTL)")); 149 break; 150 } 151 inputData.RMHandle = enumData->NodeEntry[i].RMHandle; 152 poutputData = (PRM_GETNODE_DATA) uchDataArea2; 153 // @@PF Ports always follow numbering i.e. LPT0,LPT1, etc so 154 // no sorting needed 155 if ( (poutputData->RMNode.pAdapterNode->AdaptDescriptName) && 156 (lstrncmpiA(poutputData->RMNode.pAdapterNode->AdaptDescriptName,"PARALLEL",8) == 0) && 157 (poutputData->RMNode.pResourceList->Resource[0].ResourceType == RS_TYPE_IO) ) 158 { 159 if (!portCount) memset(arrParallelPorts,0,sizeof(arrParallelPorts)); 160 arrParallelPorts[portCount].ulNumber = portCount; 161 arrParallelPorts[portCount].ulPortBase = poutputData->RMNode.pResourceList->Resource[0].IOResource.BaseIOPort; 162 arrParallelPorts[portCount].ulPortSpan = 8; 163 // @@PF Hack, but what to do no ECP info from Resource Manager! 164 if (arrParallelPorts[portCount].ulPortBase == 0x378) 165 { 166 arrParallelPorts[portCount].ulEcpPortBase = 0x778; 167 arrParallelPorts[portCount].ulEcpPortSpan = 3; 168 } 169 else 170 if (arrParallelPorts[portCount].ulPortBase == 0x278) 171 { 172 arrParallelPorts[portCount].ulEcpPortBase = 0x678; 173 arrParallelPorts[portCount].ulEcpPortSpan = 3; 174 } 175 else 176 arrParallelPorts[portCount].ulEcpPortBase = 0; 177 178 arrParallelPorts[portCount].ulEcpPortSpan = 0; 179 dprintf(("HMDeviceParPortClass: Found and registered LPT%d with Base I/O: 0x%x",portCount,arrParallelPorts[portCount].ulPortBase)); 180 portCount ++ ; 181 } 182 } 183 } 184 resourceLoopEnd: 185 OSLibDosClose(hfFileHandle); 186 187 pData = new HMDEVPARPORTDATA(); 188 if(NULL!=pData) 189 { 190 memset(pData,0,sizeof(HMDEVPARPORTDATA)); 191 pData->ulMagic = MAGIC_PARPORT; 192 pData->CommCfg.dwSize = sizeof(COMMCONFIG); 193 pData->CommCfg.wVersion = 1; 194 pData->CommCfg.dwProviderSubType = PST_PARALLELPORT; 195 } 196 197 return pData; 96 198 } 97 199 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.