aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fbos/dt.h20
-rw-r--r--include/fbos/init.h7
2 files changed, 21 insertions, 6 deletions
diff --git a/include/fbos/dt.h b/include/fbos/dt.h
index fd77c35..bbeb7cd 100644
--- a/include/fbos/dt.h
+++ b/include/fbos/dt.h
@@ -3,13 +3,21 @@
#include <fbos/compiler.h>
-// Pair of addresses where the initrd is located in memory.
-struct initrd_addr {
- uintptr_t start;
- uintptr_t end;
+// Default value for the 'dt_info.cpu_freq' property if none could be retrieved.
+#define DEFAULT_CPU_FREQ 10000000
+
+// Holds all the information that we gather from the initial DeviceTree blob.
+struct dt_info {
+ // Ticks per second. If `get_dt_info` fails at setting this value, then
+ // `DEFAULT_CPU_FREQ` is used.
+ uint64_t cpu_freq;
+
+ // Start and end addresses of the initramfs blob as stored in memory.
+ uintptr_t initrd_start;
+ uintptr_t initrd_end;
};
-// Returns the `initrd` addresses as parsed from the given DTB blob.
-struct initrd_addr find_dt_initrd_addr(uint32_t *dtb);
+// Set 'info' by parsing the given 'dtb' blob.
+void get_dt_info(uint32_t *dtb, struct dt_info *info);
#endif // __FBOS_DT_H_
diff --git a/include/fbos/init.h b/include/fbos/init.h
index f0f1dce..9e0049e 100644
--- a/include/fbos/init.h
+++ b/include/fbos/init.h
@@ -2,6 +2,7 @@
#define __FBOS_INIT_H
#include <fbos/compiler.h>
+#include <fbos/dt.h>
#include <fbos/sched.h>
// Tracks the amount of seconds that have elapsed since activating timer
@@ -10,6 +11,12 @@
// Instantiated in kernel/trap.c, initialized in main.c.
extern uint64_t seconds_elapsed;
+// General information from the DTB blob. This will be properly initialized at
+// the very beginning of kernel initialization.
+//
+// Instantiated and initialized in kernel/main.c.
+extern struct dt_info info;
+
// Extract the executables from the initrd that is located at `base_addr` and
// has the given `size`.
void extract_initrd(const unsigned char *const base_addr, uint64_t size,