Added checks to be sure paging is actually enabled on the cpu.
- Made a special assembly file to put CPU check function in. E.G. functions to get the state of specific registers In this case I have created a simple assembly function to get the contents of the CR0 register. With the help of the c++ preprocessor the value can then be used to check if certains bits are set. For example to check if the PG (paging) bit is set, indicating that paging is enabled for the processor.
This commit is contained in:
25
src/kernel/cpu.s
Normal file
25
src/kernel/cpu.s
Normal file
@ -0,0 +1,25 @@
|
||||
# Basic cpu functions
|
||||
.globl GetCR0
|
||||
GetCR0:
|
||||
push %ebp # save the base pointer on the stack
|
||||
mov %esp, %ebp # Set the base pointer to the current stack pointer
|
||||
|
||||
xor %eax, %eax # Clear EAX to make sure no weird stuff is going on
|
||||
mov %cr0, %eax # Copy the value of the CR0 register into EAX
|
||||
|
||||
mov %ebp, %esp # restore the base pointer
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
.globl GetEFLAGS
|
||||
GetEFLAGS:
|
||||
push %ebp
|
||||
mov %esp, %ebp
|
||||
|
||||
xor %eax, %eax
|
||||
pushfl # Push the EFLAGS register content onto the stack, should be pushfd but GAS apparently doesn't agree
|
||||
mov 4(%esp) , %eax
|
||||
|
||||
mov %ebp, %esp
|
||||
pop %ebp
|
||||
ret
|
Reference in New Issue
Block a user