Espresso 0.0.1b

This commit is contained in:
2025-06-27 14:48:06 -05:00
parent fca025a9bf
commit c336584114
39 changed files with 2676 additions and 936 deletions

51
boot.s
View File

@ -74,6 +74,8 @@ enable_sse_asm:
push %ebx
push %ecx
push %edx
push %esi
push %edi
# Check CPUID support
pushf
@ -87,13 +89,16 @@ enable_sse_asm:
xor %ecx, %eax
jz .no_cpuid
# Check for SSE
# CPUID function 1
mov $1, %eax
cpuid
test $0x02000000, %edx
mov %edx, %ebx # EDX = SSE1/SSE2 bits
mov %ecx, %esi # ECX = SSE3/SSSE3/SSE4.1 bits
test $0x02000000, %ebx # SSE
jz .no_sse
# Enable SSE
# Enable SSE (required for SSE1/2/3/SSSE3/4.1)
mov %cr0, %eax
and $~0x4, %eax # Clear EM (bit 2)
or $0x2, %eax # Set MP (bit 1)
@ -102,17 +107,48 @@ enable_sse_asm:
mov %cr4, %eax
or $0x600, %eax # Set OSFXSR | OSXMMEXCPT
mov %eax, %cr4
lea sse_initialized, %ebx
movl $1, (%ebx)
# Set version = 1 (SSE1)
mov $1, %eax
test $0x04000000, %ebx # SSE2 (bit 26)
jz .check_sse3
mov $2, %eax
.check_sse3:
test $0x00000001, %esi # SSE3 (bit 0)
jz .check_ssse3
mov $3, %eax
.check_ssse3:
test $0x00000200, %esi # SSSE3 (bit 9)
jz .check_sse41
mov $4, %eax
.check_sse41:
test $0x00080000, %esi # SSE4.1 (bit 19)
jz .set_result
mov $5, %eax
.set_result:
lea sse_initialized, %edi
mov %eax, (%edi)
jmp .done
.no_sse:
.no_cpuid:
lea sse_initialized, %edi
mov $0, (%edi)
.done:
pop %edi
pop %esi
pop %edx
pop %ecx
pop %ebx
pop %eax
ret
_kernel_early:
call _init
@ -205,8 +241,9 @@ This is useful when debugging or when you implement call tracing.
*/
.size _start, . - _start
.section .data
.global sse_initialized
sse_initialized: .word 0
sse_initialized: .int 0