Checks for PSE support, just for yucks.
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 13 Feb 2009 20:01:45 +0000 (12:01 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 13 Feb 2009 20:01:45 +0000 (12:01 -0800)
kern/init.c
kern/pmap.c

index 2b27507..3e7362a 100644 (file)
@@ -13,6 +13,8 @@
 #include <kern/env.h>
 #include <kern/trap.h>
 
+void print_cpuinfo(void);
+
 void kernel_init(multiboot_info_t *mboot_info)
 {
        extern char (BND(__this, end) edata)[], (SNT end)[];
@@ -26,6 +28,8 @@ void kernel_init(multiboot_info_t *mboot_info)
        // Can't call cprintf until after we do this!
        cons_init();
 
+       print_cpuinfo();
+
        // Lab 2 memory management initialization functions
        i386_detect_memory();
        i386_vm_init();
@@ -93,6 +97,24 @@ void _warn(const char *file, int line, const char *fmt,...)
        va_end(ap);
 }
 
+void print_cpuinfo(void) {
+       int func_num;
+       char vendor_id[13];
+
+       asm volatile ("subl    %0, %0;
+                   cpuid;
+                   movl    %%ebx, (%1);
+                   movl    %%edx, 4(%1);
+                   movl    %%ecx, 8(%1)"
+                     : "=a"(func_num) 
+                                 : "D"(vendor_id)
+                     : "%ebx", "%ecx", "%edx");
+
+       vendor_id[12] = '\0';
+       cprintf("Largest Standard Function Number Supported: %d\n", func_num);
+       cprintf("Vendor ID: %s\n", vendor_id);
+}
+
 
        /* Backup of old shit that i hoard for no reason
         *
index 3855853..068fac4 100644 (file)
@@ -240,10 +240,16 @@ i386_vm_init(void)
        size_t n;
        bool pse;
 
-       // check for PSE support (TODO)
-       pse = 1;
+       // check for PSE support
+       asm volatile ("movl    $1, %%eax;
+                   cpuid;
+                   andl    $0x00000008, %%edx"
+                     : "=d"(pse) 
+                                 : 
+                     : "%eax");
        // turn on PSE
        if (pse) {
+               cprintf("PSE capability detected.\n");
                uint32_t cr4;
                cr4 = rcr4();
                cr4 |= CR4_PSE;