summaryrefslogtreecommitdiff
path: root/payloads/libpayload/arch
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2018-08-22 10:03:05 -0600
committerPatrick Georgi <pgeorgi@google.com>2018-08-23 16:24:44 +0000
commitcf79c8344d007cf05bc45d064ffed87be36f7513 (patch)
tree08143b418801cf671796f913e7aaa6bd1c847e8d /payloads/libpayload/arch
parent052b5317dafade3884eb63aacd5960dcce871945 (diff)
downloadcoreboot-cf79c8344d007cf05bc45d064ffed87be36f7513.tar.xz
libpayload/x86/exception: Add methods to enable/disable interrupts
Will be used by the APIC. BUG=b:109749762 TEST=Verified by the other cls in the stack. Change-Id: Id86f2719d98a90318ac625e09601e5dbb06e3765 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://review.coreboot.org/28239 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'payloads/libpayload/arch')
-rw-r--r--payloads/libpayload/arch/x86/exception.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/payloads/libpayload/arch/x86/exception.c b/payloads/libpayload/arch/x86/exception.c
index b562660910..fe50d09c51 100644
--- a/payloads/libpayload/arch/x86/exception.c
+++ b/payloads/libpayload/arch/x86/exception.c
@@ -32,6 +32,8 @@
#include <libpayload.h>
#include <stdint.h>
+#define IF_FLAG (1 << 9)
+
u32 exception_stack[0x400] __attribute__((aligned(8)));
static exception_hook hook;
@@ -182,3 +184,33 @@ void exception_install_hook(exception_hook h)
die_if(hook, "Implement support for a list of hooks if you need it.");
hook = h;
}
+
+static uint32_t eflags(void)
+{
+ uint32_t eflags;
+ asm volatile(
+ "pushf\n\t"
+ "pop %0\n\t"
+ : "=rm" (eflags));
+ return eflags;
+}
+
+void enable_interrupts(void)
+{
+ asm volatile (
+ "sti\n"
+ : : : "cc"
+ );
+}
+void disable_interrupts(void)
+{
+ asm volatile (
+ "cli\n"
+ : : : "cc"
+ );
+}
+
+int interrupts_enabled(void)
+{
+ return !!(eflags() & IF_FLAG);
+}