]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
Add DiskIo2 protocol definition to MdePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Partition.h
... / ...
CommitLineData
1/** @file\r
2 Partition driver that produces logical BlockIo devices from a physical \r
3 BlockIo device. The logical BlockIo devices are based on the format\r
4 of the raw block devices media. Currently "El Torito CD-ROM", Legacy \r
5 MBR, and GPT partition schemes are supported.\r
6\r
7Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
8This program and the accompanying materials\r
9are licensed and made available under the terms and conditions of the BSD License\r
10which accompanies this distribution. The full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php\r
12\r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#ifndef _PARTITION_H_ \r
19#define _PARTITION_H_ \r
20\r
21#include <Uefi.h>\r
22#include <Protocol/BlockIo.h>\r
23#include <Protocol/BlockIo2.h>\r
24#include <Guid/Gpt.h>\r
25#include <Protocol/ComponentName.h>\r
26#include <Protocol/DevicePath.h>\r
27#include <Protocol/DriverBinding.h>\r
28#include <Protocol/DiskIo.h>\r
29#include <Protocol/DiskIo2.h>\r
30#include <Library/DebugLib.h>\r
31#include <Library/UefiDriverEntryPoint.h>\r
32#include <Library/BaseLib.h>\r
33#include <Library/UefiLib.h>\r
34#include <Library/BaseMemoryLib.h>\r
35#include <Library/MemoryAllocationLib.h>\r
36#include <Library/UefiBootServicesTableLib.h>\r
37#include <Library/DevicePathLib.h>\r
38\r
39#include <IndustryStandard/Mbr.h>\r
40#include <IndustryStandard/ElTorito.h>\r
41\r
42\r
43//\r
44// Partition private data\r
45//\r
46#define PARTITION_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'a', 'r', 't')\r
47typedef struct {\r
48 UINT64 Signature;\r
49\r
50 EFI_HANDLE Handle;\r
51 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
52 EFI_BLOCK_IO_PROTOCOL BlockIo;\r
53 EFI_BLOCK_IO2_PROTOCOL BlockIo2;\r
54 EFI_BLOCK_IO_MEDIA Media;\r
55 EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2\r
56\r
57 EFI_DISK_IO_PROTOCOL *DiskIo;\r
58 EFI_DISK_IO2_PROTOCOL *DiskIo2;\r
59 EFI_BLOCK_IO_PROTOCOL *ParentBlockIo;\r
60 EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2;\r
61 UINT64 Start;\r
62 UINT64 End;\r
63 UINT32 BlockSize;\r
64\r
65 EFI_GUID *EspGuid;\r
66\r
67} PARTITION_PRIVATE_DATA;\r
68\r
69typedef struct {\r
70 EFI_DISK_IO2_TOKEN DiskIo2Token;\r
71 EFI_BLOCK_IO2_TOKEN *BlockIo2Token;\r
72} PARTITION_ACCESS_TASK;\r
73\r
74#define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)\r
75#define PARTITION_DEVICE_FROM_BLOCK_IO2_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo2, PARTITION_PRIVATE_DATA_SIGNATURE)\r
76\r
77//\r
78// Global Variables\r
79//\r
80extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding;\r
81extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName;\r
82extern EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2;\r
83\r
84//\r
85// Extract INT32 from char array\r
86//\r
87#define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \\r
88 (((UINT8 *) a)[1] << 8) | \\r
89 (((UINT8 *) a)[2] << 16) | \\r
90 (((UINT8 *) a)[3] << 24) )\r
91\r
92//\r
93// Extract UINT32 from char array\r
94//\r
95#define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \\r
96 (((UINT8 *) a)[1] << 8) | \\r
97 (((UINT8 *) a)[2] << 16) | \\r
98 (((UINT8 *) a)[3] << 24) )\r
99\r
100\r
101//\r
102// GPT Partition Entry Status\r
103//\r
104typedef struct {\r
105 BOOLEAN OutOfRange;\r
106 BOOLEAN Overlap;\r
107 BOOLEAN OsSpecific;\r
108} EFI_PARTITION_ENTRY_STATUS;\r
109\r
110//\r
111// Function Prototypes\r
112//\r
113/**\r
114 Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
115 than contains a BlockIo and DiskIo protocol can be supported.\r
116\r
117 @param This Protocol instance pointer.\r
118 @param ControllerHandle Handle of device to test\r
119 @param RemainingDevicePath Optional parameter use to pick a specific child\r
120 device to start.\r
121\r
122 @retval EFI_SUCCESS This driver supports this device\r
123 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
124 @retval other This driver does not support this device\r
125\r
126**/\r
127EFI_STATUS\r
128EFIAPI\r
129PartitionDriverBindingSupported (\r
130 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
131 IN EFI_HANDLE ControllerHandle,\r
132 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
133 );\r
134\r
135/**\r
136 Start this driver on ControllerHandle by opening a Block IO and Disk IO\r
137 protocol, reading Device Path, and creating a child handle with a\r
138 Disk IO and device path protocol.\r
139\r
140 @param This Protocol instance pointer.\r
141 @param ControllerHandle Handle of device to bind driver to\r
142 @param RemainingDevicePath Optional parameter use to pick a specific child\r
143 device to start.\r
144\r
145 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
146 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
147 @retval other This driver does not support this device\r
148\r
149**/\r
150EFI_STATUS\r
151EFIAPI\r
152PartitionDriverBindingStart (\r
153 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
154 IN EFI_HANDLE ControllerHandle,\r
155 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
156 );\r
157\r
158/**\r
159 Stop this driver on ControllerHandle. Support stopping any child handles\r
160 created by this driver.\r
161\r
162 @param This Protocol instance pointer.\r
163 @param ControllerHandle Handle of device to stop driver on\r
164 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
165 children is zero stop the entire bus driver.\r
166 @param ChildHandleBuffer List of Child Handles to Stop.\r
167\r
168 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
169 @retval other This driver was not removed from this device\r
170\r
171**/\r
172EFI_STATUS\r
173EFIAPI\r
174PartitionDriverBindingStop (\r
175 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
176 IN EFI_HANDLE ControllerHandle,\r
177 IN UINTN NumberOfChildren,\r
178 IN EFI_HANDLE *ChildHandleBuffer\r
179 );\r
180\r
181//\r
182// EFI Component Name Functions\r
183//\r
184/**\r
185 Retrieves a Unicode string that is the user readable name of the driver.\r
186\r
187 This function retrieves the user readable name of a driver in the form of a\r
188 Unicode string. If the driver specified by This has a user readable name in\r
189 the language specified by Language, then a pointer to the driver name is\r
190 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
191 by This does not support the language specified by Language,\r
192 then EFI_UNSUPPORTED is returned.\r
193\r
194 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
195 EFI_COMPONENT_NAME_PROTOCOL instance.\r
196\r
197 @param Language[in] A pointer to a Null-terminated ASCII string\r
198 array indicating the language. This is the\r
199 language of the driver name that the caller is\r
200 requesting, and it must match one of the\r
201 languages specified in SupportedLanguages. The\r
202 number of languages supported by a driver is up\r
203 to the driver writer. Language is specified\r
204 in RFC 4646 or ISO 639-2 language code format.\r
205\r
206 @param DriverName[out] A pointer to the Unicode string to return.\r
207 This Unicode string is the name of the\r
208 driver specified by This in the language\r
209 specified by Language.\r
210\r
211 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
212 This and the language specified by Language was\r
213 returned in DriverName.\r
214\r
215 @retval EFI_INVALID_PARAMETER Language is NULL.\r
216\r
217 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
218\r
219 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
220 the language specified by Language.\r
221\r
222**/\r
223EFI_STATUS\r
224EFIAPI\r
225PartitionComponentNameGetDriverName (\r
226 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
227 IN CHAR8 *Language,\r
228 OUT CHAR16 **DriverName\r
229 );\r
230\r
231\r
232/**\r
233 Retrieves a Unicode string that is the user readable name of the controller\r
234 that is being managed by a driver.\r
235\r
236 This function retrieves the user readable name of the controller specified by\r
237 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
238 driver specified by This has a user readable name in the language specified by\r
239 Language, then a pointer to the controller name is returned in ControllerName,\r
240 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
241 managing the controller specified by ControllerHandle and ChildHandle,\r
242 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
243 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
244\r
245 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
246 EFI_COMPONENT_NAME_PROTOCOL instance.\r
247\r
248 @param ControllerHandle[in] The handle of a controller that the driver\r
249 specified by This is managing. This handle\r
250 specifies the controller whose name is to be\r
251 returned.\r
252\r
253 @param ChildHandle[in] The handle of the child controller to retrieve\r
254 the name of. This is an optional parameter that\r
255 may be NULL. It will be NULL for device\r
256 drivers. It will also be NULL for a bus drivers\r
257 that wish to retrieve the name of the bus\r
258 controller. It will not be NULL for a bus\r
259 driver that wishes to retrieve the name of a\r
260 child controller.\r
261\r
262 @param Language[in] A pointer to a Null-terminated ASCII string\r
263 array indicating the language. This is the\r
264 language of the driver name that the caller is\r
265 requesting, and it must match one of the\r
266 languages specified in SupportedLanguages. The\r
267 number of languages supported by a driver is up\r
268 to the driver writer. Language is specified in\r
269 RFC 4646 or ISO 639-2 language code format.\r
270\r
271 @param ControllerName[out] A pointer to the Unicode string to return.\r
272 This Unicode string is the name of the\r
273 controller specified by ControllerHandle and\r
274 ChildHandle in the language specified by\r
275 Language from the point of view of the driver\r
276 specified by This.\r
277\r
278 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
279 the language specified by Language for the\r
280 driver specified by This was returned in\r
281 DriverName.\r
282\r
283 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
284\r
285 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
286 EFI_HANDLE.\r
287\r
288 @retval EFI_INVALID_PARAMETER Language is NULL.\r
289\r
290 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
291\r
292 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
293 managing the controller specified by\r
294 ControllerHandle and ChildHandle.\r
295\r
296 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
297 the language specified by Language.\r
298\r
299**/\r
300EFI_STATUS\r
301EFIAPI\r
302PartitionComponentNameGetControllerName (\r
303 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
304 IN EFI_HANDLE ControllerHandle,\r
305 IN EFI_HANDLE ChildHandle OPTIONAL,\r
306 IN CHAR8 *Language,\r
307 OUT CHAR16 **ControllerName\r
308 );\r
309\r
310\r
311/**\r
312 Create a child handle for a logical block device that represents the\r
313 bytes Start to End of the Parent Block IO device.\r
314\r
315 @param[in] This Protocol instance pointer.\r
316 @param[in] ParentHandle Parent Handle for new child.\r
317 @param[in] ParentDiskIo Parent DiskIo interface.\r
318 @param[in] ParentDiskIo2 Parent DiskIo2 interface.\r
319 @param[in] ParentBlockIo Parent BlockIo interface.\r
320 @param[in] ParentBlockIo2 Parent BlockIo2 interface.\r
321 @param[in] ParentDevicePath Parent Device Path.\r
322 @param[in] DevicePathNode Child Device Path node.\r
323 @param[in] Start Start Block.\r
324 @param[in] End End Block.\r
325 @param[in] BlockSize Child block size.\r
326 @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle.\r
327\r
328 @retval EFI_SUCCESS A child handle was added.\r
329 @retval other A child handle was not added.\r
330\r
331**/\r
332EFI_STATUS\r
333PartitionInstallChildHandle (\r
334 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
335 IN EFI_HANDLE ParentHandle,\r
336 IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,\r
337 IN EFI_DISK_IO2_PROTOCOL *ParentDiskIo2,\r
338 IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,\r
339 IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2,\r
340 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
341 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r
342 IN EFI_LBA Start,\r
343 IN EFI_LBA End,\r
344 IN UINT32 BlockSize,\r
345 IN BOOLEAN InstallEspGuid\r
346 );\r
347\r
348/**\r
349 Install child handles if the Handle supports GPT partition structure.\r
350\r
351 @param[in] This Calling context.\r
352 @param[in] Handle Parent Handle.\r
353 @param[in] DiskIo Parent DiskIo interface.\r
354 @param[in] DiskIo2 Parent DiskIo2 interface.\r
355 @param[in] BlockIo Parent BlockIo interface.\r
356 @param[in] BlockIo2 Parent BlockIo2 interface.\r
357 @param[in] DevicePath Parent Device Path.\r
358\r
359 @retval EFI_SUCCESS Valid GPT disk.\r
360 @retval EFI_MEDIA_CHANGED Media changed Detected.\r
361 @retval EFI_INVALID_PARAMETER If both BlockIo and BlockIo2 are NULL;\r
362 @retval other Not a valid GPT disk.\r
363\r
364**/\r
365EFI_STATUS\r
366PartitionInstallGptChildHandles (\r
367 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
368 IN EFI_HANDLE Handle,\r
369 IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
370 IN EFI_DISK_IO2_PROTOCOL *DiskIo2,\r
371 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
372 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,\r
373 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
374 );\r
375\r
376/**\r
377 Install child handles if the Handle supports El Torito format.\r
378\r
379 @param[in] This Calling context.\r
380 @param[in] Handle Parent Handle.\r
381 @param[in] DiskIo Parent DiskIo interface.\r
382 @param[in] DiskIo2 Parent DiskIo2 interface.\r
383 @param[in] BlockIo Parent BlockIo interface.\r
384 @param[in] BlockIo2 Parent BlockIo2 interface.\r
385 @param[in] DevicePath Parent Device Path\r
386\r
387\r
388 @retval EFI_SUCCESS Child handle(s) was added.\r
389 @retval EFI_MEDIA_CHANGED Media changed Detected.\r
390 @retval other no child handle was added.\r
391\r
392**/\r
393EFI_STATUS\r
394PartitionInstallElToritoChildHandles (\r
395 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
396 IN EFI_HANDLE Handle,\r
397 IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
398 IN EFI_DISK_IO2_PROTOCOL *DiskIo2,\r
399 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
400 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,\r
401 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
402 );\r
403\r
404/**\r
405 Install child handles if the Handle supports MBR format.\r
406\r
407 @param[in] This Calling context.\r
408 @param[in] Handle Parent Handle.\r
409 @param[in] DiskIo Parent DiskIo interface.\r
410 @param[in] DiskIo2 Parent DiskIo2 interface.\r
411 @param[in] BlockIo Parent BlockIo interface.\r
412 @param[in] BlockIo2 Parent BlockIo2 interface.\r
413 @param[in] DevicePath Parent Device Path.\r
414 \r
415 @retval EFI_SUCCESS A child handle was added.\r
416 @retval EFI_MEDIA_CHANGED Media change was detected.\r
417 @retval Others MBR partition was not found.\r
418\r
419**/\r
420EFI_STATUS\r
421PartitionInstallMbrChildHandles (\r
422 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
423 IN EFI_HANDLE Handle,\r
424 IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
425 IN EFI_DISK_IO2_PROTOCOL *DiskIo2,\r
426 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
427 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,\r
428 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
429 );\r
430\r
431typedef\r
432EFI_STATUS\r
433(*PARTITION_DETECT_ROUTINE) (\r
434 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
435 IN EFI_HANDLE Handle,\r
436 IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
437 IN EFI_DISK_IO2_PROTOCOL *DiskIo2,\r
438 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
439 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,\r
440 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
441 );\r
442\r
443#endif\r