]>
Commit | Line | Data |
---|---|---|
adbcbf8f | 1 | /** @file\r |
2 | Partition driver that produces logical BlockIo devices from a physical \r | |
3 | BlockIo device. The logical BlockIo devices are based on the format\r | |
4 | of the raw block devices media. Currently "El Torito CD-ROM", Legacy \r | |
5 | MBR, and GPT partition schemes are supported.\r | |
6 | \r | |
47e1a80b | 7 | Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r |
f42be642 | 8 | All rights reserved. This program and the accompanying materials\r |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
adbcbf8f | 15 | \r |
16 | **/\r | |
17 | \r | |
ea7cb08c | 18 | #ifndef _PARTITION_H_ \r |
19 | #define _PARTITION_H_ \r | |
adbcbf8f | 20 | \r |
21 | #include <Uefi.h>\r | |
22 | #include <Protocol/BlockIo.h>\r | |
23 | #include <Guid/Gpt.h>\r | |
24 | #include <Protocol/ComponentName.h>\r | |
25 | #include <Protocol/DevicePath.h>\r | |
26 | #include <Protocol/DriverBinding.h>\r | |
27 | #include <Protocol/DiskIo.h>\r | |
28 | #include <Library/DebugLib.h>\r | |
29 | #include <Library/UefiDriverEntryPoint.h>\r | |
30 | #include <Library/BaseLib.h>\r | |
31 | #include <Library/UefiLib.h>\r | |
32 | #include <Library/BaseMemoryLib.h>\r | |
33 | #include <Library/MemoryAllocationLib.h>\r | |
34 | #include <Library/UefiBootServicesTableLib.h>\r | |
35 | #include <Library/DevicePathLib.h>\r | |
36 | \r | |
37 | #include <IndustryStandard/Mbr.h>\r | |
38 | #include <IndustryStandard/ElTorito.h>\r | |
39 | \r | |
40 | \r | |
41 | //\r | |
42 | // Partition private data\r | |
43 | //\r | |
f3f2e05d | 44 | #define PARTITION_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'a', 'r', 't')\r |
adbcbf8f | 45 | typedef struct {\r |
46 | UINT64 Signature;\r | |
47 | \r | |
48 | EFI_HANDLE Handle;\r | |
49 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
50 | EFI_BLOCK_IO_PROTOCOL BlockIo;\r | |
51 | EFI_BLOCK_IO_MEDIA Media;\r | |
52 | \r | |
53 | EFI_DISK_IO_PROTOCOL *DiskIo;\r | |
54 | EFI_BLOCK_IO_PROTOCOL *ParentBlockIo;\r | |
55 | UINT64 Start;\r | |
56 | UINT64 End;\r | |
57 | UINT32 BlockSize;\r | |
58 | \r | |
59 | EFI_GUID *EspGuid;\r | |
60 | \r | |
61 | } PARTITION_PRIVATE_DATA;\r | |
62 | \r | |
63 | #define PARTITION_DEVICE_FROM_BLOCK_IO_THIS(a) CR (a, PARTITION_PRIVATE_DATA, BlockIo, PARTITION_PRIVATE_DATA_SIGNATURE)\r | |
64 | \r | |
65 | //\r | |
66 | // Global Variables\r | |
67 | //\r | |
d38a0f44 | 68 | extern EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding;\r |
69 | extern EFI_COMPONENT_NAME_PROTOCOL gPartitionComponentName;\r | |
70 | extern EFI_COMPONENT_NAME2_PROTOCOL gPartitionComponentName2;\r | |
adbcbf8f | 71 | \r |
72 | //\r | |
73 | // Extract INT32 from char array\r | |
74 | //\r | |
75 | #define UNPACK_INT32(a) (INT32)( (((UINT8 *) a)[0] << 0) | \\r | |
76 | (((UINT8 *) a)[1] << 8) | \\r | |
77 | (((UINT8 *) a)[2] << 16) | \\r | |
78 | (((UINT8 *) a)[3] << 24) )\r | |
79 | \r | |
80 | //\r | |
81 | // Extract UINT32 from char array\r | |
82 | //\r | |
83 | #define UNPACK_UINT32(a) (UINT32)( (((UINT8 *) a)[0] << 0) | \\r | |
84 | (((UINT8 *) a)[1] << 8) | \\r | |
85 | (((UINT8 *) a)[2] << 16) | \\r | |
86 | (((UINT8 *) a)[3] << 24) )\r | |
87 | \r | |
4f06d35a | 88 | \r |
89 | //\r | |
90 | // GPT Partition Entry Status\r | |
91 | //\r | |
92 | typedef struct {\r | |
93 | BOOLEAN OutOfRange;\r | |
94 | BOOLEAN Overlap;\r | |
47e1a80b | 95 | BOOLEAN OsSpecific;\r |
4f06d35a | 96 | } EFI_PARTITION_ENTRY_STATUS;\r |
97 | \r | |
adbcbf8f | 98 | //\r |
99 | // Function Prototypes\r | |
100 | //\r | |
a8d0c20e | 101 | /**\r |
102 | Test to see if this driver supports ControllerHandle. Any ControllerHandle\r | |
103 | than contains a BlockIo and DiskIo protocol can be supported.\r | |
104 | \r | |
105 | @param This Protocol instance pointer.\r | |
106 | @param ControllerHandle Handle of device to test\r | |
107 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
108 | device to start.\r | |
109 | \r | |
110 | @retval EFI_SUCCESS This driver supports this device\r | |
111 | @retval EFI_ALREADY_STARTED This driver is already running on this device\r | |
112 | @retval other This driver does not support this device\r | |
113 | \r | |
114 | **/\r | |
adbcbf8f | 115 | EFI_STATUS\r |
116 | EFIAPI\r | |
117 | PartitionDriverBindingSupported (\r | |
118 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
119 | IN EFI_HANDLE ControllerHandle,\r | |
120 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
121 | );\r | |
122 | \r | |
a8d0c20e | 123 | /**\r |
124 | Start this driver on ControllerHandle by opening a Block IO and Disk IO\r | |
125 | protocol, reading Device Path, and creating a child handle with a\r | |
126 | Disk IO and device path protocol.\r | |
127 | \r | |
128 | @param This Protocol instance pointer.\r | |
129 | @param ControllerHandle Handle of device to bind driver to\r | |
130 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
131 | device to start.\r | |
132 | \r | |
133 | @retval EFI_SUCCESS This driver is added to ControllerHandle\r | |
134 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r | |
135 | @retval other This driver does not support this device\r | |
136 | \r | |
137 | **/\r | |
adbcbf8f | 138 | EFI_STATUS\r |
139 | EFIAPI\r | |
140 | PartitionDriverBindingStart (\r | |
141 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
142 | IN EFI_HANDLE ControllerHandle,\r | |
143 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
144 | );\r | |
145 | \r | |
a8d0c20e | 146 | /**\r |
48557c65 | 147 | Stop this driver on ControllerHandle. Support stopping any child handles\r |
a8d0c20e | 148 | created by this driver.\r |
149 | \r | |
150 | @param This Protocol instance pointer.\r | |
151 | @param ControllerHandle Handle of device to stop driver on\r | |
152 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
153 | children is zero stop the entire bus driver.\r | |
154 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
155 | \r | |
156 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
157 | @retval other This driver was not removed from this device\r | |
158 | \r | |
159 | **/\r | |
adbcbf8f | 160 | EFI_STATUS\r |
161 | EFIAPI\r | |
162 | PartitionDriverBindingStop (\r | |
ea7cb08c | 163 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r |
164 | IN EFI_HANDLE ControllerHandle,\r | |
165 | IN UINTN NumberOfChildren,\r | |
166 | IN EFI_HANDLE *ChildHandleBuffer\r | |
adbcbf8f | 167 | );\r |
168 | \r | |
169 | //\r | |
170 | // EFI Component Name Functions\r | |
171 | //\r | |
d38a0f44 | 172 | /**\r |
173 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
174 | \r | |
175 | This function retrieves the user readable name of a driver in the form of a\r | |
176 | Unicode string. If the driver specified by This has a user readable name in\r | |
177 | the language specified by Language, then a pointer to the driver name is\r | |
178 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
179 | by This does not support the language specified by Language,\r | |
180 | then EFI_UNSUPPORTED is returned.\r | |
181 | \r | |
182 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
183 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
184 | \r | |
185 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
186 | array indicating the language. This is the\r | |
187 | language of the driver name that the caller is\r | |
188 | requesting, and it must match one of the\r | |
189 | languages specified in SupportedLanguages. The\r | |
190 | number of languages supported by a driver is up\r | |
191 | to the driver writer. Language is specified\r | |
0254efc0 | 192 | in RFC 4646 or ISO 639-2 language code format.\r |
d38a0f44 | 193 | \r |
194 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
195 | This Unicode string is the name of the\r | |
196 | driver specified by This in the language\r | |
197 | specified by Language.\r | |
198 | \r | |
199 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
200 | This and the language specified by Language was\r | |
201 | returned in DriverName.\r | |
202 | \r | |
203 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
204 | \r | |
205 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
206 | \r | |
207 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
208 | the language specified by Language.\r | |
209 | \r | |
210 | **/\r | |
adbcbf8f | 211 | EFI_STATUS\r |
212 | EFIAPI\r | |
213 | PartitionComponentNameGetDriverName (\r | |
214 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
215 | IN CHAR8 *Language,\r | |
216 | OUT CHAR16 **DriverName\r | |
217 | );\r | |
218 | \r | |
d38a0f44 | 219 | \r |
220 | /**\r | |
221 | Retrieves a Unicode string that is the user readable name of the controller\r | |
222 | that is being managed by a driver.\r | |
223 | \r | |
224 | This function retrieves the user readable name of the controller specified by\r | |
225 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
226 | driver specified by This has a user readable name in the language specified by\r | |
227 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
228 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
229 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
230 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
231 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
232 | \r | |
233 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
234 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
235 | \r | |
236 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
237 | specified by This is managing. This handle\r | |
238 | specifies the controller whose name is to be\r | |
239 | returned.\r | |
240 | \r | |
241 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
242 | the name of. This is an optional parameter that\r | |
243 | may be NULL. It will be NULL for device\r | |
244 | drivers. It will also be NULL for a bus drivers\r | |
245 | that wish to retrieve the name of the bus\r | |
246 | controller. It will not be NULL for a bus\r | |
247 | driver that wishes to retrieve the name of a\r | |
248 | child controller.\r | |
249 | \r | |
250 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
251 | array indicating the language. This is the\r | |
252 | language of the driver name that the caller is\r | |
253 | requesting, and it must match one of the\r | |
254 | languages specified in SupportedLanguages. The\r | |
255 | number of languages supported by a driver is up\r | |
256 | to the driver writer. Language is specified in\r | |
0254efc0 | 257 | RFC 4646 or ISO 639-2 language code format.\r |
d38a0f44 | 258 | \r |
259 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
260 | This Unicode string is the name of the\r | |
261 | controller specified by ControllerHandle and\r | |
262 | ChildHandle in the language specified by\r | |
263 | Language from the point of view of the driver\r | |
264 | specified by This.\r | |
265 | \r | |
266 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
267 | the language specified by Language for the\r | |
268 | driver specified by This was returned in\r | |
269 | DriverName.\r | |
270 | \r | |
271 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
272 | \r | |
273 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
274 | EFI_HANDLE.\r | |
275 | \r | |
276 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
277 | \r | |
278 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
279 | \r | |
280 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
281 | managing the controller specified by\r | |
282 | ControllerHandle and ChildHandle.\r | |
283 | \r | |
284 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
285 | the language specified by Language.\r | |
286 | \r | |
287 | **/\r | |
adbcbf8f | 288 | EFI_STATUS\r |
289 | EFIAPI\r | |
290 | PartitionComponentNameGetControllerName (\r | |
291 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
292 | IN EFI_HANDLE ControllerHandle,\r | |
293 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
294 | IN CHAR8 *Language,\r | |
295 | OUT CHAR16 **ControllerName\r | |
296 | );\r | |
297 | \r | |
d38a0f44 | 298 | \r |
a8d0c20e | 299 | /**\r |
300 | Create a child handle for a logical block device that represents the\r | |
301 | bytes Start to End of the Parent Block IO device.\r | |
302 | \r | |
303 | @param[in] This Protocol instance pointer\r | |
304 | @param[in] ParentHandle Parent Handle for new child\r | |
305 | @param[in] ParentDiskIo Parent DiskIo interface\r | |
306 | @param[in] ParentBlockIo Parent BlockIo interface\r | |
307 | @param[in] ParentDevicePath Parent Device Path\r | |
308 | @param[in] DevicePathNode Child Device Path node\r | |
309 | @param[in] Start Start Block\r | |
310 | @param[in] End End Block\r | |
311 | @param[in] BlockSize Child block size\r | |
312 | @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle\r | |
313 | \r | |
314 | @retval EFI_SUCCESS A child handle was added\r | |
315 | @retval other A child handle was not added\r | |
316 | \r | |
317 | **/\r | |
adbcbf8f | 318 | EFI_STATUS\r |
319 | PartitionInstallChildHandle (\r | |
320 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
321 | IN EFI_HANDLE ParentHandle,\r | |
322 | IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,\r | |
323 | IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,\r | |
324 | IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r | |
325 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r | |
ea7cb08c | 326 | IN EFI_LBA Start,\r |
327 | IN EFI_LBA End,\r | |
adbcbf8f | 328 | IN UINT32 BlockSize,\r |
329 | IN BOOLEAN InstallEspGuid\r | |
ea7cb08c | 330 | );\r |
adbcbf8f | 331 | \r |
a8d0c20e | 332 | /**\r |
333 | Install child handles if the Handle supports GPT partition structure.\r | |
334 | \r | |
335 | @param[in] This - Calling context.\r | |
336 | @param[in] Handle - Parent Handle\r | |
337 | @param[in] DiskIo - Parent DiskIo interface\r | |
338 | @param[in] BlockIo - Parent BlockIo interface\r | |
339 | @param[in] DevicePath - Parent Device Path\r | |
340 | \r | |
341 | @retval EFI_SUCCESS Valid GPT disk\r | |
342 | @retval EFI_MEDIA_CHANGED Media changed Detected\r | |
343 | @retval other Not a valid GPT disk\r | |
344 | \r | |
345 | **/\r | |
adbcbf8f | 346 | EFI_STATUS\r |
347 | PartitionInstallGptChildHandles (\r | |
348 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
349 | IN EFI_HANDLE Handle,\r | |
350 | IN EFI_DISK_IO_PROTOCOL *DiskIo,\r | |
351 | IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r | |
352 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
ea7cb08c | 353 | );\r |
adbcbf8f | 354 | \r |
a8d0c20e | 355 | /**\r |
356 | Install child handles if the Handle supports El Torito format.\r | |
357 | \r | |
358 | @param[in] This Calling context.\r | |
359 | @param[in] Handle Parent Handle\r | |
360 | @param[in] DiskIo Parent DiskIo interface\r | |
361 | @param[in] BlockIo Parent BlockIo interface\r | |
362 | @param[in] DevicePath Parent Device Path\r | |
363 | \r | |
364 | \r | |
365 | @retval EFI_SUCCESS Child handle(s) was added\r | |
366 | @retval EFI_MEDIA_CHANGED Media changed Detected\r | |
367 | @retval other no child handle was added\r | |
368 | \r | |
369 | **/\r | |
adbcbf8f | 370 | EFI_STATUS\r |
371 | PartitionInstallElToritoChildHandles (\r | |
372 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
373 | IN EFI_HANDLE Handle,\r | |
374 | IN EFI_DISK_IO_PROTOCOL *DiskIo,\r | |
375 | IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r | |
376 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
ea7cb08c | 377 | );\r |
adbcbf8f | 378 | \r |
a8d0c20e | 379 | /**\r |
380 | Install child handles if the Handle supports MBR format.\r | |
381 | \r | |
382 | @param This Calling context.\r | |
383 | @param Handle Parent Handle.\r | |
384 | @param DiskIo Parent DiskIo interface.\r | |
385 | @param BlockIo Parent BlockIo interface.\r | |
386 | @param DevicePath Parent Device Path.\r | |
387 | \r | |
388 | @retval EFI_SUCCESS A child handle was added.\r | |
389 | @retval EFI_MEDIA_CHANGED Media change was detected.\r | |
390 | @retval Others MBR partition was not found.\r | |
391 | \r | |
392 | **/\r | |
adbcbf8f | 393 | EFI_STATUS\r |
394 | PartitionInstallMbrChildHandles (\r | |
395 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
396 | IN EFI_HANDLE Handle,\r | |
397 | IN EFI_DISK_IO_PROTOCOL *DiskIo,\r | |
398 | IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r | |
399 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
ea7cb08c | 400 | );\r |
adbcbf8f | 401 | \r |
402 | typedef\r | |
403 | EFI_STATUS\r | |
404 | (*PARTITION_DETECT_ROUTINE) (\r | |
405 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
406 | IN EFI_HANDLE Handle,\r | |
407 | IN EFI_DISK_IO_PROTOCOL *DiskIo,\r | |
408 | IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r | |
409 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
410 | );\r | |
411 | \r | |
412 | #endif\r |