]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
modify coding style to pass ecc tool
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMass.h
1 /** @file
2
3 Defination for the USB mass storage class driver. The USB mass storage
4 class is specified in two layers: the bottom layer is the transportation
5 protocol. The top layer is the command set. The transportation layer
6 provides the transportation of the command, data and result. The command
7 set defines what the command, data and result. The Bulk-Only-Transport and
8 Control/Bulk/Interrupt transport are two transportation protocol. USB mass
9 storage class adopts various industrial standard as its command set.
10
11 Copyright (c) 2007 - 2008, Intel Corporation
12 All rights reserved. This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
16
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19
20 **/
21
22 #ifndef _EFI_USBMASS_H_
23 #define _EFI_USBMASS_H_
24
25
26 #include <PiDxe.h>
27
28 #include <Protocol/BlockIo.h>
29 #include <Protocol/UsbIo.h>
30 #include <Protocol/DevicePath.h>
31
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/DevicePathLib.h>
39
40 #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0x80)
41 #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0)
42 #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x02)
43 #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x03)
44 #define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)
45
46 typedef enum {
47 //
48 // Usb mass storage class code
49 //
50 USB_MASS_STORE_CLASS = 0x08,
51
52 //
53 // Usb mass storage subclass code, specify the command set used.
54 //
55 USB_MASS_STORE_RBC = 0x01, // Reduced Block Commands
56 USB_MASS_STORE_8020I = 0x02, // SFF-8020i, typically a CD/DVD device
57 USB_MASS_STORE_QIC = 0x03, // Typically a tape device
58 USB_MASS_STORE_UFI = 0x04, // Typically a floppy disk driver device
59 USB_MASS_STORE_8070I = 0x05, // SFF-8070i, typically a floppy disk driver device.
60 USB_MASS_STORE_SCSI = 0x06, // SCSI transparent command set
61
62 //
63 // Usb mass storage protocol code, specify the transport protocol
64 //
65 USB_MASS_STORE_CBI0 = 0x00, // CBI protocol with command completion interrupt
66 USB_MASS_STORE_CBI1 = 0x01, // CBI protocol without command completion interrupt
67 USB_MASS_STORE_BOT = 0x50, // Bulk-Only Transport
68
69 USB_MASS_1_MILLISECOND = 1000,
70 USB_MASS_1_SECOND = 1000 * USB_MASS_1_MILLISECOND,
71
72 USB_MASS_CMD_SUCCESS = 0,
73 USB_MASS_CMD_FAIL,
74 USB_MASS_CMD_PERSISTENT
75 }USB_MASS_DEV_CLASS_AND_VALUE;
76
77 typedef
78 EFI_STATUS
79 (*USB_MASS_INIT_TRANSPORT) (
80 IN EFI_USB_IO_PROTOCOL *Usb,
81 OUT VOID **Context OPTIONAL
82 );
83
84 typedef
85 EFI_STATUS
86 (*USB_MASS_EXEC_COMMAND) (
87 IN VOID *Context,
88 IN VOID *Cmd,
89 IN UINT8 CmdLen,
90 IN EFI_USB_DATA_DIRECTION DataDir,
91 IN VOID *Data,
92 IN UINT32 DataLen,
93 IN UINT8 Lun,
94 IN UINT32 Timeout,
95 OUT UINT32 *CmdStatus
96 );
97
98 typedef
99 EFI_STATUS
100 (*USB_MASS_RESET) (
101 IN VOID *Context,
102 IN BOOLEAN ExtendedVerification
103 );
104
105 typedef
106 EFI_STATUS
107 (*USB_MASS_GET_MAX_LUN) (
108 IN VOID *Context,
109 IN UINT8 *MaxLun
110 );
111
112 typedef
113 EFI_STATUS
114 (*USB_MASS_FINI) (
115 IN VOID *Context
116 );
117
118 //
119 // This structure contains information necessary to select the
120 // proper transport protocol. The mass storage class defines
121 // two transport protocols. One is the CBI, and the other is BOT.
122 // CBI is being obseleted. The design is made modular by this
123 // structure so that the CBI protocol can be easily removed when
124 // it is no longer necessary.
125 //
126 typedef struct {
127 UINT8 Protocol;
128 USB_MASS_INIT_TRANSPORT Init; // Initialize the mass storage transport protocol
129 USB_MASS_EXEC_COMMAND ExecCommand; // Transport command to the device then get result
130 USB_MASS_RESET Reset; // Reset the device
131 USB_MASS_GET_MAX_LUN GetMaxLun; // Get max lun, only for bot
132 USB_MASS_FINI Fini; // Clean up the resources.
133 } USB_MASS_TRANSPORT;
134
135
136 /**
137 Use the USB clear feature control transfer to clear the endpoint
138 stall condition.
139
140 @param UsbIo The USB IO protocol to use
141 @param EndpointAddr The endpoint to clear stall for
142
143 @retval EFI_SUCCESS The endpoint stall condtion is clear
144 @retval Others Failed to clear the endpoint stall condtion
145
146 **/
147 EFI_STATUS
148 UsbClearEndpointStall (
149 IN EFI_USB_IO_PROTOCOL *UsbIo,
150 IN UINT8 EndpointAddr
151 );
152
153 #endif