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.
20 #include <Protocol/BlockIo.h>
22 #include <Protocol/ComponentName.h>
23 #include <Protocol/DevicePath.h>
24 #include <Protocol/DriverBinding.h>
25 #include <Protocol/DiskIo.h>
26 #include <Library/DebugLib.h>
27 #include <Library/UefiDriverEntryPoint.h>
28 #include <Library/BaseLib.h>
29 #include <Library/UefiLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/DevicePathLib.h>
36 // Driver Binding Externs
38 extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding
;
39 extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName
;
41 #include <IndustryStandard/Mbr.h>
42 #include <IndustryStandard/ElTorito.h>
46 // Partition private data
48 #define PARTITION_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('P', 'a', 'r', 't')
53 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
54 EFI_BLOCK_IO_PROTOCOL BlockIo
;
55 EFI_BLOCK_IO_MEDIA Media
;
57 EFI_DISK_IO_PROTOCOL
*DiskIo
;
58 EFI_BLOCK_IO_PROTOCOL
*ParentBlockIo
;
65 } PARTITION_PRIVATE_DATA
;
67 #define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)
72 extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding
;
73 extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName
;
76 // Extract INT32 from char array
78 #define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
79 (((UINT8 *) a)[1] << 8) | \
80 (((UINT8 *) a)[2] << 16) | \
81 (((UINT8 *) a)[3] << 24) )
84 // Extract UINT32 from char array
86 #define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \
87 (((UINT8 *) a)[1] << 8) | \
88 (((UINT8 *) a)[2] << 16) | \
89 (((UINT8 *) a)[3] << 24) )
92 // Function Prototypes
96 PartitionDriverBindingSupported (
97 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
98 IN EFI_HANDLE ControllerHandle
,
99 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
104 PartitionDriverBindingStart (
105 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
106 IN EFI_HANDLE ControllerHandle
,
107 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
112 PartitionDriverBindingStop (
113 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
114 IN EFI_HANDLE ControllerHandle
,
115 IN UINTN NumberOfChildren
,
116 IN EFI_HANDLE
*ChildHandleBuffer
120 // EFI Component Name Functions
124 PartitionComponentNameGetDriverName (
125 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
127 OUT CHAR16
**DriverName
132 PartitionComponentNameGetControllerName (
133 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
134 IN EFI_HANDLE ControllerHandle
,
135 IN EFI_HANDLE ChildHandle OPTIONAL
,
137 OUT CHAR16
**ControllerName
141 PartitionInstallChildHandle (
142 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
143 IN EFI_HANDLE ParentHandle
,
144 IN EFI_DISK_IO_PROTOCOL
*ParentDiskIo
,
145 IN EFI_BLOCK_IO_PROTOCOL
*ParentBlockIo
,
146 IN EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
,
147 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
151 IN BOOLEAN InstallEspGuid
156 PartitionInstallGptChildHandles (
157 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
158 IN EFI_HANDLE Handle
,
159 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
160 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
161 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
166 PartitionInstallElToritoChildHandles (
167 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
168 IN EFI_HANDLE Handle
,
169 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
170 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
171 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
176 PartitionInstallMbrChildHandles (
177 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
178 IN EFI_HANDLE Handle
,
179 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
180 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
181 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
187 (*PARTITION_DETECT_ROUTINE
) (
188 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
189 IN EFI_HANDLE Handle
,
190 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
191 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
192 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath