imp: dtb lib use printf instead of custom logging lib

This commit is contained in:
Jordan ⌨️ 2025-04-20 17:34:18 +02:00
parent f85e8aa35d
commit a7147437af
2 changed files with 16 additions and 11 deletions

View file

@ -0,0 +1,5 @@
#pragma once
#include <logger>
#define printf(...) _log(LOG_INFO, (Loc){0}, __VA_ARGS__)

View file

@ -1,6 +1,6 @@
#include <helpers/endian.h>
#include <helpers/mem.h>
#include <logger>
#include <stdio.h>
#include <string.h>
#include "mod.h"
@ -13,7 +13,7 @@ static uint32_t read_offset(uint8_t** offset) {
static DTBNode* dtb_parse(FDTHeader* dtb_header, Allocator* alloc) {
if (dtb_header == NULL) {
error$("Device tree blob not initialized");
printf("Device tree blob not initialized");
return NULL;
}
@ -34,13 +34,13 @@ static DTBNode* dtb_parse(FDTHeader* dtb_header, Allocator* alloc) {
if (!root) {
if (*node_name) {
error$("Invalid device tree blob. Expected root node to be empty");
printf("Invalid device tree blob. Expected root node to be empty");
return NULL;
}
root = alloc->alloc(alloc, sizeof(DTBNode));
if (root == NULL) {
error$("Failed to allocate memory for device tree node");
printf("Failed to allocate memory for device tree node");
return NULL;
}
@ -53,7 +53,7 @@ static DTBNode* dtb_parse(FDTHeader* dtb_header, Allocator* alloc) {
DTBNode* new_node = alloc->alloc(alloc, sizeof(DTBNode));
if (new_node == NULL) {
error$("Failed to allocate memory for device tree node");
printf("Failed to allocate memory for device tree node");
return NULL;
}
@ -92,7 +92,7 @@ static DTBNode* dtb_parse(FDTHeader* dtb_header, Allocator* alloc) {
DTBProp* prop = alloc->alloc(alloc, sizeof(DTBProp));
if (prop == NULL) {
error$("Failed to allocate memory for device tree property");
printf("Failed to allocate memory for device tree property");
return NULL;
}
@ -126,7 +126,7 @@ static DTBNode* dtb_parse(FDTHeader* dtb_header, Allocator* alloc) {
break;
default: {
error$("Unknown token %x", token);
printf("Unknown token %x", token);
return NULL;
}
}
@ -139,7 +139,7 @@ DTBNode* dtb_init(uintptr_t dtb, Allocator* alloc) {
FDTHeader* dtb_header = (FDTHeader*)dtb;
if (from_be32(dtb_header->magic) != DTB_MAGIC) {
error$("Invalid device tree blob magic number. Excecting %x, got %x", DTB_MAGIC, from_be32(dtb_header->magic));
printf("Invalid device tree blob magic number. Excecting %x, got %x", DTB_MAGIC, from_be32(dtb_header->magic));
return NULL;
}
@ -179,7 +179,7 @@ RegValue dtb_lookup_reg(DTBNode* node) {
DTBProp* prop = dtb_lookup_prop(node, "reg");
if (prop == NULL) {
error$("Failed to find reg property in device tree node %s", node->name);
printf("Failed to find reg property in device tree node %s", node->name);
return reg;
}
@ -187,13 +187,13 @@ RegValue dtb_lookup_reg(DTBNode* node) {
DTBProp* address_cells_prop = dtb_lookup_prop(node->parent, "#address-cells");
if (address_cells_prop == NULL) {
error$("Failed to find #address-cells property in device tree node %s", node->parent->name);
printf("Failed to find #address-cells property in device tree node %s", node->parent->name);
return reg;
}
DTBProp* size_cells_prop = dtb_lookup_prop(node->parent, "#size-cells");
if (size_cells_prop == NULL) {
error$("Failed to find #size-cells property in device tree node %s", node->parent->name);
printf("Failed to find #size-cells property in device tree node %s", node->parent->name);
return reg;
}