From patchwork Tue Feb 27 13:33:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 776216 Delivered-To: patch@linaro.org Received: by 2002:adf:a113:0:b0:33d:f458:43ce with SMTP id o19csp159719wro; Tue, 27 Feb 2024 05:43:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXNarkotl95MaHy6gBtVlGUxB1BZwGZHCXuAiNEIn6NDts9t6DDHsVM+zQLbJHHRXtOU2mUwKc8R35lLFqpHDue X-Google-Smtp-Source: AGHT+IHUxObnzzcCguXsNG6Ad+/YeuFm0bWSzF/OybZteaGIef3DL+RHps/6/PgBMEp4ONE+kApg X-Received: by 2002:a05:6871:b26:b0:21e:9eac:b0a3 with SMTP id fq38-20020a0568710b2600b0021e9eacb0a3mr11058781oab.24.1709041417252; Tue, 27 Feb 2024 05:43:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709041417; cv=none; d=google.com; s=arc-20160816; b=wQIqKEWsTbHIvO0p6cjN54tDcnTAen2+9h89527RJ+1jgZ1ABX4gdh5ALTvUgE/Vio d4NYKw51b2EJ8hdUaDkIXWuQKQOVREyW2Xf6Cgzhz0dWaZqP+UYFbKPdrIHGTcsskKxL xdkOiH20rvIu3/Hf0F2AMEIZIDArYAOvsBgG0U8Y2ihBKeM+nyjeZLpzfgHVpkD1WFJl UNK6xJ4ec7wXbrp+O2D82tyX3OsjRoldUu/v7e1AnkppH/g1R9qu0xqXhP4T7skEWfBH BB0z3GapPQQ+nd5ymVxgKcBIu4buQtU+FG2mZ0pcTz67pOoaPc6W4haPxqtqo/9JysJr TXzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+8/ybQwcfm79xtd0ngd5/n2BlvfQRgOhwhHQ/JtQPWs=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=cyzwb5DRVc9EwtSDc6Vx6gxH1sCohQmoaEN0aw/9B3lSM0T+Yq37ZnIOCQYcL7CNUO 9z7QAwZtpS57qb8J+b4gewdnIYp2/RrZjkbR1qPZEQoWeF6Dj50yaqfSMu7lgozMWfZE 65qm2XqwCLfp88c+5lCPh9RAMpepr5Fboq0TYKR9EPhaKNEam1ohSuVEZ/F6SNL2p5hM S2wMvO2a746zbjGNyXoBuQiD9TsQ53frqE/KyC74SzKB0BVZ/KFWuDKaGOBwMttB8Mpy SaB2GvCsbwbU1orEJGkb4+tDPpq3c0+nqATfZmH1kRG0fILnHTLfOKaZfuyiS6hb0/5f 0eXw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rYo2+mJa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c8-20020a05620a200800b00787b3f280c2si7190904qka.123.2024.02.27.05.43.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Feb 2024 05:43:37 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rYo2+mJa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 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()