diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-04-01 16:27:51 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-01 16:27:51 +0200 |
| commit | eaec1833e978d2443ffdfc226fff60d0b5571cb6 (patch) | |
| tree | 10eed22698de1fe6fa02ca6f5067bf38626d51e8 /kernel/src/test_support/kapi/cpu.cpp | |
| parent | 38bdee2ba829999862e37999dc212055ebedc4c6 (diff) | |
| download | teachos-eaec1833e978d2443ffdfc226fff60d0b5571cb6.tar.xz teachos-eaec1833e978d2443ffdfc226fff60d0b5571cb6.zip | |
kernel/tests: move initialization to a listener
Diffstat (limited to 'kernel/src/test_support/kapi/cpu.cpp')
| -rw-r--r-- | kernel/src/test_support/kapi/cpu.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/kernel/src/test_support/kapi/cpu.cpp b/kernel/src/test_support/kapi/cpu.cpp index 3ecaadc..9b2f0b9 100644 --- a/kernel/src/test_support/kapi/cpu.cpp +++ b/kernel/src/test_support/kapi/cpu.cpp @@ -8,17 +8,29 @@ namespace kapi::cpu { - auto init() -> void + namespace { auto static initialized = std::atomic_flag{}; + } + + auto reset() -> void + { + if (!initialized.test()) + { + throw std::logic_error{"kapi::cpu::reset() called before kapi::cpu::init()"}; + } + + initialized.clear(); + } + + auto init() -> void + { if (initialized.test_and_set()) { throw std::logic_error("kapi::cpu::init() called more than once"); } // TODO: make sure that simulated interrupt can run. - - return; } auto halt() -> void |
