From patchwork Tue May 3 19:48:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568998 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp9798716map; Tue, 3 May 2022 13:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzAggcOiabWTpZSYflTJRPti/J6EwO4PSubJ7Yf3LsG2osRohRrDcKT0Yd5JFwMLZV6UQK X-Received: by 2002:a0c:8e0b:0:b0:435:1779:7b22 with SMTP id v11-20020a0c8e0b000000b0043517797b22mr15008222qvb.63.1651610079621; Tue, 03 May 2022 13:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651610079; cv=none; d=google.com; s=arc-20160816; b=bDAV5exmgUW42F6YajsqqmP+7rJoNx4S0dZvHEKdInF6eUl2RFlYKz0EjA6Xlv6Jqv 1KP2kJWIMV4bN8xDNglZ8T/bSlosP2WWKFiVRtyTSdTjWMBw6Pk9dCoSMBVDxH/W7ykq G2nHcQbJsw3pM7UPFtUdWH5uEJagN1CLJ4L8LtsRzbc8Zz+an3UaFg/vzpXMcnQqqV2E kJWqHsslX7IrEgMFBmwypZri+yZOaEuU/ClrHSX73RVT4RSDoCp6eH5mlNqo2/8ZoxIp 7a6BIAoMUFbGHzZut1ag1pGXlfJSVKVjXDUhHCeQL/uQ4VD8oqag2/ffMlQxaEMqhpdN +nNw== 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=Dm1voH/Tt8jCYAXhzkOQ+S+yNZKBVHidOVSYOEvZNcYuW9QhSYjPqeCsRVvLHMcGQH q8zAy7Vyz6PuG3HWG/i78JeBFwS8NJtjHMU7ztXcvWvuwHIcfJKJ5kClChU+DdDxg8Me FaWHf4BYlxNWQOsw7mlWin04bD6DsfbFX9I1162SCm9Lj+7uAPIALWMxMKwc0GQlNa0/ 1yw6wA7PR/vtDwhpzJ9WaHJh9c1LEIACJghuugg0GkdrIdaejCunP3+O+v6n+hyz8kcP S9l9CGUURawLRx/39guPLvKZBCzRZ/Cm8np1GfwIhzDY7SB1JoKbf+nWO8YwJinlUhRk F0NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="am4G/MPv"; 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 k8-20020a05622a03c800b002f37dcc3303si8291840qtx.602.2022.05.03.13.34.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 May 2022 13:34:39 -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="am4G/MPv"; 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]:54194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlzEF-0000oC-6l for patch@linaro.org; Tue, 03 May 2022 16:34:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlyWY-0002NN-1v for qemu-devel@nongnu.org; Tue, 03 May 2022 15:49:30 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:52883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlyWU-0003dI-RY for qemu-devel@nongnu.org; Tue, 03 May 2022 15:49:29 -0400 Received: by mail-pj1-x1034.google.com with SMTP id e24so16250405pjt.2 for ; Tue, 03 May 2022 12:49:25 -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=am4G/MPvBfaGx4cDAOFyEwqqXcKc6dzYNglM1D6b9dwH/PFw0amtqe/c9TTT3GVXYm agB86Bf4TNjVY5iBwZOLeCIuPL+lnVlYvHx/9P0SCpwAJmxnyj9cb2CsJf0CDeUrjMop 5IMAY3mvnERzDv3zsoGuW0EDgRqatjBFRuSe4U50vY3kJ+GROMBNDEJuRB46VEKSl3+2 kM81i4N9qcN10osIl9evCD4k4Gx62UAjw2gP5JMKRz2mdKLLFDukawwrzwwrCsNNnn7a p4RDY1NdF+ElJ+AlMGw/CXwIzkNly9/dtPb3ZveqGCxng/hChGKs7EcsyG8IIplJd9rO r89A== 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=3RZJisB/RNwCrys3dIWGVKaEptUkrImBvoAuiYBEP9XWR+7KHrmKgd1Gvt18QbDB/e c4zr4GPweR5qd0jsrt0yXcBQm7eLRUXAwAsSlnwh0CtnPoqLeslA7cQPx/2SRzxg/G6N q/U1dTGjF1HChM3pTU7YMkyiDtrgyZD3XNJKxPDBjQhw5w0dYka9OKUPiiyZwWZrovhj 0riS+njP2h4jCCfhVzYHWDdATn3A6EespH5ODxHe+whhz/PUvIRoEU+j/sG+pFTYZvu1 D1Pjwe/RbHha0Z8jWbHmkZkDQ8r+iZTIQGYBV+uj0pGGeJRYfrEC6kgH5epkv06PeV5G mh7w== X-Gm-Message-State: AOAM530mxbjE2pkTCtHKk27ZjiSnJJF0g085mt4V0wxZLFO63c1lqWbJ 1+zmNqAq9pKu5HeRKXIVxW0tkT8ZCxf/mA== X-Received: by 2002:a17:90a:8b91:b0:1be:db25:eecd with SMTP id z17-20020a17090a8b9100b001bedb25eecdmr6459833pjn.10.1651607364013; Tue, 03 May 2022 12:49:24 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id p11-20020a17090ad30b00b001cd4989fed3sm1712383pju.31.2022.05.03.12.49.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 12:49:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 39/74] semihosting: Create qemu_semihosting_console_write Date: Tue, 3 May 2022 12:48:08 -0700 Message-Id: <20220503194843.1379101-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503194843.1379101-1-richard.henderson@linaro.org> References: <20220503194843.1379101-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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 --- 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;