mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-22 11:13:07 +00:00
29c579a249
So far we used inline assembly to inject the actual instruction that triggers the semihosting service. While this sounds elegant, as it's really only about one instruction, it has some serious downsides: - We need some barriers in place to force the compiler to issue writes to a data structure before issuing the trap instruction. - We need to convince the compiler to actually fill the structures that we use pointers to. - We need a memory clobber to avoid the compiler caching the data in those structures, when semihosting writes data back. - We need register arguments to make sure the function ID and the pointer land in the right registers. This is all doable, but fragile and somewhat cumbersome. Since we now have a separate function in an extra file anyway, we can do away with all the magic and just write that in an actual assembly file. This is much more readable and robust. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Sean Anderson <sean.anderson@seco.com>
31 lines
486 B
ArmAsm
31 lines
486 B
ArmAsm
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* (C) 2022 Arm Ltd.
|
|
*/
|
|
|
|
#include <config.h>
|
|
#include <asm/macro.h>
|
|
#include <linux/linkage.h>
|
|
|
|
.pushsection .text.smh_trap, "ax"
|
|
/* long smh_trap(unsigned int sysnum, void *addr); */
|
|
ENTRY(smh_trap)
|
|
|
|
#if defined(CONFIG_ARM64)
|
|
hlt #0xf000
|
|
#elif defined(CONFIG_CPU_V7M)
|
|
bkpt #0xab
|
|
#elif defined(CONFIG_SYS_THUMB_BUILD)
|
|
svc #0xab
|
|
#else
|
|
svc #0x123456
|
|
#endif
|
|
|
|
#if defined(CONFIG_ARM64)
|
|
ret
|
|
#else
|
|
bx lr
|
|
#endif
|
|
|
|
ENDPROC(smh_trap)
|
|
.popsection
|