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