Skip to content

Commit 7fafadd

Browse files
authored
Merge pull request #43 from tlauda/topic/core_flow
init: init sequence supporting slave cores
2 parents 24aef14 + 7e430f2 commit 7fafadd

4 files changed

Lines changed: 86 additions & 23 deletions

File tree

src/include/sof/init.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ struct sof;
3636
/* main firmware entry point - argc and argv not currently used */
3737
int main(int argc, char *argv[]);
3838

39-
int arch_init(struct sof *sof);
39+
int master_core_init(struct sof *sof);
40+
41+
int slave_core_init(struct sof *sof);
4042

41-
void __memmap_init(void);
43+
int arch_init(struct sof *sof);
4244

4345
#endif

src/include/sof/task.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
struct sof;
3737
struct task;
3838

39-
int do_task(struct sof *sof);
39+
int do_task_master_core(struct sof *sof);
40+
41+
int do_task_slave_core(struct sof *sof);
4042

4143
static inline void allocate_tasks(void)
4244
{

src/init/init.c

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,51 +43,92 @@
4343
#include <sof/schedule.h>
4444
#include <sof/dma-trace.h>
4545
#include <sof/pm_runtime.h>
46+
#include <platform/idc.h>
4647
#include <platform/platform.h>
48+
#include <arch/cpu.h>
4749

4850
/* main firmware context */
4951
static struct sof sof;
5052

51-
int main(int argc, char *argv[])
53+
int master_core_init(struct sof *sof)
5254
{
5355
int err;
5456

55-
trace_point(TRACE_BOOT_START);
56-
57-
/* setup context */
58-
sof.argc = argc;
59-
sof.argv = argv;
60-
6157
/* init architecture */
6258
trace_point(TRACE_BOOT_ARCH);
63-
err = arch_init(&sof);
59+
err = arch_init(sof);
6460
if (err < 0)
6561
panic(SOF_IPC_PANIC_ARCH);
6662

6763
/* initialise system services */
6864
trace_point(TRACE_BOOT_SYS_HEAP);
69-
init_heap(&sof);
65+
init_heap(sof);
7066

71-
trace_init(&sof);
67+
trace_init(sof);
7268

7369
trace_point(TRACE_BOOT_SYS_NOTE);
74-
init_system_notify(&sof);
70+
init_system_notify(sof);
7571

7672
trace_point(TRACE_BOOT_SYS_SCHED);
77-
scheduler_init(&sof);
73+
scheduler_init(sof);
7874

7975
trace_point(TRACE_BOOT_SYS_POWER);
8076
pm_runtime_init();
8177

8278
/* init the platform */
83-
err = platform_init(&sof);
79+
err = platform_init(sof);
8480
if (err < 0)
8581
panic(SOF_IPC_PANIC_PLATFORM);
8682

8783
trace_point(TRACE_BOOT_PLATFORM);
8884

8985
/* should not return */
90-
err = do_task(&sof);
86+
err = do_task_master_core(sof);
87+
88+
return err;
89+
}
90+
91+
int slave_core_init(struct sof *sof)
92+
{
93+
int err;
94+
95+
/* init architecture */
96+
trace_point(TRACE_BOOT_ARCH);
97+
err = arch_init(sof);
98+
if (err < 0)
99+
panic(SOF_IPC_PANIC_ARCH);
100+
101+
trace_point(TRACE_BOOT_SYS_SCHED);
102+
scheduler_init(sof);
103+
104+
platform_interrupt_init();
105+
106+
/* initialize IDC mechanism */
107+
trace_point(TRACE_BOOT_PLATFORM_IDC);
108+
idc_init();
109+
110+
trace_point(TRACE_BOOT_PLATFORM);
111+
112+
/* should not return */
113+
err = do_task_slave_core(sof);
114+
115+
return err;
116+
}
117+
118+
int main(int argc, char *argv[])
119+
{
120+
int err;
121+
122+
trace_point(TRACE_BOOT_START);
123+
124+
/* setup context */
125+
sof.argc = argc;
126+
sof.argv = argv;
127+
128+
if (cpu_get_id() == PLATFORM_MASTER_CORE_ID)
129+
err = master_core_init(&sof);
130+
else
131+
err = slave_core_init(&sof);
91132

92133
/* should never get here */
93134
panic(SOF_IPC_PANIC_TASK);

src/tasks/audio.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <sof/interrupt.h>
3838
#include <sof/ipc.h>
3939
#include <sof/agent.h>
40+
#include <platform/idc.h>
4041
#include <platform/interrupt.h>
4142
#include <platform/shim.h>
4243
#include <sof/audio/pipeline.h>
@@ -51,7 +52,7 @@ struct audio_data {
5152
struct pipeline *p;
5253
};
5354

54-
int do_task(struct sof *sof)
55+
int do_task_master_core(struct sof *sof)
5556
{
5657
#ifdef STATIC_PIPE
5758
struct audio_data pdata;
@@ -64,10 +65,10 @@ int do_task(struct sof *sof)
6465
sys_comp_mux_init();
6566
sys_comp_switch_init();
6667
sys_comp_volume_init();
67-
sys_comp_src_init();
68-
sys_comp_tone_init();
69-
sys_comp_eq_iir_init();
70-
sys_comp_eq_fir_init();
68+
sys_comp_src_init();
69+
sys_comp_tone_init();
70+
sys_comp_eq_iir_init();
71+
sys_comp_eq_fir_init();
7172

7273
#if STATIC_PIPE
7374
/* init static pipeline */
@@ -80,7 +81,6 @@ int do_task(struct sof *sof)
8081

8182
/* main audio IPC processing loop */
8283
while (1) {
83-
8484
/* sleep until next IPC or DMA */
8585
sa_enter_idle(sof);
8686
wait_for_interrupt(0);
@@ -95,3 +95,21 @@ int do_task(struct sof *sof)
9595
/* something bad happened */
9696
return -EIO;
9797
}
98+
99+
int do_task_slave_core(struct sof *sof)
100+
{
101+
/* main audio IDC processing loop */
102+
while (1) {
103+
/* sleep until next IDC */
104+
wait_for_interrupt(0);
105+
106+
/* now process any IDC messages from master core */
107+
idc_process_msg_queue();
108+
109+
/* schedule any idle tasks */
110+
schedule();
111+
}
112+
113+
/* something bad happened */
114+
return -EIO;
115+
}

0 commit comments

Comments
 (0)