blob: 671097e0be4d3cccb7530b9197e09e3f39cd55bb (
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
42
43
44
45
46
47
48
49
50
51
52
|
#include "kernel/test_support/cpu.hpp"
#include <kapi/cpu.hpp>
#include <atomic>
#include <stdexcept>
namespace
{
auto static initialized = std::atomic_flag{};
}
namespace kapi::cpu
{
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{};
}
auto discover_topology() -> bool
{
// TODO: implement more meaningful simulated CPU topology discovery
return true;
}
} // namespace kapi::cpu
namespace kernel::tests::cpu
{
auto deinit() -> void
{
if (!initialized.test())
{
throw std::logic_error{"kapi::cpu::reset() called before kapi::cpu::init()"};
}
initialized.clear();
}
} // namespace kernel::tests::cpu
|