forked from Bananymous/banan-os
Kernel: remove message from BAN::Error
We don't store the error message anymore in BAN::Error. Instead we store a error code that can be mapped into a string. This allows BAN::Error to only take 4 bytes instead of 128. We should also make some kernel initialization just panic instead of returning errors since they are required for succesfull boot anyway.
This commit is contained in:
40
kernel/kernel/Errors.cpp
Normal file
40
kernel/kernel/Errors.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <kernel/Errors.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
static BAN::StringView s_error_strings[] {
|
||||
"No Error"sv,
|
||||
"ACPI could not find root SDT header"sv,
|
||||
"ACPI no such header"sv,
|
||||
"ACPI root invalid",
|
||||
"PS/2 device timeout"sv,
|
||||
"PS/2 controller self test failed"sv,
|
||||
"PS/2 reset failed"sv,
|
||||
"PS/2 unsupported device"sv,
|
||||
"Invalid ext2 filesystem"sv,
|
||||
"Ext2 filesystem corrupted"sv,
|
||||
"Ext2 filesystem out of inodes"sv,
|
||||
"Attempted to access outside of device boundaries"sv,
|
||||
"Device has invalid GPT header"sv,
|
||||
"Device does not support LBA addressing"sv,
|
||||
"Address mark not found"sv,
|
||||
"Track zero not found"sv,
|
||||
"Aborted command"sv,
|
||||
"Media change request"sv,
|
||||
"ID not found"sv,
|
||||
"Media changed"sv,
|
||||
"Uncorrectable data error"sv,
|
||||
"Bad Block detected"sv,
|
||||
"Font file too small"sv,
|
||||
"Unsupported font format"sv,
|
||||
};
|
||||
static_assert(sizeof(s_error_strings) / sizeof(*s_error_strings) == (size_t)ErrorCode::Count);
|
||||
|
||||
BAN::StringView error_string(ErrorCode error)
|
||||
{
|
||||
ASSERT((uint32_t)error < (uint32_t)ErrorCode::Count);
|
||||
return s_error_strings[(uint32_t)error];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user