//------------------------------------------------------------------- // cr4.c // // This module creates a pseudo-file (named '/proc/cr4') which // allows applications to obtain the current value held in the // processor's CR4 register. Individual bits in this register // are set by the operating system to either enable or disable // special features of the Pentium's operations (including the // scheme by which the CPU translates virtual memory-addresses // to physical memory-addresses). Refer to Volume 3 of "IA-32 // Intel Architecture Software Developer's Manual" (Chapter 2) // for detailed explanation of all bits in Control Register 4. // // NOTE: Developed and tested with Linux kernel version 2.6.9. // // programmer: ALLAN CRUSE // written on: 07 JAN 2005 //------------------------------------------------------------------- #include // for init_module() #include // for create_proc_info_entry() static char modname[] = "cr4"; static int cr4; static int my_get_info( char *buf, char **start, off_t off, int count ) { int len = 0; asm(" movl %cr4, %ebx \n movl %ebx, cr4 "); len += sprintf( buf+len, "cr4=%08X ", cr4 ); len += sprintf( buf+len, "PSE=%X ", (cr4>>4)&1 ); len += sprintf( buf+len, "PAE=%X ", (cr4>>5)&1 ); len += sprintf( buf+len, "\n" ); return len; } int init_module( void ) { printk( "<1>\nInstalling \'%s\' module\n", modname ); create_proc_info_entry( modname, 0, NULL, my_get_info ); return 0; // SUCCESS } void cleanup_module( void ) { remove_proc_entry( modname, NULL ); printk( "<1>Removing \'%s\' module\n", modname ); } MODULE_LICENSE("GPL");