struct ISAPNP_Resource* CreateResource( struct ResourceIterator* iter, struct ISAPNPBase* res ) { struct ISAPNP_Resource* result = NULL; result = ISAPNP_AllocResource( iter->m_Resource->isapnpr_Type, res ); if( result == NULL ) { return NULL; } switch( iter->m_Resource->isapnpr_Type ) { case ISAPNP_NT_IRQ_RESOURCE: { struct ISAPNP_IRQResource* r; r = (struct ISAPNP_IRQResource*) result; // Make a copy of the iterators resource CopyMem( iter->m_Resource, r, sizeof( *r ) ); r->isapnpirqr_MinNode.mln_Succ = NULL; r->isapnpirqr_MinNode.mln_Pred = NULL; r->isapnpirqr_IRQMask = 1 << iter->m_IRQBit; break; } case ISAPNP_NT_DMA_RESOURCE: { struct ISAPNP_DMAResource* r; r = (struct ISAPNP_DMAResource*) result; // Make a copy of the iterators resource CopyMem( iter->m_Resource, r, sizeof( *r ) ); r->isapnpdmar_MinNode.mln_Succ = NULL; r->isapnpdmar_MinNode.mln_Pred = NULL; r->isapnpdmar_ChannelMask = 1 << iter->m_ChannelBit; break; } case ISAPNP_NT_IO_RESOURCE: { struct ISAPNP_IOResource* r; r = (struct ISAPNP_IOResource*) result; // Make a copy of the iterators resource CopyMem( iter->m_Resource, r, sizeof( *r ) ); r->isapnpior_MinNode.mln_Succ = NULL; r->isapnpior_MinNode.mln_Pred = NULL; r->isapnpior_MinBase = iter->m_Base; r->isapnpior_MaxBase = iter->m_Base; r->isapnpior_Alignment = 1; break; } case ISAPNP_NT_MEMORY_RESOURCE: default: ISAPNP_FreeResource( result, res ); result = NULL; break;; } return result; }
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 BOOL HandleToolTypes( UBYTE** tool_types, struct ISAPNP_Card* card, struct ISAPNPBase* res ) { while( *tool_types ) { if( Strnicmp( *tool_types, "DISABLE_CARD=", 13 ) == 0 ) { LONG manufacturer; WORD product; BYTE revision; LONG serial; if( ParseID( *tool_types + 13, &manufacturer, &product, &revision, &serial ) ) { struct ISAPNP_Card* card = NULL; while( ( card = ISAPNP_FindCard( card, manufacturer, product, revision, serial, res ) ) != NULL ) { card->isapnpc_Disabled = TRUE; } } else { Req( "Illegal tool type: %s\n", (ULONG) *tool_types ); return FALSE; } } else if( Strnicmp( *tool_types, "DISABLE_DEVICE=", 15 ) == 0 ) { LONG manufacturer; WORD product; BYTE revision; if( ParseID( *tool_types + 15, &manufacturer, &product, &revision, NULL ) ) { struct ISAPNP_Device* dev = NULL; while( ( dev = ISAPNP_FindDevice( dev, manufacturer, product, revision, res ) ) != NULL ) { dev->isapnpd_Disabled = TRUE; } } else { Req( "Illegal tool type value: %s\n", (ULONG) *tool_types ); return FALSE; } } else if( Strnicmp( *tool_types, "LEGACY_DEVICE=", 14 ) == 0 ) { UBYTE* str; int conv; LONG manufacturer; WORD product; BYTE revision; UWORD dev_num = 0; str = *tool_types + 14; conv = ParseID( str, &manufacturer, &product, &revision, NULL ); str += conv; if( conv != 0 ) { struct ISAPNP_Device* dev; struct ISAPNP_Identifier* id; dev = ISAPNP_AllocDevice( res ); if( dev == NULL ) { Req( "Out of memory!" ); return FALSE; } dev->isapnpd_Card = card; id = AllocVec( sizeof( *id ), MEMF_PUBLIC | MEMF_CLEAR ); if( id == NULL ) { Req( "Out of memory!" ); ISAPNP_FreeDevice( dev, res ); return FALSE; } id->isapnpid_Vendor[ 0 ] = ( manufacturer >> 24 ) & 0xff; id->isapnpid_Vendor[ 1 ] = ( manufacturer >> 16 ) & 0xff; id->isapnpid_Vendor[ 2 ] = ( manufacturer >> 8 ) & 0xff; id->isapnpid_Vendor[ 3 ] = 0; id->isapnpid_ProductID = product; id->isapnpid_Revision = revision; AddTail( (struct List*) &dev->isapnpd_IDs, (struct Node*) id ); if( card->isapnpc_Devices.lh_Head->ln_Succ != NULL ) { dev_num = ( (struct ISAPNP_Device*) card->isapnpc_Devices.lh_TailPred )->isapnpd_DeviceNumber; ++dev_num; } dev->isapnpd_DeviceNumber = dev_num; AddTail( &card->isapnpc_Devices, (struct Node*) dev ); while( *str != 0 ) { if( *str != ' ' ) { if( Strnicmp( str, "IRQ=", 4 ) == 0 ) { int irq; irq = strtol( str + 4, (char**) &str, 0 ); if( irq <= 0 || irq >= 16 ) { Req( "Invalid IRQ value '%ld' in tooltype line\n" "'%s'", irq, (ULONG) *tool_types ); return FALSE; } else { struct ISAPNP_IRQResource* r; r = (struct ISAPNP_IRQResource*) ISAPNP_AllocResource( ISAPNP_NT_IRQ_RESOURCE, res ); if( r == NULL ) { Req( "Out of memory!" ); return FALSE; } r->isapnpirqr_IRQMask = 1 << irq; r->isapnpirqr_IRQType = ISAPNP_IRQRESOURCE_ITF_HIGH_EDGE; AddTail( (struct List*) &dev->isapnpd_Options->isapnprg_Resources, (struct Node*) r ); } } else if( Strnicmp( str, "DMA=", 4 ) == 0 ) { int dma; dma = strtol( str + 4, (char**) &str, 0 ); if( dma <= 0 || dma >= 8 ) { Req( "Invalid DMA value '%ld' in tooltype line\n" "'%s'", dma, (ULONG) *tool_types ); return FALSE; } else { struct ISAPNP_DMAResource* r; r = (struct ISAPNP_DMAResource*) ISAPNP_AllocResource( ISAPNP_NT_DMA_RESOURCE, res ); if( r == NULL ) { Req( "Out of memory!" ); return FALSE; } r->isapnpdmar_ChannelMask = 1 << dma; r->isapnpdmar_Flags = 0; AddTail( (struct List*) &dev->isapnpd_Options->isapnprg_Resources, (struct Node*) r ); } } else if( Strnicmp( str, "IO=", 3 ) == 0 ) { int base; int length; struct ISAPNP_IOResource* r; base = strtol( str + 3, (char**) &str, 0 ); if( *str != '/' ) { Req( "Length missing from IO value in tooltype line\n" "'%s'", (ULONG) *tool_types ); return FALSE; } ++str; length = strtol( str, (char**) &str, 0 ); if( base <= 0 || base >= 0xffff ) { Req( "Invalid IO base value '%ld' in tooltype line\n" "'%s'", base, (ULONG) *tool_types ); return FALSE; } if( length <= 0 || length >= 0xffff ) { Req( "Invalid IO length value '%ld' in tooltype line\n" "'%s'", length, (ULONG) *tool_types ); return FALSE; } r = (struct ISAPNP_IOResource*) ISAPNP_AllocResource( ISAPNP_NT_IO_RESOURCE, res ); if( r == NULL ) { Req( "Out of memory!" ); return FALSE; } r->isapnpior_MinBase = base; r->isapnpior_MaxBase = base; r->isapnpior_Length = length; r->isapnpior_Alignment = 1; AddTail( (struct List*) &dev->isapnpd_Options->isapnprg_Resources, (struct Node*) r ); } else { Req( "Parse error near '%s'\n" "in tooltype line\n" "'%s'", (ULONG) str, (ULONG) *tool_types ); return FALSE; } } if( *str ) { ++str; } } } else { Req( "Illegal tool type: '%s'\n", (ULONG) *tool_types ); return FALSE; } }