I've been porting my microkernel to x86_64. For this, I need a function that will let me read raw memory data, by bypassing paging. Here's how I'm trying to implement it right now:
Code: Select all
asm_ReadU64Physical:
; disable paging
mov rcx, cr0;
btc rcx, 31;
mov cr0, rcx;
; do our stuff
mov rax, qword [rdi];
; enable paging
mov rdx, cr0
bts rdx, 31;
mov cr0, rdx
ret;
Code: Select all
asm_TestFunction:
mov rax, rdi;
add rax, 0x23;
ret