From patchwork Wed Jul 26 03:31: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: 1812945 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=3rQrH1JR; 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 4R9fdW1SPQz1ybX for ; Wed, 26 Jul 2023 13:34:07 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOVGD-0005N8-Gf; Tue, 25 Jul 2023 23:32:25 -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 1qOVG2-0005MJ-JL; Tue, 25 Jul 2023 23:32:14 -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 1qOVG0-0006Qw-Qx; Tue, 25 Jul 2023 23:32:14 -0400 Date: Wed, 26 Jul 2023 03:31:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690342322; x=1690601522; bh=CYxoj1AwwohRjVj/umFNzIRU2yOes9wWnbtuyhtBtvs=; 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=3rQrH1JRxpN/n3XGP+TAvZcWuLa8MzgTzVY+rpDoauM6WVuZ1al1V/BPAxlSUZP0W WI8A4QaSiBbMAZdOtk2Nd1Ehh7oTa4TkUPHRJD+SoNpPmF9Xsi6zlROxAhy5ffr4BL BGdHkAEuGO2VM5qczoGxq0Mru7GjaPb4Cd8i9ucDYaGYynUGRMIe0Ye+ymdN4VbEKS jWcZ5ciEhLXWwO1sEzoNgsYOKi45hrjlSGiHzaOm5UtNrKoun4hizY9+EgDhR8qzJ1 saaQkQF/EBqWeN1LYhJRCoqOK6as/F9g3/ZNQUrmx9WBWYgXn4YWXP4+srRb9Grm0/ EQKvxRMkeXagA== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v2 1/6] hw/gpio/nrf51: implement DETECT signal Message-ID: <20230726030450.757462-2-chris@laplante.io> In-Reply-To: <20230726030450.757462-1-chris@laplante.io> References: <20230726030450.757462-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 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 = 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 Wed Jul 26 03:31:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1812940 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=MAFK/OeL; 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 4R9fcF5Mwpz1ybX for ; Wed, 26 Jul 2023 13:33:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOVGG-0005Ou-4F; Tue, 25 Jul 2023 23:32:28 -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 1qOVG5-0005NA-Qh; Tue, 25 Jul 2023 23:32:23 -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 1qOVG3-0006vQ-R3; Tue, 25 Jul 2023 23:32:17 -0400 Date: Wed, 26 Jul 2023 03:31:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690342333; x=1690601533; bh=HgHvDYfqmVARdVYQabwTUqO/6ANgGN89IeXI5IaKM+I=; 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=MAFK/OeLLnE+b1UAHimaQKRWlnZuR82x+yOTce/CucuOEEROTpzvZ0ZuBMvqihsxP Q0n3aTybwSEjePB9Fal9yX2CICP5tR5K3IRebS5aDxlPQfyX+PUibhAMB1GnAaQi1q 769yHKqsbme95DU3J0wSRdOdqy6/ndaOXIHkoofXv+GLTm3yVzIbYE9BUVmEjKWHlY eXmDizenh65toc1pGCwNBHYq14+r0Ewe5xeIVA33koxPddvvRfMiohYUq+flWefJxe hE4Oti97rxIhIqcGgRsCANufkcLkMZr1UreeAoDg5hdBmeV5pkEqCUKVx0pU2ICuxD JyveTLWj9Q6jQ== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v2 2/6] qtest: factor out qtest_install_gpio_out_intercept Message-ID: <20230726030450.757462-3-chris@laplante.io> In-Reply-To: <20230726030450.757462-1-chris@laplante.io> References: <20230726030450.757462-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 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..1c92e5a6a3 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_intercept(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; @@ -415,12 +424,7 @@ static void qtest_process_command(CharBackend *chr, gchar **words) 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); + qtest_install_gpio_out_intercept(dev, ngl->name, i); } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, From patchwork Wed Jul 26 03:32:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1812941 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=7D46uXQo; 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 4R9fcF5VPfz1ydm for ; Wed, 26 Jul 2023 13:33:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOVGF-0005ON-3f; Tue, 25 Jul 2023 23:32:27 -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 1qOVGB-0005NR-0W for qemu-devel@nongnu.org; Tue, 25 Jul 2023 23:32:25 -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 1qOVG8-00070p-TS for qemu-devel@nongnu.org; Tue, 25 Jul 2023 23:32:22 -0400 Date: Wed, 26 Jul 2023 03:32:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690342336; x=1690601536; bh=yb1pYUgxIoRCfHqojFYKWD+C5vWzpg6C6lYB0UTVhpk=; 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=7D46uXQokYjAjnS1fVHbP23gWtD8PczmLhVwsIA9A8GugWRVCaFrDKcFJhSv4yeCz P6MzvXHvFzk06si6uOsySS3cSflPRGc/0U/8vqsXmxLqnCwExmI45HS0Ro/KoIFBaG /y64nzapqZEi+odpuK0qk9a4IT4yX4l+oAzaKmFbvwK9E3bgwQpHZfEjIwP62SOlil i8ASCW5KbQw9Oiwpp/ddThA7dszIToc7nj6EanFjvdgjkc6GAgeABI3hblRXal/kTY NnngN8mPARsfI/QVr2UM9zGsbqnxNQTVEGh9EvZ7z7L+BKSRRhqOF/eaZObwG1jPQp XoQNWOUOEc30A== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v2 3/6] qtest: implement named interception of out-GPIO Message-ID: <20230726030450.757462-4-chris@laplante.io> In-Reply-To: <20230726030450.757462-1-chris@laplante.io> References: <20230726030450.757462-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 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 | 24 ++++++++++++++++-------- tests/qtest/libqtest.c | 6 ++++++ tests/qtest/libqtest.h | 11 +++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 1c92e5a6a3..7fd8546ed2 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -397,8 +397,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); @@ -417,14 +421,18 @@ 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) { - qtest_install_gpio_out_intercept(dev, 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) { + qtest_install_gpio_out_intercept(dev, ngl->name, 0); + break; + } + } else if (!ngl->name) { + int i; + for (i = 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); } +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 Wed Jul 26 03:32:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1812943 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=Lb9zVSPl; 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 4R9fdC4jKjz1ybX for ; Wed, 26 Jul 2023 13:33:51 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOVGU-0005VJ-TR; Tue, 25 Jul 2023 23:32:42 -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 1qOVGS-0005UZ-I5; Tue, 25 Jul 2023 23:32:40 -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 1qOVGQ-0007el-Mg; Tue, 25 Jul 2023 23:32:40 -0400 Date: Wed, 26 Jul 2023 03:32:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690342356; x=1690601556; bh=+u4hReE1HgN+L3e9IZjGDlx7yBSheJRATufqrFnZkUo=; 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=Lb9zVSPlbAfonms12OjHRKO9w1+s48tJzsOFNGYs5zx+kLSpkNSLDd/XFRL4S6H/8 IU/7P5uAGOeIxwSgcUz/AXiiASlxRkPSWUsfPHxXZLKjN1OpCpiwzIXQys9emLWUR3 hb29xnFBveA03ghqPXVmqvScTauRLuMMo3xqTO4ueq/gEy67pC9YdxtXHPBOlZa+tS /FrnfU2aoRHZGBc07z5men9ypjkBIqF9L86VOUCh78Q1tVozRe3Tb7XQjo1+rCrEo3 2/aJJOCby2NAPiqvFX0PMGcRd/Xpy+DOkx6UHwUzz0lf6cKAku5eYOw52EgFsuVzmS wtCUc/p6BIZeg== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v2 4/6] qtest: bail from irq_intercept_in if name is specified Message-ID: <20230726030450.757462-5-chris@laplante.io> In-Reply-To: <20230726030450.757462-1-chris@laplante.io> References: <20230726030450.757462-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 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 7fd8546ed2..1719bbddc3 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -410,6 +410,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) { @@ -421,7 +427,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 Wed Jul 26 03:32: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: 1812946 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=dl4edW6M; 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 4R9fdw1zJvz1ybX for ; Wed, 26 Jul 2023 13:34:28 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOVGP-0005TR-1y; Tue, 25 Jul 2023 23:32:37 -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 1qOVGN-0005RU-Nn; Tue, 25 Jul 2023 23:32:36 -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 1qOVGL-0007dv-QZ; Tue, 25 Jul 2023 23:32:35 -0400 Date: Wed, 26 Jul 2023 03:32:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690342351; x=1690601551; bh=EtuSgrXwZhMLjgs507zxk5ZwlCfmtLk/i7vXQX5lOqo=; 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=dl4edW6Mlfg15e9sPMpyi5q4xwjLYviBzeHQTvzzJHwEx113gUuVNHHdc4rErNAed 3rB7t5Wm3fQa7h1PNBslDQF6su/Zsp5axNol/OgZ1PL8FqQX/L8L5ZlgUh9+ZfuPOv 8pq/Wj3fMimCA0NNZmYV2ny2At6OLkN5f4GsNFoDbUr79EvnFHbysYJ6zxDBOoZl7d G7JTqlkIH743TsS9XWqsWF61Saxn2mDXa0jfTXlDjLN0EWbIoYjME+METNWIimzzmS pzDtGX6v4yh0JskOx5Qq125WtiqCRay3xfOdT2oaJ25zICW/oevoxd6tzH5Xrjef8r tqvDf6TQzwIkg== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v2 5/6] qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed Message-ID: <20230726030450.757462-6-chris@laplante.io> In-Reply-To: <20230726030450.757462-1-chris@laplante.io> References: <20230726030450.757462-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 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 1719bbddc3..c9751f527f 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_intercept(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_intercept(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 Wed Jul 26 03:32:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Laplante X-Patchwork-Id: 1812944 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=GVfn75Kw; 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 4R9fdD0ys3z1ydm for ; Wed, 26 Jul 2023 13:33:52 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOVGa-0005We-5y; Tue, 25 Jul 2023 23:32:48 -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 1qOVGX-0005Vj-CZ; Tue, 25 Jul 2023 23:32:45 -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 1qOVGV-0007fZ-Rl; Tue, 25 Jul 2023 23:32:45 -0400 Date: Wed, 26 Jul 2023 03:32:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=laplante.io; s=protonmail3; t=1690342361; x=1690601561; 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=GVfn75KwrfZJsb3XFefGW4/6uIkDXdNAefokYpn+uX1Ws0SlleU56hcC22cL/b06q JNIn/aMSWGRan2nV1M4AXe/YGGgLrKvkWtjn41/VTQzT7llgW7NXSdgLUrRTb0NTSE x+ksqXNcRniO8A5UqvDlpa1Aq8iCid+sRToO2fkG4gXydeHJ2pPBBq9+VSgpywAZ3n LXCubIaJXe18R0B4qCgZr512voanFUu4Fh7hr65P2eTxSfjAP6+qFHbnyw/wqpgw2Z 10y31yP78Oqw+dqjx/EqzfxFF5efppNNYu9Dj4QxXqDcTiL4LppL/ctvquG393MqaI HWedNZMc+RUNw== To: qemu-devel@nongnu.org From: Chris Laplante Cc: Joel Stanley , Peter Maydell , qemu-arm@nongnu.org, Chris Laplante Subject: [PATCH v2 6/6] qtest: microbit-test: add tests for nRF51 DETECT Message-ID: <20230726030450.757462-7-chris@laplante.io> In-Reply-To: <20230726030450.757462-1-chris@laplante.io> References: <20230726030450.757462-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 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); } +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/gpio", "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);