mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
Kernel: Add getter and setter for the X86 CR3 register
This gets rid of a bunch of inline assembly.
This commit is contained in:
parent
7323d085dd
commit
27f0102bbe
3 changed files with 25 additions and 31 deletions
|
@ -178,9 +178,7 @@ static void dump(const RegisterDump& regs)
|
|||
u32 cr2;
|
||||
asm("movl %%cr2, %%eax"
|
||||
: "=a"(cr2));
|
||||
u32 cr3;
|
||||
asm("movl %%cr3, %%eax"
|
||||
: "=a"(cr3));
|
||||
u32 cr3 = read_cr3();
|
||||
u32 cr4;
|
||||
asm("movl %%cr4, %%eax"
|
||||
: "=a"(cr4));
|
||||
|
@ -271,11 +269,8 @@ void page_fault_handler(RegisterDump regs)
|
|||
asm("movl %%cr2, %%eax"
|
||||
: "=a"(fault_address));
|
||||
|
||||
u32 fault_page_directory;
|
||||
asm("movl %%cr3, %%eax"
|
||||
: "=a"(fault_page_directory));
|
||||
|
||||
#ifdef PAGE_FAULT_DEBUG
|
||||
u32 fault_page_directory = read_cr3();
|
||||
dbgprintf("%s(%u): ring%u %s page fault in PD=%x, %s%s V%08x\n",
|
||||
current ? current->process().name().characters() : "(none)",
|
||||
current ? current->pid() : 0,
|
||||
|
@ -716,3 +711,17 @@ void cpu_setup()
|
|||
kprintf("x86: No RDRAND support detected. Randomness will be shitty\n");
|
||||
}
|
||||
}
|
||||
|
||||
u32 read_cr3()
|
||||
{
|
||||
u32 cr3;
|
||||
asm("movl %%cr3, %%eax"
|
||||
: "=a"(cr3));
|
||||
return cr3;
|
||||
}
|
||||
|
||||
void write_cr3(u32 cr3)
|
||||
{
|
||||
asm volatile("movl %%eax, %%cr3" ::"a"(cr3)
|
||||
: "memory");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue