]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Dxe/OhciSched.h
QuarkSocPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / QuarkSocPkg / QuarkSouthCluster / Usb / Ohci / Dxe / OhciSched.h
1 /** @file
2 This file contains the definination for host controller schedule routines.
3
4 Copyright (c) 2013-2015 Intel Corporation.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10
11
12 #ifndef _OHCI_SCHED_H
13 #define _OHCI_SCHED_H
14
15 #include "Descriptor.h"
16
17 #define HCCA_MEM_SIZE 256
18 #define GRID_SIZE 16
19 #define GRID_SHIFT 4
20
21 typedef struct _INTERRUPT_CONTEXT_ENTRY INTERRUPT_CONTEXT_ENTRY;
22
23 struct _INTERRUPT_CONTEXT_ENTRY{
24 UINT8 DeviceAddress;
25 UINT8 EndPointAddress;
26 ED_DESCRIPTOR *Ed;
27 TD_DESCRIPTOR *DataTd;
28 BOOLEAN IsSlowDevice;
29 UINT8 MaxPacketLength;
30 UINTN PollingInterval;
31 EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction;
32 VOID *Context;
33 BOOLEAN IsPeriodic;
34 VOID *Buffer;
35 UINTN DataLength;
36 VOID *UCBuffer;
37 VOID *UCBufferMapping;
38 UINT8 *Toggle;
39 INTERRUPT_CONTEXT_ENTRY *NextEntry;
40 };
41
42
43 typedef struct {
44 UINT32 ErrorCode;
45 UINT8 NextToggle;
46 } OHCI_ED_RESULT;
47
48 /**
49
50 Add an item of interrupt context
51
52 @param Ohc UHC private data
53 @param NewEntry New entry to add
54
55 @retval EFI_SUCCESS Item successfully added
56
57 **/
58 EFI_STATUS
59 OhciAddInterruptContextEntry (
60 IN USB_OHCI_HC_DEV *Ohc,
61 IN INTERRUPT_CONTEXT_ENTRY *NewEntry
62 );
63
64 /**
65
66 Free a interrupt context entry
67
68 @param Ohc UHC private data
69 @param Entry Pointer to an interrupt context entry
70
71 @retval EFI_SUCCESS Entry freed
72 @retval EFI_INVALID_PARAMETER Entry is NULL
73
74 **/
75 EFI_STATUS
76 OhciFreeInterruptContextEntry (
77 IN USB_OHCI_HC_DEV *Ohc,
78 IN INTERRUPT_CONTEXT_ENTRY *Entry
79 );
80
81 /**
82
83 Free entries match the device address and endpoint address
84
85 @Param Ohc UHC private date
86 @Param DeviceAddress Item to free must match this device address
87 @Param EndPointAddress Item to free must match this end point address
88 @Param DataToggle DataToggle for output
89
90 @retval EFI_SUCCESS Items match the requirement removed
91
92 **/
93 EFI_STATUS
94 OhciFreeInterruptContext(
95 IN USB_OHCI_HC_DEV *Ohc,
96 IN UINT8 DeviceAddress,
97 IN UINT8 EndPointAddress,
98 OUT UINT8 *DataToggle
99 );
100
101
102 /**
103
104 Convert Error code from OHCI format to EFI format
105
106 @Param ErrorCode ErrorCode in OHCI format
107
108 @retval ErrorCode in EFI format
109
110 **/
111 UINT32
112 ConvertErrorCode (
113 IN UINT32 ErrorCode
114 );
115
116
117 /**
118
119 Check TDs Results
120
121 @Param Ohc UHC private data
122 @Param Td TD_DESCRIPTOR
123 @Param Result Result to return
124
125 @retval TRUE means OK
126 @retval FLASE means Error or Short packet
127
128 **/
129 BOOLEAN
130 OhciCheckTDsResults (
131 IN USB_OHCI_HC_DEV *Ohc,
132 IN TD_DESCRIPTOR *Td,
133 OUT UINT32 *Result
134 );
135 /**
136
137 Check the task status on an ED
138
139 @Param Ed Pointer to the ED task that TD hooked on
140 @Param HeadTd TD header for current transaction
141
142 @retval Task Status Code
143
144 **/
145
146 UINT32
147 CheckEDStatus (
148 IN ED_DESCRIPTOR *Ed,
149 IN TD_DESCRIPTOR *HeadTd,
150 OUT OHCI_ED_RESULT *EdResult
151 );
152 /**
153
154 Check the task status
155
156 @Param Ohc UHC private data
157 @Param ListType Pipe type
158 @Param Ed Pointer to the ED task hooked on
159 @Param HeadTd Head of TD corresponding to the task
160 @Param ErrorCode return the ErrorCode
161
162 @retval EFI_SUCCESS Task done
163 @retval EFI_NOT_READY Task on processing
164 @retval EFI_DEVICE_ERROR Some error occured
165
166 **/
167 EFI_STATUS
168 CheckIfDone (
169 IN USB_OHCI_HC_DEV *Ohc,
170 IN DESCRIPTOR_LIST_TYPE ListType,
171 IN ED_DESCRIPTOR *Ed,
172 IN TD_DESCRIPTOR *HeadTd,
173 OUT OHCI_ED_RESULT *EdResult
174 );
175
176 /**
177
178 Convert TD condition code to Efi Status
179
180 @Param ConditionCode Condition code to convert
181
182 @retval EFI_SUCCESS No error occured
183 @retval EFI_NOT_READY TD still on processing
184 @retval EFI_DEVICE_ERROR Error occured in processing TD
185
186 **/
187
188 EFI_STATUS
189 OhciTDConditionCodeToStatus (
190 IN UINT32 ConditionCode
191 );
192
193 /**
194
195 Invoke callbacks hooked on done TDs
196
197 @Param Entry Interrupt transfer transaction information data structure
198 @Param Context Ohc private data
199
200 **/
201
202 VOID
203 OhciInvokeInterruptCallBack(
204 IN INTERRUPT_CONTEXT_ENTRY *Entry,
205 IN UINT32 Result
206 );
207
208
209 /**
210
211 Timer to submit periodic interrupt transfer, and invoke callbacks hooked on done TDs
212
213 @param Event Event handle
214 @param Context Device private data
215
216 **/
217
218 VOID
219 EFIAPI
220 OhciHouseKeeper (
221 IN EFI_EVENT Event,
222 IN VOID *Context
223 );
224
225 #endif