Merge tag 'pull-loongarch-20241016' of https://gitlab.com/gaosong/qemu into staging
[qemu/armbru.git] / tests / tcg / arm / system / semiconsole.c
blob206dd60eed7719cd5bb9013b57cca628bb99a8c6
1 /*
2 * Semihosting Console Test
4 * Copyright (c) 2019 Linaro Ltd
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
9 #include <stdint.h>
10 #include <minilib.h>
12 #define SYS_READC 0x7
14 uintptr_t __semi_call(uintptr_t type, uintptr_t arg0)
16 register uintptr_t t asm("r0") = type;
17 register uintptr_t a0 asm("r1") = arg0;
18 #ifdef __thumb__
19 # define SVC "svc 0xab"
20 #else
21 # define SVC "svc 0x123456"
22 #endif
23 asm(SVC : "=r" (t)
24 : "r" (t), "r" (a0));
26 return t;
29 int main(void)
31 char c;
33 ml_printf("Semihosting Console Test\n");
34 ml_printf("hit X to exit:");
36 do {
37 c = __semi_call(SYS_READC, 0);
38 __sys_outc(c);
39 } while (c != 'X');
41 return 0;