summaryrefslogtreecommitdiff
path: root/kernel/common/dtb.c
diff options
context:
space:
mode:
authorNathan Lee <me@nwlee.tech>2026-08-28 21:26:14 -0500
committerNathan Lee <me@nwlee.tech>2026-08-28 21:26:14 -0500
commit7f4c833ced046f88160a50e7adb1f55343e7e759 (patch)
treeec41ed5c02ba61bc9abf58b9db5f8a1d88c8ebd1 /kernel/common/dtb.c
parent4bbe418d2ecea36f80a38b74462c2936343f3b7d (diff)
rework early kernel init
Diffstat (limited to 'kernel/common/dtb.c')
-rw-r--r--kernel/common/dtb.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/kernel/common/dtb.c b/kernel/common/dtb.c
index b345db0..482359b 100644
--- a/kernel/common/dtb.c
+++ b/kernel/common/dtb.c
@@ -1,5 +1,5 @@
#include <early/dtb.h>
-#include <early/bump.h>
+#include <sys/mem.h>
struct dt_node *dt_parse(void *fdt) {
struct fdt_header *hdr = fdt;
@@ -52,6 +52,28 @@ struct dt_node *dt_parse(void *fdt) {
}
}
+struct dt_node *dt_find_device(struct dt_node *head, const char *name) {
+ struct dt_node *child = head->children;
+ while (child) {
+ struct dt_node *result = dt_find_device(child, name);
+ if (result) {
+ return result;
+ } else {
+ child = child->next;
+ }
+ }
+
+ struct dt_prop *props = head->props;
+ while (props) {
+ if (strcmp(props->name, "device_type") == 0 &&
+ strcmp(props->value, name) == 0) {
+ return head;
+ }
+ }
+
+ return NULL;
+}
+
void *dt_get_prop(struct dt_node *node, char *name, size_t *len) {
for (struct dt_prop *p = node->props; p; p = p->next) {
if (strcmp(p->name, name) == 0) {