]> Git Repo - qemu.git/blame - linux-user/arm/semihost.c
Merge commit 'df84f17' into HEAD
[qemu.git] / linux-user / arm / semihost.c
CommitLineData
0dc07721
AB
1/*
2 * ARM Semihosting Console Support
3 *
4 * Copyright (c) 2019 Linaro Ltd
5 *
6 * Currently ARM is unique in having support for semihosting support
7 * in linux-user. So for now we implement the common console API but
8 * just for arm linux-user.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13#include "qemu/osdep.h"
14#include "cpu.h"
15#include "hw/semihosting/console.h"
16#include "qemu.h"
17
78e24848 18int qemu_semihosting_console_outs(CPUArchState *env, target_ulong addr)
0dc07721 19{
78e24848
AB
20 int len = target_strlen(addr);
21 void *s;
22 if (len < 0){
23 qemu_log_mask(LOG_GUEST_ERROR,
24 "%s: passed inaccessible address " TARGET_FMT_lx,
25 __func__, addr);
26 return 0;
27 }
28 s = lock_user(VERIFY_READ, addr, (long)(len + 1), 1);
29 g_assert(s); /* target_strlen has already verified this will work */
30 len = write(STDERR_FILENO, s, len);
0dc07721
AB
31 unlock_user(s, addr, 0);
32 return len;
33}
78e24848
AB
34
35void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr)
36{
37 char c;
38
39 if (get_user_u8(c, addr)) {
40 qemu_log_mask(LOG_GUEST_ERROR,
41 "%s: passed inaccessible address " TARGET_FMT_lx,
42 __func__, addr);
43 } else {
44 if (write(STDERR_FILENO, &c, 1) != 1) {
45 qemu_log_mask(LOG_UNIMP, "%s: unexpected write to stdout failure",
46 __func__);
47 }
48 }
49}
This page took 0.061812 seconds and 4 git commands to generate.