PERFORCE change 28418 for review
Peter Wemm
peter at FreeBSD.org
Mon Apr 7 01:03:54 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=28418
Change 28418 by peter at peter_overcee on 2003/04/07 01:03:02
checkpoint. set %cs descriptor properly. L=1,D=1 is reserved
and causes a fault if I try and use it. (doh!)
upset jake and set proc0uarea and proc0kstack
dump gdt contents for debugging
deal with "elf64 kernel" vs "elf kernel"
Affected files ...
.. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#43 edit
Differences ...
==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#43 (text+ko) ====
@@ -590,7 +590,7 @@
0, /* segment descriptor priority level */
1, /* segment descriptor present */
1, /* long */
- 1, /* default 32 vs 16 bit size */
+ 0, /* default 32 vs 16 bit size */
1 /* limit granularity (byte/page units)*/ },
/* GDATA_SEL 2 Data Descriptor for kernel */
{ 0x0, /* segment base address */
@@ -1064,6 +1064,11 @@
p0kpa = allocpages(KSTACK_PAGES);
printf("p0kpa = 0x%lx\n", p0kpa);
+ proc0uarea = (struct user *)(p0upa + KERNBASE);
+ printf("proc0uarea = 0x%lx\n", proc0uarea);
+ proc0kstack = p0kpa + KERNBASE;
+ printf("proc0kstack = 0x%lx\n", proc0kstack);
+
/* Fill in the underlying page table pages */
/* Read-only from zero to physfree */
/* XXX not actually used, underneath 2M pages */
@@ -1111,18 +1116,11 @@
first = physfree;
printf("It is hammer_time!\n");
-printf("first = 0x%lx\n", first);
create_pagetables();
-printf("got to the end; activating page tables...\n");
-
load_cr3(IdlePML4);
-printf("it worked!\n");
-printf("yippee!\n");
-for(;;);
-
proc0.p_uarea = proc0uarea;
thread0.td_kstack = proc0kstack;
thread0.td_pcb = (struct pcb *)
@@ -1137,24 +1135,19 @@
preload_metadata = (caddr_t)(uintptr_t)(modulep + KERNBASE);
preload_bootstrap_relocate(KERNBASE);
- kmdp = preload_search_by_type("elf kernel");
+ kmdp = preload_search_by_type("elf64 kernel");
+ if (kmdp == NULL)
+ kmdp = preload_search_by_type("elf kernel");
boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
- kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
+ kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE;
/* Init basic tunables, hz etc */
init_param1();
+printf("gdt time, ugh\n");
/*
- * make gdt memory segments, the code segment goes up to end of the
- * page with etext in it, the data segment goes to the end of
- * the address space
- */
- /*
- * XXX text protection is temporarily (?) disabled. The limit was
- * i386_btop(round_page(etext)) - 1.
+ * make gdt memory segments
*/
- gdt_segs[GCODE_SEL].ssd_limit = -1;
- gdt_segs[GDATA_SEL].ssd_limit = -1;
gdt_segs[GPROC0_SEL].ssd_base = (uintptr_t)&common_tss.tss;
for (x = 0; x < NGDT; x++) {
@@ -1163,13 +1156,25 @@
}
ssdtosyssd(&gdt_segs[GPROC0_SEL], (struct system_segment_descriptor *)&gdt[GPROC0_SEL]);
+for (x = 0; x < NGDT; x++)
+printf("gdt slot %d: 0x%016lx\n", x, *(long *)&gdt[x]);
+
r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
r_gdt.rd_base = (long) gdt;
+printf("doing lgdt....\n");
lgdt(&r_gdt);
+printf("lgdt done\n");
+ pc = &__pcpu;
+
+printf("setting MSR_FSBASE and GSBASE to %p\n", pc);
+ wrmsr(MSR_FSBASE, (u_int64_t)pc);
+ wrmsr(MSR_GSBASE, (u_int64_t)pc);
- pc = &__pcpu;
+printf("pcpu init\n");
pcpu_init(pc, 0, sizeof(struct pcpu));
+printf("PCPU_SET(prvspace, pc)\n");
PCPU_SET(prvspace, pc);
+printf("PCPU_SET(curthread, &thread0)\n");
PCPU_SET(curthread, &thread0);
/*
@@ -1180,9 +1185,11 @@
* must be able to get the icu lock, so it can't be
* under witness.
*/
+printf("mutex init\n");
mutex_init();
mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_RECURSE);
mtx_init(&icu_lock, "icu", NULL, MTX_SPIN | MTX_NOWITNESS);
+for(;;);
/* exceptions */
for (x = 0; x < NIDT; x++)
More information about the p4-projects
mailing list