Create a global firmware context structure and pass this to each subsystem on initialisation. This allows components to share access to global DSP context.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/arch/xtensa/init.c | 2 +- src/include/reef/alloc.h | 4 +++- src/include/reef/init.h | 4 +++- src/include/reef/ipc.h | 4 +++- src/include/reef/notifier.h | 4 +++- src/include/reef/reef.h | 17 +++++++++++++++++ src/include/reef/task.h | 4 +++- src/init/init.c | 20 +++++++++++++------- src/ipc/ipc.c | 2 +- src/lib/alloc.c | 2 +- src/lib/notifier.c | 2 +- src/platform/baytrail/include/platform/platform.h | 4 +++- src/platform/baytrail/platform.c | 4 ++-- src/tasks/audio.c | 2 +- 14 files changed, 55 insertions(+), 20 deletions(-)
diff --git a/src/arch/xtensa/init.c b/src/arch/xtensa/init.c index edbc6c5..f904738 100644 --- a/src/arch/xtensa/init.c +++ b/src/arch/xtensa/init.c @@ -149,7 +149,7 @@ static void register_exceptions(void) }
/* do any architecture init here */ -int arch_init(void) +int arch_init(struct reef *reef) { register_exceptions(); return 0; diff --git a/src/include/reef/alloc.h b/src/include/reef/alloc.h index 209203f..d263052 100644 --- a/src/include/reef/alloc.h +++ b/src/include/reef/alloc.h @@ -36,6 +36,8 @@ #include <stdint.h> #include <reef/dma.h>
+struct reef; + /* Heap Memory Zones * * The heap has three different zones from where memory can be allocated :- @@ -87,5 +89,5 @@ int mm_pm_context_save(struct dma_sg_config *sg); int mm_pm_context_restore(struct dma_sg_config *sg);
/* heap initialisation */ -void init_heap(void); +void init_heap(struct reef *reef); #endif diff --git a/src/include/reef/init.h b/src/include/reef/init.h index d8544b2..c2eaf87 100644 --- a/src/include/reef/init.h +++ b/src/include/reef/init.h @@ -31,9 +31,11 @@ #ifndef __INCLUDE_INIT_H__ #define __INCLUDE_INIT_H__
+struct reef; + /* main firmware entry point - argc and argv not currently used */ int main(int argc, char *argv[]);
-int arch_init(void); +int arch_init(struct reef *reef);
#endif diff --git a/src/include/reef/ipc.h b/src/include/reef/ipc.h index 4b5e59e..8d4a422 100644 --- a/src/include/reef/ipc.h +++ b/src/include/reef/ipc.h @@ -38,6 +38,8 @@ #include <reef/audio/component.h> #include <reef/lock.h>
+struct reef; + #define trace_ipc(__e) trace_event(TRACE_CLASS_IPC, __e) #define tracev_ipc(__e) tracev_event(TRACE_CLASS_IPC, __e) #define trace_ipc_error(__e) trace_error(TRACE_CLASS_IPC, __e) @@ -136,7 +138,7 @@ struct ipc { #define ipc_get_dai_comp(id) \ (struct ipc_dai_dev *)ipc_get_comp(id)
-int ipc_init(void); +int ipc_init(struct reef *reef); int platform_ipc_init(struct ipc *ipc); void ipc_free(struct ipc *ipc);
diff --git a/src/include/reef/notifier.h b/src/include/reef/notifier.h index 2c04a95..1c42a60 100644 --- a/src/include/reef/notifier.h +++ b/src/include/reef/notifier.h @@ -34,6 +34,8 @@ #include <stdint.h> #include <reef/list.h>
+struct reef; + /* notifier general IDs */ #define NOTIFIER_ID_CPU_FREQ 0 #define NOTIFIER_ID_SSP_FREQ 1 @@ -50,6 +52,6 @@ void notifier_unregister(struct notifier *notifier);
void notifier_event(int id, int message, void *event_data);
-void init_system_notify(void); +void init_system_notify(struct reef *reef);
#endif diff --git a/src/include/reef/reef.h b/src/include/reef/reef.h index 84bbfc0..0cf8261 100644 --- a/src/include/reef/reef.h +++ b/src/include/reef/reef.h @@ -35,6 +35,9 @@ #include <stddef.h> #include <arch/reef.h>
+struct ipc; + +/* TODO: define for unsigned and short, byte */ #define MAX_INT 0xffffffff
/* use same syntax as Linux for simplicity */ @@ -55,4 +58,18 @@ void cmemcpy(void *dest, void *src, size_t size); cmemcpy(dest, src, size) #endif
+/* general firmware context */ +struct reef { + /* init data */ + int argc; + char **argv; + + /* ipc */ + struct ipc *ipc; + + /* private data */ + void *arch_private; + void *plat_private; +}; + #endif diff --git a/src/include/reef/task.h b/src/include/reef/task.h index dc51242..0158f3f 100644 --- a/src/include/reef/task.h +++ b/src/include/reef/task.h @@ -31,6 +31,8 @@ #ifndef __INCLUDE_TASK_H__ #define __INCLUDE_TASK_H__
-int do_task(void); +struct reef; + +int do_task(struct reef *reef);
#endif diff --git a/src/init/init.c b/src/init/init.c index 31d727e..029c20f 100644 --- a/src/init/init.c +++ b/src/init/init.c @@ -41,35 +41,41 @@ #include <reef/trace.h> #include <platform/platform.h>
+/* main firmware context */ +static struct reef reef; + int main(int argc, char *argv[]) { int err;
trace_point(TRACE_BOOT_START);
+ /* setup context */ + reef.argc = argc; + reef.argv = argv; + /* init architecture */ - err = arch_init(); + trace_point(TRACE_BOOT_ARCH); + err = arch_init(&reef); if (err < 0) panic(PANIC_ARCH);
- trace_point(TRACE_BOOT_ARCH); - /* initialise system services */ trace_point(TRACE_BOOT_SYS_HEAP); - init_heap(); - init_system_notify(); + init_heap(&reef);
trace_point(TRACE_BOOT_SYS_NOTE); + init_system_notify(&reef);
/* init the platform */ - err = platform_init(); + err = platform_init(&reef); if (err < 0) panic(PANIC_PLATFORM);
trace_point(TRACE_BOOT_PLATFORM);
/* should not return */ - err = do_task(); + err = do_task(&reef);
/* should never get here */ panic(PANIC_TASK); diff --git a/src/ipc/ipc.c b/src/ipc/ipc.c index edf3f58..0b7b40a 100644 --- a/src/ipc/ipc.c +++ b/src/ipc/ipc.c @@ -188,7 +188,7 @@ int ipc_comp_connect(uint32_t source_id, uint32_t sink_id, uint32_t buffer_id) icd_source->cd, icd_sink->cd, ibd->dev.cb); }
-int ipc_init(void) +int ipc_init(struct reef *reef) { /* init ipc data */ _ipc = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*_ipc)); diff --git a/src/lib/alloc.c b/src/lib/alloc.c index b77fbf8..86c2bc7 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -602,7 +602,7 @@ int mm_pm_context_restore(struct dma_sg_config *sg) }
/* initialise map */ -void init_heap(void) +void init_heap(struct reef *reef) { struct block_map *next_map, *current_map; int i; diff --git a/src/lib/notifier.c b/src/lib/notifier.c index d0f0a45..888473e 100644 --- a/src/lib/notifier.c +++ b/src/lib/notifier.c @@ -78,7 +78,7 @@ out: spin_unlock(&_notify.lock); }
-void init_system_notify(void) +void init_system_notify(struct reef *reef) { list_init(&_notify.list); spinlock_init(&_notify.lock); diff --git a/src/platform/baytrail/include/platform/platform.h b/src/platform/baytrail/include/platform/platform.h index 7df65b8..cd1e1d9 100644 --- a/src/platform/baytrail/include/platform/platform.h +++ b/src/platform/baytrail/include/platform/platform.h @@ -35,6 +35,8 @@ #include <platform/shim.h> #include <platform/interrupt.h>
+struct reef; + /* default static pipeline SSP port - not used for dynamic pipes */ #define PLATFORM_SSP_PORT 2
@@ -107,6 +109,6 @@
int platform_boot_complete(uint32_t boot_message);
-int platform_init(void); +int platform_init(struct reef *reef);
#endif diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index ed7f108..eb28958 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -133,7 +133,7 @@ static struct timer platform_ext_timer = { .irq = IRQ_NUM_EXT_TIMER, };
-int platform_init(void) +int platform_init(struct reef *reef) { #if defined CONFIG_BAYTRAIL struct dma *dmac0, *dmac1; @@ -185,7 +185,7 @@ int platform_init(void)
/* initialise the host IPC mechanisms */ trace_point(TRACE_BOOT_PLATFORM_IPC); - ipc_init(); + ipc_init(reef);
/* init DMACs */ trace_point(TRACE_BOOT_PLATFORM_DMA); diff --git a/src/tasks/audio.c b/src/tasks/audio.c index 2de1a82..3cdaea4 100644 --- a/src/tasks/audio.c +++ b/src/tasks/audio.c @@ -50,7 +50,7 @@ struct audio_data { struct pipeline *p; };
-int do_task(void) +int do_task(struct reef *reef) { struct audio_data pdata;