//------------------------------------------------------------------- // showrbda.cpp // // This program shows the contents of the ROM-BIOS DATA AREA in // hexadecimal format (it employs a custom device-driver module // to support mapping of the relevant area of physical memory). // // These preliminary steps required (to create the device-file) // before executing this program for the first time: // $ sudo mkdir /dev/dos c 86 0 // $ sudo chmod a+rwx /dev/dos // // NOTE: Developed and tested with Linux kernel version 2.4.23. // // programmer: ALLAN CRUSE // written on: 23 JAN 2004 //------------------------------------------------------------------- #include // for printf(), perror() #include // for open() #include // for exit(), system() #include // for close() #include // for mmap() #define N_WORDS 128 // number of words in ROM-BIOS DATA-AREA char devname[] = "/dev/dos"; int main( int argc, char **argv ) { // install our custom device-driver module system( "/sbin/insmod dos.o" ); // open the device special file for reading int fd = open( devname, O_RDONLY ); if ( fd < 0 ) { perror( devname ); exit(1); } // memory map the file's initial two killobytes int base = 0; int size = (2<<10); // 2KB int prot = PROT_READ; int flag = MAP_FIXED | MAP_PRIVATE; void *vm = (void*)base; if ( mmap( vm, size, prot, flag, fd, base ) == MAP_FAILED ) { perror( "mmap" ); exit(1); } // display the ROM-BIOS DATA AREA (0x00000400 - 0x00000500) unsigned short *wp = (unsigned short*)0x400; for (int i = 0; i < N_WORDS; i++) { if ( ( i % 8 ) == 0 ) printf( "\n%04X: ", &wp[i] ); printf( "%04X ", wp[i] ); } printf( "\n\n" ); }