diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-25 13:24:03 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-27 07:02:35 +0100 |
| commit | fd1c5a50bb35f772b8e37125188640447d4b3b2a (patch) | |
| tree | ed1ac0b99fccb52e627338915490ba035655c774 /kapi | |
| parent | 363a6d701d4998137fcc123059f9749098ac7d75 (diff) | |
| download | teachos-fd1c5a50bb35f772b8e37125188640447d4b3b2a.tar.xz teachos-fd1c5a50bb35f772b8e37125188640447d4b3b2a.zip | |
kapi/cpu: enable formatting of exception types
Diffstat (limited to 'kapi')
| -rw-r--r-- | kapi/include/kapi/cpu/exception.hpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/kapi/include/kapi/cpu/exception.hpp b/kapi/include/kapi/cpu/exception.hpp index 9fc697a..00b02e7 100644 --- a/kapi/include/kapi/cpu/exception.hpp +++ b/kapi/include/kapi/cpu/exception.hpp @@ -5,6 +5,8 @@ #include "kapi/memory.hpp" +#include <kstd/format> + #include <cstdint> namespace kapi::cpu @@ -82,4 +84,38 @@ namespace kapi::cpu } // namespace kapi::cpu +template<> +struct kstd::formatter<enum kapi::cpu::exception::type> +{ + constexpr auto parse(kstd::format_parse_context & ctx) -> decltype(ctx.begin()) + { + return ctx.begin(); + } + + constexpr auto format(enum kapi::cpu::exception::type type, kstd::format_context & ctx) const -> void + { + switch (type) + { + case kapi::cpu::exception::type::unknown: + return ctx.push("unknown"); + case kapi::cpu::exception::type::page_fault: + return ctx.push("page fault"); + case kapi::cpu::exception::type::alignment_fault: + return ctx.push("alignment fault"); + case kapi::cpu::exception::type::memory_access_fault: + return ctx.push("memory access fault"); + case kapi::cpu::exception::type::illegal_instruction: + return ctx.push("illegal instruction"); + case kapi::cpu::exception::type::privilege_violation: + return ctx.push("privilege violation"); + case kapi::cpu::exception::type::arithmetic_error: + return ctx.push("arithmetic error"); + case kapi::cpu::exception::type::breakpoint: + return ctx.push("breakpoint"); + case kapi::cpu::exception::type::single_step: + return ctx.push("single step"); + } + } +}; + #endif
\ No newline at end of file |
