struct ISAPNP_Device* ASMCALL ISAPNP_FindDevice( REG( a0, struct ISAPNP_Device* last_device ), REG( d0, LONG manufacturer ), REG( d1, WORD product ), REG( d2, BYTE revision ), REG( a6, struct ISAPNPBase* res ) ) { struct ISAPNP_Card* card; struct ISAPNP_Device* dev; if( last_device == NULL ) { card = (struct ISAPNP_Card*) res->m_Cards.lh_Head; dev = (struct ISAPNP_Device*) card->isapnpc_Devices.lh_Head; } else { card = (struct ISAPNP_Card*) last_device->isapnpd_Card; dev = (struct ISAPNP_Device*) last_device->isapnpd_Node.ln_Succ; } while( card->isapnpc_Node.ln_Succ != NULL ) { while( dev->isapnpd_Node.ln_Succ != NULL ) { struct ISAPNP_Identifier* id; for( id = (struct ISAPNP_Identifier*) dev->isapnpd_IDs.mlh_Head; id->isapnpid_MinNode.mln_Succ != NULL; id = (struct ISAPNP_Identifier*) id->isapnpid_MinNode.mln_Succ ) { if( manufacturer == -1 || ISAPNP_MAKE_ID( id->isapnpid_Vendor[ 0 ], id->isapnpid_Vendor[ 1 ], id->isapnpid_Vendor[ 2 ] ) == manufacturer ) { if( product == -1 || id->isapnpid_ProductID == product ) { if( revision == -1 || id->isapnpid_Revision == revision ) { return dev; } } } } dev = (struct ISAPNP_Device*) dev->isapnpd_Node.ln_Succ; } card = (struct ISAPNP_Card*) card->isapnpc_Node.ln_Succ; dev = (struct ISAPNP_Device*) card->isapnpc_Devices.lh_Head; } return NULL; }
struct ISAPNP_Card* ASMCALL ISAPNP_FindCard( REG( a0, struct ISAPNP_Card* last_card ), REG( d0, LONG manufacturer ), REG( d1, WORD product ), REG( d2, BYTE revision ), REG( d3, LONG serial ), REG( a6, struct ISAPNPBase* res ) ) { struct ISAPNP_Card* card; if( last_card == NULL ) { card = (struct ISAPNP_Card*) res->m_Cards.lh_Head; } else { card = (struct ISAPNP_Card*) last_card->isapnpc_Node.ln_Succ; } while( card->isapnpc_Node.ln_Succ != NULL ) { if( manufacturer == -1 || ISAPNP_MAKE_ID( card->isapnpc_ID.isapnpid_Vendor[ 0 ], card->isapnpc_ID.isapnpid_Vendor[ 1 ], card->isapnpc_ID.isapnpid_Vendor[ 2 ] ) == manufacturer ) { if( product == -1 || card->isapnpc_ID.isapnpid_ProductID == product ) { if( revision == -1 || card->isapnpc_ID.isapnpid_Revision == revision ) { if( serial == -1 || (LONG) card->isapnpc_SerialNumber == serial ) { return card; } } } } card = (struct ISAPNP_Card*) card->isapnpc_Node.ln_Succ; } return NULL; }
static BOOL PatchBrokenCards( struct ISAPNPBase* res ) { struct ISAPNP_Device* dev = NULL; // Patch the wavetable device on SB AWE32 and AWE64 while( ( dev = ISAPNP_FindDevice( dev, ISAPNP_MAKE_ID('C','T','L'), 0x002, 1, res ) ) != NULL ) { struct ISAPNP_ResourceGroup* rg; struct ISAPNP_IOResource* r1; struct ISAPNP_IOResource* r2; struct ISAPNP_IOResource* r3; // Nuke all dependent options while( ( rg = (struct ISAPNP_ResourceGroup*) RemHead( (struct List*) &dev->isapnpd_Options->isapnprg_ResourceGroups ) ) != NULL ) { ISAPNP_FreeResourceGroup( rg, res ); } rg = ISAPNP_AllocResourceGroup( ISAPNP_RG_PRI_ACCEPTABLE, res ); r1 = (struct ISAPNP_IOResource*) ISAPNP_AllocResource( ISAPNP_NT_IO_RESOURCE, res ); r2 = (struct ISAPNP_IOResource*) ISAPNP_AllocResource( ISAPNP_NT_IO_RESOURCE, res ); r3 = (struct ISAPNP_IOResource*) ISAPNP_AllocResource( ISAPNP_NT_IO_RESOURCE, res ); if( rg == NULL || r1 == NULL || r2 == NULL || r3 == NULL ) { ISAPNP_FreeResourceGroup( rg, res ); ISAPNP_FreeResource( (struct ISAPNP_Resource*) r1, res ); ISAPNP_FreeResource( (struct ISAPNP_Resource*) r2, res ); ISAPNP_FreeResource( (struct ISAPNP_Resource*) r3, res ); return FALSE; } r1->isapnpior_Flags = ISAPNP_IORESOURCE_FF_FULL_DECODE; r2->isapnpior_Flags = ISAPNP_IORESOURCE_FF_FULL_DECODE; r3->isapnpior_Flags = ISAPNP_IORESOURCE_FF_FULL_DECODE; r1->isapnpior_Alignment = 1; r2->isapnpior_Alignment = 1; r3->isapnpior_Alignment = 1; r1->isapnpior_Length = 4; r2->isapnpior_Length = 4; r3->isapnpior_Length = 4; r1->isapnpior_MinBase = 0x620; r2->isapnpior_MinBase = 0xa20; r3->isapnpior_MinBase = 0xe20; r1->isapnpior_MaxBase = 0x620; r2->isapnpior_MaxBase = 0xa20; r3->isapnpior_MaxBase = 0xe20; AddTail( (struct List*) &rg->isapnprg_Resources, (struct Node*) r1 ); AddTail( (struct List*) &rg->isapnprg_Resources, (struct Node*) r2 ); AddTail( (struct List*) &rg->isapnprg_Resources, (struct Node*) r3 ); AddTail( (struct List*) &dev->isapnpd_Options->isapnprg_ResourceGroups, (struct Node*) rg ); } return TRUE; }
static int ParseID( UBYTE* string, LONG* manufacturer, WORD* product, BYTE* revision, LONG* serial ) { int chars = 0; *manufacturer = ISAPNP_MAKE_ID( ToUpper( string[ 0 ] ), ToUpper( string[ 1 ] ), ToUpper( string[ 2 ] ) ); *product = ( HexToInt( string[ 3 ] ) << 8 ) | ( HexToInt( string[ 4 ] ) << 4 ) | ( HexToInt( string[ 5 ] ) ); if( *product == -1 ) { return 0; } *revision = HexToInt( string[ 6 ] ); if( *revision == -1 ) { return 0; } chars = 7; if( serial != NULL ) { if( string[ 7 ] == '/' ) { int conv = StrToLong( string + 8, serial ); if( conv == -1 ) { return 0; } else { chars += conv; } } else if( string[ 7 ] == 0 || string[ 7 ] != ' ' ) { *serial = -1; } else { return 0; } } else { if( string[ 7 ] != 0 && string[ 7 ] != ' ' ) { return 0; } } return chars; }