|
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.
|
Implementation of Device Tree Blob (FDT) parsing and validation functions. More...
#include "fdt/fdt.h"#include "utils/kprintf.h"#include <libfdt.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Functions | |
| 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. | |
Implementation of Device Tree Blob (FDT) parsing and validation functions.
Validates the FDT header, extracts memory map entries, and exposes kernel helpers for consuming device tree data.
| 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. |