From nobody Wed May 15 19:26:23 2024 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=1690560656; cv=none; d=zohomail.com; s=zohoarc; b=gF3Es6IGwNdh+qsse0jCbtzf/5flZ5XihhJYCTzolM/a6OpQG+Rjid4J+zuK+82+zs2mqhdTsLJGqly2d3kVPMQ1vYX+vAP7ErAkLYoy50+ZcvfzeNPQdnIaAqkom6O7tIXzdEmTyDchD++8dmDgdpvbVjCv6E2TGIEk3RKqC1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690560656; 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=zTjLq+zc91w1jiR1LPwIgyvKj+dT7Pr54R8PgUtkI0A=; b=nkvX4JeGAazb86M2W2X2/pl8jxIalSNKwHo7OjfCfYtqI0lE93d3Hc8N9MMEsrL1cD/FkclkVhdIOqS49ne6EQqjDLUEHXQKiAXSHpWTKh2bUG/5nzW0fIFg5GS909nmHyzQ0rHAINEkjpUBfcHEy9XuixfSuPZhdeXuXxcGiEs= 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 169056065669962.96620949535509; Fri, 28 Jul 2023 09:10:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPPxi-0004sn-IM; Fri, 28 Jul 2023 12:05: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 1qPPxh-0004sA-7b for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:05 -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 1qPPxe-0004NM-VA for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:04 -0400 Date: Fri, 28 Jul 2023 16:04:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690560300; x=1690819500; bh=zTjLq+zc91w1jiR1LPwIgyvKj+dT7Pr54R8PgUtkI0A=; 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=kD3/sLgeNbtK+qZ7wfsRkxWl6CK9ROeLmmOU37tRXlztnFTgfFxi/bzgnSxfWLoIM U7KgNXa/zq+uzPb0Est8/LLWylJ5FLe/b6h/r3h/dl/L1i2Q0nMd0GjFTPYLzwcrXc O1ShU+QHpumMGYKJ2Vab8uxT2y5GqQ3oN4KWNtPWSzW9CL+sVASMyLuuQSlsZSyxk5 nswFQbQrSacArTpab/coLAditxadWEDvWXve0g1SvMgLm3mw7jG8o7fMsG9vSsQKYC elrjD9lhoJUeWDbI7Ow9i1IK6VcS1hH7L59zQHkSyZNYvRKWxtiN5LKgV4k8g6f/ZI B/A2kiC5r9SmA== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v3 1/6] hw/gpio/nrf51: implement DETECT signal Message-ID: <20230728160324.1159090-2-chris@laplante.io> In-Reply-To: <20230728160324.1159090-1-chris@laplante.io> References: <20230728160324.1159090-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: 1690560657586100003 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: Peter Maydell --- hw/gpio/nrf51_gpio.c | 14 +++++++++++++- include/hw/gpio/nrf51_gpio.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) 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.41.0 From nobody Wed May 15 19:26:23 2024 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=1690562677; cv=none; d=zohomail.com; s=zohoarc; b=YO1eG8efKRQuh9QAt5VUKTQB2mA8/ocMVDON34R6FzOFfv2xd6K8RZs1x9v2hVNBBDjFB27uvA/B9ThrRk0kubej318u3azEDcdbp467lxW67UQyjWVXAjoB2zdb1k9KiPzcIyHKL1OLY/vTwzRYcuTgfaESDE5a76qaO1ss+ZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690562677; 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=Rk0N/XPmjneuAZccDgJuKpf3b/CK7sC2+1J9idvSmWo=; b=DL8bWqFDC22eea0wgYH4P1QMy6epIpMLGAoL59BhaZl/UL1inp420X8RP463Td7USmSFXQo8PBhBBvtaraN5P6+gBZIMnqD9uYgUffIk1uguNEK1kJEYfL5j8+8kwmhaIBqP7gpcKUAOcGBp8n0Q3zHSZTVxRSCIg9/DyVuQttM= 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 1690562677785642.9536316972873; Fri, 28 Jul 2023 09:44:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPPxh-0004sH-Kz; Fri, 28 Jul 2023 12:05: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 1qPPxf-0004ru-W3 for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05: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 1qPPxe-0004NF-Ct for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:03 -0400 Date: Fri, 28 Jul 2023 16:04:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690560300; x=1690819500; bh=Rk0N/XPmjneuAZccDgJuKpf3b/CK7sC2+1J9idvSmWo=; 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=OwABK5ehC1D9P2acVBNiqDjdAz9nTw1mPatjHZ0qYd8qKn3/dEGKHf9HgCSNzEccv vcNeA6PG4LiDDTa7fG5GpMa3uDskO9UbyBxk95OIHuIAhsNds7eRqfTVRAwapdc2IT +/ALjZFeGmfBy2fsYsyTLyWoL2S9zlZg5/kU4473UIsOO0Gbh/n43bQjWhHcxRvxpG ypME+b/8yDpSb7i/wRX2FLCXGJ1FjuZfvIOxuE6zDOWNWr8Na3Oo3r7A7nbHHBFBVg Y9fWBO9sV/wYBJuItB3f8q5o/903kB0C4W077AqaVvsj1ANdi9SnTdZgmBMwGIiHCw qPiqK9kb4UQZg== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v3 2/6] qtest: factor out qtest_install_gpio_out_intercept Message-ID: <20230728160324.1159090-3-chris@laplante.io> In-Reply-To: <20230728160324.1159090-1-chris@laplante.io> References: <20230728160324.1159090-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: 1690562679693100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell --- softmmu/qtest.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index f8d764b719..1b86489162 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_intercept(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; @@ -415,12 +424,7 @@ static void qtest_process_command(CharBackend *chr, gc= har **words) 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); + qtest_install_gpio_out_intercept(dev, ngl->name, i); } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, --=20 2.41.0 From nobody Wed May 15 19:26:23 2024 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=1690563307; cv=none; d=zohomail.com; s=zohoarc; b=dbIgPGaa1/w80xHMCIAhy8QdqCyGS/PsEpC/QxHOM0pkxt+JaMS6VscYYfno8bJCUqbVYgEThPibLd9Cn9Lf1V7/RiGTkNt7WUokGjW9vFfr4rE9/VigA8j6YznK79u2SlQLj23i4xLIRnJaEHiFhH753AEjfsmyeRp8coTnUOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690563307; 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=8kaga0Tq1DHDgh2bcs3qrXwpLVkm/Jqm49BzCQmqlWk=; b=ZUjWuCPBUYuTT0/2xlsIT4BAPslJO/Yu5og9X6FK6cZWriDHJkOrhBtsJPk557vIqCDKTL0Au5ZUN5S0t54tt9APsB/fQeAfUITZTsBXVOWEailhW5pBaZ8LZ5esxRPI/siaMKUJ11yJ60hFMd05zqmpEJPcxj3dJ4QsYuWrxNg= 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 1690563307642440.07135771942876; Fri, 28 Jul 2023 09:55:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPPxy-0004yo-FZ; Fri, 28 Jul 2023 12:05:22 -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 1qPPxw-0004xS-S9 for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:20 -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 1qPPxu-0004eX-B3 for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:20 -0400 Date: Fri, 28 Jul 2023 16:04:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690560315; x=1690819515; bh=8kaga0Tq1DHDgh2bcs3qrXwpLVkm/Jqm49BzCQmqlWk=; 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=2Jo1oVGtvnE43xpCXAZ7SDPwA0zFniUbeIh8ggtQZcHHqMM4jUjAzTHDnwHqNuQOI LrEoNcgeB1uuZb/MdrpwTlI56qPXLCeDJkNLs6kctNBbh3oqez5+ZzSd7qGglz55Fo BSJN17nXfpISwsi/DGSEwF8Gr/OW/+KaHivduaRQXQLFqaXITXu8jdRydlu+TZWuIG KyVCu2YzqNvkD2HyxOgVR40ZB7vtFV+C5IVuaNm92ybGYra+q/4faVPTwo0ST6n8kF p30DrAQmGELXgv+ehIJUC7LgfetFp5xs5ECY9+RzbheaQhC9ziavEf59ulAvbbzLF/ w6vTEGGtG1omw== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v3 3/6] qtest: implement named interception of out-GPIO Message-ID: <20230728160324.1159090-4-chris@laplante.io> In-Reply-To: <20230728160324.1159090-1-chris@laplante.io> References: <20230728160324.1159090-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=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: 1690563309711100003 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 --- softmmu/qtest.c | 18 ++++++++++-------- tests/qtest/libqtest.c | 6 ++++++ tests/qtest/libqtest.h | 11 +++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 1b86489162..0f1d478bda 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -397,8 +397,10 @@ 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_outbound; =20 g_assert(words[1]); + is_outbound =3D words[0][14] =3D=3D 'o'; dev =3D DEVICE(object_resolve_path(words[1], NULL)); if (!dev) { qtest_send_prefix(chr); @@ -417,14 +419,14 @@ 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) { - qtest_install_gpio_out_intercept(dev, ngl->name, i); + /* We don't support inbound interception of named GPIOs yet */ + if (is_outbound) { + /* NULL is valid and matchable, for "unnamed GPIO" */ + if (g_strcmp0(ngl->name, words[2]) =3D=3D 0) { + int i; + for (i =3D 0; i < ngl->num_out; ++i) { + qtest_install_gpio_out_intercept(dev, 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.41.0 From nobody Wed May 15 19:26:23 2024 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=1690564192; cv=none; d=zohomail.com; s=zohoarc; b=TPTup7DKmMLi3qBJN5OblRDd0ynubrXngciuMXKSNDhNa8aWW6dhinppnk9T6a1SS6DWv2oH7B3PrmOj5qlQ7HJ/Bq8gN/EBMlLfx12iX9g9cb3iAzDSM67Zq3Zf91l8ya0fGGtwirvxpfcj6xppQvIpYOz4aVNadkIoff8Z4xQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690564192; 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=9creud7ffADP036CJBemj2r7ekswvmWnuyDLTNzzpEU=; b=LOr5PZcnzv2LaA7zQPsD6peBYw8cOvGC2k0l6cxqrmmzJbzsLidEpuBpwSyMruk5eyx+1wZcD/iUbBO+B4axFzYRsvVQI2svg7hangaNXkqyRGfMo+dIMK/tIe6W39DpeonW/exZuZIEbyLGUi0QuvTY9gXB7W2QYOnFacShMBg= 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 1690564192253201.4969068104407; Fri, 28 Jul 2023 10:09:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPPxz-0004yp-1c; Fri, 28 Jul 2023 12:05:23 -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 1qPPxw-0004x7-6e for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:20 -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 1qPPxu-0004ek-8A for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:19 -0400 Date: Fri, 28 Jul 2023 16:05:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690560316; x=1690819516; bh=9creud7ffADP036CJBemj2r7ekswvmWnuyDLTNzzpEU=; 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=CUy0d56E5zGoJGELUBmBK+AnMJYvg7Td1w74auDPt2s4KgWNzeIZdA33IILIIM1Pq 1WqUl+EORcfD+YzJtOjEilpNv9UKzr488gMiXNRtjP5bUpLTlkdKmEiI7KGvtXaVrc MRR/d9w3yUJiwZIXd5E4R7YMyZge8yNx6Az7BBZ/bcsHwR/R9tvwnbymsIuc3WuRYK +IQiPt497l89CIvkXekJmPvNMdD+3TB67hV12e/F3atpxZKLC42+Z9Q10Xb0suKsVC 1nassoE43DFVWQ5yvNF7mhEcktxaxs4TanfACv7TD9oNbiRyR/LDIDHaxS+usUS+3n TKqNtydFuLXCw== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v3 4/6] qtest: bail from irq_intercept_in if name is specified Message-ID: <20230728160324.1159090-5-chris@laplante.io> In-Reply-To: <20230728160324.1159090-1-chris@laplante.io> References: <20230728160324.1159090-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: 1690564194680100003 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 --- softmmu/qtest.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 0f1d478bda..66757ba261 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -397,9 +397,11 @@ 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) { @@ -408,6 +410,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) { --=20 2.41.0 From nobody Wed May 15 19:26:23 2024 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=1690562593; cv=none; d=zohomail.com; s=zohoarc; b=bgjTHrOrcGNvqMS8XVI2yMseZKb/QfFOaPEPwQMlLOqihlVWgxeHn8vFKQx7cQkAizIK2rDVn955n01cYId+F+HdOGqN7d0hq2pYNHEym8uVovsvP+pdL8jA+iyusG+uBTpAqX8ICiiWpSOn8E4Xu/kcQGmufm9YPG9fQdQ57XQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690562593; 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=5mJBH2avifG4/P8iPdPedQfA6UtFs96ajMwje8eMy2s=; b=n7M2fZpoIO4pr2lc2LU6hl0sHR8FD/0GKYctKSMF1yj4787QpjHSGGqO+RVy1XpVqtJryqggW40n4mIm1bgEALuJRyxYfODc9JpohE6AFskTrAKi9oobc4Uiiu5La4XT+4lLVzyZ0p6Swx5omR+OaPIZm137v1JSpTyweJ8zFL4= 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 1690562593718444.4682338401975; Fri, 28 Jul 2023 09:43:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPPxw-0004xP-QS; Fri, 28 Jul 2023 12:05:20 -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 1qPPxv-0004wm-0j; Fri, 28 Jul 2023 12:05:19 -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 1qPPxt-0004eS-AZ; Fri, 28 Jul 2023 12:05:18 -0400 Date: Fri, 28 Jul 2023 16:05:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690560315; x=1690819515; bh=5mJBH2avifG4/P8iPdPedQfA6UtFs96ajMwje8eMy2s=; 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=h4MYg/NM9tEY67P1Y6089itidh+DuArYd2t+fC23fOpIGIvEUZuaAqYBNnMRSDwqr SlJpZ8CqlrqdYGbdWFdwWRahCqqHNfGEZIZqrh/jzHfu9DqcuPPdTrwRhWH2tP54cz ur1YXdV96+nOyZ/pxRfbjJ2Vj30sABO9VOpuGHf90PkSfHx8xejNj/ziy795MSfIXT OWAjk2oCsUnZzXnCw1Ca/l0X+8w76DvJS23aYOx7TOrzYreIi6vGqrhlIerFjWBdZ8 rFPL4XN8ls3mJRsvzlU4oihyN4ut3i79bBgnBQcrIan/DAxKPhgH1OThL1+06p6E9l cwdzu1OjL0fEA== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v3 5/6] qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed Message-ID: <20230728160324.1159090-6-chris@laplante.io> In-Reply-To: <20230728160324.1159090-1-chris@laplante.io> References: <20230728160324.1159090-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: 1690562594664100003 Content-Type: text/plain; charset="utf-8" This is much better than just silently failing with OK. Signed-off-by: Chris Laplante --- softmmu/qtest.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 66757ba261..35b643a274 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; @@ -435,15 +436,22 @@ static void qtest_process_command(CharBackend *chr, g= char **words) for (i =3D 0; i < ngl->num_out; ++i) { qtest_install_gpio_out_intercept(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.41.0 From nobody Wed May 15 19:26:23 2024 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=1690561654; cv=none; d=zohomail.com; s=zohoarc; b=coKJRstk/fnJJu+zKfiNDtuG8nkJVH5i9G/TU5LiL9/6cDyBv2s94Mg8XDgLso54rxEjzUy5AmToOJecOv9XNSSV8FvLNQXW7Oyl3a69tQ0UEGP8yKMcYoWWco/yI5y0iRkPEQBX5F8OeQ49JmWhIxRm8Ti/hbuDPYGdoZYw5IU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690561654; 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=o7zIkzaI1a62QrEcz/FY3julaQj7d2aOqS7MyikdcUw=; b=gci1o7g8cN4s6rxhpv+eynHKKCFnyy3egRPNk6jlNuxJNd6XiXa44puQJsZoZIQtZ1D7rttLLqM+7sxjNRi92FzfUnzffXxtiIhQ9HYgllHL7BldB7TaeIcAI48ypIduaRdJMBspvQZeH3ZNEUq+NclecjNqUWfljLRxT6BAN3k= 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 1690561654400430.11980726288755; Fri, 28 Jul 2023 09:27:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qPPyB-00052z-R4; Fri, 28 Jul 2023 12:05: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 1qPPy9-0004zW-AD for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:34 -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 1qPPy5-0004kn-Uq for qemu-devel@nongnu.org; Fri, 28 Jul 2023 12:05:31 -0400 Date: Fri, 28 Jul 2023 16:05:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690560324; x=1690819524; bh=o7zIkzaI1a62QrEcz/FY3julaQj7d2aOqS7MyikdcUw=; 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=9TzBFJqOpkJE/3QTI/ZpK3K0L/5t/qNL0gPNtLw3yFJUk8YZjPOOLehGY1pRBAv8b XKzqYcSho/QrM5WFBd5HdpImwSIRnIhAHRbWr2CQzuidr79TcON7SfO+N6C8sc2rJJ rb05ph7qHmt6V/xScGw+0zGUjXbS+p+s+Sj7yz/GmlNzKkl0+P+xC7g7/qak/0YGLo /xt+v3kO1ssd7aa95vvve0+yMLoroXrYndCdWe/jxjLweR0gAkysUSNgv4V/srV5b3 r3184oieHwc4aDfB8AZAPWE8bRR6FKy1IB8Ro3ON5Jikv46FE6i2gTRIZaHG4ykmMU EAGJx9LWsX2HQ== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v3 6/6] qtest: microbit-test: add tests for nRF51 DETECT Message-ID: <20230728160324.1159090-7-chris@laplante.io> In-Reply-To: <20230728160324.1159090-1-chris@laplante.io> References: <20230728160324.1159090-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: 1690561656289100001 Content-Type: text/plain; charset="utf-8" Exercise the DETECT mechanism of the GPIO peripheral. Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell --- 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..8f87810cd5 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/gpio", "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.41.0