more comments in entryother.S

This commit is contained in:
Robert Morris 2016-08-10 11:35:28 -04:00
parent 0a69dc9b17
commit 3431cd4927
2 changed files with 22 additions and 15 deletions

View file

@ -17,37 +17,43 @@
# place to jump to (mpenter) in start-8, and the physical address # place to jump to (mpenter) in start-8, and the physical address
# of entrypgdir in start-12. # of entrypgdir in start-12.
# #
# This code is identical to bootasm.S except: # This code combines elements of bootasm.S and entry.S.
# - it does not need to enable A20
# - it uses the address at start-4, start-8, and start-12
.code16 .code16
.globl start .globl start
start: start:
cli cli
# Zero data segment registers DS, ES, and SS.
xorw %ax,%ax xorw %ax,%ax
movw %ax,%ds movw %ax,%ds
movw %ax,%es movw %ax,%es
movw %ax,%ss movw %ax,%ss
# Switch from real to protected mode. Use a bootstrap GDT that makes
# virtual addresses map directly to physical addresses so that the
# effective memory map doesn't change during the transition.
lgdt gdtdesc lgdt gdtdesc
movl %cr0, %eax movl %cr0, %eax
orl $CR0_PE, %eax orl $CR0_PE, %eax
movl %eax, %cr0 movl %eax, %cr0
//PAGEBREAK! //PAGEBREAK!
# Complete the transition to 32-bit protected mode by using a long jmp
# to reload %cs and %eip. The segment descriptors are set up with no
# translation, so that the mapping is still the identity mapping.
ljmpl $(SEG_KCODE<<3), $(start32) ljmpl $(SEG_KCODE<<3), $(start32)
.code32 .code32 # Tell assembler to generate 32-bit code now.
start32: start32:
movw $(SEG_KDATA<<3), %ax # Set up the protected-mode data segment registers
movw %ax, %ds movw $(SEG_KDATA<<3), %ax # Our data segment selector
movw %ax, %es movw %ax, %ds # -> DS: Data Segment
movw %ax, %ss movw %ax, %es # -> ES: Extra Segment
movw $0, %ax movw %ax, %ss # -> SS: Stack Segment
movw %ax, %fs movw $0, %ax # Zero segments not ready for use
movw %ax, %gs movw %ax, %fs # -> FS
movw %ax, %gs # -> GS
# Turn on page size extension for 4Mbyte pages # Turn on page size extension for 4Mbyte pages
movl %cr4, %eax movl %cr4, %eax

9
main.c
View file

@ -98,10 +98,11 @@ startothers(void)
} }
} }
// Boot page table used in entry.S and entryother.S. // The boot page table used in entry.S and entryother.S.
// Page directories (and page tables), must start on a page boundary, // Page directories (and page tables) must start on page boundaries,
// hence the "__aligned__" attribute. // hence the __aligned__ attribute.
// Use PTE_PS in page directory entry to enable 4Mbyte pages. // PTE_PS in a page directory entry enables 4Mbyte pages.
__attribute__((__aligned__(PGSIZE))) __attribute__((__aligned__(PGSIZE)))
pde_t entrypgdir[NPDENTRIES] = { pde_t entrypgdir[NPDENTRIES] = {
// Map VA's [0, 4MB) to PA's [0, 4MB) // Map VA's [0, 4MB) to PA's [0, 4MB)