rem: resources       = saved_resources; saved_resources = NULL;
add: options       = saved_options; saved_options = NULL;
context: ReadResourceData( struct ISAPNP_Card* card,                  struct ISAPNPBase*  res ){  UBYTE                        check_sum       = 0;  struct ISAPNP_Device*        dev             = NULL;  struct ISAPNP_ResourceGroup* resources       = NULL;  struct ISAPNP_ResourceGroup* saved_resources = NULL;  while( TRUE )  {    ULONG i;    UBYTE rd;    UBYTE name;    ULONG length;    rd = GetNextResourceData( res );    check_sum += rd;    if( rd & PNPISA_RDF_LARGE )    {      name    = PNPISA_RD_LARGE_ITEM_NAME( rd );      length  = GetNextResourceData( res );      length |= GetNextResourceData( res ) << 8;    }    else    {      name   = PNPISA_RD_SMALL_ITEM_NAME( rd );      length = PNPISA_RD_SMALL_LENGTH( rd );    }    switch( name )    {      case PNPISA_RDN_PNP_VERSION:      {        UBYTE ver;                ver = GetNextResourceData( res );        card->m_MinorPnPVersion  = ver & 0x0f;        card->m_MajorPnPVersion  = ver >> 4;        card->m_VendorPnPVersion = GetNextResourceData( res );                length -= 2;        break;      }      case PNPISA_RDN_LOGICAL_DEVICE_ID:      {        struct ISAPNP_Identifier* id;        UBYTE                     buf[ 4 ];        dev = PNPISA_AllocDevice( res );                if( dev == NULL )        {          break;        }        id  = AllocVec( sizeof( *id ), MEMF_PUBLIC | MEMF_CLEAR );                if( id == NULL )        {          PNPISA_FreeDevice( dev, res );          dev = NULL;          break;        }                buf[ 0 ] = GetNextResourceData( res );        buf[ 1 ] = GetNextResourceData( res );        buf[ 2 ] = GetNextResourceData( res );        buf[ 3 ] = GetNextResourceData( res );        length -= 4;        if( ! DecodeID( buf, id ) )        {          FreeVec( id );          PNPISA_FreeDevice( dev, res );          dev = NULL;          break;        }                AddTail( (struct List*) &dev->m_IDs, (struct Node*) id );        resources = dev->m_Resources;        dev->m_SupportedCommands = GetNextResourceData( res );        --length;                if( length > 0 )        {          dev->m_SupportedCommands |= GetNextResourceData( res ) << 8;        }                AddTail( &card->m_Devices, (struct Node*) dev );        break;      }            case PNPISA_RDN_COMPATIBLE_DEVICE_ID:      {        struct ISAPNP_Identifier* id;        UBYTE                     buf[ 4 ];        if( dev == NULL )        {          break;        }        id  = AllocVec( sizeof( *id ), MEMF_PUBLIC | MEMF_CLEAR );                if( id == NULL )        {          break;        }        buf[ 0 ] = GetNextResourceData( res );        buf[ 1 ] = GetNextResourceData( res );        buf[ 2 ] = GetNextResourceData( res );        buf[ 3 ] = GetNextResourceData( res );        length -= 4;        if( ! DecodeID( buf, id ) )        {          FreeVec( id );          break;        }        AddTail( (struct List*) &dev->m_IDs, (struct Node*) id );        break;      }      case PNPISA_RDN_IRQ_FORMAT:      {        struct ISAPNP_IRQResource* r;                r = (struct ISAPNP_IRQResource*)             PNPISA_AllocResource( ISAPNP_NT_IRQ_RESOURCE, res );                    if( r == NULL )        {          break;        }                r->m_IRQMask  = GetNextResourceData( res );        r->m_IRQMask |= GetNextResourceData( res ) << 8;        length -= 2;                if( length > 0 )        {          r->m_IRQType = GetNextResourceData( res );          --length;        }        else        {          r->m_IRQType = ISAPNP_IRQRESOURCE_ITF_HIGH_EDGE;        }        AddTail( (struct List*) &resources->m_Resources, (struct Node*) r );        break;      }      case PNPISA_RDN_DMA_FORMAT:      {        struct ISAPNP_DMAResource* r;                r = (struct ISAPNP_DMAResource*)             PNPISA_AllocResource( ISAPNP_NT_DMA_RESOURCE, res );                    if( r == NULL )        {          break;        }                r->m_ChannelMask = GetNextResourceData( res );        r->m_Flags       = GetNextResourceData( res );        length -= 2;        AddTail( (struct List*) &resources->m_Resources, (struct Node*) r );        break;      }      case PNPISA_RDN_START_DF:      {        struct ISAPNP_ResourceGroup* rg;        UBYTE  pri;                if( length > 0 )        {          pri = GetNextResourceData( res );          --length;        }        else        {          pri = 1;        }                switch( pri )        {          case 0:            pri = ISAPNP_RG_PRI_GOOD;            break;                      case 1:          default:            pri = ISAPNP_RG_PRI_ACCEPTABLE;            break;          case 2:            pri = ISAPNP_RG_PRI_SUBOPTIMAL;            break;        }                rg = PNPISA_AllocResourceGroup( pri, res );                if( rg == NULL )        {          break;        }        // Insert in priority order                Enqueue( (struct List*) &resources->m_ResourceGroups,                  (struct Node*) rg );        if( saved_resources == NULL )        {          saved_resources = resources;        }        resources = rg;        break;      }            case PNPISA_RDN_END_DF:      {        resources       = saved_resources;        saved_resources = NULL;                break;      }      case PNPISA_RDN_IO_PORT:      {        struct ISAPNP_IOResource* r;                r = (struct ISAPNP_IOResource*)             PNPISA_AllocResource( ISAPNP_NT_IO_RESOURCE, res );                    if( r == NULL )        {          break;        }                r->m_Flags      = GetNextResourceData( res );        r->m_MinBase    = GetNextResourceData( res );        r->m_MinBase   |= GetNextResourceData( res ) << 8;        r->m_MaxBase    = GetNextResourceData( res );        r->m_MaxBase   |= GetNextResourceData( res ) << 8;        r->m_Alignment  = GetNextResourceData( res );        r->m_Length     = GetNextResourceData( res );        length -= 7;        AddTail( (struct List*) &resources->m_Resources, (struct Node*) r );        break;      }      case PNPISA_RDN_FIXED_IO_PORT:      {        struct ISAPNP_IOResource* r;                r = (struct ISAPNP_IOResource*)             PNPISA_AllocResource( ISAPNP_NT_IO_RESOURCE, res );                    if( r == NULL )        {          break;        }                r->m_Flags      = 0;        r->m_MinBase    = GetNextResourceData( res );        r->m_MinBase   |= GetNextResourceData( res ) << 8;        r->m_MaxBase    = r->m_MinBase;        r->m_Alignment  = 1;        r->m_Length     = GetNextResourceData( res );                length -= 3;        AddTail( (struct List*) &resources->m_Resources, (struct Node*) r );        break;      }      case PNPISA_RDN_ANSI_IDENTIFIER:      {        STRPTR id = AllocVec( length + 1, MEMF_PUBLIC );                if( id == NULL )        {          break;        }        // Attach identifier to either the card or the logical device        if( dev == NULL )        {          FreeVec( card->m_Node.ln_Name );          card->m_Node.ln_Name = id;        }        else        {          FreeVec( dev->m_Node.ln_Name );          dev->m_Node.ln_Name = id;        }                while( length > 0 )        {          *id = GetNextResourceData( res );          ++id;          --length;        }                // Terminate the string        *id = '\0';        break;      }            default:        KPrintF( "%02lx, length %ld: ", name, length );        while( length > 0 )        {          KPrintF( "%02lx ", GetNextResourceData( res ) );          --length;        }        KPrintF( "\n" );        break;    }    // Make sure we have read all data for this name    while( length > 0 )    {      KPrintF( "!" );      GetNextResourceData( res );      --length;    }    if( name == PNPISA_RDN_END_TAG )    {      break;    }  }  KPrintF( "Check sum: %ld\n", check_sum );    return TRUE;}