VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/PartitionDxe/Partition.h@ 58173

Last change on this file since 58173 was 56292, checked in by vboxsync, 10 years ago

Devices: Updated (C) year.

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

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