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