|
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.
|
Header that interfaces with libfdt for Device Tree Blob (DTB) parsing. More...
#include "mem_layout/mem_layout.h"#include "utils/kprintf.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Data Structures | |
| struct | memory_region_t |
| Represents a single physical memory span. More... | |
| struct | memory_map_t |
| Container for the system physical memory layout. More... | |
| struct | interrupt_t |
| Describes a single interrupt as parsed from an FDT "interrupts" specifier. More... | |
Macros | |
| #define | MAX_MEM_REGIONS 16 |
| Maximum number of distinct memory regions the kernel will track. | |
Typedefs | |
| typedef struct memory_region_t | memory_region_t |
| Represents a single physical memory span. | |
| typedef struct memory_map_t | memory_map_t |
| Container for the system physical memory layout. | |
| typedef enum irq_type_t | irq_type_t |
| Interrupt category, as encoded in the first cell of an FDT "interrupts" property. | |
| typedef enum irq_trigger_t | irq_trigger_t |
| Signal shape used to trigger an interrupt. | |
| typedef struct interrupt_t | interrupt_t |
| Describes a single interrupt as parsed from an FDT "interrupts" specifier. | |
Enumerations | |
| enum | irq_type_t { IRQ_TYPE_SPI = 0x0 , IRQ_TYPE_PPI = 0x1 } |
| Interrupt category, as encoded in the first cell of an FDT "interrupts" property. More... | |
| enum | irq_trigger_t { IRQ_TRIGGER_EDGE , IRQ_TRIGGER_LEVEL_HIGH } |
| Signal shape used to trigger an interrupt. More... | |
Functions | |
| static int32_t | interrupt_to_intid (const interrupt_t *const interrupt) |
| Converts a parsed FDT interrupt specifier to its GIC INTID. | |
| bool | check_fdt (const void *ptr) |
| Check the validity of the Device Tree Blob (FDT). | |
| int | get_mem (const void *fdt, memory_map_t *mmap) |
| Scans the FDT for memory nodes and populates the provided map. | |
| int | get_intc_node_offset (const void *fdt) |
| Retrieves a pointer to the interrupt controller node in the FDT. | |
| bool | fdt_is_error (int offset) |
| Checks if the given FDT offset represents an error. | |
| char * | get_compatible_string (const void *fdt, int node_offset) |
| Retrieves the compatible string for a given node. | |
| bool | get_reg_property (const void *fdt, int node_offset, memory_map_t *reg_map) |
| Retrieves the register property for a given node. | |
| int | get_intr_property (const void *fdt, int node_offset, interrupt_t *out_intr_array, size_t out_intr_array_len) |
| Retrieves the interrupt property for a given node. | |
| int | get_nodes_by_compatible (const void *fdt, const char *compatible, int *out_node_offsets, size_t out_node_offsets_len) |
| Finds all nodes in the FDT matching a given "compatible" string. | |
Header that interfaces with libfdt for Device Tree Blob (DTB) parsing.
Declares the kernel-facing FDT helper APIs used to validate and extract memory mapping information from the device tree.
| enum irq_trigger_t |
| enum irq_type_t |
| bool check_fdt | ( | const void * | ptr | ) |
Check the validity of the Device Tree Blob (FDT).
| ptr | Pointer to the FDT in memory. |
| bool fdt_is_error | ( | int | offset | ) |
Checks if the given FDT offset represents an error.
| offset | The FDT offset to check. |
| char * get_compatible_string | ( | const void * | fdt, |
| int | node_offset | ||
| ) |
Retrieves the compatible string for a given node.
| fdt | Pointer to the FDT header in memory. |
| node_offset | Offset of the node for which to retrieve the compatible string. |
| int get_intc_node_offset | ( | const void * | fdt | ) |
Retrieves a pointer to the interrupt controller node in the FDT.
| fdt | Pointer to the FDT header in memory. |
| int get_intr_property | ( | const void * | fdt, |
| int | node_offset, | ||
| interrupt_t * | out_intr_array, | ||
| size_t | out_intr_array_len | ||
| ) |
Retrieves the interrupt property for a given node.
| fdt | Pointer to the FDT header in memory. |
| node_offset | Offset of the node for which to retrieve the interrupt property. |
| out_intr_array | Array to be populated with the parsed interrupt specifiers. |
| out_intr_array_len | Number of elements available in out_intr_array. |
out_intr_array_len), or a negative libfdt error code on failure. | int get_mem | ( | const void * | fdt, |
| memory_map_t * | mmap | ||
| ) |
Scans the FDT for memory nodes and populates the provided map.
This function searches the FDT for nodes with device_type = "memory", respects the root node's #address-cells and #size-cells, and handles both 32-bit and 64-bit address formats.
| fdt | Pointer to the FDT header in memory. |
| mmap | Pointer to a memory_map_t structure to be populated. |
| int get_nodes_by_compatible | ( | const void * | fdt, |
| const char * | compatible, | ||
| int * | out_node_offsets, | ||
| size_t | out_node_offsets_len | ||
| ) |
Finds all nodes in the FDT matching a given "compatible" string.
| fdt | Pointer to the FDT header in memory. |
| compatible | Compatible string to search for. |
| out_node_offsets | Array to be populated with the offsets of matching nodes. |
| out_node_offsets_len | Number of elements available in out_node_offsets. |
out_node_offsets_len), or a negative libfdt error code on failure. | bool get_reg_property | ( | const void * | fdt, |
| int | node_offset, | ||
| memory_map_t * | reg_map | ||
| ) |
Retrieves the register property for a given node.
| fdt | Pointer to the FDT header in memory. |
| node_offset | Offset of the node for which to retrieve the register property. |
| reg_map | Pointer to a memory_map_t structure to be populated with register information. |
|
inlinestatic |
Converts a parsed FDT interrupt specifier to its GIC INTID.
Per the ARM GIC devicetree binding, the "interrupts" cell's id is an offset within its category rather than the absolute INTID, so the base offset must be added back in: PPIs start at INTID 16, SPIs at INTID 32.
| interrupt | Interrupt specifier to convert. |
interrupt has an unrecognized type.