]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[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
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
e237e7ae 7\r
e237e7ae 8**/\r
9\r
10#ifndef _EFI_USBMASS_CBI_H_\r
11#define _EFI_USBMASS_CBI_H_\r
12\r
d80ed2a7 13extern USB_MASS_TRANSPORT mUsbCbi0Transport;\r
14extern USB_MASS_TRANSPORT mUsbCbi1Transport;\r
15\r
1ccdbf2a 16#define USB_CBI_MAX_PACKET_NUM 16\r
17#define USB_CBI_RESET_CMD_LEN 12\r
18//\r
19// USB CBI retry C/B/I transport times, set by experience\r
20//\r
21#define USB_CBI_MAX_RETRY 3\r
22//\r
23// Time to wait for USB CBI reset to complete, set by experience\r
d1102dba 24//\r
1ccdbf2a 25#define USB_CBI_RESET_DEVICE_STALL (50 * USB_MASS_1_MILLISECOND)\r
26//\r
27// USB CBI transport timeout, set by experience\r
28//\r
29#define USB_CBI_RESET_DEVICE_TIMEOUT (1 * USB_MASS_1_SECOND)\r
e237e7ae 30\r
e237e7ae 31typedef struct {\r
d80ed2a7 32 //\r
33 // Put Interface at the first field to make it easy to distinguish BOT/CBI Protocol instance\r
34 //\r
e237e7ae 35 EFI_USB_INTERFACE_DESCRIPTOR Interface;\r
36 EFI_USB_ENDPOINT_DESCRIPTOR *BulkInEndpoint;\r
37 EFI_USB_ENDPOINT_DESCRIPTOR *BulkOutEndpoint;\r
38 EFI_USB_ENDPOINT_DESCRIPTOR *InterruptEndpoint;\r
39 EFI_USB_IO_PROTOCOL *UsbIo;\r
40} USB_CBI_PROTOCOL;\r
41\r
42#pragma pack(1)\r
43typedef struct {\r
44 UINT8 Type;\r
45 UINT8 Value;\r
46} USB_CBI_STATUS;\r
47#pragma pack()\r
48\r
d80ed2a7 49/**\r
50 Initializes USB CBI protocol.\r
51\r
52 This function initializes the USB mass storage class CBI protocol.\r
53 It will save its context which is a USB_CBI_PROTOCOL structure\r
54 in the Context if Context isn't NULL.\r
55\r
56 @param UsbIo The USB I/O Protocol instance\r
57 @param Context The buffer to save the context to\r
58\r
59 @retval EFI_SUCCESS The device is successfully initialized.\r
60 @retval EFI_UNSUPPORTED The transport protocol doesn't support the device.\r
61 @retval Other The USB CBI initialization fails.\r
62\r
63**/\r
64EFI_STATUS\r
65UsbCbiInit (\r
66 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
67 OUT VOID **Context OPTIONAL\r
68 );\r
69\r
70/**\r
71 Execute USB mass storage command through the CBI0/CBI1 transport protocol.\r
72\r
73 @param Context The USB CBI Protocol.\r
74 @param Cmd The command to transfer to device\r
75 @param CmdLen The length of the command\r
76 @param DataDir The direction of data transfer\r
77 @param Data The buffer to hold the data\r
78 @param DataLen The length of the buffer\r
79 @param Lun Should be 0, this field for bot only\r
80 @param Timeout The time to wait\r
81 @param CmdStatus The result of the command execution\r
82\r
83 @retval EFI_SUCCESS The command is executed successfully.\r
84 @retval Other Failed to execute the command\r
85\r
86**/\r
87EFI_STATUS\r
88UsbCbiExecCommand (\r
89 IN VOID *Context,\r
90 IN VOID *Cmd,\r
91 IN UINT8 CmdLen,\r
92 IN EFI_USB_DATA_DIRECTION DataDir,\r
93 IN VOID *Data,\r
94 IN UINT32 DataLen,\r
95 IN UINT8 Lun,\r
96 IN UINT32 Timeout,\r
97 OUT UINT32 *CmdStatus\r
98 );\r
99\r
100/**\r
101 Reset the USB mass storage device by CBI protocol.\r
102\r
103 This function resets the USB mass storage device by CBI protocol.\r
104 The reset is defined as a non-data command. Don't use UsbCbiExecCommand\r
105 to send the command to device because that may introduce recursive loop.\r
106\r
107 @param Context The USB CBI protocol\r
108 @param ExtendedVerification The flag controlling the rule of reset.\r
109 Not used here.\r
110\r
111 @retval EFI_SUCCESS The device is reset.\r
112 @retval Others Failed to reset the device.\r
113\r
114**/\r
115EFI_STATUS\r
116UsbCbiResetDevice (\r
117 IN VOID *Context,\r
118 IN BOOLEAN ExtendedVerification\r
119 );\r
120\r
121/**\r
122 Clean up the CBI protocol's resource.\r
123\r
124 @param Context The instance of CBI protocol.\r
125\r
126 @retval EFI_SUCCESS The resource is cleaned up.\r
127\r
128**/\r
129EFI_STATUS\r
130UsbCbiCleanUp (\r
131 IN VOID *Context\r
132 );\r
133\r
e237e7ae 134#endif\r