diff --git a/kernel/cpu/cpu_amd64.go b/kernel/cpu/cpu_amd64.go index 7776082..c757266 100644 --- a/kernel/cpu/cpu_amd64.go +++ b/kernel/cpu/cpu_amd64.go @@ -18,3 +18,6 @@ func SwitchPDT(pdtPhysAddr uintptr) // ActivePDT returns the physical address of the currently active page table. func ActivePDT() uintptr + +// ReadCR2 returns the value stored in the CR2 register. +func ReadCR2() uint64 diff --git a/kernel/cpu/cpu_amd64.s b/kernel/cpu/cpu_amd64.s index 5ef45db..b654195 100644 --- a/kernel/cpu/cpu_amd64.s +++ b/kernel/cpu/cpu_amd64.s @@ -27,3 +27,7 @@ TEXT ·ActivePDT(SB),NOSPLIT,$0 MOVQ AX, ret+0(FP) RET +TEXT ·ReadCR2(SB),NOSPLIT,$0 + MOVQ CR2, AX + MOVQ AX, ret+0(FP) + RET