//------------------------------------------------------------------- // findsvga.cpp // // This utility invokes PCI Bios Services in virtual-8086 mode // to locate the SVGA display devices installed in the system. // For each such device the PCI Configuration Header is shown. // // compile with: $ g++ findsvga.cpp int86.cpp -o findsvga // // Note: to execute this utility, our 'dosio.c' driver must be // installed, and the '/dev/dos' device-file must be writable. // // programmer: ALLAN CRUSE // written on: 02 AUG 2005 //------------------------------------------------------------------- #include // for printf() #include "int86.h" // for init8086(), int86() #define CLASS_SVGA 0x030000 // PCI Display Device class struct vm86plus_struct vm; int main( int argc, char **argv ) { init8086(); // setup simulated 8086 environment vm.regs.eax = 0xB101; // detect presence of the PCI Bios int86( 0x1A, vm ); int version = vm.regs.ebx; printf( "\nPCI Bios version: %X.%X ", version >> 8, version & 0xFF ); printf( "Number of PCI buses: %d \n\n", vm.regs.ecx & 0xFF ); for (int i = 0; i < 0xFFFF; i++) { vm.regs.eax = 0xB103; // find PCI Class vm.regs.ecx = CLASS_SVGA; vm.regs.esi = i; // device index int86( 0x1A, vm ); if ( ( vm.regs.eax & 0xFF00 ) == 0x8600 ) break; printf( "VGA display device #%d: ", i ); printf( "bus=%d ", (vm.regs.ebx >> 8) & 0xFF ); printf( "device=%d ", ( vm.regs.ebx >> 3 )&0x1F ); printf( "function=%d ", (vm.regs.ebx >> 0 )&0x07 ); for (int j = 0; j < 256; j+=4) { if ( ( j % 32 ) == 0 ) printf( "\n%02X: ", j ); vm.regs.eax = 0xB10A; // read PCI Config Dword vm.regs.edi = j; int86( 0x1A, vm ); printf( "%08X ", vm.regs.ecx ); } printf( "\n\n" ); } }