Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / aarch64 / system / semiconsole.c
blob81324c639f70677466b30d7aca6ba4ef3377f2a9
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("x0") = type;
17 register uintptr_t a0 asm("x1") = arg0;
18 asm("hlt 0xf000"
19 : "=r" (t)
20 : "r" (t), "r" (a0));
22 return t;
25 int main(void)
27 char c;
29 ml_printf("Semihosting Console Test\n");
30 ml_printf("hit X to exit:");
32 do {
33 c = __semi_call(SYS_READC, 0);
34 __sys_outc(c);
35 } while (c != 'X');
37 return 0;