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