unified comment fontcase

This commit is contained in:
Steffen Vogel 2014-01-09 13:41:22 +01:00
parent 88a2e573c6
commit 269bffc208

View file

@ -81,11 +81,11 @@ GDT64: ; Global Descriptor Table (64-bit).
dw $ - GDT64 - 1 ; Limit.
dq GDT64 ; Base.
times 256 DD 0 ; stack for booting
times 256 DD 0 ; Stack for booting
startup_stack:
SECTION .data
; create default page tables for the 64bit kernel
; Create default page tables for the 64bit kernel
global boot_pml4
ALIGN 4096 ; of course, the page tables have to be page aligned
@ -102,37 +102,37 @@ ALIGN 8
%if MAX_CORES > 1
global smp_entry
smp_entry:
; initialize cpu features
; Initialize cpu features
call cpu_init
; initialize cr3 register
; Initialize cr3 register
mov edi, boot_pml4
mov cr3, edi
; enable PAE
; Enable PAE
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
; enable longmode (compatibility mode)
; Enable longmode (compatibility mode)
mov ecx, 0xC0000080
rdmsr
or eax, 1 << 8
wrmsr
; enable paging
; Enable paging
mov eax, cr0
or eax, 1 << 31 | 1 << 0 ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit.
mov cr0, eax ; According to the multiboot spec the PE-bit has to be set by bootloader already!
or eax, 1 << 31 | 1 << 0 ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit.
mov cr0, eax ; According to the multiboot spec the PE-bit has to be set by bootloader already!
; jump to 64-bit longmode
mov edi, [esp+4] ; set argumet for smp_start
; Jump to 64-bit longmode
mov edi, [esp+4] ; Set argumet for smp_start
lgdt [GDT64.Pointer] ; Load the 64-bit global descriptor table.
jmp GDT64.Code:smp_start64 ; Set the code segment and enter 64-bit long mode.
jmp $ ; endless loop
%endif
; search MP Floating Pointer Structure
; Search MP Floating Pointer Structure
search_mps:
push ebp
mov ebp, esp
@ -164,7 +164,7 @@ search_mps:
ret
check_longmode:
; check for cpuid instruction
; Check for cpuid instruction
pushfd
pop eax
mov ecx, eax
@ -177,12 +177,12 @@ check_longmode:
popfd
xor eax, ecx
jz .unsupported
; check for extended cpu features (cpuid > 0x80000000)
; Check for extended cpu features (cpuid > 0x80000000)
mov eax, 0x80000000
cpuid
cmp eax, 0x80000001
jb .unsupported ; It is less, there is no long mode.
; check if longmode is supported
; Check if longmode is supported
mov eax, 0x80000001
cpuid
test edx, 1 << 29 ; Test if the LM-bit, which is bit 29, is set in the D-register.
@ -201,7 +201,7 @@ check_lapic:
and edx, 0x200
cmp edx, 0
je .unsupported
; map lapic at 0xFEE00000 below the kernel
; Map lapic at 0xFEE00000 below the kernel
mov edi, kernel_start - 0x1000
shr edi, 9 ; (edi >> 12) * 8
add edi, boot_pgt
@ -217,12 +217,12 @@ check_lapic:
cpu_init:
mov eax, cr0
; enable caching, disable paging and fpu emulation
; Enable caching, disable paging and fpu emulation
and eax, 0x1ffffffb
; ...and turn on FPU exceptions
or eax, 0x22
mov cr0, eax
; clears the current pgd entry
; Clear the current pgd entry
xor eax, eax
mov cr3, eax
; at this stage, we disable the SSE support
@ -231,18 +231,20 @@ cpu_init:
mov cr4, eax
ret
; identity map a single page at address eax
; Identity map a single page at address eax
identity_page:
push edi
push ebx
and eax, 0xFFFFF000
mov edi, eax
and edi, 0xFFFFF000 ; page align in lower half
shr edi, 9 ; (edi >> 12) * 8 (index for boot_pgt)
add edi, boot_pgt
mov ebx, eax
or ebx, 0x113 ; set present, global, writable and cache disable bits
and ebx, 0xFFFFF000 ; page align lower half
or ebx, 0x113 ; set present, global, writable and cache disable bits
mov DWORD [edi], ebx
mov DWORD [edi+4], 0x80000000 ; set execution disable bit in higher half
pop ebx
pop edi
@ -251,16 +253,16 @@ identity_page:
ALIGN 4
stublet:
mov esp, startup_stack-4
; save pointer to the Multiboot structure
; Save pointer to the Multiboot structure
push ebx
; initialize cpu features
; Initialize cpu features
call cpu_init
; check if longmode is supported
; Check if longmode is supported
call check_longmode
; check if lapic is available
; Check if lapic is available
call check_lapic
; find MP Floating Pointer structure
; Find MP Floating Pointer structure
push DWORD 0x100000
push DWORD 0xF0000
call search_mps
@ -278,22 +280,22 @@ stublet:
je map_kernel
map_mps:
; map MP Floating Pointer structure
; Map MP Floating Pointer structure
mov DWORD [apic_mp], eax
call identity_page
; map MP Configuration table
mov eax, [apic_mp+4]
; Map MP Configuration table
mov eax, [eax+4] ; Offset for physical address of MP table
call identity_page
%ifdef CONFIG_VGA
; map VGA textmode plane
; Map VGA textmode plane
mov eax, 0xB8000
call identity_page
%endif
; map Multiboot structure
mov eax, [esp] ; pointer is still on the stack
; Map Multiboot structure
mov eax, [esp] ; Pointer is still on the stack
call identity_page
map_kernel:
@ -317,67 +319,67 @@ init_paging:
mov cr3, edi
mov DWORD [edi], boot_pdpt
or DWORD [edi], 0x07 ; set present, user and writable flags
or DWORD [edi], 0x03 ; Set present and writable flags
mov edi, boot_pdpt
mov DWORD [edi], boot_pgd
or DWORD [edi], 0x03 ; set present and writable flags
or DWORD [edi], 0x03 ; Set present and writable flags
mov edi, boot_pgd
mov ebx, boot_pgt
mov ecx, PAGE_MAP_ENTRIES ; map all boot_pgt to the kernel space
mov ecx, PAGE_MAP_ENTRIES ; Map all boot_pgt to the kernel space
.l1:
mov DWORD [edi], ebx
or DWORD [edi], 0x03 ; set present and writable flags
or DWORD [edi], 0x03 ; Set present and writable flags
add edi, 8
add ebx, 0x1000
loop .l1
; enable PAE
; Enable PAE
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
; enable longmode (compatibility mode)
; Enable longmode (compatibility mode)
mov ecx, 0xC0000080
rdmsr
or eax, 1 << 8
or eax, 1 << 8 ; IA32_EFER.LME = 1
wrmsr
; enable paging
; Enable paging
mov eax, cr0
or eax, 1 << 31 | 1 << 0 ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit.
or eax, 1 << 31 | 1 << 0 ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit.
mov cr0, eax
; jump to 64-bit longmode
pop ebx ; restore pointer to multiboot structure
lgdt [GDT64.Pointer] ; Load the 64-bit global descriptor table.
jmp GDT64.Code:start64 ; Set the code segment and enter 64-bit long mode.
; Jump to 64-bit longmode
pop ebx ; Restore pointer to multiboot structure
lgdt [GDT64.Pointer] ; Load the 64-bit global descriptor table.
jmp GDT64.Code:start64 ; Set the code segment and enter 64-bit long mode.
[BITS 64]
start64:
; initialize segment registers
; Initialize segment registers
mov ax, GDT64.Data
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; set default stack pointer
; Set default stack pointer
mov rsp, boot_stack
add rsp, KERNEL_STACK_SIZE-16
; interpret multiboot information
; Interpret multiboot information
extern multiboot_init
mov rdi, rbx
call multiboot_init
; jump to the boot processors's C code
; Jump to the boot processors's C code
extern main
call main
jmp $
%if MAX_CORES > 1
smp_start64:
; initialize segment registers
; Initialize segment registers
mov ax, GDT64.Data
mov ds, ax
mov es, ax
@ -385,7 +387,7 @@ smp_start64:
mov gs, ax
mov ss, ax
; jump to the boot processors's C code
; Jump to the boot processors's C code
extern smp_start
call smp_start
jmp $