Added support for floating point numbers.

Note that the scheduler does not load/restore floating point numbers yet
upon task switching. This means only one task can use floating point numbers
at the same time without the risk of race conditions.

Note that this enables SSE in 32-bit x86 platforms - but not all models
have such support, which limits which computers Sortix works on. Ideally, we
should detect what features are available on the computer at runtime and
enable/disable the proper kernel support. This is not a problem on x86_64.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-05-27 14:57:32 +02:00
parent 66b8d23713
commit 93bb4f992b
3 changed files with 40 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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