From cd3199199b9d1cce938f245c5bf629f7f886f908 Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Wed, 21 Jun 2017 07:58:15 +0100 Subject: [PATCH] Add assemnly code for enabling/disabling insterrupts and halting the CPU --- kernel/cpu/cpu_amd64.go | 9 +++++++++ kernel/cpu/cpu_amd64.s | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/kernel/cpu/cpu_amd64.go b/kernel/cpu/cpu_amd64.go index 4943fa2..7776082 100644 --- a/kernel/cpu/cpu_amd64.go +++ b/kernel/cpu/cpu_amd64.go @@ -1,5 +1,14 @@ package cpu +// EnableInterrupts enables interrupt handling. +func EnableInterrupts() + +// DisableInterrupts disables interrupt handling. +func DisableInterrupts() + +// Halt stops instruction execution. +func Halt() + // FlushTLBEntry flushes a TLB entry for a particular virtual address. func FlushTLBEntry(virtAddr uintptr) diff --git a/kernel/cpu/cpu_amd64.s b/kernel/cpu/cpu_amd64.s index 002c8cb..5ef45db 100644 --- a/kernel/cpu/cpu_amd64.s +++ b/kernel/cpu/cpu_amd64.s @@ -1,5 +1,18 @@ #include "textflag.h" +TEXT ·EnableInterrupts(SB),NOSPLIT,$0 + STI + RET + +TEXT ·DisableInterrupts(SB),NOSPLIT,$0 + CLI + RET + +TEXT ·Halt(SB),NOSPLIT,$0 + CLI + HLT + RET + TEXT ·FlushTLBEntry(SB),NOSPLIT,$0 INVLPG virtAddr+0(FP) RET