From nobody Sun Nov 9 22:38:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551981569055298.46945930099594; Thu, 7 Mar 2019 09:59:29 -0800 (PST) Received: from localhost ([127.0.0.1]:56480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1xIj-0001cp-Vq for importer@patchew.org; Thu, 07 Mar 2019 12:59:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wqY-0002tv-7p for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wqX-0007tx-7X for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:18 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:42108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wqW-0007tQ-Ve for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:17 -0500 Received: by mail-wr1-x429.google.com with SMTP id r5so18398151wrg.9 for ; Thu, 07 Mar 2019 09:30:16 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.30.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=gRQtJP4aVVEtFFsiyWmcf17aJjmb84pPeK7GLf6s4aQ=; b=nA2x8IGHhYXC4el9HoPGyeG/L61RnjMBuU0KffTshnHE0sBUqRZsHPDYiucnQ2pGJ6 VjeN/2IPJnIoaQCpD4bm7DB+fnVmnN0PerW+aQYDxrrZ0xYNhKD0NMQTu+alhGMaBtZe RxytWRtC5KA8t1DHINLQx0h/idhEUgTOncrdQM41EalXw10X8ldy1GS1vslGaRvXQv16 6kplRAT2r8h/MjMsRUtcK2CG65js8SPE2gxn4vM3wmLoHiVPK7UluySK1XGflGCra/iy jY11Nvpszp+s4SWx759O64JjX5oGQSBSMZOD8hKecNp624UGIp1hAG/tRXEzMAuh6DuB Pt2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=gRQtJP4aVVEtFFsiyWmcf17aJjmb84pPeK7GLf6s4aQ=; b=UyUJEH993d37hJYfHkpmgnEnTMGTxhxCoq7eTyxXx7qAE2tYykAgVEcydktvC00viw ZloCbvBghRBzbY8WUlKIjV4K0CDWILVEPbOqhM9dq2WvVxzqjzDrsvIXyxRUFRZW1xGX CDEqbH/0Vb+YlzjHSkZBQs+H9xBk08/51p3Z+2bYdx6QKadWyZjhg8jc5EqhA/m68AcG c47uvWPHGAtLTSlz3FmIIUSXD7fwh1/oDic2Wfdt8NCJkQjiYgmltYa+rr9sNrhKff3P c84wjoK8TeVOSSklnLjMvcSwLfNEXsEnHiGxURI2/BNR5W2UdGhsR4gzbwhx1BBTwhCR yyAg== X-Gm-Message-State: APjAAAXYetQcXOlnAQLOspx4MqCIbgAxbtvgLNhZOXAS22JPm4uN6fKp 928e6L87+1VHY6sJOkrv8+OIqpQa X-Google-Smtp-Source: APXvYqwxF9RRDVViPKi3vbJ7d6T8unXNJ/wR7CvTX4xYNKx0kCV9TPqQ0BykpO0Y8bR2Z3Fz/m6UQw== X-Received: by 2002:a5d:558c:: with SMTP id i12mr7575251wrv.19.1551979815610; Thu, 07 Mar 2019 09:30:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:16 +0100 Message-Id: <1551979804-6060-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> References: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 09/57] tests/libqos: arm/raspi2 machine node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, Emanuele Giuseppe Esposito , lviver@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Add arm/raspi2 machine to the graph. This machine contains a generic-sdhci,= so its constructor must take care of setting it properly when called. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 1 + tests/libqos/arm-raspi2-machine.c | 91 +++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 92 insertions(+) create mode 100644 tests/libqos/arm-raspi2-machine.c diff --git a/tests/Makefile.include b/tests/Makefile.include index b1b03e6..41d248d 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -755,6 +755,7 @@ qos-test-obj-y +=3D $(libqos-pc-obj-y) qos-test-obj-y +=3D tests/libqos/sdhci.o =20 # Machines +qos-test-obj-y +=3D tests/libqos/arm-raspi2-machine.o qos-test-obj-y +=3D tests/libqos/x86_64_pc-machine.o =20 check-unit-y +=3D tests/test-qgraph$(EXESUF) diff --git a/tests/libqos/arm-raspi2-machine.c b/tests/libqos/arm-raspi2-ma= chine.c new file mode 100644 index 0000000..3aff670 --- /dev/null +++ b/tests/libqos/arm-raspi2-machine.c @@ -0,0 +1,91 @@ +/* + * libqos driver framework + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "libqos/malloc.h" +#include "libqos/qgraph.h" +#include "sdhci.h" + +#define ARM_PAGE_SIZE 4096 +#define RASPI2_RAM_ADDR 0 +#define RASPI2_RAM_SIZE 0x20000000 + +typedef struct QRaspi2Machine QRaspi2Machine; + +struct QRaspi2Machine { + QOSGraphObject obj; + QGuestAllocator alloc; + QSDHCI_MemoryMapped sdhci; +}; + +static void *raspi2_get_driver(void *object, const char *interface) +{ + QRaspi2Machine *machine =3D object; + if (!g_strcmp0(interface, "memory")) { + return &machine->alloc; + } + + fprintf(stderr, "%s not present in arm/raspi2\n", interface); + g_assert_not_reached(); +} + +static QOSGraphObject *raspi2_get_device(void *obj, const char *device) +{ + QRaspi2Machine *machine =3D obj; + if (!g_strcmp0(device, "generic-sdhci")) { + return &machine->sdhci.obj; + } + + fprintf(stderr, "%s not present in arm/raspi2\n", device); + g_assert_not_reached(); +} + +static void raspi2_destructor(QOSGraphObject *obj) +{ + QRaspi2Machine *machine =3D (QRaspi2Machine *) obj; + alloc_destroy(&machine->alloc); +} + +static void *qos_create_machine_arm_raspi2(QTestState *qts) +{ + QRaspi2Machine *machine =3D g_new0(QRaspi2Machine, 1); + + alloc_init(&machine->alloc, 0, + RASPI2_RAM_ADDR + (1 << 20), + RASPI2_RAM_ADDR + RASPI2_RAM_SIZE, + ARM_PAGE_SIZE); + machine->obj.get_device =3D raspi2_get_device; + machine->obj.get_driver =3D raspi2_get_driver; + machine->obj.destructor =3D raspi2_destructor; + qos_init_sdhci_mm(&machine->sdhci, qts, 0x3f300000, &(QSDHCIProperties= ) { + .version =3D 3, + .baseclock =3D 52, + .capab.sdma =3D false, + .capab.reg =3D 0x052134b4 + }); + return &machine->obj; +} + +static void raspi2_register_nodes(void) +{ + qos_node_create_machine("arm/raspi2", qos_create_machine_arm_raspi2); + qos_node_contains("arm/raspi2", "generic-sdhci", NULL); +} + +libqos_init(raspi2_register_nodes); --=20 1.8.3.1