aboutsummaryrefslogtreecommitdiff
path: root/include/sbi
diff options
context:
space:
mode:
authorGregor Haas <gregorhaas1997@gmail.com>2024-08-08 20:16:38 -0700
committerAnup Patel <anup@brainfault.org>2024-08-09 08:51:27 +0530
commitb9c091ed890224dc83a152d897965c7a332c1504 (patch)
tree6f3408b532a6ad3b8ac30e7854e1bc46c7336cfb /include/sbi
parentcda001479555e08dfb8d952093fa843021a39930 (diff)
downloadopensbi-b9c091ed890224dc83a152d897965c7a332c1504.zip
opensbi-b9c091ed890224dc83a152d897965c7a332c1504.tar.gz
opensbi-b9c091ed890224dc83a152d897965c7a332c1504.tar.bz2
lib: sbi: Implement aligned memory allocators
This change adds a simple implementation of sbi_aligned_alloc(), for future use in allocating aligned memory for SMMTT tables. Signed-off-by: Gregor Haas <gregorhaas1997@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'include/sbi')
-rw-r--r--include/sbi/sbi_heap.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/sbi/sbi_heap.h b/include/sbi/sbi_heap.h
index 9a67090..a4b3f0c 100644
--- a/include/sbi/sbi_heap.h
+++ b/include/sbi/sbi_heap.h
@@ -31,6 +31,15 @@ static inline void *sbi_malloc(size_t size)
return sbi_malloc_from(&global_hpctrl, size);
}
+/** Allocate aligned from heap area */
+void *sbi_aligned_alloc_from(struct sbi_heap_control *hpctrl,
+ size_t alignment,size_t size);
+
+static inline void *sbi_aligned_alloc(size_t alignment, size_t size)
+{
+ return sbi_aligned_alloc_from(&global_hpctrl, alignment, size);
+}
+
/** Zero allocate from heap area */
void *sbi_zalloc_from(struct sbi_heap_control *hpctrl, size_t size);