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