All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 35/45] tests/qtest: Add bcm2838 mailbox test stub
Date: Tue, 27 Feb 2024 13:33:04 +0000	[thread overview]
Message-ID: <20240227133314.1721857-36-peter.maydell@linaro.org> (raw)
In-Reply-To: <20240227133314.1721857-1-peter.maydell@linaro.org>

From: Sergey Kambalin <serg.oker@gmail.com>

Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com>
Message-id: 20240226000259.2752893-32-sergey.kambalin@auriga.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
 tests/qtest/bcm2838-mailbox.h | 37 +++++++++++++++++++++
 tests/qtest/bcm2838-mailbox.c | 60 +++++++++++++++++++++++++++++++++++
 tests/qtest/meson.build       |  1 +
 3 files changed, 98 insertions(+)
 create mode 100644 tests/qtest/bcm2838-mailbox.h
 create mode 100644 tests/qtest/bcm2838-mailbox.c

diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h
new file mode 100644
index 00000000000..e9e1f53bc98
--- /dev/null
+++ b/tests/qtest/bcm2838-mailbox.h
@@ -0,0 +1,37 @@
+/*
+ * Declarations for BCM2838 mailbox test.
+ *
+ * Copyright (c) 2023 Auriga LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+typedef struct {
+    uint32_t size;
+    uint32_t req_resp_code;
+} MboxBufHeader;
+
+#define DECLARE_TAG_TYPE(TypeName, RequestValueType, ResponseValueType) \
+typedef struct {                                                        \
+    uint32_t id;                                                        \
+    uint32_t value_buffer_size;                                         \
+    union {                                                             \
+        struct {                                                        \
+            uint32_t zero;                                              \
+            RequestValueType value;                                     \
+        } request;                                                      \
+        struct {                                                        \
+            uint32_t size_stat;                                         \
+            ResponseValueType value;                                    \
+        } response;                                                     \
+    };                                                                  \
+} TypeName
+
+
+int mbox0_has_data(void);
+void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size);
+void mbox1_write_message(uint8_t channel, uint32_t msg_addr);
+int qtest_mbox0_has_data(QTestState *s);
+void qtest_mbox0_read_message(QTestState *s, uint8_t channel, void *msgbuf, size_t msgbuf_size);
+void qtest_mbox1_write_message(QTestState *s, uint8_t channel, uint32_t msg_addr);
diff --git a/tests/qtest/bcm2838-mailbox.c b/tests/qtest/bcm2838-mailbox.c
new file mode 100644
index 00000000000..0928a3dff8e
--- /dev/null
+++ b/tests/qtest/bcm2838-mailbox.c
@@ -0,0 +1,60 @@
+/*
+ * Helper functions to work with BCM2838 mailbox via qtest interface.
+ *
+ * Copyright (c) 2023 Auriga LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/registerfields.h"
+#include "libqtest-single.h"
+#include "bcm2838-mailbox.h"
+
+REG32(MBOX_EXCHNG_REG,          0)
+FIELD(MBOX_EXCHNG_REG, CHANNEL, 0, 4)
+FIELD(MBOX_EXCHNG_REG, DATA,    4, 28)
+
+static uint32_t qtest_mbox0_read_reg32(QTestState *s, uint32_t offset)
+{
+    return qtest_readl(s, MBOX0_BASE + offset);
+}
+
+static void qtest_mbox1_write_reg32(QTestState *s, uint32_t offset, uint32_t value)
+{
+    return qtest_writel(s, MBOX1_BASE + offset, value);
+}
+
+static void qtest_mbox1_write(QTestState *s, uint8_t channel, uint32_t data)
+{
+    uint32_t mbox_reg = 0;
+
+    mbox_reg = FIELD_DP32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL, channel);
+    mbox_reg = FIELD_DP32(mbox_reg, MBOX_EXCHNG_REG, DATA, data);
+    qtest_mbox1_write_reg32(s, MBOX_REG_WRITE, mbox_reg);
+}
+
+int qtest_mbox0_has_data(QTestState *s) {
+    return !(qtest_mbox0_read_reg32(s, MBOX_REG_STATUS) & MBOX_READ_EMPTY);
+}
+
+void qtest_mbox0_read_message(QTestState *s,
+                              uint8_t channel,
+                              void *msgbuf,
+                              size_t msgbuf_size)
+{
+    uint32_t mbox_reg;
+    uint32_t msgaddr;
+
+    g_assert(qtest_mbox0_has_data(s));
+    mbox_reg = qtest_mbox0_read_reg32(s, MBOX_REG_READ);
+    g_assert_cmphex(FIELD_EX32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL), ==, channel);
+    msgaddr = FIELD_EX32(mbox_reg, MBOX_EXCHNG_REG, DATA) << 4;
+    qtest_memread(s, msgaddr, msgbuf, msgbuf_size);
+}
+
+void qtest_mbox1_write_message(QTestState *s, uint8_t channel, uint32_t msg_addr)
+{
+    qtest_mbox1_write(s, channel, msg_addr >> 4);
+}
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 6ea77893f50..e49ce4f0929 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -334,6 +334,7 @@ qtests = {
   'virtio-net-failover': files('migration-helpers.c'),
   'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'),
   'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'),
+  'bcm2838-mbox-property-test' : files('bcm2838-mailbox.c'),
 }
 
 if vnc.found()
-- 
2.34.1



  parent reply	other threads:[~2024-02-27 13:43 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 13:32 [PULL 00/45] target-arm queue Peter Maydell
2024-02-27 13:32 ` [PULL 01/45] hw/arm/sbsa-ref: Simplify init since PCIe is always enabled Peter Maydell
2024-02-27 13:32 ` [PULL 02/45] target/arm: Advertise Cortex-A53 erratum #843419 fix via REVIDR Peter Maydell
2024-02-27 13:32 ` [PULL 03/45] MAINTAINERS: Cover hw/ide/ahci-allwinner.c with AllWinner A10 machine Peter Maydell
2024-02-27 13:32 ` [PULL 04/45] misc: m48t59: replace qemu_system_reset_request() call with watchdog_perform_action() Peter Maydell
2024-02-27 13:32 ` [PULL 05/45] misc: pxa2xx_timer: " Peter Maydell
2024-02-27 13:32 ` [PULL 06/45] xlnx-versal-ospi: disable reentrancy detection for iomem_dac Peter Maydell
2024-02-27 13:32 ` [PULL 07/45] hw/arm: Use TYPE_OR_IRQ when connecting STM32L4x5 EXTI fan-in IRQs Peter Maydell
2024-02-27 13:32 ` [PULL 08/45] tests/qtest: Check that EXTI fan-in irqs are correctly connected Peter Maydell
2024-02-27 13:32 ` [PULL 09/45] pl031: Update last RTCLR value on write in case it's read back Peter Maydell
2024-02-27 13:32 ` [PULL 10/45] block: m25p80: Add support of mt35xu02gbba Peter Maydell
2024-02-27 13:32 ` [PULL 11/45] arm: xlnx-versal-virt: Add machine property ospi-flash Peter Maydell
2024-02-27 13:32 ` [PULL 12/45] arm/ptw: Handle atomic updates of page tables entries in MMIO during PTW Peter Maydell
2024-02-27 13:32 ` [PULL 13/45] system/bootdevice: Don't unregister reset handler in restore_boot_order() Peter Maydell
2024-02-27 13:32 ` [PULL 14/45] include/qom/object.h: New OBJECT_DEFINE_SIMPLE_TYPE{, _WITH_INTERFACES} macros Peter Maydell
2024-02-27 13:32 ` [PULL 15/45] hw/core: Add documentation and license comments to reset.h Peter Maydell
2024-02-27 13:32 ` [PULL 16/45] hw/core: Add ResetContainer which holds objects implementing Resettable Peter Maydell
2024-02-27 13:32 ` [PULL 17/45] hw/core/reset: Add qemu_{register, unregister}_resettable() Peter Maydell
2024-02-27 13:32 ` [PULL 18/45] hw/core/reset: Implement qemu_register_reset via qemu_register_resettable Peter Maydell
2024-02-27 13:32 ` [PULL 19/45] hw/core/machine: Use qemu_register_resettable for sysbus reset Peter Maydell
2024-02-27 13:32 ` [PULL 20/45] docs/devel/reset: Update to discuss system reset Peter Maydell
2024-02-27 13:32 ` [PULL 21/45] hw/arm/bcm2836: Split out common part of BCM283X classes Peter Maydell
2024-02-27 13:32 ` [PULL 22/45] hw/arm/bcm2853_peripherals: Split out common part of peripherals Peter Maydell
2024-02-27 13:32 ` [PULL 23/45] hw/arm/raspi: Split out raspi machine common part Peter Maydell
2024-02-27 13:32 ` [PULL 24/45] hw/arm: Introduce BCM2838 SoC Peter Maydell
2024-02-27 13:32 ` [PULL 25/45] hw/arm/bcm2838: Add GIC-400 to " Peter Maydell
2024-02-27 13:32 ` [PULL 26/45] hw/gpio: Add BCM2838 GPIO stub Peter Maydell
2024-02-27 13:32 ` [PULL 27/45] hw/gpio: Implement BCM2838 GPIO functionality Peter Maydell
2024-02-27 13:32 ` [PULL 28/45] hw/gpio: Connect SD controller to BCM2838 GPIO Peter Maydell
2024-02-27 13:32 ` [PULL 29/45] hw/arm: Add GPIO and SD to BCM2838 periph Peter Maydell
2024-02-27 13:32 ` [PULL 30/45] hw/arm: Introduce Raspberry PI 4 machine Peter Maydell
2024-02-27 13:33 ` [PULL 31/45] hw/arm/raspi4b: Temporarily disable unimplemented rpi4b devices Peter Maydell
2024-02-27 13:33 ` [PULL 32/45] hw/arm: Add memory region for BCM2837 RPiVid ASB Peter Maydell
2024-02-27 13:33 ` [PULL 33/45] hw/arm/bcm2838_peripherals: Add clock_isp stub Peter Maydell
2024-02-27 13:33 ` [PULL 34/45] tests/avocado/boot_linux_console.py: Add Rpi4b boot tests Peter Maydell
2024-02-27 13:33 ` Peter Maydell [this message]
2024-02-27 13:33 ` [PULL 36/45] tests/qtest/bcm2828-mailbox: Add mailbox test constants Peter Maydell
2024-02-27 13:33 ` [PULL 37/45] tests/qtest/bcm2828-mailbox: Add mailbox tests tags. Part 1 Peter Maydell
2024-02-27 13:33 ` [PULL 38/45] tests/qtest/bcm2828-mailbox: Add mailbox tests tags. Part 2 Peter Maydell
2024-02-27 13:33 ` [PULL 39/45] tests/qtest/bcm2828-mailbox: Add mailbox tests tags. Part 3 Peter Maydell
2024-02-27 13:33 ` [PULL 40/45] tests/qtest/bcm2828-mailbox: Add mailbox property tests. Part 1 Peter Maydell
2024-02-27 13:33 ` [PULL 41/45] tests/qtest/bcm2828-mailbox: Add mailbox property tests. Part 2 Peter Maydell
2024-02-27 13:33 ` [PULL 42/45] tests/qtest/bcm2828-mailbox: Add mailbox property tests. Part 3 Peter Maydell
2024-02-27 13:33 ` [PULL 43/45] hw/misc/bcm2835_property: Add missed BCM2835 properties Peter Maydell
2024-02-27 13:33 ` [PULL 44/45] tests/qtest/bcm2828-mailbox: Append added properties to mailbox test Peter Maydell
2024-02-27 13:33 ` [PULL 45/45] docs/system/arm: Add RPi4B to raspi.rst Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240227133314.1721857-36-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.