summaryrefslogtreecommitdiff
path: root/include/early
diff options
context:
space:
mode:
authorNathan Lee <me@nwlee.tech>2026-08-12 17:44:17 -0500
committerNathan Lee <me@nwlee.tech>2026-08-12 17:44:17 -0500
commit2c0efd93530c472e96ff3529aee983b53f3b78d9 (patch)
treecc36e7334e162ba67df79333e267ac93b4d984b9 /include/early
parent640a81b3ee366c651286efd1b80b37992cd53282 (diff)
rework project structure
Diffstat (limited to 'include/early')
-rw-r--r--include/early/bump.h9
-rw-r--r--include/early/dtb.h46
2 files changed, 55 insertions, 0 deletions
diff --git a/include/early/bump.h b/include/early/bump.h
new file mode 100644
index 0000000..bf3e6f9
--- /dev/null
+++ b/include/early/bump.h
@@ -0,0 +1,9 @@
+#pragma once
+#include <sys/stddef.h>
+#include <early/dtb.h>
+#define EHEAP_SIZE (512 * 1024)
+
+
+void* kemalloc(size_t size);
+struct mem_info *km_find_memory(struct dt_node *head);
+
diff --git a/include/early/dtb.h b/include/early/dtb.h
new file mode 100644
index 0000000..41a7bcc
--- /dev/null
+++ b/include/early/dtb.h
@@ -0,0 +1,46 @@
+#pragma once
+#include <sys/stddef.h>
+
+#define FDT_MAGIC 0xEDFE0DD0
+#define FDT_BEGIN_NODE 1
+#define FDT_END_NODE 2
+#define FDT_PROP 3
+#define FDT_NOP 4
+#define FDT_END 9
+
+#define DTB_MAX_NODES 16
+
+struct dt_node {
+ char *name;
+ struct dt_prop *props;
+ struct dt_node *children;
+ struct dt_node *next;
+};
+
+struct dt_prop {
+ char *name;
+ char *value;
+ size_t len;
+ struct dt_prop *next;
+};
+
+struct fdt_header {
+ uint32_t magic;
+ uint32_t totalsize;
+ uint32_t off_dt_struct;
+ uint32_t off_dt_strings;
+ uint32_t off_mem_rsvmap;
+ uint32_t version;
+ uint32_t last_comp_version;
+ uint32_t boot_cpuid_phys;
+ uint32_t size_dt_strings;
+ uint32_t size_dt_struct;
+};
+
+struct dt_node *dt_parse(void *fdt);
+void *dt_get_prop(struct dt_node *node, char *name, size_t *len);
+uint32_t dt_read_u32(struct dt_node *node, char *name, uint32_t *out);
+
+
+struct dt_node *dt_node_alloc(char *name);
+struct dt_prop *dt_prop_alloc(char *name, void *value, size_t len);