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