VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/PartitionDxe/Partition.h@ 48661

Last change on this file since 48661 was 42653, checked in by vboxsync, 13 years ago

EFI/OvmfPkg: import PartitionDxe from OvmfPkg.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.7 KB
Line 
1/* $Id: Partition.h 42653 2012-08-07 10:32:00Z vboxsync $ */
2/** @file
3 * Partition.h
4 */
5
6/*
7 * Copyright (C) 2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/** @file
19 Partition driver that produces logical BlockIo devices from a physical
20 BlockIo device. The logical BlockIo devices are based on the format
21 of the raw block devices media. Currently "El Torito CD-ROM", Legacy
22 MBR, and GPT partition schemes are supported.
23
24Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
25This program and the accompanying materials
26are licensed and made available under the terms and conditions of the BSD License
27which accompanies this distribution. The full text of the license may be found at
28http://opensource.org/licenses/bsd-license.php
29
30THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
31WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
32
33**/
34
35#ifndef _PARTITION_H_
36#define _PARTITION_H_
37
38#include <Uefi.h>
39#include <Protocol/BlockIo.h>
40#include <Protocol/BlockIo2.h>
41#include <Guid/Gpt.h>
42#include <Protocol/ComponentName.h>
43#include <Protocol/DevicePath.h>
44#include <Protocol/DriverBinding.h>
45#include <Protocol/DiskIo.h>
46#include <Library/DebugLib.h>
47#include <Library/UefiDriverEntryPoint.h>
48#include <Library/BaseLib.h>
49#include <Library/UefiLib.h>
50#include <Library/BaseMemoryLib.h>
51#include <Library/MemoryAllocationLib.h>
52#include <Library/UefiBootServicesTableLib.h>
53#include <Library/DevicePathLib.h>
54
55#include <IndustryStandard/Mbr.h>
56#include <IndustryStandard/ElTorito.h>
57
58
59//
60// Partition private data
61//
62#define PARTITION_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'a', 'r', 't')
63typedef struct {
64 UINT64 Signature;
65
66 EFI_HANDLE Handle;
67 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
68 EFI_BLOCK_IO_PROTOCOL BlockIo;
69 EFI_BLOCK_IO2_PROTOCOL BlockIo2;
70 EFI_BLOCK_IO_MEDIA Media;
71 EFI_BLOCK_IO_MEDIA Media2;//For BlockIO2
72
73 EFI_DISK_IO_PROTOCOL *DiskIo;
74 EFI_BLOCK_IO_PROTOCOL *ParentBlockIo;
75 EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2;
76 UINT64 Start;
77 UINT64 End;
78 UINT32 BlockSize;
79
80 EFI_GUID *EspGuid;
81
82} PARTITION_PRIVATE_DATA;
83
84#define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)
85#define PARTITION_DEVICE_FROM_BLOCK_IO2_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo2, PARTITION_PRIVATE_DATA_SIGNATURE)
86
87//
88// Global Variables
89//
90extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding;
91extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName;
92extern EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2;
93
94//
95// Extract INT32 from char array
96//
97#define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
98 (((UINT8 *) a)[1] << 8) | \
99 (((UINT8 *) a)[2] << 16) | \
100 (((UINT8 *) a)[3] << 24) )
101
102//
103// Extract UINT32 from char array
104//
105#define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \
106 (((UINT8 *) a)[1] << 8) | \
107 (((UINT8 *) a)[2] << 16) | \
108 (((UINT8 *) a)[3] << 24) )
109
110
111//
112// GPT Partition Entry Status
113//
114typedef struct {
115 BOOLEAN OutOfRange;
116 BOOLEAN Overlap;
117 BOOLEAN OsSpecific;
118} EFI_PARTITION_ENTRY_STATUS;
119
120//
121// Function Prototypes
122//
123/**
124 Test to see if this driver supports ControllerHandle. Any ControllerHandle
125 than contains a BlockIo and DiskIo protocol can be supported.
126
127 @param This Protocol instance pointer.
128 @param ControllerHandle Handle of device to test
129 @param RemainingDevicePath Optional parameter use to pick a specific child
130 device to start.
131
132 @retval EFI_SUCCESS This driver supports this device
133 @retval EFI_ALREADY_STARTED This driver is already running on this device
134 @retval other This driver does not support this device
135
136**/
137EFI_STATUS
138EFIAPI
139PartitionDriverBindingSupported (
140 IN EFI_DRIVER_BINDING_PROTOCOL *This,
141 IN EFI_HANDLE ControllerHandle,
142 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
143 );
144
145/**
146 Start this driver on ControllerHandle by opening a Block IO and Disk IO
147 protocol, reading Device Path, and creating a child handle with a
148 Disk IO and device path protocol.
149
150 @param This Protocol instance pointer.
151 @param ControllerHandle Handle of device to bind driver to
152 @param RemainingDevicePath Optional parameter use to pick a specific child
153 device to start.
154
155 @retval EFI_SUCCESS This driver is added to ControllerHandle
156 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
157 @retval other This driver does not support this device
158
159**/
160EFI_STATUS
161EFIAPI
162PartitionDriverBindingStart (
163 IN EFI_DRIVER_BINDING_PROTOCOL *This,
164 IN EFI_HANDLE ControllerHandle,
165 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
166 );
167
168/**
169 Stop this driver on ControllerHandle. Support stopping any child handles
170 created by this driver.
171
172 @param This Protocol instance pointer.
173 @param ControllerHandle Handle of device to stop driver on
174 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
175 children is zero stop the entire bus driver.
176 @param ChildHandleBuffer List of Child Handles to Stop.
177
178 @retval EFI_SUCCESS This driver is removed ControllerHandle
179 @retval other This driver was not removed from this device
180
181**/
182EFI_STATUS
183EFIAPI
184PartitionDriverBindingStop (
185 IN EFI_DRIVER_BINDING_PROTOCOL *This,
186 IN EFI_HANDLE ControllerHandle,
187 IN UINTN NumberOfChildren,
188 IN EFI_HANDLE *ChildHandleBuffer
189 );
190
191//
192// EFI Component Name Functions
193//
194/**
195 Retrieves a Unicode string that is the user readable name of the driver.
196
197 This function retrieves the user readable name of a driver in the form of a
198 Unicode string. If the driver specified by This has a user readable name in
199 the language specified by Language, then a pointer to the driver name is
200 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
201 by This does not support the language specified by Language,
202 then EFI_UNSUPPORTED is returned.
203
204 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
205 EFI_COMPONENT_NAME_PROTOCOL instance.
206
207 @param Language[in] A pointer to a Null-terminated ASCII string
208 array indicating the language. This is the
209 language of the driver name that the caller is
210 requesting, and it must match one of the
211 languages specified in SupportedLanguages. The
212 number of languages supported by a driver is up
213 to the driver writer. Language is specified
214 in RFC 4646 or ISO 639-2 language code format.
215
216 @param DriverName[out] A pointer to the Unicode string to return.
217 This Unicode string is the name of the
218 driver specified by This in the language
219 specified by Language.
220
221 @retval EFI_SUCCESS The Unicode string for the Driver specified by
222 This and the language specified by Language was
223 returned in DriverName.
224
225 @retval EFI_INVALID_PARAMETER Language is NULL.
226
227 @retval EFI_INVALID_PARAMETER DriverName is NULL.
228
229 @retval EFI_UNSUPPORTED The driver specified by This does not support
230 the language specified by Language.
231
232**/
233EFI_STATUS
234EFIAPI
235PartitionComponentNameGetDriverName (
236 IN EFI_COMPONENT_NAME_PROTOCOL *This,
237 IN CHAR8 *Language,
238 OUT CHAR16 **DriverName
239 );
240
241
242/**
243 Retrieves a Unicode string that is the user readable name of the controller
244 that is being managed by a driver.
245
246 This function retrieves the user readable name of the controller specified by
247 ControllerHandle and ChildHandle in the form of a Unicode string. If the
248 driver specified by This has a user readable name in the language specified by
249 Language, then a pointer to the controller name is returned in ControllerName,
250 and EFI_SUCCESS is returned. If the driver specified by This is not currently
251 managing the controller specified by ControllerHandle and ChildHandle,
252 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
253 support the language specified by Language, then EFI_UNSUPPORTED is returned.
254
255 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
256 EFI_COMPONENT_NAME_PROTOCOL instance.
257
258 @param ControllerHandle[in] The handle of a controller that the driver
259 specified by This is managing. This handle
260 specifies the controller whose name is to be
261 returned.
262
263 @param ChildHandle[in] The handle of the child controller to retrieve
264 the name of. This is an optional parameter that
265 may be NULL. It will be NULL for device
266 drivers. It will also be NULL for a bus drivers
267 that wish to retrieve the name of the bus
268 controller. It will not be NULL for a bus
269 driver that wishes to retrieve the name of a
270 child controller.
271
272 @param Language[in] A pointer to a Null-terminated ASCII string
273 array indicating the language. This is the
274 language of the driver name that the caller is
275 requesting, and it must match one of the
276 languages specified in SupportedLanguages. The
277 number of languages supported by a driver is up
278 to the driver writer. Language is specified in
279 RFC 4646 or ISO 639-2 language code format.
280
281 @param ControllerName[out] A pointer to the Unicode string to return.
282 This Unicode string is the name of the
283 controller specified by ControllerHandle and
284 ChildHandle in the language specified by
285 Language from the point of view of the driver
286 specified by This.
287
288 @retval EFI_SUCCESS The Unicode string for the user readable name in
289 the language specified by Language for the
290 driver specified by This was returned in
291 DriverName.
292
293 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
294
295 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
296 EFI_HANDLE.
297
298 @retval EFI_INVALID_PARAMETER Language is NULL.
299
300 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
301
302 @retval EFI_UNSUPPORTED The driver specified by This is not currently
303 managing the controller specified by
304 ControllerHandle and ChildHandle.
305
306 @retval EFI_UNSUPPORTED The driver specified by This does not support
307 the language specified by Language.
308
309**/
310EFI_STATUS
311EFIAPI
312PartitionComponentNameGetControllerName (
313 IN EFI_COMPONENT_NAME_PROTOCOL *This,
314 IN EFI_HANDLE ControllerHandle,
315 IN EFI_HANDLE ChildHandle OPTIONAL,
316 IN CHAR8 *Language,
317 OUT CHAR16 **ControllerName
318 );
319
320
321/**
322 Create a child handle for a logical block device that represents the
323 bytes Start to End of the Parent Block IO device.
324
325 @param[in] This Protocol instance pointer.
326 @param[in] ParentHandle Parent Handle for new child.
327 @param[in] ParentDiskIo Parent DiskIo interface.
328 @param[in] ParentBlockIo Parent BlockIo interface.
329 @param[in] ParentBlockIo2 Parent BlockIo2 interface.
330 @param[in] ParentDevicePath Parent Device Path.
331 @param[in] DevicePathNode Child Device Path node.
332 @param[in] Start Start Block.
333 @param[in] End End Block.
334 @param[in] BlockSize Child block size.
335 @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle.
336
337 @retval EFI_SUCCESS A child handle was added.
338 @retval other A child handle was not added.
339
340**/
341EFI_STATUS
342PartitionInstallChildHandle (
343 IN EFI_DRIVER_BINDING_PROTOCOL *This,
344 IN EFI_HANDLE ParentHandle,
345 IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,
346 IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,
347 IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2,
348 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
349 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
350 IN EFI_LBA Start,
351 IN EFI_LBA End,
352 IN UINT32 BlockSize,
353 IN BOOLEAN InstallEspGuid
354 );
355
356/**
357 Install child handles if the Handle supports GPT partition structure.
358
359 @param[in] This Calling context.
360 @param[in] Handle Parent Handle.
361 @param[in] DiskIo Parent DiskIo interface.
362 @param[in] BlockIo Parent BlockIo interface.
363 @param[in] BlockIo2 Parent BlockIo2 interface.
364 @param[in] DevicePath Parent Device Path.
365
366 @retval EFI_SUCCESS Valid GPT disk.
367 @retval EFI_MEDIA_CHANGED Media changed Detected.
368 @retval EFI_INVALID_PARAMETER If both BlockIo and BlockIo2 are NULL;
369 @retval other Not a valid GPT disk.
370
371**/
372EFI_STATUS
373PartitionInstallGptChildHandles (
374 IN EFI_DRIVER_BINDING_PROTOCOL *This,
375 IN EFI_HANDLE Handle,
376 IN EFI_DISK_IO_PROTOCOL *DiskIo,
377 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
378 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
379 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
380 );
381
382/**
383 Install child handles if the Handle supports El Torito format.
384
385 @param[in] This Calling context.
386 @param[in] Handle Parent Handle.
387 @param[in] DiskIo Parent DiskIo interface.
388 @param[in] BlockIo Parent BlockIo interface.
389 @param[in] BlockIo2 Parent BlockIo2 interface.
390 @param[in] DevicePath Parent Device Path
391
392
393 @retval EFI_SUCCESS Child handle(s) was added.
394 @retval EFI_MEDIA_CHANGED Media changed Detected.
395 @retval other no child handle was added.
396
397**/
398EFI_STATUS
399PartitionInstallElToritoChildHandles (
400 IN EFI_DRIVER_BINDING_PROTOCOL *This,
401 IN EFI_HANDLE Handle,
402 IN EFI_DISK_IO_PROTOCOL *DiskIo,
403 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
404 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
405 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
406 );
407
408/**
409 Install child handles if the Handle supports MBR format.
410
411 @param[in] This Calling context.
412 @param[in] Handle Parent Handle.
413 @param[in] DiskIo Parent DiskIo interface.
414 @param[in] BlockIo Parent BlockIo interface.
415 @param[in] BlockIo2 Parent BlockIo2 interface.
416 @param[in] DevicePath Parent Device Path.
417
418 @retval EFI_SUCCESS A child handle was added.
419 @retval EFI_MEDIA_CHANGED Media change was detected.
420 @retval Others MBR partition was not found.
421
422**/
423EFI_STATUS
424PartitionInstallMbrChildHandles (
425 IN EFI_DRIVER_BINDING_PROTOCOL *This,
426 IN EFI_HANDLE Handle,
427 IN EFI_DISK_IO_PROTOCOL *DiskIo,
428 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
429 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
430 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
431 );
432
433
434/**
435 Install child handles if the Handle supports Apple format.
436
437 @param This Calling context.
438 @param Handle Parent Handle.
439 @param DiskIo Parent DiskIo interface.
440 @param BlockIo Parent BlockIo interface.
441 @param[in] BlockIo2 Parent BlockIo2 interface.
442 @param DevicePath Parent Device Path.
443
444 @retval EFI_SUCCESS A child handle was added.
445 @retval EFI_MEDIA_CHANGED Media change was detected.
446 @retval Others Apple partition was not found.
447
448**/
449EFI_STATUS
450PartitionInstallAppleChildHandles (
451 IN EFI_DRIVER_BINDING_PROTOCOL *This,
452 IN EFI_HANDLE Handle,
453 IN EFI_DISK_IO_PROTOCOL *DiskIo,
454 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
455 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
456 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
457 );
458
459typedef
460EFI_STATUS
461(*PARTITION_DETECT_ROUTINE) (
462 IN EFI_DRIVER_BINDING_PROTOCOL *This,
463 IN EFI_HANDLE Handle,
464 IN EFI_DISK_IO_PROTOCOL *DiskIo,
465 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
466 IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,
467 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
468 );
469
470#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette