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>
This commit is contained in:
Gregor Haas
2024-08-08 20:16:38 -07:00
committed by Anup Patel
parent cda0014795
commit b9c091ed89
2 changed files with 78 additions and 6 deletions

View File

@@ -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);