]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Disk/PartitionDxe/Partition.h
Add doxygen style comments for functions in Partition & Disk IO modules.
[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 - 2008, Intel Corporation. <BR>
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 /**
92 Test to see if this driver supports ControllerHandle. Any ControllerHandle
93 than contains a BlockIo and DiskIo protocol can be supported.
94
95 @param This Protocol instance pointer.
96 @param ControllerHandle Handle of device to test
97 @param RemainingDevicePath Optional parameter use to pick a specific child
98 device to start.
99
100 @retval EFI_SUCCESS This driver supports this device
101 @retval EFI_ALREADY_STARTED This driver is already running on this device
102 @retval other This driver does not support this device
103
104 **/
105 EFI_STATUS
106 EFIAPI
107 PartitionDriverBindingSupported (
108 IN EFI_DRIVER_BINDING_PROTOCOL *This,
109 IN EFI_HANDLE ControllerHandle,
110 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
111 );
112
113 /**
114 Start this driver on ControllerHandle by opening a Block IO and Disk IO
115 protocol, reading Device Path, and creating a child handle with a
116 Disk IO and device path protocol.
117
118 @param This Protocol instance pointer.
119 @param ControllerHandle Handle of device to bind driver to
120 @param RemainingDevicePath Optional parameter use to pick a specific child
121 device to start.
122
123 @retval EFI_SUCCESS This driver is added to ControllerHandle
124 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
125 @retval other This driver does not support this device
126
127 **/
128 EFI_STATUS
129 EFIAPI
130 PartitionDriverBindingStart (
131 IN EFI_DRIVER_BINDING_PROTOCOL *This,
132 IN EFI_HANDLE ControllerHandle,
133 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
134 );
135
136 /**
137 Stop this driver on ControllerHandle. Support stoping any child handles
138 created by this driver.
139
140 @param This Protocol instance pointer.
141 @param ControllerHandle Handle of device to stop driver on
142 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
143 children is zero stop the entire bus driver.
144 @param ChildHandleBuffer List of Child Handles to Stop.
145
146 @retval EFI_SUCCESS This driver is removed ControllerHandle
147 @retval other This driver was not removed from this device
148
149 **/
150 EFI_STATUS
151 EFIAPI
152 PartitionDriverBindingStop (
153 IN EFI_DRIVER_BINDING_PROTOCOL *This,
154 IN EFI_HANDLE ControllerHandle,
155 IN UINTN NumberOfChildren,
156 IN EFI_HANDLE *ChildHandleBuffer
157 );
158
159 //
160 // EFI Component Name Functions
161 //
162 /**
163 Retrieves a Unicode string that is the user readable name of the driver.
164
165 This function retrieves the user readable name of a driver in the form of a
166 Unicode string. If the driver specified by This has a user readable name in
167 the language specified by Language, then a pointer to the driver name is
168 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
169 by This does not support the language specified by Language,
170 then EFI_UNSUPPORTED is returned.
171
172 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
173 EFI_COMPONENT_NAME_PROTOCOL instance.
174
175 @param Language[in] A pointer to a Null-terminated ASCII string
176 array indicating the language. This is the
177 language of the driver name that the caller is
178 requesting, and it must match one of the
179 languages specified in SupportedLanguages. The
180 number of languages supported by a driver is up
181 to the driver writer. Language is specified
182 in RFC 3066 or ISO 639-2 language code format.
183
184 @param DriverName[out] A pointer to the Unicode string to return.
185 This Unicode string is the name of the
186 driver specified by This in the language
187 specified by Language.
188
189 @retval EFI_SUCCESS The Unicode string for the Driver specified by
190 This and the language specified by Language was
191 returned in DriverName.
192
193 @retval EFI_INVALID_PARAMETER Language is NULL.
194
195 @retval EFI_INVALID_PARAMETER DriverName is NULL.
196
197 @retval EFI_UNSUPPORTED The driver specified by This does not support
198 the language specified by Language.
199
200 **/
201 EFI_STATUS
202 EFIAPI
203 PartitionComponentNameGetDriverName (
204 IN EFI_COMPONENT_NAME_PROTOCOL *This,
205 IN CHAR8 *Language,
206 OUT CHAR16 **DriverName
207 );
208
209
210 /**
211 Retrieves a Unicode string that is the user readable name of the controller
212 that is being managed by a driver.
213
214 This function retrieves the user readable name of the controller specified by
215 ControllerHandle and ChildHandle in the form of a Unicode string. If the
216 driver specified by This has a user readable name in the language specified by
217 Language, then a pointer to the controller name is returned in ControllerName,
218 and EFI_SUCCESS is returned. If the driver specified by This is not currently
219 managing the controller specified by ControllerHandle and ChildHandle,
220 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
221 support the language specified by Language, then EFI_UNSUPPORTED is returned.
222
223 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
224 EFI_COMPONENT_NAME_PROTOCOL instance.
225
226 @param ControllerHandle[in] The handle of a controller that the driver
227 specified by This is managing. This handle
228 specifies the controller whose name is to be
229 returned.
230
231 @param ChildHandle[in] The handle of the child controller to retrieve
232 the name of. This is an optional parameter that
233 may be NULL. It will be NULL for device
234 drivers. It will also be NULL for a bus drivers
235 that wish to retrieve the name of the bus
236 controller. It will not be NULL for a bus
237 driver that wishes to retrieve the name of a
238 child controller.
239
240 @param Language[in] A pointer to a Null-terminated ASCII string
241 array indicating the language. This is the
242 language of the driver name that the caller is
243 requesting, and it must match one of the
244 languages specified in SupportedLanguages. The
245 number of languages supported by a driver is up
246 to the driver writer. Language is specified in
247 RFC 3066 or ISO 639-2 language code format.
248
249 @param ControllerName[out] A pointer to the Unicode string to return.
250 This Unicode string is the name of the
251 controller specified by ControllerHandle and
252 ChildHandle in the language specified by
253 Language from the point of view of the driver
254 specified by This.
255
256 @retval EFI_SUCCESS The Unicode string for the user readable name in
257 the language specified by Language for the
258 driver specified by This was returned in
259 DriverName.
260
261 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
262
263 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
264 EFI_HANDLE.
265
266 @retval EFI_INVALID_PARAMETER Language is NULL.
267
268 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
269
270 @retval EFI_UNSUPPORTED The driver specified by This is not currently
271 managing the controller specified by
272 ControllerHandle and ChildHandle.
273
274 @retval EFI_UNSUPPORTED The driver specified by This does not support
275 the language specified by Language.
276
277 **/
278 EFI_STATUS
279 EFIAPI
280 PartitionComponentNameGetControllerName (
281 IN EFI_COMPONENT_NAME_PROTOCOL *This,
282 IN EFI_HANDLE ControllerHandle,
283 IN EFI_HANDLE ChildHandle OPTIONAL,
284 IN CHAR8 *Language,
285 OUT CHAR16 **ControllerName
286 );
287
288
289 /**
290 Create a child handle for a logical block device that represents the
291 bytes Start to End of the Parent Block IO device.
292
293 @param[in] This Protocol instance pointer
294 @param[in] ParentHandle Parent Handle for new child
295 @param[in] ParentDiskIo Parent DiskIo interface
296 @param[in] ParentBlockIo Parent BlockIo interface
297 @param[in] ParentDevicePath Parent Device Path
298 @param[in] DevicePathNode Child Device Path node
299 @param[in] Start Start Block
300 @param[in] End End Block
301 @param[in] BlockSize Child block size
302 @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle
303
304 @retval EFI_SUCCESS A child handle was added
305 @retval other A child handle was not added
306
307 **/
308 EFI_STATUS
309 PartitionInstallChildHandle (
310 IN EFI_DRIVER_BINDING_PROTOCOL *This,
311 IN EFI_HANDLE ParentHandle,
312 IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,
313 IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,
314 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
315 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
316 IN UINT64 Start,
317 IN UINT64 End,
318 IN UINT32 BlockSize,
319 IN BOOLEAN InstallEspGuid
320 )
321 ;
322
323 /**
324 Install child handles if the Handle supports GPT partition structure.
325
326 @param[in] This - Calling context.
327 @param[in] Handle - Parent Handle
328 @param[in] DiskIo - Parent DiskIo interface
329 @param[in] BlockIo - Parent BlockIo interface
330 @param[in] DevicePath - Parent Device Path
331
332 @retval EFI_SUCCESS Valid GPT disk
333 @retval EFI_MEDIA_CHANGED Media changed Detected
334 @retval other Not a valid GPT disk
335
336 **/
337 EFI_STATUS
338 PartitionInstallGptChildHandles (
339 IN EFI_DRIVER_BINDING_PROTOCOL *This,
340 IN EFI_HANDLE Handle,
341 IN EFI_DISK_IO_PROTOCOL *DiskIo,
342 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
343 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
344 )
345 ;
346
347 /**
348 Install child handles if the Handle supports El Torito format.
349
350 @param[in] This Calling context.
351 @param[in] Handle Parent Handle
352 @param[in] DiskIo Parent DiskIo interface
353 @param[in] BlockIo Parent BlockIo interface
354 @param[in] DevicePath Parent Device Path
355
356
357 @retval EFI_SUCCESS Child handle(s) was added
358 @retval EFI_MEDIA_CHANGED Media changed Detected
359 @retval other no child handle was added
360
361 **/
362 EFI_STATUS
363 PartitionInstallElToritoChildHandles (
364 IN EFI_DRIVER_BINDING_PROTOCOL *This,
365 IN EFI_HANDLE Handle,
366 IN EFI_DISK_IO_PROTOCOL *DiskIo,
367 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
368 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
369 )
370 ;
371
372 /**
373 Install child handles if the Handle supports MBR format.
374
375 @param This Calling context.
376 @param Handle Parent Handle.
377 @param DiskIo Parent DiskIo interface.
378 @param BlockIo Parent BlockIo interface.
379 @param DevicePath Parent Device Path.
380
381 @retval EFI_SUCCESS A child handle was added.
382 @retval EFI_MEDIA_CHANGED Media change was detected.
383 @retval Others MBR partition was not found.
384
385 **/
386 EFI_STATUS
387 PartitionInstallMbrChildHandles (
388 IN EFI_DRIVER_BINDING_PROTOCOL *This,
389 IN EFI_HANDLE Handle,
390 IN EFI_DISK_IO_PROTOCOL *DiskIo,
391 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
392 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
393 )
394 ;
395
396 typedef
397 EFI_STATUS
398 (*PARTITION_DETECT_ROUTINE) (
399 IN EFI_DRIVER_BINDING_PROTOCOL *This,
400 IN EFI_HANDLE Handle,
401 IN EFI_DISK_IO_PROTOCOL *DiskIo,
402 IN EFI_BLOCK_IO_PROTOCOL *BlockIo,
403 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
404 );
405
406 #endif