From patchwork Mon Jan 7 16:31:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 154942 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3699445ljp; Mon, 7 Jan 2019 09:05:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN4NVVzkyhKdRm0nLoT7QYVYKdrA5DcUDfa3QtmB0h3WJzAJWSR6WpqJrp/gHQAptP6w6asK X-Received: by 2002:adf:e44c:: with SMTP id t12mr25354294wrm.89.1546880754620; Mon, 07 Jan 2019 09:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546880754; cv=none; d=google.com; s=arc-20160816; b=qTfvCRvQMA+M7h7NLkZ7WmBcQfaJYZxGoC16cQDIH/M8pQlyfF6m9X2EZtTa1uhU30 MyuspHAiT0JDEbcbeSRjcocdDS8/6x7PDzcPrSvU7YCJDr9G9lXfV039RgdYfdVTwFWB 8y7cOFS9ONSjBCLOcROh3mfWJTJLTBbgC5JxqC04pngltyUQWmGkdUccD5eBd5Kih2oM 2SRM7U+Swt77NZ5kFq1DDCoFK14Qm+2zyssXCodHGIRibsmtX26ggKvNdQ1G7wkKlMpW Ovt8HFQu9io+H+VOnDU/4eBE9BTKk+I2I8r+aNOoiTzMPygtHGj2wOmKbCJJ/OZX8yBd tLgA== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ve0B8kcL9xi8WPnq11WzGB1BxRiHUSFLk/M8udS3Wzw=; b=aSEoisaMDKDGT/tsbOAcG4iNnfU2m7iJgi/Le5BVQpLyYGSYhqg7Z+sVFVJ0nnRzbu TCrRRWZjiNI2JQjsSDIR2e+4B26eT3qRQMzw6OVg/sHV4b2S4D2XlsUIgpQFS5THHT0u b4H3NpRMzt+hi5bS1HLu5sTMkBvajZkC1scurDGUciR1a2IVoxWO96wztLSrnG1Tnl5R 2PsvJRhaWyvPLOHwBAxG0oaTih3TJy1UAOVRDkrZNYEWMvv6LM+jTeEbt8UE5WU6lkyO zdBQYM+hwXZvxMOqrZ8T+MMTUl68o8eOtLOZ1Uh28GXyG1uBXq1eJOCYUPpLMA5ynLBV am4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cNGnadji; 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 88si36143079wrn.355.2019.01.07.09.05.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 07 Jan 2019 09:05:54 -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=cNGnadji; 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]:50052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggYLZ-0006j5-IV for patch@linaro.org; Mon, 07 Jan 2019 12:05:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXoi-00056k-HT for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggXoe-0002Gm-UV for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:56 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:44265) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggXod-0002DU-2H for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:51 -0500 Received: by mail-wr1-x42b.google.com with SMTP id z5so1034408wrt.11 for ; Mon, 07 Jan 2019 08:31:50 -0800 (PST) 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=ve0B8kcL9xi8WPnq11WzGB1BxRiHUSFLk/M8udS3Wzw=; b=cNGnadjijC8aO/VlReFo7ujfxOJbSAaf1EuJi9jqY8qvYHF1ZpC74nbX5hFwft29hq INcvKJ2+01ATSQvRUGVE4sn3Q/22G2fst/Z/cxFL367s6yF6dTG/pRGUhhRMK5yoGPIR MeC/4t59j73t53zxhJRzliGrc2JbBs/6i4n6E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ve0B8kcL9xi8WPnq11WzGB1BxRiHUSFLk/M8udS3Wzw=; b=tr7Sn2j5M0J18c/glUHg204duHHT3JGTfm04NVWHFZgv2Dg6TrHtCnFnmyfN2hwTBp iYCUZLMOomivdlWZrfSiLHwQDCKLJhuMH2p46zb0naZVmv/X/A6BL0/Krbg+1L/O1frj mQhb2RdA5fIxD1v6pfcvD18gMdYekbmM38na9Sv5+uB1TTmlfu9TCoh6zLiC3fsJPgb/ 5VFYHknNa/GCcvK6eI2OY9ji5QDTHLYYs1r9NlwEIcnmr+hgCziYUgQo2XjjqlWYa5nr zsVqLs/b/1GEAiFfKWtecX2C0TBAEcTlgt/B4zd7t1HEI5p6mpIS/zUbTHEivRtYaiFb Ta0w== X-Gm-Message-State: AJcUukcFYhXWGjV4XM1T4rngcKNWWfV9rK29apd1M8Puc4TEUTmo1ct+ Wpb8l5Y6kxZAMpdXzBqZ/c4b6k+1WgX7Bw== X-Received: by 2002:a5d:4b01:: with SMTP id v1mr49734060wrq.5.1546878709459; Mon, 07 Jan 2019 08:31:49 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id j14sm46039759wrv.96.2019.01.07.08.31.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Jan 2019 08:31:48 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 7 Jan 2019 16:31:04 +0000 Message-Id: <20190107163117.16269-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107163117.16269-1-peter.maydell@linaro.org> References: <20190107163117.16269-1-peter.maydell@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::42b Subject: [Qemu-devel] [PULL 24/37] qtest: Add set_irq_in command to set IRQ/GPIO level 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Steffen Görtz Adds a new qtest command "set_irq_in" which allows to set qemu gpio lines to a given level. Based on https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02363.html which never got merged. Signed-off-by: Steffen Görtz Reviewed-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Reviewed-by: Laurent Vivier Signed-off-by: Stefan Hajnoczi Message-id: 20190103091119.9367-2-stefanha@redhat.com Originally-by: Matthew Ogilvie Reviewed-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Reviewed-by: Laurent Vivier Signed-off-by: Stefan Hajnoczi Signed-off-by: Peter Maydell --- tests/libqtest.h | 13 +++++++++++++ qtest.c | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/libqtest.c | 10 ++++++++++ 3 files changed, 66 insertions(+) -- 2.19.2 diff --git a/tests/libqtest.h b/tests/libqtest.h index 9758c51be61..7ea94139b0c 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -230,6 +230,19 @@ void qtest_irq_intercept_in(QTestState *s, const char *string); */ void qtest_irq_intercept_out(QTestState *s, const char *string); +/** + * qtest_set_irq_in: + * @s: QTestState instance to operate on. + * @string: QOM path of a device + * @name: IRQ name + * @irq: IRQ number + * @level: IRQ level + * + * Force given device/irq GPIO-in pin to the given level. + */ +void qtest_set_irq_in(QTestState *s, const char *string, const char *name, + int irq, int level); + /** * qtest_outb: * @s: #QTestState instance to operate on. diff --git a/qtest.c b/qtest.c index 69b9e9962b5..451696b5dae 100644 --- a/qtest.c +++ b/qtest.c @@ -164,6 +164,17 @@ static bool qtest_opened; * where NUM is an IRQ number. For the PC, interrupts can be intercepted * simply with "irq_intercept_in ioapic" (note that IRQ0 comes out with * NUM=0 even though it is remapped to GSI 2). + * + * Setting interrupt level: + * + * > set_irq_in QOM-PATH NAME NUM LEVEL + * < OK + * + * where NAME is the name of the irq/gpio list, NUM is an IRQ number and + * LEVEL is an signed integer IRQ level. + * + * Forcibly set the given interrupt pin to the given level. + * */ static int hex2nib(char ch) @@ -326,7 +337,39 @@ static void qtest_process_command(CharBackend *chr, gchar **words) irq_intercept_dev = dev; qtest_send_prefix(chr); qtest_send(chr, "OK\n"); + } else if (strcmp(words[0], "set_irq_in") == 0) { + DeviceState *dev; + qemu_irq irq; + char *name; + int ret; + int num; + int level; + g_assert(words[1] && words[2] && words[3] && words[4]); + + dev = DEVICE(object_resolve_path(words[1], NULL)); + if (!dev) { + qtest_send_prefix(chr); + qtest_send(chr, "FAIL Unknown device\n"); + return; + } + + if (strcmp(words[2], "unnamed-gpio-in") == 0) { + name = NULL; + } else { + name = words[2]; + } + + ret = qemu_strtoi(words[3], NULL, 0, &num); + g_assert(!ret); + ret = qemu_strtoi(words[4], NULL, 0, &level); + g_assert(!ret); + + irq = qdev_get_gpio_in_named(dev, name, num); + + qemu_set_irq(irq, level); + qtest_send_prefix(chr); + qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "outb") == 0 || strcmp(words[0], "outw") == 0 || strcmp(words[0], "outl") == 0) { diff --git a/tests/libqtest.c b/tests/libqtest.c index 1d75d3c9363..55750dd68de 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -753,6 +753,16 @@ void qtest_irq_intercept_in(QTestState *s, const char *qom_path) qtest_rsp(s, 0); } +void qtest_set_irq_in(QTestState *s, const char *qom_path, const char *name, + int num, int level) +{ + if (!name) { + name = "unnamed-gpio-in"; + } + qtest_sendf(s, "set_irq_in %s %s %d %d\n", qom_path, name, num, level); + qtest_rsp(s, 0); +} + static void qtest_out(QTestState *s, const char *cmd, uint16_t addr, uint32_t value) { qtest_sendf(s, "%s 0x%x 0x%x\n", cmd, addr, value);