arch: arc: use _curr_cpu to replace _curr_irq_stack

use _curr_cpu to record the _cpu_t of each cpu.
the irq_stack is also covered

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
This commit is contained in:
Wayne Ren 2019-08-13 23:25:34 +08:00 committed by Ioannis Glaropoulos
commit bb0a189d42
2 changed files with 7 additions and 8 deletions

View file

@ -77,18 +77,16 @@ volatile struct {
*/ */
volatile u32_t arc_cpu_wake_flag; volatile u32_t arc_cpu_wake_flag;
/* /*
* _curr_irq_stack is used to record the irq stack pointer * _curr_cpu is used to record the struct of _cpu_t of each cpu.
* of per_cpu. _kernel.cpus[CONFIG_MP_NUM_CPUS].irq_stack also * for efficient usage in assembly
* has a copy of irq stack pointer, but not efficient to use in assembly
*/ */
volatile u32_t _curr_irq_stack[CONFIG_MP_NUM_CPUS]; volatile _cpu_t *_curr_cpu[CONFIG_MP_NUM_CPUS];
/* Called from Zephyr initialization */ /* Called from Zephyr initialization */
void z_arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz, void z_arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
void (*fn)(int, void *), void *arg) void (*fn)(int, void *), void *arg)
{ {
_curr_cpu[cpu_num] = &(_kernel.cpus[cpu_num]);
_curr_irq_stack[cpu_num] = (u32_t)(sz + (char *)stack);
arc_cpu_init[cpu_num].fn = fn; arc_cpu_init[cpu_num].fn = fn;
arc_cpu_init[cpu_num].arg = arg; arc_cpu_init[cpu_num].arg = arg;
@ -139,7 +137,7 @@ static int arc_smp_init(struct device *dev)
_kernel.cpus[0].id = 0; _kernel.cpus[0].id = 0;
_kernel.cpus[0].irq_stack = Z_THREAD_STACK_BUFFER(_interrupt_stack) _kernel.cpus[0].irq_stack = Z_THREAD_STACK_BUFFER(_interrupt_stack)
+ CONFIG_ISR_STACK_SIZE; + CONFIG_ISR_STACK_SIZE;
_curr_irq_stack[0] = (u32_t)(_kernel.cpus[0].irq_stack); _curr_cpu[0] = &(_kernel.cpus[0]);
bcr.val = z_arc_v2_aux_reg_read(_ARC_V2_CONNECT_BCR); bcr.val = z_arc_v2_aux_reg_read(_ARC_V2_CONNECT_BCR);

View file

@ -314,7 +314,8 @@
.macro _get_curr_cpu_irq_stack irq_sp .macro _get_curr_cpu_irq_stack irq_sp
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
_get_cpu_id \irq_sp _get_cpu_id \irq_sp
ld.as \irq_sp, [@_curr_irq_stack, \irq_sp] ld.as \irq_sp, [@_curr_cpu, \irq_sp]
ld \irq_sp, [\irq_sp, ___cpu_t_irq_stack_OFFSET]
#else #else
mov \irq_sp, _kernel mov \irq_sp, _kernel
ld \irq_sp, [\irq_sp, _kernel_offset_to_irq_stack] ld \irq_sp, [\irq_sp, _kernel_offset_to_irq_stack]