aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-03-02 21:45:51 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2025-03-02 21:45:51 +0200
commit0464b7765aa4d1fc2178e443a3b37d19cfe541a0 (patch)
tree7df54d44f11bcba1c9271148f085501bc2a02d2e /include
parentad6107d33a8a222d9062aae45d0e8d8483939d5d (diff)
downloadgran-0464b7765aa4d1fc2178e443a3b37d19cfe541a0.tar.gz
gran-0464b7765aa4d1fc2178e443a3b37d19cfe541a0.zip
add ideal allocation tracker
+ Kind of like CHERI, but uses out-of-line pointer information. The idea is that a core that is compatible with ALLOC_IF queries the allocation tracker if an address is legal and gets a response. This ideal tracker effectively has infinite memory and doesn't talk to any other components, but a real implementation might want to limit the allocations per process or chat with some reserved memory region somewhere else in the system to maintain a binary tree or something.
Diffstat (limited to 'include')
-rw-r--r--include/gran/if/alloc.h36
-rw-r--r--include/gran/mem/ideal_alloc.h11
2 files changed, 47 insertions, 0 deletions
diff --git a/include/gran/if/alloc.h b/include/gran/if/alloc.h
new file mode 100644
index 0000000..1fec04b
--- /dev/null
+++ b/include/gran/if/alloc.h
@@ -0,0 +1,36 @@
+#ifndef GRAN_ALLOC_IF_H
+#define GRAN_ALLOC_IF_H
+
+#include <stdint.h>
+
+/* completely arbitrary values */
+enum alloc_if_op {
+ ALLOC_IF_NEW = 0x00,
+ ALLOC_IF_RM = 0x40,
+ ALLOC_IF_Q = 0x80,
+};
+
+enum alloc_if_ret {
+ ALLOC_IF_OK,
+ ALLOC_IF_ERR_SPACE,
+ ALLOC_IF_ERR_RANGE,
+};
+
+struct alloc_if_new {
+ uint64_t space, start, end;
+};
+
+struct alloc_if_rm {
+ uint64_t space, start, end;
+};
+
+struct alloc_if_q {
+ uint64_t space, addr;
+};
+
+struct alloc_if_r {
+ enum alloc_if_ret r;
+ uint64_t start, end;
+};
+
+#endif /* GRAN_ALLOC_IF_H */
diff --git a/include/gran/mem/ideal_alloc.h b/include/gran/mem/ideal_alloc.h
new file mode 100644
index 0000000..009f91a
--- /dev/null
+++ b/include/gran/mem/ideal_alloc.h
@@ -0,0 +1,11 @@
+#ifndef GRAN_IDEAL_ALLOC_H
+#define GRAN_IDEAL_ALLOC_H
+
+#include <stdint.h>
+#include <gran/if/alloc.h>
+#include <gran/component.h>
+
+struct component *create_ideal_alloc(uint64_t spaces);
+void ideal_alloc_connect(struct component *alloc, struct component *send);
+
+#endif /* GRAN_IDEAL_ALLOC_H */