1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Add method for reading the CR2 register value

This will allow us to figure out the virtual address that caused a page-
or general protection fault.
This commit is contained in:
Achilleas Anagnostopoulos 2017-06-21 18:18:29 +01:00
parent 9adde8f5c1
commit c5aa5fe05f
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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