Kernelite 0.1.0
Kernelite is a minimalist, educational operating system kernel built from scratch. The project aims to recreate core components of the Linux architecture to explore the fundamentals of operating system design and hardware-software interaction.
Loading...
Searching...
No Matches
Macros | Functions
error_strings.h File Reference

Human-readable string mapping for kernel error codes. More...

#include "error_codes.h"
Include dependency graph for error_strings.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define STRING_MAP
 master mapping table for error codes and strings.
 

Functions

const char * error_to_string (long code)
 Converts a numeric error code into a human-readable string.
 

Detailed Description

Human-readable string mapping for kernel error codes.

Provides lookup support for converting numeric error codes into readable diagnostics used by panic and logging routines.

Author
Abhin Parekadan Jose
Date
2026-04-11

Macro Definition Documentation

◆ STRING_MAP

#define STRING_MAP
Value:
X(ERROR_CODE_SUCCESS, "SUCCESS") \
X(ERROR_CODE_NOT_EL1, "CPU not in EL1")
#define ERROR_CODE_NOT_EL1
Error code for when the current privilege level is not EL1.
Definition error_codes.h:19
#define ERROR_CODE_SUCCESS
Success error code.
Definition error_codes.h:16

master mapping table for error codes and strings.

This macro uses the X-Macro pattern: X(constant, string). To add a new error message, define the constant in error_codes.h and add a corresponding entry here.

Function Documentation

◆ error_to_string()

const char * error_to_string ( long  code)

Converts a numeric error code into a human-readable string.

This function maps internal kernel error constants (e.g., ERROR_CODE_NOT_EL1) to descriptive string literals. It is primarily used by the panic handler to provide diagnostic feedback over UART when a fatal error occurs.

Parameters
codeThe numeric error code triggered by the kernel or bootloader.
Returns
A pointer to a constant null-terminated string representing the error. Returns "UNKNOWN" if the code is not recognized.
Note
This function is designed to be safe for use during early boot or panic states; it does not allocate memory and relies solely on strings stored in the .rodata section.