diff --git a/sortix/x64/boot.s b/sortix/x64/boot.s index 7ebb80f9..636a4b83 100644 --- a/sortix/x64/boot.s +++ b/sortix/x64/boot.s @@ -31,7 +31,7 @@ .code32 start: _start: - jmp multiboot_entry + jmp prepare_kernel_execution # Align 32 bits boundary. .align 4 @@ -45,8 +45,7 @@ multiboot_header: # Checksum. .long -(0x1BADB002 + 0x00000003) -multiboot_entry: - +prepare_kernel_execution: # We got our multiboot information in various registers. But we are going # to need these registers. But where can we store them then? Oh hey, let's # store then in the code already run! @@ -127,6 +126,22 @@ Realm64: mov %ax, %fs mov %ax, %gs + # Enable the floating point unit. + mov %cr0, %rax + and $0xFFFD, %ax + or $0x10, %ax + mov %rax, %cr0 + fninit + + # Enable Streaming SIMD Extensions. + mov %cr0, %rax + and $0xFFFB, %ax + or $0x2, %ax + mov %rax, %cr0 + mov %cr4, %rax + or $0x600, %rax + mov %rax, %cr4 + # Alright, that was the bootstrap code. Now begin preparing to run the # actual 64-bit kernel. jmp Main diff --git a/sortix/x86/base.s b/sortix/x86/base.s index c02c11b3..6c2a71ce 100644 --- a/sortix/x86/base.s +++ b/sortix/x86/base.s @@ -28,9 +28,8 @@ .section .text .text 0x100000 -.type _beginkernel, @function +.type beginkernel, @function beginkernel: -_beginkernel: # Initialize the stack pointer. The magic value is from kernel.cpp. movl $stack, %esp addl $65536, %esp # 64 KiB, see kernel.cpp diff --git a/sortix/x86/boot.s b/sortix/x86/boot.s index 07394c40..63a990ba 100644 --- a/sortix/x86/boot.s +++ b/sortix/x86/boot.s @@ -31,7 +31,7 @@ .type _start, @function start: _start: - jmp beginkernel + jmp prepare_kernel_execution # Align 32 bits boundary. .align 4 @@ -45,3 +45,23 @@ multiboot_header: # Checksum. .long -(0x1BADB002 + 0x00000003) +prepare_kernel_execution: + # Enable the floating point unit. + mov %eax, 0x100000 + mov %cr0, %eax + and $0xFFFD, %ax + or $0x10, %ax + mov %eax, %cr0 + fninit + + # Enable Streaming SIMD Extensions. + mov %cr0, %eax + and $0xFFFB, %ax + or $0x2, %ax + mov %eax, %cr0 + mov %cr4, %eax + or $0x600, %eax + mov %eax, %cr4 + mov 0x100000, %eax + + jmp beginkernel