kernel: cleanup and formally define CPU start fn
The "key" parameter is legacy, remove it. Add a typedef for the expected function pointer type. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
808cca0efb
commit
a594ca7c8f
11 changed files with 28 additions and 22 deletions
|
@ -24,7 +24,7 @@
|
|||
#define ARCV2_ICI_IRQ_PRIORITY 1
|
||||
|
||||
volatile struct {
|
||||
void (*fn)(int, void*);
|
||||
arch_cpustart_t fn;
|
||||
void *arg;
|
||||
} arc_cpu_init[CONFIG_MP_NUM_CPUS];
|
||||
|
||||
|
@ -46,7 +46,7 @@ volatile _cpu_t *_curr_cpu[CONFIG_MP_NUM_CPUS];
|
|||
|
||||
/* Called from Zephyr initialization */
|
||||
void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
|
||||
void (*fn)(int, void *), void *arg)
|
||||
arch_cpustart_t fn, void *arg)
|
||||
{
|
||||
_curr_cpu[cpu_num] = &(_kernel.cpus[cpu_num]);
|
||||
arc_cpu_init[cpu_num].fn = fn;
|
||||
|
@ -69,7 +69,7 @@ void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
|
|||
/* the C entry of slave cores */
|
||||
void z_arc_slave_start(int cpu_num)
|
||||
{
|
||||
void (*fn)(int, void*);
|
||||
arch_cpustart_t fn;
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
z_icache_setup();
|
||||
|
@ -82,7 +82,7 @@ void z_arc_slave_start(int cpu_num)
|
|||
/* call the function set by arch_start_cpu */
|
||||
fn = arc_cpu_init[cpu_num].fn;
|
||||
|
||||
fn(cpu_num, arc_cpu_init[cpu_num].arg);
|
||||
fn(arc_cpu_init[cpu_num].arg);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
|
|
|
@ -240,7 +240,6 @@ __csSet:
|
|||
#endif
|
||||
|
||||
pushl %ebx /* pointer to multiboot info, or NULL */
|
||||
pushl %eax /* junk, unused argument */
|
||||
call z_x86_prep_c /* enter kernel; never returns */
|
||||
|
||||
_x86_bss_zero:
|
||||
|
|
|
@ -94,11 +94,11 @@ struct x86_cpuboot x86_cpuboot[] = {
|
|||
|
||||
/*
|
||||
* Send the INIT/STARTUP IPI sequence required to start up CPU 'cpu_num', which
|
||||
* will enter the kernel at fn(---, arg), running on the specified stack.
|
||||
* will enter the kernel at fn(arg), running on the specified stack.
|
||||
*/
|
||||
|
||||
void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
|
||||
void (*fn)(int key, void *data), void *arg)
|
||||
arch_cpustart_t fn, void *arg)
|
||||
{
|
||||
u8_t vector = ((unsigned long) x86_ap_start) >> 12;
|
||||
u8_t apic_id = x86_cpu_loapics[cpu_num];
|
||||
|
|
|
@ -196,7 +196,7 @@ go64: movl %cr4, %eax /* enable PAE and SSE */
|
|||
/* don't replace CALL with JMP; honor the ABI stack alignment! */
|
||||
|
||||
incl __x86_cpuboot_t_ready_OFFSET(%rbp)
|
||||
movq __x86_cpuboot_t_arg_OFFSET(%rbp), %rsi
|
||||
movq __x86_cpuboot_t_arg_OFFSET(%rbp), %rdi
|
||||
call *__x86_cpuboot_t_fn_OFFSET(%rbp) /* enter kernel; never return */
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,9 +11,12 @@
|
|||
|
||||
extern FUNC_NORETURN void z_cstart(void);
|
||||
|
||||
FUNC_NORETURN void z_x86_prep_c(int unused, struct multiboot_info *info)
|
||||
/* Early global initialization functions, C domain. This runs only on the first
|
||||
* CPU for SMP systems.
|
||||
*/
|
||||
FUNC_NORETURN void z_x86_prep_c(void *arg)
|
||||
{
|
||||
ARG_UNUSED(unused);
|
||||
struct multiboot_info *info = arg;
|
||||
|
||||
_kernel.cpus[0].nested = 0;
|
||||
_kernel.cpus[0].irq_stack = Z_THREAD_STACK_BUFFER(_interrupt_stack) +
|
||||
|
|
|
@ -23,7 +23,7 @@ struct x86_cpuboot {
|
|||
u16_t tr; /* selector for task register */
|
||||
struct x86_tss64 *gs_base; /* Base address for GS segment */
|
||||
u64_t sp; /* initial stack pointer */
|
||||
void *fn; /* kernel entry function */
|
||||
arch_cpustart_t fn; /* kernel entry function */
|
||||
void *arg; /* argument for above function */
|
||||
#ifdef CONFIG_X86_MMU
|
||||
struct x86_page_tables *ptables; /* Runtime page tables to install */
|
||||
|
|
|
@ -36,7 +36,7 @@ extern K_THREAD_STACK_DEFINE(_interrupt_stack3, CONFIG_ISR_STACK_SIZE);
|
|||
|
||||
struct multiboot_info;
|
||||
|
||||
extern FUNC_NORETURN void z_x86_prep_c(int dummy, struct multiboot_info *info);
|
||||
extern FUNC_NORETURN void z_x86_prep_c(void *arg);
|
||||
|
||||
#ifdef CONFIG_X86_VERY_EARLY_CONSOLE
|
||||
/* Setup ultra-minimal serial driver for printk() */
|
||||
|
|
|
@ -159,6 +159,13 @@ void arch_cpu_atomic_idle(unsigned int key);
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Per-cpu entry function
|
||||
*
|
||||
* @param context parameter, implementation specific
|
||||
*/
|
||||
typedef FUNC_NORETURN void (*arch_cpustart_t)(void *data);
|
||||
|
||||
/**
|
||||
* @brief Start a numbered CPU on a MP-capable system
|
||||
*
|
||||
|
@ -176,12 +183,11 @@ void arch_cpu_atomic_idle(unsigned int key);
|
|||
* @param cpu_num Integer number of the CPU
|
||||
* @param stack Stack memory for the CPU
|
||||
* @param sz Stack buffer size, in bytes
|
||||
* @param fn Function to begin running on the CPU. First argument is
|
||||
* an irq_unlock() key.
|
||||
* @param fn Function to begin running on the CPU.
|
||||
* @param arg Untyped argument to be passed to "fn"
|
||||
*/
|
||||
void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
|
||||
void (*fn)(int key, void *data), void *arg);
|
||||
arch_cpustart_t fn, void *arg);
|
||||
/** @} */
|
||||
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ extern k_thread_stack_t _interrupt_stack2[];
|
|||
extern k_thread_stack_t _interrupt_stack3[];
|
||||
|
||||
#if CONFIG_MP_NUM_CPUS > 1
|
||||
static void smp_init_top(int key, void *arg)
|
||||
static FUNC_NORETURN void smp_init_top(void *arg)
|
||||
{
|
||||
atomic_t *start_flag = arg;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
struct cpustart_rec {
|
||||
int cpu;
|
||||
void (*fn)(int, void *);
|
||||
arch_cpustart_t fn;
|
||||
char *stack_top;
|
||||
void *arg;
|
||||
int vecbase;
|
||||
|
@ -93,7 +93,7 @@ static void appcpu_entry2(void)
|
|||
__asm__ volatile("wsr.MISC0 %0" : : "r"(cpu));
|
||||
|
||||
*start_rec->alive = 1;
|
||||
start_rec->fn(ps, start_rec->arg);
|
||||
start_rec->fn(start_rec->arg);
|
||||
}
|
||||
|
||||
/* Defines a locally callable "function" named _stack-switch(). The
|
||||
|
@ -191,7 +191,7 @@ static void appcpu_start(void)
|
|||
}
|
||||
|
||||
void arch_start_cpu(int cpu_num, k_thread_stack_t *stack, int sz,
|
||||
void (*fn)(int, void *), void *arg)
|
||||
arch_cpustart_t fn, void *arg)
|
||||
{
|
||||
volatile struct cpustart_rec sr;
|
||||
int vb;
|
||||
|
|
|
@ -33,10 +33,8 @@ volatile int cpu_running;
|
|||
* @{
|
||||
* @}
|
||||
*/
|
||||
void cpu1_fn(int key, void *arg)
|
||||
FUNC_NORETURN void cpu1_fn(void *arg)
|
||||
{
|
||||
ARG_UNUSED(key);
|
||||
|
||||
zassert_true(arg == &cpu_arg && *(int *)arg == 12345, "wrong arg");
|
||||
|
||||
cpu_running = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue