From patchwork Fri Jul 14 23:27:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1808050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=laplante.io header.i=@laplante.io header.a=rsa-sha256 header.s=protonmail3 header.b=4nlMIzWN; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2njM4tPbz20bh for ; Sat, 15 Jul 2023 09:28:39 +1000 (AEST) 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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, Error **errp) /* 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"); /* TIMER */ for (i = 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 = false; for (i = 0; i < NRF51_GPIO_PINS; i++) { pull = 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 = extract32(s->cnf[i], 16, 2); + if ((detect_config == 2) && (in == 1)) { + assert_detect = true; + } + if ((detect_config == 3) && (in == 0)) { + assert_detect = true; + } + } else { /* * Floating input: the output stimulates IN if connected, * otherwise pull-up/pull-down resistors put a value on both @@ -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); } /* @@ -291,6 +302,7 @@ static void nrf51_gpio_init(Object *obj) 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); } 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; qemu_irq output[NRF51_GPIO_PINS]; + qemu_irq detect; }; From patchwork Fri Jul 14 23:27:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1808054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=laplante.io header.i=@laplante.io header.a=rsa-sha256 header.s=protonmail3 header.b=1wkHJuE7; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2nk72xzmz20bh for ; Sat, 15 Jul 2023 09:29:19 +1000 (AEST) 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 | 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, gchar **words) || strcmp(words[0], "irq_intercept_in") == 0) { DeviceState *dev; NamedGPIOList *ngl; + bool is_named; + bool is_outbound; g_assert(words[1]); + is_named = words[2] != NULL; + is_outbound = words[0][14] == 'o'; dev = DEVICE(object_resolve_path(words[1], NULL)); if (!dev) { qtest_send_prefix(chr); @@ -408,19 +412,28 @@ static void qtest_process_command(CharBackend *chr, gchar **words) } QLIST_FOREACH(ngl, &dev->gpios, node) { - /* We don't support intercept of named GPIOs yet */ - if (ngl->name) { - continue; - } - if (words[0][14] == 'o') { - int i; - for (i = 0; i < ngl->num_out; ++i) { - qemu_irq *disconnected = g_new0(qemu_irq, 1); - qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, - disconnected, i); - - *disconnected = 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]) == 0) { + qemu_irq *disconnected = g_new0(qemu_irq, 1); + qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, + disconnected, 0); + + *disconnected = qdev_intercept_gpio_out(dev, icpt, + ngl->name, 0); + break; + } + } else if (!ngl->name) { + int i; + for (i = 0; i < ngl->num_out; ++i) { + qemu_irq *disconnected = g_new0(qemu_irq, 1); + qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, + disconnected, i); + + *disconnected = qdev_intercept_gpio_out(dev, icpt, + 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); } +void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const 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); +/** + * 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, const char *name); + /** * qtest_set_irq_in: * @s: QTestState instance to operate on. From patchwork Fri Jul 14 23:27:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1808053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=laplante.io header.i=@laplante.io header.a=rsa-sha256 header.s=protonmail3 header.b=H895B0Gj; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2njQ1gq6z20cl for ; Sat, 15 Jul 2023 09:28:42 +1000 (AEST) 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Named interception of in-GPIOs is not supported yet. Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell --- 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, gchar **words) return; } + if (is_named && !is_outbound) { + qtest_send_prefix(chr); + qtest_send(chr, "FAIL Interception of named in-GPIOs not yet supported\n"); + return; + } + if (irq_intercept_dev) { qtest_send_prefix(chr); if (irq_intercept_dev != dev) { @@ -412,7 +418,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) } 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]) == 0) { From patchwork Fri Jul 14 23:27:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1808052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=laplante.io header.i=@laplante.io header.a=rsa-sha256 header.s=protonmail3 header.b=mqu2Tzyg; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2njQ0Ypbz20bh for ; Sat, 15 Jul 2023 09:28:41 +1000 (AEST) 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Simplify the code a bit. Signed-off-by: Chris Laplante --- 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 *chr, gchar **words)) process_command_cb = pc_cb; } +static void qtest_install_gpio_out_intercepts(DeviceState *dev, const char *name, int n) +{ + qemu_irq *disconnected = g_new0(qemu_irq, 1); + qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, + disconnected, n); + + *disconnected = 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, gchar **words) if (is_outbound) { if (is_named) { if (ngl->name && strcmp(ngl->name, words[2]) == 0) { - qemu_irq *disconnected = g_new0(qemu_irq, 1); - qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, - disconnected, 0); - - *disconnected = qdev_intercept_gpio_out(dev, icpt, - ngl->name, 0); + qtest_install_gpio_out_intercepts(dev, ngl->name, 0); break; } } else if (!ngl->name) { int i; for (i = 0; i < ngl->num_out; ++i) { - qemu_irq *disconnected = g_new0(qemu_irq, 1); - qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, - disconnected, i); - - *disconnected = qdev_intercept_gpio_out(dev, icpt, - ngl->name, i); + qtest_install_gpio_out_intercepts(dev, ngl->name, i); } } } else { From patchwork Fri Jul 14 23:27:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1808055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=laplante.io header.i=@laplante.io header.a=rsa-sha256 header.s=protonmail3 header.b=AmwSJ46u; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2nk73rrGz20cB for ; Sat, 15 Jul 2023 09:29:19 +1000 (AEST) 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is much better than just silently failing with OK. Signed-off-by: Chris Laplante Reviewed-by: Peter Maydell --- 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, gchar **words) NamedGPIOList *ngl; bool is_named; bool is_outbound; + bool interception_succeeded = false; g_assert(words[1]); is_named = words[2] != NULL; @@ -431,6 +432,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) if (is_named) { if (ngl->name && strcmp(ngl->name, words[2]) == 0) { qtest_install_gpio_out_intercepts(dev, ngl->name, 0); + interception_succeeded = true; break; } } else if (!ngl->name) { @@ -438,15 +440,22 @@ static void qtest_process_command(CharBackend *chr, gchar **words) for (i = 0; i < ngl->num_out; ++i) { qtest_install_gpio_out_intercepts(dev, ngl->name, i); } + interception_succeeded = true; } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, ngl->num_in); + interception_succeeded = true; } } - irq_intercept_dev = dev; + qtest_send_prefix(chr); - qtest_send(chr, "OK\n"); + if (interception_succeeded) { + irq_intercept_dev = dev; + qtest_send(chr, "OK\n"); + } else { + qtest_send(chr, "FAIL No intercepts installed\n"); + } } else if (strcmp(words[0], "set_irq_in") == 0) { DeviceState *dev; qemu_irq irq; From patchwork Fri Jul 14 23:27:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1808051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=laplante.io header.i=@laplante.io header.a=rsa-sha256 header.s=protonmail3 header.b=aeUhYacE; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R2njM5kFPz20cB for ; Sat, 15 Jul 2023 09:28:39 +1000 (AEST) 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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..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); } +static void test_nrf51_gpio_detect(void) { + QTestState *qts = qtest_init("-M microbit"); + int i; + + // Connect input buffer on pins 1-7, configure SENSE for high level + for (i = 1; i <= 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 = 1; i <= 7; i++) { + // Set pin high + qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", i, 1); + uint32_t actual = qtest_readl(qts, NRF51_GPIO_BASE + NRF51_GPIO_REG_IN); + g_assert_cmpuint(actual, ==, 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 = qtest_readl(qts, NRF51_GPIO_BASE + NRF51_GPIO_REG_IN); + g_assert_cmpuint(actual, ==, 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 still high. + for (i = 1; i <= 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) 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);