From nobody Tue Nov 26 08:34:00 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1709041417; cv=none; d=zohomail.com; s=zohoarc; b=fFcq2YC8tRf5OTAP74prYrR3MjtMgaKSK4rDr3+ehzj7TkYJTannz8F5DxUBY3N4jaWE95YjIERkM0wJwLIBG8TheFDeHQGAtrSEJXWmpHFTBoXtn3/0XNRlFYZCzCAjRRXIR/o85eCO2CYyythWUPl9nKRPrP71c/iQpZhDsUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709041417; h=Content-Transfer-Encoding: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:Cc; bh=+8/ybQwcfm79xtd0ngd5/n2BlvfQRgOhwhHQ/JtQPWs=; b=Bq3YwU0zNIKOo6UbRRzad7+/WnXBbKMvGADYWeFEyKO9iy0fG7lzQlzF7BF5hcn9VyZZqDppcG4TQAiU+q3gKdLdIIlPp6TJcINawKPEASbHLdJRTUXV9JbdaIZFrmDtxTutFIdpCqvtuIltAAKteaj5llXmCVCrX9whdF1jUqE= 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 1709041417557318.57244553899204; Tue, 27 Feb 2024 05:43:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rexap-0000uC-7u; Tue, 27 Feb 2024 08:34:00 -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 1rexaX-0000oW-FB for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:41 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rexaQ-0002v2-Sc for qemu-devel@nongnu.org; Tue, 27 Feb 2024 08:33:41 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-33ddebaf810so959429f8f.2 for ; Tue, 27 Feb 2024 05:33:34 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i13-20020adfe48d000000b0033ae7d768b2sm11319552wrm.117.2024.02.27.05.33.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 05:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709040813; x=1709645613; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+8/ybQwcfm79xtd0ngd5/n2BlvfQRgOhwhHQ/JtQPWs=; b=rYo2+mJa/Tz1qSKIc/UeXa9FgEQR6BLL7bCdu6WhmdKIcB1VqbbBvDz7qKeRvZ+Ujf sBgybkz9Otm5+JC5oTTOOyosMKxOaM+hCIDPc1KR4EMLvbth4prlz8Z3LYesYEpb7EnD XPWLQD6IG9y3SNbsEBF8K53Ye+ti2bVS1XNG22zJX0DaPcNTbgD8l4dHR8rz/SvNC2aO 6xY8KfdcLOf9yKrhE8411H1gq1KnoTVu0YajXiA2/3xPdB2w0JEW6aOdmWlq0zvk+1Ez NfXJdj7vZGItlk399t1MbuDnimowFh0N93eJIY1s8JWGfdTJzmkPBnfr9mh20YBwGEq4 CVQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709040813; x=1709645613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+8/ybQwcfm79xtd0ngd5/n2BlvfQRgOhwhHQ/JtQPWs=; b=RMI6jcTZjhrqKlrM6ygzJFS+JlxlyITj0sJXtbQiASNhw39y3oSlYLKjKAnH2O8R/+ ZA3gJIsvVDI9/tM6JQZu3+S7KDRE+fo7ovZtSBbc6QsA/ckpzUCjcE7WoPP6kooEZJtO FD/geXUpBsL3EjQIauBDhOiAVvEdzW9VzzWZsbOEytA9aSvjrN6gwyy8gu5T5AG2uneV J7n1SJtR7aJT+uHbvxsTg8wdoXum0HTEYxVgapHT5qklUEBQoaJTn+E07zMuCr5Z19Bi m+PKw46MA+XzvcC422BSQlvgmAiOOInmXNXByOLMqSrKeEupzOVzJtVAnDnIEftJBKVV qdEQ== X-Gm-Message-State: AOJu0Yz8GEvH8sYxskxOkS/uonYzblN9bCj7NK2+eIrhCe3wzmWRpNB4 tXk7YV1DvLcGzEaRM1H4ciKPN+Ii6lPiXiEpO3YK7SQwSIhKkk1ebD1tqKinW21B9voL5M8EKpg s X-Google-Smtp-Source: AGHT+IFpP4xDPIarwKvph/hIEp6gi4hOQaosnkPjDDFTP43WrZ3ZxF+dAhnwxH4yj9er/OMhirZg8A== X-Received: by 2002:a05:6000:136a:b0:33d:2629:c518 with SMTP id q10-20020a056000136a00b0033d2629c518mr6517686wrz.64.1709040813628; Tue, 27 Feb 2024 05:33:33 -0800 (PST) From: Peter Maydell 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 Message-Id: <20240227133314.1721857-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227133314.1721857-1-peter.maydell@linaro.org> References: <20240227133314.1721857-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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, 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 @linaro.org) X-ZM-MESSAGEID: 1709041418716100001 Content-Type: text/plain; charset="utf-8" From: Sergey Kambalin Signed-off-by: Sergey Kambalin Message-id: 20240226000259.2752893-32-sergey.kambalin@auriga.com Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell --- 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 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/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 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/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 =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