From faad047ab22cbe989c208bff5ecb42608ecb8d7b Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Mon, 13 Sep 2010 15:34:44 -0400 Subject: change some comments, maybe more informative delete most comments from bootother.S (since copy of bootasm.S) ksegment() -> seginit() move more stuff from main() to mainc() --- bootasm.S | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bootasm.S') diff --git a/bootasm.S b/bootasm.S index 56175ce..f5d1678 100644 --- a/bootasm.S +++ b/bootasm.S @@ -13,7 +13,7 @@ .code16 # Assemble for 16-bit mode .globl start start: - cli # Disable interrupts + cli # BIOS enabled interrupts ; disable # Set up the important data segment registers (DS, ES, SS). xorw %ax,%ax # Segment number zero @@ -45,7 +45,8 @@ seta20.2: # Switch from real to protected mode, using a bootstrap GDT # and segment translation that makes virtual addresses # identical to physical addresses, so that the - # effective memory map does not change during the switch. + # effective memory map does not change after subsequent + # loads of segment registers. lgdt gdtdesc movl %cr0, %eax orl $CR0_PE, %eax @@ -57,7 +58,11 @@ seta20.2: # default to 32 bits after this jump. ljmp $(SEG_KCODE<<3), $start32 -.code32 # Assemble for 32-bit mode +# tell the assembler to generate 0x66 prefixes for 16-bit +# instructions like movw, and to generate 32-bit immediate +# addresses. +.code32 + start32: # Set up the protected-mode data segment registers movw $(SEG_KDATA<<3), %ax # Our data segment selector -- cgit v1.2.3 From cf4b1ad90bcaeeb0c8458098c87948f61d408f94 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 19 Feb 2011 21:17:55 -0500 Subject: xv6: formatting, cleanup, rev5 (take 2) --- bootasm.S | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'bootasm.S') diff --git a/bootasm.S b/bootasm.S index f5d1678..3cc23e7 100644 --- a/bootasm.S +++ b/bootasm.S @@ -13,7 +13,7 @@ .code16 # Assemble for 16-bit mode .globl start start: - cli # BIOS enabled interrupts ; disable + cli # BIOS enabled interrupts; disable # Set up the important data segment registers (DS, ES, SS). xorw %ax,%ax # Segment number zero @@ -21,10 +21,8 @@ start: movw %ax,%es # -> Extra Segment movw %ax,%ss # -> Stack Segment - # Enable A20: - # For backwards compatibility with the earliest PCs, physical - # address line 20 is tied low, so that addresses higher than - # 1MB wrap around to zero by default. This code undoes this. + # Physical address line A20 is tied to zero so that the first PCs + # with 2 MB would run software that assumed 1 MB. Undo that. seta20.1: inb $0x64,%al # Wait for not busy testb $0x2,%al @@ -41,28 +39,21 @@ seta20.2: movb $0xdf,%al # 0xdf -> port 0x60 outb %al,$0x60 -//PAGEBREAK! - # Switch from real to protected mode, using a bootstrap GDT - # and segment translation that makes virtual addresses - # identical to physical addresses, so that the - # effective memory map does not change after subsequent - # loads of segment registers. + # Switch from real to protected mode. Use a bootstrap GDT that makes + # virtual addresses map dierctly to physical addresses so that the + # effective memory map doesn't change during the transition. lgdt gdtdesc movl %cr0, %eax orl $CR0_PE, %eax movl %eax, %cr0 - - # This ljmp is how you load the CS (Code Segment) register. - # SEG_ASM produces segment descriptors with the 32-bit mode - # flag set (the D flag), so addresses and word operands will - # default to 32 bits after this jump. - ljmp $(SEG_KCODE<<3), $start32 -# tell the assembler to generate 0x66 prefixes for 16-bit -# instructions like movw, and to generate 32-bit immediate -# addresses. -.code32 +//PAGEBREAK! + # Complete transition to 32-bit protected mode by using long jmp + # to reload %cs and %eip. The segment registers are set up with no + # translation, so that the mapping is still the identity mapping. + ljmp $(SEG_KCODE<<3), $start32 +.code32 # Tell assembler to generate 32-bit code now. start32: # Set up the protected-mode data segment registers movw $(SEG_KDATA<<3), %ax # Our data segment selector -- cgit v1.2.3