quic/qbox
Loading...
Searching...
No Matches
usb_host.h
1/*
2 * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _LIBQBOX_COMPONENTS_USB_HOST_H
8#define _LIBQBOX_COMPONENTS_USB_HOST_H
9
10#include <module_factory_registery.h>
11#include "qemu_xhci.h"
12#include <string>
13
15{
16protected:
17 cci::cci_param<uint32_t> p_hostbus;
18 cci::cci_param<uint32_t> p_hostaddr;
19 cci::cci_param<std::string> p_hostport;
20 cci::cci_param<uint32_t> p_vendorid;
21 cci::cci_param<uint32_t> p_productid;
22
23 cci::cci_param<uint32_t> p_isobufs;
24 cci::cci_param<uint32_t> p_isobsize;
25 cci::cci_param<bool> p_guest_reset;
26 cci::cci_param<bool> p_guest_resets_all;
27 cci::cci_param<bool> p_suppress_remote_wake;
28
29public:
30 usb_host(const sc_core::sc_module_name& name, sc_core::sc_object* o, sc_core::sc_object* t)
31 : usb_host(name, *(dynamic_cast<QemuInstance*>(o)), dynamic_cast<qemu_xhci*>(t))
32 {
33 }
34 usb_host(const sc_core::sc_module_name& n, QemuInstance& inst, qemu_xhci* xhci)
35 : qemu_xhci::Device(n, inst, "usb-host")
36 , p_hostbus("hostbus", 0, "host usb device bus")
37 , p_hostaddr("hostaddr", 0, "host usb device addr")
38 , p_hostport("hostport", std::string(""), "host usb device port")
39 , p_vendorid("vendorid", 0, "host usb device vendorid")
40 , p_productid("productid", 0, "host usb device productid")
41 , p_isobufs("isobufs", 4, "usb isobufs")
42 , p_isobsize("isobsize", 32, "usb isobsize")
43 , p_guest_reset("guest_reset", true, "guest usb reset")
44 , p_guest_resets_all("guest_resets_all", false, "guest usb resets all")
45 , p_suppress_remote_wake("suppress_remote_wake", true, "suppress remote wake")
46 {
47 set_dev_props = [this]() -> void {
48 m_dev.set_prop_uint("hostbus", p_hostbus.get_value());
49 m_dev.set_prop_uint("hostaddr", p_hostaddr.get_value());
50 if (!p_hostport.get_value().empty()) {
51 m_dev.set_prop_str("hostport", p_hostport.get_value().c_str());
52 }
53 m_dev.set_prop_uint("vendorid", p_vendorid.get_value());
54 m_dev.set_prop_uint("productid", p_productid.get_value());
55 m_dev.set_prop_uint("isobufs", p_isobufs.get_value());
56 m_dev.set_prop_uint("isobsize", p_isobsize.get_value());
57 m_dev.set_prop_bool("guest-reset", p_guest_reset.get_value());
58 m_dev.set_prop_bool("guest-resets-all", p_guest_resets_all.get_value());
59 m_dev.set_prop_bool("suppress-remote-wake", p_suppress_remote_wake.get_value());
60 };
61
62 xhci->add_device(*this);
63 }
64};
65
66extern "C" void module_register();
67
68#endif
This class encapsulates a libqemu-cxx qemu::LibQemu instance. It handles QEMU parameters and instance...
Definition qemu-instance.h:89
Definition target.h:160
Definition qemu_xhci.h:20
This class wraps the qemu's XHCI USB controller: eXtensible Host Controller Interface.
Definition qemu_xhci.h:17
Definition usb_host.h:15