From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
To: Gerd Hoffmann <kraxel@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Markus Armbruster <armbru@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Vikram Garhwal" <fnuv@xilinx.com>,
sai.pavan.boddu@xilinx.com, qemu-devel@nongnu.org,
"Paul Zimmerman" <pauldzim@gmail.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Ying Fang" <fangying1@huawei.com>,
"'Marc-André Lureau'" <marcandre.lureau@redhat.com>,
"'Philippe Mathieu-Daudé'" <philmd@redhat.com>
Subject: [PATCH v3 2/3] usb/hcd-xhci: Move qemu-xhci device to hcd-xhci-pci.c
Date: Tue, 7 Jul 2020 22:14:30 +0530 [thread overview]
Message-ID: <1594140271-16462-3-git-send-email-sai.pavan.boddu@xilinx.com> (raw)
In-Reply-To: <1594140271-16462-1-git-send-email-sai.pavan.boddu@xilinx.com>
Move pci specific devices to new file. This set the environment to move all
pci specific hooks in hcd-xhci.c to hcd-xhci-pci.c.
Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
---
hw/usb/hcd-xhci-pci.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++
hw/usb/hcd-xhci.c | 40 ++------------------------------
hw/usb/hcd-xhci.h | 2 ++
3 files changed, 68 insertions(+), 38 deletions(-)
create mode 100644 hw/usb/hcd-xhci-pci.c
diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c
new file mode 100644
index 0000000..26af683
--- /dev/null
+++ b/hw/usb/hcd-xhci-pci.c
@@ -0,0 +1,64 @@
+/*
+ * USB xHCI controller with PCI system bus emulation
+ *
+ * Copyright (c) 2011 Securiforest
+ * Date: 2011-05-11 ; Author: Hector Martin <hector@marcansoft.com>
+ * Based on usb-ohci.c, emulates Renesas NEC USB 3.0
+ * Date: 2020-03-01; Author: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
+ * Moved the pci specific content for hcd-xhci.c to hcd-xhci-pci.c
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+#include "qemu/osdep.h"
+#include "hw/pci/pci.h"
+#include "hw/qdev-properties.h"
+#include "hw/pci/msi.h"
+#include "hw/pci/msix.h"
+#include "hcd-xhci.h"
+#include "trace.h"
+#include "qapi/error.h"
+
+static void qemu_xhci_class_init(ObjectClass *klass, void *data)
+{
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->vendor_id = PCI_VENDOR_ID_REDHAT;
+ k->device_id = PCI_DEVICE_ID_REDHAT_XHCI;
+ k->revision = 0x01;
+}
+
+static void qemu_xhci_instance_init(Object *obj)
+{
+ XHCIState *xhci = XHCI(obj);
+
+ xhci->msi = ON_OFF_AUTO_OFF;
+ xhci->msix = ON_OFF_AUTO_AUTO;
+ xhci->numintrs = MAXINTRS;
+ xhci->numslots = MAXSLOTS;
+ xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST);
+}
+
+static const TypeInfo qemu_xhci_info = {
+ .name = TYPE_QEMU_XHCI,
+ .parent = TYPE_XHCI,
+ .class_init = qemu_xhci_class_init,
+ .instance_init = qemu_xhci_instance_init,
+};
+
+static void xhci_register_types(void)
+{
+ type_register_static(&qemu_xhci_info);
+}
+
+type_init(xhci_register_types)
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index fa6ce98..052e26e 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -429,12 +429,12 @@ static const char *ep_state_name(uint32_t state)
ARRAY_SIZE(ep_state_names));
}
-static bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit)
+bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit)
{
return xhci->flags & (1 << bit);
}
-static void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit)
+void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit)
{
xhci->flags |= (1 << bit);
}
@@ -3692,13 +3692,6 @@ static Property xhci_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
-static void xhci_instance_init(Object *obj)
-{
- /* QEMU_PCI_CAP_EXPRESS initialization does not depend on QEMU command
- * line, therefore, no need to wait to realize like other devices */
- PCI_DEVICE(obj)->cap_present |= QEMU_PCI_CAP_EXPRESS;
-}
-
static void xhci_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -3718,7 +3711,6 @@ static const TypeInfo xhci_info = {
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(XHCIState),
.class_init = xhci_class_init,
- .instance_init = xhci_instance_init,
.abstract = true,
.interfaces = (InterfaceInfo[]) {
{ INTERFACE_PCIE_DEVICE },
@@ -3727,37 +3719,9 @@ static const TypeInfo xhci_info = {
},
};
-static void qemu_xhci_class_init(ObjectClass *klass, void *data)
-{
- PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
- k->vendor_id = PCI_VENDOR_ID_REDHAT;
- k->device_id = PCI_DEVICE_ID_REDHAT_XHCI;
- k->revision = 0x01;
-}
-
-static void qemu_xhci_instance_init(Object *obj)
-{
- XHCIState *xhci = XHCI(obj);
-
- xhci->msi = ON_OFF_AUTO_OFF;
- xhci->msix = ON_OFF_AUTO_AUTO;
- xhci->numintrs = MAXINTRS;
- xhci->numslots = MAXSLOTS;
- xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST);
-}
-
-static const TypeInfo qemu_xhci_info = {
- .name = TYPE_QEMU_XHCI,
- .parent = TYPE_XHCI,
- .class_init = qemu_xhci_class_init,
- .instance_init = qemu_xhci_instance_init,
-};
-
static void xhci_register_types(void)
{
type_register_static(&xhci_info);
- type_register_static(&qemu_xhci_info);
}
type_init(xhci_register_types)
diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
index edbd926..34bdb22 100644
--- a/hw/usb/hcd-xhci.h
+++ b/hw/usb/hcd-xhci.h
@@ -232,4 +232,6 @@ struct XHCIState {
bool nec_quirks;
};
+bool xhci_get_flag(XHCIState *xhci, enum xhci_flags bit);
+void xhci_set_flag(XHCIState *xhci, enum xhci_flags bit);
#endif
--
2.7.4
next prev parent reply other threads:[~2020-07-07 17:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 16:44 [PATCH v3 0/3] Make hcd-xhci independent of pci hooks Sai Pavan Boddu
2020-07-07 16:44 ` [PATCH v3 1/3] usb/hcd-xhci: Make dma read/writes hooks pci free Sai Pavan Boddu
2020-07-07 16:44 ` Sai Pavan Boddu [this message]
2020-07-07 16:44 ` [PATCH v3 3/3] usb/hcd-xhci: Split pci wrapper for xhci base model Sai Pavan Boddu
2020-07-15 10:48 ` Gerd Hoffmann
2020-07-14 13:59 ` [PATCH v3 0/3] Make hcd-xhci independent of pci hooks Sai Pavan Boddu
2020-07-15 10:51 ` Gerd Hoffmann
2020-07-16 12:57 ` Sai Pavan Boddu
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=1594140271-16462-3-git-send-email-sai.pavan.boddu@xilinx.com \
--to=sai.pavan.boddu@xilinx.com \
--cc=alistair.francis@wdc.com \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=fangying1@huawei.com \
--cc=fnuv@xilinx.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pauldzim@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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).