From patchwork Fri Dec 20 13:22:46 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: 182269 Delivered-To: patch@linaro.org Received: by 2002:a92:1f98:0:0:0:0:0 with SMTP id f24csp524792ilf; Fri, 20 Dec 2019 05:23:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxV2t1wqQtHfPnR8+kAXsvo6ilKJAPmdoemtzzWRSPhdOac6HViahujhAXHol0hnGmg7Tbd X-Received: by 2002:a05:6830:3054:: with SMTP id p20mr14639430otr.121.1576848220802; Fri, 20 Dec 2019 05:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576848220; cv=none; d=google.com; s=arc-20160816; b=p/CbW7J6nxb1eCGsgOUCzK0GG+zkrRSp5ACucvz4owxIBCglersxzOXBMzHY2vi4Lv p08wjDYOSyDunJYc2vph4Z7zZgVRrIZgIwLQKR7KLhnw1Pg6UohbZS1sVpZ7eAgG0qqZ w8Us5CzgaTy1btpe8jbS6LxCJyMeDTkm6IZQhy7PukxW9IbxQ5J+QZik/3+wAaTUQ9Ds gqMPwN5NLp3HhW7XwZ1QHKrWU+SSykDa9/sbLbbPaUn5bDbPlXUnEP4F4vgofnrwlBrd FH17tsQyRdT6WVnXXJKi1XsBZ2s3ZDh6Ii40cjsdIWZUjmhObJGscs+hy60qpSYPxat/ T9Ig== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=06XcrWFNlcIoXvMNfQG79LGFIvgNsdfFUwprXyUXHHk=; b=W10H2EfSG3Gc2Q0V+KPWpP7zmde1ijwb/gs0Sf3vsOzaF1x6QX9FdgyayFDgC6oeE6 K4KQZeyPr38FcAnfkUB8MNIY9QL/m5W1kDklBx4g9ovrrpCHdHG2c5SMAR70F0IH+7NV FrQiPAkESju1TkOBbLGU6KbAoXhMBkbHCb3PHbFXoqVjjzehCCeESr5hG63lbqcCr7GO fsIVw13J/Rrqq4AyyWZe8BVn0z/0E9bVAv3BOHvLLpT9LQbHgDrAGeYob1shnbafOmeZ /Bpp4M/A0TwP9SW670i82UAkdm9aC4Fp3/10Te1LfFCOa60EbUKGBoO3PH3KJE9Ye8j2 rqag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BJZ6TIXh; 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 b17si3292839otl.320.2019.12.20.05.23.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Dec 2019 05:23:40 -0800 (PST) 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=BJZ6TIXh; 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 ([::1]:55386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiIFn-0008PB-Oo for patch@linaro.org; Fri, 20 Dec 2019 08:23:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43245) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiIF8-0007aP-O4 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 08:22:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiIF7-0005jj-EP for qemu-devel@nongnu.org; Fri, 20 Dec 2019 08:22:58 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:51079) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiIF6-0005fe-Ta for qemu-devel@nongnu.org; Fri, 20 Dec 2019 08:22:57 -0500 Received: by mail-wm1-x332.google.com with SMTP id a5so8924090wmb.0 for ; Fri, 20 Dec 2019 05:22:56 -0800 (PST) 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=06XcrWFNlcIoXvMNfQG79LGFIvgNsdfFUwprXyUXHHk=; b=BJZ6TIXhZiMuci54F//kmtNJyI9a8Qfq7aXKUYE2HiTdFLJ5SQyge6LGDKSo76ka/I +gyflGd0LltpF4bcNJ4YAAOcliYbDN+JytvtbNFy/MlcfhgQ+g0f+yLYzqwdH7YWinC8 1sqN3hJ6MmWWgP5OKItYdamq8eOq2MhUIttW5x9yJ8QEIwqxGbHOWnj9jJIE/vugj93+ fWW7BqSSYgfu62Ube+TKCr2LnsdICrIUypUOsCX05j9XptDJtn74NKGko+fY5Q500lvd Ar7BP5ZeTtIc5aHdnh18+0Jx6SGWMfT2VVoSc4CNjzAlMFpHfVYtVA5Pl6rAwRODJ1A/ mtjQ== 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=06XcrWFNlcIoXvMNfQG79LGFIvgNsdfFUwprXyUXHHk=; b=KomLBhV0X+AuqZqyjx4Okm9rAPe8Yajq5LdGTRHZ3T8KN1gHauzc9EYZGyC/gH0sn/ dFrMZNuqHMYdZ8oE6Ju5BQRIF5cczVCb2iUAn27LrVzs3/Xvfd/2PbX6oEVayt6nFzR+ lJNtNHpFThyP2X1yRmrS7Hy6V3SPFb4QfJeQonMDT1/gEarxFPWF4DRRjTzsowkpGsnP 61vqvrL2SCDY2jBteEBG80+2TDw/FWd2vB92CTywaZma40Ff+lL8OVe5HaSaNRVuWl3P c9dXAo6aeJhXM0YXxIQkuU+7qeffErfwObRs6mC4Kx3W3xckZ0/SLfnf+YjMCGwiWcAh P2Yw== X-Gm-Message-State: APjAAAWuB3afo2LgWg7Jvk4ac4IoJ6kxfkCBVXlEYnJMBwU5NtJ5gSGN s8aw2AR9w5NWgE7y2x4rZlW6fA== X-Received: by 2002:a7b:c001:: with SMTP id c1mr16623663wmb.96.1576848175612; Fri, 20 Dec 2019 05:22:55 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x132sm13756583wmg.0.2019.12.20.05.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 05:22:53 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 259591FF92; Fri, 20 Dec 2019 13:22:47 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 5/5] tests/tcg: add user version of dumb-as-bricks semiconsole test Date: Fri, 20 Dec 2019 13:22:46 +0000 Message-Id: <20191220132246.6759-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220132246.6759-1-alex.bennee@linaro.org> References: <20191220132246.6759-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::332 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , keithp@keithp.com, "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There are linux-user users of semihosting so we'd better check things work for them as well. Signed-off-by: Alex Bennée --- tests/tcg/arm/semiconsole.c | 47 +++++++++++++++++++++++++++++++++++ tests/tcg/arm/Makefile.target | 7 ++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/tcg/arm/semiconsole.c -- 2.20.1 diff --git a/tests/tcg/arm/semiconsole.c b/tests/tcg/arm/semiconsole.c new file mode 100644 index 00000000000..cc9266b87df --- /dev/null +++ b/tests/tcg/arm/semiconsole.c @@ -0,0 +1,47 @@ +/* + * linux-user semihosting console + * + * Copyright (c) 2019 + * Written by Alex Bennée + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include +#include + +#define SYS_READC 0x7 + +uintptr_t __semi_call(uintptr_t type, uintptr_t arg0) +{ +#if defined(__arm__) + register uintptr_t t asm("r0") = type; + register uintptr_t a0 asm("r1") = arg0; + asm("svc 0xab" + : "=r" (t) + : "r" (t), "r" (a0)); +#else + register uintptr_t t asm("x0") = type; + register uintptr_t a0 asm("x1") = arg0; + asm("hlt 0xf000" + : "=r" (t) + : "r" (t), "r" (a0)); +#endif + + return t; +} + +int main(void) +{ + char c; + + printf("Semihosting Console Test\n"); + printf("hit X to exit:"); + + do { + c = __semi_call(SYS_READC, 0); + printf("got '%c'\n", c); + } while (c != 'X'); + + return 0; +} diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 0765f37ff04..997e6e78ed9 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -40,6 +40,13 @@ run-plugin-semihosting-with-%: $(call strip-plugin,$<) 2> $<.err, \ "$< on $(TARGET_NAME) with $*") +ARM_TESTS += semiconsole +run-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") + +run-semiconsole-with-%: + $(call skip-test, $<, "MANUAL ONLY") + TESTS += $(ARM_TESTS) # On ARM Linux only supports 4k pages