]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
1. updated "the Bus Driver that creates all of its child handles on the first call...
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Partition.c
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 - 2009, 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
19 #include "Partition.h"
20
21 //
22 // Partition Driver Global Variables.
23 //
24 EFI_DRIVER_BINDING_PROTOCOL gPartitionDriverBinding = {
25 PartitionDriverBindingSupported,
26 PartitionDriverBindingStart,
27 PartitionDriverBindingStop,
28 0xa,
29 NULL,
30 NULL
31 };
32
33 //
34 // Prioritized function list to detect partition table.
35 //
36 PARTITION_DETECT_ROUTINE mPartitionDetectRoutineTable[] = {
37 PartitionInstallGptChildHandles,
38 PartitionInstallElToritoChildHandles,
39 PartitionInstallMbrChildHandles,
40 NULL
41 };
42
43
44
45 /**
46 Test to see if this driver supports ControllerHandle. Any ControllerHandle
47 than contains a BlockIo and DiskIo protocol can be supported.
48
49 @param This Protocol instance pointer.
50 @param ControllerHandle Handle of device to test
51 @param RemainingDevicePath Optional parameter use to pick a specific child
52 device to start.
53
54 @retval EFI_SUCCESS This driver supports this device
55 @retval EFI_ALREADY_STARTED This driver is already running on this device
56 @retval other This driver does not support this device
57
58 **/
59 EFI_STATUS
60 EFIAPI
61 PartitionDriverBindingSupported (
62 IN EFI_DRIVER_BINDING_PROTOCOL *This,
63 IN EFI_HANDLE ControllerHandle,
64 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
65 )
66 {
67 EFI_STATUS Status;
68 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
69 EFI_DISK_IO_PROTOCOL *DiskIo;
70 EFI_DEV_PATH *Node;
71
72 //
73 // Check RemainingDevicePath validation
74 //
75 if (RemainingDevicePath != NULL) {
76 //
77 // Check if RemainingDevicePath is the End of Device Path Node,
78 // if yes, go on checking other conditions
79 //
80 if (!IsDevicePathEnd (RemainingDevicePath)) {
81 //
82 // If RemainingDevicePath isn't the End of Device Path Node,
83 // check its validation
84 //
85 Node = (EFI_DEV_PATH *) RemainingDevicePath;
86 if (Node->DevPath.Type != MEDIA_DEVICE_PATH ||
87 Node->DevPath.SubType != MEDIA_HARDDRIVE_DP ||
88 DevicePathNodeLength (&Node->DevPath) != sizeof (HARDDRIVE_DEVICE_PATH)) {
89 return EFI_UNSUPPORTED;
90 }
91 }
92 }
93
94 //
95 // Open the IO Abstraction(s) needed to perform the supported test
96 //
97 Status = gBS->OpenProtocol (
98 ControllerHandle,
99 &gEfiDiskIoProtocolGuid,
100 (VOID **) &DiskIo,
101 This->DriverBindingHandle,
102 ControllerHandle,
103 EFI_OPEN_PROTOCOL_BY_DRIVER
104 );
105 if (Status == EFI_ALREADY_STARTED) {
106 return EFI_SUCCESS;
107 }
108
109 if (EFI_ERROR (Status)) {
110 return Status;
111 }
112 //
113 // Close the I/O Abstraction(s) used to perform the supported test
114 //
115 gBS->CloseProtocol (
116 ControllerHandle,
117 &gEfiDiskIoProtocolGuid,
118 This->DriverBindingHandle,
119 ControllerHandle
120 );
121
122 //
123 // Open the EFI Device Path protocol needed to perform the supported test
124 //
125 Status = gBS->OpenProtocol (
126 ControllerHandle,
127 &gEfiDevicePathProtocolGuid,
128 (VOID **) &ParentDevicePath,
129 This->DriverBindingHandle,
130 ControllerHandle,
131 EFI_OPEN_PROTOCOL_BY_DRIVER
132 );
133 if (Status == EFI_ALREADY_STARTED) {
134 return EFI_SUCCESS;
135 }
136
137 if (EFI_ERROR (Status)) {
138 return Status;
139 }
140
141 //
142 // Close protocol, don't use device path protocol in the Support() function
143 //
144 gBS->CloseProtocol (
145 ControllerHandle,
146 &gEfiDevicePathProtocolGuid,
147 This->DriverBindingHandle,
148 ControllerHandle
149 );
150
151 //
152 // Open the IO Abstraction(s) needed to perform the supported test
153 //
154 Status = gBS->OpenProtocol (
155 ControllerHandle,
156 &gEfiBlockIoProtocolGuid,
157 NULL,
158 This->DriverBindingHandle,
159 ControllerHandle,
160 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
161 );
162
163 return Status;
164 }
165
166
167 /**
168 Start this driver on ControllerHandle by opening a Block IO and Disk IO
169 protocol, reading Device Path, and creating a child handle with a
170 Disk IO and device path protocol.
171
172 @param This Protocol instance pointer.
173 @param ControllerHandle Handle of device to bind driver to
174 @param RemainingDevicePath Optional parameter use to pick a specific child
175 device to start.
176
177 @retval EFI_SUCCESS This driver is added to ControllerHandle
178 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
179 @retval other This driver does not support this device
180
181 **/
182 EFI_STATUS
183 EFIAPI
184 PartitionDriverBindingStart (
185 IN EFI_DRIVER_BINDING_PROTOCOL *This,
186 IN EFI_HANDLE ControllerHandle,
187 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
188 )
189 {
190 EFI_STATUS Status;
191 EFI_STATUS OpenStatus;
192 EFI_BLOCK_IO_PROTOCOL *BlockIo;
193 EFI_DISK_IO_PROTOCOL *DiskIo;
194 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
195 PARTITION_DETECT_ROUTINE *Routine;
196 BOOLEAN MediaPresent;
197
198 //
199 // Check RemainingDevicePath validation
200 //
201 if (RemainingDevicePath != NULL) {
202 //
203 // Check if RemainingDevicePath is the End of Device Path Node,
204 // if yes, return EFI_SUCCESS
205 //
206 if (IsDevicePathEnd (RemainingDevicePath)) {
207 return EFI_SUCCESS;
208 }
209 }
210
211 Status = gBS->OpenProtocol (
212 ControllerHandle,
213 &gEfiBlockIoProtocolGuid,
214 (VOID **) &BlockIo,
215 This->DriverBindingHandle,
216 ControllerHandle,
217 EFI_OPEN_PROTOCOL_GET_PROTOCOL
218 );
219 if (EFI_ERROR (Status)) {
220 return Status;
221 }
222 //
223 // Get the Device Path Protocol on ControllerHandle's handle
224 //
225 Status = gBS->OpenProtocol (
226 ControllerHandle,
227 &gEfiDevicePathProtocolGuid,
228 (VOID **) &ParentDevicePath,
229 This->DriverBindingHandle,
230 ControllerHandle,
231 EFI_OPEN_PROTOCOL_BY_DRIVER
232 );
233 if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
234 return Status;
235 }
236
237 Status = gBS->OpenProtocol (
238 ControllerHandle,
239 &gEfiDiskIoProtocolGuid,
240 (VOID **) &DiskIo,
241 This->DriverBindingHandle,
242 ControllerHandle,
243 EFI_OPEN_PROTOCOL_BY_DRIVER
244 );
245 if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
246 gBS->CloseProtocol (
247 ControllerHandle,
248 &gEfiDevicePathProtocolGuid,
249 This->DriverBindingHandle,
250 ControllerHandle
251 );
252 return Status;
253 }
254
255 OpenStatus = Status;
256
257 //
258 // Try to read blocks when there's media or it is removable physical partition.
259 //
260 Status = EFI_UNSUPPORTED;
261 MediaPresent = BlockIo->Media->MediaPresent;
262 if (BlockIo->Media->MediaPresent ||
263 (BlockIo->Media->RemovableMedia && !BlockIo->Media->LogicalPartition)) {
264 //
265 // Try for GPT, then El Torito, and then legacy MBR partition types. If the
266 // media supports a given partition type install child handles to represent
267 // the partitions described by the media.
268 //
269 Routine = &mPartitionDetectRoutineTable[0];
270 while (*Routine != NULL) {
271 Status = (*Routine) (
272 This,
273 ControllerHandle,
274 DiskIo,
275 BlockIo,
276 ParentDevicePath
277 );
278 if (!EFI_ERROR (Status) || Status == EFI_MEDIA_CHANGED || Status == EFI_NO_MEDIA) {
279 break;
280 }
281 Routine++;
282 }
283 }
284 //
285 // In the case that the driver is already started (OpenStatus == EFI_ALREADY_STARTED),
286 // the DevicePathProtocol and the DiskIoProtocol are not actually opened by the
287 // driver. So don't try to close them. Otherwise, we will break the dependency
288 // between the controller and the driver set up before.
289 //
290 // In the case that when the media changes on a device it will Reinstall the
291 // BlockIo interaface. This will cause a call to our Stop(), and a subsequent
292 // reentrant call to our Start() successfully. We should leave the device open
293 // when this happen. The "media change" case includes either the status is
294 // EFI_MEDIA_CHANGED or it is a "media" to "no media" change.
295 //
296 if (EFI_ERROR (Status) &&
297 !EFI_ERROR (OpenStatus) &&
298 Status != EFI_MEDIA_CHANGED &&
299 !(MediaPresent && Status == EFI_NO_MEDIA)) {
300 gBS->CloseProtocol (
301 ControllerHandle,
302 &gEfiDiskIoProtocolGuid,
303 This->DriverBindingHandle,
304 ControllerHandle
305 );
306
307 gBS->CloseProtocol (
308 ControllerHandle,
309 &gEfiDevicePathProtocolGuid,
310 This->DriverBindingHandle,
311 ControllerHandle
312 );
313 }
314
315 return Status;
316 }
317
318
319 /**
320 Stop this driver on ControllerHandle. Support stopping any child handles
321 created by this driver.
322
323 @param This Protocol instance pointer.
324 @param ControllerHandle Handle of device to stop driver on
325 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
326 children is zero stop the entire bus driver.
327 @param ChildHandleBuffer List of Child Handles to Stop.
328
329 @retval EFI_SUCCESS This driver is removed ControllerHandle
330 @retval other This driver was not removed from this device
331
332 **/
333 EFI_STATUS
334 EFIAPI
335 PartitionDriverBindingStop (
336 IN EFI_DRIVER_BINDING_PROTOCOL *This,
337 IN EFI_HANDLE ControllerHandle,
338 IN UINTN NumberOfChildren,
339 IN EFI_HANDLE *ChildHandleBuffer
340 )
341 {
342 EFI_STATUS Status;
343 UINTN Index;
344 EFI_BLOCK_IO_PROTOCOL *BlockIo;
345 BOOLEAN AllChildrenStopped;
346 PARTITION_PRIVATE_DATA *Private;
347 EFI_DISK_IO_PROTOCOL *DiskIo;
348
349 if (NumberOfChildren == 0) {
350 //
351 // Close the bus driver
352 //
353 gBS->CloseProtocol (
354 ControllerHandle,
355 &gEfiDiskIoProtocolGuid,
356 This->DriverBindingHandle,
357 ControllerHandle
358 );
359
360 gBS->CloseProtocol (
361 ControllerHandle,
362 &gEfiDevicePathProtocolGuid,
363 This->DriverBindingHandle,
364 ControllerHandle
365 );
366
367 return EFI_SUCCESS;
368 }
369
370 AllChildrenStopped = TRUE;
371 for (Index = 0; Index < NumberOfChildren; Index++) {
372 Status = gBS->OpenProtocol (
373 ChildHandleBuffer[Index],
374 &gEfiBlockIoProtocolGuid,
375 (VOID **) &BlockIo,
376 This->DriverBindingHandle,
377 ControllerHandle,
378 EFI_OPEN_PROTOCOL_GET_PROTOCOL
379 );
380 if (!EFI_ERROR (Status)) {
381
382 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
383
384 //
385 // All Software protocols have be freed from the handle so remove it.
386 //
387 BlockIo->FlushBlocks (BlockIo);
388
389 Status = gBS->CloseProtocol (
390 ControllerHandle,
391 &gEfiDiskIoProtocolGuid,
392 This->DriverBindingHandle,
393 ChildHandleBuffer[Index]
394 );
395
396 Status = gBS->UninstallMultipleProtocolInterfaces (
397 ChildHandleBuffer[Index],
398 &gEfiDevicePathProtocolGuid,
399 Private->DevicePath,
400 &gEfiBlockIoProtocolGuid,
401 &Private->BlockIo,
402 Private->EspGuid,
403 NULL,
404 NULL
405 );
406 if (EFI_ERROR (Status)) {
407 gBS->OpenProtocol (
408 ControllerHandle,
409 &gEfiDiskIoProtocolGuid,
410 (VOID **) &DiskIo,
411 This->DriverBindingHandle,
412 ChildHandleBuffer[Index],
413 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
414 );
415 } else {
416 FreePool (Private->DevicePath);
417 FreePool (Private);
418 }
419
420 }
421
422 if (EFI_ERROR (Status)) {
423 AllChildrenStopped = FALSE;
424 }
425 }
426
427 if (!AllChildrenStopped) {
428 return EFI_DEVICE_ERROR;
429 }
430
431 return EFI_SUCCESS;
432 }
433
434
435 /**
436 Reset the Block Device.
437
438 @param This Protocol instance pointer.
439 @param ExtendedVerification Driver may perform diagnostics on reset.
440
441 @retval EFI_SUCCESS The device was reset.
442 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
443 not be reset.
444
445 **/
446 EFI_STATUS
447 EFIAPI
448 PartitionReset (
449 IN EFI_BLOCK_IO_PROTOCOL *This,
450 IN BOOLEAN ExtendedVerification
451 )
452 {
453 PARTITION_PRIVATE_DATA *Private;
454
455 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
456
457 return Private->ParentBlockIo->Reset (
458 Private->ParentBlockIo,
459 ExtendedVerification
460 );
461 }
462
463
464 /**
465 Read by using the Disk IO protocol on the parent device. Lba addresses
466 must be converted to byte offsets.
467
468 @param This Protocol instance pointer.
469 @param MediaId Id of the media, changes every time the media is replaced.
470 @param Lba The starting Logical Block Address to read from
471 @param BufferSize Size of Buffer, must be a multiple of device block size.
472 @param Buffer Buffer containing read data
473
474 @retval EFI_SUCCESS The data was read correctly from the device.
475 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
476 @retval EFI_NO_MEDIA There is no media in the device.
477 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
478 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
479 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
480 valid for the device.
481
482 **/
483 EFI_STATUS
484 EFIAPI
485 PartitionReadBlocks (
486 IN EFI_BLOCK_IO_PROTOCOL *This,
487 IN UINT32 MediaId,
488 IN EFI_LBA Lba,
489 IN UINTN BufferSize,
490 OUT VOID *Buffer
491 )
492 {
493 PARTITION_PRIVATE_DATA *Private;
494 UINT64 Offset;
495
496 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
497
498 if (BufferSize % Private->BlockSize != 0) {
499 return EFI_BAD_BUFFER_SIZE;
500 }
501
502 Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;
503 if (Offset + BufferSize > Private->End) {
504 return EFI_INVALID_PARAMETER;
505 }
506 //
507 // Because some kinds of partition have different block size from their parent
508 // device, we call the Disk IO protocol on the parent device, not the Block IO
509 // protocol
510 //
511 return Private->DiskIo->ReadDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);
512 }
513
514 /**
515 Write by using the Disk IO protocol on the parent device. Lba addresses
516 must be converted to byte offsets.
517
518 @param This Protocol instance pointer.
519 @param MediaId Id of the media, changes every time the media is replaced.
520 @param Lba The starting Logical Block Address to read from
521 @param BufferSize Size of Buffer, must be a multiple of device block size.
522 @param Buffer Buffer containing read data
523
524 @retval EFI_SUCCESS The data was written correctly to the device.
525 @retval EFI_WRITE_PROTECTED The device can not be written to.
526 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
527 @retval EFI_NO_MEDIA There is no media in the device.
528 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
529 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
530 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not
531 valid for the device.
532
533 **/
534 EFI_STATUS
535 EFIAPI
536 PartitionWriteBlocks (
537 IN EFI_BLOCK_IO_PROTOCOL *This,
538 IN UINT32 MediaId,
539 IN EFI_LBA Lba,
540 IN UINTN BufferSize,
541 OUT VOID *Buffer
542 )
543 {
544 PARTITION_PRIVATE_DATA *Private;
545 UINT64 Offset;
546
547 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
548
549 if (BufferSize % Private->BlockSize != 0) {
550 return EFI_BAD_BUFFER_SIZE;
551 }
552
553 Offset = MultU64x32 (Lba, Private->BlockSize) + Private->Start;
554 if (Offset + BufferSize > Private->End) {
555 return EFI_INVALID_PARAMETER;
556 }
557 //
558 // Because some kinds of partition have different block size from their parent
559 // device, we call the Disk IO protocol on the parent device, not the Block IO
560 // protocol
561 //
562 return Private->DiskIo->WriteDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);
563 }
564
565
566 /**
567 Flush the parent Block Device.
568
569 @param This Protocol instance pointer.
570
571 @retval EFI_SUCCESS All outstanding data was written to the device
572 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
573 @retval EFI_NO_MEDIA There is no media in the device.
574
575 **/
576 EFI_STATUS
577 EFIAPI
578 PartitionFlushBlocks (
579 IN EFI_BLOCK_IO_PROTOCOL *This
580 )
581 {
582 PARTITION_PRIVATE_DATA *Private;
583
584 Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (This);
585
586 return Private->ParentBlockIo->FlushBlocks (Private->ParentBlockIo);
587 }
588
589
590
591 /**
592 Create a child handle for a logical block device that represents the
593 bytes Start to End of the Parent Block IO device.
594
595 @param[in] This Protocol instance pointer
596 @param[in] ParentHandle Parent Handle for new child
597 @param[in] ParentDiskIo Parent DiskIo interface
598 @param[in] ParentBlockIo Parent BlockIo interface
599 @param[in] ParentDevicePath Parent Device Path
600 @param[in] DevicePathNode Child Device Path node
601 @param[in] Start Start Block
602 @param[in] End End Block
603 @param[in] BlockSize Child block size
604 @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle
605
606 @retval EFI_SUCCESS A child handle was added
607 @retval other A child handle was not added
608
609 **/
610 EFI_STATUS
611 PartitionInstallChildHandle (
612 IN EFI_DRIVER_BINDING_PROTOCOL *This,
613 IN EFI_HANDLE ParentHandle,
614 IN EFI_DISK_IO_PROTOCOL *ParentDiskIo,
615 IN EFI_BLOCK_IO_PROTOCOL *ParentBlockIo,
616 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
617 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
618 IN EFI_LBA Start,
619 IN EFI_LBA End,
620 IN UINT32 BlockSize,
621 IN BOOLEAN InstallEspGuid
622 )
623 {
624 EFI_STATUS Status;
625 PARTITION_PRIVATE_DATA *Private;
626
627 Private = AllocateZeroPool (sizeof (PARTITION_PRIVATE_DATA));
628 if (Private == NULL) {
629 return EFI_OUT_OF_RESOURCES;
630 }
631
632 Private->Signature = PARTITION_PRIVATE_DATA_SIGNATURE;
633
634 Private->Start = MultU64x32 (Start, ParentBlockIo->Media->BlockSize);
635 Private->End = MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);
636
637 Private->BlockSize = BlockSize;
638 Private->ParentBlockIo = ParentBlockIo;
639 Private->DiskIo = ParentDiskIo;
640
641 Private->BlockIo.Revision = ParentBlockIo->Revision;
642
643 Private->BlockIo.Media = &Private->Media;
644 CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
645 Private->Media.LogicalPartition = TRUE;
646 Private->Media.LastBlock = DivU64x32 (
647 MultU64x32 (
648 End - Start + 1,
649 ParentBlockIo->Media->BlockSize
650 ),
651 BlockSize
652 ) - 1;
653
654 Private->Media.BlockSize = (UINT32) BlockSize;
655
656 Private->BlockIo.Reset = PartitionReset;
657 Private->BlockIo.ReadBlocks = PartitionReadBlocks;
658 Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
659 Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
660
661 Private->DevicePath = AppendDevicePathNode (ParentDevicePath, DevicePathNode);
662
663 if (Private->DevicePath == NULL) {
664 FreePool (Private);
665 return EFI_OUT_OF_RESOURCES;
666 }
667
668 if (InstallEspGuid) {
669 Private->EspGuid = &gEfiPartTypeSystemPartGuid;
670 } else {
671 //
672 // If NULL InstallMultipleProtocolInterfaces will ignore it.
673 //
674 Private->EspGuid = NULL;
675 }
676 //
677 // Create the new handle
678 //
679 Private->Handle = NULL;
680 Status = gBS->InstallMultipleProtocolInterfaces (
681 &Private->Handle,
682 &gEfiDevicePathProtocolGuid,
683 Private->DevicePath,
684 &gEfiBlockIoProtocolGuid,
685 &Private->BlockIo,
686 Private->EspGuid,
687 NULL,
688 NULL
689 );
690
691 if (!EFI_ERROR (Status)) {
692 //
693 // Open the Parent Handle for the child
694 //
695 Status = gBS->OpenProtocol (
696 ParentHandle,
697 &gEfiDiskIoProtocolGuid,
698 (VOID **) &ParentDiskIo,
699 This->DriverBindingHandle,
700 Private->Handle,
701 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
702 );
703 } else {
704 FreePool (Private->DevicePath);
705 FreePool (Private);
706 }
707
708 return Status;
709 }
710
711
712 /**
713 The user Entry Point for module Partition. The user code starts with this function.
714
715 @param[in] ImageHandle The firmware allocated handle for the EFI image.
716 @param[in] SystemTable A pointer to the EFI System Table.
717
718 @retval EFI_SUCCESS The entry point is executed successfully.
719 @retval other Some error occurs when executing this entry point.
720
721 **/
722 EFI_STATUS
723 EFIAPI
724 InitializePartition (
725 IN EFI_HANDLE ImageHandle,
726 IN EFI_SYSTEM_TABLE *SystemTable
727 )
728 {
729 EFI_STATUS Status;
730
731 //
732 // Install driver model protocol(s).
733 //
734 Status = EfiLibInstallDriverBindingComponentName2 (
735 ImageHandle,
736 SystemTable,
737 &gPartitionDriverBinding,
738 ImageHandle,
739 &gPartitionComponentName,
740 &gPartitionComponentName2
741 );
742 ASSERT_EFI_ERROR (Status);
743
744
745 return Status;
746 }
747