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