mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Move TLB-handling code to the cpu pkg
This commit is contained in:
11
kernel/cpu/cpu_amd64.go
Normal file
11
kernel/cpu/cpu_amd64.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package cpu
|
||||
|
||||
// FlushTLBEntry flushes a TLB entry for a particular virtual address.
|
||||
func FlushTLBEntry(virtAddr uintptr)
|
||||
|
||||
// SwitchPDT sets the root page table directory to point to the specified
|
||||
// physical address and flushes the TLB.
|
||||
func SwitchPDT(pdtPhysAddr uintptr)
|
||||
|
||||
// ActivePDT returns the physical address of the currently active page table.
|
||||
func ActivePDT() uintptr
|
||||
16
kernel/cpu/cpu_amd64.s
Normal file
16
kernel/cpu/cpu_amd64.s
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "textflag.h"
|
||||
|
||||
TEXT ·FlushTLBEntry(SB),NOSPLIT,$0
|
||||
INVLPG virtAddr+0(FP)
|
||||
RET
|
||||
|
||||
TEXT ·SwitchPDT(SB),NOSPLIT,$0
|
||||
// loading CR3 also triggers a TLB flush
|
||||
MOVQ pdtPhysAddr+0(FP), CR3
|
||||
RET
|
||||
|
||||
TEXT ·ActivePDT(SB),NOSPLIT,$0
|
||||
MOVQ CR3, AX
|
||||
MOVQ AX, ret+0(FP)
|
||||
RET
|
||||
|
||||
Reference in New Issue
Block a user