]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Ppi/PeiBlockIo.h
Vlv2DeviceRefCodePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2DeviceRefCodePkg / ValleyView2Soc / SouthCluster / Include / Ppi / PeiBlockIo.h
1 /** @file
2 Block IO protocol as defined in the UEFI 2.0 specification.
3
4 The Block IO protocol is used to abstract block devices like hard drives,
5 DVD-ROMs and floppy drives.
6
7 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #ifndef __PEI_BLOCK_IO_H__
13 #define __PEI_BLOCK_IO_H__
14 // {BC5FA650-EDBB-4d0d-B3A3-D98907F847DF}
15 #ifndef ECP_FLAG
16 #define PEI_BLOCK_IO_PPI_GUID \
17 { \
18 0xbc5fa650, 0xedbb, 0x4d0d, { 0xb3, 0xa3, 0xd9, 0x89, 0x7, 0xf8, 0x47, 0xdf } \
19 }
20 #endif
21 typedef struct _PEI_BLOCK_IO_PPI PEI_BLOCK_IO_PPI;
22
23
24 /**
25 Reset the Block Device.
26
27 @param This Indicates a pointer to the calling context.
28 @param ExtendedVerification Driver may perform diagnostics on reset.
29
30 @retval EFI_SUCCESS The device was reset.
31 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
32 not be reset.
33
34 **/
35 typedef
36 EFI_STATUS
37 (EFIAPI *PEI_BLOCK_RESET)(
38 IN PEI_BLOCK_IO_PPI *This,
39 IN BOOLEAN ExtendedVerification
40 );
41
42 /**
43 Read BufferSize bytes from Lba into Buffer.
44
45 @param This Indicates a pointer to the calling context.
46 @param MediaId Id of the media, changes every time the media is replaced.
47 @param Lba The starting Logical Block Address to read from
48 @param BufferSize Size of Buffer, must be a multiple of device block size.
49 @param Buffer A pointer to the destination buffer for the data. The caller is
50 responsible for either having implicit or explicit ownership of the buffer.
51
52 @retval EFI_SUCCESS The data was read correctly from the device.
53 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
54 @retval EFI_NO_MEDIA There is no media in the device.
55 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
56 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
57 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
58 or the buffer is not on proper alignment.
59
60 **/
61 typedef
62 EFI_STATUS
63 (EFIAPI *PEI_BLOCK_READ)(
64 IN EFI_PEI_SERVICES **PeiServices,
65 IN PEI_BLOCK_IO_PPI *This,
66 IN UINT32 MediaId,
67 IN EFI_LBA Lba,
68 IN UINTN BufferSize,
69 OUT VOID *Buffer
70 );
71
72 /**
73 Write BufferSize bytes from Lba into Buffer.
74
75 @param This Indicates a pointer to the calling context.
76 @param MediaId The media ID that the write request is for.
77 @param Lba The starting logical block address to be written. The caller is
78 responsible for writing to only legitimate locations.
79 @param BufferSize Size of Buffer, must be a multiple of device block size.
80 @param Buffer A pointer to the source buffer for the data.
81
82 @retval EFI_SUCCESS The data was written correctly to the device.
83 @retval EFI_WRITE_PROTECTED The device can not be written to.
84 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
85 @retval EFI_NO_MEDIA There is no media in the device.
86 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
87 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
88 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
89 or the buffer is not on proper alignment.
90
91 **/
92 typedef
93 EFI_STATUS
94 (EFIAPI *PEI_BLOCK_WRITE)(
95 IN EFI_PEI_SERVICES **PeiServices,
96 IN PEI_BLOCK_IO_PPI *This,
97 IN UINT32 MediaId,
98 IN EFI_LBA Lba,
99 IN UINTN BufferSize,
100 IN VOID *Buffer
101 );
102
103 /**
104 Flush the Block Device.
105
106 @param This Indicates a pointer to the calling context.
107
108 @retval EFI_SUCCESS All outstanding data was written to the device
109 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
110 @retval EFI_NO_MEDIA There is no media in the device.
111
112 **/
113 typedef
114 EFI_STATUS
115 (EFIAPI *PEI_BLOCK_FLUSH)(
116 IN PEI_BLOCK_IO_PPI *This
117 );
118
119 /**
120 Block IO read only mode data and updated only via members of BlockIO
121 **/
122 typedef struct {
123 ///
124 /// The curent media Id. If the media changes, this value is changed.
125 ///
126 UINT32 MediaId;
127
128 ///
129 /// TRUE if the media is removable; otherwise, FALSE.
130 ///
131 BOOLEAN RemovableMedia;
132
133 ///
134 /// TRUE if there is a media currently present in the device;
135 /// othersise, FALSE. THis field shows the media present status
136 /// as of the most recent ReadBlocks() or WriteBlocks() call.
137 ///
138 BOOLEAN MediaPresent;
139
140 ///
141 /// TRUE if LBA 0 is the first block of a partition; otherwise
142 /// FALSE. For media with only one partition this would be TRUE.
143 ///
144 BOOLEAN LogicalPartition;
145
146 ///
147 /// TRUE if the media is marked read-only otherwise, FALSE.
148 /// This field shows the read-only status as of the most recent WriteBlocks () call.
149 ///
150 BOOLEAN ReadOnly;
151
152 ///
153 /// TRUE if the WriteBlock () function caches write data.
154 ///
155 BOOLEAN WriteCaching;
156
157 ///
158 /// The intrinsic block size of the device. If the media changes, then
159 /// this field is updated.
160 ///
161 UINT32 BlockSize;
162
163 ///
164 /// Supplies the alignment requirement for any buffer to read or write block(s).
165 ///
166 UINT32 IoAlign;
167
168 ///
169 /// The last logical block address on the device.
170 /// If the media changes, then this field is updated.
171 ///
172 EFI_LBA LastBlock;
173
174 ///
175 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
176 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to
177 /// a physical block boundary.
178 ///
179 EFI_LBA LowestAlignedLba;
180
181 ///
182 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
183 /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks
184 /// per physical block.
185 ///
186 UINT32 LogicalBlocksPerPhysicalBlock;
187
188 ///
189 /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
190 /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length
191 /// granularity as a number of logical blocks.
192 ///
193 UINT32 OptimalTransferLengthGranularity;
194 #ifdef ECP_FLAG
195 } PEI_BLOCK_IO_MEDIA2;
196 #else
197 } PEI_BLOCK_IO_MEDIA;
198 #endif
199 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
200 #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
201 #define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031
202
203 ///
204 /// Revision defined in EFI1.1.
205 ///
206 #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
207
208 ///
209 /// This protocol provides control over block devices.
210 ///
211 struct _PEI_BLOCK_IO_PPI {
212 ///
213 /// The revision to which the block IO interface adheres. All future
214 /// revisions must be backwards compatible. If a future version is not
215 /// back wards compatible, it is not the same GUID.
216 ///
217 UINT64 Revision;
218 ///
219 /// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.
220 ///
221 PEI_BLOCK_IO_MEDIA *Media;
222 PEI_BLOCK_RESET Reset;
223 PEI_BLOCK_READ ReadBlocks;
224 PEI_BLOCK_WRITE WriteBlocks;
225 PEI_BLOCK_FLUSH FlushBlocks;
226 };
227
228 //extern EFI_GUID gEfiBlockIoProtocolGuid;
229 extern EFI_GUID gPeiBlockIoPpiGuid;
230 #endif