From 0464b7765aa4d1fc2178e443a3b37d19cfe541a0 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 2 Mar 2025 21:45:51 +0200 Subject: 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. --- include/gran/if/alloc.h | 36 ++++++++++++++++++++++++++++++++++++ include/gran/mem/ideal_alloc.h | 11 +++++++++++ 2 files changed, 47 insertions(+) create mode 100644 include/gran/if/alloc.h create mode 100644 include/gran/mem/ideal_alloc.h (limited to 'include') 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 + +/* 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 +#include +#include + +struct component *create_ideal_alloc(uint64_t spaces); +void ideal_alloc_connect(struct component *alloc, struct component *send); + +#endif /* GRAN_IDEAL_ALLOC_H */ -- cgit v1.3