From nobody Tue Feb 10 17:02:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=laplante.io ARC-Seal: i=1; a=rsa-sha256; t=1689377318; cv=none; d=zohomail.com; s=zohoarc; b=X/7F+E7+Wlel1tM6HVYYVEjrFdh03Bj1RPJV80yVsZQiMl0oy3Y9oTNS66nqWeN4yd4F4J35QuXxtP2jrlHV/17mWMg6W74RouUwjda+78he1jPr4KhJ0gdEgciBZB2nsxJ8EYucOzNNBdkkBQyb4QSwfMeSf5tUczHWrS9eeuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689377318; 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; bh=rBUVME81L2BwsoVmoHCIFwJeWfKSbWXNevI9b3imAvo=; b=dUBnxwIJkT7ehFxlyf1N0Ft1IuadEs2ScyNAe1PRBQRaqVmwUxVJH7Kqqr303P2tFbdFAsFQMi7F3kzsv+yN94brrnsKHt7ol+7liC2zZlmJ1niMFG7gGWkuFMOI9CV7mqrnradWnWesk48QliDP6ddxuDk4J5UCuyKwAmqcBFM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168937731895755.8357052382986; Fri, 14 Jul 2023 16:28:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKSCF-0000jS-Lr; Fri, 14 Jul 2023 19:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCD-0000jF-QR for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:33 -0400 Received: from mail-4317.proton.ch ([185.70.43.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCB-0003zD-Tg for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:33 -0400 Date: Fri, 14 Jul 2023 23:27:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1689377250; x=1689636450; bh=rBUVME81L2BwsoVmoHCIFwJeWfKSbWXNevI9b3imAvo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=4nlMIzWN4aI85nB+6I9Ri5h1X/gigg4/Xrc3izw1w3YEKdUSaHKLkUrSbiuDX56pT yczaDdNyHnyVuJWcNFqWlW+mYw86fjiLl2As/Z6DKhb4wZM22dNQIkOfob2UJP7A7A 3M1UMn1SoZw9yTEf70t1pYdYZiRKXq4se2fY4HGQ/4w7QmIxM0QN1huoUkJk6QUhDa fI9JXEXbjZPWQXgblt7wutwsSJkXFzuCkCd6o7G8vAmezLaLL3kb7C3spikOZ4nJrX xcwey0DLbZlqwJ8I4VElttXlfqzcOfYlr8GUZOvf944YaZXIS1O2xtgevPjk4iMCmz 2qP4CJbuGQEEA== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH 1/6] hw/gpio/nrf51: implement DETECT signal Message-ID: <20230714232659.76434-2-chris@laplante.io> In-Reply-To: <20230714232659.76434-1-chris@laplante.io> References: <20230714232659.76434-1-chris@laplante.io> Feedback-ID: 43500449:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=185.70.43.17; envelope-from=chris@laplante.io; helo=mail-4317.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @laplante.io) X-ZM-MESSAGEID: 1689377319835100003 Content-Type: text/plain; charset="utf-8" Implement nRF51 DETECT signal in the GPIO peripheral. The reference manual makes mention of a per-pin DETECT signal, but these are not exposed to the user. See https://devzone.nordicsemi.com/f/nordic-q-= a/39858/gpio-per-pin-detect-signal-available for more information. Currently, I don't see a reason to model these. Signed-off-by: Chris Laplante reviewed-by tags. (Where I've given one of those, you should --- hw/arm/nrf51_soc.c | 1 + hw/gpio/nrf51_gpio.c | 14 +++++++++++++- include/hw/gpio/nrf51_gpio.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c index 34da0d62f0..7ae54e18be 100644 --- a/hw/arm/nrf51_soc.c +++ b/hw/arm/nrf51_soc.c @@ -150,6 +150,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Err= or **errp) =20 /* Pass all GPIOs to the SOC layer so they are available to the board = */ qdev_pass_gpios(DEVICE(&s->gpio), dev_soc, NULL); + qdev_pass_gpios(DEVICE(&s->gpio), dev_soc, "detect"); =20 /* TIMER */ for (i =3D 0; i < NRF51_NUM_TIMERS; i++) { diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c index b47fddf4ed..08396c69a4 100644 --- a/hw/gpio/nrf51_gpio.c +++ b/hw/gpio/nrf51_gpio.c @@ -78,6 +78,7 @@ static void update_state(NRF51GPIOState *s) int pull; size_t i; bool connected_out, dir, connected_in, out, in, input; + bool assert_detect =3D false; =20 for (i =3D 0; i < NRF51_GPIO_PINS; i++) { pull =3D pull_value(s->cnf[i]); @@ -99,7 +100,15 @@ static void update_state(NRF51GPIOState *s) qemu_log_mask(LOG_GUEST_ERROR, "GPIO pin %zu short circuited\n", i); } - if (!connected_in) { + if (connected_in) { + uint32_t detect_config =3D extract32(s->cnf[i], 16, 2); + if ((detect_config =3D=3D 2) && (in =3D=3D 1)) { + assert_detect =3D true; + } + if ((detect_config =3D=3D 3) && (in =3D=3D 0)) { + assert_detect =3D true; + } + } else { /* * Floating input: the output stimulates IN if connected, * otherwise pull-up/pull-down resistors put a value on bo= th @@ -116,6 +125,8 @@ static void update_state(NRF51GPIOState *s) } update_output_irq(s, i, connected_out, out); } + + qemu_set_irq(s->detect, assert_detect); } =20 /* @@ -291,6 +302,7 @@ static void nrf51_gpio_init(Object *obj) =20 qdev_init_gpio_in(DEVICE(s), nrf51_gpio_set, NRF51_GPIO_PINS); qdev_init_gpio_out(DEVICE(s), s->output, NRF51_GPIO_PINS); + qdev_init_gpio_out_named(DEVICE(s), &s->detect, "detect", 1); } =20 static void nrf51_gpio_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/gpio/nrf51_gpio.h b/include/hw/gpio/nrf51_gpio.h index 8f9c2f86da..fcfa2bac17 100644 --- a/include/hw/gpio/nrf51_gpio.h +++ b/include/hw/gpio/nrf51_gpio.h @@ -64,6 +64,7 @@ struct NRF51GPIOState { uint32_t old_out_connected; =20 qemu_irq output[NRF51_GPIO_PINS]; + qemu_irq detect; }; =20 =20 --=20 2.39.2 From nobody Tue Feb 10 17:02:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=laplante.io ARC-Seal: i=1; a=rsa-sha256; t=1689377358; cv=none; d=zohomail.com; s=zohoarc; b=BieCY0VqkIfdTijbt59areCk61Occjj7jqg1tgWkXhiFnv6oBQRZz/VBbJw4dOY3/8Ct+WaGodaKMPKBEogQ5ezotMQHnJ3xfidQJ75wVxKpYwyrJV+Gt0/3FLU3pEyaM4AQNJD53t58cxZAJwnQ3UuTM2kVS5QgTLNJeTiTJd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689377358; 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; bh=NYu5jlkZSkIqIRSOGkwaCvk5BdLhtCKzeYg2plVUhzo=; b=Yw5t0JUP4zUVz9ISw/J/+nDFlwtQ3XiqbuflHEpFfyZ85HJMhMa7sOwP1eAx/kP3Z2I3ykQLc0IB4eU4KxMkbHLYgMwNKACYO7TwlOcDM7qs67ohwuTnrKzKqpqVFoArzm9gTyhyvngAAADAqO2wCs2ReWehWKtfkZlUDAGYZXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689377358154183.89536805338582; Fri, 14 Jul 2023 16:29:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKSCT-0000lW-7J; Fri, 14 Jul 2023 19:27:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCQ-0000ku-8t for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:46 -0400 Received: from mail-4323.proton.ch ([185.70.43.23]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCO-0003zc-Mi for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:46 -0400 Date: Fri, 14 Jul 2023 23:27:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1689377257; x=1689636457; bh=NYu5jlkZSkIqIRSOGkwaCvk5BdLhtCKzeYg2plVUhzo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=1wkHJuE7qt14zGF0B5UL2CPBWUL5g3cOcOMTpWUdPgAQg/SIPLL5cmX2XvokKsOL5 1sZ39sJxkO8IZ3KRDZJ+s7U1Pv3sPTrQhNO50zP3x4+hFELdsGsV3r9iRZPzivLx+u 3oKdZq7zvZXaafV5GjDFzVH38FLJTZAAZLasiVQP3TliimkaR98PgjXVi9gRI/N0H0 CqLX7YE16Pa4TirhlCrNvZj2LVjN2cqpbgEIZqMy0uPqU0AxghnSWyO5efOUxGlNuw baku2PwG9BBouNqFN/EuOtR40k1Xaq6CSwIZNDXBkW8KNk1MOA6NZCvojwem2GFDmJ 8wgjiilslAUpw== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH 2/6] qtest: implement named interception of out-GPIO Message-ID: <20230714232659.76434-3-chris@laplante.io> In-Reply-To: <20230714232659.76434-1-chris@laplante.io> References: <20230714232659.76434-1-chris@laplante.io> Feedback-ID: 43500449:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=185.70.43.23; envelope-from=chris@laplante.io; helo=mail-4323.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @laplante.io) X-ZM-MESSAGEID: 1689377360102100005 Content-Type: text/plain; charset="utf-8" Adds qtest_irq_intercept_out_named method, which utilizes a new optional name parameter to the irq_intercept_out qtest command. Signed-off-by: Chris Laplante reviewed-by tags. (Where I've given one of those, you should --- softmmu/qtest.c | 39 ++++++++++++++++++++++++++------------- tests/qtest/libqtest.c | 6 ++++++ tests/qtest/libqtest.h | 11 +++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index f8d764b719..7c3dea5760 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -388,8 +388,12 @@ static void qtest_process_command(CharBackend *chr, gc= har **words) || strcmp(words[0], "irq_intercept_in") =3D=3D 0) { DeviceState *dev; NamedGPIOList *ngl; + bool is_named; + bool is_outbound; =20 g_assert(words[1]); + is_named =3D words[2] !=3D NULL; + is_outbound =3D words[0][14] =3D=3D 'o'; dev =3D DEVICE(object_resolve_path(words[1], NULL)); if (!dev) { qtest_send_prefix(chr); @@ -408,19 +412,28 @@ static void qtest_process_command(CharBackend *chr, g= char **words) } =20 QLIST_FOREACH(ngl, &dev->gpios, node) { - /* We don't support intercept of named GPIOs yet */ - if (ngl->name) { - continue; - } - if (words[0][14] =3D=3D 'o') { - int i; - for (i =3D 0; i < ngl->num_out; ++i) { - qemu_irq *disconnected =3D g_new0(qemu_irq, 1); - qemu_irq icpt =3D qemu_allocate_irq(qtest_irq_handler, - disconnected, i); - - *disconnected =3D qdev_intercept_gpio_out(dev, icpt, - ngl->name, i); + /* We don't support inbound interception of named GPIOs yet */ + if (is_outbound) { + if (is_named) { + if (ngl->name && strcmp(ngl->name, words[2]) =3D=3D 0)= { + qemu_irq *disconnected =3D g_new0(qemu_irq, 1); + qemu_irq icpt =3D qemu_allocate_irq(qtest_irq_hand= ler, + disconnected, 0); + + *disconnected =3D qdev_intercept_gpio_out(dev, icp= t, + ngl->name,= 0); + break; + } + } else if (!ngl->name) { + int i; + for (i =3D 0; i < ngl->num_out; ++i) { + qemu_irq *disconnected =3D g_new0(qemu_irq, 1); + qemu_irq icpt =3D qemu_allocate_irq(qtest_irq_hand= ler, + disconnected, i); + + *disconnected =3D qdev_intercept_gpio_out(dev, icp= t, + ngl->name,= i); + } } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index c22dfc30d3..471529e6cc 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -993,6 +993,12 @@ void qtest_irq_intercept_out(QTestState *s, const char= *qom_path) qtest_rsp(s); } =20 +void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, co= nst char *name) +{ + qtest_sendf(s, "irq_intercept_out %s %s\n", qom_path, name); + qtest_rsp(s); +} + void qtest_irq_intercept_in(QTestState *s, const char *qom_path) { qtest_sendf(s, "irq_intercept_in %s\n", qom_path); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 3a71bc45fc..e53e350e3a 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -371,6 +371,17 @@ void qtest_irq_intercept_in(QTestState *s, const char = *string); */ void qtest_irq_intercept_out(QTestState *s, const char *string); =20 +/** + * qtest_irq_intercept_out_named: + * @s: #QTestState instance to operate on. + * @qom_path: QOM path of a device. + * @name: Name of the GPIO out pin + * + * Associate a qtest irq with the named GPIO-out pin of the device + * whose path is specified by @string and whose name is @name. + */ +void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, co= nst char *name); + /** * qtest_set_irq_in: * @s: QTestState instance to operate on. --=20 2.39.2 From nobody Tue Feb 10 17:02:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=laplante.io ARC-Seal: i=1; a=rsa-sha256; t=1689377321; cv=none; d=zohomail.com; s=zohoarc; b=itezWpRR5vR92FTflSmN9bMf4YCaFJcnHX9ZGKRv7Z6ZU+1tPk/7Adg6yCkb3gaJeFCnhv+cWKdRn08WyAbOVWGulbLyb3qt7gwLgq7fUAr+5Z7UndhV1WdAksof8maXbXBlWew8w8+Jx01Zg8d8+hLkBU1jeH53/FkecIuLmLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689377321; 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; bh=p8qyHHyfDhdsEY8JvJ77P9SgwAhpNZHlmyp2CWDWqO8=; b=BVquFfLCGW8BU1dw8haPao/BJksgoaOW17P6123WvlVjIYIbse7Ov/9GjAID4413RSm5p1HAMkZjA083mAOV3lHqZ76HhIhOlFz9LsU4onElXt4gNpWtoboFgmaMCCwtIdZiGQjOFKVcfM3imP083cVzFmYGoxp5ap8o2BpwDT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689377321527622.0832640492719; Fri, 14 Jul 2023 16:28:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKSCW-0000mV-6Z; Fri, 14 Jul 2023 19:27:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCS-0000lH-II for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:49 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCR-00040X-41 for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:48 -0400 Date: Fri, 14 Jul 2023 23:27:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1689377259; x=1689636459; bh=p8qyHHyfDhdsEY8JvJ77P9SgwAhpNZHlmyp2CWDWqO8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=H895B0Gj1q3Fp+OtSCoYgRtsx9dObrAmJv2trFlK/6Vhkc+K1CF9lZOCiQ/zc+sWa h5/BcjFnqxvDlJUq744PhH2T2IUA97PCMdSHvNtOV666CtlfQnJJuYCmGICXG4Aryt 6GMMKtTVrZG5hqMiWZtE6hr5BAIWuHkIynPNHwVGzpN8CM5fzYhx7QOoo+RrOBKQZX GLnWOcN5Asjnk7EAne6tiLuoBFgvNLTEaMzfqLzFwBUTDy1yBvCN8PRYt4sBFQ6vwP W9/6msgwsA66kfRKoVEcJyq/guQgffEVdKPK1WwfuCPq8ScwbKlycxl5Mfd5vh+XOL 2HZZBjP7Y2syg== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH 3/6] qtest: bail from irq_intercept_in if name is specified Message-ID: <20230714232659.76434-4-chris@laplante.io> In-Reply-To: <20230714232659.76434-1-chris@laplante.io> References: <20230714232659.76434-1-chris@laplante.io> Feedback-ID: 43500449:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=188.165.51.139; envelope-from=chris@laplante.io; helo=mail-0301.mail-europe.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @laplante.io) X-ZM-MESSAGEID: 1689377323830100019 Content-Type: text/plain; charset="utf-8" Named interception of in-GPIOs is not supported yet. Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell reviewed-by tags. (Where I've given one of those, you should --- softmmu/qtest.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 7c3dea5760..74482ce3cd 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -401,6 +401,12 @@ static void qtest_process_command(CharBackend *chr, gc= har **words) return; } =20 + if (is_named && !is_outbound) { + qtest_send_prefix(chr); + qtest_send(chr, "FAIL Interception of named in-GPIOs not yet s= upported\n"); + return; + } + if (irq_intercept_dev) { qtest_send_prefix(chr); if (irq_intercept_dev !=3D dev) { @@ -412,7 +418,6 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) } =20 QLIST_FOREACH(ngl, &dev->gpios, node) { - /* We don't support inbound interception of named GPIOs yet */ if (is_outbound) { if (is_named) { if (ngl->name && strcmp(ngl->name, words[2]) =3D=3D 0)= { --=20 2.39.2 From nobody Tue Feb 10 17:02:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=laplante.io ARC-Seal: i=1; a=rsa-sha256; t=1689377320; cv=none; d=zohomail.com; s=zohoarc; b=dyaTm9WYH5P+zyGp0EpkC9R/bO4O6T+CeiMU6JMvoqTBrlPTpcnQt9SQBuT6BIS6ACFc27eIBIOCOwLDHwb70WLDpNrFcw8lN5zlyxCefdhx1v3hJoSZl4hMOktROJSPEM1uGbkYsTcWzkDK8A6QFRi5eWDLstbscmP9dUwUYio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689377320; 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; bh=rYex7wocRTZGMfRvcRZxojizl1kEh3Iuu8cjifrFqzQ=; b=V4hv07CxEhJePFlNA4nWKKEISAmQgbjuwVKMAi5ngpjIWIuaA0XggLsetuaWalMWgo5l3pP0o09uWLqmEaXRMXFeS3jTN+433ZUnWJlysG1DaZ1UWizPrdbnqP0MTx2LbBxnFI1Qmer3vjFLpCzkBn+ZhAuWha28e5fodpodVjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689377320831484.4611790248633; Fri, 14 Jul 2023 16:28:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKSCb-0000qs-OP; Fri, 14 Jul 2023 19:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCZ-0000oc-NP for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:56 -0400 Received: from mail-4018.proton.ch ([185.70.40.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCY-000417-4y for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:27:55 -0400 Date: Fri, 14 Jul 2023 23:27:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1689377271; x=1689636471; bh=rYex7wocRTZGMfRvcRZxojizl1kEh3Iuu8cjifrFqzQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=mqu2TzygWc2rF5jtfcV0lwJ/yKDEcSdLDU1yPwOU+mke/yAgzIlvxidTOvoeTk5T1 QcjuktGSYHfRh74wNBuaJp9+2Zg/QNNDS6aktbG30CjtUBL7gU3swjsuup1QluiH1y 76OCTZQoB/yOmQXRFVYPT3FoR0XCOguoTysLZzIeydG42pZGs/d7lU1cE1+GmV5HVk eeYRgEq+ees5tkiqIcWnQawkbXo0TaGwY7/YYChgcorSWmO13f9QGKrmUCxXh9zVbV 0FvSH0MKxIZvWyFCCHCwQqTKgspTXcYB4CU8ybmTy0f0jdIbmXYBn63zbQ0UhciK1S nlR9+TeB61bDg== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts Message-ID: <20230714232659.76434-5-chris@laplante.io> In-Reply-To: <20230714232659.76434-1-chris@laplante.io> References: <20230714232659.76434-1-chris@laplante.io> Feedback-ID: 43500449:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=185.70.40.18; envelope-from=chris@laplante.io; helo=mail-4018.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @laplante.io) X-ZM-MESSAGEID: 1689377321135100013 Content-Type: text/plain; charset="utf-8" Simplify the code a bit. Signed-off-by: Chris Laplante reviewed-by tags. (Where I've given one of those, you should --- softmmu/qtest.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 74482ce3cd..051bbf4177 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -365,6 +365,15 @@ void qtest_set_command_cb(bool (*pc_cb)(CharBackend *c= hr, gchar **words)) process_command_cb =3D pc_cb; } =20 +static void qtest_install_gpio_out_intercepts(DeviceState *dev, const char= *name, int n) +{ + qemu_irq *disconnected =3D g_new0(qemu_irq, 1); + qemu_irq icpt =3D qemu_allocate_irq(qtest_irq_handler, + disconnected, n); + + *disconnected =3D qdev_intercept_gpio_out(dev, icpt,name, n); +} + static void qtest_process_command(CharBackend *chr, gchar **words) { const gchar *command; @@ -421,23 +430,13 @@ static void qtest_process_command(CharBackend *chr, g= char **words) if (is_outbound) { if (is_named) { if (ngl->name && strcmp(ngl->name, words[2]) =3D=3D 0)= { - qemu_irq *disconnected =3D g_new0(qemu_irq, 1); - qemu_irq icpt =3D qemu_allocate_irq(qtest_irq_hand= ler, - disconnected, 0); - - *disconnected =3D qdev_intercept_gpio_out(dev, icp= t, - ngl->name,= 0); + qtest_install_gpio_out_intercepts(dev, ngl->name, = 0); break; } } else if (!ngl->name) { int i; for (i =3D 0; i < ngl->num_out; ++i) { - qemu_irq *disconnected =3D g_new0(qemu_irq, 1); - qemu_irq icpt =3D qemu_allocate_irq(qtest_irq_hand= ler, - disconnected, i); - - *disconnected =3D qdev_intercept_gpio_out(dev, icp= t, - ngl->name,= i); + qtest_install_gpio_out_intercepts(dev, ngl->name, = i); } } } else { --=20 2.39.2 From nobody Tue Feb 10 17:02:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=laplante.io ARC-Seal: i=1; a=rsa-sha256; t=1689377358; cv=none; d=zohomail.com; s=zohoarc; b=F2BES1y2PNymrim//KTEM1pKxeBPIbtQxFeou3xogRdCvz2+6PIwFouAqQ83LGaU8/5/O0rYltEng+jPkeT6vrFA9MbJlSpsic3lfHC93VVW6QibnpFG8zJUV0tq8HaxqVL/aN9YxreyInasrEUV2IrGlFI3rQOQFeUK6TKJw8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689377358; 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; bh=kCTGZscRn0Vly+yIoAdKyZJzfkd9NkpoIHdFxIsVLuc=; b=HKF65DsbfkTieFfPZuikICNWwFJt0Zd2t5sbxohwZ/wnRJe38J1pJScPByn5zHhjhalAPpyazQ2BfL7A82MjooRwJrU7HVDDU3beGdVDCjXjpqA6zuIV4GexPbZ5njo/hT+fDx16rPKvSFcdDAfmDBzbjdUyHyJEvc7wQtSOieM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16893773585031010.8801175749439; Fri, 14 Jul 2023 16:29:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKSCk-0000st-3F; Fri, 14 Jul 2023 19:28:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCi-0000rx-6T for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:28:04 -0400 Received: from mail-40136.proton.ch ([185.70.40.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCf-00043P-PA for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:28:03 -0400 Date: Fri, 14 Jul 2023 23:27:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1689377278; x=1689636478; bh=kCTGZscRn0Vly+yIoAdKyZJzfkd9NkpoIHdFxIsVLuc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=AmwSJ46uycYMhdBtcgo0j9qVcan+g04NVoOuGO4gg3cSr72OHlyh0XCDtN/14W5gy DaQJtEDTF/dj3pBE3NzgK8Zge79eH9qif7zHxGZgihUZ2eBJrmi3LY2qKtO9RNIJ7W Lo7VYuVTpc1rQySgcwjopNX47kZRb3iyGDjNHt31alpqX6BAQ8bFwFRKtx82j+bi+v L5dMysoI32uUwttTSYtStXUaUZt2cD7qNqJ3Ii8tVlsBfpqNCRi1vRqaSG6ICjSwEi upmrzPhY8YqwQFxQd4FqK93geZi2l6GSDV9mgoALhy99v1zpbo7RIV5CtXeJaOi/Gx PK24d0fvgO7ig== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH 5/6] qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed Message-ID: <20230714232659.76434-6-chris@laplante.io> In-Reply-To: <20230714232659.76434-1-chris@laplante.io> References: <20230714232659.76434-1-chris@laplante.io> Feedback-ID: 43500449:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=185.70.40.136; envelope-from=chris@laplante.io; helo=mail-40136.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @laplante.io) X-ZM-MESSAGEID: 1689377360104100006 Content-Type: text/plain; charset="utf-8" This is much better than just silently failing with OK. Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell reviewed-by tags. (Where I've given one of those, you should --- softmmu/qtest.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 051bbf4177..e888acb319 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -399,6 +399,7 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) NamedGPIOList *ngl; bool is_named; bool is_outbound; + bool interception_succeeded =3D false; =20 g_assert(words[1]); is_named =3D words[2] !=3D NULL; @@ -431,6 +432,7 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) if (is_named) { if (ngl->name && strcmp(ngl->name, words[2]) =3D=3D 0)= { qtest_install_gpio_out_intercepts(dev, ngl->name, = 0); + interception_succeeded =3D true; break; } } else if (!ngl->name) { @@ -438,15 +440,22 @@ static void qtest_process_command(CharBackend *chr, g= char **words) for (i =3D 0; i < ngl->num_out; ++i) { qtest_install_gpio_out_intercepts(dev, ngl->name, = i); } + interception_succeeded =3D true; } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, ngl->num_in); + interception_succeeded =3D true; } } - irq_intercept_dev =3D dev; + qtest_send_prefix(chr); - qtest_send(chr, "OK\n"); + if (interception_succeeded) { + irq_intercept_dev =3D dev; + qtest_send(chr, "OK\n"); + } else { + qtest_send(chr, "FAIL No intercepts installed\n"); + } } else if (strcmp(words[0], "set_irq_in") =3D=3D 0) { DeviceState *dev; qemu_irq irq; --=20 2.39.2 From nobody Tue Feb 10 17:02:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=laplante.io ARC-Seal: i=1; a=rsa-sha256; t=1689377318; cv=none; d=zohomail.com; s=zohoarc; b=mmm27+dp6Z+rC0uRkt1eNhcVymZw2K3nkxo1ffleBUlrWHvoSlrgMbeQ+Dkb19uYIJrv5toITn25RvUgB3T2zD27p7WO6OTtON6JiD2GPIazkI+sXD0daiWl3l+w3+yvnTpxOMcF4FkbFW4DWUkalgHjXt04h9Sc+7WlMfQ4+Rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689377318; 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; bh=PQsO06m872ZPS3ye7JAZN9jPnnRrY+OuHRHTzT8HnJI=; b=gkh55eghw4IFjg9ww+jJjv8a2gj2iqNgQEPMPz5d4E5zqU0nNTGgiwNDI/m8gG+MgggT29yhGyhNNgwvI5DYOLQw3DaEi9fEtQeup2Vg87MkmWEcmrljqr6XAqtxV3+Jj7jNMLAnrvIIMlpJgCqWj7t1lEtPAO6S2u6FKNWBwLU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168937731884295.48894908284046; Fri, 14 Jul 2023 16:28:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKSCj-0000sc-Pj; Fri, 14 Jul 2023 19:28:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCi-0000rw-6K for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:28:04 -0400 Received: from mail-4018.proton.ch ([185.70.40.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKSCg-00043S-Al for qemu-devel@nongnu.org; Fri, 14 Jul 2023 19:28:03 -0400 Date: Fri, 14 Jul 2023 23:27:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1689377279; x=1689636479; bh=PQsO06m872ZPS3ye7JAZN9jPnnRrY+OuHRHTzT8HnJI=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=aeUhYacEYXMWkLo4pVxVmuaZVAcmPok43vO8RmvXsh9+qOriHeGzzkBm8DCmAiE83 6D99qREbzKNYZZ5Y2QQWsmhaJDeTsSutNEwY54eTjMT/t+sJX79ZjRvEWAOCaVuSqo b6RfMxXkGnyH2cfwg+ZhgecHZWyuyEm+Pc1/K9U9syAID3SdgFe6Fueg3SEiflzFgU VJdGCY+7rpQky2rYUZVcHu8kyUwNvdmE6Zw4ysbkLkkQLNq1tXxAeulGULGmlVlo5C fOQXSZa98xR8Q/nQY44Rk++g4/9U80pi0uhDGFsmzAL6ClsylrBidEsWLfwM469hdy 9G2O9mjkvAwlQ== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH 6/6] qtest: microbit-test: add tests for nRF51 DETECT Message-ID: <20230714232659.76434-7-chris@laplante.io> In-Reply-To: <20230714232659.76434-1-chris@laplante.io> References: <20230714232659.76434-1-chris@laplante.io> Feedback-ID: 43500449:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=185.70.40.18; envelope-from=chris@laplante.io; helo=mail-4018.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @laplante.io) X-ZM-MESSAGEID: 1689377319920100010 Content-Type: text/plain; charset="utf-8" Exercise the DETECT mechanism of the GPIO peripheral. Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell reviewed-by tags. (Where I've given one of those, you should --- tests/qtest/microbit-test.c | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c index 6022a92b6a..3c85adba37 100644 --- a/tests/qtest/microbit-test.c +++ b/tests/qtest/microbit-test.c @@ -393,6 +393,47 @@ static void test_nrf51_gpio(void) qtest_quit(qts); } =20 +static void test_nrf51_gpio_detect(void) { + QTestState *qts =3D qtest_init("-M microbit"); + int i; + + // Connect input buffer on pins 1-7, configure SENSE for high level + for (i =3D 1; i <=3D 7; i++) { + qtest_writel(qts, NRF51_GPIO_BASE + NRF51_GPIO_REG_CNF_START + i *= 4, deposit32(0, 16, 2, 2)); + } + + qtest_irq_intercept_out_named(qts, "/machine/nrf51", "detect"); + + for (i =3D 1; i <=3D 7; i++) { + // Set pin high + qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", i, 1); + uint32_t actual =3D qtest_readl(qts, NRF51_GPIO_BASE + NRF51_GPIO_= REG_IN); + g_assert_cmpuint(actual, =3D=3D, 1 << i); + + // Check that DETECT is high + g_assert_true(qtest_get_irq(qts, 0)); + + // Set pin low, check that DETECT goes low. + qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", i, 0); + actual =3D qtest_readl(qts, NRF51_GPIO_BASE + NRF51_GPIO_REG_IN); + g_assert_cmpuint(actual, =3D=3D, 0x0); + g_assert_false(qtest_get_irq(qts, 0)); + } + + // Set pin 0 high, check that DETECT doesn't fire + qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", 0, 1); + g_assert_false(qtest_get_irq(qts, 0)); + qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", 0, 0); + + // Set pins 1, 2, and 3 high, then set 3 low. Check that DETECT is sti= ll high. + for (i =3D 1; i <=3D 3; i++) { + qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", i, 1); + } + g_assert_true(qtest_get_irq(qts, 0)); + qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", 3, 0); + g_assert_true(qtest_get_irq(qts, 0)); +} + static void timer_task(QTestState *qts, hwaddr task) { qtest_writel(qts, NRF51_TIMER_BASE + task, NRF51_TRIGGER_TASK); @@ -499,6 +540,7 @@ int main(int argc, char **argv) =20 qtest_add_func("/microbit/nrf51/uart", test_nrf51_uart); qtest_add_func("/microbit/nrf51/gpio", test_nrf51_gpio); + qtest_add_func("/microbit/nrf51/gpio_detect", test_nrf51_gpio_detect); qtest_add_func("/microbit/nrf51/nvmc", test_nrf51_nvmc); qtest_add_func("/microbit/nrf51/timer", test_nrf51_timer); qtest_add_func("/microbit/microbit/i2c", test_microbit_i2c); --=20 2.39.2