]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Ppi/BlockIo2.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Ppi / BlockIo2.h
CommitLineData
4c5acce7
FT
1/** @file\r
2 Provides the services required to access a block I/O 2 device during PEI recovery\r
3 boot mode.\r
4\r
5Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
9344f092 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
4c5acce7
FT
7\r
8 @par Revision Reference:\r
9 This PPI is defined in UEFI Platform Initialization Specification 1.4 Volume 1:\r
10 Pre-EFI Initalization Core Interface.\r
11\r
12**/\r
13\r
14#ifndef _PEI_BLOCK_IO2_H_\r
15#define _PEI_BLOCK_IO2_H_\r
16\r
17#include <Ppi/BlockIo.h>\r
18#include <Protocol/DevicePath.h>\r
19\r
20///\r
21/// Global ID for EFI_PEI_RECOVERY_BLOCK_IO2_PPI\r
22///\r
23#define EFI_PEI_RECOVERY_BLOCK_IO2_PPI_GUID \\r
24 { \\r
25 0x26cc0fad, 0xbeb3, 0x478a, { 0x91, 0xb2, 0xc, 0x18, 0x8f, 0x72, 0x61, 0x98 } \\r
26 }\r
27\r
28///\r
29/// The forward declaration for EFI_PEI_RECOVERY_BLOCK_IO_PPI.\r
30///\r
31typedef struct _EFI_PEI_RECOVERY_BLOCK_IO2_PPI EFI_PEI_RECOVERY_BLOCK_IO2_PPI;\r
32\r
33#define EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION 0x00010000\r
34\r
35typedef struct {\r
36 ///\r
37 /// A type of interface that the device being referenced by DeviceIndex is\r
38 /// attached to. This field re-uses Messaging Device Path Node sub-type values\r
39 /// as defined by Section 9.3.5 Messaging Device Path of UEFI Specification.\r
40 /// When more than one sub-type is associated with the interface, sub-type with\r
41 /// the smallest number must be used.\r
42 ///\r
43 UINT8 InterfaceType;\r
44 ///\r
45 /// A flag that indicates if media is removable.\r
46 ///\r
47 BOOLEAN RemovableMedia;\r
48 ///\r
49 /// A flag that indicates if media is present. This flag is always set for\r
50 /// non-removable media devices.\r
51 ///\r
52 BOOLEAN MediaPresent;\r
53 ///\r
54 /// A flag that indicates if media is read-only.\r
55 ///\r
56 BOOLEAN ReadOnly;\r
57 ///\r
58 /// The size of a logical block in bytes.\r
59 ///\r
60 UINT32 BlockSize;\r
61 ///\r
62 /// The last logical block that the device supports.\r
63 ///\r
64 EFI_PEI_LBA LastBlock;\r
65} EFI_PEI_BLOCK_IO2_MEDIA;\r
66\r
67/**\r
68 Gets the count of block I/O devices that one specific block driver detects.\r
69\r
70 This function is used for getting the count of block I/O devices that one\r
71 specific block driver detects. To the PEI ATAPI driver, it returns the number\r
72 of all the detected ATAPI devices it detects during the enumeration process.\r
73 To the PEI legacy floppy driver, it returns the number of all the legacy\r
74 devices it finds during its enumeration process. If no device is detected,\r
75 then the function will return zero.\r
76\r
77 @param[in] PeiServices General-purpose services that are available\r
78 to every PEIM.\r
79 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI\r
80 instance.\r
81 @param[out] NumberBlockDevices The number of block I/O devices discovered.\r
82\r
83 @retval EFI_SUCCESS The operation performed successfully.\r
84\r
85**/\r
86typedef\r
87EFI_STATUS\r
88(EFIAPI *EFI_PEI_GET_NUMBER_BLOCK_DEVICES2)(\r
89 IN EFI_PEI_SERVICES **PeiServices,\r
90 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
91 OUT UINTN *NumberBlockDevices\r
92 );\r
93\r
94/**\r
95 Gets a block device's media information.\r
96\r
97 This function will provide the caller with the specified block device's media\r
98 information. If the media changes, calling this function will update the media\r
99 information accordingly.\r
100\r
101 @param[in] PeiServices General-purpose services that are available to every\r
102 PEIM\r
103 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
104 @param[in] DeviceIndex Specifies the block device to which the function wants\r
105 to talk. Because the driver that implements Block I/O\r
106 PPIs will manage multiple block devices, the PPIs that\r
107 want to talk to a single device must specify the\r
108 device index that was assigned during the enumeration\r
109 process. This index is a number from one to\r
110 NumberBlockDevices.\r
111 @param[out] MediaInfo The media information of the specified block media.\r
112 The caller is responsible for the ownership of this\r
113 data structure.\r
114\r
115 @par Note:\r
116 The MediaInfo structure describes an enumeration of possible block device\r
117 types. This enumeration exists because no device paths are actually passed\r
118 across interfaces that describe the type or class of hardware that is publishing\r
119 the block I/O interface. This enumeration will allow for policy decisions\r
120 in the Recovery PEIM, such as "Try to recover from legacy floppy first,\r
121 LS-120 second, CD-ROM third." If there are multiple partitions abstracted\r
122 by a given device type, they should be reported in ascending order; this\r
123 order also applies to nested partitions, such as legacy MBR, where the\r
124 outermost partitions would have precedence in the reporting order. The\r
125 same logic applies to systems such as IDE that have precedence relationships\r
126 like "Master/Slave" or "Primary/Secondary". The master device should be\r
127 reported first, the slave second.\r
128\r
129 @retval EFI_SUCCESS Media information about the specified block device\r
130 was obtained successfully.\r
131 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware\r
132 error.\r
133\r
134**/\r
135typedef\r
136EFI_STATUS\r
137(EFIAPI *EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2)(\r
138 IN EFI_PEI_SERVICES **PeiServices,\r
139 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
140 IN UINTN DeviceIndex,\r
141 OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo\r
142 );\r
143\r
144/**\r
145 Reads the requested number of blocks from the specified block device.\r
146\r
147 The function reads the requested number of blocks from the device. All the\r
148 blocks are read, or an error is returned. If there is no media in the device,\r
149 the function returns EFI_NO_MEDIA.\r
150\r
151 @param[in] PeiServices General-purpose services that are available to\r
152 every PEIM.\r
153 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
154 @param[in] DeviceIndex Specifies the block device to which the function wants\r
155 to talk. Because the driver that implements Block I/O\r
156 PPIs will manage multiple block devices, PPIs that\r
157 want to talk to a single device must specify the device\r
158 index that was assigned during the enumeration process.\r
159 This index is a number from one to NumberBlockDevices.\r
160 @param[in] StartLBA The starting logical block address (LBA) to read from\r
161 on the device\r
162 @param[in] BufferSize The size of the Buffer in bytes. This number must be\r
163 a multiple of the intrinsic block size of the device.\r
164 @param[out] Buffer A pointer to the destination buffer for the data.\r
165 The caller is responsible for the ownership of the\r
166 buffer.\r
167\r
168 @retval EFI_SUCCESS The data was read correctly from the device.\r
169 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
170 to perform the read operation.\r
171 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
172 valid, or the buffer is not properly aligned.\r
173 @retval EFI_NO_MEDIA There is no media in the device.\r
174 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
175 the intrinsic block size of the device.\r
176\r
177**/\r
178typedef\r
179EFI_STATUS\r
180(EFIAPI *EFI_PEI_READ_BLOCKS2)(\r
181 IN EFI_PEI_SERVICES **PeiServices,\r
182 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,\r
183 IN UINTN DeviceIndex,\r
184 IN EFI_PEI_LBA StartLBA,\r
185 IN UINTN BufferSize,\r
186 OUT VOID *Buffer\r
187 );\r
188\r
189///\r
190/// EFI_PEI_RECOVERY_BLOCK_IO_PPI provides the services that are required\r
191/// to access a block I/O device during PEI recovery boot mode.\r
192///\r
193struct _EFI_PEI_RECOVERY_BLOCK_IO2_PPI {\r
194 ///\r
195 /// The revision to which the interface adheres.\r
196 /// All future revisions must be backwards compatible.\r
197 ///\r
198 UINT64 Revision;\r
199 ///\r
200 /// Gets the number of block I/O devices that the specific block driver manages.\r
201 ///\r
202 EFI_PEI_GET_NUMBER_BLOCK_DEVICES2 GetNumberOfBlockDevices;\r
203\r
204 ///\r
205 /// Gets the specified media information.\r
206 ///\r
207 EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2 GetBlockDeviceMediaInfo;\r
208\r
209 ///\r
210 /// Reads the requested number of blocks from the specified block device.\r
211 ///\r
212 EFI_PEI_READ_BLOCKS2 ReadBlocks;\r
213};\r
214\r
215extern EFI_GUID gEfiPeiVirtualBlockIo2PpiGuid;\r
216\r
217#endif\r