]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassCbi.h
CommitLineData
e237e7ae 1/** @file\r
d80ed2a7 2 Defination for the USB mass storage Control/Bulk/Interrupt (CBI) transport,\r
3 according to USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport, Revision 1.1.\r
cc5166ff 4\r
d1102dba 5Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 6This program and the accompanying materials\r
e237e7ae 7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
e237e7ae 14**/\r
15\r
16#ifndef _EFI_USBMASS_CBI_H_\r
17#define _EFI_USBMASS_CBI_H_\r
18\r
d80ed2a7 19extern USB_MASS_TRANSPORT mUsbCbi0Transport;\r
20extern USB_MASS_TRANSPORT mUsbCbi1Transport;\r
21\r
1ccdbf2a 22#define USB_CBI_MAX_PACKET_NUM 16\r
23#define USB_CBI_RESET_CMD_LEN 12\r
24//\r
25// USB CBI retry C/B/I transport times, set by experience\r
26//\r
27#define USB_CBI_MAX_RETRY 3\r
28//\r
29// Time to wait for USB CBI reset to complete, set by experience\r
d1102dba 30//\r
1ccdbf2a 31#define USB_CBI_RESET_DEVICE_STALL (50 * USB_MASS_1_MILLISECOND)\r
32//\r
33// USB CBI transport timeout, set by experience\r
34//\r
35#define USB_CBI_RESET_DEVICE_TIMEOUT (1 * USB_MASS_1_SECOND)\r
e237e7ae 36\r
e237e7ae 37typedef struct {\r
d80ed2a7 38 //\r
39 // Put Interface at the first field to make it easy to distinguish BOT/CBI Protocol instance\r
40 //\r
e237e7ae 41 EFI_USB_INTERFACE_DESCRIPTOR Interface;\r
42 EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;\r
43 EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;\r
44 EFI_USB_ENDPOINT_DESCRIPTOR *InterruptEndpoint;\r
45 EFI_USB_IO_PROTOCOL *UsbIo;\r
46} USB_CBI_PROTOCOL;\r
47\r
48#pragma pack(1)\r
49typedef struct {\r
50 UINT8 Type;\r
51 UINT8 Value;\r
52} USB_CBI_STATUS;\r
53#pragma pack()\r
54\r
d80ed2a7 55/**\r
56 Initializes USB CBI protocol.\r
57\r
58 This function initializes the USB mass storage class CBI protocol.\r
59 It will save its context which is a USB_CBI_PROTOCOL structure\r
60 in the Context if Context isn't NULL.\r
61\r
62 @param UsbIo The USB I/O Protocol instance\r
63 @param Context The buffer to save the context to\r
64\r
65 @retval EFI_SUCCESS The device is successfully initialized.\r
66 @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r
67 @retval Other The USB CBI initialization fails.\r
68\r
69**/\r
70EFI_STATUS\r
71UsbCbiInit (\r
72 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
73 OUT VOID **Context OPTIONAL\r
74 );\r
75\r
76/**\r
77 Execute USB mass storage command through the CBI0/CBI1 transport protocol.\r
78\r
79 @param Context The USB CBI Protocol.\r
80 @param Cmd The command to transfer to device\r
81 @param CmdLen The length of the command\r
82 @param DataDir The direction of data transfer\r
83 @param Data The buffer to hold the data\r
84 @param DataLen The length of the buffer\r
85 @param Lun Should be 0, this field for bot only\r
86 @param Timeout The time to wait\r
87 @param CmdStatus The result of the command execution\r
88\r
89 @retval EFI_SUCCESS The command is executed successfully.\r
90 @retval Other Failed to execute the command\r
91\r
92**/\r
93EFI_STATUS\r
94UsbCbiExecCommand (\r
95 IN VOID *Context,\r
96 IN VOID *Cmd,\r
97 IN UINT8 CmdLen,\r
98 IN EFI_USB_DATA_DIRECTION DataDir,\r
99 IN VOID *Data,\r
100 IN UINT32 DataLen,\r
101 IN UINT8 Lun,\r
102 IN UINT32 Timeout,\r
103 OUT UINT32 *CmdStatus\r
104 );\r
105\r
106/**\r
107 Reset the USB mass storage device by CBI protocol.\r
108\r
109 This function resets the USB mass storage device by CBI protocol.\r
110 The reset is defined as a non-data command. Don't use UsbCbiExecCommand\r
111 to send the command to device because that may introduce recursive loop.\r
112\r
113 @param Context The USB CBI protocol\r
114 @param ExtendedVerification The flag controlling the rule of reset.\r
115 Not used here.\r
116\r
117 @retval EFI_SUCCESS The device is reset.\r
118 @retval Others Failed to reset the device.\r
119\r
120**/\r
121EFI_STATUS\r
122UsbCbiResetDevice (\r
123 IN VOID *Context,\r
124 IN BOOLEAN ExtendedVerification\r
125 );\r
126\r
127/**\r
128 Clean up the CBI protocol's resource.\r
129\r
130 @param Context The instance of CBI protocol.\r
131\r
132 @retval EFI_SUCCESS The resource is cleaned up.\r
133\r
134**/\r
135EFI_STATUS\r
136UsbCbiCleanUp (\r
137 IN VOID *Context\r
138 );\r
139\r
e237e7ae 140#endif\r