From patchwork Thu May 23 10:25:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 164959 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1992109ili; Thu, 23 May 2019 03:33:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyk50k+TjpDy236jSHpEtSLikufGEKXBaR/OOb2tU2GlF+qrQWLr1qzqth5Zn/BHOMcbBV X-Received: by 2002:a50:e79b:: with SMTP id b27mr98092456edn.281.1558607612234; Thu, 23 May 2019 03:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558607612; cv=none; d=google.com; s=arc-20160816; b=0cVAYe6pm7gKaFPeH67ZJnK7JYcSTAHIghDlSHyxSCPP/Zt46EDeh/JNPkxWlmlHnh FFM35uWbHmU7E9UrnTBrrT/Lnsimyxn1/e13ndkSE3ZNJnw/IrbQAm16zChha/tNSFDm 5fsqxmni0ybtPdsG9YvnYaH+0kxuY1bIThobCwFmkA8ZAI5t7FRs9CIZA/cFoyGt6yQg 1x37frqtABsDBb7VjlNcMc8Sr+w+afFkwyRfrqK2vQLWTlBZ/1rBZied84ZkZk76Hpra k+A9XQiaKdqlh0AyeXBTCzmk03TmZNUMIC1lNFfiIjcfVehhCJMsvU4eFu5B6wyuRQKJ 9IEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=82m0nfi4dm1nYK1jjOZA1RHXA6lw0YusU8h2ijo5ck8=; b=AvGWJ3hGtX8sZS0HY72Mp0cyfp7KojrGR9CZxpMb0iT+HsjWTY0LSn3cNDpir3HwTT 45SHQeuwaVIaSia0OLvWqAVpazEJvyzCtSAer5o21Soo9B4IyX8rLyEBo/20/UVyYJPC Q3HsO77R8veCayhlcsFG+1eHPB5tN8kv7xIRSHY0YtU6K4xXSZVpyUiMdz3TF1xvPGsY lVTD8N4TAqnN8uVij1IiyeDW7wThGXA+4YuKJ47zEY2lI+1eyUVuAKo9Bg8la50CNq31 g03pltEKc8V614zuOn595xXd3hsvn/yvfYB9/rCh7hVypvSRgRMpN8vYD+lXpNoG6IKH SOcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iHcGHSBq; 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=fail (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 v16si3821386eju.197.2019.05.23.03.33.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 23 May 2019 03:33:32 -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=fail header.i=@linaro.org header.s=google header.b=iHcGHSBq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:33164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTl2R-00047g-7M for patch@linaro.org; Thu, 23 May 2019 06:33:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTkvK-0005ua-08 for qemu-devel@nongnu.org; Thu, 23 May 2019 06:26:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTkvA-0001K2-Ns for qemu-devel@nongnu.org; Thu, 23 May 2019 06:26:06 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:40060) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTkv4-0000w9-C9 for qemu-devel@nongnu.org; Thu, 23 May 2019 06:25:58 -0400 Received: by mail-wm1-x342.google.com with SMTP id 15so5186358wmg.5 for ; Thu, 23 May 2019 03:25:40 -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=82m0nfi4dm1nYK1jjOZA1RHXA6lw0YusU8h2ijo5ck8=; b=iHcGHSBqgqA03l7DRF5mjuOailwePJ57lDnjFJ+ptwz/w3bH7QNwot5Qglu74EeDl+ 4oOAKE+StzTeBR1TS8WfuefzaxfaypReMbgoYOmZ7E7NNqXk+MM6Mjeb9LWE4DKOBuBH p9B+wD7poJczrLxz7IC9NIRjmmUAnFTIHTEjuvOjZsDp+J6dq+NvOMW2Jn7QrL51giv5 dEON2ZzgkJb2+6eoRqK92BJYoQOlgM6hjO13C9lCFOuaOLMedamiJcfG+LL7HAwC/r95 Th8ql8jwfQyGpHdAoDpiQoRIWd3cnIObbGC8tjp4mOpq+yNsB6ryHhZ6pS7dkadHyoGQ zVrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=82m0nfi4dm1nYK1jjOZA1RHXA6lw0YusU8h2ijo5ck8=; b=HZbLGWLpa81Tc+o91WiaMblpKlSd6iGzVdTzWg2Cs3MBSo2J7tOzNPZPtotzY2mkej XZz+vqy/QWXhbb9wdVDvgqHoftpDM4PpYdCnqkkV0PyyvtFL+cOoP3vwEZ+OyR5DB2qA hZ0TzgwVIxDtGTAwU3rWtNMVhjBYE8u7YzyTQIxk3yhDTpA5+qPWvXO0NLpEZ93Dd57P saMrxTFI7jGLUQuiTaIwsDdKegn0h9NIwe4nEhkLZDpW6xEF2jZIIDqG+Bbaiy7j9Ivk LnsTXvpyxus6Ku7i+mYEgozbo/03ptmHzo/6ADV1MNNX1DBuG2vLnhZGHjO39n/xHQfq SNew== X-Gm-Message-State: APjAAAUClqe5/EJNpqi9oJNvolgzplhq/YfNHNNYv8fi1pwfvUGXHNne eiv0alggLBE3VhRswqGHTzw8IA== X-Received: by 2002:a7b:c844:: with SMTP id c4mr11196258wml.108.1558607139479; Thu, 23 May 2019 03:25:39 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b206sm10396597wmd.28.2019.05.23.03.25.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 May 2019 03:25:35 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5D0D51FF99; Thu, 23 May 2019 11:25:33 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 23 May 2019 11:25:14 +0100 Message-Id: <20190523102532.10486-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190523102532.10486-1-alex.bennee@linaro.org> References: <20190523102532.10486-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v2 10/28] target/mips: convert UHI_plog to use common semihosting code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aleksandar Rikalo , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Aleksandar Markovic Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than printing directly to stdout lets use our common semihosting code. There is one minor difference in that the output currently defaults to stderr instead of stdout however this can be controlled by connecting semihosting to a chardev. Signed-off-by: Alex Bennée Reviewed-by: Aleksandar Markovic --- target/mips/mips-semi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/target/mips/mips-semi.c b/target/mips/mips-semi.c index eac8374fb34..35bdfd7c77e 100644 --- a/target/mips/mips-semi.c +++ b/target/mips/mips-semi.c @@ -23,6 +23,7 @@ #include "exec/helper-proto.h" #include "exec/softmmu-semi.h" #include "hw/semihosting/semihost.h" +#include "hw/semihosting/console.h" typedef enum UHIOp { UHI_exit = 1, @@ -329,13 +330,12 @@ void helper_do_semihosting(CPUMIPSState *env) p2 = strstr(p, "%d"); if (p2) { int char_num = p2 - p; - char *buf = g_malloc(char_num + 1); - strncpy(buf, p, char_num); - buf[char_num] = '\0'; - gpr[2] = printf("%s%d%s", buf, (int)gpr[5], p2 + 2); - g_free(buf); + GString *s = g_string_new_len(p, char_num); + g_string_append_printf(s, "%d%s", (int)gpr[5], p2 + 2); + gpr[2] = qemu_semihosting_log_out(s->str, s->len); + g_string_free(s, true); } else { - gpr[2] = printf("%s", p); + gpr[2] = qemu_semihosting_log_out(p, strlen(p)); } FREE_TARGET_STRING(p, gpr[4]); break;