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 <Protocol/BlockIo.h>
24 #include <Protocol/ComponentName.h>
25 #include <Protocol/DevicePath.h>
26 #include <Protocol/DriverBinding.h>
27 #include <Protocol/DiskIo.h>
28 #include <Library/DebugLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/BaseLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/UefiBootServicesTableLib.h>
35 #include <Library/DevicePathLib.h>
37 #include <IndustryStandard/Mbr.h>
38 #include <IndustryStandard/ElTorito.h>
42 // Partition private data
44 #define PARTITION_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('P', 'a', 'r', 't')
49 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
50 EFI_BLOCK_IO_PROTOCOL BlockIo
;
51 EFI_BLOCK_IO_MEDIA Media
;
53 EFI_DISK_IO_PROTOCOL
*DiskIo
;
54 EFI_BLOCK_IO_PROTOCOL
*ParentBlockIo
;
61 } PARTITION_PRIVATE_DATA
;
63 #define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)
68 extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding
;
69 extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName
;
72 // Extract INT32 from char array
74 #define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
75 (((UINT8 *) a)[1] << 8) | \
76 (((UINT8 *) a)[2] << 16) | \
77 (((UINT8 *) a)[3] << 24) )
80 // Extract UINT32 from char array
82 #define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \
83 (((UINT8 *) a)[1] << 8) | \
84 (((UINT8 *) a)[2] << 16) | \
85 (((UINT8 *) a)[3] << 24) )
88 // Function Prototypes
92 PartitionDriverBindingSupported (
93 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
94 IN EFI_HANDLE ControllerHandle
,
95 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
100 PartitionDriverBindingStart (
101 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
102 IN EFI_HANDLE ControllerHandle
,
103 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
108 PartitionDriverBindingStop (
109 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
110 IN EFI_HANDLE ControllerHandle
,
111 IN UINTN NumberOfChildren
,
112 IN EFI_HANDLE
*ChildHandleBuffer
116 // EFI Component Name Functions
120 PartitionComponentNameGetDriverName (
121 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
123 OUT CHAR16
**DriverName
128 PartitionComponentNameGetControllerName (
129 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
130 IN EFI_HANDLE ControllerHandle
,
131 IN EFI_HANDLE ChildHandle OPTIONAL
,
133 OUT CHAR16
**ControllerName
137 PartitionInstallChildHandle (
138 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
139 IN EFI_HANDLE ParentHandle
,
140 IN EFI_DISK_IO_PROTOCOL
*ParentDiskIo
,
141 IN EFI_BLOCK_IO_PROTOCOL
*ParentBlockIo
,
142 IN EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
,
143 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
147 IN BOOLEAN InstallEspGuid
152 PartitionInstallGptChildHandles (
153 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
154 IN EFI_HANDLE Handle
,
155 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
156 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
157 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
162 PartitionInstallElToritoChildHandles (
163 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
164 IN EFI_HANDLE Handle
,
165 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
166 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
167 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
172 PartitionInstallMbrChildHandles (
173 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
174 IN EFI_HANDLE Handle
,
175 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
176 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
177 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
183 (*PARTITION_DETECT_ROUTINE
) (
184 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
185 IN EFI_HANDLE Handle
,
186 IN EFI_DISK_IO_PROTOCOL
*DiskIo
,
187 IN EFI_BLOCK_IO_PROTOCOL
*BlockIo
,
188 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath