]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.h
Update the copyright notice format
[mirror_edk2.git] / OvmfPkg / BlockMmioToBlockIoDxe / BlockIo.h
CommitLineData
efd82c57 1/** @file\r
2 Definitions of functions for Driver Binding Protocol and Block I/O Protocol,\r
3 and other internal definitions.\r
4\r
56d7640a
HT
5 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
efd82c57 7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _EFI_BLOCK_MMIO_TO_BLOCK_IO_H_\r
17#define _EFI_BLOCK_MMIO_TO_BLOCK_IO_H_\r
18\r
19#include <Uefi.h>\r
20#include <Protocol/BlockMmio.h>\r
21#include <Protocol/ComponentName.h>\r
22#include <Protocol/ComponentName2.h>\r
23#include <Protocol/CpuIo2.h>\r
24#include <Protocol/DevicePath.h>\r
25#include <Protocol/DriverBinding.h>\r
26#include <Library/BaseLib.h>\r
27#include <Library/DebugLib.h>\r
28#include <Library/MemoryAllocationLib.h>\r
29#include <Library/UefiBootServicesTableLib.h>\r
30#include <Library/UefiLib.h>\r
31\r
32#define BLOCK_MMIO_TO_BLOCK_IO_SIGNATURE SIGNATURE_32 ('B', 'M', 'I', 'O')\r
33\r
34#define PRIVATE_FROM_BLOCK_IO(a) \\r
35 CR (a, BLOCK_MMIO_TO_BLOCK_IO_DEVICE, BlockIo, BLOCK_MMIO_TO_BLOCK_IO_SIGNATURE)\r
36\r
37extern EFI_COMPONENT_NAME_PROTOCOL gBlockMmioToBlockIoComponentName;\r
38extern EFI_COMPONENT_NAME2_PROTOCOL gBlockMmioToBlockIoComponentName2;\r
39\r
40typedef struct {\r
41 UINT32 Signature;\r
42 EFI_HANDLE Controller;\r
43 BLOCK_MMIO_PROTOCOL *BlockMmio;\r
44 EFI_CPU_IO2_PROTOCOL *CpuIo;\r
45 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
46 EFI_BLOCK_IO_PROTOCOL BlockIo;\r
47} BLOCK_MMIO_TO_BLOCK_IO_DEVICE;\r
48\r
49//\r
50// Functions for Driver Binding Protocol\r
51//\r
52\r
53/**\r
54 Check whether the controller is a supported.\r
55\r
56 @param This The driver binding protocol.\r
57 @param Controller The controller handle to check.\r
58 @param RemainingDevicePath The remaining device path.\r
59\r
60 @retval EFI_SUCCESS The driver supports this controller.\r
61 @retval other This device isn't supported.\r
62\r
63**/\r
64EFI_STATUS\r
65EFIAPI\r
66BlockIoDriverBindingSupported (\r
67 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
68 IN EFI_HANDLE Controller,\r
69 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
70 );\r
71\r
72/**\r
73 Starts the BlockIo device with this driver.\r
74\r
75 This function consumes Block MMIO Portocol and\r
76 installs Block I/O Protocol.\r
77\r
78 @param This The driver binding protocol.\r
79 @param Controller The Block MMIO device to start on\r
80 @param RemainingDevicePath The remaining device path.\r
81\r
82 @retval EFI_SUCCESS This driver supports this device.\r
83 @retval EFI_UNSUPPORTED This driver does not support this device.\r
84 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error.\r
85 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
86 @retval EFI_ALREADY_STARTED This driver has been started.\r
87\r
88**/\r
89EFI_STATUS\r
90EFIAPI\r
91BlockIoDriverBindingStart (\r
92 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
93 IN EFI_HANDLE Controller,\r
94 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
95 );\r
96\r
97/**\r
98 Stop controlling the device.\r
99\r
100 @param This The driver binding\r
101 @param Controller The device controller controlled by the driver.\r
102 @param NumberOfChildren The number of children of this device\r
103 @param ChildHandleBuffer The buffer of children handle.\r
104\r
105 @retval EFI_SUCCESS The driver stopped from controlling the device.\r
106 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
107 @retval EFI_UNSUPPORTED Block I/O Protocol is not installed on Controller.\r
108 @retval Others Failed to stop the driver\r
109\r
110**/\r
111EFI_STATUS\r
112EFIAPI\r
113BlockIoDriverBindingStop (\r
114 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
115 IN EFI_HANDLE Controller,\r
116 IN UINTN NumberOfChildren,\r
117 IN EFI_HANDLE *ChildHandleBuffer\r
118 );\r
119\r
120//\r
121// Functions for Block I/O Protocol\r
122//\r
123\r
124/**\r
125 Reset the block device.\r
126\r
127 This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). \r
128 It resets the block device hardware.\r
129 ExtendedVerification is ignored in this implementation.\r
130\r
131 @param This Indicates a pointer to the calling context.\r
132 @param ExtendedVerification Indicates that the driver may perform a more exhaustive\r
133 verification operation of the device during reset.\r
134\r
135 @retval EFI_SUCCESS The block device was reset.\r
136 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset.\r
137\r
138**/\r
139EFI_STATUS\r
140EFIAPI\r
141BlockIoReset (\r
142 IN EFI_BLOCK_IO_PROTOCOL *This,\r
143 IN BOOLEAN ExtendedVerification\r
144 );\r
145\r
146/**\r
147 Reads the requested number of blocks from the device.\r
148\r
149 This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). \r
150 It reads the requested number of blocks from the device.\r
151 All the blocks are read, or an error is returned.\r
152\r
153 @param This Indicates a pointer to the calling context.\r
154 @param MediaId The media ID that the read request is for.\r
155 @param Lba The starting logical block address to read from on the device.\r
156 @param BufferSize The size of the Buffer in bytes.\r
157 This must be a multiple of the intrinsic block size of the device.\r
158 @param Buffer A pointer to the destination buffer for the data. The caller is\r
159 responsible for either having implicit or explicit ownership of the buffer.\r
160\r
161 @retval EFI_SUCCESS The data was read correctly from the device.\r
162 @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the read operation.\r
163 @retval EFI_NO_MEDIA There is no media in the device.\r
164 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
165 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic block size of the device.\r
166 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
167 or the buffer is not on proper alignment.\r
168\r
169**/\r
170EFI_STATUS\r
171EFIAPI\r
172BlockIoReadBlocks (\r
173 IN EFI_BLOCK_IO_PROTOCOL *This,\r
174 IN UINT32 MediaId,\r
175 IN EFI_LBA Lba,\r
176 IN UINTN BufferSize,\r
177 OUT VOID *Buffer\r
178 );\r
179\r
180/**\r
181 Writes a specified number of blocks to the device.\r
182\r
183 This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). \r
184 It writes a specified number of blocks to the device.\r
185 All blocks are written, or an error is returned.\r
186\r
187 @param This Indicates a pointer to the calling context.\r
188 @param MediaId The media ID that the write request is for.\r
189 @param Lba The starting logical block address to be written.\r
190 @param BufferSize The size of the Buffer in bytes.\r
191 This must be a multiple of the intrinsic block size of the device.\r
192 @param Buffer Pointer to the source buffer for the data.\r
193\r
194 @retval EFI_SUCCESS The data were written correctly to the device.\r
195 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
196 @retval EFI_NO_MEDIA There is no media in the device.\r
197 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
198 @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation.\r
199 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic\r
200 block size of the device.\r
201 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
202 or the buffer is not on proper alignment.\r
203\r
204**/\r
205EFI_STATUS\r
206EFIAPI\r
207BlockIoWriteBlocks (\r
208 IN EFI_BLOCK_IO_PROTOCOL *This,\r
209 IN UINT32 MediaId,\r
210 IN EFI_LBA Lba,\r
211 IN UINTN BufferSize,\r
212 IN VOID *Buffer\r
213 );\r
214\r
215/**\r
216 Flushes all modified data to a physical block device.\r
217\r
218 @param This Indicates a pointer to the calling context.\r
219\r
220 @retval EFI_SUCCESS All outstanding data were written correctly to the device.\r
221 @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data.\r
222 @retval EFI_NO_MEDIA There is no media in the device.\r
223\r
224**/\r
225EFI_STATUS\r
226EFIAPI\r
227BlockIoFlushBlocks (\r
228 IN EFI_BLOCK_IO_PROTOCOL *This\r
229 );\r
230\r
231//\r
232// EFI Component Name Functions\r
233//\r
234\r
235/**\r
236 Retrieves a Unicode string that is the user readable name of the driver.\r
237\r
238 This function retrieves the user readable name of a driver in the form of a\r
239 Unicode string. If the driver specified by This has a user readable name in\r
240 the language specified by Language, then a pointer to the driver name is\r
241 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
242 by This does not support the language specified by Language,\r
243 then EFI_UNSUPPORTED is returned.\r
244\r
245 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
246 EFI_COMPONENT_NAME_PROTOCOL instance.\r
247 @param Language A pointer to a Null-terminated ASCII string\r
248 array indicating the language. This is the\r
249 language of the driver name that the caller is\r
250 requesting, and it must match one of the\r
251 languages specified in SupportedLanguages. The\r
252 number of languages supported by a driver is up\r
253 to the driver writer. Language is specified\r
254 in RFC 4646 or ISO 639-2 language code format.\r
255 @param DriverName A pointer to the Unicode string to return.\r
256 This Unicode string is the name of the\r
257 driver specified by This in the language\r
258 specified by Language.\r
259\r
260 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
261 This and the language specified by Language was\r
262 returned in DriverName.\r
263 @retval EFI_INVALID_PARAMETER Language is NULL.\r
264 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
265 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
266 the language specified by Language.\r
267\r
268**/\r
269EFI_STATUS\r
270EFIAPI\r
271BlockMmioToBlockIoGetDriverName (\r
272 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
273 IN CHAR8 *Language,\r
274 OUT CHAR16 **DriverName\r
275 );\r
276\r
277\r
278/**\r
279 Retrieves a Unicode string that is the user readable name of the controller\r
280 that is being managed by a driver.\r
281\r
282 This function retrieves the user readable name of the controller specified by\r
283 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
284 driver specified by This has a user readable name in the language specified by\r
285 Language, then a pointer to the controller name is returned in ControllerName,\r
286 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
287 managing the controller specified by ControllerHandle and ChildHandle,\r
288 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
289 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
290\r
291 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
292 EFI_COMPONENT_NAME_PROTOCOL instance.\r
293 @param ControllerHandle The handle of a controller that the driver\r
294 specified by This is managing. This handle\r
295 specifies the controller whose name is to be\r
296 returned.\r
297 @param ChildHandle The handle of the child controller to retrieve\r
298 the name of. This is an optional parameter that\r
299 may be NULL. It will be NULL for device\r
300 drivers. It will also be NULL for a bus drivers\r
301 that wish to retrieve the name of the bus\r
302 controller. It will not be NULL for a bus\r
303 driver that wishes to retrieve the name of a\r
304 child controller.\r
305 @param Language A pointer to a Null-terminated ASCII string\r
306 array indicating the language. This is the\r
307 language of the driver name that the caller is\r
308 requesting, and it must match one of the\r
309 languages specified in SupportedLanguages. The\r
310 number of languages supported by a driver is up\r
311 to the driver writer. Language is specified in\r
312 RFC 4646 or ISO 639-2 language code format.\r
313 @param ControllerName A pointer to the Unicode string to return.\r
314 This Unicode string is the name of the\r
315 controller specified by ControllerHandle and\r
316 ChildHandle in the language specified by\r
317 Language from the point of view of the driver\r
318 specified by This.\r
319\r
320 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
321 the language specified by Language for the\r
322 driver specified by This was returned in\r
323 DriverName.\r
324 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
325 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
326 EFI_HANDLE.\r
327 @retval EFI_INVALID_PARAMETER Language is NULL.\r
328 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
329 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
330 managing the controller specified by\r
331 ControllerHandle and ChildHandle.\r
332 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
333 the language specified by Language.\r
334\r
335**/\r
336EFI_STATUS\r
337EFIAPI\r
338BlockMmioToBlockIoGetControllerName (\r
339 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
340 IN EFI_HANDLE ControllerHandle,\r
341 IN EFI_HANDLE ChildHandle OPTIONAL,\r
342 IN CHAR8 *Language,\r
343 OUT CHAR16 **ControllerName\r
344 );\r
345\r
346#endif\r