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