1
0
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:
Achilleas Anagnostopoulos
2017-06-21 07:57:05 +01:00
parent 3923e09aac
commit d793300279
5 changed files with 22 additions and 19 deletions

11
kernel/cpu/cpu_amd64.go Normal file
View 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
View 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