7#define ALIGN_UP(addr, size) (((addr) + (size)-1) & ~((size)-1))
8#define ALIGN_DOWN(addr, size) ((addr) & ~((size)-1))
10#define MIN_CHUNK_SIZE 8
20inline void *snrt_l1_next() {
return (
void *)snrt_l1_allocator()->next; }
22inline void *snrt_l3_next() {
return (
void *)snrt_l3_allocator()->next; }
31inline void *snrt_l1_alloc(
size_t size) {
36 size = ALIGN_UP(size, MIN_CHUNK_SIZE);
47 void *ret = (
void *)alloc->next;
55inline void snrt_l1_update_next(
void *next) {
57 alloc->next = (uint32_t)next;
67inline void *snrt_l3_alloc(
size_t size) {
72 void *ret = (
void *)alloc->next;
77inline void snrt_alloc_init() {
79 if (snrt_is_dm_core()) {
84 snrt_l1_allocator()->base =
85 ALIGN_UP(snrt_l1_start_addr(), MIN_CHUNK_SIZE);
86 snrt_l1_allocator()->end = snrt_l1_end_addr();
87 snrt_l1_allocator()->next = snrt_l1_allocator()->base;
89 extern uint32_t _edram;
90 snrt_l3_allocator()->base = ALIGN_UP((uint32_t)&_edram, MIN_CHUNK_SIZE);
91 snrt_l3_allocator()->end = snrt_l3_allocator()->base;
92 snrt_l3_allocator()->next = snrt_l3_allocator()->base;
95 snrt_cluster_hw_barrier();
99inline void *snrt_memset(
void *ptr,
int value,
size_t num) {
100 for (uint32_t i = 0; i < num; ++i)
101 *((uint8_t *)ptr + i) = (
unsigned char)value;
Definition alloc_decls.h:10