From nobody Mon Nov 10 17:55:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1557849717; cv=none; d=zoho.com; s=zohoarc; b=ALlkGM5GEXwaYuJY3BwhdTaQ00U5awVGN9mQEVJOVqhwLyYHhz6LxKOpsGJT1i4wdjq1M9TQTY5ydKPk/WR7x7aTFsh32cGkGfj/PrDuzcaXicIkZk8Ibg/K9HpR7MQFo6gfiUmwtLjNFhiAITQLTnOSmHGID9g2ArAzB0P5tnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557849717; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/LCsl9Du5Zb3JNBgOo6lbNCwiqPK/NFNHlF5WOB9yB0=; b=hPlGqE+2QdnIQgT5y79cOwoR4o2fWDarAX0leiYbRweWGVbDParYWJ7QdeLGQjd8W4zIx7VR21Pndz1YdUyd06reMmF01E/MTd//qhbJsR/L7e2MMudF1EaMErsgpUoDuPcZRvjRRv3mQii7jgKBkuLjHVfjvX4xjQfddNa/BN4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557849716949322.94886019173373; Tue, 14 May 2019 09:01:56 -0700 (PDT) Received: from localhost ([127.0.0.1]:50332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQZrv-0003YX-1M for importer@patchew.org; Tue, 14 May 2019 12:01:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQZjs-0004pZ-7K for qemu-devel@nongnu.org; Tue, 14 May 2019 11:53:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQZjr-0006Mf-49 for qemu-devel@nongnu.org; Tue, 14 May 2019 11:53:12 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQZjq-0006Ke-TG for qemu-devel@nongnu.org; Tue, 14 May 2019 11:53:11 -0400 Received: by mail-wr1-x444.google.com with SMTP id d12so19775965wrm.8 for ; Tue, 14 May 2019 08:53:10 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c9sm12598826wrv.62.2019.05.14.08.53.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 08:53:05 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E24A31FF87; Tue, 14 May 2019 16:53:02 +0100 (BST) 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=/LCsl9Du5Zb3JNBgOo6lbNCwiqPK/NFNHlF5WOB9yB0=; b=YDPRcD4TwCfdkuQSRZLeMT9Sr9bRTKQZSSJ2O7XBGrHXcItE5Dx5rpRmM/+KPbg8DT bLXx7ZJqb2CbMTPlriruH/MCzUIP9A5HntnKc/oxpREb4rwtTsuAPnBojlK5kh0Lro5a 8OYnZffrNOBSh/fr4sACpQNW5jVEuV0UDQe0bBcj9UUBiT93I0J6UDB7nt+dVW1sl77T WFhxQ5/77K3kb2IwLtj/vh20/cwP36kQ3qa2FlhCY3cxepF7s3dPd78rp5Jr5unM/E8A 0tz4npDuHpVSpBkz/UT8eRL2QGbIbUrTrcDtfpqpAvUNsu3zvCNW3cn4i6X5vQCDmbtx /gjA== 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=/LCsl9Du5Zb3JNBgOo6lbNCwiqPK/NFNHlF5WOB9yB0=; b=B5ZGN+9nubC4xZagEku+G1k9AvX5m1VM0kapepC68UEH9vdv44wV7FNkQARpWNvbQ7 6/ohILstA1BUxgITcHne5RrK2HGUHQ6eXhbZETJ3zl98j6xwQd6sLJiQLn0ibSaGo1/y ehGgcp7LJIMYkq4uAAO8g+UvoyO2tKwRor3DcHU4jqZD08FmjkOKvWgpQ+ePDxQ6htzv ZHawmyt67ifpMi6ha50R1O1AO7KihOKP0YiIbv+k5P0B/xwAaP/k7Ko6Kprtqe1bQlDp 6DRA0V13uDbpLOf5VlgljMOt69JyesQHQBtQ6LUId9yRIymhmQW+2UzqsdYkh6nb8N3J POmg== X-Gm-Message-State: APjAAAVTM0nPboQNsXKWXNgaX7v14bOjVC2enY2OTRT4xtiQFXKl8nW/ 3z0h46halO1NiWNleEPyzZMK7zJMS6c= X-Google-Smtp-Source: APXvYqzAykb8ticQn2EAU5voWaABgy754IDQf+PQ6AXO9cf1a6fgqRaGsut4zUBn7fn+hl2Ya8h/5w== X-Received: by 2002:a5d:4988:: with SMTP id r8mr11283170wrq.57.1557849189770; Tue, 14 May 2019 08:53:09 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 16:53:00 +0100 Message-Id: <20190514155301.16123-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190514155301.16123-1-alex.bennee@linaro.org> References: <20190514155301.16123-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [RFC PATCH 10/11] 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=20Benn=C3=A9e?= , Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9e Reviewed-by: Aleksandar Markovic --- target/mips/mips-semi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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" =20 typedef enum UHIOp { UHI_exit =3D 1, @@ -329,13 +330,12 @@ void helper_do_semihosting(CPUMIPSState *env) p2 =3D strstr(p, "%d"); if (p2) { int char_num =3D p2 - p; - char *buf =3D g_malloc(char_num + 1); - strncpy(buf, p, char_num); - buf[char_num] =3D '\0'; - gpr[2] =3D printf("%s%d%s", buf, (int)gpr[5], p2 + 2); - g_free(buf); + GString *s =3D g_string_new_len(p, char_num); + g_string_append_printf(s, "%d%s", (int)gpr[5], p2 + 2); + gpr[2] =3D qemu_semihosting_log_out(s->str, s->len); + g_string_free(s, true); } else { - gpr[2] =3D printf("%s", p); + gpr[2] =3D qemu_semihosting_log_out(p, strlen(p)); } FREE_TARGET_STRING(p, gpr[4]); break; --=20 2.20.1