diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-09-29 10:41:36 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-09-29 10:41:36 +0200 |
| commit | e9b880648c18d3680ae10cc5660f0dbe981af5d8 (patch) | |
| tree | a24e81e48920853ba191e8e7c6c3cfcd22194fba /arch/x86_64/kapi/interrupts.cpp | |
| parent | 5bad38935238da045d9fd467eae9dfd958deea34 (diff) | |
| download | kernel-e9b880648c18d3680ae10cc5660f0dbe981af5d8.tar.xz kernel-e9b880648c18d3680ae10cc5660f0dbe981af5d8.zip | |
kapi/interrupt: rework enablement API
Diffstat (limited to 'arch/x86_64/kapi/interrupts.cpp')
| -rw-r--r-- | arch/x86_64/kapi/interrupts.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/arch/x86_64/kapi/interrupts.cpp b/arch/x86_64/kapi/interrupts.cpp index 85acc0fa..8d863bad 100644 --- a/arch/x86_64/kapi/interrupts.cpp +++ b/arch/x86_64/kapi/interrupts.cpp @@ -3,14 +3,27 @@ namespace kapi::interrupts { - auto enable() -> void + auto enabled() -> bool { - asm volatile("sti"); + auto value = false; + asm volatile("pushfq\n" + "pop %0\n" + "and $0x200, %0" + : "=r"(value)); + return value; } - auto disable() -> void + auto enabled(bool value) -> void { - asm volatile("cli"); + // NOLINTNEXTLINE(bugprone-branch-clone) + if (value) + { + asm volatile("sti"); + } + else + { + asm volatile("cli"); + } } -} // namespace kapi::interrupts
\ No newline at end of file +} // namespace kapi::interrupts |
