X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fthreads%2Floader.S;h=11ab7c9e4d1e5f2bb6ddc1753532528ae1a65681;hb=15aa248a41556196803c75cb4f56ddad05f5d64e;hp=811d2b60be1f2c89706d51ae4dd6ef48dea99792;hpb=5b670fb86ef37f5a81188e940e5fe1b04b5824af;p=pintos-anon diff --git a/src/threads/loader.S b/src/threads/loader.S index 811d2b6..11ab7c9 100644 --- a/src/threads/loader.S +++ b/src/threads/loader.S @@ -70,12 +70,13 @@ start: cli cld -# Set up data segments and stack. +# Set up data segments. sub ax, ax mov es, ax mov ds, ax +# Set up stack segment. # Stack grows downward starting from us. # We don't ever use the stack so this is strictly speaking # unnecessary. @@ -109,7 +110,7 @@ start: mov al, 0xdf out 0x60, al -#### Get memory size, via interrupt 15h function 88h. Returns CF +#### Get memory size, via interrupt 15h function 88h, which returns CF #### clear if successful, with AX = (kB of physical memory) - 1024. #### This only works for memory sizes <= 65 MB, which should be fine #### for our purposes. We cap memory at 64 MB because that's all we @@ -118,6 +119,7 @@ start: mov ah, 0x88 int 0x15 jc panic + cli # BIOS might have enabled interrupts add eax, 1024 # Total kB memory cmp eax, 0x10000 # Cap at 64 MB jbe 1f @@ -140,11 +142,17 @@ start: # Also add identical PDEs starting at LOADER_PHYS_BASE. # See [IA32-v3] section 3.7.6 for a description of the bits in eax. +# A bug in some versions of GAS prevents us from using the straightforward +# mov es:[di + LOADER_PHYS_BASE / 1024 / 1024], eax +# so we calculate the displacement in bx instead. + mov eax, 0x11007 mov ecx, 0x11 - sub edi, edi + sub di, di + mov ebx, LOADER_PHYS_BASE + shr ebx, 20 1: mov es:[di], eax - mov es:LOADER_PHYS_BASE / 1024 / 1024[di], eax + mov es:[bx + di], eax add di, 4 add eax, 0x1000 loop 1b @@ -155,8 +163,8 @@ start: mov ax, 0x1100 mov es, ax mov eax, 0x7 - mov ecx, 0x4000 - sub edi, edi + mov cx, 0x4000 + sub di, di 1: mov es:[di], eax add di, 4 add eax, 0x1000 @@ -169,10 +177,6 @@ start: #### Switch to protected mode. -# First we turn off interrupts because we don't set up an IDT. - - cli - # Then we point the GDTR to our GDT. Protected mode requires a GDT. # We need a data32 prefix to ensure that all 32 bits of the GDT # descriptor are loaded (default is to load only 24 bits). @@ -310,7 +314,7 @@ panic: .code16 # We only panic in real mode. jmp 1b panicmsg: - .ascii "Loader panic!\r\n" + .ascii "Panic!" .byte 0 #### Memory size in 4 kB pages.