]>
Commit | Line | Data |
---|---|---|
4b1bf81c | 1 | /** @file\r |
2 | BOT Transportation implementation.\r | |
3 | \r | |
d1102dba LG |
4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
5 | \r | |
4b1bf81c | 6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _PEI_BOT_PEIM_H_\r | |
18 | #define _PEI_BOT_PEIM_H_\r | |
19 | \r | |
20 | \r | |
21 | #include <PiPei.h>\r | |
22 | \r | |
23 | #include <Ppi/UsbIo.h>\r | |
24 | #include <Ppi/UsbHostController.h>\r | |
25 | #include <Ppi/BlockIo.h>\r | |
26 | \r | |
27 | //#include <Library/DebugLib.h>\r | |
28 | #include <Library/PeimEntryPoint.h>\r | |
29 | #include <Library/PeiServicesLib.h>\r | |
30 | #include <Library/BaseMemoryLib.h>\r | |
31 | \r | |
32 | #include <IndustryStandard/Atapi.h>\r | |
33 | \r | |
34 | #pragma pack(1)\r | |
35 | //\r | |
36 | // Bulk Only device protocol\r | |
37 | //\r | |
38 | typedef struct {\r | |
39 | UINT32 Signature;\r | |
40 | UINT32 Tag;\r | |
41 | UINT32 DataTransferLength;\r | |
42 | UINT8 Flags;\r | |
43 | UINT8 Lun;\r | |
44 | UINT8 CmdLen;\r | |
45 | UINT8 CmdBlock[16];\r | |
46 | } CBW;\r | |
47 | \r | |
48 | typedef struct {\r | |
49 | UINT32 Signature;\r | |
50 | UINT32 Tag;\r | |
51 | UINT32 DataResidue;\r | |
52 | UINT8 Status;\r | |
53 | } CSW;\r | |
54 | \r | |
55 | #pragma pack()\r | |
56 | //\r | |
57 | // Status code, see Usb Bot device spec\r | |
58 | //\r | |
59 | #define CSWSIG 0x53425355\r | |
60 | #define CBWSIG 0x43425355\r | |
61 | \r | |
62 | /**\r | |
63 | Sends out ATAPI Inquiry Packet Command to the specified device. This command will\r | |
64 | return INQUIRY data of the device.\r | |
65 | \r | |
66 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
67 | @param PeiBotDevice The pointer to PEI_BOT_DEVICE instance.\r | |
68 | \r | |
69 | @retval EFI_SUCCESS Inquiry command completes successfully.\r | |
70 | @retval EFI_DEVICE_ERROR Inquiry command failed.\r | |
71 | \r | |
72 | **/\r | |
73 | EFI_STATUS\r | |
74 | PeiUsbInquiry (\r | |
75 | IN EFI_PEI_SERVICES **PeiServices,\r | |
76 | IN PEI_BOT_DEVICE *PeiBotDevice\r | |
77 | );\r | |
78 | \r | |
79 | /**\r | |
80 | Sends out ATAPI Test Unit Ready Packet Command to the specified device\r | |
81 | to find out whether device is accessible.\r | |
82 | \r | |
83 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
84 | @param PeiBotDevice The pointer to PEI_BOT_DEVICE instance.\r | |
85 | \r | |
86 | @retval EFI_SUCCESS TestUnit command executed successfully.\r | |
87 | @retval EFI_DEVICE_ERROR Device cannot be executed TestUnit command successfully.\r | |
88 | \r | |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | PeiUsbTestUnitReady (\r | |
92 | IN EFI_PEI_SERVICES **PeiServices,\r | |
93 | IN PEI_BOT_DEVICE *PeiBotDevice\r | |
94 | );\r | |
95 | \r | |
96 | /**\r | |
97 | Sends out ATAPI Request Sense Packet Command to the specified device.\r | |
98 | \r | |
99 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
100 | @param PeiBotDevice The pointer to PEI_BOT_DEVICE instance.\r | |
101 | @param SenseCounts Length of sense buffer.\r | |
102 | @param SenseKeyBuffer Pointer to sense buffer.\r | |
103 | \r | |
104 | @retval EFI_SUCCESS Command executed successfully.\r | |
105 | @retval EFI_DEVICE_ERROR Some device errors happen.\r | |
106 | \r | |
107 | **/\r | |
108 | EFI_STATUS\r | |
109 | PeiUsbRequestSense (\r | |
110 | IN EFI_PEI_SERVICES **PeiServices,\r | |
111 | IN PEI_BOT_DEVICE *PeiBotDevice,\r | |
112 | OUT UINTN *SenseCounts,\r | |
113 | IN UINT8 *SenseKeyBuffer\r | |
114 | );\r | |
115 | \r | |
116 | /**\r | |
117 | Sends out ATAPI Read Capacity Packet Command to the specified device.\r | |
118 | This command will return the information regarding the capacity of the\r | |
119 | media in the device.\r | |
120 | \r | |
121 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
122 | @param PeiBotDevice The pointer to PEI_BOT_DEVICE instance.\r | |
123 | \r | |
124 | @retval EFI_SUCCESS Command executed successfully.\r | |
125 | @retval EFI_DEVICE_ERROR Some device errors happen.\r | |
126 | \r | |
127 | **/\r | |
128 | EFI_STATUS\r | |
129 | PeiUsbReadCapacity (\r | |
130 | IN EFI_PEI_SERVICES **PeiServices,\r | |
131 | IN PEI_BOT_DEVICE *PeiBotDevice\r | |
132 | );\r | |
133 | \r | |
134 | /**\r | |
135 | Sends out ATAPI Read Format Capacity Data Command to the specified device.\r | |
136 | This command will return the information regarding the capacity of the\r | |
137 | media in the device.\r | |
138 | \r | |
139 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
140 | @param PeiBotDevice The pointer to PEI_BOT_DEVICE instance.\r | |
141 | \r | |
142 | @retval EFI_SUCCESS Command executed successfully.\r | |
143 | @retval EFI_DEVICE_ERROR Some device errors happen.\r | |
144 | \r | |
145 | **/\r | |
146 | EFI_STATUS\r | |
147 | PeiUsbReadFormattedCapacity (\r | |
148 | IN EFI_PEI_SERVICES **PeiServices,\r | |
149 | IN PEI_BOT_DEVICE *PeiBotDevice\r | |
150 | );\r | |
151 | \r | |
152 | /**\r | |
153 | Execute Read(10) ATAPI command on a specific SCSI target.\r | |
154 | \r | |
155 | Executes the ATAPI Read(10) command on the ATAPI target specified by PeiBotDevice.\r | |
156 | \r | |
157 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
158 | @param PeiBotDevice The pointer to PEI_BOT_DEVICE instance.\r | |
159 | @param Buffer The pointer to data buffer.\r | |
160 | @param Lba The start logic block address of reading.\r | |
161 | @param NumberOfBlocks The block number of reading.\r | |
162 | \r | |
163 | @retval EFI_SUCCESS Command executed successfully.\r | |
164 | @retval EFI_DEVICE_ERROR Some device errors happen.\r | |
165 | \r | |
166 | **/\r | |
167 | EFI_STATUS\r | |
168 | PeiUsbRead10 (\r | |
169 | IN EFI_PEI_SERVICES **PeiServices,\r | |
170 | IN PEI_BOT_DEVICE *PeiBotDevice,\r | |
171 | IN VOID *Buffer,\r | |
172 | IN EFI_PEI_LBA Lba,\r | |
173 | IN UINTN NumberOfBlocks\r | |
174 | );\r | |
175 | \r | |
d1102dba | 176 | /**\r |
4b1bf81c | 177 | Check if there is media according to sense data.\r |
178 | \r | |
179 | @param SenseData Pointer to sense data.\r | |
180 | @param SenseCounts Count of sense data.\r | |
181 | \r | |
182 | @retval TRUE No media\r | |
183 | @retval FALSE Media exists\r | |
184 | \r | |
185 | **/\r | |
186 | BOOLEAN\r | |
187 | IsNoMedia (\r | |
188 | IN ATAPI_REQUEST_SENSE_DATA *SenseData,\r | |
189 | IN UINTN SenseCounts\r | |
190 | );\r | |
191 | \r | |
d1102dba | 192 | /**\r |
4b1bf81c | 193 | Check if there is media error according to sense data.\r |
194 | \r | |
195 | @param SenseData Pointer to sense data.\r | |
196 | @param SenseCounts Count of sense data.\r | |
197 | \r | |
198 | @retval TRUE Media error\r | |
199 | @retval FALSE No media error\r | |
200 | \r | |
201 | **/\r | |
202 | BOOLEAN\r | |
203 | IsMediaError (\r | |
204 | IN ATAPI_REQUEST_SENSE_DATA *SenseData,\r | |
205 | IN UINTN SenseCounts\r | |
206 | );\r | |
207 | \r | |
d1102dba | 208 | /**\r |
4b1bf81c | 209 | Check if media is changed according to sense data.\r |
210 | \r | |
211 | @param SenseData Pointer to sense data.\r | |
212 | @param SenseCounts Count of sense data.\r | |
213 | \r | |
214 | @retval TRUE There is media change event.\r | |
215 | @retval FALSE media is NOT changed.\r | |
216 | \r | |
217 | **/\r | |
218 | BOOLEAN\r | |
219 | IsMediaChange (\r | |
220 | IN ATAPI_REQUEST_SENSE_DATA *SenseData,\r | |
221 | IN UINTN SenseCounts\r | |
222 | );\r | |
223 | \r | |
224 | #endif\r |