diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 08:23:39 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2024-10-15 08:23:39 +0000 |
| commit | 205934ca45d591924b4be6e7ae5a8849958e0cf6 (patch) | |
| tree | 5f0b193fa9620a253690f494405e5d407d97ca56 /arch/x86_64/src/exception_handling | |
| parent | 38e0b13ab9a4997fdf9f311fd125825919d2e6c7 (diff) | |
| download | teachos-205934ca45d591924b4be6e7ae5a8849958e0cf6.tar.xz teachos-205934ca45d591924b4be6e7ae5a8849958e0cf6.zip | |
continue implementing paging
Diffstat (limited to 'arch/x86_64/src/exception_handling')
| -rw-r--r-- | arch/x86_64/src/exception_handling/assert.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/x86_64/src/exception_handling/assert.cpp b/arch/x86_64/src/exception_handling/assert.cpp new file mode 100644 index 0000000..b55da49 --- /dev/null +++ b/arch/x86_64/src/exception_handling/assert.cpp @@ -0,0 +1,24 @@ +#include "arch/video/vga/text.hpp" + +namespace teachos::arch::exception_handling +{ + auto assert(bool condition, char const * message) -> void + { + if (condition) + { + return; + } + + video::vga::text::write("Assert failed: ", video::vga::text::common_attributes::green_on_black); + video::vga::text::write(message, video::vga::text::common_attributes::green_on_black); + for (;;) + { + // Trick the compiler into thinking the variable is changes at run time, + // to prevent the while loop being optimized away + // See + // https://stackoverflow.com/questions/9495856/how-to-prevent-g-from-optimizing-out-a-loop-controlled-by-a-variable-that-can + // for more information. + asm volatile("" : "+g"(condition)); + } + } +} // namespace teachos::arch::exception_handling
\ No newline at end of file |
