2 Partition driver that produces logical BlockIo devices from a physical
3 BlockIo device. The logical BlockIo devices are based on the format
4 of the raw block devices media. Currently "El Torito CD-ROM", Legacy
5 MBR, and GPT partition schemes are supported.
7 Copyright (c) 2006 - 2007, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 // Include common header file for this module.
24 #include "CommonHeader.h"
27 #include <Protocol/BlockIo.h>
29 #include <Protocol/ComponentName.h>
30 #include <Protocol/DevicePath.h>
31 #include <Protocol/DriverBinding.h>
32 #include <Protocol/DiskIo.h>
33 #include <Library/DebugLib.h>
34 #include <Library/UefiDriverEntryPoint.h>
35 #include <Library/BaseLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseMemoryLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/UefiBootServicesTableLib.h>
40 #include <Library/DevicePathLib.h>
42 #include <IndustryStandard/Mbr.h>
43 #include <IndustryStandard/ElTorito.h>
47 // Partition private data
49 #define PARTITION_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('P', 'a', 'r', 't')
54 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
55 EFI_BLOCK_IO_PROTOCOL BlockIo
;
56 EFI_BLOCK_IO_MEDIA Media
;
58 EFI_DISK_IO_PROTOCOL
*DiskIo
;
59 EFI_BLOCK_IO_PROTOCOL
*ParentBlockIo
;
66 } PARTITION_PRIVATE_DATA
;
68 #define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)
73 extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding
;
74 extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName
;
77 // Extract INT32 from char array
79 #define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
80 (((UINT8 *) a)[1] << 8) | \
81 (((UINT8 *) a)[2] << 16) | \
82 (((UINT8 *) a)[3] << 24) )
85 // Extract UINT32 from char array
87 #define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \
88 (((UINT8 *) a)[1] << 8) | \
89 (((UINT8 *) a)[2] << 16) | \
90 (((UINT8 *) a)[3] << 24) )
93 // Function Prototypes
97 PartitionDriverBindingSupported (
98 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
99 IN EFI_HANDLE ControllerHandle
,
100 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
105 PartitionDriverBindingStart (
106 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
107 IN EFI_HANDLE ControllerHandle
,
108 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
113 PartitionDriverBindingStop (
114 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
115 IN EFI_HANDLE ControllerHandle
,
116 IN UINTN NumberOfChildren
,
117 IN EFI_HANDLE
*ChildHandleBuffer
121 // EFI Component Name Functions
125 PartitionComponentNameGetDriverName (
126 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
128 OUT CHAR16
**DriverName
133 PartitionComponentNameGetControllerName (
134 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
135 IN EFI_HANDLE ControllerHandle
,
136 IN EFI_HANDLE ChildHandle OPTIONAL
,
138 OUT CHAR16
**ControllerName
142 PartitionInstallChildHandle (
143 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
144 IN EFI_HANDLE ParentHandle
,
145 IN EFI_DISK_IO_PROTOCOL
*ParentDiskIo
,
146 IN EFI_BLOCK_IO_PROTOCOL
*ParentBlockIo
,
147 IN EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
,
148 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
152 IN BOOLEAN InstallEspGuid
157 PartitionInstallGptChildHandles (
158 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
159 IN EFI_HANDLE Handle
,
160 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
161 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
162 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
167 PartitionInstallElToritoChildHandles (
168 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
169 IN EFI_HANDLE Handle
,
170 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
171 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
172 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
177 PartitionInstallMbrChildHandles (
178 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
179 IN EFI_HANDLE Handle
,
180 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
181 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
182 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
188 (*PARTITION_DETECT_ROUTINE
) (
189 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
190 IN EFI_HANDLE Handle
,
191 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
192 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
193 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath