1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Added comments to x64/boot.s.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-09-21 21:08:43 +02:00
parent ab2b14fc16
commit f1848b9932

View file

@ -23,7 +23,6 @@
******************************************************************************/ ******************************************************************************/
.globl start, _start .globl start, _start
.section .text .section .text
@ -36,16 +35,16 @@ _start:
jmp multiboot_entry jmp multiboot_entry
# Align 32 bits boundary. # Align 32 bits boundary.
.align 4 .align 4
# Multiboot header. # Multiboot header.
multiboot_header: multiboot_header:
# Magic. # Magic.
.long 0x1BADB002 .long 0x1BADB002
# Flags. # Flags.
.long 0x00000003 .long 0x00000003
# Checksum. # Checksum.
.long -(0x1BADB002 + 0x00000003) .long -(0x1BADB002 + 0x00000003)
multiboot_entry: multiboot_entry:
@ -59,6 +58,7 @@ multiboot_entry:
# Store the magic value. # Store the magic value.
mov %eax, 0x100004 mov %eax, 0x100004
# Clear the first 4096*4 bytes following 0x1000.
movl $0x1000, %edi movl $0x1000, %edi
mov %edi, %cr3 mov %edi, %cr3
xorl %eax, %eax xorl %eax, %eax
@ -66,6 +66,7 @@ multiboot_entry:
rep stosl rep stosl
movl %cr3, %edi movl %cr3, %edi
# Set the initial page tables.
movl $0x2003, (%edi) movl $0x2003, (%edi)
addl $0x1000, %edi addl $0x1000, %edi
@ -75,6 +76,7 @@ multiboot_entry:
movl $0x4003, (%edi) movl $0x4003, (%edi)
addl $0x1000, %edi addl $0x1000, %edi
# Memory map the first 2 MiB.
movl $0x3, %ebx movl $0x3, %ebx
movl $512, %ecx movl $512, %ecx
@ -84,27 +86,33 @@ SetEntry:
add $8, %edi add $8, %edi
loop SetEntry loop SetEntry
# Enable PAE.
mov %cr4, %eax mov %cr4, %eax
orl $0x20, %eax orl $0x20, %eax
mov %eax, %cr4 mov %eax, %cr4
# Enable long mode.
mov $0xC0000080, %ecx mov $0xC0000080, %ecx
rdmsr rdmsr
orl $0x100, %eax orl $0x100, %eax
wrmsr wrmsr
# Enable paging and enter long mode (still 32-bit)
mov %cr0, %eax mov %cr0, %eax
orl $0x80000000, %eax orl $0x80000000, %eax
mov %eax, %cr0 mov %eax, %cr0
# Load the long mode GDT.
mov GDTPointer, %eax mov GDTPointer, %eax
lgdtl GDTPointer lgdtl GDTPointer
# Now use the 64-bit code segment, and we are in full 64-bit mode.
ljmp $0x10, $Realm64 ljmp $0x10, $Realm64
.code64 .code64
Realm64: Realm64:
# Now, set up the other segment registers.
cli cli
mov $0x18, %ax mov $0x18, %ax
mov %ax, %ds mov %ax, %ds
@ -112,14 +120,8 @@ Realm64:
mov %ax, %fs mov %ax, %fs
mov %ax, %gs mov %ax, %gs
# Alright, that was the bootstrap code. Now begin preparing to run the
# actual 64-bit kernel.
# Disable virtual memory
#movq %cr0, %rdi
#movabs $0xffffffff7fffffff, %rbx
#andq %rbx, %rdi
#movq %rdi, %cr0
jmp Main jmp Main
.section .data .section .data
@ -163,7 +165,6 @@ Main:
movq %r15, %rax movq %r15, %rax
movw %ax, 0xB8000 movw %ax, 0xB8000
# Load the pointer to the Multiboot information structure. # Load the pointer to the Multiboot information structure.
mov 0x100000, %ebx mov 0x100000, %ebx