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