summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
+}