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