summaryrefslogtreecommitdiff
path: root/multiboot.S
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2011-08-09 21:37:35 -0400
committerFrans Kaashoek <[email protected]>2011-08-09 21:37:35 -0400
commit66ba8079c7e376c189ccb3367b8d13825141b8ec (patch)
tree93343a9d7c9ea75a02c05e4ce078ef2d4a48e2da /multiboot.S
parent3a038106431314c85a5950c473b113a7037ac1aa (diff)
downloadxv6-labs-66ba8079c7e376c189ccb3367b8d13825141b8ec.tar.gz
xv6-labs-66ba8079c7e376c189ccb3367b8d13825141b8ec.tar.bz2
xv6-labs-66ba8079c7e376c189ccb3367b8d13825141b8ec.zip
Use static page table for boot, mapping first 4Mbyte; no more segment trick
Allocate proper kernel page table immediately in main using boot allocator Remove pginit Simplify address space layout a tiny bit More to come (e.g., superpages to simplify static table)
Diffstat (limited to 'multiboot.S')
-rw-r--r--multiboot.S27
1 files changed, 14 insertions, 13 deletions
diff --git a/multiboot.S b/multiboot.S
index 4aa9f20..84f4aa0 100644
--- a/multiboot.S
+++ b/multiboot.S
@@ -41,8 +41,8 @@ multiboot_header:
# boot loader - bootasm.S - sets up.
.globl multiboot_entry
multiboot_entry:
- lgdt V2P_WO(gdtdesc)
- ljmp $(SEG_KCODE<<3), $mbstart32
+# lgdt V2P_WO(gdtdesc)
+# ljmp $(SEG_KCODE<<3), $mbstart32
mbstart32:
# Set up the protected-mode data segment registers
@@ -54,21 +54,22 @@ mbstart32:
movw %ax, %fs # -> FS
movw %ax, %gs # -> GS
+ movl $(V2P_WO(bootpgdir)), %eax
+ movl %eax, %cr3
+ # Turn on paging.
+ movl %cr0, %eax
+ orl $(CR0_PE|CR0_PG|CR0_WP), %eax
+ movl %eax, %cr0
+
+ # now switch to using addresses above KERNBASE
+ # call addresses are pc-relative so we jump though this hoop:
+ mov $relocated, %eax
+ jmp *%eax
+relocated:
# Set up the stack pointer and call into C.
movl $(stack + STACK), %esp
call main
spin:
jmp spin
-# Bootstrap GDT
-.p2align 2 # force 4 byte alignment
-gdt:
- SEG_NULLASM # null seg
- SEG_ASM(STA_X|STA_R, -KERNBASE, 0xffffffff) # code seg
- SEG_ASM(STA_W, -KERNBASE, 0xffffffff) # data seg
-
-gdtdesc:
- .word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
- .long V2P_WO(gdt) # address gdt
-
.comm stack, STACK