Skip to content

Commit 64dfa69

Browse files
carlocaionenashif
authored andcommitted
aarch64: Remove useless _curr_cpu struct
Currently _curr_cpu is only used by the get_cpu macro to quickly access the cpu struct. This is not really necessary because we can access to the struct by directly referencing &(_kernel.cpus[cpu_num]) in assembly Signed-off-by: Carlo Caione <ccaione@baylibre.com>
1 parent f62a40b commit 64dfa69

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

arch/arm64/core/macro_priv.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#ifdef _ASMLANGUAGE
1111

12-
GDATA(_curr_cpu)
1312
GDATA(_kernel)
1413

1514
/*
@@ -27,10 +26,11 @@ GDATA(_kernel)
2726
*/
2827

2928
.macro get_cpu xreg0, xreg1
30-
ldr \xreg0, =_curr_cpu
3129
get_cpu_id \xreg1
32-
add \xreg0, \xreg0, \xreg1, lsl #3
33-
ldr \xreg0, [\xreg0]
30+
mov \xreg0, #___cpu_t_SIZEOF
31+
mul \xreg0, \xreg0, \xreg1
32+
ldr \xreg1, =(_kernel + ___kernel_t_cpus_OFFSET)
33+
add \xreg0, \xreg0, \xreg1
3434
.endm
3535

3636
/*

arch/arm64/core/smp.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,15 @@ volatile struct {
3232
char pad[] __aligned(L1_CACHE_BYTES);
3333
} arm64_cpu_init[CONFIG_MP_NUM_CPUS];
3434

35-
/*
36-
* _curr_cpu is used to record the struct of _cpu_t of each cpu.
37-
* for efficient usage in assembly
38-
*/
39-
volatile _cpu_t *_curr_cpu[CONFIG_MP_NUM_CPUS];
40-
4135
extern void __start(void);
36+
4237
/* Called from Zephyr initialization */
4338
void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
4439
arch_cpustart_t fn, void *arg)
4540
{
4641
__ASSERT(sizeof(arm64_cpu_init[0]) == ARM64_CPU_INIT_SIZE,
4742
"ARM64_CPU_INIT_SIZE != sizeof(arm64_cpu_init[0]\n");
4843

49-
_curr_cpu[cpu_num] = &(_kernel.cpus[cpu_num]);
5044
arm64_cpu_init[cpu_num].fn = fn;
5145
arm64_cpu_init[cpu_num].arg = arg;
5246
arm64_cpu_init[cpu_num].sp =
@@ -124,9 +118,6 @@ static int arm64_smp_init(const struct device *dev)
124118
{
125119
ARG_UNUSED(dev);
126120

127-
/* necessary master core init */
128-
_curr_cpu[0] = &(_kernel.cpus[0]);
129-
130121
/*
131122
* SGI0 is use for sched ipi, this might be changed to use Kconfig
132123
* option

kernel/include/kernel_offsets.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ GEN_OFFSET_SYM(_cpu_t, current);
2727
GEN_OFFSET_SYM(_cpu_t, nested);
2828
GEN_OFFSET_SYM(_cpu_t, irq_stack);
2929

30+
GEN_ABSOLUTE_SYM(___cpu_t_SIZEOF, sizeof(struct _cpu));
31+
32+
GEN_OFFSET_SYM(_kernel_t, cpus);
33+
3034
#if defined(CONFIG_THREAD_MONITOR)
3135
GEN_OFFSET_SYM(_kernel_t, threads);
3236
#endif

0 commit comments

Comments
 (0)