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
Data Structures | Typedefs | Functions
utils.c File Reference

Implementation of utility functions for kernel development. More...

#include "utils/utils.h"
#include "allocator/page_allocator.h"
#include "asm/asm_helper.h"
#include "fdt/fdt.h"
#include "linker/symbols.h"
#include "utils/kprintf.h"
#include <libfdt.h>
Include dependency graph for utils.c:

Data Structures

union  current_el_t
 AArch64 CurrentEL register. More...
 

Typedefs

typedef union current_el_t current_el_t
 AArch64 CurrentEL register.
 

Functions

static current_el_t read_current_el (void)
 Reads the current Exception Level via the CurrentEL system register.
 
static bool reserve_kernel_img_pages (void)
 Reserve pages occupied by the kernel image.
 
static bool reserve_fdt_pages (const void *fdt_addr)
 Reserve pages occupied by the Device Tree Blob (FDT).
 
bool setup_page_allocator (const void *fdt_addr)
 Set up the global page allocator.
 
void print_kernelite_logo (void)
 Prints the Kernelite ASCII art logo and banner to the console.
 
uint32_t get_core_id (void)
 Gets the core id.
 
void print_current_el (void)
 Prints the current exeception level.
 

Detailed Description

Implementation of utility functions for kernel development.

This module contains utility functions for kernel development, including functions for reserving kernel image pages, setting up the global page allocator, and other helper functions used across the kernel.

Author
Abhin Parekadan Jose
Date
2026-05-25

Typedef Documentation

◆ current_el_t

typedef union current_el_t current_el_t

AArch64 CurrentEL register.

Contains the current Exception Level. Read-only. The EL field is at bits [3:2]; bits [1:0] are RES0.

Function Documentation

◆ get_core_id()

uint32_t get_core_id ( void  )

Gets the core id.

Returns
the core id.

◆ read_current_el()

static current_el_t read_current_el ( void  )
inlinestatic

Reads the current Exception Level via the CurrentEL system register.

Returns
current_el_t The decoded CurrentEL register value.

◆ reserve_fdt_pages()

static bool reserve_fdt_pages ( const void *  fdt_addr)
static

Reserve pages occupied by the Device Tree Blob (FDT).

This function calculates the number of pages occupied by the FDT and reserves those pages in the page allocator to prevent them from being allocated for other purposes.

Parameters
fdt_addrPointer to the FDT blob.
Returns
bool True if reservation was successful, false otherwise.

◆ reserve_kernel_img_pages()

static bool reserve_kernel_img_pages ( void  )
static

Reserve pages occupied by the kernel image.

This function calculates the number of pages occupied by the kernel image based on the linker-provided symbols and reserves those pages in the page allocator to prevent them from being allocated for other purposes.

Returns
bool True if reservation was successful, false otherwise.

◆ setup_page_allocator()

bool setup_page_allocator ( const void *  fdt_addr)

Set up the global page allocator.

This function initializes the global page allocator based on the memory map obtained from the Device Tree Blob (FDT).

Parameters
fdt_addrPointer to the FDT blob.
Returns
bool True if initialization was successful, false otherwise.