1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef HCD_OHCI_H
22#define HCD_OHCI_H
23
24#include "sysemu/dma.h"
25#include "hw/usb.h"
26#include "qom/object.h"
27
28
29#define OHCI_MAX_PORTS 15
30
31typedef struct OHCIPort {
32 USBPort port;
33 uint32_t ctrl;
34} OHCIPort;
35
36typedef struct OHCIState {
37 USBBus bus;
38 qemu_irq irq;
39 MemoryRegion mem;
40 AddressSpace *as;
41 uint32_t num_ports;
42 const char *name;
43
44 QEMUTimer *eof_timer;
45 int64_t sof_time;
46
47
48
49 uint32_t ctl, status;
50 uint32_t intr_status;
51 uint32_t intr;
52
53
54 uint32_t hcca;
55 uint32_t ctrl_head, ctrl_cur;
56 uint32_t bulk_head, bulk_cur;
57 uint32_t per_cur;
58 uint32_t done;
59 int32_t done_count;
60
61
62 uint16_t fsmps;
63 uint8_t fit;
64 uint16_t fi;
65 uint8_t frt;
66 uint16_t frame_number;
67 uint16_t padding;
68 uint32_t pstart;
69 uint32_t lst;
70
71
72 uint32_t rhdesc_a, rhdesc_b;
73 uint32_t rhstatus;
74 OHCIPort rhport[OHCI_MAX_PORTS];
75
76
77 uint32_t hstatus;
78 uint32_t hmask;
79 uint32_t hreset;
80 uint32_t htest;
81
82
83 dma_addr_t localmem_base;
84
85
86 uint32_t old_ctl;
87 USBPacket usb_packet;
88 uint8_t usb_buf[8192];
89 uint32_t async_td;
90 bool async_complete;
91
92 void (*ohci_die)(struct OHCIState *ohci);
93} OHCIState;
94
95#define TYPE_SYSBUS_OHCI "sysbus-ohci"
96OBJECT_DECLARE_SIMPLE_TYPE(OHCISysBusState, SYSBUS_OHCI)
97
98struct OHCISysBusState {
99
100 SysBusDevice parent_obj;
101
102
103 OHCIState ohci;
104 char *masterbus;
105 uint32_t num_ports;
106 uint32_t firstport;
107 dma_addr_t dma_offset;
108};
109
110extern const VMStateDescription vmstate_ohci_state;
111
112void usb_ohci_init(OHCIState *ohci, DeviceState *dev, uint32_t num_ports,
113 dma_addr_t localmem_base, char *masterbus,
114 uint32_t firstport, AddressSpace *as,
115 void (*ohci_die_fn)(struct OHCIState *), Error **errp);
116void ohci_bus_stop(OHCIState *ohci);
117void ohci_stop_endpoints(OHCIState *ohci);
118void ohci_hard_reset(OHCIState *ohci);
119void ohci_sysbus_die(struct OHCIState *ohci);
120
121#endif
122