IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
cpu.hpp
Go to the documentation of this file.
1
11
12
13#pragma once
14
15
16// IgrOS-Kernel arch
17#include <arch/register.hpp>
18#include <arch/types.hpp>
19// IgrOS-Kernel library
20#include <klib/kPrint.hpp>
21
22
23#ifdef __cplusplus
24
25extern "C" {
26
27#endif // __cplusplus
28
29
31 [[noreturn]]
32 void cpuHalt() noexcept;
33
34
35#ifdef __cplusplus
36
37} // extern "C"
38
39#endif // __cplusplus
40
41
42// i386 platform namespace
43namespace igros::i386 {
44
45
47 class cpu final {
48
49 public:
50
52 cpu() noexcept = default;
54 ~cpu() noexcept = default;
55
57 cpu(const cpu &other) = delete;
59 auto operator=(const cpu &other) -> cpu & = delete;
61 cpu(cpu &&other) = delete;
63 auto operator=(cpu &&other) -> cpu & = delete;
64
66 [[noreturn]]
67 static void halt() noexcept;
68
71 static void dumpRegisters(const register_t* const regs) noexcept;
72 };
73
74
76 [[noreturn]]
77 inline void cpu::halt() noexcept {
78 ::cpuHalt();
79 }
80
81
83 inline void cpu::dumpRegisters(const register_t* const regs) noexcept {
84 // Print regs (32-bit values)
85 klib::kprintf(R"registers(Registers dump:
86 EAX=[%08x] EBX=[%08x] ECX=[%08x] EDX=[%08x]
87 ESI=[%08x] EDI=[%08x] ESP=[%08x] EBP=[%08x]
88 EIP=[%08x] EFLAGS=[%08x]
89Segments:
90 CS=[%08x]
91 DS=[%08x]
92 SS=[%08x]
93 ES=[%08x]
94 FS=[%08x]
95 GS=[%08x])registers",
96 regs->eax, regs->ebx, regs->ecx, regs->edx,
97 regs->esi, regs->edi, regs->esp, regs->ebp,
98 regs->eip, regs->eflags,
99 regs->cs,
100 regs->ds,
101 regs->ss,
102 regs->es,
103 regs->fs,
104 regs->gs
105 );
106 }
107
108
109} // namespace igros::i386
110
static void halt() noexcept
Halt CPU.
Definition cpu.hpp:77
cpu() noexcept=default
Default c-tor.
static void dumpRegisters(const register_t *const regs) noexcept
Dump CPU registers.
Definition cpu.hpp:83
void cpuHalt() noexcept
Halt CPU.
Kernel text print functions.
i386 (32-bit protected mode): GDT, IDT, TSS, CPU registers
void kprintf(const char *const format,...) noexcept
Kernel printf function (arguments are checked against format at compile time).
Definition kPrint.cpp:358
Architecture register type deduction.
x86 task switch registers save
Definition register.hpp:117
Common C++ types redefinition.