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