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
Functions | Variables
panic.c File Reference

Diagnostic and emergency error handling routines. More...

#include "error/error_strings.h"
#include <stdint.h>
Include dependency graph for panic.c:

Functions

void print_uart0 (const char *str)
 Transmits a null-terminated string over UART0.
 
void print_hex_digit (uint8_t digit)
 Converts a 4-bit nibble to a hex character and prints it.
 
void print_hex (uint64_t val)
 Prints a 64-bit unsigned integer in hexadecimal format.
 
void panic_print_c (long code)
 Primary C-level panic entry point.
 

Variables

volatile unsigned int *const uart0_dr = (unsigned int *)0x09000000
 UART0 Data Register (MMIO).
 

Detailed Description

Diagnostic and emergency error handling routines.

Provides low-level UART output and panic handling routines used when the kernel encounters unrecoverable failures.

Author
Abhin Parekadan Jose
Date
2026-04-11

Function Documentation

◆ panic_print_c()

void panic_print_c ( long  code)

Primary C-level panic entry point.

This function is typically called by the assembly panic_print macro. It outputs the numeric error code, resolves the human-readable error string, and indicates system halt.

Parameters
codeThe numeric error code representing the failure type.
See also
error_to_string

◆ print_hex()

void print_hex ( uint64_t  val)

Prints a 64-bit unsigned integer in hexadecimal format.

Iterates through the 64-bit value 4 bits at a time from most significant bit to least significant bit.

Parameters
valThe 64-bit value to be printed.

◆ print_hex_digit()

void print_hex_digit ( uint8_t  digit)

Converts a 4-bit nibble to a hex character and prints it.

Parameters
digitThe digit to print (0-15).
Note
This function uses a compound literal to pass a temporary string to the UART driver.

◆ print_uart0()

void print_uart0 ( const char *  str)

Transmits a null-terminated string over UART0.

This function performs a simple polling-based write. It does not check for FIFO status (TX Full), assuming the baud rate/buffer is sufficient for early boot strings.

Parameters
strA pointer to the null-terminated ASCII string to be printed.

Variable Documentation

◆ uart0_dr

volatile unsigned int* const uart0_dr = (unsigned int *)0x09000000

UART0 Data Register (MMIO).

This pointer accesses the hardware's transmit/receive buffer. It is marked 'volatile' to prevent the compiler from optimizing out repeated writes to the same memory location, which are necessary for hardware communication.