Skip to content

Commit 6ef5b7b

Browse files
committed
readme: add some highlevel detail around the boot flow.
Describe the boot flow and manifest. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent a32d983 commit 6ef5b7b

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

src/init/README.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# DSP Initialization (`src/init`)
2+
3+
The `src/init` directory contains the generic digital signal processor (DSP) initialization code and firmware metadata structures for Sound Open Firmware (SOF). It acts as the bridge between the underlying RTOS (Zephyr) boot phase and the SOF-specific task scheduling and processing pipelines.
4+
5+
## Architecture and Boot Flow
6+
7+
The firmware initialization architecture relies on the Zephyr RTOS boot sequence. Zephyr handles the very early hardware setup and kernel initialization before invoking SOF-specific routines via Zephyr's `SYS_INIT` macros.
8+
9+
### Primary Core Boot Sequence
10+
11+
The primary entry point for SOF system initialization is `sof_init()`, registered to run at Zephyr's `POST_KERNEL` initialization level. This ensures basic OS primitives (like memory allocators and threads) are available before SOF starts.
12+
13+
`sof_init()` delegates to `primary_core_init()`, which executes the following sequence:
14+
15+
```mermaid
16+
sequenceDiagram
17+
participant Zephyr as Zephyr RTOS
18+
participant sof_init as sof_init (src/init.c)
19+
participant pci as primary_core_init
20+
participant trace as trace_init
21+
participant notify as init_system_notify
22+
participant pm as pm_runtime_init
23+
participant platform as platform_init
24+
participant ams as ams_init
25+
participant mbox as mailbox (IPC4)
26+
participant task as task_main_start
27+
28+
Zephyr->>sof_init: SYS_INIT (POST_KERNEL)
29+
sof_init->>pci: Initialize Primary Core Context
30+
31+
pci->>trace: Setup DMA Tracing & Logging
32+
pci->>notify: Setup System Notifiers
33+
pci->>pm: Initialize Runtime Power Management
34+
35+
pci->>platform: Platform-Specific HW Config
36+
note right of platform: e.g., interrupts, IPC windows (Intel, i.MX)
37+
38+
pci->>ams: Init Asynchronous Messaging Service
39+
40+
pci->>mbox: Set Firmware Registers ABI Version
41+
42+
pci->>task: Start SOF Main Processing Task Loop
43+
```
44+
45+
1. **Context Initialization**: Sets up the global `struct sof` context.
46+
2. **Logging and Tracing**: Initializes Zephyr's logging timestamps and SOF's DMA trace infrastructure (`trace_init()`), printing the firmware version and ABI banner.
47+
3. **System Subsystems**:
48+
- Initializes the system notifier (`init_system_notify()`) for inter-component messaging.
49+
- Sets up runtime power management (`pm_runtime_init()`).
50+
4. **Platform-Specific Initialization**: Calls `platform_init()` to allow the specific hardware platform (e.g., Intel cAVS, IMX) to configure its hardware IPs, interrupts, and IPC mailbox memory windows.
51+
5. **Architectural Handoff**: For IPC4, it sets the Firmware Registers ABI version in the mailbox. It may also unpack boot manifests if configured.
52+
6. **Task Scheduler**: Finally, it calls `task_main_start()` to kick off the main SOF processing task loop.
53+
54+
### Secondary Core Boot Sequence
55+
56+
For multi-core DSP platforms, secondary cores execute `secondary_core_init()`:
57+
58+
```mermaid
59+
sequenceDiagram
60+
participant ZephyrN as Zephyr RTOS (Core N)
61+
participant sci as secondary_core_init
62+
participant check as check_restore
63+
participant notify as init_system_notify
64+
participant ll as scheduler_init_ll
65+
participant dp as scheduler_dp_init
66+
participant idc as idc_init
67+
68+
ZephyrN->>sci: Core Wake/Boot
69+
sci->>check: Cold boot or power restore?
70+
71+
alt is Power Restore (e.g. D0ix wake)
72+
sci->>sci: secondary_core_restore()<br>(Skip full init)
73+
else is Cold Boot
74+
sci->>notify: Setup Local Core Notifiers
75+
76+
sci->>ll: Init Low-Latency (LL) Timer Domain
77+
sci->>ll: Init LL DMA Domain (if applicable)
78+
sci->>dp: Init Data Processing (DP) Scheduler
79+
80+
sci->>idc: Init Inter-Domain Communication (IDC)
81+
end
82+
```
83+
84+
1. **Power State Checking**: It checks if the core is cold booting or waking up from a low-power restore state (e.g., D0ix) via `check_restore()`. If returning from power off, it restores state without re-allocating core structures.
85+
2. **Local Subsystem Setup**: Sets up system notifiers for the local core.
86+
3. **Scheduler Setup**: Initializes the Low-Latency (LL) and Data Processing (DP) schedulers on the secondary core.
87+
4. **Inter-Core Communication**: Initializes the Inter-Domain Communication (IDC) mechanism (`idc_init()`), allowing cross-core messaging.
88+
89+
### Firmware Extended Manifest (`ext_manifest.c`)
90+
91+
This directory also provides the extended manifest implementation. The manifest consists of structured metadata embedded into the `.fw_metadata` section of the firmware binary.
92+
93+
```mermaid
94+
classDiagram
95+
direction LR
96+
97+
class fw_metadata {
98+
<<Section>>
99+
+ext_man_fw_ver
100+
+ext_man_cc_ver
101+
+ext_man_probe
102+
+ext_man_dbg_info
103+
+ext_man_config
104+
}
105+
106+
class ext_man_elem_header {
107+
+uint32_t type
108+
+uint32_t elem_size
109+
}
110+
111+
class ext_man_fw_version {
112+
+ext_man_elem_header hdr
113+
+sof_ipc_fw_version version
114+
+uint32_t flags
115+
}
116+
117+
class ext_man_cc_version {
118+
+ext_man_elem_header hdr
119+
+sof_ipc_cc_version cc_version
120+
}
121+
122+
class ext_man_probe_support {
123+
+ext_man_elem_header hdr
124+
+sof_ipc_probe_support probe
125+
}
126+
127+
class ext_man_dbg_abi {
128+
+ext_man_elem_header hdr
129+
+sof_ipc_user_abi_version dbg_abi
130+
}
131+
132+
class ext_man_config_data {
133+
+ext_man_elem_header hdr
134+
+config_elem elems[]
135+
}
136+
137+
fw_metadata *-- ext_man_fw_version
138+
fw_metadata *-- ext_man_cc_version
139+
fw_metadata *-- ext_man_probe_support
140+
fw_metadata *-- ext_man_dbg_abi
141+
fw_metadata *-- ext_man_config_data
142+
143+
ext_man_fw_version *-- ext_man_elem_header
144+
ext_man_cc_version *-- ext_man_elem_header
145+
ext_man_probe_support *-- ext_man_elem_header
146+
ext_man_dbg_abi *-- ext_man_elem_header
147+
ext_man_config_data *-- ext_man_elem_header
148+
```
149+
150+
When the host OS (e.g., Linux SOF driver) parses the firmware binary before loading it, it reads these manifest structures to discover firmware capabilities dynamically. The manifest includes:
151+
152+
- **Firmware Version**: Major, minor, micro, tag, and build hashes (`ext_man_fw_ver`).
153+
- **Compiler Version**: Details of the toolchain used to compile the firmware (`ext_man_cc_ver`).
154+
- **Probe Info**: Extraction probe configurations and limits (`ext_man_probe`).
155+
- **Debug ABI**: Supported debugger ABI versions (`ext_man_dbg_info`).
156+
- **Configuration Dictionary**: Compile-time enabled features and sizing parameters (e.g., `SOF_IPC_MSG_MAX_SIZE`).

0 commit comments

Comments
 (0)