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