From nobody Thu Nov 14 17:53:38 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1708906055; cv=none; d=zohomail.com; s=zohoarc; b=lgFKKKwGpVT6v5pTC8q3ByuIwv6eQh8QUeMd7vazFzhGUi/Fsxo+5tOCHRrdpmAB+5GD5VcEXjYVZfTXkETvQtuxUsAsybihO4KM2OU28vNVXiXO4KqVMQfYiVCZKld0mwBlpJNyNrNrBYHHfc3ZqVaWihtyFUFUuobtAGcPIlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708906055; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m0t+xmx/PNLJX3De7wXTVpzxGfzPKHqSNh1RXOyeiwA=; b=D41BNNWVh9LZn9WiH6elLZzebnyeZrH/Oxp6YJrZY+NQUeFRFcCt6dDafcgxOpRL7Vv1P6j4ImNnip4DNO/VuS9F2moiz46ap606xnfLYRXtvmwx0K33pciR/GwhqBE3ao6nVO+SIvDcxxy+uz2DPsqbbx79kmnr2nf+Ie3+yHE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708906055092255.796001830818; Sun, 25 Feb 2024 16:07:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reOUd-0000TM-7y; Sun, 25 Feb 2024 19:05:18 -0500 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 1reOT9-0006ug-6g; Sun, 25 Feb 2024 19:03:44 -0500 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reOT7-0000YS-Bl; Sun, 25 Feb 2024 19:03:42 -0500 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-608fb59fe4aso3114287b3.0; Sun, 25 Feb 2024 16:03:40 -0800 (PST) Received: from localhost.localdomain ([201.203.117.224]) by smtp.gmail.com with ESMTPSA id t18-20020a818312000000b00607bfa1913csm938171ywf.114.2024.02.25.16.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 16:03:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708905820; x=1709510620; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m0t+xmx/PNLJX3De7wXTVpzxGfzPKHqSNh1RXOyeiwA=; b=luKEJ+MjwQmFCHlZuU5Z/Nzg/SCvXC35fi3bynSP/ZgxHVVpYPi9LSvvq376KFzrFy WIvRvhJdzc0Oq/v/hNCHzSP3prvzzJ7MShc97ClrBpMuW4K2W3Ac8pB41KoZ9CCkp27E aKoDPyb4VAucBF8pgFIp+7hMbX7uShutxmaSeKupbdSaCB2v+ZtV0f/7BU54ur8dhz+b h9kFWW3X+o1VlliKmTW3y9e5vNErGuXCszzIWRh/gN6bFpd2jDkYDK1CBfKaLl2MhVKi iYF8GHF5N/I4vZ4OGrHsJcLyxQJf4tJuTja3YHuXs34WtAgaWWH7cyw9xE4yGW0n2dwJ AtKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708905820; x=1709510620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m0t+xmx/PNLJX3De7wXTVpzxGfzPKHqSNh1RXOyeiwA=; b=Zyx0eXbVfzNJ6IxFcqMZy3udQ5B7sTbeLKJ6u2KuMQ3yoJbq6Qcb9aozZc9gtt+m3E 8lii+jly6VOP3O5ycPi0uBpmAd6PLLOZV55pTDtYORQfgpZZUz1Eu50VKSVlaWaQv+AG utyTvU33gfk4HhHC5Fri1x/IrKTvwVQkcrTxAxXY4GfVSr3/rHQIWhuAQ7mmlVYfnsZU WAdXYWpRXTYIwfBcL2636tMHYrfTsxZsCKsUp4D7BR25vfErHAzSfZGuNZ0ozcSKaE5f UYOT9Djzc9hkIlcfPHmyboqxjN/Febuny8/uHWoXUMTqiJkIfeT8ebNlh19q118txNl3 TrFw== X-Gm-Message-State: AOJu0Yyy2ADaTpeMatrAh+S/oQ+rZJ1tdiHVhJh4YeoG6obgsYUSofVl XHUG2qpl1spxcg6C2mO4DcAbfs9m51xW4+QRtV3+vRoVBO14URx9lhB3R5N0+6bZLQ== X-Google-Smtp-Source: AGHT+IE9vTAx6KiqS/rF12DlK3VXUHC+mrQV9GTM2IvSyDC50MbqpBBdKOK/N81PfUQ8wTFexnOJVw== X-Received: by 2002:a81:af67:0:b0:608:ba29:9a46 with SMTP id x39-20020a81af67000000b00608ba299a46mr4371965ywj.12.1708905819882; Sun, 25 Feb 2024 16:03:39 -0800 (PST) From: Sergey Kambalin X-Google-Original-From: Sergey Kambalin To: qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Sergey Kambalin Subject: [PATCH v6 31/41] Add mailbox test stub Date: Sun, 25 Feb 2024 18:02:49 -0600 Message-Id: <20240226000259.2752893-32-sergey.kambalin@auriga.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240226000259.2752893-1-sergey.kambalin@auriga.com> References: <20240226000259.2752893-1-sergey.kambalin@auriga.com> 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=2607:f8b0:4864:20::112f; envelope-from=serg.oker@gmail.com; helo=mail-yw1-x112f.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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 @gmail.com) X-ZM-MESSAGEID: 1708906057141100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sergey Kambalin Reviewed-by: Peter Maydell --- tests/qtest/bcm2838-mailbox.c | 60 +++++++++++++++++++++++++++++++++++ tests/qtest/bcm2838-mailbox.h | 37 +++++++++++++++++++++ tests/qtest/meson.build | 1 + 3 files changed, 98 insertions(+) create mode 100644 tests/qtest/bcm2838-mailbox.c create mode 100644 tests/qtest/bcm2838-mailbox.h diff --git a/tests/qtest/bcm2838-mailbox.c b/tests/qtest/bcm2838-mailbox.c new file mode 100644 index 0000000000..0928a3dff8 --- /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 late= r. + * 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 dat= a) +{ + uint32_t mbox_reg =3D 0; + + mbox_reg =3D FIELD_DP32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL, channel); + mbox_reg =3D 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 =3D qtest_mbox0_read_reg32(s, MBOX_REG_READ); + g_assert_cmphex(FIELD_EX32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL), =3D=3D= , channel); + msgaddr =3D 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 ms= g_addr) +{ + qtest_mbox1_write(s, channel, msg_addr >> 4); +} diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h new file mode 100644 index 0000000000..e9e1f53bc9 --- /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 late= r. + * 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 ms= g_addr); diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 6ea77893f5..e49ce4f092 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -334,6 +334,7 @@ qtests =3D { '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'), } =20 if vnc.found() --=20 2.34.1