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