From f54227c580be1552979622dd7e590cbf3ae328f0 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 4 Oct 2002 02:44:56 +0000 Subject: 2002-10-03 Roland McGrath * i386/i386/gdt.h (KERNEL_CS, KERNEL_DS, KERNEL_TSS, KERNEL_LDT): Values changed, new GDT layout not matching oskit base_gdt.h defaults. (BASE_KERNEL_CS, BASE_KERNEL_DS): New macros with to oskit's values. * oskit/x86/main.c (ktss): Variable moved to gdt.c. (main): Don't diddle the tss here. * i386/i386/gdt.c (gdt_init): Do it here instead. * oskit/x86/main.c (my_exit): Restore oskit's base_gdt. * oskit/x86/main.c (main): BASE_TSS -> KERNEL_TSS * i386/i386/mp_desc.c (mp_desc_load): Likewise. --- oskit/x86/main.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/oskit/x86/main.c b/oskit/x86/main.c index 817f574f..9627b4c6 100644 --- a/oskit/x86/main.c +++ b/oskit/x86/main.c @@ -24,10 +24,10 @@ #include #include #include -#include #include #include #include +#include "gdt.h" #include @@ -43,13 +43,6 @@ #include -/* The BASE_TSS in OSKit has no I/O permission bitmap, but we want - one. So we replace it with an extended TSS at link-time. */ -#include -#include -static struct task_tss ktss; -extern struct x86_tss base_tss __attribute__ ((alias ("ktss"))); - /* As of 2000-12-21 the oskit has an incorrect value for this constant in , so we redefine it with the correct one. */ #undef CR4_PGE @@ -152,15 +145,11 @@ main (int argc, char **argv) int_init(); ldt_init(); - /* Set up the BASE_TSS to include an I/O permission bitmap. */ - fill_descriptor(&base_gdt[sel_idx(BASE_TSS)], - kvtolin(&ktss), - sizeof(struct task_tss) - 1, - ACC_P|ACC_PL_K|ACC_TSS, 0); - ktss.tss.io_bit_map_offset = IOPB_INVAL; - ktss.barrier = 0xFF; - /* This will also reload the TSS. */ - base_cpu_load(); + base_cpu_load(); /* Load all the new tables into the CPU. */ + + /* Now reload the TSS using our slot instead of the oskit's. */ + base_gdt[sel_idx (KERNEL_TSS)].access &= ~ACC_TSS_BUSY; + set_tr(KERNEL_TSS); /* Arrange a callback to our special exit function below, so we can try to return to a state the generic oskit reboot code can cope with. */ @@ -246,6 +235,10 @@ my_exit (int rc) set_cr4 (get_cr4 () &~ CR4_PGE); set_pdbr (kvtophys (kernel_page_dir)); + /* Reload the oskit's GDT slots. */ + base_gdt_init (); + base_gdt_load (); + asm volatile (" ljmp %0,$1f \n" /* Switch to LINEAR_CS, */ "1: movw %w1,%%ds\n" /* Switch %ds to LINEAR_DS. */ " movw %w1,%%es\n" /* Switch %es to LINEAR_DS. */ @@ -385,4 +378,10 @@ void machine_init() /* Catch interrupt stack overflow. */ set_b0 (kvtolin (&base_stack_start), DR7_LEN_4, DR7_RW_DATA); base_gdt_load(); /* necessary after setting debug regs */ + + /* That loaded the oskit's selectors. Now reload ours. */ + asm volatile("ljmp %0,$1f\n\t1:" : : "i" (KERNEL_CS)); + set_ds(KERNEL_DS); + set_es(KERNEL_DS); + set_ss(KERNEL_DS); } -- cgit v1.2.3