Skip to content

Commit 1ec2b1c

Browse files
andyrosskartben
authored andcommitted
soc/mediatek: Add back SOF-only entry point
I thought I was being clever letting the linker place the entry point arbitrarily (since the hardware can set it to any value). But it turns out that the upstream Linux SOF loader code is hard-wired to start the DSP only at the first byte of SRAM, always, no matter what entry point is listed in the rimage file. So until/unless this is fixed, we need to add a trampoline at the start of SRAM (and frustratingly that needs to be 1024 bytes long becuase of the alignment requirements of the vector table that follows it, sigh...) Signed-off-by: Andy Ross <[email protected]>
1 parent 00417b3 commit 1ec2b1c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

soc/mediatek/mt8xxx/linker.ld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ ENTRY(mtk_adsp_boot_entry)
2525

2626
SECTIONS {
2727

28+
/* kluged-in entry point for Linux loader */
29+
.sof_entry : {
30+
KEEP(*(.sof_entry.text))
31+
} > sram
32+
2833
#include <xtensa_vectors.ld>
2934
> sram
3035

soc/mediatek/mt8xxx/soc.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ __asm__(".align 4\n\t"
5050
" movi a1, " INIT_STACK "\n\t"
5151
" call4 c_boot\n\t");
5252

53+
/* Unfortunately the SOF kernel loader doesn't understand the boot
54+
* vector in the ELF/rimage file yet, so we still need a stub to get
55+
* actual audio firmware to load. Leave a stub in place that jumps to
56+
* our "real" vector. Note that this is frustratingly pessimal: the
57+
* kernel wants the entry point to be at the start of the SRAM region,
58+
* but (1) Xtensa can only load an immediate from addresses LOWER than
59+
* a L32R instruction, which we can't do and so need to jump across a
60+
* region to put one, and (2) the vector table that gets displaced has
61+
* a 1024 byte alignment requirement, forcing us to waste ~1011 bytes
62+
* needlessly.
63+
*/
64+
__asm__(".pushsection .sof_entry.text\n\t"
65+
" j 2f\n"
66+
".align 4\n\t"
67+
"1:\n\t"
68+
" .word mtk_adsp_boot_entry\n"
69+
"2:\n\t"
70+
" l32r a0, 1b\n\t"
71+
" jx a0\n\t"
72+
".popsection");
73+
5374
/* Initial MPU configuration, needed to enable caching */
5475
static void enable_mpu(void)
5576
{

0 commit comments

Comments
 (0)