]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
Add in example on
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / DiskIoDxe / DiskIo.h
CommitLineData
adbcbf8f 1/** @file\r
2 DiskIo driver that layers it's self on every Block IO protocol in the system.\r
3 DiskIo converts a block oriented device to a byte oriented device.\r
4\r
f42be642 5Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
adbcbf8f 13\r
14**/\r
15\r
16#ifndef _DISK_IO_H\r
17#define _DISK_IO_H\r
18\r
19#include <Uefi.h>\r
20#include <Protocol/BlockIo.h>\r
21#include <Protocol/ComponentName.h>\r
22#include <Protocol/DriverBinding.h>\r
23#include <Protocol/DiskIo.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/UefiDriverEntryPoint.h>\r
26#include <Library/UefiLib.h>\r
27#include <Library/BaseLib.h>\r
28#include <Library/BaseMemoryLib.h>\r
29#include <Library/MemoryAllocationLib.h>\r
30#include <Library/UefiBootServicesTableLib.h>\r
31\r
32\r
33#define DISK_IO_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('d', 's', 'k', 'I')\r
34\r
35#define DATA_BUFFER_BLOCK_NUM (64)\r
36\r
37typedef struct {\r
38 UINTN Signature;\r
39 EFI_DISK_IO_PROTOCOL DiskIo;\r
40 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
41} DISK_IO_PRIVATE_DATA;\r
42\r
43#define DISK_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)\r
44\r
45//\r
46// Global Variables\r
47//\r
d38a0f44 48extern EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding;\r
49extern EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName;\r
50extern EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2;\r
adbcbf8f 51\r
52//\r
53// Prototypes\r
54// Driver model protocol interface\r
55//\r
a8d0c20e 56/**\r
57 Test to see if this driver supports ControllerHandle. \r
58\r
59 @param This Protocol instance pointer.\r
60 @param ControllerHandle Handle of device to test\r
61 @param RemainingDevicePath Optional parameter use to pick a specific child\r
62 device to start.\r
63\r
64 @retval EFI_SUCCESS This driver supports this device\r
65 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
66 @retval other This driver does not support this device\r
67\r
68**/\r
adbcbf8f 69EFI_STATUS\r
70EFIAPI\r
71DiskIoDriverBindingSupported (\r
72 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
73 IN EFI_HANDLE ControllerHandle,\r
74 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
75 );\r
76\r
a8d0c20e 77/**\r
78 Start this driver on ControllerHandle by opening a Block IO protocol and\r
79 installing a Disk IO protocol on ControllerHandle.\r
80\r
81 @param This Protocol instance pointer.\r
82 @param ControllerHandle Handle of device to bind driver to\r
83 @param RemainingDevicePath Optional parameter use to pick a specific child\r
84 device to start.\r
85\r
86 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
87 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
88 @retval other This driver does not support this device\r
89\r
90**/\r
adbcbf8f 91EFI_STATUS\r
92EFIAPI\r
93DiskIoDriverBindingStart (\r
94 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
95 IN EFI_HANDLE ControllerHandle,\r
96 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
97 );\r
98\r
a8d0c20e 99/**\r
100 Stop this driver on ControllerHandle by removing Disk IO protocol and closing\r
101 the Block IO protocol on ControllerHandle.\r
102\r
103 @param This Protocol instance pointer.\r
104 @param ControllerHandle Handle of device to stop driver on\r
105 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
106 children is zero stop the entire bus driver.\r
107 @param ChildHandleBuffer List of Child Handles to Stop.\r
108\r
109 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
110 @retval other This driver was not removed from this device\r
111\r
112**/\r
adbcbf8f 113EFI_STATUS\r
114EFIAPI\r
115DiskIoDriverBindingStop (\r
116 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
117 IN EFI_HANDLE ControllerHandle,\r
118 IN UINTN NumberOfChildren,\r
119 IN EFI_HANDLE *ChildHandleBuffer\r
120 );\r
121\r
122//\r
123// Disk I/O Protocol Interface\r
124//\r
a8d0c20e 125/**\r
126 Read BufferSize bytes from Offset into Buffer.\r
127 Reads may support reads that are not aligned on\r
128 sector boundaries. There are three cases:\r
129 UnderRun - The first byte is not on a sector boundary or the read request is\r
130 less than a sector in length.\r
131 Aligned - A read of N contiguous sectors.\r
132 OverRun - The last byte is not on a sector boundary.\r
133\r
134 @param This Protocol instance pointer.\r
135 @param MediaId Id of the media, changes every time the media is replaced.\r
136 @param Offset The starting byte offset to read from\r
137 @param BufferSize Size of Buffer\r
138 @param Buffer Buffer containing read data\r
139\r
140 @retval EFI_SUCCESS The data was read correctly from the device.\r
141 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
142 @retval EFI_NO_MEDIA There is no media in the device.\r
143 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
144 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
145 valid for the device.\r
146\r
147**/\r
adbcbf8f 148EFI_STATUS\r
149EFIAPI\r
150DiskIoReadDisk (\r
151 IN EFI_DISK_IO_PROTOCOL *This,\r
152 IN UINT32 MediaId,\r
153 IN UINT64 Offset,\r
154 IN UINTN BufferSize,\r
155 OUT VOID *Buffer\r
156 );\r
157\r
a8d0c20e 158/**\r
159 Read BufferSize bytes from Offset into Buffer.\r
160 Writes may require a read modify write to support writes that are not\r
161 aligned on sector boundaries. There are three cases:\r
162 UnderRun - The first byte is not on a sector boundary or the write request\r
163 is less than a sector in length. Read modify write is required.\r
164 Aligned - A write of N contiguous sectors.\r
165 OverRun - The last byte is not on a sector boundary. Read modified write\r
166 required.\r
167\r
168 @param This Protocol instance pointer.\r
169 @param MediaId Id of the media, changes every time the media is replaced.\r
170 @param Offset The starting byte offset to read from\r
171 @param BufferSize Size of Buffer\r
172 @param Buffer Buffer containing read data\r
173\r
174 @retval EFI_SUCCESS The data was written correctly to the device.\r
175 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
176 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
177 @retval EFI_NO_MEDIA There is no media in the device.\r
178 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
179 @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not\r
180 valid for the device.\r
181\r
182**/\r
adbcbf8f 183EFI_STATUS\r
184EFIAPI\r
185DiskIoWriteDisk (\r
186 IN EFI_DISK_IO_PROTOCOL *This,\r
187 IN UINT32 MediaId,\r
188 IN UINT64 Offset,\r
189 IN UINTN BufferSize,\r
190 IN VOID *Buffer\r
191 );\r
192\r
193//\r
194// EFI Component Name Functions\r
195//\r
d38a0f44 196/**\r
197 Retrieves a Unicode string that is the user readable name of the driver.\r
198\r
199 This function retrieves the user readable name of a driver in the form of a\r
200 Unicode string. If the driver specified by This has a user readable name in\r
201 the language specified by Language, then a pointer to the driver name is\r
202 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
203 by This does not support the language specified by Language,\r
204 then EFI_UNSUPPORTED is returned.\r
205\r
206 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
207 EFI_COMPONENT_NAME_PROTOCOL instance.\r
208\r
209 @param Language[in] A pointer to a Null-terminated ASCII string\r
210 array indicating the language. This is the\r
211 language of the driver name that the caller is\r
212 requesting, and it must match one of the\r
213 languages specified in SupportedLanguages. The\r
214 number of languages supported by a driver is up\r
215 to the driver writer. Language is specified\r
216 in RFC 3066 or ISO 639-2 language code format.\r
217\r
218 @param DriverName[out] A pointer to the Unicode string to return.\r
219 This Unicode string is the name of the\r
220 driver specified by This in the language\r
221 specified by Language.\r
222\r
223 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
224 This and the language specified by Language was\r
225 returned in DriverName.\r
226\r
227 @retval EFI_INVALID_PARAMETER Language is NULL.\r
228\r
229 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
230\r
231 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
232 the language specified by Language.\r
233\r
234**/\r
adbcbf8f 235EFI_STATUS\r
236EFIAPI\r
237DiskIoComponentNameGetDriverName (\r
238 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
239 IN CHAR8 *Language,\r
240 OUT CHAR16 **DriverName\r
241 );\r
242\r
d38a0f44 243\r
244/**\r
245 Retrieves a Unicode string that is the user readable name of the controller\r
246 that is being managed by a driver.\r
247\r
248 This function retrieves the user readable name of the controller specified by\r
249 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
250 driver specified by This has a user readable name in the language specified by\r
251 Language, then a pointer to the controller name is returned in ControllerName,\r
252 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
253 managing the controller specified by ControllerHandle and ChildHandle,\r
254 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
255 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
256\r
257 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
258 EFI_COMPONENT_NAME_PROTOCOL instance.\r
259\r
260 @param ControllerHandle[in] The handle of a controller that the driver\r
261 specified by This is managing. This handle\r
262 specifies the controller whose name is to be\r
263 returned.\r
264\r
265 @param ChildHandle[in] The handle of the child controller to retrieve\r
266 the name of. This is an optional parameter that\r
267 may be NULL. It will be NULL for device\r
268 drivers. It will also be NULL for a bus drivers\r
269 that wish to retrieve the name of the bus\r
270 controller. It will not be NULL for a bus\r
271 driver that wishes to retrieve the name of a\r
272 child controller.\r
273\r
274 @param Language[in] A pointer to a Null-terminated ASCII string\r
275 array indicating the language. This is the\r
276 language of the driver name that the caller is\r
277 requesting, and it must match one of the\r
278 languages specified in SupportedLanguages. The\r
279 number of languages supported by a driver is up\r
280 to the driver writer. Language is specified in\r
281 RFC 3066 or ISO 639-2 language code format.\r
282\r
283 @param ControllerName[out] A pointer to the Unicode string to return.\r
284 This Unicode string is the name of the\r
285 controller specified by ControllerHandle and\r
286 ChildHandle in the language specified by\r
287 Language from the point of view of the driver\r
288 specified by This.\r
289\r
290 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
291 the language specified by Language for the\r
292 driver specified by This was returned in\r
293 DriverName.\r
294\r
295 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
296\r
297 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
298 EFI_HANDLE.\r
299\r
300 @retval EFI_INVALID_PARAMETER Language is NULL.\r
301\r
302 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
303\r
304 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
305 managing the controller specified by\r
306 ControllerHandle and ChildHandle.\r
307\r
308 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
309 the language specified by Language.\r
310\r
311**/\r
adbcbf8f 312EFI_STATUS\r
313EFIAPI\r
314DiskIoComponentNameGetControllerName (\r
315 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
316 IN EFI_HANDLE ControllerHandle,\r
317 IN EFI_HANDLE ChildHandle OPTIONAL,\r
318 IN CHAR8 *Language,\r
319 OUT CHAR16 **ControllerName\r
320 );\r
321\r
d38a0f44 322\r
adbcbf8f 323#endif\r