hw/usb/hcd-uhci: Expose generic prototypes to local header
Extract generic UHCI prototypes into a new "hcd-uhci.h" local header so we can reuse them in other units. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20210309190802.830969-3-f4bug@amsat.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
f4c46916dc
commit
9a4e12a64d
@ -40,6 +40,7 @@
|
|||||||
#include "qemu/main-loop.h"
|
#include "qemu/main-loop.h"
|
||||||
#include "qemu/module.h"
|
#include "qemu/module.h"
|
||||||
#include "qom/object.h"
|
#include "qom/object.h"
|
||||||
|
#include "hcd-uhci.h"
|
||||||
|
|
||||||
#define FRAME_TIMER_FREQ 1000
|
#define FRAME_TIMER_FREQ 1000
|
||||||
|
|
||||||
@ -50,8 +51,6 @@
|
|||||||
|
|
||||||
#define MAX_FRAMES_PER_TICK (QH_VALID / 2)
|
#define MAX_FRAMES_PER_TICK (QH_VALID / 2)
|
||||||
|
|
||||||
#define NB_PORTS 2
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TD_RESULT_STOP_FRAME = 10,
|
TD_RESULT_STOP_FRAME = 10,
|
||||||
TD_RESULT_COMPLETE,
|
TD_RESULT_COMPLETE,
|
||||||
@ -62,20 +61,8 @@ enum {
|
|||||||
|
|
||||||
typedef struct UHCIState UHCIState;
|
typedef struct UHCIState UHCIState;
|
||||||
typedef struct UHCIAsync UHCIAsync;
|
typedef struct UHCIAsync UHCIAsync;
|
||||||
typedef struct UHCIQueue UHCIQueue;
|
|
||||||
typedef struct UHCIInfo UHCIInfo;
|
|
||||||
typedef struct UHCIPCIDeviceClass UHCIPCIDeviceClass;
|
typedef struct UHCIPCIDeviceClass UHCIPCIDeviceClass;
|
||||||
|
|
||||||
struct UHCIInfo {
|
|
||||||
const char *name;
|
|
||||||
uint16_t vendor_id;
|
|
||||||
uint16_t device_id;
|
|
||||||
uint8_t revision;
|
|
||||||
uint8_t irq_pin;
|
|
||||||
void (*realize)(PCIDevice *dev, Error **errp);
|
|
||||||
bool unplug;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UHCIPCIDeviceClass {
|
struct UHCIPCIDeviceClass {
|
||||||
PCIDeviceClass parent_class;
|
PCIDeviceClass parent_class;
|
||||||
UHCIInfo info;
|
UHCIInfo info;
|
||||||
@ -107,43 +94,6 @@ struct UHCIQueue {
|
|||||||
int8_t valid;
|
int8_t valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct UHCIPort {
|
|
||||||
USBPort port;
|
|
||||||
uint16_t ctrl;
|
|
||||||
} UHCIPort;
|
|
||||||
|
|
||||||
struct UHCIState {
|
|
||||||
PCIDevice dev;
|
|
||||||
MemoryRegion io_bar;
|
|
||||||
USBBus bus; /* Note unused when we're a companion controller */
|
|
||||||
uint16_t cmd; /* cmd register */
|
|
||||||
uint16_t status;
|
|
||||||
uint16_t intr; /* interrupt enable register */
|
|
||||||
uint16_t frnum; /* frame number */
|
|
||||||
uint32_t fl_base_addr; /* frame list base address */
|
|
||||||
uint8_t sof_timing;
|
|
||||||
uint8_t status2; /* bit 0 and 1 are used to generate UHCI_STS_USBINT */
|
|
||||||
int64_t expire_time;
|
|
||||||
QEMUTimer *frame_timer;
|
|
||||||
QEMUBH *bh;
|
|
||||||
uint32_t frame_bytes;
|
|
||||||
uint32_t frame_bandwidth;
|
|
||||||
bool completions_only;
|
|
||||||
UHCIPort ports[NB_PORTS];
|
|
||||||
|
|
||||||
/* Interrupts that should be raised at the end of the current frame. */
|
|
||||||
uint32_t pending_int_mask;
|
|
||||||
|
|
||||||
/* Active packets */
|
|
||||||
QTAILQ_HEAD(, UHCIQueue) queues;
|
|
||||||
uint8_t num_ports_vmstate;
|
|
||||||
|
|
||||||
/* Properties */
|
|
||||||
char *masterbus;
|
|
||||||
uint32_t firstport;
|
|
||||||
uint32_t maxframes;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct UHCI_TD {
|
typedef struct UHCI_TD {
|
||||||
uint32_t link;
|
uint32_t link;
|
||||||
uint32_t ctrl; /* see TD_CTRL_xxx */
|
uint32_t ctrl; /* see TD_CTRL_xxx */
|
||||||
@ -160,10 +110,6 @@ static void uhci_async_cancel(UHCIAsync *async);
|
|||||||
static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td);
|
static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td);
|
||||||
static void uhci_resume(void *opaque);
|
static void uhci_resume(void *opaque);
|
||||||
|
|
||||||
#define TYPE_UHCI "pci-uhci-usb"
|
|
||||||
DECLARE_INSTANCE_CHECKER(UHCIState, UHCI,
|
|
||||||
TYPE_UHCI)
|
|
||||||
|
|
||||||
static inline int32_t uhci_queue_token(UHCI_TD *td)
|
static inline int32_t uhci_queue_token(UHCI_TD *td)
|
||||||
{
|
{
|
||||||
if ((td->token & (0xf << 15)) == 0) {
|
if ((td->token & (0xf << 15)) == 0) {
|
||||||
@ -1213,7 +1159,7 @@ static USBPortOps uhci_port_ops = {
|
|||||||
static USBBusOps uhci_bus_ops = {
|
static USBBusOps uhci_bus_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
|
void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
|
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
|
||||||
@ -1335,7 +1281,7 @@ static const TypeInfo uhci_pci_type_info = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void uhci_data_class_init(ObjectClass *klass, void *data)
|
void uhci_data_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
93
hw/usb/hcd-uhci.h
Normal file
93
hw/usb/hcd-uhci.h
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* USB UHCI controller emulation
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008 Max Krasnyansky
|
||||||
|
* Magor rewrite of the UHCI data structures parser and frame processor
|
||||||
|
* Support for fully async operation and multiple outstanding transactions
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef HW_USB_HCD_UHCI_H
|
||||||
|
#define HW_USB_HCD_UHCI_H
|
||||||
|
|
||||||
|
#include "exec/memory.h"
|
||||||
|
#include "qemu/timer.h"
|
||||||
|
#include "hw/pci/pci.h"
|
||||||
|
#include "hw/usb.h"
|
||||||
|
|
||||||
|
typedef struct UHCIQueue UHCIQueue;
|
||||||
|
|
||||||
|
#define NB_PORTS 2
|
||||||
|
|
||||||
|
typedef struct UHCIPort {
|
||||||
|
USBPort port;
|
||||||
|
uint16_t ctrl;
|
||||||
|
} UHCIPort;
|
||||||
|
|
||||||
|
typedef struct UHCIState {
|
||||||
|
PCIDevice dev;
|
||||||
|
MemoryRegion io_bar;
|
||||||
|
USBBus bus; /* Note unused when we're a companion controller */
|
||||||
|
uint16_t cmd; /* cmd register */
|
||||||
|
uint16_t status;
|
||||||
|
uint16_t intr; /* interrupt enable register */
|
||||||
|
uint16_t frnum; /* frame number */
|
||||||
|
uint32_t fl_base_addr; /* frame list base address */
|
||||||
|
uint8_t sof_timing;
|
||||||
|
uint8_t status2; /* bit 0 and 1 are used to generate UHCI_STS_USBINT */
|
||||||
|
int64_t expire_time;
|
||||||
|
QEMUTimer *frame_timer;
|
||||||
|
QEMUBH *bh;
|
||||||
|
uint32_t frame_bytes;
|
||||||
|
uint32_t frame_bandwidth;
|
||||||
|
bool completions_only;
|
||||||
|
UHCIPort ports[NB_PORTS];
|
||||||
|
|
||||||
|
/* Interrupts that should be raised at the end of the current frame. */
|
||||||
|
uint32_t pending_int_mask;
|
||||||
|
|
||||||
|
/* Active packets */
|
||||||
|
QTAILQ_HEAD(, UHCIQueue) queues;
|
||||||
|
uint8_t num_ports_vmstate;
|
||||||
|
|
||||||
|
/* Properties */
|
||||||
|
char *masterbus;
|
||||||
|
uint32_t firstport;
|
||||||
|
uint32_t maxframes;
|
||||||
|
} UHCIState;
|
||||||
|
|
||||||
|
#define TYPE_UHCI "pci-uhci-usb"
|
||||||
|
DECLARE_INSTANCE_CHECKER(UHCIState, UHCI, TYPE_UHCI)
|
||||||
|
|
||||||
|
typedef struct UHCIInfo {
|
||||||
|
const char *name;
|
||||||
|
uint16_t vendor_id;
|
||||||
|
uint16_t device_id;
|
||||||
|
uint8_t revision;
|
||||||
|
uint8_t irq_pin;
|
||||||
|
void (*realize)(PCIDevice *dev, Error **errp);
|
||||||
|
bool unplug;
|
||||||
|
} UHCIInfo;
|
||||||
|
|
||||||
|
void uhci_data_class_init(ObjectClass *klass, void *data);
|
||||||
|
void usb_uhci_common_realize(PCIDevice *dev, Error **errp);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user