From patchwork Tue Jun 7 20:45:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579434 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5578522max; Tue, 7 Jun 2022 15:44:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsduej6JtOHS2Qu77x9drvsenI5RSZlAj9in1MkzJo0au72ejdxI4gMADVAS8AGeKjDwSq X-Received: by 2002:a05:6214:2aa4:b0:46b:9672:e4cc with SMTP id js4-20020a0562142aa400b0046b9672e4ccmr10422436qvb.20.1654641877399; Tue, 07 Jun 2022 15:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654641877; cv=none; d=google.com; s=arc-20160816; b=LSSThkud8EbQh5KhfVC9OKwd0S0sv2LthYj8SYVee8Z0+P3vqflEVmIUyFRzKS2qD3 BugAvJBEoh6C1c3AGEaogPWd+b/JLVe1QYvywF+BynTxo0oS0p7c9ghBO51AtNMAgfM+ S0sg9NdM+1kMThAlw8NGUD1RtCEOFS3Pud2JAyFYt0A9lT91JmG2PlSTkjWcC2jGBdei NRq3ObbKS1uaYA2xWB/8rPgtOUR0am343R+K8ygRcy5fEf7+cdtn4t18TbLkviuACtdP Wbh0ViVwmV46Ct8Upltg78pK3qIsF5Yj8w28E8XEFXbiOgwJtydbM2omQ04Rfw7K+rWT Ltlg== 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:to:from :dkim-signature; bh=U2oK2ipOEqoaAfOulrRTtOQB2zK3TVTPXCClS/WGFgs=; b=x4Qp4Lo/1laMNpKcwGcdNAoyuVzR42FRQoFp1H74H1gYs81qHiqSFUYmAdL1Ka2DZg tsMtQQK5DLeJub1/Z45qG+DOarrOeXdoZZkSzF0G4AETPnv4igQKocbHepjg/Qk7ciGX Z4yv4SEZyVVXWSr50pM9u06Nw6TNHSTdvLABmTi1rrIapkGYSvGdLVH5btmaLulIYKym 5lbJPYJ8mgMF8A0wlTfXNTkUhlET8G4l1hyGzZDW8KrdiqC/+892dwX4aqVhP/yupcV+ 2rN10j8PS7zNOlcf4HEXKFRKtxZPvDJ912C1RPq1y0Qm2UEUrKM8MlRZ2W3W7JAlNHlh JW5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F0BOKFec; 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 o17-20020a05622a139100b00304eacb2c87si4748559qtk.769.2022.06.07.15.44.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 15:44:37 -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=F0BOKFec; 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]:60486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyhwC-0008BC-VR for patch@linaro.org; Tue, 07 Jun 2022 18:44:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyg95-0005hI-U5 for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:49:47 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:38714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyg90-0001ou-5o for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:49:45 -0400 Received: by mail-pg1-x535.google.com with SMTP id 123so6623311pgb.5 for ; Tue, 07 Jun 2022 13:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=U2oK2ipOEqoaAfOulrRTtOQB2zK3TVTPXCClS/WGFgs=; b=F0BOKFecdt+2QKnW2z307Udrhov0h9WFL3JJonmPhgnMa4lhU8tFTKBmUr2t2b0UIp ePi4F2pFvomjCLLkYd91SS9zaQUI3+GgLIUqYuNbofcmkldbKKhcvQ22fPRChOGtiMWd usZM+OKDhLMQ2S3d3wEu7B/6Rp7mvsW8sTSd/TY8JtkOp8tjZWrvgvsXC10jPS4hFlj9 Y+xxoaa53bHEGaFqFXUDx4RJNt8qO98N4Alpy9dXllHb341f4Z2zKQHd/EsCQ62D2gK2 Ysui85VtVnMi0oE8E/nTJe52NZUOQ3OqW3lsqhoseGwlVTmsUq8+2YZkB8p2kRYEqgzP Pw7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U2oK2ipOEqoaAfOulrRTtOQB2zK3TVTPXCClS/WGFgs=; b=UTCYwMpCLuGxRqE0XslEcWXj6bIKLx3rGpu47O1IUFgTpvgm4MSQDHjyK5M94g5mSd ZYyEvnfN7FJXY+1JyNmOQZTAk3vG+zxYkkeMr394qpR2J2+RCbtnkfWk2AnYLi/lpPSQ BDKxqdBCYot5BXD7vqFeRhHXILt0f0XB98VD23XNpMoijvoIcTSVZRwoCMPqmsdCW73t jJeGeSovGbpU8kstrqDTvKN23rIxMwxVWVcA6ra/OFNgv9d8VqLRsrua4jpnvMnu/yFC /5K8VGIhFw+d5tYNVHqBbyrsbSrMCjKbie2bTdqEz9twvFUbBRTvTs1hy/w7pQqeF8he EUBg== X-Gm-Message-State: AOAM532RnEF7NV/w5uv/6fjVtn6lKURRwnHxxwltT1/Y3FGRzl/peTdP ECZ4YGqrsA0cICGr6q5jtEJWR8tooHKTlg== X-Received: by 2002:a62:e116:0:b0:51b:c452:47e6 with SMTP id q22-20020a62e116000000b0051bc45247e6mr30680011pfh.25.1654634979605; Tue, 07 Jun 2022 13:49:39 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3cf2:c634:5b19:25f6]) by smtp.gmail.com with ESMTPSA id 128-20020a620686000000b00518b4cfbbe0sm13152327pfg.203.2022.06.07.13.49.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:49:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 45/53] semihosting: Create qemu_semihosting_console_write Date: Tue, 7 Jun 2022 13:45:49 -0700 Message-Id: <20220607204557.658541-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220607204557.658541-1-richard.henderson@linaro.org> References: <20220607204557.658541-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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" Will replace qemu_semihosting_console_{outs,outc}, but we need more plumbing first. Signed-off-by: Richard Henderson Reviewed-by: Luc Michel --- include/semihosting/console.h | 12 ++++++++++++ linux-user/semihost.c | 5 +++++ semihosting/console.c | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/include/semihosting/console.h b/include/semihosting/console.h index 39dbf1b062..6994f23c82 100644 --- a/include/semihosting/console.h +++ b/include/semihosting/console.h @@ -54,6 +54,18 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c); */ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len); +/** + * qemu_semihosting_console_write: + * @buf: host buffer + * @len: buffer size + * + * Write len bytes from buf to the debug console. + * + * Returns: number of bytes written -- this should only ever be short + * on some sort of i/o error. + */ +int qemu_semihosting_console_write(void *buf, int len); + /** * qemu_semihosting_log_out: * @s: pointer to string diff --git a/linux-user/semihost.c b/linux-user/semihost.c index 2029fb674c..871edf993a 100644 --- a/linux-user/semihost.c +++ b/linux-user/semihost.c @@ -76,3 +76,8 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len) return ret; } + +int qemu_semihosting_console_write(void *buf, int len) +{ + return fwrite(buf, 1, len, stderr); +} diff --git a/semihosting/console.c b/semihosting/console.c index 4088192842..b6a342744d 100644 --- a/semihosting/console.c +++ b/semihosting/console.c @@ -169,6 +169,15 @@ int qemu_semihosting_console_read(CPUState *cs, void *buf, int len) return ret; } +int qemu_semihosting_console_write(void *buf, int len) +{ + if (console.chr) { + return qemu_chr_write_all(console.chr, (uint8_t *)buf, len); + } else { + return fwrite(buf, 1, len, stderr); + } +} + void qemu_semihosting_console_init(Chardev *chr) { console.chr = chr;