Changeset 679 for GPL/trunk/drv32/rmhelp.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/drv32/rmhelp.c
r587 r679 13 13 #include <os2.h> 14 14 15 #include <devhelp.h> 16 #include <devinfo.h> 17 18 #include <rmbase.h> // Resource manager definitions. 19 #include "rmcalls.h" 20 #include <rmioctl.h> 21 15 #include <devtype.h> 16 #include <stacktoflat.h> 22 17 #include <version.h> 23 18 #include <dbgos2.h> 24 #include <unicard.h>25 19 #include <osspci.h> 26 20 #include <ossidc32.h> 21 #include <string.h> 22 #include "rmbase.h" // Resource manager definitions. 23 #include "rmcalls.h" 27 24 #include "pciids.h" 28 25 29 #include <string.h>30 31 26 #define MAX_RESHANDLES 16 32 27 33 //****************************************************************************** 34 35 //extern PFN RM_Help; 36 //extern PFN RM_Help0; 37 //extern PFN RM_Help3; 38 //extern ULONG RMFlags; 39 40 static HDRIVER DriverHandle = (HDRIVER)-1; 41 static HDEVICE DeviceHandle = 0; 28 static HDRIVER DriverHandle = (HDRIVER)-1; 42 29 static HADAPTER AdapterHandle = 0; 43 static ULONG ctResHandles = 0; 44 static HRESOURCE arResHandles[MAX_RESHANDLES]; 45 46 //****************************************************************************** 47 VOID RMInit(VOID) 48 { 49 APIRET rc; 50 HDRIVER hDriver; 51 DRIVERSTRUCT DriverStruct; 52 char DriverName[sizeof(RM_DRIVER_NAME)]; 53 char VendorName[sizeof(RM_DRIVER_VENDORNAME)]; 54 char DriverDesc[sizeof(RM_DRIVER_DESCRIPTION)]; 55 56 if( DriverHandle == (HDRIVER)-1 ) 57 { 58 memset( (PVOID) &DriverStruct, 0, sizeof(DriverStruct) ); 59 60 //copy strings to stack, because we need to give RM 16:16 pointers 61 //(which can only be (easily) generated from 32 bits stack addresses) 62 strcpy(DriverName, RM_DRIVER_NAME); 63 strcpy(VendorName, RM_DRIVER_VENDORNAME); 64 strcpy(DriverDesc, RM_DRIVER_DESCRIPTION); 65 66 DriverStruct.DrvrName = FlatToSel((ULONG)DriverName); /* ### IHV */ 67 DriverStruct.DrvrDescript = FlatToSel((ULONG)DriverDesc); /* ### IHV */ 68 DriverStruct.VendorName = FlatToSel((ULONG)VendorName); /* ### IHV */ 69 DriverStruct.MajorVer = CMVERSION_MAJOR; //rmbase.h /* ### IHV */ 70 DriverStruct.MinorVer = CMVERSION_MINOR; //rmbase.h /* ### IHV */ 71 DriverStruct.Date.Year = RM_DRIVER_BUILDYEAR; /* ### IHV */ 72 DriverStruct.Date.Month = RM_DRIVER_BUILDMONTH; /* ### IHV */ 73 DriverStruct.Date.Day = RM_DRIVER_BUILDDAY; /* ### IHV */ 74 DriverStruct.DrvrType = DRT_AUDIO; 75 DriverStruct.DrvrSubType = 0; 76 DriverStruct.DrvrCallback = 0; 77 78 rc = RMCreateDriver( FlatToSel((ULONG)&DriverStruct), FlatToSel((ULONG)&hDriver) ); 79 80 if( rc == RMRC_SUCCESS ) DriverHandle = hDriver; 81 dprintf(("RMCreateDriver rc=%d DriverHandle=%x", rc, DriverHandle)); 82 } 83 84 while( ctResHandles ) 85 RMDeallocResource(DriverHandle, arResHandles[--ctResHandles]); 86 } 87 30 31 typedef struct 32 { 33 ULONG NumResource; 34 HRESOURCE hResource[MAX_RESHANDLES]; 35 } RESOURCES; 36 37 static RESOURCES Resource_stt = {0}; 38 39 //****************************************************************************** 40 //****************************************************************************** 41 VOID RMCreateDriverU32(VOID) 42 { 43 HDRIVER hDriver; 44 DRIVERSTRUCT DriverStruct; 45 char DriverName[sizeof(RM_DRIVER_NAME)]; 46 char VendorName[sizeof(RM_DRIVER_VENDORNAME)]; 47 char DriverDesc[sizeof(RM_DRIVER_DESCRIPTION)]; 48 49 //copy strings to stack, because we need to give RM 16:16 pointers 50 //(which can only be (easily) generated from 32 bits stack addresses) 51 strcpy(DriverName, RM_DRIVER_NAME); 52 strcpy(VendorName, RM_DRIVER_VENDORNAME); 53 strcpy(DriverDesc, RM_DRIVER_DESCRIPTION); 54 55 DriverStruct.DrvrName = FlatToSel((ULONG)DriverName); 56 DriverStruct.DrvrDescript = FlatToSel((ULONG)DriverDesc); 57 DriverStruct.VendorName = FlatToSel((ULONG)VendorName); 58 DriverStruct.MajorVer = RM_VMAJOR; 59 DriverStruct.MinorVer = RM_VMINOR; 60 DriverStruct.Date.Year = RM_DRIVER_BUILDYEAR; 61 DriverStruct.Date.Month = RM_DRIVER_BUILDMONTH; 62 DriverStruct.Date.Day = RM_DRIVER_BUILDDAY; 63 DriverStruct.DrvrFlags = 0; 64 DriverStruct.DrvrType = DRT_AUDIO; 65 DriverStruct.DrvrSubType = 0; 66 DriverStruct.DrvrCallback = 0; 67 68 APIRET rc = RMCreateDriver( FlatToSel((ULONG)&DriverStruct), 69 FlatToSel((ULONG)&hDriver) ); 70 71 if( rc == RMRC_SUCCESS ) 72 { 73 DriverHandle = hDriver; 74 } 75 dprintf(("RMCreateDriver rc=%d DriverHandle=%x", rc, DriverHandle)); 76 } 77 78 //****************************************************************************** 79 //****************************************************************************** 80 VOID RMCreateAdapterU32(ULONG DevID, ULONG *phAdapter, USHORT BusDevFunc, ULONG CardNum) 81 { 82 APIRET rc; 83 char szAdapterName[128]; 84 char szMixerName[64]; 85 86 szAdapterName[0] = szMixerName[0] = '\0'; 87 88 if(OSS32_QueryNames(CardNum, szAdapterName, sizeof(szAdapterName), 89 szMixerName, sizeof(szMixerName), FALSE) != OSSERR_SUCCESS ) 90 { 91 return; // error 92 } 93 94 switch(DevID) 95 { 96 case PCIID_VIA_686A: 97 case PCIID_VIA_8233: 98 case PCIID_SI_7012: 99 case PCIID_INTEL_82801: 100 case PCIID_INTEL_82901: 101 case PCIID_INTEL_92801BA: 102 case PCIID_INTEL_440MX: 103 case PCIID_INTEL_ICH3: 104 case PCIID_INTEL_ICH4: 105 case PCIID_INTEL_ICH5: 106 case PCIID_INTEL_ICH6: 107 case PCIID_INTEL_ICH7: 108 case PCIID_NVIDIA_MCP_AUDIO: 109 case PCIID_NVIDIA_MCP2_AUDIO: 110 case PCIID_NVIDIA_MCP3_AUDIO: 111 case PCIID_NVIDIA_CK8S_AUDIO: 112 case PCIID_NVIDIA_CK8_AUDIO: 113 strcat(szAdapterName, " with "); 114 strcat(szAdapterName, szMixerName); 115 break; 116 /* 117 case PCIID_CREATIVELABS_SBLIVE: 118 case PCIID_ALS4000: 119 case PCIID_CMEDIA_CM8338A: 120 case PCIID_CMEDIA_CM8338B: 121 case PCIID_CMEDIA_CM8738: 122 case PCIID_CMEDIA_CM8738B: 123 case PCIID_CIRRUS_4281: 124 case PCIID_CIRRUS_4280: 125 case PCIID_CIRRUS_4612: 126 case PCIID_CIRRUS_4615: 127 case PCIID_ESS_ALLEGRO_1: 128 case PCIID_ESS_ALLEGRO: 129 case PCIID_ESS_MAESTRO3: 130 case PCIID_ESS_MAESTRO3_1: 131 case PCIID_ESS_MAESTRO3_HW: 132 case PCIID_ESS_MAESTRO3_2: 133 case PCIID_ESS_CANYON3D_2LE: 134 case PCIID_ESS_CANYON3D_2: 135 case PCIID_ESS_ES1938: 136 case PCIID_AUREAL_VORTEX: 137 case PCIID_AUREAL_VORTEX2: 138 case PCIID_AUREAL_ADVANTAGE: 139 case PCIID_ENSONIQ_CT5880: 140 case PCIID_ENSONIQ_ES1371: 141 case PCIID_YAMAHA_YMF724: 142 case PCIID_YAMAHA_YMF724F: 143 case PCIID_YAMAHA_YMF740: 144 case PCIID_YAMAHA_YMF740C: 145 case PCIID_YAMAHA_YMF744: 146 case PCIID_YAMAHA_YMF754: 147 case PCIID_ESS_M2E: 148 case PCIID_ESS_M2: 149 case PCIID_ESS_M1: 150 case PCIID_ALI_5451: 151 case PCIID_TRIDENT_4DWAVE_DX: 152 case PCIID_TRIDENT_4DWAVE_NX: 153 case PCIID_SI_7018: 154 case PCIID_FM801: 155 case PCIID_ATIIXP_SB200: 156 case PCIID_ATIIXP_SB300: 157 case PCIID_ATIIXP_SB400: 158 case PCIID_AUDIGYLS: 159 case PCIID_AUDIGYLS1: 160 case PCIID_AUDIGYLS2: 161 break; 162 */ 163 } 164 165 if( !szAdapterName[0] ) 166 { 167 strcpy(szAdapterName, "Unknown"); 168 } 169 170 //copy to stack, because we need to give RM 16:16 pointers 171 //(which can only be (easily) generated from 32 bits stack addresses) 172 RESOURCES Resource_loc; 173 // is any resoures detected and registered in RM ? 174 if( Resource_stt.NumResource ) 175 { 176 memcpy( &Resource_loc, &Resource_stt, sizeof(Resource_loc) ); 177 } 178 else 179 { 180 dprintf(("No resources allocated !!!")); 181 Resource_loc.NumResource = 0; 182 } 183 184 ADJUNCT adjBusDevFunc; 185 adjBusDevFunc.pNextAdj = NULL; 186 adjBusDevFunc.AdjLength = sizeof(adjBusDevFunc); 187 adjBusDevFunc.AdjType = ADJ_PCI_DEVFUNC; 188 adjBusDevFunc.PCI_DevFunc = BusDevFunc; 189 190 ADAPTERSTRUCT AdapterStruct; 191 AdapterStruct.AdaptDescriptName = FlatToSel((ULONG)szAdapterName); /* ### IHV */ 192 AdapterStruct.AdaptFlags = AS_16MB_ADDRESS_LIMIT; // AdaptFlags /* ### IHV */ 193 AdapterStruct.BaseType = AS_BASE_MMEDIA; // BaseType 194 AdapterStruct.SubType = AS_SUB_MM_AUDIO; // SubType 195 AdapterStruct.InterfaceType = AS_INTF_GENERIC; // InterfaceType 196 AdapterStruct.HostBusType = AS_HOSTBUS_PCI; // HostBusType /* ### IHV */ 197 AdapterStruct.HostBusWidth = AS_BUSWIDTH_32BIT; // HostBusWidth /* ### IHV */ 198 AdapterStruct.pAdjunctList = FlatToSel((ULONG)&adjBusDevFunc);// pAdjunctList /* ### IHV */ 199 AdapterStruct.Reserved = 0; 200 201 //--- Register adapter. We'll record any error code, but won't fail 202 // the driver initialization and won't return resources. 203 //NOTE: hAdapter must be used as FlatToSel only works for stack variables 204 HADAPTER hAdapter; 205 rc = RMCreateAdapter(DriverHandle, // Handle to driver 206 FlatToSel((ULONG)&hAdapter), // (OUT) Handle to adapter 207 FlatToSel((ULONG)&AdapterStruct), // Adapter structure 208 0, // Parent device (defaults OK) 209 Resource_loc.NumResource ? (FlatToSel((ULONG)&Resource_loc)) : 0); // Allocated resources. 210 211 dprintf(("RMCreateAdapter rc=%d", rc)); 212 213 if( rc == 0 ) 214 { 215 AdapterHandle = hAdapter; 216 *phAdapter = hAdapter; 217 Resource_stt.NumResource = 0; // no resource handles to be freed 218 } 219 else 220 { 221 RMDeallocRes(); 222 } 223 } 88 224 89 225 //****************************************************************************** … … 105 241 FlatToSel((ULONG)&Resource)); // Resource to allocate. 106 242 107 if( rc == 0 && ctResHandles< MAX_RESHANDLES )243 if( rc == 0 && Resource_stt.NumResource < MAX_RESHANDLES ) 108 244 { 109 arResHandles[ctResHandles++] = hres; return TRUE;245 Resource_stt.hResource[Resource_stt.NumResource++] = hres; return TRUE; 110 246 } 111 247 112 dprintf(("RMAllocResource[%d] IO rc = %d", ctResHandles, rc));248 dprintf(("RMAllocResource[%d] IO rc = %d", Resource_stt.NumResource, rc)); 113 249 114 250 return FALSE; … … 133 269 FlatToSel((ULONG)&Resource)); // Resource to allocate. 134 270 135 if( rc == 0 && ctResHandles< MAX_RESHANDLES )271 if( rc == 0 && Resource_stt.NumResource < MAX_RESHANDLES ) 136 272 { 137 arResHandles[ctResHandles++] = hres; return TRUE;273 Resource_stt.hResource[Resource_stt.NumResource++] = hres; return TRUE; 138 274 } 139 275 140 dprintf(("RMAllocResource[%d] MEM rc = %d", ctResHandles, rc));276 dprintf(("RMAllocResource[%d] MEM rc = %d", Resource_stt.NumResource, rc)); 141 277 142 278 return rc == 0; … … 148 284 BOOL RMRequestIRQ(ULONG ulIrq, BOOL fShared, PHRESOURCE phRes) 149 285 { 150 RESOURCESTRUCT Resource; 151 HRESOURCE hRes; 152 APIRET rc; 153 154 Resource.ResourceType = RS_TYPE_IRQ; 155 Resource.IRQResource.IRQLevel = (USHORT)ulIrq & 0xff; 156 Resource.IRQResource.PCIIrqPin = 0; 157 Resource.IRQResource.IRQFlags = ( fShared ) ? RS_IRQ_SHARED : RS_IRQ_EXCLUSIVE; 158 159 rc = RMAllocResource(DriverHandle, // Handle to driver. 160 FlatToSel((ULONG)&hRes), // OUT: "allocated" resource node handle 161 FlatToSel((ULONG)&Resource)); // Resource to allocate. 162 163 164 if (rc == 0) { 165 *phRes = hRes; 166 if (DeviceHandle) { 167 dprintf(("RMRequestIRQ: DriverHandle=%x DeviceHandle=%x hRes=%x", DriverHandle, DeviceHandle, hRes)); 168 rc = RMModifyResources(DriverHandle, DeviceHandle, RM_MODIFY_ADD, hRes); 169 } else { 170 if (ctResHandles < MAX_RESHANDLES ) arResHandles[ctResHandles++] = hRes; 171 } 286 RESOURCESTRUCT Resource; 287 HRESOURCE hRes; 288 APIRET rc; 289 290 memset( &Resource, 0, sizeof(Resource) ); 291 Resource.ResourceType = RS_TYPE_IRQ; 292 Resource.IRQResource.IRQLevel = (USHORT)ulIrq & 0xff; 293 Resource.IRQResource.PCIIrqPin = 0; 294 Resource.IRQResource.IRQFlags = ( fShared ) ? RS_IRQ_SHARED : RS_IRQ_EXCLUSIVE; 295 296 rc = RMAllocResource(DriverHandle, // Handle to driver. 297 FlatToSel((ULONG)&hRes), // OUT: "allocated" resource node handle 298 FlatToSel((ULONG)&Resource)); // Resource to allocate. 299 300 if (rc == 0) 301 { 302 *phRes = hRes; 303 if (AdapterHandle) 304 { 305 dprintf(("RMRequestIRQ: DriverHandle=%x AdapterHandle=%x hRes=%x", DriverHandle, AdapterHandle, hRes)); 306 rc = RMModifyResources(DriverHandle, AdapterHandle, RM_MODIFY_ADD, hRes); 307 } 308 else 309 { 310 if (Resource_stt.NumResource < MAX_RESHANDLES ) 311 { 312 Resource_stt.hResource[Resource_stt.NumResource++] = hRes; 313 } 172 314 } 173 174 dprintf(("RMAllocResource[%d] IRQ=%d rc=%d", ctResHandles, ulIrq, rc)); 315 } 316 dprintf(("RMAllocResource[%d] IRQ=%d rc=%d", Resource_stt.NumResource, ulIrq, rc)); 317 return rc == 0; 318 } 319 320 //****************************************************************************** 321 //****************************************************************************** 322 BOOL RMDeallocateIRQ(HRESOURCE hRes) 323 { 324 APIRET rc; 325 326 dprintf(("RMDeallocateIRQ: DriverHandle=%x AdapterHandle=%x hRes=%x", DriverHandle, AdapterHandle, hRes)); 327 rc = RMModifyResources(DriverHandle, AdapterHandle, RM_MODIFY_DELETE, hRes); 175 328 176 329 return rc == 0; … … 179 332 //****************************************************************************** 180 333 //****************************************************************************** 181 BOOL RMDeallocateIRQ(HRESOURCE hRes) 182 { 183 APIRET rc; 184 185 dprintf(("RMDeallocateIRQ: DriverHandle=%x DeviceHandle=%x hRes=%x", DriverHandle, DeviceHandle, hRes)); 186 rc = RMModifyResources(DriverHandle, DeviceHandle, RM_MODIFY_DELETE, hRes); 187 188 return rc == 0; 189 } 190 191 192 //****************************************************************************** 193 //****************************************************************************** 194 VOID RMDone(ULONG DevID, PHADAPTER phAdapter, PHDEVICE phDevice) 195 { 196 APIRET rc; 197 HDEVICE hDevice; 198 HADAPTER hAdapter; 199 ADAPTERSTRUCT AdapterStruct; 200 DEVICESTRUCT DeviceStruct; 201 char AdapterName[sizeof(RM_ADAPTER_NAME)]; 202 char szDeviceName[128]; 203 char szMixerName[64]; 204 struct { 205 ULONG NumResource; 206 HRESOURCE hResource[MAX_RESHANDLES]; 207 } ahResource; 208 209 szDeviceName[0] = szMixerName[0] = '\0'; 210 211 if( DevID && OSS32_QueryNames(OSS32_DEFAULT_DEVICE, 212 szDeviceName, sizeof(szDeviceName), 213 szMixerName, sizeof(szMixerName), FALSE) == OSSERR_SUCCESS ) 214 { 215 switch(DevID) { 216 case PCIID_VIA_686A: 217 case PCIID_VIA_8233: 218 case PCIID_SI_7012: 219 case PCIID_INTEL_82801: 220 case PCIID_INTEL_82901: 221 case PCIID_INTEL_92801BA: 222 case PCIID_INTEL_440MX: 223 case PCIID_INTEL_ICH3: 224 case PCIID_INTEL_ICH4: 225 case PCIID_INTEL_ICH5: 226 case PCIID_INTEL_ICH6: 227 case PCIID_INTEL_ICH7: 228 case PCIID_NVIDIA_MCP_AUDIO: 229 case PCIID_NVIDIA_MCP2_AUDIO: 230 case PCIID_NVIDIA_MCP3_AUDIO: 231 case PCIID_NVIDIA_CK8S_AUDIO: 232 case PCIID_NVIDIA_CK8_AUDIO: 233 strcat(szDeviceName, " with "); 234 strcat(szDeviceName, szMixerName); 235 break; 236 /* 237 case PCIID_CREATIVELABS_SBLIVE: 238 case PCIID_ALS4000: 239 case PCIID_CMEDIA_CM8338A: 240 case PCIID_CMEDIA_CM8338B: 241 case PCIID_CMEDIA_CM8738: 242 case PCIID_CMEDIA_CM8738B: 243 case PCIID_CIRRUS_4281: 244 case PCIID_CIRRUS_4280: 245 case PCIID_CIRRUS_4612: 246 case PCIID_CIRRUS_4615: 247 case PCIID_ESS_ALLEGRO_1: 248 case PCIID_ESS_ALLEGRO: 249 case PCIID_ESS_MAESTRO3: 250 case PCIID_ESS_MAESTRO3_1: 251 case PCIID_ESS_MAESTRO3_HW: 252 case PCIID_ESS_MAESTRO3_2: 253 case PCIID_ESS_CANYON3D_2LE: 254 case PCIID_ESS_CANYON3D_2: 255 case PCIID_ESS_ES1938: 256 case PCIID_AUREAL_VORTEX: 257 case PCIID_AUREAL_VORTEX2: 258 case PCIID_AUREAL_ADVANTAGE: 259 case PCIID_ENSONIQ_CT5880: 260 case PCIID_ENSONIQ_ES1371: 261 case PCIID_YAMAHA_YMF724: 262 case PCIID_YAMAHA_YMF724F: 263 case PCIID_YAMAHA_YMF740: 264 case PCIID_YAMAHA_YMF740C: 265 case PCIID_YAMAHA_YMF744: 266 case PCIID_YAMAHA_YMF754: 267 case PCIID_ESS_M2E: 268 case PCIID_ESS_M2: 269 case PCIID_ESS_M1: 270 case PCIID_ALI_5451: 271 case PCIID_TRIDENT_4DWAVE_DX: 272 case PCIID_TRIDENT_4DWAVE_NX: 273 case PCIID_SI_7018: 274 case PCIID_FM801: 275 case PCIID_ATIIXP_SB200: 276 case PCIID_ATIIXP_SB300: 277 case PCIID_ATIIXP_SB400: 278 case PCIID_AUDIGYLS: 279 case PCIID_AUDIGYLS1: 280 case PCIID_AUDIGYLS2: 281 break; 282 */ 283 } /* switch */ 284 285 286 if( ctResHandles ) 287 { 288 ahResource.NumResource = ctResHandles; 289 memcpy(ahResource.hResource, 290 arResHandles, ctResHandles * sizeof(arResHandles[0])); 291 292 //copy string to stack, because we need to give RM 16:16 pointers 293 //(which can only be (easily) generated from 32 bits stack addresses) 294 strcpy(AdapterName, RM_ADAPTER_NAME); 295 296 memset( (PVOID) &AdapterStruct, 0, sizeof(AdapterStruct) ); 297 AdapterStruct.AdaptDescriptName = FlatToSel((ULONG)AdapterName); /* ### IHV */ 298 AdapterStruct.AdaptFlags = AS_16MB_ADDRESS_LIMIT; // AdaptFlags /* ### IHV */ 299 AdapterStruct.BaseType = AS_BASE_MMEDIA; // BaseType 300 AdapterStruct.SubType = AS_SUB_MM_AUDIO; // SubType 301 AdapterStruct.InterfaceType = AS_INTF_GENERIC; // InterfaceType 302 AdapterStruct.HostBusType = AS_HOSTBUS_PCI; // HostBusType /* ### IHV */ 303 AdapterStruct.HostBusWidth = AS_BUSWIDTH_32BIT; // HostBusWidth /* ### IHV */ 304 AdapterStruct.pAdjunctList = 0; // pAdjunctList /* ### IHV */ 305 306 //--- Register adapter. We'll record any error code, but won't fail 307 // the driver initialization and won't return resources. 308 //NOTE: hAdapter must be used as FlatToSel only works for stack variables 309 rc = RMCreateAdapter(DriverHandle, // Handle to driver 310 FlatToSel((ULONG)&hAdapter), // (OUT) Handle to adapter 311 FlatToSel((ULONG)&AdapterStruct), // Adapter structure 312 0, // Parent device (defaults OK) 313 0); // Allocated resources. 314 315 dprintf(("RMCreateAdapter rc=%d", rc)); 316 317 if( rc == 0 ) 318 { 319 AdapterHandle = hAdapter; 320 if (phAdapter) *phAdapter = hAdapter; 321 if( !szDeviceName[0] ) strcpy(szDeviceName, "Unknown"); 322 323 //NOTE: Assumes szDeviceName is a stack pointer!! 324 memset( (PVOID) &DeviceStruct, 0, sizeof(DeviceStruct) ); 325 DeviceStruct.DevDescriptName = FlatToSel((ULONG)szDeviceName); 326 DeviceStruct.DevFlags = DS_FIXED_LOGICALNAME; 327 DeviceStruct.DevType = DS_TYPE_AUDIO; 328 DeviceStruct.pAdjunctList = 0; 329 330 rc = RMCreateDevice(DriverHandle, // Handle to driver 331 FlatToSel((ULONG)&hDevice), // (OUT) Handle to device, unused. 332 FlatToSel((ULONG)&DeviceStruct), // Device structure 333 hAdapter, // Parent adapter 334 FlatToSel((ULONG)&ahResource)); // Allocated resources 335 336 dprintf(("RMCreateDevice rc=%d", rc)); 337 338 if( rc == 0 ) 339 { 340 DeviceHandle = hDevice; 341 if (phDevice) *phDevice = hDevice; 342 ctResHandles = 0; // no resource handles to be freed 343 dprintf(("RMDone: DriverHandle=%x DeviceHandle=%x", DriverHandle, DeviceHandle)); 344 return; 345 } 346 347 // !!! Not implemented in startup.asm 348 // RMDestroyAdapter(DriverHandle, hAdapter); 349 } /* if rc == 0 */ 350 } /* ctResHandles */ 351 else dprintf(("No resources allocated !!!")); 352 } /* if DevID */ 353 354 355 // free resource handles 356 while( ctResHandles ) 357 RMDeallocResource(DriverHandle, arResHandles[--ctResHandles]); 358 } 359 334 VOID RMDeallocRes(VOID) 335 { 336 // free resource handles 337 while( Resource_stt.NumResource ) 338 { 339 RMDeallocResource(DriverHandle, Resource_stt.hResource[--Resource_stt.NumResource]); 340 } 341 } 360 342 361 343 /* DAZ - dirty hack so that resource manager is updated correctly 362 344 * when using APIC and multiple adapters */ 363 VOID RMSetHandles(HADAPTER hAdapter , HDEVICE hDevice)345 VOID RMSetHandles(HADAPTER hAdapter) 364 346 { 365 347 AdapterHandle = hAdapter; 366 DeviceHandle = hDevice; 367 } 368 348 }
Note:
See TracChangeset
for help on using the changeset viewer.