//------------------------------------------------------------------- // 82573pci.cpp // // This program displays the PCI Configuration Space registers // for the Intel 82573L PRO1000 Gigabit Ethernet controller in // our classroom's workstations or our anchor-cluster servers. // // compile using: $ g++ 82573pci.cpp -o 82573pci // execute using: $ sudo ./82573pci // // programmer: ALLAN CRUSE // written on: 16 APR 2009 //------------------------------------------------------------------- #include // for printf(), perror() #include // for read(), write(), close() #include // for iopl(), in(), out() #define VENDOR_ID 0x8086 // Intel Corporation #define DEVICE_ID 0x109A // 82573L controller #define CONFADD 0x0CF8 #define CONFDAT 0x0CFC #define PMC 0x0CFB char legend1[] = "PCI Configuration Space for "; char legend2[] = "Intel 82573L Gigabit Ethernet Controller"; int main( int argc, char **argv ) { // adjust the IOPL-field in the processor's FLAGS register if ( iopl( 3 ) < 0 ) { perror( "iopl" ); return 1; } // insure that PCI configuration mechanism #1 is enabled outb( inb( PMC ) | 1, PMC ); // perform a PCI bus-scan to locate the 82773L controller for (int bus = 0; bus < (1 << 8); bus++) for (int dev = 0; dev < (1 << 5); dev++) { int busdev = (bus << 16)|(dev << 11)|(1 << 31); outl( busdev, CONFADD ); int pcidat = inl( CONFDAT ); if ( pcidat == ~0 ) continue; int vendor = (pcidat >> 0)&0xFFFF; if ( vendor != VENDOR_ID ) continue; int device = (pcidat >> 16)&0xFFFF; if ( device != DEVICE_ID ) continue; // exhibit the 82573's Configuration Space registers printf( "\n %s%s \n", legend1, legend2 ); for (int reg = 0; reg < 0x100; reg +=4) { if ( (reg % 32) == 0 ) printf( "\n 0x%03X: ", reg ); outl( busdev | reg, CONFADD ); pcidat = inl( CONFDAT ); printf( "%08X ", pcidat ); } printf( "\n" ); } printf( "\n" ); }