diff options
author | rsc <rsc> | 2009-03-08 21:41:30 +0000 |
---|---|---|
committer | rsc <rsc> | 2009-03-08 21:41:30 +0000 |
commit | b7f653dc49dd4af29a3b7bdd66cd712bea166623 (patch) | |
tree | e3bc07bdacacf2a7e311f3a87bbad243e5ba79d7 /bootasm.S | |
parent | 8220135362c02b5e4a5532a561c6c1bd4b4d1540 (diff) | |
download | xv6-labs-b7f653dc49dd4af29a3b7bdd66cd712bea166623.tar.gz xv6-labs-b7f653dc49dd4af29a3b7bdd66cd712bea166623.tar.bz2 xv6-labs-b7f653dc49dd4af29a3b7bdd66cd712bea166623.zip |
xv6: boot loader adjustments
do Bochs breakpoint and spin in bootasm.S.
not needed in bootmain too.
fix readseg bug (rounding of va).
zero segments when memsz > filesz.
no need to clear BSS in kernel main.
make bootother.S like bootasm.S
Diffstat (limited to 'bootasm.S')
-rw-r--r-- | bootasm.S | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -5,13 +5,13 @@ # memory at physical address 0x7c00 and starts executing in real mode # with %cs=0 %ip=7c00. -.set PROT_MODE_CSEG, 0x8 # kernel code segment selector -.set PROT_MODE_DSEG, 0x10 # kernel data segment selector -.set CR0_PE_ON, 0x1 # protected mode enable flag +.set CSEG32, 0x8 # kernel code segment selector +.set DSEG32, 0x10 # kernel data segment selector +.set CR0_PE, 0x1 # protected mode enable flag +.code16 # Assemble for 16-bit mode .globl start start: - .code16 # Assemble for 16-bit mode cli # Disable interrupts cld # String operations increment @@ -48,17 +48,17 @@ seta20.2: # effective memory map does not change during the switch. lgdt gdtdesc movl %cr0, %eax - orl $CR0_PE_ON, %eax + orl $CR0_PE, %eax movl %eax, %cr0 # Jump to next instruction, but in 32-bit code segment. # Switches processor into 32-bit mode. - ljmp $PROT_MODE_CSEG, $protcseg + ljmp $CSEG32, $start32 - .code32 # Assemble for 32-bit mode -protcseg: +.code32 # Assemble for 32-bit mode +start32: # Set up the protected-mode data segment registers - movw $PROT_MODE_DSEG, %ax # Our data segment selector + movw $DSEG32, %ax # Our data segment selector movw %ax, %ds # -> DS: Data Segment movw %ax, %es # -> ES: Extra Segment movw %ax, %fs # -> FS @@ -69,7 +69,13 @@ protcseg: movl $start, %esp call bootmain - # If bootmain returns (it shouldn't), loop. + # If bootmain returns (it shouldn't), trigger a Bochs + # breakpoint if running under Bochs, then loop. + movw $0x8a00, %ax # 0x8a00 -> port 0x8a00 + movw %ax, %dx + outw %ax, %dx + movw $0x8e00, %ax # 0x8e00 -> port 0x8a00 + outw %ax, %dx spin: jmp spin |