blob: c0d96c01824edb08974c5fb28bd528c99d3afb4b [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi3d767252018-03-15 14:04:35 +01002
Patrick Georgi3d767252018-03-15 14:04:35 +01003#include <stdint.h>
4#include <cpu/x86/smm.h>
5
6/*
7 * calls into SMM with the given cmd and subcmd in eax, and arg in ebx
8 *
9 * static inline because the resulting assembly is often smaller than
10 * the call sequence due to constant folding.
11 */
12static inline u32 call_smm(u8 cmd, u8 subcmd, void *arg)
13{
14 u32 res = 0;
15 __asm__ __volatile__ (
Felix Held8dd5b9d2024-01-04 17:52:41 +010016 "outb %%al, %%dx"
Patrick Georgi3d767252018-03-15 14:04:35 +010017 : "=a" (res)
Felix Held8dd5b9d2024-01-04 17:52:41 +010018 : "a" ((subcmd << 8) | cmd),
19 "b" (arg),
20 "d" (APM_CNT)
21 : "memory");
Patrick Georgi3d767252018-03-15 14:04:35 +010022 return res;
23}