blob: 9b2f0b959f85ee583db1a3c1c03456fc63675525 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "kernel/tests/cpu.hpp"
#include <kapi/cpu.hpp>
#include <atomic>
#include <stdexcept>
namespace kapi::cpu
{
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.
}
auto halt() -> void
{
throw kernel::tests::cpu::halt{};
}
} // namespace kapi::cpu
|