//------------------------------------------------------------------- // vramscan.cpp // // This program should be executed in a terminal window on the // graphical desktop. It adjusts the CRTC Start-Address value // to allow a user to see the entire contents of video memory. // // NOTE: The value of the global variable 'pitch' will need to // be modified if the desktop graphics display mode is not set // up for truecolor with horizontal resolution of 1280-pixels. // // compile using: $ g++ vramscan.cpp int86.cpp -o vramscan // // programmer: ALLAN CRUSE // written on: 11 OCT 2005 //------------------------------------------------------------------- #include // for printf(), perror() #include // for open() #include // for exit() #include // for lseek() #include // for inb(), outl(), etc. #include "int86.h" // for init8086(), int86() #define VENDOR_ID 0x1002 // Advanced Technologies, Inc, #define DEVICE_ID 0x5B60 // ATI Radeon X300 //#define DEVICE_ID 0x5159 // ATI Radeon 7000 //#define DEVICE_ID 0x5960 // ATI Radeon 9250 Pro #define CRT_START_ADDR 0x0224 #define CRTC_PITCH 0x022C #define MM_INDEX 0 #define MM_DATA 4 unsigned char *vram = (unsigned char*)0xA0000000; struct vm86plus_struct vm; int iobase, pitch = 1280*4; void set_crt_start_address( unsigned int start_address ) { outl( CRT_START_ADDR, iobase + MM_INDEX ); outl( start_address, iobase + MM_DATA ); } int main( int argc, char **argv ) { // obtain the port-address for the Radeon engine init8086(); vm.regs.eax = 0xB102; // PCI Find Device vm.regs.ecx = DEVICE_ID; // Device ID vm.regs.edx = VENDOR_ID; // Vendor ID vm.regs.esi = 0x0000; // device index int86( 0x1A, vm ); // invoke BIOS service if ( ( vm.regs.eax & 0xFF00 ) == 0 ) { vm.regs.eax = 0xB10A; // PCI Read Config Dword vm.regs.edi = 0x0014; // register number int86( 0x1A, vm ); // invoke BIOS service iobase = vm.regs.ecx & ~3; fprintf( stderr, "iobase=%04X \n", iobase ); getchar(); } else { fprintf( stderr, "ioport not found\n" ); exit(1); } // obtain the size of the installed video memory int vd = open( "/dev/vram", O_RDWR ); if ( vd < 0 ) { perror( "/dev/vram" ); exit(1); } int size = lseek( vd, 0, SEEK_END ); // wait until the user is ready to begin the memory-scan printf( "\nHit to begin scanning video memory\n" ); getchar(); // this loop performs a forward scan of video memory for (int i = 0; i < size; i+= pitch) { set_crt_start_address( i ); while ( (inb( 0x3DA )&8) == 8 ); while ( (inb( 0x3DA )&8) == 0 ); } getchar(); set_crt_start_address( 0 ); printf( "demo is finished\n" ); }