From: Amelia Coutard Date: Fri, 6 May 2022 23:00:41 +0000 (+0200) Subject: Made os::assert print "Error: " before the error message, updated calls accordingly X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=ef4981e802260d82cdf79ba9581f831c942fb7ee;p=voyage-au-centre-des-fichiers.git Made os::assert print "Error: " before the error message, updated calls accordingly --- diff --git a/src/fb.cpp b/src/fb.cpp index c35caf0..3956290 100644 --- a/src/fb.cpp +++ b/src/fb.cpp @@ -16,11 +16,11 @@ os::framebuffer::framebuffer(std::uint64_t addr, std::uint32_t pitch, std::uint3 this->height = height; this->bpp = bpp; if (type != 1) { - os::println("Error: framebuffer not in direct RGB mode."); + os::println("framebuffer not in direct RGB mode."); os::halt(); } if (bpp != 32) { - os::println("Error: framebuffer bpp != 32."); + os::println("framebuffer bpp != 32."); os::halt(); } diff --git a/src/kernel.cpp b/src/kernel.cpp index 4b810d9..1f056e4 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -5,7 +5,7 @@ #include "serial.hpp" extern "C" void kmain(unsigned long magic, os::phys_ptr info) { - os::assert(magic == 0x36D76289, "Error: Incorrect magic number: wasn't booted with multiboot."); + os::assert(magic == 0x36D76289, "Incorrect magic number: wasn't booted with multiboot."); if (!os::init_serial_port()) { os::halt(); diff --git a/src/paging.hpp b/src/paging.hpp index bcdb12d..779e4cc 100644 --- a/src/paging.hpp +++ b/src/paging.hpp @@ -12,7 +12,7 @@ struct __attribute__((aligned(0x1000))) paging_table; template struct paging_entry { public: - static_assert(order >= 0, "Error: negative order for paging entry."); + static_assert(order >= 0, "negative order for paging entry."); paging_entry(bool is_page) { os::assert(order != 0 || is_page, "4KiB defined as non-page."); if (order != 0 && is_page) { @@ -30,19 +30,19 @@ public: data = (data & ~(1ul << 63)) | (v ? (1ul << 63) : 0); } inline unsigned PK() { - os::assert(is_page(), "Error: read protection key of non-page."); + os::assert(is_page(), "read protection key of non-page."); return (data >> 52) & 0xF; } inline void PK(unsigned v) { - os::assert(is_page(), "Error: write to protection key of non-page."); - os::assert((v & 0xF) == v, "Error: incorrect protection key."); + os::assert(is_page(), "write to protection key of non-page."); + os::assert((v & 0xF) == v, "incorrect protection key."); data = (data & ~(0xFul << 59)) | (std::uint64_t(v) << 59); } inline unsigned AVL_high() { return (data >> 52) & (is_page() ? 0x7F : 0x7FF); } inline void AVL_high(unsigned v) { - os::assert((v & (is_page() ? 0x7F : 0x7FF)) == v, "Error: incorrect AVL high bits."); + os::assert((v & (is_page() ? 0x7F : 0x7FF)) == v, "incorrect AVL high bits."); data = (data & ~((is_page() ? 0x7Ful : 0x7FFul) << 52)) | (std::uint64_t(v) << 52); } inline phys_ptr> base_address() { @@ -50,38 +50,38 @@ public: } inline void base_address(phys_ptr> v) { const std::uint64_t v_int = v.get_phys_addr(); - os::assert((v_int & 0x000FFFFFFFFFF000 & (0xFFFFFFFFFFFFF000 << (is_page() ? 9 * order : 0))) == v_int, "Error: incorrect base address."); + os::assert((v_int & 0x000FFFFFFFFFF000 & (0xFFFFFFFFFFFFF000 << (is_page() ? 9 * order : 0))) == v_int, "incorrect base address."); data = (data & ~0x000FFFFFFFFFF000ul & ~(order != 0 && is_page() ? 1ul << 12 : 0ul)) | v_int; } inline unsigned AVL_low() { return (data >> 9) & 0x7; } inline void AVL_low(unsigned v) { - os::assert((v & 0x7) == v, "Error: incorrect AVL low bits"); + os::assert((v & 0x7) == v, "incorrect AVL low bits"); data = (data & ~(0x7ul << 9)) | (v << 9); } inline bool G() { - os::assert(is_page(), "Error: read global bit of non-page."); + os::assert(is_page(), "read global bit of non-page."); return (data & (1 << 8)) != 0; } inline void G(bool v) { - os::assert(is_page(), "Error: write to global bit of non-page."); + os::assert(is_page(), "write to global bit of non-page."); data = (data & ~(1ul << 8)) | (v ? 1 << 8 : 0); } inline bool PAT() { - os::assert(is_page(), "Error: read PAT bit of non-page."); + os::assert(is_page(), "read PAT bit of non-page."); return (data & (1 << (order == 0 ? 7 : 12))) != 0; } inline void PAT(bool v) { - os::assert(is_page(), "Error: write to PAT bit of non-page."); + os::assert(is_page(), "write to PAT bit of non-page."); data = (data & ~(1ul << (order == 0 ? 7 : 12))) | (v ? 1 << (order == 0 ? 7 : 12) : 0); } inline bool D() { - os::assert(is_page(), "Error: read dirty bit of non-page."); + os::assert(is_page(), "read dirty bit of non-page."); return (data & (1 << 6)) != 0; } inline void D(bool v) { - os::assert(is_page(), "Error: write to dirty bit of non-page."); + os::assert(is_page(), "write to dirty bit of non-page."); data = (data & ~(1ul << 6)) | (v ? 1 << 6 : 0); } inline bool A() { diff --git a/src/serial.cpp b/src/serial.cpp index a8ae1a7..384ba9d 100644 --- a/src/serial.cpp +++ b/src/serial.cpp @@ -118,5 +118,8 @@ void os::println(const char* str) { os::printc('\n'); } void os::assert(bool cond, const char* diagnostic) { - if (!cond) { os::println(diagnostic); } + if (!cond) { + os::print("Error: "); + os::println(diagnostic); + } }