?? findchip.c
字號:
/*
findchip.c
*/
#include <stdtypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* non-standard includes... */
#include <lib.h>
#include <amcclib.h>
#include <main.h>
#include <amcc5920.h>
#include <amcc5933.h>
#define CHECKPCI if ( status != PCI_SUCCESSFUL ) \
return pci_bios_fail( status );
extern CHAR text[], infostring[];
int findchip( struct _chip *chip, CHAR *errstr )
/*
Find chip based on VID, DID, SVID, and SID.
Entry: chip->device_id, chip->vendor_id,
chip->susbsy_vendor_id, chip->susbsy_id
infostring is valid (null-teminated after stuff we don't want)
Return: TRUE if chip found, and chip->index updated
FALSE and errstr updated
*/
{
UINT16 subsys_vendor=0, subsys_id=0;
int found, index, status, strptr;
strptr = strlen( infostring );
// holds each device subsystem info
found = FALSE;
for ( index = 0; !found ; index++ )
{
switch ( pci_init( chip, index, chip->device_id, chip->vendor_id ) )
{
case 0:
status = pci_config_read16( chip, PCI_CS_SVID, &subsys_vendor );
CHECKPCI
status = pci_config_read16( chip, PCI_CS_SID, &subsys_id );
CHECKPCI
sprintf( text, "Index %d Subsystem Vendor/ID %4.4x/%4.4x.\n",
index, subsys_vendor, subsys_id );
strcat( infostring, text );
break; // chip found
case 1: strcat( errstr, "PCI BIOS not found.\n" );
return FALSE;
case 2: if ( index == 0 )
{
sprintf( text, "No device matches Vendor ID/Device ID %4.4x/%4.4x.\n", chip->vendor_id, chip->device_id );
strcat( errstr, text );
return FALSE;
}
// index != 0...
sprintf( text, "%d devices match Vendor/Device, but not Subsystem Vendor/ID %4.4x/%4.4x.\n", \
index, chip->subsys_vendor_id, chip->subsys_id );
strcat( errstr, text );
strcat( errstr, infostring ); // add each subsystem stuff
return FALSE;
default: strcat( errstr, "Unknown case - programming error in \"findchip\".\n" );
return FALSE;
}
// see if susbsystem ID matches...
if ( chip->subsys_vendor_id != subsys_vendor ) continue;
if ( chip->subsys_id == subsys_id ) break; // found
}
infostring[strptr] = '\0'; // delete string stuff we added
chip->index = index;
return TRUE;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -