]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
Revert the wrong patch that adds NOOPT target into MdeModulePkg.dsc.
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Partition.c
... / ...
CommitLineData
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
7Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
8This program and the accompanying materials\r
9are licensed and made available under the terms and conditions of the BSD License\r
10which accompanies this distribution. The full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php\r
12\r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18\r
19#include "Partition.h"\r
20\r
21//\r
22// Partition Driver Global Variables.\r
23//\r
24EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {\r
25 PartitionDriverBindingSupported,\r
26 PartitionDriverBindingStart,\r
27 PartitionDriverBindingStop,\r
28 0xa,\r
29 NULL,\r
30 NULL\r
31};\r
32\r
33//\r
34// Prioritized function list to detect partition table. \r
35//\r
36PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {\r
37 PartitionInstallGptChildHandles,\r
38 PartitionInstallElToritoChildHandles,\r
39 PartitionInstallMbrChildHandles,\r
40 NULL\r
41};\r
42\r
43/**\r
44 Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
45 than contains a BlockIo and DiskIo protocol or a BlockIo2 protocol can be\r
46 supported.\r
47\r
48 @param[in] This Protocol instance pointer.\r
49 @param[in] ControllerHandle Handle of device to test.\r
50 @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
51 device to start.\r
52\r
53 @retval EFI_SUCCESS This driver supports this device\r
54 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
55 @retval other This driver does not support this device\r
56\r
57**/\r
58EFI_STATUS\r
59EFIAPI\r
60PartitionDriverBindingSupported (\r
61 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
62 IN EFI_HANDLE ControllerHandle,\r
63 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
64 )\r
65{\r
66 EFI_STATUS Status;\r
67 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
68 EFI_DISK_IO_PROTOCOL *DiskIo;\r
69 EFI_DEV_PATH *Node;\r
70\r
71 //\r
72 // Check RemainingDevicePath validation\r
73 //\r
74 if (RemainingDevicePath != NULL) {\r
75 //\r
76 // Check if RemainingDevicePath is the End of Device Path Node, \r
77 // if yes, go on checking other conditions\r
78 //\r
79 if (!IsDevicePathEnd (RemainingDevicePath)) {\r
80 //\r
81 // If RemainingDevicePath isn't the End of Device Path Node,\r
82 // check its validation\r
83 //\r
84 Node = (EFI_DEV_PATH *) RemainingDevicePath;\r
85 if (Node->DevPath.Type != MEDIA_DEVICE_PATH ||\r
86 Node->DevPath.SubType != MEDIA_HARDDRIVE_DP ||\r
87 DevicePathNodeLength (&Node->DevPath) != sizeof (HARDDRIVE_DEVICE_PATH)) {\r
88 return EFI_UNSUPPORTED;\r
89 }\r
90 }\r
91 }\r
92\r
93 //\r
94 // Open the IO Abstraction(s) needed to perform the supported test\r
95 //\r
96 Status = gBS->OpenProtocol (\r
97 ControllerHandle,\r
98 &gEfiDiskIoProtocolGuid,\r
99 (VOID **) &DiskIo,\r
100 This->DriverBindingHandle,\r
101 ControllerHandle,\r
102 EFI_OPEN_PROTOCOL_BY_DRIVER\r
103 );\r
104 if (Status == EFI_ALREADY_STARTED) {\r
105 return EFI_SUCCESS;\r
106 }\r
107 if (EFI_ERROR (Status)) {\r
108 return Status;\r
109 }\r
110 //\r
111 // Close the I/O Abstraction(s) used to perform the supported test\r
112 //\r
113 gBS->CloseProtocol (\r
114 ControllerHandle,\r
115 &gEfiDiskIoProtocolGuid,\r
116 This->DriverBindingHandle,\r
117 ControllerHandle\r
118 );\r
119\r
120 //\r
121 // Open the EFI Device Path protocol needed to perform the supported test\r
122 //\r
123 Status = gBS->OpenProtocol (\r
124 ControllerHandle,\r
125 &gEfiDevicePathProtocolGuid,\r
126 (VOID **) &ParentDevicePath,\r
127 This->DriverBindingHandle,\r
128 ControllerHandle,\r
129 EFI_OPEN_PROTOCOL_BY_DRIVER\r
130 );\r
131 if (Status == EFI_ALREADY_STARTED) {\r
132 return EFI_SUCCESS;\r
133 }\r
134\r
135 if (EFI_ERROR (Status)) {\r
136 return Status;\r
137 }\r
138\r
139 //\r
140 // Close protocol, don't use device path protocol in the Support() function\r
141 //\r
142 gBS->CloseProtocol (\r
143 ControllerHandle,\r
144 &gEfiDevicePathProtocolGuid,\r
145 This->DriverBindingHandle,\r
146 ControllerHandle\r
147 );\r
148\r
149 //\r
150 // Open the IO Abstraction(s) needed to perform the supported test\r
151 //\r
152 Status = gBS->OpenProtocol (\r
153 ControllerHandle,\r
154 &gEfiBlockIoProtocolGuid,\r
155 NULL,\r
156 This->DriverBindingHandle,\r
157 ControllerHandle,\r
158 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
159 );\r
160 if (EFI_ERROR (Status)) {\r
161 return Status;\r
162 }\r
163 \r
164 Status = gBS->OpenProtocol (\r
165 ControllerHandle,\r
166 &gEfiBlockIo2ProtocolGuid,\r
167 NULL,\r
168 This->DriverBindingHandle,\r
169 ControllerHandle,\r
170 EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
171 );\r
172 if (EFI_ERROR (Status)) {\r
173 //\r
174 // According to UEFI Spec 2.3.1, if a driver is written for a disk device, \r
175 // then the EFI_BLOCK_IO_PROTOCOL and EFI_BLOCK_IO2_PROTOCOAL must be implemented.\r
176 // Currently, SCSI disk driver only produce the EFI_BLOCK_IO_PROTOCOL, it will\r
177 // not be updated until the non blocking SCSI Pass Thru Protocol is provided.\r
178 // If there is no EFI_BLOCK_IO2_PROTOCOL, skip here.\r
179 // \r
180 } \r
181 return EFI_SUCCESS; \r
182}\r
183\r
184/**\r
185 Start this driver on ControllerHandle by opening a Block IO or a Block IO2\r
186 or both, and Disk IO protocol, reading Device Path, and creating a child\r
187 handle with a Disk IO and device path protocol.\r
188\r
189 @param[in] This Protocol instance pointer.\r
190 @param[in] ControllerHandle Handle of device to bind driver to\r
191 @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
192 device to start.\r
193\r
194 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
195 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
196 @retval other This driver does not support this device\r
197\r
198**/\r
199EFI_STATUS\r
200EFIAPI\r
201PartitionDriverBindingStart (\r
202 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
203 IN EFI_HANDLE ControllerHandle,\r
204 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
205 )\r
206{\r
207 EFI_STATUS Status;\r
208 EFI_STATUS OpenStatus;\r
209 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
210 EFI_BLOCK_IO2_PROTOCOL *BlockIo2;\r
211 EFI_DISK_IO_PROTOCOL *DiskIo;\r
212 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
213 PARTITION_DETECT_ROUTINE *Routine;\r
214 BOOLEAN MediaPresent;\r
215 EFI_TPL OldTpl;\r
216\r
217 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); \r
218 //\r
219 // Check RemainingDevicePath validation\r
220 //\r
221 if (RemainingDevicePath != NULL) {\r
222 //\r
223 // Check if RemainingDevicePath is the End of Device Path Node, \r
224 // if yes, return EFI_SUCCESS\r
225 //\r
226 if (IsDevicePathEnd (RemainingDevicePath)) {\r
227 Status = EFI_SUCCESS;\r
228 goto Exit;\r
229 }\r
230 }\r
231\r
232 //\r
233 // Try to open BlockIO and BlockIO2. If BlockIO would be opened, continue,\r
234 // otherwise, return error.\r
235 //\r
236 Status = gBS->OpenProtocol (\r
237 ControllerHandle,\r
238 &gEfiBlockIoProtocolGuid,\r
239 (VOID **) &BlockIo,\r
240 This->DriverBindingHandle,\r
241 ControllerHandle,\r
242 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
243 );\r
244 if (EFI_ERROR (Status)) {\r
245 goto Exit;\r
246 }\r
247\r
248 Status = gBS->OpenProtocol (\r
249 ControllerHandle,\r
250 &gEfiBlockIo2ProtocolGuid,\r
251 (VOID **) &BlockIo2,\r
252 This->DriverBindingHandle,\r
253 ControllerHandle,\r
254 EFI_OPEN_PROTOCOL_BY_DRIVER\r
255 );\r
256 if (EFI_ERROR (Status)) {\r
257 //\r
258 // According to UEFI Spec 2.3.1, if a driver is written for a disk device, \r
259 // then the EFI_BLOCK_IO_PROTOCOL and EFI_BLOCK_IO2_PROTOCOAL must be implemented.\r
260 // Currently, SCSI disk driver only produce the EFI_BLOCK_IO_PROTOCOL, it will\r
261 // not be updated until the non blocking SCSI Pass Thru Protocol is provided.\r
262 // If there is no EFI_BLOCK_IO2_PROTOCOL, skip here.\r
263 //\r
264 }\r
265\r
266 //\r
267 // Get the Device Path Protocol on ControllerHandle's handle.\r
268 //\r
269 Status = gBS->OpenProtocol (\r
270 ControllerHandle,\r
271 &gEfiDevicePathProtocolGuid,\r
272 (VOID **) &ParentDevicePath,\r
273 This->DriverBindingHandle,\r
274 ControllerHandle,\r
275 EFI_OPEN_PROTOCOL_BY_DRIVER\r
276 );\r
277 if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
278 goto Exit;\r
279 }\r
280\r
281 Status = gBS->OpenProtocol (\r
282 ControllerHandle,\r
283 &gEfiDiskIoProtocolGuid,\r
284 (VOID **) &DiskIo,\r
285 This->DriverBindingHandle,\r
286 ControllerHandle,\r
287 EFI_OPEN_PROTOCOL_BY_DRIVER\r
288 );\r
289 if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {\r
290 gBS->CloseProtocol (\r
291 ControllerHandle,\r
292 &gEfiDevicePathProtocolGuid,\r
293 This->DriverBindingHandle,\r
294 ControllerHandle\r
295 );\r
296 goto Exit;\r
297 }\r
298\r
299 OpenStatus = Status;\r
300\r
301 //\r
302 // Try to read blocks when there's media or it is removable physical partition.\r
303 //\r
304 Status = EFI_UNSUPPORTED;\r
305 MediaPresent = BlockIo->Media->MediaPresent;\r
306 if (BlockIo->Media->MediaPresent ||\r
307 (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition)) {\r
308 //\r
309 // Try for GPT, then El Torito, and then legacy MBR partition types. If the\r
310 // media supports a given partition type install child handles to represent\r
311 // the partitions described by the media.\r
312 //\r
313 Routine = &mPartitionDetectRoutineTable[0];\r
314 while (*Routine != NULL) {\r
315 Status = (*Routine) (\r
316 This,\r
317 ControllerHandle,\r
318 DiskIo,\r
319 BlockIo,\r
320 BlockIo2,\r
321 ParentDevicePath\r
322 );\r
323 if (!EFI_ERROR (Status) || Status == EFI_MEDIA_CHANGED || Status == EFI_NO_MEDIA) {\r
324 break;\r
325 }\r
326 Routine++;\r
327 }\r
328 }\r
329 //\r
330 // In the case that the driver is already started (OpenStatus == EFI_ALREADY_STARTED),\r
331 // the DevicePathProtocol and the DiskIoProtocol are not actually opened by the\r
332 // driver. So don't try to close them. Otherwise, we will break the dependency\r
333 // between the controller and the driver set up before.\r
334 //\r
335 // In the case that when the media changes on a device it will Reinstall the \r
336 // BlockIo interaface. This will cause a call to our Stop(), and a subsequent\r
337 // reentrant call to our Start() successfully. We should leave the device open\r
338 // when this happen. The "media change" case includes either the status is\r
339 // EFI_MEDIA_CHANGED or it is a "media" to "no media" change. \r
340 // \r
341 if (EFI_ERROR (Status) &&\r
342 !EFI_ERROR (OpenStatus) &&\r
343 Status != EFI_MEDIA_CHANGED &&\r
344 !(MediaPresent && Status == EFI_NO_MEDIA)) {\r
345 gBS->CloseProtocol (\r
346 ControllerHandle,\r
347 &gEfiDiskIoProtocolGuid,\r
348 This->DriverBindingHandle,\r
349 ControllerHandle\r
350 );\r
351 //\r
352 // Close Parent BlockIO2 if has.\r
353 // \r
354 gBS->CloseProtocol (\r
355 ControllerHandle,\r
356 &gEfiBlockIo2ProtocolGuid,\r
357 This->DriverBindingHandle,\r
358 ControllerHandle\r
359 );\r
360\r
361 gBS->CloseProtocol (\r
362 ControllerHandle,\r
363 &gEfiDevicePathProtocolGuid,\r
364 This->DriverBindingHandle,\r
365 ControllerHandle\r
366 );\r
367 }\r
368\r
369Exit:\r
370 gBS->RestoreTPL (OldTpl);\r
371 return Status;\r
372}\r
373\r
374/**\r
375 Stop this driver on ControllerHandle. Support stopping any child handles\r
376 created by this driver.\r
377\r
378 @param This Protocol instance pointer.\r
379 @param ControllerHandle Handle of device to stop driver on\r
380 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
381 children is zero stop the entire bus driver.\r
382 @param ChildHandleBuffer List of Child Handles to Stop.\r
383\r
384 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
385 @retval other This driver was not removed from this device\r
386\r
387**/\r
388EFI_STATUS\r
389EFIAPI\r
390PartitionDriverBindingStop (\r
391 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
392 IN EFI_HANDLE ControllerHandle,\r
393 IN UINTN NumberOfChildren,\r
394 IN EFI_HANDLE *ChildHandleBuffer\r
395 )\r
396{\r
397 EFI_STATUS Status;\r
398 UINTN Index;\r
399 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
400 EFI_BLOCK_IO2_PROTOCOL *BlockIo2;\r
401 BOOLEAN AllChildrenStopped;\r
402 PARTITION_PRIVATE_DATA *Private;\r
403 EFI_DISK_IO_PROTOCOL *DiskIo;\r
404\r
405 BlockIo = NULL;\r
406 BlockIo2 = NULL;\r
407 Private = NULL;\r
408\r
409 if (NumberOfChildren == 0) {\r
410 //\r
411 // Close the bus driver\r
412 //\r
413 gBS->CloseProtocol (\r
414 ControllerHandle,\r
415 &gEfiDiskIoProtocolGuid,\r
416 This->DriverBindingHandle,\r
417 ControllerHandle\r
418 );\r
419 //\r
420 // Close Parent BlockIO2 if has.\r
421 // \r
422 gBS->CloseProtocol (\r
423 ControllerHandle,\r
424 &gEfiBlockIo2ProtocolGuid,\r
425 This->DriverBindingHandle,\r
426 ControllerHandle\r
427 );\r
428\r
429 gBS->CloseProtocol (\r
430 ControllerHandle,\r
431 &gEfiDevicePathProtocolGuid,\r
432 This->DriverBindingHandle,\r
433 ControllerHandle\r
434 );\r
435 return EFI_SUCCESS;\r
436 }\r
437\r
438 AllChildrenStopped = TRUE;\r
439 for (Index = 0; Index < NumberOfChildren; Index++) {\r
440 gBS->OpenProtocol (\r
441 ChildHandleBuffer[Index],\r
442 &gEfiBlockIoProtocolGuid,\r
443 (VOID **) &BlockIo,\r
444 This->DriverBindingHandle,\r
445 ControllerHandle,\r
446 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
447 );\r
448 //\r
449 // Try to locate BlockIo2.\r
450 //\r
451 gBS->OpenProtocol (\r
452 ChildHandleBuffer[Index],\r
453 &gEfiBlockIo2ProtocolGuid,\r
454 (VOID **) &BlockIo2,\r
455 This->DriverBindingHandle,\r
456 ControllerHandle,\r
457 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
458 ); \r
459\r
460\r
461 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);\r
462\r
463 Status = gBS->CloseProtocol (\r
464 ControllerHandle,\r
465 &gEfiDiskIoProtocolGuid,\r
466 This->DriverBindingHandle,\r
467 ChildHandleBuffer[Index]\r
468 );\r
469 //\r
470 // All Software protocols have be freed from the handle so remove it.\r
471 // Remove the BlockIo Protocol if has.\r
472 // Remove the BlockIo2 Protocol if has.\r
473 //\r
474 if (BlockIo2 != NULL) {\r
475 BlockIo->FlushBlocks (BlockIo);\r
476 BlockIo2->FlushBlocksEx (BlockIo2, NULL);\r
477 Status = gBS->UninstallMultipleProtocolInterfaces (\r
478 ChildHandleBuffer[Index],\r
479 &gEfiDevicePathProtocolGuid,\r
480 Private->DevicePath,\r
481 &gEfiBlockIoProtocolGuid,\r
482 &Private->BlockIo,\r
483 &gEfiBlockIo2ProtocolGuid,\r
484 &Private->BlockIo2,\r
485 Private->EspGuid,\r
486 NULL,\r
487 NULL\r
488 );\r
489 } else {\r
490 BlockIo->FlushBlocks (BlockIo);\r
491 Status = gBS->UninstallMultipleProtocolInterfaces (\r
492 ChildHandleBuffer[Index],\r
493 &gEfiDevicePathProtocolGuid,\r
494 Private->DevicePath,\r
495 &gEfiBlockIoProtocolGuid,\r
496 &Private->BlockIo,\r
497 Private->EspGuid,\r
498 NULL,\r
499 NULL\r
500 );\r
501 }\r
502\r
503 if (EFI_ERROR (Status)) {\r
504 gBS->OpenProtocol (\r
505 ControllerHandle,\r
506 &gEfiDiskIoProtocolGuid,\r
507 (VOID **) &DiskIo,\r
508 This->DriverBindingHandle,\r
509 ChildHandleBuffer[Index],\r
510 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
511 );\r
512 } else {\r
513 FreePool (Private->DevicePath);\r
514 FreePool (Private);\r
515 }\r
516\r
517 if (EFI_ERROR (Status)) {\r
518 AllChildrenStopped = FALSE;\r
519 }\r
520 }\r
521\r
522 if (!AllChildrenStopped) {\r
523 return EFI_DEVICE_ERROR;\r
524 }\r
525\r
526 return EFI_SUCCESS;\r
527}\r
528\r
529\r
530/**\r
531 Reset the Block Device.\r
532\r
533 @param This Protocol instance pointer.\r
534 @param ExtendedVerification Driver may perform diagnostics on reset.\r
535\r
536 @retval EFI_SUCCESS The device was reset.\r
537 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
538 not be reset.\r
539\r
540**/\r
541EFI_STATUS\r
542EFIAPI\r
543PartitionReset (\r
544 IN EFI_BLOCK_IO_PROTOCOL *This,\r
545 IN BOOLEAN ExtendedVerification\r
546 )\r
547{\r
548 PARTITION_PRIVATE_DATA *Private;\r
549\r
550 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);\r
551\r
552 return Private->ParentBlockIo->Reset (\r
553 Private->ParentBlockIo,\r
554 ExtendedVerification\r
555 );\r
556}\r
557\r
558/**\r
559 Probe the media status and return EFI_NO_MEDIA or EFI_MEDIA_CHANGED\r
560 for no media or media change case. Otherwise DefaultStatus is returned.\r
561\r
562 @param DiskIo Pointer to the DiskIo instance.\r
563 @param MediaId Id of the media, changes every time the media is replaced.\r
564 @param DefaultStatus The default status to return when it's not the no media\r
565 or media change case.\r
566\r
567 @retval EFI_NO_MEDIA There is no media.\r
568 @retval EFI_MEDIA_CHANGED The media was changed.\r
569 @retval others The default status to return.\r
570**/\r
571EFI_STATUS\r
572ProbeMediaStatus (\r
573 IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
574 IN UINT32 MediaId,\r
575 IN EFI_STATUS DefaultStatus\r
576 )\r
577{\r
578 EFI_STATUS Status;\r
579\r
580 //\r
581 // Read 1 byte from offset 0 but passing NULL as buffer pointer\r
582 //\r
583 Status = DiskIo->ReadDisk (DiskIo, MediaId, 0, 1, NULL);\r
584 if ((Status == EFI_NO_MEDIA) || (Status == EFI_MEDIA_CHANGED)) {\r
585 return Status;\r
586 }\r
587 return DefaultStatus;\r
588}\r
589\r
590/**\r
591 Read by using the Disk IO protocol on the parent device. Lba addresses\r
592 must be converted to byte offsets.\r
593\r
594 @param This Protocol instance pointer.\r
595 @param MediaId Id of the media, changes every time the media is replaced.\r
596 @param Lba The starting Logical Block Address to read from\r
597 @param BufferSize Size of Buffer, must be a multiple of device block size.\r
598 @param Buffer Buffer containing read data\r
599\r
600 @retval EFI_SUCCESS The data was read correctly from the device.\r
601 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
602 @retval EFI_NO_MEDIA There is no media in the device.\r
603 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.\r
604 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
605 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
606 valid for the device.\r
607\r
608**/\r
609EFI_STATUS\r
610EFIAPI\r
611PartitionReadBlocks (\r
612 IN EFI_BLOCK_IO_PROTOCOL *This,\r
613 IN UINT32 MediaId,\r
614 IN EFI_LBA Lba,\r
615 IN UINTN BufferSize,\r
616 OUT VOID *Buffer\r
617 )\r
618{\r
619 PARTITION_PRIVATE_DATA *Private;\r
620 UINT64 Offset;\r
621\r
622 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);\r
623\r
624 if (BufferSize % Private->BlockSize != 0) {\r
625 return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_BAD_BUFFER_SIZE);\r
626 }\r
627\r
628 Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;\r
629 if (Offset + BufferSize > Private->End) {\r
630 return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_INVALID_PARAMETER);\r
631 }\r
632 //\r
633 // Because some kinds of partition have different block size from their parent\r
634 // device, we call the Disk IO protocol on the parent device, not the Block IO\r
635 // protocol\r
636 //\r
637 return Private->DiskIo->ReadDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);\r
638}\r
639\r
640/**\r
641 Write by using the Disk IO protocol on the parent device. Lba addresses\r
642 must be converted to byte offsets.\r
643\r
644 @param[in] This Protocol instance pointer.\r
645 @param[in] MediaId Id of the media, changes every time the media is replaced.\r
646 @param[in] Lba The starting Logical Block Address to read from\r
647 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
648 @param[in] Buffer Buffer containing data to be written to device.\r
649\r
650 @retval EFI_SUCCESS The data was written correctly to the device.\r
651 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
652 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
653 @retval EFI_NO_MEDIA There is no media in the device.\r
654 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
655 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
656 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not\r
657 valid for the device.\r
658\r
659**/\r
660EFI_STATUS\r
661EFIAPI\r
662PartitionWriteBlocks (\r
663 IN EFI_BLOCK_IO_PROTOCOL *This,\r
664 IN UINT32 MediaId,\r
665 IN EFI_LBA Lba,\r
666 IN UINTN BufferSize,\r
667 IN VOID *Buffer\r
668 )\r
669{\r
670 PARTITION_PRIVATE_DATA *Private;\r
671 UINT64 Offset;\r
672\r
673 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);\r
674\r
675 if (BufferSize % Private->BlockSize != 0) {\r
676 return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_BAD_BUFFER_SIZE);\r
677 }\r
678\r
679 Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;\r
680 if (Offset + BufferSize > Private->End) {\r
681 return ProbeMediaStatus (Private->DiskIo, MediaId, EFI_INVALID_PARAMETER);\r
682 }\r
683 //\r
684 // Because some kinds of partition have different block size from their parent\r
685 // device, we call the Disk IO protocol on the parent device, not the Block IO\r
686 // protocol\r
687 //\r
688 return Private->DiskIo->WriteDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);\r
689}\r
690\r
691\r
692/**\r
693 Flush the parent Block Device.\r
694\r
695 @param This Protocol instance pointer.\r
696\r
697 @retval EFI_SUCCESS All outstanding data was written to the device\r
698 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r
699 @retval EFI_NO_MEDIA There is no media in the device.\r
700\r
701**/\r
702EFI_STATUS\r
703EFIAPI\r
704PartitionFlushBlocks (\r
705 IN EFI_BLOCK_IO_PROTOCOL *This\r
706 )\r
707{\r
708 PARTITION_PRIVATE_DATA *Private;\r
709\r
710 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);\r
711\r
712 return Private->ParentBlockIo->FlushBlocks (Private->ParentBlockIo);\r
713}\r
714\r
715/**\r
716 Reset the Block Device throught Block I/O2 protocol.\r
717\r
718 @param This Protocol instance pointer.\r
719 @param ExtendedVerification Driver may perform diagnostics on reset.\r
720\r
721 @retval EFI_SUCCESS The device was reset.\r
722 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
723 not be reset.\r
724\r
725**/\r
726EFI_STATUS\r
727EFIAPI\r
728PartitionResetEx (\r
729 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
730 IN BOOLEAN ExtendedVerification\r
731 )\r
732{\r
733 PARTITION_PRIVATE_DATA *Private;\r
734\r
735 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);\r
736\r
737 return Private->ParentBlockIo2->Reset (\r
738 Private->ParentBlockIo2,\r
739 ExtendedVerification\r
740 );\r
741}\r
742\r
743/**\r
744 Read BufferSize bytes from Lba into Buffer.\r
745 \r
746 This function reads the requested number of blocks from the device. All the\r
747 blocks are read, or an error is returned.\r
748 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
749 non-blocking I/O is being used, the Event associated with this request will\r
750 not be signaled.\r
751\r
752 @param[in] This Indicates a pointer to the calling context.\r
753 @param[in] MediaId Id of the media, changes every time the media is \r
754 replaced.\r
755 @param[in] Lba The starting Logical Block Address to read from.\r
756 @param[in, out] Token A pointer to the token associated with the transaction.\r
757 @param[in] BufferSize Size of Buffer, must be a multiple of device block size. \r
758 @param[out] Buffer A pointer to the destination buffer for the data. The \r
759 caller is responsible for either having implicit or \r
760 explicit ownership of the buffer.\r
761\r
762 @retval EFI_SUCCESS The read request was queued if Token->Event is\r
763 not NULL.The data was read correctly from the\r
764 device if the Token->Event is NULL.\r
765 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
766 the read.\r
767 @retval EFI_NO_MEDIA There is no media in the device.\r
768 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
769 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
770 intrinsic block size of the device.\r
771 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
772 or the buffer is not on proper alignment.\r
773 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
774 of resources.\r
775**/\r
776EFI_STATUS\r
777EFIAPI\r
778PartitionReadBlocksEx (\r
779 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
780 IN UINT32 MediaId,\r
781 IN EFI_LBA Lba,\r
782 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
783 IN UINTN BufferSize,\r
784 OUT VOID *Buffer\r
785 )\r
786{\r
787 PARTITION_PRIVATE_DATA *Private;\r
788 UINT64 Offset;\r
789 UINT32 UnderRun;\r
790\r
791 if (Token == NULL) {\r
792 return EFI_INVALID_PARAMETER;\r
793 }\r
794\r
795 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);\r
796 if (BufferSize % Private->BlockSize != 0) {\r
797 return EFI_BAD_BUFFER_SIZE;\r
798 }\r
799\r
800 Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;\r
801 if (Offset + BufferSize > Private->End) {\r
802 return EFI_INVALID_PARAMETER;\r
803 }\r
804\r
805 //\r
806 // Since the BlockIO2 call Parent BlockIO2 directly, so here the offset must\r
807 // be multiple of BlockSize. If the Spec will be updated the DiskIO to support\r
808 // BlockIO2, this limitation will be removed and call DiskIO here.\r
809 //\r
810 Lba = DivU64x32Remainder (Offset, Private->BlockSize, &UnderRun);\r
811 if (UnderRun != 0) {\r
812 return EFI_UNSUPPORTED;\r
813 }\r
814\r
815 //\r
816 // Because some partitions have different block size from their parent\r
817 // device, in that case the Block I/O2 couldn't be called.\r
818 //\r
819 if (Private->BlockSize != Private->ParentBlockIo->Media->BlockSize) {\r
820 return EFI_UNSUPPORTED;\r
821 }\r
822\r
823 return Private->ParentBlockIo2->ReadBlocksEx (Private->ParentBlockIo2, MediaId, Lba, Token, BufferSize, Buffer);\r
824}\r
825\r
826/**\r
827 Write BufferSize bytes from Lba into Buffer.\r
828\r
829 This function writes the requested number of blocks to the device. All blocks\r
830 are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
831 EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
832 being used, the Event associated with this request will not be signaled.\r
833\r
834 @param[in] This Indicates a pointer to the calling context.\r
835 @param[in] MediaId The media ID that the write request is for.\r
836 @param[in] Lba The starting logical block address to be written. The\r
837 caller is responsible for writing to only legitimate\r
838 locations.\r
839 @param[in, out] Token A pointer to the token associated with the transaction.\r
840 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
841 @param[in] Buffer A pointer to the source buffer for the data.\r
842\r
843 @retval EFI_SUCCESS The write request was queued if Event is not NULL.\r
844 The data was written correctly to the device if\r
845 the Event is NULL.\r
846 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
847 @retval EFI_NO_MEDIA There is no media in the device.\r
848 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
849 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
850 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
851 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
852 or the buffer is not on proper alignment.\r
853 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
854 of resources.\r
855\r
856**/\r
857EFI_STATUS\r
858EFIAPI\r
859PartitionWriteBlocksEx (\r
860 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
861 IN UINT32 MediaId,\r
862 IN EFI_LBA Lba,\r
863 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
864 IN UINTN BufferSize,\r
865 IN VOID *Buffer\r
866 )\r
867{\r
868 PARTITION_PRIVATE_DATA *Private;\r
869 UINT64 Offset;\r
870 UINT32 UnderRun;\r
871\r
872 if (Token == NULL) {\r
873 return EFI_INVALID_PARAMETER;\r
874 }\r
875\r
876 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);\r
877 if (BufferSize % Private->BlockSize != 0) {\r
878 return EFI_BAD_BUFFER_SIZE;\r
879 }\r
880\r
881 Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;\r
882 if (Offset + BufferSize > Private->End) {\r
883 return EFI_INVALID_PARAMETER;\r
884 }\r
885\r
886 //\r
887 // Since the BlockIO2 call Parent BlockIO2 directly, so here the offset must\r
888 // be multiple of BlockSize. If the Spec will be updated the DiskIO to support\r
889 // BlockIO2, this limitation will be removed and call DiskIO here.\r
890 //\r
891 Lba = DivU64x32Remainder (Offset, Private->BlockSize, &UnderRun);\r
892 if (UnderRun != 0) {\r
893 return EFI_UNSUPPORTED;\r
894 }\r
895\r
896 //\r
897 // Because some kinds of partition have different block size from their parent,\r
898 // in that case it couldn't call parent Block I/O2. \r
899 //\r
900 if (Private->BlockSize != Private->ParentBlockIo->Media->BlockSize) {\r
901 return EFI_UNSUPPORTED;\r
902 }\r
903\r
904 return Private->ParentBlockIo2->WriteBlocksEx (Private->ParentBlockIo2, MediaId, Lba, Token, BufferSize, Buffer);\r
905}\r
906\r
907/**\r
908 Flush the Block Device.\r
909 \r
910 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
911 is returned and non-blocking I/O is being used, the Event associated with\r
912 this request will not be signaled. \r
913\r
914 @param[in] This Indicates a pointer to the calling context.\r
915 @param[in, out] Token A pointer to the token associated with the transaction\r
916\r
917 @retval EFI_SUCCESS The flush request was queued if Event is not NULL.\r
918 All outstanding data was written correctly to the\r
919 device if the Event is NULL.\r
920 @retval EFI_DEVICE_ERROR The device reported an error while writting back\r
921 the data.\r
922 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
923 @retval EFI_NO_MEDIA There is no media in the device.\r
924 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
925 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
926 of resources.\r
927\r
928**/\r
929EFI_STATUS\r
930EFIAPI\r
931PartitionFlushBlocksEx (\r
932 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
933 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
934 )\r
935{\r
936 PARTITION_PRIVATE_DATA *Private;\r
937\r
938 Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (This);\r
939\r
940 //\r
941 // Because some kinds of partition have different block size from their parent,\r
942 // in that case it couldn't call parent Block I/O2. \r
943 //\r
944 if (Private->BlockSize != Private->ParentBlockIo->Media->BlockSize) {\r
945 return EFI_UNSUPPORTED;\r
946 }\r
947\r
948 return Private->ParentBlockIo2->FlushBlocksEx (Private->ParentBlockIo2, Token);\r
949}\r
950\r
951\r
952/**\r
953 Create a child handle for a logical block device that represents the\r
954 bytes Start to End of the Parent Block IO device.\r
955\r
956 @param[in] This Protocol instance pointer.\r
957 @param[in] ParentHandle Parent Handle for new child.\r
958 @param[in] ParentDiskIo Parent DiskIo interface.\r
959 @param[in] ParentBlockIo Parent BlockIo interface.\r
960 @param[in] ParentBlockIo2 Parent BlockIo2 interface.\r
961 @param[in] ParentDevicePath Parent Device Path.\r
962 @param[in] DevicePathNode Child Device Path node.\r
963 @param[in] Start Start Block.\r
964 @param[in] End End Block.\r
965 @param[in] BlockSize Child block size.\r
966 @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle.\r
967\r
968 @retval EFI_SUCCESS A child handle was added.\r
969 @retval other A child handle was not added.\r
970\r
971**/\r
972EFI_STATUS\r
973PartitionInstallChildHandle (\r
974 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
975 IN EFI_HANDLE ParentHandle,\r
976 IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,\r
977 IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,\r
978 IN EFI_BLOCK_IO2_PROTOCOL *ParentBlockIo2,\r
979 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
980 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,\r
981 IN EFI_LBA Start,\r
982 IN EFI_LBA End,\r
983 IN UINT32 BlockSize,\r
984 IN BOOLEAN InstallEspGuid\r
985 )\r
986{\r
987 EFI_STATUS Status;\r
988 PARTITION_PRIVATE_DATA *Private;\r
989\r
990 Status = EFI_SUCCESS;\r
991 Private = AllocateZeroPool (sizeof (PARTITION_PRIVATE_DATA));\r
992 if (Private == NULL) {\r
993 return EFI_OUT_OF_RESOURCES;\r
994 }\r
995\r
996 Private->Signature = PARTITION_PRIVATE_DATA_SIGNATURE;\r
997\r
998 Private->Start = MultU64x32 (Start, ParentBlockIo->Media->BlockSize);\r
999 Private->End = MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);\r
1000\r
1001 Private->BlockSize = BlockSize;\r
1002 Private->ParentBlockIo = ParentBlockIo;\r
1003 Private->ParentBlockIo2 = ParentBlockIo2;\r
1004 Private->DiskIo = ParentDiskIo;\r
1005\r
1006 //\r
1007 // Set the BlockIO into Private Data.\r
1008 //\r
1009 Private->BlockIo.Revision = ParentBlockIo->Revision;\r
1010 \r
1011 Private->BlockIo.Media = &Private->Media;\r
1012 CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));\r
1013\r
1014 Private->BlockIo.Reset = PartitionReset;\r
1015 Private->BlockIo.ReadBlocks = PartitionReadBlocks;\r
1016 Private->BlockIo.WriteBlocks = PartitionWriteBlocks;\r
1017 Private->BlockIo.FlushBlocks = PartitionFlushBlocks;\r
1018\r
1019 //\r
1020 // Set the BlockIO2 into Private Data.\r
1021 //\r
1022 if (Private->ParentBlockIo2 != NULL) {\r
1023 Private->BlockIo2.Media = &Private->Media2;\r
1024 CopyMem (Private->BlockIo2.Media, ParentBlockIo2->Media, sizeof (EFI_BLOCK_IO_MEDIA));\r
1025\r
1026 Private->BlockIo2.Reset = PartitionResetEx;\r
1027 Private->BlockIo2.ReadBlocksEx = PartitionReadBlocksEx;\r
1028 Private->BlockIo2.WriteBlocksEx = PartitionWriteBlocksEx;\r
1029 Private->BlockIo2.FlushBlocksEx = PartitionFlushBlocksEx; \r
1030 }\r
1031\r
1032 Private->Media.IoAlign = 0;\r
1033 Private->Media.LogicalPartition = TRUE;\r
1034 Private->Media.LastBlock = DivU64x32 (\r
1035 MultU64x32 (\r
1036 End - Start + 1,\r
1037 ParentBlockIo->Media->BlockSize\r
1038 ),\r
1039 BlockSize\r
1040 ) - 1;\r
1041\r
1042 Private->Media.BlockSize = (UINT32) BlockSize;\r
1043\r
1044 //\r
1045 // For BlockIO2, it should keep the same alignment with the parent BlockIO2's.\r
1046 //\r
1047 Private->Media2.LogicalPartition = TRUE;\r
1048 Private->Media2.LastBlock = Private->Media.LastBlock;\r
1049 Private->Media2.BlockSize = (UINT32) BlockSize;\r
1050\r
1051 //\r
1052 // Per UEFI Spec, LowestAlignedLba, LogicalBlocksPerPhysicalBlock and OptimalTransferLengthGranularity must be 0\r
1053 // for logical partitions.\r
1054 //\r
1055 if (Private->BlockIo.Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION2) {\r
1056 Private->Media.LowestAlignedLba = 0;\r
1057 Private->Media.LogicalBlocksPerPhysicalBlock = 0;\r
1058 Private->Media2.LowestAlignedLba = 0;\r
1059 Private->Media2.LogicalBlocksPerPhysicalBlock = 0;\r
1060 if (Private->BlockIo.Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION3) {\r
1061 Private->Media.OptimalTransferLengthGranularity = 0;\r
1062 Private->Media2.OptimalTransferLengthGranularity = 0;\r
1063 }\r
1064 }\r
1065\r
1066 Private->DevicePath = AppendDevicePathNode (ParentDevicePath, DevicePathNode);\r
1067\r
1068 if (Private->DevicePath == NULL) {\r
1069 FreePool (Private);\r
1070 return EFI_OUT_OF_RESOURCES;\r
1071 }\r
1072\r
1073 if (InstallEspGuid) {\r
1074 Private->EspGuid = &gEfiPartTypeSystemPartGuid;\r
1075 } else {\r
1076 //\r
1077 // If NULL InstallMultipleProtocolInterfaces will ignore it.\r
1078 //\r
1079 Private->EspGuid = NULL;\r
1080 }\r
1081\r
1082 //\r
1083 // Create the new handle. \r
1084 // BlockIO2 will be installed on the condition that the blocksize of parent BlockIO \r
1085 // is same with the child BlockIO's. Instead of calling the DiskIO, the child BlockIO2 \r
1086 // directly call the parent BlockIO and doesn't handle the different block size issue.\r
1087 // If SPEC will update the DiskIO to support the Non-Blocking model, the BlockIO2 will call\r
1088 // DiskIO to handle the blocksize unequal issue and the limitation will be remove from\r
1089 // here.\r
1090 //\r
1091 Private->Handle = NULL;\r
1092 if ((Private->ParentBlockIo2 != NULL) &&\r
1093 (Private->ParentBlockIo2->Media->BlockSize == BlockSize)\r
1094 ) {\r
1095 Status = gBS->InstallMultipleProtocolInterfaces (\r
1096 &Private->Handle,\r
1097 &gEfiDevicePathProtocolGuid,\r
1098 Private->DevicePath,\r
1099 &gEfiBlockIoProtocolGuid,\r
1100 &Private->BlockIo,\r
1101 &gEfiBlockIo2ProtocolGuid,\r
1102 &Private->BlockIo2,\r
1103 Private->EspGuid,\r
1104 NULL,\r
1105 NULL\r
1106 );\r
1107 } else { \r
1108 Status = gBS->InstallMultipleProtocolInterfaces (\r
1109 &Private->Handle,\r
1110 &gEfiDevicePathProtocolGuid,\r
1111 Private->DevicePath,\r
1112 &gEfiBlockIoProtocolGuid,\r
1113 &Private->BlockIo,\r
1114 Private->EspGuid,\r
1115 NULL,\r
1116 NULL\r
1117 );\r
1118 }\r
1119\r
1120 if (!EFI_ERROR (Status)) {\r
1121 //\r
1122 // Open the Parent Handle for the child\r
1123 //\r
1124 Status = gBS->OpenProtocol (\r
1125 ParentHandle,\r
1126 &gEfiDiskIoProtocolGuid,\r
1127 (VOID **) &ParentDiskIo,\r
1128 This->DriverBindingHandle,\r
1129 Private->Handle,\r
1130 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
1131 );\r
1132 } else {\r
1133 FreePool (Private->DevicePath);\r
1134 FreePool (Private);\r
1135 }\r
1136\r
1137 return Status;\r
1138}\r
1139\r
1140\r
1141/**\r
1142 The user Entry Point for module Partition. The user code starts with this function.\r
1143\r
1144 @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
1145 @param[in] SystemTable A pointer to the EFI System Table.\r
1146 \r
1147 @retval EFI_SUCCESS The entry point is executed successfully.\r
1148 @retval other Some error occurs when executing this entry point.\r
1149\r
1150**/\r
1151EFI_STATUS\r
1152EFIAPI\r
1153InitializePartition (\r
1154 IN EFI_HANDLE ImageHandle,\r
1155 IN EFI_SYSTEM_TABLE *SystemTable\r
1156 )\r
1157{\r
1158 EFI_STATUS Status;\r
1159\r
1160 //\r
1161 // Install driver model protocol(s).\r
1162 //\r
1163 Status = EfiLibInstallDriverBindingComponentName2 (\r
1164 ImageHandle,\r
1165 SystemTable,\r
1166 &gPartitionDriverBinding,\r
1167 ImageHandle,\r
1168 &gPartitionComponentName,\r
1169 &gPartitionComponentName2\r
1170 );\r
1171 ASSERT_EFI_ERROR (Status);\r
1172\r
1173\r
1174 return Status;\r
1175}\r
1176\r