From 961edb14af977df0295c830d851d7b220baad70e Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 2 Apr 2020 11:09:49 +0200 Subject: [PATCH] Cluster stacks are now dynamically allocated to avoid long preloading on netlist sim --- include/pulp.h | 8 ++++++++ kernel/alloc_pool.c | 11 +++++++++++ kernel/cluster.c | 8 +++++++- kernel/crt0.S | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/pulp.h b/include/pulp.h index 2ddf606..c56b2d5 100755 --- a/include/pulp.h +++ b/include/pulp.h @@ -78,6 +78,14 @@ int uart_read(int uart_id, void *buffer, uint32_t size); void synch_barrier(); +void *pi_l1_malloc(int cid, int size); +void pi_l1_free(int cid, void *chunk, int size); + +void *pi_l2_malloc(int size); +void pi_l2_free(void *_chunk, int size); + + + #endif diff --git a/kernel/alloc_pool.c b/kernel/alloc_pool.c index 1b0b869..a04278a 100644 --- a/kernel/alloc_pool.c +++ b/kernel/alloc_pool.c @@ -90,6 +90,17 @@ void alloc_init_l1(int cid) { pos_alloc_init(&pos_alloc_l1[cid], pos_l1_base(cid), pos_l1_size(cid)); } + +void *pi_l1_malloc(int cid, int size) +{ + return pos_alloc(&pos_alloc_l1[cid], size); +} + +void pi_l1_free(int cid, void *chunk, int size) +{ + return pos_free(&pos_alloc_l1[cid], chunk, size); +} + #endif diff --git a/kernel/cluster.c b/kernel/cluster.c index 71bd412..872eab9 100644 --- a/kernel/cluster.c +++ b/kernel/cluster.c @@ -20,7 +20,7 @@ volatile void *cluster_entry; -L1_DATA char cluster_stacks[ARCHI_CLUSTER_NB_PE*CLUSTER_STACK_SIZE]; +L1_DATA char *cluster_stacks; static volatile int cluster_running; @@ -78,6 +78,12 @@ void cluster_start(int cid, int (*entry)()) cluster_core_init(); } + alloc_init_l1(cid); + + cluster_stacks = pi_l1_malloc(cid, ARCHI_CLUSTER_NB_PE*CLUSTER_STACK_SIZE); + if (cluster_stacks == NULL) + return; + cluster_running = 1; // Fetch all cores diff --git a/kernel/crt0.S b/kernel/crt0.S index 5e71de9..f377889 100644 --- a/kernel/crt0.S +++ b/kernel/crt0.S @@ -160,6 +160,7 @@ pos_semihosting_call: #if defined(ARCHI_HAS_CLUSTER) pe_start: la x2, cluster_stacks + lw x2, 0(x2) li x3, CLUSTER_STACK_SIZE addi a1, a1, 1 mul x1, x3, a1