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 <andyross@google.com>
This commit is contained in:
Andy Ross 2024-11-18 17:43:06 -08:00 committed by Benjamin Cabé
commit 1ec2b1c68f
2 changed files with 26 additions and 0 deletions

View file

@ -25,6 +25,11 @@ ENTRY(mtk_adsp_boot_entry)
SECTIONS {
/* kluged-in entry point for Linux loader */
.sof_entry : {
KEEP(*(.sof_entry.text))
} > sram
#include <xtensa_vectors.ld>
> sram

View file

@ -50,6 +50,27 @@ __asm__(".align 4\n\t"
" movi a1, " INIT_STACK "\n\t"
" call4 c_boot\n\t");
/* Unfortunately the SOF kernel loader doesn't understand the boot
* vector in the ELF/rimage file yet, so we still need a stub to get
* actual audio firmware to load. Leave a stub in place that jumps to
* our "real" vector. Note that this is frustratingly pessimal: the
* kernel wants the entry point to be at the start of the SRAM region,
* but (1) Xtensa can only load an immediate from addresses LOWER than
* a L32R instruction, which we can't do and so need to jump across a
* region to put one, and (2) the vector table that gets displaced has
* a 1024 byte alignment requirement, forcing us to waste ~1011 bytes
* needlessly.
*/
__asm__(".pushsection .sof_entry.text\n\t"
" j 2f\n"
".align 4\n\t"
"1:\n\t"
" .word mtk_adsp_boot_entry\n"
"2:\n\t"
" l32r a0, 1b\n\t"
" jx a0\n\t"
".popsection");
/* Initial MPU configuration, needed to enable caching */
static void enable_mpu(void)
{