aboutsummaryrefslogtreecommitdiff
path: root/common/mem.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-05-11 22:55:31 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-05-11 22:55:31 +0300
commit27ffa747f36aee9c1d5bbc61395a078238366070 (patch)
treef37c544aaca6bebd1cc146d1eb002483c7cfd474 /common/mem.c
parent3109effe7297232e17c1792e63c3a9c7d129a4eb (diff)
downloadkmi-27ffa747f36aee9c1d5bbc61395a078238366070.tar.gz
kmi-27ffa747f36aee9c1d5bbc61395a078238366070.zip
arbitrary load address and RAM base detection
+ Both kind of go hand in hand, made sense to do both at the same time. Some parts feel slightly hacky, the loader works by placing everything on the stack and avoiding global values. Still, seems to work?
Diffstat (limited to 'common/mem.c')
-rw-r--r--common/mem.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/mem.c b/common/mem.c
index 69ba4d6..e3f98e7 100644
--- a/common/mem.c
+++ b/common/mem.c
@@ -17,6 +17,12 @@ size_t __mm_sizes[10];
size_t __mm_page_shift;
enum mm_order __mm_max_order;
+/**
+ * RAM base address. Not sure if it should be provided through a macro
+ * like __mm_*.
+ */
+pm_t ram_base;
+
enum mm_order nearest_order(size_t size)
{
for (enum mm_order order = max_order(); order >= MM_MIN; --order)
@@ -41,3 +47,13 @@ void init_mem(size_t max_order, size_t bits[10], size_t page_shift)
__mm_sizes[i] = 1UL << __mm_shifts[i];
}
}
+
+void set_ram_base(uintptr_t base)
+{
+ ram_base = base;
+}
+
+uintptr_t get_ram_base()
+{
+ return ram_base;
+}