summaryrefslogtreecommitdiffstats
path: root/qemu/roms/seabios/src/hw/usb-xhci.h
blob: c768c5b58fbb5083818ede7b18c69b555731fa5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef __USB_XHCI_H
#define __USB_XHCI_H

struct usbdevice_s;
struct usb_endpoint_descriptor;
struct usb_pipe;

// --------------------------------------------------------------

// usb-xhci.c
void xhci_setup(void);
struct usb_pipe *xhci_realloc_pipe(struct usbdevice_s *usbdev
                                   , struct usb_pipe *upipe
                                   , struct usb_endpoint_descriptor *epdesc);
int xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                   , void *data, int datasize);
int xhci_poll_intr(struct usb_pipe *p, void *data);

// --------------------------------------------------------------
// register interface

// capabilities
struct xhci_caps {
    u8  caplength;
    u8  reserved_01;
    u16 hciversion;
    u32 hcsparams1;
    u32 hcsparams2;
    u32 hcsparams3;
    u32 hccparams;
    u32 dboff;
    u32 rtsoff;
} PACKED;

// extended capabilities
struct xhci_xcap {
    u32 cap;
    u32 data[];
} PACKED;

// operational registers
struct xhci_op {
    u32 usbcmd;
    u32 usbsts;
    u32 pagesize;
    u32 reserved_01[2];
    u32 dnctl;
    u32 crcr_low;
    u32 crcr_high;
    u32 reserved_02[4];
    u32 dcbaap_low;
    u32 dcbaap_high;
    u32 config;
} PACKED;

// port registers
struct xhci_pr {
    u32 portsc;
    u32 portpmsc;
    u32 portli;
    u32 reserved_01;
} PACKED;

// doorbell registers
struct xhci_db {
    u32 doorbell;
} PACKED;

// runtime registers
struct xhci_rts {
    u32 mfindex;
} PACKED;

// interrupter registers
struct xhci_ir {
    u32 iman;
    u32 imod;
    u32 erstsz;
    u32 reserved_01;
    u32 erstba_low;
    u32 erstba_high;
    u32 erdp_low;
    u32 erdp_high;
} PACKED;

// --------------------------------------------------------------
// memory data structs

// slot context
struct xhci_slotctx {
    u32 ctx[4];
    u32 reserved_01[4];
} PACKED;

// endpoint context
struct xhci_epctx {
    u32 ctx[2];
    u32 deq_low;
    u32 deq_high;
    u32 length;
    u32 reserved_01[3];
} PACKED;

// device context array element
struct xhci_devlist {
    u32 ptr_low;
    u32 ptr_high;
} PACKED;

// input context
struct xhci_inctx {
    u32 del;
    u32 add;
    u32 reserved_01[6];
} PACKED;

// transfer block (ring element)
struct xhci_trb {
    u32 ptr_low;
    u32 ptr_high;
    u32 status;
    u32 control;
} PACKED;

// event ring segment
struct xhci_er_seg {
    u32 ptr_low;
    u32 ptr_high;
    u32 size;
    u32 reserved_01;
} PACKED;

#endif // usb-xhci.h