From nobody Tue Oct 28 01:56:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515016308204318.1893491620474; Wed, 3 Jan 2018 13:51:48 -0800 (PST) Received: from localhost ([::1]:38411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqws-00026c-EB for importer@patchew.org; Wed, 03 Jan 2018 16:51:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqup-0000gl-6u for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWqun-0003oc-R8 for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:39 -0500 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:46729) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWqun-0003oH-Ls for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:37 -0500 Received: by mail-qk0-x242.google.com with SMTP id b132so3325037qkc.13 for ; Wed, 03 Jan 2018 13:49:37 -0800 (PST) Received: from x1.lan ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id l80sm1237566qki.96.2018.01.03.13.49.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 13:49:36 -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 :mime-version:content-transfer-encoding; bh=NfMG68vXxpxUyyWS6o5oWMAME+jPMdrNzSUeuMGlZzc=; b=iPeCv2G78Hy7ThVwbmFOuphV6PBCyxC5LtRY1YvZMAWHo+ghEjGRW8MARJud4p/ZGY blp8NSDYCNzTxjGA8iFXq1q++SOzoZN9nvnOQvpH1hE5eytYRaPggsTXCITdhd35MLO7 bwrwNWzSWFp/EvXJoRsiDBTcDJJGKCCyA6sxBF3C74sTU6HBLt21sq0sO50L8FrLKrE5 2DrcQArxbK/izXVmBG+Zc4lcSyfcFpcSTRJfZw9oygRL7LKjwJN0MGy8Df9MpiWnqgs5 o2Vn4rOsngQUT8ZeDZtDFy54hObalQTYuJsVlOBpKWdEhifhSlNxkKWL26gLV8EvfQay UzDA== 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:mime-version:content-transfer-encoding; bh=NfMG68vXxpxUyyWS6o5oWMAME+jPMdrNzSUeuMGlZzc=; b=alGlLkK5QBuszVaXa/h7lXicwSQRUIrX7k0uxDerRYlZtnUjfeZJpvFpNELAuxDSxG Y08ri1UGMPSIP3xPCwsXCreJQMe2jJGS7yb2xSgzjs6liT/PAun1M78bvZzRllizXiHF lD2ZSEuF0RzpTDRvFtAUjiu9IYt4PLstE2OFm96PNoGibZc+Ou2nsuPIhkebfvKgbXXT p4cfBsdZKnbK46g92687ILKQTMe0lxFjR3b6KGHSkSu/ppz3aOry4w1a5jq0hhrsTiAM Dwk/k5MrWu3wRo+ZJGG+6Ss8G+hipTLEfBMAlYsbJFK0Pt5/rKhJS2pBXmY8FjLe+ah1 SU/Q== X-Gm-Message-State: AKGB3mIKCjdlyGX2cJ/NqhRbL++ZlIE/uY1Nu2uvENl7yBQqproFkk1a Ugq7oHr6AQxx/SaotuVb2Fw= X-Google-Smtp-Source: ACJfBourNIpXlyc7+Rc5FliqZq6Eu1l6f9xRaSS3Yj5VWgrAZjy9X2cFpUltGk/Q5wF/6/v+/jmDLw== X-Received: by 10.55.99.75 with SMTP id x72mr3672467qkb.258.1515016177034; Wed, 03 Jan 2018 13:49:37 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell , Eric Blake , Paolo Bonzini , Kevin Wolf , Eduardo Habkost , "Daniel P . Berrange" , Stefan Hajnoczi Date: Wed, 3 Jan 2018 18:49:22 -0300 Message-Id: <20180103214925.16677-2-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103214925.16677-1-f4bug@amsat.org> References: <20180103214925.16677-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH v2 1/4] sdbus: add a QMP command to access a SDBus 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: "Edgar E . Iglesias" , Thomas Huth , qemu-devel@nongnu.org, Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Use Base64 to serialize the binary blobs in JSON. So far at most 512 bytes will be transfered, which result in a 684 bytes payload. Since this command is intented for qtesting, it is acceptable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- qapi-schema.json | 41 +++++++++++++++++++++++++++++++++ hw/sd/sdbus-qmp.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ stubs/qmp_sdbus.c | 12 ++++++++++ hw/sd/Makefile.objs | 2 +- stubs/Makefile.objs | 1 + 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 hw/sd/sdbus-qmp.c create mode 100644 stubs/qmp_sdbus.c diff --git a/qapi-schema.json b/qapi-schema.json index 18457954a8..be26e8cd34 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3200,3 +3200,44 @@ # Since: 2.11 ## { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } + +## +# @SDBusCommandResponse: +# +# SD Bus command response. +# +# @base64: the command response encoded as a Base64 string, if any (option= al) +# +# Since: 2.11 +## +{ 'struct': 'SDBusCommandResponse', 'data': {'*base64': 'str'} } + +## +# @x-debug-sdbus-command: +# +# Execute a command on a SD Bus return the response (if any). +# +# @qom-path: the SD Bus path +# @command: the SD protocol command to execute in the bus +# @arg: a 64-bit command argument (optional) +# @crc: the command/argument CRC (optional) +# +# Returns: the response of the command encoded as a Base64 string +# +# Since: 2.11 +# +# -> { "execute": "x-debug-sdbus-command", +# "arguments": { "qom-path": "/machine/unattached/device[32]/sd.0", +# "command": 0x01 +# } +# } +# <- { "return": {'base64': 'A=3D'} } +# +## +{ 'command': 'x-debug-sdbus-command', + 'data': { 'qom-path': 'str', + 'command': 'uint8', + '*arg': 'uint64', + '*crc': 'uint16' }, + 'returns': 'SDBusCommandResponse' +} diff --git a/hw/sd/sdbus-qmp.c b/hw/sd/sdbus-qmp.c new file mode 100644 index 0000000000..8c4b6f2aee --- /dev/null +++ b/hw/sd/sdbus-qmp.c @@ -0,0 +1,65 @@ +/* + * SD card bus QMP debugging interface (for QTesting). + * + * Copyright (c) 2017 ? + * + * Author: + * Philippe Mathieu-Daud=C3=A9 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ +#include "qemu/osdep.h" +#include "hw/sd/sd.h" +#include "qmp-commands.h" + +SDBusCommandResponse *qmp_x_debug_sdbus_command(const char *qom_path, + uint8_t command, + bool has_arg, uint64_t arg, + bool has_crc, uint16_t crc, + Error **errp) +{ + uint8_t response[16 + 1]; + SDBusCommandResponse *res; + bool ambiguous =3D false; + Object *obj; + SDBus *sdbus; + int sz; + + obj =3D object_resolve_path(qom_path, &ambiguous); + if (obj =3D=3D NULL) { + if (ambiguous) { + error_setg(errp, "Path '%s' is ambiguous", qom_path); + } else { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", qom_path); + } + return NULL; + } + sdbus =3D (SDBus *)object_dynamic_cast(obj, TYPE_SD_BUS); + if (sdbus =3D=3D NULL) { + error_set(errp, ERROR_CLASS_GENERIC_ERROR, + "Device '%s' not a sd-bus", qom_path); + return NULL; + } + + res =3D g_new0(SDBusCommandResponse, 1); + sz =3D sdbus_do_command(sdbus, + &(SDRequest){ command, arg, has_crc ? crc : -1 }, + response); + if (sz > 0) { + res->has_base64 =3D true; + res->base64 =3D g_base64_encode(response, sz); + } + + return res; +} diff --git a/stubs/qmp_sdbus.c b/stubs/qmp_sdbus.c new file mode 100644 index 0000000000..d9bd75ec71 --- /dev/null +++ b/stubs/qmp_sdbus.c @@ -0,0 +1,12 @@ +#include "qemu/osdep.h" +#include "qmp-commands.h" +#include "hw/sd/sd.h" + +SDBusCommandResponse *qmp_x_debug_sdbus_command(const char *qom_path, + uint8_t command, + bool has_arg, uint64_t arg, + bool has_crc, uint16_t crc, + Error **errp) +{ + return NULL; +} diff --git a/hw/sd/Makefile.objs b/hw/sd/Makefile.objs index c2b7664264..3a70477bba 100644 --- a/hw/sd/Makefile.objs +++ b/hw/sd/Makefile.objs @@ -1,6 +1,6 @@ common-obj-$(CONFIG_PL181) +=3D pl181.o common-obj-$(CONFIG_SSI_SD) +=3D ssi-sd.o -common-obj-$(CONFIG_SD) +=3D sd.o core.o +common-obj-$(CONFIG_SD) +=3D sd.o core.o sdbus-qmp.o common-obj-$(CONFIG_SDHCI) +=3D sdhci.o =20 obj-$(CONFIG_MILKYMIST) +=3D milkymist-memcard.o diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 8cfe34328a..a46cb3b992 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -35,6 +35,7 @@ stub-obj-y +=3D vm-stop.o stub-obj-y +=3D vmstate.o stub-obj-$(CONFIG_WIN32) +=3D fd-register.o stub-obj-y +=3D qmp_pc_dimm.o +stub-obj-y +=3D qmp_sdbus.o stub-obj-y +=3D target-monitor-defs.o stub-obj-y +=3D target-get-monitor-def.o stub-obj-y +=3D pc_madt_cpu_entry.o --=20 2.15.1 From nobody Tue Oct 28 01:56:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515016315244329.06271526711464; Wed, 3 Jan 2018 13:51:55 -0800 (PST) Received: from localhost ([::1]:38412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqx0-0002AL-C1 for importer@patchew.org; Wed, 03 Jan 2018 16:51:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqus-0000ig-CH for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWqur-0003sI-6b for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:42 -0500 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:44421) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWqur-0003rp-1m for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:41 -0500 Received: by mail-qt0-x241.google.com with SMTP id m59so3854437qte.11 for ; Wed, 03 Jan 2018 13:49:40 -0800 (PST) Received: from x1.lan ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id l80sm1237566qki.96.2018.01.03.13.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 13:49:39 -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 :mime-version:content-transfer-encoding; bh=SCK4EXh6glHZ/wpDDFN5ad8VoCu2bGEyTUUgwmgCeHk=; b=J3a9jpdO1nKOGfyFY3t4eihPz0r3U3/1nrP/URl9qOIlY7PYmAWsKZ4FIMOasJMb0s ka6swKX5Bt903Adc4olu/8pT+6g+S7iBoUxXWP1Pbtj/iTP5tBO2Bjh9kd0JZWWKZdE3 QJmvm30nXK0goeJAQ6/34siWi+J+yrjcFx/hAEG4euiVJVRKtDiqyaFgGOe00heMzN0+ iM68DrsZ5dsNzZeaiDrm0vouT4pi8JL0fdsZJPZMhbN2wFYdCs86tXt0w2D4zeCC3QTO vpzfC39Fg2fAQVB4RjHFJ6bIEOf9cBUi6Jp/2U+JfbdVZbdr2+mog/hsOzX0eXLj+ivP 9m7A== 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:mime-version:content-transfer-encoding; bh=SCK4EXh6glHZ/wpDDFN5ad8VoCu2bGEyTUUgwmgCeHk=; b=IZWtz7IPflRLv4T/Fm2pOVfr5imKzlgbVIGNEosxHoVCDh5bvSGeou+sxAqZWDhIhr HisRNIfTyV6OxFiInBpgXRmKQxkCOCpJQJzFzkjFKnlSMqpgIJ1iFjZjyKP2Ve7HQySS YpcnK+dY9Rxf4F1nkdhCOiSzzqkEdltO17n9tZY19KRWIjfTcVrBm+zoL93pmNBjo1s9 mGCVSpTcQrmElpvIr0PmNiD6Dbam49CZjQr/4a9QC/9neOIwmO5bz4Oi8YbQ9j8mgrCZ SLHRrOYsMJL85T6rOBDZrF4DJ0QGD2IoqFSIDGC1VbDSOOcgXYjfzWGkyry8Dk8wxuI+ aGZg== X-Gm-Message-State: AKGB3mKBY36GCpdPVzb3FKmR2beyEpzIQV9ex2qxhUW+euwzs5Zizi86 1mQECSDk02qLynFBY3Cphd4= X-Google-Smtp-Source: ACJfBot/HRqcOlX7DYA+L/aK2p859uLXZaV1pgt93dFalkVWsrfMmnWFR2HTxkCkyzjD3bXT13psPg== X-Received: by 10.200.55.231 with SMTP id e36mr3759120qtc.274.1515016180432; Wed, 03 Jan 2018 13:49:40 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell , Eric Blake , Paolo Bonzini , Kevin Wolf , Stefan Hajnoczi Date: Wed, 3 Jan 2018 18:49:23 -0300 Message-Id: <20180103214925.16677-3-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103214925.16677-1-f4bug@amsat.org> References: <20180103214925.16677-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::241 Subject: [Qemu-devel] [RFC PATCH v2 2/4] libqos: add a sdbus API 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: "Edgar E . Iglesias" , Thomas Huth , qemu-devel@nongnu.org, Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/libqos/sdbus.h | 45 ++++++++++++++++++++++++++++++ tests/libqos/sdbus.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/Makefile.include | 1 + 3 files changed, 120 insertions(+) create mode 100644 tests/libqos/sdbus.h create mode 100644 tests/libqos/sdbus.c diff --git a/tests/libqos/sdbus.h b/tests/libqos/sdbus.h new file mode 100644 index 0000000000..2057faf176 --- /dev/null +++ b/tests/libqos/sdbus.h @@ -0,0 +1,45 @@ +/* + * SD/MMC Bus libqos + * + * Copyright (c) 2017 Philippe Mathieu-Daud=C3=A9 + * + * 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. + */ +#ifndef LIBQOS_SDBUS_H +#define LIBQOS_SDBUS_H + +enum NCmd { + GO_IDLE_STATE =3D 0, + ALL_SEND_CID =3D 2, + SEND_RELATIVE_ADDR =3D 3, + SELECT_CARD =3D 7, + SEND_IF_COND =3D 8, + SEND_CSD =3D 9, +}; + +enum ACmd { + SEND_STATUS =3D 13, + SEND_OP_COND =3D 41, + SEND_SCR =3D 51, +}; + +typedef struct SDBusAdapter SDBusAdapter; +struct SDBusAdapter { + + ssize_t (*do_command)(SDBusAdapter *adapter, enum NCmd cmd, uint32_t a= rg, + uint8_t **response); + void (*write_byte)(SDBusAdapter *adapter, uint8_t value); + uint8_t (*read_byte)(SDBusAdapter *adapter); +}; + +ssize_t sdbus_do_cmd(SDBusAdapter *adapter, enum NCmd cmd, uint32_t arg, + uint8_t **response); +ssize_t sdbus_do_acmd(SDBusAdapter *adapter, enum ACmd acmd, uint32_t arg, + uint16_t address, uint8_t **response); +void sdbus_write_byte(SDBusAdapter *adapter, uint8_t value); +uint8_t sdbus_read_byte(SDBusAdapter *adapter); + +SDBusAdapter *qmp_sdbus_create(const char *bus_name); + +#endif diff --git a/tests/libqos/sdbus.c b/tests/libqos/sdbus.c new file mode 100644 index 0000000000..15f38c2bb8 --- /dev/null +++ b/tests/libqos/sdbus.c @@ -0,0 +1,74 @@ +/* + * QTest SD/MMC Bus driver + * + * Copyright (c) 2017 Philippe Mathieu-Daud=C3=A9 + * + * 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 "libqos/sdbus.h" +#include "libqtest.h" +#include "qemu-common.h" + +static bool verbose; +#define DPRINTF(fmt, ...) \ + do { \ + if (verbose) { \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ + } while (0) + +static ssize_t do_cmd(SDBusAdapter *adapter, enum NCmd cmd, uint32_t arg, + uint8_t **response, bool is_app_cmd) +{ + const char *s_cmd =3D is_app_cmd ? "ACMD" : "CMD"; + ssize_t sz; + + verbose =3D !!getenv("V"); + if (verbose && !is_app_cmd && (cmd =3D=3D 55)) { + verbose =3D false; + } + + DPRINTF("-> %s%02u (0x%08x)\n", s_cmd, cmd, arg); + sz =3D adapter->do_command(adapter, cmd, arg, response); + if (response) { + if (sz < 0) { + DPRINTF("<- %s%02u (len: %ld)\n", s_cmd, cmd, sz); + } else if (verbose) { + char *pfx =3D g_strdup_printf("<- %s%02u (len: %ld)", s_cmd, c= md, sz); + + qemu_hexdump((const char *)*response, stderr, pfx, sz); + g_free(pfx); + } + } else { + DPRINTF("<- %s%02u\n", s_cmd, cmd); + } + + return sz; +} + +ssize_t sdbus_do_cmd(SDBusAdapter *adapter, enum NCmd cmd, uint32_t arg, + uint8_t **response) +{ + return do_cmd(adapter, cmd, arg, response, false); +} + +ssize_t sdbus_do_acmd(SDBusAdapter *adapter, enum ACmd acmd, uint32_t arg, + uint16_t address, uint8_t **response) +{ + do_cmd(adapter, 55, address << 16, NULL, false); + // TODO check rv? + + return do_cmd(adapter, acmd, arg, response, true); +} + +void sdbus_write_byte(SDBusAdapter *adapter, uint8_t value) +{ + adapter->write_byte(adapter, value); +} + +uint8_t sdbus_read_byte(SDBusAdapter *adapter) +{ + return adapter->read_byte(adapter); +} diff --git a/tests/Makefile.include b/tests/Makefile.include index cd18ab4519..c22925d4db 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -715,6 +715,7 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-blo= ck.o $(test-crypto-obj-y) =20 libqos-obj-y =3D tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/mal= loc.o libqos-obj-y +=3D tests/libqos/i2c.o tests/libqos/libqos.o +libqos-obj-y +=3D tests/libqos/sdbus.o libqos-spapr-obj-y =3D $(libqos-obj-y) tests/libqos/malloc-spapr.o libqos-spapr-obj-y +=3D tests/libqos/libqos-spapr.o libqos-spapr-obj-y +=3D tests/libqos/rtas.o --=20 2.15.1 From nobody Tue Oct 28 01:56:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515016482792988.3569981555783; Wed, 3 Jan 2018 13:54:42 -0800 (PST) Received: from localhost ([::1]:38454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqzh-0004ZO-Sn for importer@patchew.org; Wed, 03 Jan 2018 16:54:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWquv-0000kj-KV for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWquu-0003vn-Md for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:45 -0500 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:40247) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWquu-0003vN-Hi for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:44 -0500 Received: by mail-qk0-x244.google.com with SMTP id q14so3326151qke.7 for ; Wed, 03 Jan 2018 13:49:44 -0800 (PST) Received: from x1.lan ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id l80sm1237566qki.96.2018.01.03.13.49.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 13:49:43 -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 :mime-version:content-transfer-encoding; bh=NsSeRd6/zN0GzUYEQdPa2VIpHjXDm2XxTGQWM40X7uw=; b=HzwXj4VFGSoiOQ7PQawxakWdEvFqDJpP7oyLX5K2Dn00NgzteZDNnWCfEupSNBEw+F gy+eaH+b/W+nOh2BHqC9W1tnaph3v4IgC5kE8D4g9vyU9mRxW7fN56kbPoHWCSkPsPE8 2FzJkWPQDMN65SzK3QSeDDATrrCSK8BEbT9tpgwsWk7XwkEaAt5n2ffqDegGrbmh3BSG p4I7qcHap+tW9u81mKmwo5JKMwXa3hibarRtxvg823O14pAIwQj2MM76m8+QXd9JmjxU NQZ0W01BRgZwITy2+0uokF6UQuFdZY1YCjOwazzCMll/qIAVZj9u4lqY/b9rUicxk9Ki a12g== 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:mime-version:content-transfer-encoding; bh=NsSeRd6/zN0GzUYEQdPa2VIpHjXDm2XxTGQWM40X7uw=; b=k6DitP5egRpZLwM7+vlsGsTzmYDJPEYFVxtFHf2BJ3luc3btFJ5/AL1Q3sG5yihMa0 CkLYqMz+B5XgBrJjeTxcaJd+ffN8g3AJi/Z+HbbaC84zYoxTbV2hxaUVfD46R/rYasrH IPPcwWIIiV4yTEym7kj9xqCm2GgmnlE+gdLyrG5M249MvzvdR8d295cQdAT1r7SAmcwc QpP7IMgmFDZFa3FkXZzpNaKiqS7tL3xfSooAX/20vJ7dhylsSSQiP5IJQf2pqqnquINT jcxlWkvzkXOXd7U3v4KKhwTjIru3SckUUS2hdkIehbqTZBR4pNUfqAI2Wr2yTEwhDS9X Wk8Q== X-Gm-Message-State: AKGB3mKxt4W097MaNnxHk6gjDvniAlprqoatuPate5iVeqAJyQqY8byL WLZOHNpHTw7IVTqgHAVuf7k= X-Google-Smtp-Source: ACJfBotayFerj3+z+iaV+oWzavkENrK+HAYj0spSh895hmGbukICyXqm0WPipij631ZlyvmOgiuHmw== X-Received: by 10.55.6.145 with SMTP id 139mr3614063qkg.328.1515016183998; Wed, 03 Jan 2018 13:49:43 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell , Eric Blake , Paolo Bonzini , Kevin Wolf , Stefan Hajnoczi Date: Wed, 3 Jan 2018 18:49:24 -0300 Message-Id: <20180103214925.16677-4-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103214925.16677-1-f4bug@amsat.org> References: <20180103214925.16677-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [RFC PATCH v2 3/4] libqos: implement sdbus QMP driver 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: "Edgar E . Iglesias" , Thomas Huth , qemu-devel@nongnu.org, Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/libqos/sdbus-qmp.c | 130 +++++++++++++++++++++++++++++++++++++++++++= ++++ tests/Makefile.include | 2 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 tests/libqos/sdbus-qmp.c diff --git a/tests/libqos/sdbus-qmp.c b/tests/libqos/sdbus-qmp.c new file mode 100644 index 0000000000..565e2481db --- /dev/null +++ b/tests/libqos/sdbus-qmp.c @@ -0,0 +1,130 @@ +/* + * QTest SD/MMC Bus QMP driver + * + * Copyright (c) 2017 Philippe Mathieu-Daud=C3=A9 + * + * 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 "qapi/qmp/qdict.h" +#include "qapi/qmp/qstring.h" + +#include "libqos/sdbus.h" +#include "libqtest.h" + +typedef struct QMPSDBus { + SDBusAdapter parent; + + const char *qom_path; +} QMPSDBus; + + +static const char *qmp_sdbus_getpath(const char *blkname) +{ + QDict *response, *minfo; + QList *list; + const QListEntry *le; + QString *qstr; + const char *mname; + QObject *qobj; + + response =3D qmp("{ 'execute': 'query-block' }"); + g_assert_nonnull(response); + list =3D qdict_get_qlist(response, "return"); + g_assert_nonnull(list); + + QLIST_FOREACH_ENTRY(list, le) { + QDict *response2; + + minfo =3D qobject_to_qdict(qlist_entry_obj(le)); + g_assert(minfo); + qobj =3D qdict_get(minfo, "qdev"); + if (!qobj) { + continue; + } + qstr =3D qobject_to_qstring(qobj); + g_assert(qstr); + mname =3D qstring_get_str(qstr); + + response2 =3D qmp("{ 'execute': 'qom-get'," + " 'arguments': { 'path': %s," + " 'property': \"parent_bus\"}" + "}", mname); + g_assert(response2); + g_assert(qdict_haskey(response2, "return")); + qobj =3D qdict_get(response2, "return"); + qstr =3D qobject_to_qstring(qobj); + g_assert(qstr); + mname =3D qstring_get_str(qstr); + + return mname; + } + return NULL; +} + +static ssize_t qmp_mmc_do_cmd(SDBusAdapter *adapter, enum NCmd cmd, uint32= _t arg, + uint8_t **response) +{ + QMPSDBus *s =3D (QMPSDBus *)adapter; + QDict *response1; + QObject *qobj; + + response1 =3D qmp("{ 'execute': 'x-debug-sdbus-command'," + " 'arguments': { 'qom-path': %s," + " 'command': %u, 'arg': %u}" + "}", + s->qom_path, cmd, arg); + g_assert(qdict_haskey(response1, "return")); + qobj =3D qdict_get(response1, "return"); + //QDECREF(response); + + if (!qobj) { + return -1; + } + + { + QString *qstr; + const gchar *mname; + guchar *uc; + gsize out_len; + QDict *response2 =3D qobject_to_qdict(qobj); + + if (!qdict_haskey(response2, "base64")) { + return 0; + } + qobj =3D qdict_get(response2, "base64"); + qstr =3D qobject_to_qstring(qobj); + if (!qstr) { + puts("!qstr"); + return 0; + } + mname =3D qstring_get_str(qstr); + + uc =3D g_base64_decode(mname, &out_len); + if (response) { + *response =3D uc; + } else { + g_free(uc); + } + return out_len; + + } + + return 0; +} + +SDBusAdapter *qmp_sdbus_create(const char *bus_name) +{ + QMPSDBus *s; + SDBusAdapter *mmc; + + s =3D g_new(QMPSDBus, 1); + s->qom_path =3D qmp_sdbus_getpath(bus_name); + g_assert_nonnull(s->qom_path); + + mmc =3D (SDBusAdapter *)s; + mmc->do_command =3D qmp_mmc_do_cmd; + + return mmc; +} diff --git a/tests/Makefile.include b/tests/Makefile.include index c22925d4db..409784a189 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -715,7 +715,7 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-blo= ck.o $(test-crypto-obj-y) =20 libqos-obj-y =3D tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/mal= loc.o libqos-obj-y +=3D tests/libqos/i2c.o tests/libqos/libqos.o -libqos-obj-y +=3D tests/libqos/sdbus.o +libqos-obj-y +=3D tests/libqos/sdbus.o tests/libqos/sdbus-qmp.o libqos-spapr-obj-y =3D $(libqos-obj-y) tests/libqos/malloc-spapr.o libqos-spapr-obj-y +=3D tests/libqos/libqos-spapr.o libqos-spapr-obj-y +=3D tests/libqos/rtas.o --=20 2.15.1 From nobody Tue Oct 28 01:56:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515016481024267.8855185680943; Wed, 3 Jan 2018 13:54:41 -0800 (PST) Received: from localhost ([::1]:38453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqzc-0004U5-PO for importer@patchew.org; Wed, 03 Jan 2018 16:54:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWquz-0000ov-Iy for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWquy-0003zh-75 for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:49 -0500 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:35995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWquy-0003z9-29 for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:48 -0500 Received: by mail-qt0-x243.google.com with SMTP id a16so3882041qtj.3 for ; Wed, 03 Jan 2018 13:49:47 -0800 (PST) Received: from x1.lan ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id l80sm1237566qki.96.2018.01.03.13.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 13:49:46 -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 :mime-version:content-transfer-encoding; bh=62Zqscggp6hORXY4TLQJDapW1Dzwaea8XwgV6uLH2hM=; b=ieSczIVWjjMrH4/2SHrR2V/l4aPbTDM3zWSIDyp7cbkVd4JvvOt1n5X4JTiBxzDXYV 4jrcZkZuh7E3FijKH7Xd1eOiIu14A5PAWDo+TiFAZeIdWKkj12AUlIXrIilCrJuW3doj n1lr0bHG7yCFJ3IhGWIMTs5dniKIcx7IQMZGgTHCqc89uoJrHRjUYLMLE+nAavn3pAlp gktRZ/QuOFGXud1KpoKjGpf+0tKVUp3dYtsIP3+9KGWd7Yku/a2lInMNhvKyAZl+bla9 NM7V7Iywpw88GIKfc1szIjbdfq3m4FkzLI12+y7MSLt8b7dRsdqc5eC1TzaO18U6jtPN 4PWw== 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:mime-version:content-transfer-encoding; bh=62Zqscggp6hORXY4TLQJDapW1Dzwaea8XwgV6uLH2hM=; b=IDyJ+idGLPOTHkkxtKB42yCpSIAPGtd0PixUWHpt4CkD6hTUfoeexBFtQzS4iJHeqF xT104v4cjc0RNMiR33aab369tMWxCrVdnZoWuB2PEZbtzD6bio5Ho5K+Rebjl82rz/Ae aALyz200E99d7fRCg3GVF0TW10MuJebC5wW/K8nZ7MAV/s0kQIRSoO1RjpSo95e68jcR rjLW0gPvxyJp5TJj9B/ayBBBpFesyltJWfTtm8CXKMDpmw6gCuDj2zRVyA2G/tOzlHO0 9LTkU7MuMyJebMVPdJBSsNfZrO8CvSQ1jA0TbO3e5Dg9gUtHYL3zHeiz6UEg8vCZUAbf 932A== X-Gm-Message-State: AKGB3mJdNAXc+5oK/dj40ZBuChl1MkJ6WieRO0Hvo+oT8Z0mLee54QI/ QZLb7h/1J5StCzjA0mBj44w= X-Google-Smtp-Source: ACJfBouGyv75q3A/LxaUXTTHBsysY94IMjWvwjdcjPTngpNV5RTsqtJM6+pUCt+/aKE0TGP+SgR+Jg== X-Received: by 10.237.60.238 with SMTP id e43mr3678710qtf.23.1515016187455; Wed, 03 Jan 2018 13:49:47 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell , Eric Blake , Paolo Bonzini , Kevin Wolf , Stefan Hajnoczi Date: Wed, 3 Jan 2018 18:49:25 -0300 Message-Id: <20180103214925.16677-5-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103214925.16677-1-f4bug@amsat.org> References: <20180103214925.16677-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [RFC PATCH v2 4/4] tests: add some sdcard qtest 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: "Edgar E . Iglesias" , Thomas Huth , qemu-devel@nongnu.org, Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/sdbus-test.c | 151 +++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/Makefile.include | 2 + 2 files changed, 153 insertions(+) create mode 100644 tests/sdbus-test.c diff --git a/tests/sdbus-test.c b/tests/sdbus-test.c new file mode 100644 index 0000000000..9c38be13cb --- /dev/null +++ b/tests/sdbus-test.c @@ -0,0 +1,151 @@ +/* + * QTest testcase for the SD/MMC cards + * + * Copyright (c) 2017 Philippe Mathieu-Daud=C3=A9 + * + * 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 "qemu/bswap.h" +#include "qemu/cutils.h" + +#include "libqtest.h" +#include "libqos/sdbus.h" + +enum { + PROTO_SD, + PROTO_MMC, + PROTO_SPI, + PROTO_COUNT +}; + +static const char *proto_name[PROTO_COUNT] =3D { + [PROTO_SD] =3D "sd", + [PROTO_MMC] =3D "mmc", + [PROTO_SPI] =3D "spi" +}; + +static const char *machines[PROTO_COUNT] =3D { + [PROTO_SD] =3D "nuri", + //[PROTO_MMC] =3D "vexpress-a9", + //[PROTO_SPI] =3D "lm3s6965evb" +}; + +static const uint64_t sizes[] =3D { + //512 * M_BYTE, + //1 * G_BYTE, + 4 * G_BYTE, + //64 * G_BYTE, +}; + +typedef struct { + int protocol; + uint64_t size; +} TestCase; + +static void test1(SDBusAdapter *mmc, uint64_t size) +{ + uint8_t *response; + uint16_t rca; + ssize_t sz; + + sz =3D sdbus_do_cmd(mmc, GO_IDLE_STATE, 0, NULL); + g_assert_cmpuint(sz, =3D=3D, 0); + + sz =3D sdbus_do_cmd(mmc, SEND_IF_COND, 0x1aa, NULL); + //g_assert_cmpuint(sz, =3D=3D, 0); + + sz =3D sdbus_do_acmd(mmc, SEND_OP_COND, 0x40300000, 0, NULL); + g_assert_cmpuint(sz, =3D=3D, 4); + + /* CID */ + sz =3D sdbus_do_cmd(mmc, ALL_SEND_CID, 0, &response); + g_assert_cmpuint(sz, =3D=3D, 16); + g_assert_cmpmem (&response[3], 5, "QEMU!", 5); + g_assert_cmphex(be32_to_cpu(*(uint32_t *)&response[9]), =3D=3D, 0xdead= beef); + g_free(response); + + /* RCA */ + sz =3D sdbus_do_cmd(mmc, SEND_RELATIVE_ADDR, 0, &response); + g_assert_cmpuint(sz, =3D=3D, 4); + rca =3D be16_to_cpu(*(uint16_t *)response); + g_assert_cmphex(rca, =3D=3D, 0x4567); + g_free(response); + + /* CSD */ + sz =3D sdbus_do_cmd(mmc, SEND_CSD, rca << 16, &response); + g_assert_cmpuint(sz, =3D=3D, 16); + g_assert_cmphex(response[3], =3D=3D, 0x32); + g_assert_cmphex(response[4], =3D=3D, 0x5b); /* class */ + g_assert_cmphex(response[5], =3D=3D, 0x59); + /* (SDHC test) */ + g_assert_cmphex(be32_to_cpu(*(uint32_t *)&response[6]), + =3D=3D, (size >> 19) - 1); + g_assert_cmphex(response[10], =3D=3D, 0x7f); + g_assert_cmphex(response[11], =3D=3D, 0x80); + g_assert_cmphex(response[12], =3D=3D, 0x0a); + g_assert_cmphex(response[13], =3D=3D, 0x40); + g_assert_cmphex(response[14], =3D=3D, 0); + g_assert_cmphex(response[15], =3D=3D, 0); + g_free(response); + + sz =3D sdbus_do_cmd(mmc, SELECT_CARD, rca << 16, NULL); + + sz =3D sdbus_do_acmd(mmc, SEND_SCR, 0, rca, &response); + g_assert_cmpuint(sz, =3D=3D, 4); + g_free(response); + + // TODO 8x: sdcard_read_data len 512 + + //sz =3D sdbus_do_acmd(mmc, SEND_STATUS, 0, rca, &response); + //g_free(response); +} + +static void sdcard_tests(gconstpointer data) +{ + const TestCase *test =3D data; + SDBusAdapter *sdbus; + + global_qtest =3D qtest_startf("-machine %s " + "-drive if=3Dsd,driver=3Dnull-co,size=3D%lu,id=3D= mmc0", + machines[test->protocol], test->size); + sdbus =3D qmp_sdbus_create("sd-bus"); + + test1(sdbus, test->size); + g_free(sdbus); + + qtest_quit(global_qtest); +} + +int main(int argc, char **argv) +{ + const char *arch =3D qtest_get_arch(); + int iproto, isize; + gchar *path; + TestCase *test; + + g_test_init(&argc, &argv, NULL); + + if (strcmp(arch, "arm") =3D=3D 0 || strcmp(arch, "aarch64") =3D=3D 0) { + for (iproto =3D 0; iproto < PROTO_COUNT; iproto++) { + if (!machines[iproto]) { + continue; + } + for (isize =3D 0; isize < ARRAY_SIZE(sizes); isize++) { + test =3D g_new(TestCase, 1); + + test->protocol =3D iproto; + test->size =3D sizes[isize]; + + path =3D g_strdup_printf("sdcard/%s/%lu", proto_name[iprot= o], sizes[isize]); + qtest_add_data_func(path, test, sdcard_tests); + g_free(path); + // g_free(test)? + } + } + } + + return g_test_run(); +} diff --git a/tests/Makefile.include b/tests/Makefile.include index 409784a189..e4434cdfff 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -348,6 +348,7 @@ check-qtest-sparc64-y =3D tests/endianness-test$(EXESUF) check-qtest-sparc64-y +=3D tests/prom-env-test$(EXESUF) =20 check-qtest-arm-y =3D tests/tmp105-test$(EXESUF) +check-qtest-arm-y =3D tests/sdbus-test$(EXESUF) check-qtest-arm-y +=3D tests/ds1338-test$(EXESUF) check-qtest-arm-y +=3D tests/m25p80-test$(EXESUF) gcov-files-arm-y +=3D hw/misc/tmp105.c @@ -748,6 +749,7 @@ tests/bios-tables-test$(EXESUF): tests/bios-tables-test= .o \ tests/boot-sector.o tests/acpi-utils.o $(libqos-obj-y) tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o $(libqos-obj= -y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) +tests/sdbus-test$(EXESUF): tests/sdbus-test.o $(libqos-obj-y) tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y) tests/m25p80-test$(EXESUF): tests/m25p80-test.o tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) --=20 2.15.1