qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] qtest and pci mmio?
Date: Wed, 07 May 2014 18:06:37 +0200	[thread overview]
Message-ID: <1399478797.25347.6.camel@nilsson.home.kraxel.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 298 bytes --]

  Hi,

Trying to add something real to the new ehci test.  Having trouble
accessing the ehci mmio registers.  uhci io registers are working fine.
Current patch attached, which just does a register dump to stderr.  uhci
looks sane.  ehci shouldn't be all zeros.  Anyone has a clue?

thanks,
  Gerd


[-- Attachment #2: 0001-wip-ehci-uhci-test.patch --]
[-- Type: text/x-patch, Size: 4774 bytes --]

>From a4cc34ec95c50f43d328e1a453712b011df9ad00 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 7 May 2014 16:39:11 +0200
Subject: [PATCH] [wip] ehci/uhci test

---
 tests/Makefile            |  4 ++-
 tests/usb-hcd-ehci-test.c | 79 ++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 14ecf05..f37ef47 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -152,6 +152,8 @@ gcov-files-i386-y += hw/pci-bridge/ioh3420.c
 check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
 gcov-files-i386-y += hw/usb/hcd-ehci.c
 gcov-files-i386-y += hw/usb/hcd-uhci.c
+gcov-files-i386-y += hw/usb/dev-hid.c
+gcov-files-i386-y += hw/usb/dev-storage.c
 check-qtest-x86_64-y = $(check-qtest-i386-y)
 gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
 gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y))
@@ -307,7 +309,7 @@ tests/ac97-test$(EXESUF): tests/ac97-test.o
 tests/es1370-test$(EXESUF): tests/es1370-test.o
 tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o
 tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o
-tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o
+tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y)
 tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
 
 # QTest rules
diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c
index bc56ba7..ce38795 100644
--- a/tests/usb-hcd-ehci-test.c
+++ b/tests/usb-hcd-ehci-test.c
@@ -9,12 +9,79 @@
 
 #include <glib.h>
 #include <string.h>
+#include <stdio.h>
 #include "libqtest.h"
+#include "libqos/pci-pc.h"
 #include "qemu/osdep.h"
 
-/* Tests only initialization so far. TODO: Replace with functional tests */
-static void pci_nop(void)
+static QPCIBus    *pcibus;
+static QPCIDevice *uhci1;
+static QPCIDevice *uhci2;
+static QPCIDevice *uhci3;
+static QPCIDevice *ehci1;
+
+static void *uhci1_io;
+static void *uhci2_io;
+static void *uhci3_io;
+static void *ehci1_mmio;
+
+static void pci_init(void)
 {
+    if (pcibus) {
+        return;
+    }
+    pcibus = qpci_init_pc();
+    g_assert(pcibus != NULL);
+
+    uhci1 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 0));
+    g_assert(uhci1 != NULL);
+    uhci2 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 1));
+    g_assert(uhci2 != NULL);
+    uhci3 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 2));
+    g_assert(uhci3 != NULL);
+    ehci1 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 7));
+    g_assert(ehci1 != NULL);
+
+    qpci_device_enable(uhci1);
+    qpci_device_enable(uhci2);
+    qpci_device_enable(uhci3);
+    qpci_device_enable(ehci1);
+
+    uhci1_io   = qpci_iomap(uhci1, 4);
+    uhci2_io   = qpci_iomap(uhci2, 4);
+    uhci3_io   = qpci_iomap(uhci3, 4);
+    ehci1_mmio = qpci_iomap(ehci1, 0);
+
+#if 1
+    fprintf(stderr, "%s: uhci1  %p\n", __func__, uhci1_io);
+    fprintf(stderr, "%s: uhci2  %p\n", __func__, uhci2_io);
+    fprintf(stderr, "%s: uhci3  %p\n", __func__, uhci3_io);
+    fprintf(stderr, "%s: ehci1  %p\n", __func__, ehci1_mmio);
+    fprintf(stderr, "\n");
+#endif
+}
+
+static void pci_portsc_1(void)
+{
+    int i;
+
+    g_assert(pcibus != NULL);
+
+#if 1
+    for (i = 0; i < 0x14; i += 2) {
+        fprintf(stderr, "%s: uhci1  0x%02x: 0x%04x\n", __func__, i,
+                qpci_io_readw(uhci1, uhci1_io + i));
+    }
+    fprintf(stderr, "\n");
+
+    for (i = 0; i < 0x60; i += 4) {
+        fprintf(stderr, "%s: ehci1  0x%02x: 0x%08x\n", __func__, i,
+                qpci_io_readl(ehci1, ehci1_mmio + i));
+    }
+    fprintf(stderr, "\n");
+
+    g_assert(false);
+#endif
 }
 
 int main(int argc, char **argv)
@@ -22,7 +89,8 @@ int main(int argc, char **argv)
     int ret;
 
     g_test_init(&argc, &argv, NULL);
-    qtest_add_func("/ehci/pci/nop", pci_nop);
+    qtest_add_func("/ehci/pci/init", pci_init);
+    qtest_add_func("/ehci/pci/portsc_1", pci_portsc_1);
 
     qtest_start("-machine q35 -device ich9-usb-ehci1,bus=pcie.0,addr=1d.7,"
                 "multifunction=on,id=ich9-ehci-1 "
@@ -31,7 +99,10 @@ int main(int argc, char **argv)
                 "-device ich9-usb-uhci2,bus=pcie.0,addr=1d.1,"
                 "multifunction=on,masterbus=ich9-ehci-1.0,firstport=2 "
                 "-device ich9-usb-uhci3,bus=pcie.0,addr=1d.2,"
-                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4");
+                "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4 "
+                "-drive if=none,id=usbcdrom,media=cdrom "
+                "-device usb-tablet,bus=ich9-ehci-1.0,port=1,usb_version=1 "
+                "-device usb-storage,bus=ich9-ehci-1.0,port=2,drive=usbcdrom ");
     ret = g_test_run();
 
     qtest_end();
-- 
1.8.3.1


             reply	other threads:[~2014-05-07 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 16:06 Gerd Hoffmann [this message]
2014-05-07 16:41 ` [Qemu-devel] qtest and pci mmio? Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399478797.25347.6.camel@nilsson.home.kraxel.org \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).