//------------------------------------------------------------------- // instatus.cpp // // This program produces a visualization for the state of the // SVGA's Input Status Register 1 by continuously drawing its // volatile contents to successive pixel-locations within the // graphics display memory (using a 1024x768 256-color mode); // the program terminates when the screen is completely full. // // compile using: $ g++ instatus.cpp int86.cpp -o instatus // // programmer: ALLAN CRUSE // written on: 13 SEP 2005 //------------------------------------------------------------------- #include // for printf(), perror() #include // for open() #include // for exit() #include // for lseek() #include // for mmap() #include // for inb() #include "int86.h" // for init8086(), int86() #define VRAM_BASE 0xA0000000 #define INPUT_STATUS_1 0x03DA unsigned char *vram = (unsigned char*)VRAM_BASE; int vesa_mode = 0x4105, hres = 1024, vres = 768; struct vm86plus_struct vm; int main( int argc, char **argv ) { // memory-map the graphics display-memory into user-space int vd = open( "/dev/vram", O_RDWR ); if ( vd < 0 ) { perror( "/dev/vram" ); exit(1); } int size = lseek( vd, 0, SEEK_END ); int prot = PROT_READ | PROT_WRITE; int flag = MAP_FIXED | MAP_SHARED; void *mm = (void*)VRAM_BASE; if ( mmap( mm, size, prot, flag, vd, 0 ) == MAP_FAILED ) { perror( "mmap" ); exit(1); } // enter graphics mode init8086(); // enable BIOS and I/O access vm.regs.eax = 0x4F02; // VESA Set Display Mode vm.regs.ebx = vesa_mode; // Specify Mode ID int86( 0x10, vm ); // invoke BIOS service // fill the visible screen with bytes from INPUT_STATUS_1 for (int pel = 0; pel < hres * vres; pel++) vram[ pel ] = inb( INPUT_STATUS_1 ); getchar(); // await -key // leave graphics mode vm.regs.eax = 0x0003; // VGA Set Display Mode 3 int86( 0x10, vm ); // invoke BIOS service printf( "\ndone\n\n" ); // show termination message }