projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Break GDT, TSS out of init.c, mmu.h.
[pintos-anon]
/
src
/
threads
/
loader.S
diff --git
a/src/threads/loader.S
b/src/threads/loader.S
index 5a0262b58733315296f85ae9ff429711c8d81854..535c442c4f1f39a0d59cf43aa51c0e3cc8beee33 100644
(file)
--- a/
src/threads/loader.S
+++ b/
src/threads/loader.S
@@
-1,5
+1,6
@@
-#include "mmu.h"
#include "loader.h"
#include "loader.h"
+#include "mmu.h"
+#include "gdt.h"
##############################################################################
# Kernel loader.
##############################################################################
# Kernel loader.
@@
-12,6
+13,11
@@
# first byte of the kernel, where start.S is linked.
##############################################################################
# first byte of the kernel, where start.S is linked.
##############################################################################
+/* Flags in control register 0 */
+#define CR0_PE 0x00000001 /* Protection Enable. */
+#define CR0_EM 0x00000004 /* (Floating-point) Emulation. */
+#define CR0_PG 0x80000000 /* Paging. */
+
.globl start # Entry point
start: .code16 # This runs in real mode
cli # Disable interrupts
.globl start # Entry point
start: .code16 # This runs in real mode
cli # Disable interrupts
@@
-133,33
+139,33
@@
read_sector:
cmpl $KERNEL_LOAD_PAGES*8 + 1, %ebx
jnz read_sector
cmpl $KERNEL_LOAD_PAGES*8 + 1, %ebx
jnz read_sector
-##### Create temporary
PDE and PTE, set page directory pointer, and turn
-##### on paging.
+##### Create temporary
page directory and page table, set page
+#####
directory pointer, and turn
on paging.
##### FIXME? We could use a single 4 MB page instead of 1024 4 kB pages.
##### FIXME? We could use a single 4 MB page instead of 1024 4 kB pages.
- # Create
PDE
at 64 kB.
+ # Create
page directory
at 64 kB.
movl $0x10000, %edi
movl %edi, %cr3
movl $0x10000, %edi
movl %edi, %cr3
- # Fill
PDE
with zeroes.
+ # Fill
page directory
with zeroes.
subl %eax, %eax
movl $0x400, %ecx
rep stosl
subl %eax, %eax
movl $0x400, %ecx
rep stosl
- # Set PDE
entrie
s for 0 and LOADER_PHYS_BASE to point to the
- #
PTE
.
+ # Set PDEs for 0 and LOADER_PHYS_BASE to point to the
+ #
page table
.
movl $0x11000 | PG_U | PG_W | PG_P, %eax
movl %eax, 0x10000
movl %eax, 0x10000 | (LOADER_PHYS_BASE >> 20)
movl $0x11000 | PG_U | PG_W | PG_P, %eax
movl %eax, 0x10000
movl %eax, 0x10000 | (LOADER_PHYS_BASE >> 20)
- # Initialize
PTE
.
+ # Initialize
page table
.
movl $PG_U | PG_W | PG_P, %eax
movl $0x400, %ecx
1: stosl
addl $0x1000, %eax
loop 1b
movl $PG_U | PG_W | PG_P, %eax
movl $0x400, %ecx
1: stosl
addl $0x1000, %eax
loop 1b
- #
Enable
paging.
+ #
Turn on
paging.
movl %cr0, %eax
orl $CR0_PG, %eax
movl %eax, %cr0
movl %cr0, %eax
orl $CR0_PG, %eax
movl %eax, %cr0
@@
-206,17
+212,17
@@
panicmsg:
.byte 0
##### Memory size in 4 kB pages.
.byte 0
##### Memory size in 4 kB pages.
- .org LOADER_RAM_PAGES
+ .org LOADER_RAM_PAGES
- LOADER_BASE
ram_pages:
.long 0
##### Command-line arguments inserted by another utility.
##### The loader doesn't use these, but we note their
##### location here for easy reference.
ram_pages:
.long 0
##### Command-line arguments inserted by another utility.
##### The loader doesn't use these, but we note their
##### location here for easy reference.
- .org LOADER_CMD_LINE
+ .org LOADER_CMD_LINE
- LOADER_BASE
cmd_line:
.fill 0x80, 1, 0
##### Boot-sector signature for BIOS inspection.
cmd_line:
.fill 0x80, 1, 0
##### Boot-sector signature for BIOS inspection.
- .org LOADER_BIOS_SIG
+ .org LOADER_BIOS_SIG
- LOADER_BASE
.word 0xaa55
.word 0xaa55