Espresso 0.0.2a
This commit is contained in:
@ -21,7 +21,7 @@ forced to be within the first 8 KiB of the kernel file.
|
||||
/*
|
||||
The multiboot standard does not define the value of the stack pointer register
|
||||
(esp) and it is up to the kernel to provide a stack. This allocates room for a
|
||||
small stack by creating a symbol at the bottom of it, then allocating 16384
|
||||
small stack by creating a symbol at the bottom of it, then allocating 65536
|
||||
bytes for it, and finally creating a symbol at the top. The stack grows
|
||||
downwards on x86. The stack is in its own section so it can be marked nobits,
|
||||
which means the kernel file is smaller because it does not contain an
|
||||
@ -30,10 +30,10 @@ System V ABI standard and de-facto extensions. The compiler will assume the
|
||||
stack is properly aligned and failure to align the stack will result in
|
||||
undefined behavior.
|
||||
*/
|
||||
.section .bss
|
||||
.section .stack
|
||||
.align 16
|
||||
stack_bottom:
|
||||
.skip 16384 # 16 KiB
|
||||
.skip 65536 # 64 KiB
|
||||
stack_top:
|
||||
|
||||
/*
|
||||
@ -183,7 +183,6 @@ _start:
|
||||
|
||||
/*
|
||||
Call _kernel_early, early low-level initialization will happen there.
|
||||
NOTE: I don't use 'jmp' because it doesn't work. Nice try.
|
||||
*/
|
||||
call _kernel_early
|
||||
|
||||
|
||||
57
arch/x86/cpuid.s
Normal file
57
arch/x86/cpuid.s
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
|
||||
/*
|
||||
Just a bunch of CPUID stuff.
|
||||
*/
|
||||
|
||||
.extern sse_initialized
|
||||
|
||||
.section .text
|
||||
|
||||
|
||||
_init_cpuid:
|
||||
pusha
|
||||
|
||||
pushf
|
||||
pop %eax
|
||||
mov %eax, %ecx
|
||||
xor $0x200000, %eax
|
||||
push %eax
|
||||
popf
|
||||
/*pushf*/
|
||||
pop %eax
|
||||
xor %ecx, %eax
|
||||
jz .no_cpuid
|
||||
|
||||
lea _has_cpuid, %edi
|
||||
movl $1, (%edi)
|
||||
|
||||
jmp .done
|
||||
|
||||
.no_cpuid:
|
||||
lea _has_cpuid, %edi
|
||||
movl $0, (%edi)
|
||||
|
||||
jmp .done
|
||||
|
||||
.done:
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
_sse_level:
|
||||
lea _has_sse, %edi
|
||||
lea sse_initialized, %esi
|
||||
|
||||
movl (%esi), %eax
|
||||
|
||||
movl %eax, (%edi)
|
||||
|
||||
|
||||
.section .data
|
||||
|
||||
.global _has_cpuid
|
||||
|
||||
_has_cpuid: .int 0
|
||||
_has_sse: .int 0
|
||||
_has_mmx: .int 0
|
||||
46
arch/x86/cpuid_asm.asm
Normal file
46
arch/x86/cpuid_asm.asm
Normal file
@ -0,0 +1,46 @@
|
||||
.global get_cpu_brand_string
|
||||
|
||||
.type get_cpu_brand_string, @function
|
||||
|
||||
get_cpu_brand_string:
|
||||
pushad # Save all general-purpose registers
|
||||
|
||||
mov ebx, eax # Save buffer pointer to ebx
|
||||
|
||||
mov eax, 0x80000000
|
||||
cpuid
|
||||
cmp eax, 0x80000004 # Check if brand string is supported
|
||||
jb .not_supported
|
||||
|
||||
mov esi, ebx # Copy address to ESI
|
||||
|
||||
mov eax, 0x80000002
|
||||
cpuid
|
||||
mov [esi], eax
|
||||
mov [esi + 4], ebx
|
||||
mov [esi + 8], ecx
|
||||
mov [esi + 12], edx
|
||||
|
||||
mov eax, 0x80000003
|
||||
cpuid
|
||||
mov [esi + 16], eax
|
||||
mov [esi + 20], ebx
|
||||
mov [esi + 24], ecx
|
||||
mov [esi + 28], edx
|
||||
|
||||
mov eax, 0x80000004
|
||||
cpuid
|
||||
mov [esi + 32], eax
|
||||
mov [esi + 36], ebx
|
||||
mov [esi + 40], ecx
|
||||
mov [esi + 44], edx
|
||||
|
||||
jmp .done
|
||||
|
||||
.not_supported:
|
||||
mov byte [ebx], 0 # Null-terminate if not supported
|
||||
|
||||
.done:
|
||||
popad
|
||||
ret
|
||||
|
||||
0
arch/x86/cpuid_asm.s
Normal file
0
arch/x86/cpuid_asm.s
Normal file
@ -3,25 +3,16 @@
|
||||
Mostly so I could get more experience in assembler.
|
||||
*/
|
||||
|
||||
/*
|
||||
DO NOT USE "pusha" AND/OR "popa"!!!
|
||||
THEY ARE DEPRECATED (or something like that)
|
||||
AND SHOULD NOT BE USED!!!
|
||||
INSTEAD PUSH/POP REGISTERS ON/OFF THE STACK INDIVIDUALLY!!!
|
||||
*/
|
||||
|
||||
|
||||
.section .text
|
||||
|
||||
.global _enable_paging_asm
|
||||
|
||||
.global _push_regs
|
||||
.global _pop_regs
|
||||
|
||||
.global _hang_asm
|
||||
.global _halt_asm
|
||||
|
||||
.global _sti_asm
|
||||
.global _cli_asm
|
||||
|
||||
|
||||
_enable_paging_asm:
|
||||
@ -34,30 +25,6 @@ _enable_paging_asm:
|
||||
pop %eax
|
||||
|
||||
ret
|
||||
|
||||
_push_regs:
|
||||
push %eax
|
||||
push %ebx
|
||||
push %ecx
|
||||
push %edx
|
||||
push %esi
|
||||
push %edi
|
||||
push %esp
|
||||
push %ebp
|
||||
|
||||
ret
|
||||
|
||||
_pop_regs:
|
||||
pop %ebp
|
||||
pop %esp
|
||||
pop %edi
|
||||
pop %esi
|
||||
pop %edx
|
||||
pop %ecx
|
||||
pop %ebx
|
||||
pop %eax
|
||||
|
||||
ret
|
||||
|
||||
_hang_asm:
|
||||
hlt
|
||||
@ -70,5 +37,7 @@ _halt_asm:
|
||||
_sti_asm:
|
||||
sti
|
||||
ret
|
||||
|
||||
.section .data
|
||||
|
||||
_cli_asm:
|
||||
cli
|
||||
ret
|
||||
|
||||
Reference in New Issue
Block a user