summaryrefslogtreecommitdiff
path: root/src/arch/x86/include/smm.h
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2018-03-15 14:04:35 +0100
committerPatrick Georgi <pgeorgi@google.com>2018-07-02 16:34:54 +0000
commit3d76725c415c2cae751fab62fdc51f505896af38 (patch)
tree54284e608c11eab6e098059671eef7e898494b5c /src/arch/x86/include/smm.h
parent1619a3847594ecf6a5125d1030c8d86089dc7fda (diff)
downloadcoreboot-3d76725c415c2cae751fab62fdc51f505896af38.tar.xz
arch/x86: add SMM caller
Useful for debugging or for cases where we need to enter SMM. Probably should be moved to commonlib or libpayload. Change-Id: I7a9cc626dae9a7751034615ef409eebc6035f5c3 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/25193 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/arch/x86/include/smm.h')
-rw-r--r--src/arch/x86/include/smm.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/arch/x86/include/smm.h b/src/arch/x86/include/smm.h
new file mode 100644
index 0000000000..d66e8906d6
--- /dev/null
+++ b/src/arch/x86/include/smm.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <cpu/x86/smm.h>
+
+/*
+ * calls into SMM with the given cmd and subcmd in eax, and arg in ebx
+ *
+ * static inline because the resulting assembly is often smaller than
+ * the call sequence due to constant folding.
+ */
+static inline u32 call_smm(u8 cmd, u8 subcmd, void *arg)
+{
+ u32 res = 0;
+ __asm__ __volatile__ (
+ "outb %b0, %3"
+ : "=a" (res)
+ : "a" ((subcmd << 8) | cmd), "b" (arg), "i" (APM_CNT));
+ return res;
+}