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