From patchwork Wed Jul 18 10:48:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 10532055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7FF86600F4 for ; Wed, 18 Jul 2018 10:49:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CDC428E19 for ; Wed, 18 Jul 2018 10:49:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70E2028DEE; Wed, 18 Jul 2018 10:49:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E9D7A28DEE for ; Wed, 18 Jul 2018 10:49:47 +0000 (UTC) Received: from localhost ([::1]:35861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffk1h-0004GT-CQ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Jul 2018 06:49:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffk0l-0003Li-Sp for qemu-devel@nongnu.org; Wed, 18 Jul 2018 06:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffk0i-0007jO-OQ for qemu-devel@nongnu.org; Wed, 18 Jul 2018 06:48:47 -0400 Received: from ssl.serverraum.org ([2a01:4f8:151:8464::1:2]:37045) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffk0i-0007iz-DQ for qemu-devel@nongnu.org; Wed, 18 Jul 2018 06:48:44 -0400 Received: from mwalle01.sab.local. (unknown [213.135.10.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 0019522D99; Wed, 18 Jul 2018 12:48:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1531910923; bh=PfwczEpyNAAyjXZK6EAFebNwVN3eW687G8pwssjnr2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iz3GPJpaH5hzMKeeT4sto2fgSBe4btWkeUiKDPj4/gqOBRWNNa94qM//kd+XFCSkF 6JKkypmYl/WwN/DneJA+pigoIQ1hadMCKu8+CyRVfHXTg1R6AOYym5U5VwU7Cq8rD+ 6Z/f059Bbbahh1LfaGieXre0AAlhVg3pq36g+1Us= From: Michael Walle To: qemu-devel@nongnu.org Date: Wed, 18 Jul 2018 12:48:35 +0200 Message-Id: <20180718104836.18488-2-michael@walle.cc> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180718104836.18488-1-michael@walle.cc> References: <20180718104836.18488-1-michael@walle.cc> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.100.0 at web X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a01:4f8:151:8464::1:2 Subject: [Qemu-devel] [PATCH 2/3] qtest: new functions for pulsed IRQs 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: Paolo Bonzini , Michael Walle , =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP It is only possible to retrieve the current state of an interrupt line. But there are devices which just pulses the interrupt line. Introduce a latch which is set by qtest and which can be cleared by the test case. Signed-off-by: Michael Walle Cc: Paolo Bonzini Cc: Andreas Färber --- tests/libqtest.c | 19 +++++++++++++++++++ tests/libqtest.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/tests/libqtest.c b/tests/libqtest.c index 098af6aec4..85e1f6f92a 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -40,6 +40,7 @@ struct QTestState int fd; int qmp_fd; bool irq_level[MAX_IRQ]; + bool irq_latch[MAX_IRQ]; GString *rx; pid_t qemu_pid; /* our child QEMU process */ bool big_endian; @@ -233,6 +234,7 @@ QTestState *qtest_init_without_qmp_handshake(bool use_oob, s->rx = g_string_new(""); for (i = 0; i < MAX_IRQ; i++) { s->irq_level[i] = false; + s->irq_latch[i] = false; } if (getenv("QTEST_STOP")) { @@ -386,6 +388,7 @@ redo: if (strcmp(words[1], "raise") == 0) { s->irq_level[irq] = true; + s->irq_latch[irq] = true; } else { s->irq_level[irq] = false; } @@ -678,6 +681,22 @@ bool qtest_get_irq(QTestState *s, int num) return s->irq_level[num]; } +bool qtest_get_irq_latched(QTestState *s, int num) +{ + g_assert_cmpint(num, <, MAX_IRQ); + + /* dummy operation in order to make sure irq is up to date */ + qtest_inb(s, 0); + + return s->irq_latch[num]; +} + +void qtest_clear_irq_latch(QTestState *s, int num) +{ + g_assert_cmpint(num, <, MAX_IRQ); + s->irq_latch[num] = false; +} + static int64_t qtest_clock_rsp(QTestState *s) { gchar **words; diff --git a/tests/libqtest.h b/tests/libqtest.h index ac52872cbe..721dd50863 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -192,6 +192,24 @@ char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap); bool qtest_get_irq(QTestState *s, int num); /** + * qtest_get_irq_latched: + * @s: #QTestState instance to operate on. + * @num: Interrupt to observe. + * + * Returns: The latched state of the @num interrupt. + */ +bool qtest_get_irq_latched(QTestState *s, int num); + +/** + * qtest_clear_irq_latch: + * @s: #QTestState instance to operate on. + * @num: Interrupt to operate on. + * + * Clears the latch of the @num interrupt. + */ +void qtest_clear_irq_latch(QTestState *s, int num); + +/** * qtest_irq_intercept_in: * @s: #QTestState instance to operate on. * @string: QOM path of a device. @@ -638,6 +656,28 @@ static inline bool get_irq(int num) } /** + * get_irq_latched: + * @num: Interrupt to observe. + * + * Returns: The latched level of the @num interrupt. + */ +static inline bool get_irq_latched(int num) +{ + return qtest_get_irq_latched(global_qtest, num); +} + +/** + * clear_irq_latch: + * @num: Interrupt to operate on. + * + * Clears the latch of the @num interrupt. + */ +static inline void clear_irq_latch(int num) +{ + return qtest_clear_irq_latch(global_qtest, num); +} + +/** * irq_intercept_in: * @string: QOM path of a device. *