x86_64: GS base work
[akaros.git] / kern / arch / x86 / cpuinfo.c
index 9233299..0ef9a1e 100644 (file)
@@ -27,6 +27,10 @@ void print_cpuinfo(void)
        char vendor_id[13];
        extern char (SNT RO _start)[];
 
+       if (sizeof(long) == 8)
+               printk("64 bit Kernel Booting...\n");
+       else
+               printk("32 bit Kernel Booting...\n");
        asm volatile ("cpuid;"
                  "movl    %%ebx, (%2);"
                  "movl    %%edx, 4(%2);"
@@ -107,17 +111,9 @@ void print_cpuinfo(void)
        printk("\n");
        cpuid(0x80000008, 0x0, &eax, &ebx, &ecx, &edx);
        cprintf("Physical Address Bits: %d\n", eax & 0x000000FF);
-       cprintf("Cores per Die: %d\n", (ecx & 0x000000FF) + 1);
-    cprintf("This core's Default APIC ID: 0x%08x\n", lapic_get_default_id());
        msr_val = read_msr(IA32_APIC_BASE);
-       if (msr_val & MSR_APIC_ENABLE)
-               cprintf("Local APIC Enabled\n");
-       else
-               cprintf("Local APIC Disabled\n");
-       if (msr_val & 0x00000100)
-               cprintf("I am the Boot Strap Processor\n");
-       else
-               cprintf("I am an Application Processor\n");
+       if (!(msr_val & MSR_APIC_ENABLE))
+               panic("Local APIC Disabled!!");
        cpuid(0x80000007, 0x0, &eax, &ebx, &ecx, &edx);
        if (edx & 0x00000100)
                printk("Invariant TSC present\n");
@@ -134,6 +130,13 @@ void print_cpuinfo(void)
        else
                printk("RDTSCP not supported: don't trust detailed measurements\n");
        printk("FS/GS MSRs %ssupported\n", edx & (1 << 29) ? "" : "not ");
+       #ifdef CONFIG_X86_64
+       if (!(edx & (1 << 29))) {
+               printk("Can't handle no FS/GS MSRs!\n");
+               while (1)
+                       asm volatile ("hlt");
+       }
+       #endif
        msr_val = read_msr(IA32_MISC_ENABLE);
        /* we want this to be not set for cpuid.6h to work. */
        if (msr_val & (1 << 22))
@@ -145,17 +148,25 @@ void print_cpuinfo(void)
                printk("Always running APIC *not* detected\n");
 }
 
+#ifdef CONFIG_X86_64
+#define BIT_SPACING "        "
+#define BIT_DASHES "----------------"
+#else
+#define BIT_SPACING ""
+#define BIT_DASHES ""
+#endif
+
 void show_mapping(uintptr_t start, size_t size)
 {
-       pde_t LCKD(&vpd_lock) *CT(PTSIZE) pgdir =
-           (pde_t LCKD(&vpd_lock) *CT(PTSIZE))vpd;
+       pde_t *pgdir = (pde_t*)vpd;
        pte_t *pte;
-       pte_t LCKD(&vpd_lock) *pde;
+       pte_t *pde;
        page_t *page;
        uintptr_t i;
 
-       printk("   Virtual    Physical  Ps Dr Ac CD WT U W P\n");
-       printk("--------------------------------------------\n");
+       printk("   %sVirtual    %sPhysical  Ps Dr Ac CD WT U W P\n", BIT_SPACING,
+              BIT_SPACING);
+       printk("--------------------------------------------%s\n", BIT_DASHES);
        for(i = 0; i < size; i += PGSIZE, start += PGSIZE) {
                pte = pgdir_walk(pgdir, (void*)start, 0);
                printk("%p  ", start);