diff options
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 |