]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
Update to support to produce Component Name and & Component Name 2 protocol based...
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Partition.h
1 /** @file
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.
6
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
12
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.
15
16 **/
17
18 #ifndef _PARTITION_H
19 #define _PARTITION_H
20
21 #include <Uefi.h>
22 #include <Protocol/BlockIo.h>
23 #include <Guid/Gpt.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>
36
37 #include <IndustryStandard/Mbr.h>
38 #include <IndustryStandard/ElTorito.h>
39
40
41 //
42 // Partition private data
43 //
44 #define PARTITION_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('P', 'a', 'r', 't')
45 typedef struct {
46 UINT64 Signature;
47
48 EFI_HANDLE Handle;
49 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
50 EFI_BLOCK_IO_PROTOCOL BlockIo;
51 EFI_BLOCK_IO_MEDIA Media;
52
53 EFI_DISK_IO_PROTOCOL *DiskIo;
54 EFI_BLOCK_IO_PROTOCOL *ParentBlockIo;
55 UINT64 Start;
56 UINT64 End;
57 UINT32 BlockSize;
58
59 EFI_GUID *EspGuid;
60
61 } PARTITION_PRIVATE_DATA;
62
63 #define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)
64
65 //
66 // Global Variables
67 //
68 extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding;
69 extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName;
70 extern EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2;
71
72 //
73 // Extract INT32 from char array
74 //
75 #define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \
76 (((UINT8 *) a)[1] << 8) | \
77 (((UINT8 *) a)[2] << 16) | \
78 (((UINT8 *) a)[3] << 24) )
79
80 //
81 // Extract UINT32 from char array
82 //
83 #define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \
84 (((UINT8 *) a)[1] << 8) | \
85 (((UINT8 *) a)[2] << 16) | \
86 (((UINT8 *) a)[3] << 24) )
87
88 //
89 // Function Prototypes
90 //
91 EFI_STATUS
92 EFIAPI
93 PartitionDriverBindingSupported (
94 IN EFI_DRIVER_BINDING_PROTOCOL *This,
95 IN EFI_HANDLE ControllerHandle,
96 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
97 );
98
99 EFI_STATUS
100 EFIAPI
101 PartitionDriverBindingStart (
102 IN EFI_DRIVER_BINDING_PROTOCOL *This,
103 IN EFI_HANDLE ControllerHandle,
104 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
105 );
106
107 EFI_STATUS
108 EFIAPI
109 PartitionDriverBindingStop (
110 IN EFI_DRIVER_BINDING_PROTOCOL *This,
111 IN EFI_HANDLE ControllerHandle,
112 IN UINTN NumberOfChildren,
113 IN EFI_HANDLE *ChildHandleBuffer
114 );
115
116 //
117 // EFI Component Name Functions
118 //
119 /**
120 Retrieves a Unicode string that is the user readable name of the driver.
121
122 This function retrieves the user readable name of a driver in the form of a
123 Unicode string. If the driver specified by This has a user readable name in
124 the language specified by Language, then a pointer to the driver name is
125 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
126 by This does not support the language specified by Language,
127 then EFI_UNSUPPORTED is returned.
128
129 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
130 EFI_COMPONENT_NAME_PROTOCOL instance.
131
132 @param Language[in] A pointer to a Null-terminated ASCII string
133 array indicating the language. This is the
134 language of the driver name that the caller is
135 requesting, and it must match one of the
136 languages specified in SupportedLanguages. The
137 number of languages supported by a driver is up
138 to the driver writer. Language is specified
139 in RFC 3066 or ISO 639-2 language code format.
140
141 @param DriverName[out] A pointer to the Unicode string to return.
142 This Unicode string is the name of the
143 driver specified by This in the language
144 specified by Language.
145
146 @retval EFI_SUCCESS The Unicode string for the Driver specified by
147 This and the language specified by Language was
148 returned in DriverName.
149
150 @retval EFI_INVALID_PARAMETER Language is NULL.
151
152 @retval EFI_INVALID_PARAMETER DriverName is NULL.
153
154 @retval EFI_UNSUPPORTED The driver specified by This does not support
155 the language specified by Language.
156
157 **/
158 EFI_STATUS
159 EFIAPI
160 PartitionComponentNameGetDriverName (
161 IN EFI_COMPONENT_NAME_PROTOCOL *This,
162 IN CHAR8 *Language,
163 OUT CHAR16 **DriverName
164 );
165
166
167 /**
168 Retrieves a Unicode string that is the user readable name of the controller
169 that is being managed by a driver.
170
171 This function retrieves the user readable name of the controller specified by
172 ControllerHandle and ChildHandle in the form of a Unicode string. If the
173 driver specified by This has a user readable name in the language specified by
174 Language, then a pointer to the controller name is returned in ControllerName,
175 and EFI_SUCCESS is returned. If the driver specified by This is not currently
176 managing the controller specified by ControllerHandle and ChildHandle,
177 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
178 support the language specified by Language, then EFI_UNSUPPORTED is returned.
179
180 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
181 EFI_COMPONENT_NAME_PROTOCOL instance.
182
183 @param ControllerHandle[in] The handle of a controller that the driver
184 specified by This is managing. This handle
185 specifies the controller whose name is to be
186 returned.
187
188 @param ChildHandle[in] The handle of the child controller to retrieve
189 the name of. This is an optional parameter that
190 may be NULL. It will be NULL for device
191 drivers. It will also be NULL for a bus drivers
192 that wish to retrieve the name of the bus
193 controller. It will not be NULL for a bus
194 driver that wishes to retrieve the name of a
195 child controller.
196
197 @param Language[in] A pointer to a Null-terminated ASCII string
198 array indicating the language. This is the
199 language of the driver name that the caller is
200 requesting, and it must match one of the
201 languages specified in SupportedLanguages. The
202 number of languages supported by a driver is up
203 to the driver writer. Language is specified in
204 RFC 3066 or ISO 639-2 language code format.
205
206 @param ControllerName[out] A pointer to the Unicode string to return.
207 This Unicode string is the name of the
208 controller specified by ControllerHandle and
209 ChildHandle in the language specified by
210 Language from the point of view of the driver
211 specified by This.
212
213 @retval EFI_SUCCESS The Unicode string for the user readable name in
214 the language specified by Language for the
215 driver specified by This was returned in
216 DriverName.
217
218 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
219
220 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
221 EFI_HANDLE.
222
223 @retval EFI_INVALID_PARAMETER Language is NULL.
224
225 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
226
227 @retval EFI_UNSUPPORTED The driver specified by This is not currently
228 managing the controller specified by
229 ControllerHandle and ChildHandle.
230
231 @retval EFI_UNSUPPORTED The driver specified by This does not support
232 the language specified by Language.
233
234 **/
235 EFI_STATUS
236 EFIAPI
237 PartitionComponentNameGetControllerName (
238 IN EFI_COMPONENT_NAME_PROTOCOL *This,
239 IN EFI_HANDLE ControllerHandle,
240 IN EFI_HANDLE ChildHandle OPTIONAL,
241 IN CHAR8 *Language,
242 OUT CHAR16 **ControllerName
243 );
244
245
246 EFI_STATUS
247 PartitionInstallChildHandle (
248 IN EFI_DRIVER_BINDING_PROTOCOL *This,
249 IN EFI_HANDLE ParentHandle,
250 IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,
251 IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,
252 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
253 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
254 IN UINT64 Start,
255 IN UINT64 End,
256 IN UINT32 BlockSize,
257 IN BOOLEAN InstallEspGuid
258 )
259 ;
260
261 EFI_STATUS
262 PartitionInstallGptChildHandles (
263 IN EFI_DRIVER_BINDING_PROTOCOL *This,
264 IN EFI_HANDLE Handle,
265 IN EFI_DISK_IO_PROTOCOL *DiskIo,
266 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
267 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
268 )
269 ;
270
271 EFI_STATUS
272 PartitionInstallElToritoChildHandles (
273 IN EFI_DRIVER_BINDING_PROTOCOL *This,
274 IN EFI_HANDLE Handle,
275 IN EFI_DISK_IO_PROTOCOL *DiskIo,
276 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
277 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
278 )
279 ;
280
281 EFI_STATUS
282 PartitionInstallMbrChildHandles (
283 IN EFI_DRIVER_BINDING_PROTOCOL *This,
284 IN EFI_HANDLE Handle,
285 IN EFI_DISK_IO_PROTOCOL *DiskIo,
286 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
287 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
288 )
289 ;
290
291 typedef
292 EFI_STATUS
293 (*PARTITION_DETECT_ROUTINE) (
294 IN EFI_DRIVER_BINDING_PROTOCOL *This,
295 IN EFI_HANDLE Handle,
296 IN EFI_DISK_IO_PROTOCOL *DiskIo,
297 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
298 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
299 );
300
301 #endif