//------------------------------------------------------------------- // showivt.cpp // // This program shows the (Real Mode) INTERRUPT VECTOR TABLE 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 mknod /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: 27 JAN 2004 //------------------------------------------------------------------- #include // for printf(), perror() #include // for open() #include // for exit(), system() #include // for close() #include // for mmap() #define N_VECTORS 256 // the number of interrupt vectors 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 device-file's initial killobyte int base = 0; int size = (1<<10); // 1KB 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 INTERRUPT VECTOR TABLE (0x00000000 - 0x00000400) printf( "\nTABLE OF (REAL-MODE) INTERRUPT VECTORS \n" ); unsigned long *lp = (unsigned long*)0; for (int i = 0; i < N_VECTORS; i++) { if ( ( i % 8 ) == 0 ) printf( "\n#0x%02X: ", i ); printf( "%08X ", lp[i] ); } printf( "\n\n" ); }