TF-RMM Release v0.1.0
This is the first external release of TF-RMM and provides a reference
implementation of Realm Management Monitor (RMM) as specified by the
RMM Beta0 specification[1].
The `docs/readme.rst` has more details about the project and
`docs/getting_started/getting-started.rst` has details on how to get
started with TF-RMM.
[1] https://developer.arm.com/documentation/den0137/1-0bet0/?lang=en
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: I205ef14c015e4a37ae9ae1a64e4cd22eb8da746e
diff --git a/lib/allocator/include/memory_alloc.h b/lib/allocator/include/memory_alloc.h
new file mode 100644
index 0000000..5346395
--- /dev/null
+++ b/lib/allocator/include/memory_alloc.h
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
+ */
+
+#ifndef MEMORY_ALLOC_H
+#define MEMORY_ALLOC_H
+
+#include <stddef.h>
+
+struct _memory_header;
+typedef struct memory_header_s memory_header_t;
+
+/*
+ * Number of pages per REC to be allocated. MbedTLS needs 8K of heap
+ * for attestation usecases.
+ */
+#define REC_HEAP_PAGES 2
+
+struct buffer_alloc_ctx {
+ unsigned char *buf;
+ size_t len;
+ memory_header_t *first;
+ memory_header_t *first_free;
+ int verify;
+};
+
+struct memory_header_s {
+ size_t magic1;
+ size_t size;
+ size_t alloc;
+ memory_header_t *prev;
+ memory_header_t *next;
+ memory_header_t *prev_free;
+ memory_header_t *next_free;
+ size_t magic2;
+};
+
+
+/*
+ * Function to assign a heap context to the current CPU for
+ * use by the MbedCrypto. In case the heap needs to be isolated
+ * to the CPU executing a realm , this function must to be
+ * called before entering a Realm. This will ensure that any
+ * crypto operations triggered via RSI will used the assigned
+ * heap.
+ * Arguments:
+ * ctx - Pointer to a valid context for the memory allocator.
+ * Returns:
+ * 0 on success or a POSIX error code or error.
+ */
+int buffer_alloc_ctx_assign(struct buffer_alloc_ctx *ctx);
+
+/*
+ * Function to unasign a heap context from the current CPU.
+ * In case the heap was isolated to the CPU executing a realm,
+ * this function must to be called after exiting a Realm.
+ */
+void buffer_alloc_ctx_unassign(void);
+
+#endif /* MEMORY_ALLOC_H */