From patchwork Tue Jun 28 04:53:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585542 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp505341mab; Tue, 28 Jun 2022 00:22:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tKFv/2rg4xAWkKPZYU3ivhpXPqgLyNgp+tYfxasT20wKuV8ORWSFOYhZe6XMy7aJIBImt0 X-Received: by 2002:a05:6214:300d:b0:470:4530:79f1 with SMTP id ke13-20020a056214300d00b00470453079f1mr2358488qvb.121.1656400921680; Tue, 28 Jun 2022 00:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656400921; cv=none; d=google.com; s=arc-20160816; b=pFT+9QxjkJe4C64aXfM9N57CMJ/QkyF1FgMTZnJyWTrxoBU8jyRbpPS6FTOOotWXN3 bUnS8blFQ9u0X7J6b4DU1Bc65rKEGgeWLFfS6ZIWefdsOgvA2wsxk1/f/U3i5Gv9x1kf 4nSYf3nfxLcBqVoVrC2T00qiCCxCoFl6Lolm/v1YvHOIvNjXAcT2p7wEVOBSMsNrX+A9 sud60M9aCIdAq5gks6RggvAU5174ouCyxwiJGb5adpgAV7tY1hW+Ls9kY5o4ICENhlyL dI3kE/r1xEe6ja/RvBxJMj4JLkMFkypL5apWoDpx/cs57lolMHyOb4zjpqI1R49eglET Zp9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4guIB9WBX/ay757xxYogFh0D5rQcKO1Qw1OmBzJA6xE=; b=fLo5dam2iQDOlryqlWq/2frFR/Y3WSC4zjAjXxUslD2ZTKT8qH+XfUiZPlu0GldpMt WgKJ5fWdO5KuHqTpeNGnJIZIOLseKMpwdfE6yyy3mg3AOyeYFdKpwaEvJ3bNOI4SRraO Xm7OOQtcsZ863Vcd9t3IYJn8aCBHYChdsrNq//SrVDGXqCe68GDEXu7fSr5y9vkCWqr2 IAyshkK4Jib7PMlJM0WVzY0L4S71RpsswHPUZgqTLnD+By/qhWy+nNwJL67osSJpueM/ gn9Qx8+HvltVHvvuVBCPMqVzmW+Mq5T4wymOL5MBeuYIIZQ6GiZLU8HxUev6YWM8tpPJ 8XQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="yfKjKX/S"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jl7-20020ad45e87000000b004707a5335c1si7078608qvb.200.2022.06.28.00.22.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 00:22:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="yfKjKX/S"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o65Xt-0000Wb-7w for patch@linaro.org; Tue, 28 Jun 2022 03:22:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o63Jf-00022v-Te for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:59:14 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:35588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o63Je-0000XJ-Cd for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:59:11 -0400 Received: by mail-pf1-x42a.google.com with SMTP id x4so10975509pfq.2 for ; Mon, 27 Jun 2022 21:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4guIB9WBX/ay757xxYogFh0D5rQcKO1Qw1OmBzJA6xE=; b=yfKjKX/S2DdUpfHmMrARtImCXV/D7LCsXznW7ul5S6y1Gt4eO1MKURfhw4Gi7O/lu7 t/4Tv6qDMameV3Yc5mc8kUkaGHfMlalR0SnmFAirq9oz/kC2bCZxwa2WDSihyy/uCNDL U/pisHTm62ckyTM11VdRwocXUa7xYbGhOiKj+UPLeWm1cTteSoV4He+DmlUKbJumP6jw ydEMwYfY9u45LjYqv8ZwiX0ZbhiApbJKatVwevv+0e1luvKAKXKEwRluLeTh4/6pQtEy oOaB9ZJ866ZsCsDpJN7L75v3HOwE6KQhzq4FuP5NKkThrpdqiiNdydTRFGdRTV9LbSLn VOxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4guIB9WBX/ay757xxYogFh0D5rQcKO1Qw1OmBzJA6xE=; b=Pt0yPb95pOq/cp/xq1kwe3illHrxRyXClASfVkSbD/l1nlg20O/446mtKHHEPq3Agc V40lVrRNZ773pevR68peS4YQhOEBH5sYujKeMZFptzXFqUab+KXClNcdolsAgAWQhe8N 3CsMgOv7SYLLHUdeBBpCHcDNeAsYCVAl0xPoH4S+5aH4zmg8FLLh4WZDDjHxPQkyFoGU AyXwn6MSGdMi/5usQfST+FKMo2frGPS9V2FgDbCzZb26o7CHrAtnxz/rk+cZchUh1vKa xCJyvmlZmDudNphPr2iGehxmiILJWfWCIdHBCwuF/4PM9twXdQP/ecVUa1CpUcSuCPA5 o3aA== X-Gm-Message-State: AJIora8x0rgRLpw4cOVyxZe4cyMtHiL4ff+afPykVxDbUmfqxnyf2jFE v7XCB2ZR7dYTJfZNvCoSAiAQYdzEGzPQaQ== X-Received: by 2002:a05:6a00:2402:b0:4e1:46ca:68bd with SMTP id z2-20020a056a00240200b004e146ca68bdmr2767516pfh.70.1656392349181; Mon, 27 Jun 2022 21:59:09 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id y7-20020aa78f27000000b00522c0a75c39sm8259686pfr.196.2022.06.27.21.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:59:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Luc Michel Subject: [PULL 48/60] semihosting: Use console_in_gf for SYS_READC Date: Tue, 28 Jun 2022 10:23:51 +0530 Message-Id: <20220628045403.508716-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628045403.508716-1-richard.henderson@linaro.org> References: <20220628045403.508716-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Luc Michel Signed-off-by: Richard Henderson --- semihosting/arm-compat-semi.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index fdb143ace8..9d4d6d2812 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -302,6 +302,22 @@ common_semi_flen_fstat_cb(CPUState *cs, uint64_t ret, int err) common_semi_cb(cs, ret, err); } +static void +common_semi_readc_cb(CPUState *cs, uint64_t ret, int err) +{ + if (!err) { + CPUArchState *env G_GNUC_UNUSED = cs->env_ptr; + uint8_t ch; + + if (get_user_u8(ch, common_semi_stack_bottom(cs) - 1)) { + ret = -1, err = EFAULT; + } else { + ret = ch; + } + } + common_semi_cb(cs, ret, err); +} + #define SHFB_MAGIC_0 0x53 #define SHFB_MAGIC_1 0x48 #define SHFB_MAGIC_2 0x46 @@ -428,15 +444,8 @@ void do_common_semihosting(CPUState *cs) break; case TARGET_SYS_READC: - { - uint8_t ch; - int ret = qemu_semihosting_console_read(cs, &ch, 1); - if (ret == 1) { - common_semi_cb(cs, ch, 0); - } else { - common_semi_cb(cs, -1, EIO); - } - } + semihost_sys_read_gf(cs, common_semi_readc_cb, &console_in_gf, + common_semi_stack_bottom(cs) - 1, 1); break; case TARGET_SYS_ISERROR: