arm: smh: specify Thumb trap instruction
authorAndre Przywara <andre.przywara@arm.com>
Wed, 5 Oct 2022 16:38:47 +0000 (17:38 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 2 Nov 2022 17:31:40 +0000 (13:31 -0400)
commit30b315b48da38a704896f550771cdebf9d619413
tree0e1cdf0620dda047f57eff8b5a0dcf5bc1a5cdd4
parentcca41ed3d63f462ca044e0d2d30a34d4917fc6c5
arm: smh: specify Thumb trap instruction

The ARM semihosting interface uses different trap instructions for
different architectures and instruction sets. So far we were using
AArch64 and ARMv7-M, and had an untested v7-A entry. The latter does
not work when building for Thumb, as can be verified by using
qemu_arm_defconfig, then enabling SEMIHOSTING and SYS_THUMB_BUILD:
==========
{standard input}:35: Error: invalid swi expression
{standard input}:35: Error: value of 1193046 too large for field of 2 bytes at 0
==========

Fix this by providing the recommended instruction[1] for Thumb, and
using the ARM instruction only when not building for Thumb. This also
removes some comment, as QEMU for ARM allows to now test this case.
Also use the opportunity to clean up the inline assembly, and just define
the actual trap instruction inside #ifdef's, to improve readability.

[1] https://developer.arm.com/documentation/dui0471/g/Semihosting/The-semihosting-interface?lang=en

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
arch/arm/lib/semihosting.c