TianoCore EDK2 master
Loading...
Searching...
No Matches
PlatDriOverrideLib.c
Go to the documentation of this file.
1
10
11#define PLATFORM_OVERRIDE_ITEM_SIGNATURE SIGNATURE_32('p','d','o','i')
13 UINTN Signature;
14 LIST_ENTRY Link;
15 UINT32 DriverInfoNum;
16 EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;
21 EFI_HANDLE LastReturnedImageHandle;
23
24#define DRIVER_IMAGE_INFO_SIGNATURE SIGNATURE_32('p','d','i','i')
25typedef struct _DRIVER_IMAGE_INFO {
26 UINTN Signature;
27 LIST_ENTRY Link;
28 EFI_HANDLE ImageHandle;
29 EFI_DEVICE_PATH_PROTOCOL *DriverImagePath;
30 BOOLEAN UnLoadable;
31 BOOLEAN UnStartable;
33
34#define DEVICE_PATH_STACK_ITEM_SIGNATURE SIGNATURE_32('d','p','s','i')
36 UINTN Signature;
37 LIST_ENTRY Link;
38 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
40
41LIST_ENTRY mDevicePathStack = INITIALIZE_LIST_HEAD_VARIABLE (mDevicePathStack);
42
52EFIAPI
55 )
56{
57 DEVICE_PATH_STACK_ITEM *DevicePathStackItem;
58
59 DevicePathStackItem = AllocateZeroPool (sizeof (DEVICE_PATH_STACK_ITEM));
60 ASSERT (DevicePathStackItem != NULL);
61 DevicePathStackItem->Signature = DEVICE_PATH_STACK_ITEM_SIGNATURE;
62 DevicePathStackItem->DevicePath = DuplicateDevicePath (DevicePath);
63 InsertTailList (&mDevicePathStack, &DevicePathStackItem->Link);
64 return EFI_SUCCESS;
65}
66
77EFIAPI
79 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
80 )
81{
82 DEVICE_PATH_STACK_ITEM *DevicePathStackItem;
83 LIST_ENTRY *ItemListIndex;
84
85 ItemListIndex = mDevicePathStack.BackLink;
86 //
87 // Check if the stack is empty
88 //
89 if (ItemListIndex != &mDevicePathStack) {
90 DevicePathStackItem = CR (ItemListIndex, DEVICE_PATH_STACK_ITEM, Link, DEVICE_PATH_STACK_ITEM_SIGNATURE);
91 if (DevicePath != NULL) {
92 *DevicePath = DuplicateDevicePath (DevicePathStackItem->DevicePath);
93 }
94
95 FreePool (DevicePathStackItem->DevicePath);
96 RemoveEntryList (&DevicePathStackItem->Link);
97 FreePool (DevicePathStackItem);
98 return EFI_SUCCESS;
99 }
100
101 return EFI_NOT_FOUND;
102}
103
113BOOLEAN
114EFIAPI
116 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
117 )
118{
119 DEVICE_PATH_STACK_ITEM *DevicePathStackItem;
120 LIST_ENTRY *ItemListIndex;
121 UINTN DevicePathSize;
122
123 ItemListIndex = mDevicePathStack.BackLink;
124 while (ItemListIndex != &mDevicePathStack) {
125 DevicePathStackItem = CR (ItemListIndex, DEVICE_PATH_STACK_ITEM, Link, DEVICE_PATH_STACK_ITEM_SIGNATURE);
126 DevicePathSize = GetDevicePathSize (DevicePath);
127 if (DevicePathSize == GetDevicePathSize (DevicePathStackItem->DevicePath)) {
128 if (CompareMem (DevicePath, DevicePathStackItem->DevicePath, DevicePathSize) == 0) {
129 return TRUE;
130 }
131 }
132
133 ItemListIndex = ItemListIndex->BackLink;
134 }
135
136 return FALSE;
137}
138
164EFIAPI
166 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
167 IN EFI_GUID *FileGuid,
168 IN EFI_HANDLE CallerImageHandle
169 )
170{
171 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
172 EFI_DEVICE_PATH_PROTOCOL *LastDeviceNode;
173 EFI_STATUS Status;
174 EFI_GUID *GuidPoint;
175 UINTN Index;
176 UINTN FvHandleCount;
177 EFI_HANDLE *FvHandleBuffer;
178 EFI_FV_FILETYPE Type;
179 UINTN Size;
180 EFI_FV_FILE_ATTRIBUTES Attributes;
181 UINT32 AuthenticationStatus;
182 BOOLEAN FindFvFile;
183 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
186 EFI_HANDLE FoundFvHandle;
187 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
188 BOOLEAN HasFvNode;
189
190 if (DevicePath == NULL) {
191 return EFI_INVALID_PARAMETER;
192 }
193
194 if (*DevicePath == NULL) {
195 return EFI_INVALID_PARAMETER;
196 }
197
198 //
199 // Check whether the device path points to the default the input FV file
200 //
201 TempDevicePath = *DevicePath;
202 LastDeviceNode = TempDevicePath;
203 while (!IsDevicePathEnd (TempDevicePath)) {
204 LastDeviceNode = TempDevicePath;
205 TempDevicePath = NextDevicePathNode (TempDevicePath);
206 }
207
209 if (GuidPoint == NULL) {
210 //
211 // If this option does not point to a FV file, just return EFI_UNSUPPORTED.
212 //
213 return EFI_UNSUPPORTED;
214 }
215
216 if (FileGuid != NULL) {
217 if (!CompareGuid (GuidPoint, FileGuid)) {
218 //
219 // If the FV file is not the input file GUID, just return EFI_UNSUPPORTED
220 //
221 return EFI_UNSUPPORTED;
222 }
223 } else {
224 FileGuid = GuidPoint;
225 }
226
227 //
228 // Check to see if the device path contains memory map node
229 //
230 TempDevicePath = *DevicePath;
231 HasFvNode = FALSE;
232 while (!IsDevicePathEnd (TempDevicePath)) {
233 //
234 // Use old Device Path
235 //
236 if ((DevicePathType (TempDevicePath) == HARDWARE_DEVICE_PATH) &&
237 (DevicePathSubType (TempDevicePath) == HW_MEMMAP_DP))
238 {
239 HasFvNode = TRUE;
240 break;
241 }
242
243 TempDevicePath = NextDevicePathNode (TempDevicePath);
244 }
245
246 if (!HasFvNode) {
247 return EFI_UNSUPPORTED;
248 }
249
250 //
251 // Check whether the input Fv file device path is valid
252 //
253 TempDevicePath = *DevicePath;
254 FoundFvHandle = NULL;
255 Status = gBS->LocateDevicePath (
256 &gEfiFirmwareVolume2ProtocolGuid,
257 &TempDevicePath,
258 &FoundFvHandle
259 );
260 if (!EFI_ERROR (Status)) {
261 Status = gBS->HandleProtocol (
262 FoundFvHandle,
263 &gEfiFirmwareVolume2ProtocolGuid,
264 (VOID **)&Fv
265 );
266 if (!EFI_ERROR (Status)) {
267 //
268 // Set FV ReadFile Buffer as NULL, only need to check whether input Fv file exist there
269 //
270 Status = Fv->ReadFile (
271 Fv,
272 FileGuid,
273 NULL,
274 &Size,
275 &Type,
276 &Attributes,
277 &AuthenticationStatus
278 );
279 if (!EFI_ERROR (Status)) {
280 return EFI_ALREADY_STARTED;
281 }
282 }
283 }
284
285 //
286 // Look for the input wanted FV file in current FV
287 // First, try to look for in Caller own FV. Caller and input wanted FV file usually are in the same FV
288 //
289 FindFvFile = FALSE;
290 FoundFvHandle = NULL;
291 Status = gBS->HandleProtocol (
292 CallerImageHandle,
293 &gEfiLoadedImageProtocolGuid,
294 (VOID **)&LoadedImage
295 );
296 if (!EFI_ERROR (Status)) {
297 Status = gBS->HandleProtocol (
298 LoadedImage->DeviceHandle,
299 &gEfiFirmwareVolume2ProtocolGuid,
300 (VOID **)&Fv
301 );
302 if (!EFI_ERROR (Status)) {
303 Status = Fv->ReadFile (
304 Fv,
305 FileGuid,
306 NULL,
307 &Size,
308 &Type,
309 &Attributes,
310 &AuthenticationStatus
311 );
312 if (!EFI_ERROR (Status)) {
313 FindFvFile = TRUE;
314 FoundFvHandle = LoadedImage->DeviceHandle;
315 }
316 }
317 }
318
319 //
320 // Second, if fail to find, try to enumerate all FV
321 //
322 if (!FindFvFile) {
323 gBS->LocateHandleBuffer (
325 &gEfiFirmwareVolume2ProtocolGuid,
326 NULL,
327 &FvHandleCount,
328 &FvHandleBuffer
329 );
330 for (Index = 0; Index < FvHandleCount; Index++) {
331 gBS->HandleProtocol (
332 FvHandleBuffer[Index],
333 &gEfiFirmwareVolume2ProtocolGuid,
334 (VOID **)&Fv
335 );
336
337 Status = Fv->ReadFile (
338 Fv,
339 FileGuid,
340 NULL,
341 &Size,
342 &Type,
343 &Attributes,
344 &AuthenticationStatus
345 );
346 if (EFI_ERROR (Status)) {
347 //
348 // Skip if input Fv file not in the FV
349 //
350 continue;
351 }
352
353 FindFvFile = TRUE;
354 FoundFvHandle = FvHandleBuffer[Index];
355 break;
356 }
357 }
358
359 if (FindFvFile) {
360 //
361 // Build the shell device path
362 //
363 NewDevicePath = DevicePathFromHandle (FoundFvHandle);
364
365 EfiInitializeFwVolDevicepathNode (&FvFileNode, FileGuid);
366 NewDevicePath = AppendDevicePathNode (NewDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&FvFileNode);
367 *DevicePath = NewDevicePath;
368 return EFI_SUCCESS;
369 }
370
371 return EFI_NOT_FOUND;
372}
373
390VOID *
391EFIAPI
393 IN CHAR16 *Name,
394 IN EFI_GUID *VendorGuid,
395 OUT UINTN *VariableSize
396 )
397{
398 EFI_STATUS Status;
399 UINTN BufferSize;
400 VOID *Buffer;
401
402 Buffer = NULL;
403
404 //
405 // Pass in a zero size buffer to find the required buffer size.
406 //
407 BufferSize = 0;
408 Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
409 if (Status == EFI_BUFFER_TOO_SMALL) {
410 //
411 // Allocate the buffer to return
412 //
413 Buffer = AllocateZeroPool (BufferSize);
414 if (Buffer == NULL) {
415 return NULL;
416 }
417
418 //
419 // Read variable into the allocated buffer.
420 //
421 Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
422 if (EFI_ERROR (Status)) {
423 BufferSize = 0;
424 }
425 }
426
427 *VariableSize = BufferSize;
428 return Buffer;
429}
430
450EFIAPI
452 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
453 )
454{
455 EFI_STATUS Status;
456 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
457 EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
458 EFI_DEVICE_PATH_PROTOCOL *Instance;
459 EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
461 EFI_HANDLE Handle;
462 EFI_HANDLE PreviousHandle;
463 UINTN Size;
464
465 if (DevicePathToConnect == NULL) {
466 return EFI_SUCCESS;
467 }
468
469 DevicePath = DuplicateDevicePath (DevicePathToConnect);
470 CopyOfDevicePath = DevicePath;
471 if (DevicePath == NULL) {
472 return EFI_OUT_OF_RESOURCES;
473 }
474
475 do {
476 //
477 // The outer loop handles multi instance device paths.
478 // Only console variables contain multiple instance device paths.
479 //
480 // After this call DevicePath points to the next Instance
481 //
482 Instance = GetNextDevicePathInstance (&DevicePath, &Size);
483 ASSERT (Instance != NULL);
484
485 Next = Instance;
486 while (!IsDevicePathEndType (Next)) {
487 Next = NextDevicePathNode (Next);
488 }
489
491
492 //
493 // Start the real work of connect with RemainingDevicePath
494 //
495 PreviousHandle = NULL;
496 do {
497 //
498 // Find the handle that best matches the Device Path. If it is only a
499 // partial match the remaining part of the device path is returned in
500 // RemainingDevicePath.
501 //
502 RemainingDevicePath = Instance;
503 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
504
505 if (!EFI_ERROR (Status)) {
506 if (Handle == PreviousHandle) {
507 //
508 // If no forward progress is made try invoking the Dispatcher.
509 // A new FV may have been added to the system an new drivers
510 // may now be found.
511 // Status == EFI_SUCCESS means a driver was dispatched
512 // Status == EFI_NOT_FOUND means no new drivers were dispatched
513 //
514 Status = gDS->Dispatch ();
515 }
516
517 if (!EFI_ERROR (Status)) {
518 PreviousHandle = Handle;
519 //
520 // Connect all drivers that apply to Handle and RemainingDevicePath,
521 // the Recursive flag is FALSE so only one level will be expanded.
522 //
523 // Do not check the connect status here, if the connect controller fail,
524 // then still give the chance to do dispatch, because partial
525 // RemainingDevicepath may be in the new FV
526 //
527 // 1. If the connect fails, RemainingDevicepath and handle will not
528 // change, so next time will do the dispatch, then dispatch's status
529 // will take effect
530 // 2. If the connect succeeds, the RemainingDevicepath and handle will
531 // change, then avoid the dispatch, we have chance to continue the
532 // next connection
533 //
534 gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
535 }
536 }
537
538 //
539 // Loop until RemainingDevicePath is an empty device path
540 //
541 } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
542 } while (DevicePath != NULL);
543
544 if (CopyOfDevicePath != NULL) {
545 FreePool (CopyOfDevicePath);
546 }
547
548 //
549 // All handle with DevicePath exists in the handle database
550 //
551 return Status;
552}
553
564EFIAPI
566 IN OUT LIST_ENTRY *MappingDataBase
567 )
568{
569 LIST_ENTRY *OverrideItemListIndex;
570 LIST_ENTRY *ImageInfoListIndex;
571 PLATFORM_OVERRIDE_ITEM *OverrideItem;
572 DRIVER_IMAGE_INFO *DriverImageInfo;
573
574 if (MappingDataBase == NULL) {
575 return EFI_INVALID_PARAMETER;
576 }
577
578 OverrideItemListIndex = GetFirstNode (MappingDataBase);
579 while (!IsNull (MappingDataBase, OverrideItemListIndex)) {
580 OverrideItem = CR (OverrideItemListIndex, PLATFORM_OVERRIDE_ITEM, Link, PLATFORM_OVERRIDE_ITEM_SIGNATURE);
581 //
582 // Free PLATFORM_OVERRIDE_ITEM.ControllerDevicePath[]
583 //
584 if (OverrideItem->ControllerDevicePath != NULL) {
585 FreePool (OverrideItem->ControllerDevicePath);
586 }
587
588 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
589 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
590 //
591 // Free DRIVER_IMAGE_INFO.DriverImagePath[]
592 //
593 DriverImageInfo = CR (ImageInfoListIndex, DRIVER_IMAGE_INFO, Link, DRIVER_IMAGE_INFO_SIGNATURE);
594 if (DriverImageInfo->DriverImagePath != NULL) {
595 FreePool (DriverImageInfo->DriverImagePath);
596 }
597
598 //
599 // Free DRIVER_IMAGE_INFO itself
600 //
601 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
602 RemoveEntryList (&DriverImageInfo->Link);
603 FreePool (DriverImageInfo);
604 }
605
606 //
607 // Free PLATFORM_OVERRIDE_ITEM itself
608 //
609 OverrideItemListIndex = GetNextNode (MappingDataBase, OverrideItemListIndex);
610 RemoveEntryList (&OverrideItem->Link);
611 FreePool (OverrideItem);
612 }
613
614 InitializeListHead (MappingDataBase);
615 return EFI_SUCCESS;
616}
617
661EFIAPI
663 OUT LIST_ENTRY *MappingDataBase
664 )
665{
666 UINTN BufferSize;
667 VOID *VariableBuffer;
668 UINT8 *VariableIndex;
669 UINTN VariableNum;
670 CHAR16 OverrideVariableName[40];
671 UINT32 NotEnd;
672 UINT32 DriverNumber;
673 PLATFORM_OVERRIDE_ITEM *OverrideItem;
674 DRIVER_IMAGE_INFO *DriverImageInfo;
675 BOOLEAN Corrupted;
676 UINT32 Signature;
677 EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;
678 EFI_DEVICE_PATH_PROTOCOL *DriverDevicePath;
679 UINTN Index;
680
681 if (MappingDataBase == NULL) {
682 return EFI_INVALID_PARAMETER;
683 }
684
685 //
686 // Check the environment variable(s) that contain the override mappings .
687 //
688 VariableBuffer = GetVariableAndSize (L"PlatDriOver", &gEfiCallerIdGuid, &BufferSize);
689 ASSERT ((UINTN)VariableBuffer % sizeof (UINTN) == 0);
690 if (VariableBuffer == NULL) {
691 return EFI_NOT_FOUND;
692 }
693
694 //
695 // Traverse all variables.
696 //
697 VariableNum = 1;
698 Corrupted = FALSE;
699 NotEnd = 0;
700 do {
701 VariableIndex = VariableBuffer;
702 if (VariableIndex + sizeof (UINT32) > (UINT8 *)VariableBuffer + BufferSize) {
703 Corrupted = TRUE;
704 } else {
705 //
706 // End flag
707 //
708 NotEnd = *(UINT32 *)VariableIndex;
709 }
710
711 //
712 // Traverse the entries containing the mapping that Controller Device Path
713 // to a set of Driver Device Paths within this variable.
714 //
715 VariableIndex = VariableIndex + sizeof (UINT32);
716 while (VariableIndex < ((UINT8 *)VariableBuffer + BufferSize)) {
717 //
718 // Check signature of this entry
719 //
720 if (VariableIndex + sizeof (UINT32) > (UINT8 *)VariableBuffer + BufferSize) {
721 Corrupted = TRUE;
722 break;
723 }
724
725 Signature = *(UINT32 *)VariableIndex;
726 if (Signature != PLATFORM_OVERRIDE_ITEM_SIGNATURE) {
727 Corrupted = TRUE;
728 break;
729 }
730
731 //
732 // Create PLATFORM_OVERRIDE_ITEM for this mapping
733 //
734 OverrideItem = AllocateZeroPool (sizeof (PLATFORM_OVERRIDE_ITEM));
735 ASSERT (OverrideItem != NULL);
736 OverrideItem->Signature = PLATFORM_OVERRIDE_ITEM_SIGNATURE;
737 InitializeListHead (&OverrideItem->DriverInfoList);
738 VariableIndex = VariableIndex + sizeof (UINT32);
739 //
740 // Get DriverNum
741 //
742 if (VariableIndex + sizeof (UINT32) >= (UINT8 *)VariableBuffer + BufferSize) {
743 Corrupted = TRUE;
744 break;
745 }
746
747 DriverNumber = *(UINT32 *)VariableIndex;
748 OverrideItem->DriverInfoNum = DriverNumber;
749 VariableIndex = VariableIndex + sizeof (UINT32);
750 //
751 // Get ControllerDevicePath[]
752 //
753 ControllerDevicePath = (EFI_DEVICE_PATH_PROTOCOL *)VariableIndex;
754 OverrideItem->ControllerDevicePath = DuplicateDevicePath (ControllerDevicePath);
755 VariableIndex = VariableIndex + GetDevicePathSize (ControllerDevicePath);
756 //
757 // Align the VariableIndex since the controller device path may not be aligned, refer to the SaveOverridesMapping()
758 //
759 VariableIndex += ((sizeof (UINT32) - ((UINTN)(VariableIndex))) & (sizeof (UINT32) - 1));
760 //
761 // Check buffer overflow.
762 //
763 if ((OverrideItem->ControllerDevicePath == NULL) || (VariableIndex < (UINT8 *)ControllerDevicePath) ||
764 (VariableIndex > (UINT8 *)VariableBuffer + BufferSize))
765 {
766 Corrupted = TRUE;
767 break;
768 }
769
770 //
771 // Get all DriverImageDevicePath[]
772 //
773 for (Index = 0; Index < DriverNumber; Index++) {
774 //
775 // Create DRIVER_IMAGE_INFO for this DriverDevicePath[]
776 //
777 DriverImageInfo = AllocateZeroPool (sizeof (DRIVER_IMAGE_INFO));
778 ASSERT (DriverImageInfo != NULL);
779 DriverImageInfo->Signature = DRIVER_IMAGE_INFO_SIGNATURE;
780
781 DriverDevicePath = (EFI_DEVICE_PATH_PROTOCOL *)VariableIndex;
782 DriverImageInfo->DriverImagePath = DuplicateDevicePath (DriverDevicePath);
783 VariableIndex = VariableIndex + GetDevicePathSize (DriverDevicePath);
784 //
785 // Align the VariableIndex since the driver image device path may not be aligned, refer to the SaveOverridesMapping()
786 //
787 VariableIndex += ((sizeof (UINT32) - ((UINTN)(VariableIndex))) & (sizeof (UINT32) - 1));
788
789 InsertTailList (&OverrideItem->DriverInfoList, &DriverImageInfo->Link);
790
791 //
792 // Check buffer overflow
793 //
794 if ((DriverImageInfo->DriverImagePath == NULL) || (VariableIndex < (UINT8 *)DriverDevicePath) ||
795 (VariableIndex > (UINT8 *)VariableBuffer + BufferSize))
796 {
797 Corrupted = TRUE;
798 break;
799 }
800 }
801
802 InsertTailList (MappingDataBase, &OverrideItem->Link);
803 if (Corrupted) {
804 break;
805 }
806 }
807
808 FreePool (VariableBuffer);
809 if (Corrupted) {
810 FreeMappingDatabase (MappingDataBase);
811 return EFI_VOLUME_CORRUPTED;
812 }
813
814 //
815 // If there are additional variables (PlatDriOver1, PlatDriOver2, PlatDriOver3.....), get them.
816 // NotEnd indicates whether current variable is the end variable.
817 //
818 if (NotEnd != 0) {
819 UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", VariableNum++);
820 VariableBuffer = GetVariableAndSize (OverrideVariableName, &gEfiCallerIdGuid, &BufferSize);
821 ASSERT ((UINTN)VariableBuffer % sizeof (UINTN) == 0);
822 if (VariableBuffer == NULL) {
823 FreeMappingDatabase (MappingDataBase);
824 return EFI_VOLUME_CORRUPTED;
825 }
826 }
827 } while (NotEnd != 0);
828
829 return EFI_SUCCESS;
830}
831
840UINTN
841EFIAPI
843 IN LIST_ENTRY *OverrideItemListIndex
844 )
845{
846 UINTN NeededSize;
847 PLATFORM_OVERRIDE_ITEM *OverrideItem;
848 LIST_ENTRY *ImageInfoListIndex;
849 DRIVER_IMAGE_INFO *DriverImageInfo;
850 UINTN DevicePathSize;
851
852 NeededSize = 0;
853 OverrideItem = CR (OverrideItemListIndex, PLATFORM_OVERRIDE_ITEM, Link, PLATFORM_OVERRIDE_ITEM_SIGNATURE);
854 NeededSize += sizeof (UINT32); // UINT32 SIGNATURE;
855 NeededSize += sizeof (UINT32); // UINT32 DriverNum;
856 DevicePathSize = GetDevicePathSize (OverrideItem->ControllerDevicePath);
857 NeededSize += DevicePathSize; // ControllerDevicePath
858 //
859 // Align the controller device path
860 //
861 NeededSize += ((sizeof (UINT32) - DevicePathSize) & (sizeof (UINT32) - 1));
862 //
863 // Traverse the Driver Info List of this Override Item
864 //
865 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
866 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
867 DriverImageInfo = CR (ImageInfoListIndex, DRIVER_IMAGE_INFO, Link, DRIVER_IMAGE_INFO_SIGNATURE);
868 DevicePathSize = GetDevicePathSize (DriverImageInfo->DriverImagePath);
869 NeededSize += DevicePathSize; // DriverDevicePath
870 //
871 // Align the driver image device path
872 //
873 NeededSize += ((sizeof (UINT32) - DevicePathSize) & (sizeof (UINT32) - 1));
874 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
875 }
876
877 return NeededSize;
878}
879
889EFIAPI
891 VOID
892 )
893{
894 EFI_STATUS Status;
895 VOID *VariableBuffer;
896 UINTN VariableNum;
897 UINTN BufferSize;
898 UINTN Index;
899 CHAR16 OverrideVariableName[40];
900
901 //
902 // Get environment variable(s) number
903 //
904 VariableNum = 0;
905 VariableBuffer = GetVariableAndSize (L"PlatDriOver", &gEfiCallerIdGuid, &BufferSize);
906 VariableNum++;
907 if (VariableBuffer == NULL) {
908 return EFI_NOT_FOUND;
909 }
910
911 //
912 // Check NotEnd to get all PlatDriOverX variable(s)
913 //
914 while ((VariableBuffer != NULL) && ((*(UINT32 *)VariableBuffer) != 0)) {
915 FreePool (VariableBuffer);
916 UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", VariableNum);
917 VariableBuffer = GetVariableAndSize (OverrideVariableName, &gEfiCallerIdGuid, &BufferSize);
918 VariableNum++;
919 }
920
921 //
922 // Delete PlatDriOver and all additional variables, if exist.
923 //
924 Status = gRT->SetVariable (
925 L"PlatDriOver",
926 &gEfiCallerIdGuid,
927 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
928 0,
929 NULL
930 );
931 ASSERT (!EFI_ERROR (Status));
932 for (Index = 1; Index < VariableNum; Index++) {
933 UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", Index);
934 Status = gRT->SetVariable (
935 OverrideVariableName,
936 &gEfiCallerIdGuid,
937 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
938 0,
939 NULL
940 );
941 ASSERT (!EFI_ERROR (Status));
942 }
943
944 return EFI_SUCCESS;
945}
946
957EFIAPI
959 IN LIST_ENTRY *MappingDataBase
960 )
961{
962 EFI_STATUS Status;
963 VOID *VariableBuffer;
964 UINT8 *VariableIndex;
965 UINTN NumIndex;
966 CHAR16 OverrideVariableName[40];
967 UINT32 NotEnd;
968 PLATFORM_OVERRIDE_ITEM *OverrideItem;
969 DRIVER_IMAGE_INFO *DriverImageInfo;
970 LIST_ENTRY *OverrideItemListIndex;
971 LIST_ENTRY *ItemIndex;
972 LIST_ENTRY *ImageInfoListIndex;
973 UINTN VariableNeededSize;
974 UINT64 MaximumVariableStorageSize;
975 UINT64 RemainingVariableStorageSize;
976 UINT64 MaximumVariableSize;
977 UINTN OneItemNeededSize;
978
979 if (MappingDataBase == NULL) {
980 return EFI_INVALID_PARAMETER;
981 }
982
983 if (IsListEmpty (MappingDataBase)) {
984 Status = DeleteOverridesVariables ();
985 return EFI_SUCCESS;
986 }
987
988 //
989 // Get the the maximum size of an individual EFI variable in current system
990 //
991 gRT->QueryVariableInfo (
992 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
993 &MaximumVariableStorageSize,
994 &RemainingVariableStorageSize,
995 &MaximumVariableSize
996 );
997
998 NumIndex = 0;
999 OverrideItemListIndex = GetFirstNode (MappingDataBase);
1000 while (!IsNull (MappingDataBase, OverrideItemListIndex)) {
1001 //
1002 // Try to find the most proper variable size which <= MaximumVariableSize,
1003 // but can contain mapping info as much as possible
1004 //
1005 VariableNeededSize = sizeof (UINT32); // NotEnd;
1006 ItemIndex = OverrideItemListIndex;
1007 NotEnd = FALSE;
1008 //
1009 // Traverse all PLATFORM_OVERRIDE_ITEMs and get the total size.
1010 //
1011 while (!IsNull (MappingDataBase, ItemIndex)) {
1012 OneItemNeededSize = GetOneItemNeededSize (ItemIndex);
1013 //
1014 // If the total size exceeds the MaximumVariableSize, then we must use
1015 // multiple variables.
1016 //
1017 if ((VariableNeededSize +
1018 OneItemNeededSize +
1019 StrSize (L"PlatDriOver ")
1020 ) >= MaximumVariableSize
1021 )
1022 {
1023 NotEnd = TRUE;
1024 break;
1025 }
1026
1027 VariableNeededSize += OneItemNeededSize;
1028 ItemIndex = GetNextNode (MappingDataBase, ItemIndex);
1029 }
1030
1031 if (NotEnd != 0) {
1032 if (VariableNeededSize == sizeof (UINT32)) {
1033 //
1034 // If an individual EFI variable cannot contain a single Item, return error
1035 //
1036 return EFI_OUT_OF_RESOURCES;
1037 }
1038 }
1039
1040 //
1041 // VariableNeededSize is the most proper variable size, allocate variable buffer
1042 // ItemIndex now points to the next PLATFORM_OVERRIDE_ITEM which is not covered by VariableNeededSize
1043 //
1044 VariableBuffer = AllocateZeroPool (VariableNeededSize);
1045 ASSERT (VariableBuffer != NULL);
1046 ASSERT ((UINTN)VariableBuffer % sizeof (UINTN) == 0);
1047
1048 //
1049 // Fill the variable buffer according to MappingDataBase
1050 //
1051 VariableIndex = VariableBuffer;
1052 *(UINT32 *)VariableIndex = NotEnd;
1053 VariableIndex += sizeof (UINT32); // pass NotEnd
1054 //
1055 // ItemIndex points to the next PLATFORM_OVERRIDE_ITEM which is not covered by VariableNeededSize
1056 //
1057 while (OverrideItemListIndex != ItemIndex) {
1058 *(UINT32 *)VariableIndex = PLATFORM_OVERRIDE_ITEM_SIGNATURE;
1059 VariableIndex += sizeof (UINT32); // pass SIGNATURE
1060
1061 OverrideItem = CR (OverrideItemListIndex, PLATFORM_OVERRIDE_ITEM, Link, PLATFORM_OVERRIDE_ITEM_SIGNATURE);
1062 *(UINT32 *)VariableIndex = OverrideItem->DriverInfoNum;
1063 VariableIndex += sizeof (UINT32); // pass DriverNum
1064
1065 CopyMem (VariableIndex, OverrideItem->ControllerDevicePath, GetDevicePathSize (OverrideItem->ControllerDevicePath));
1066 VariableIndex += GetDevicePathSize (OverrideItem->ControllerDevicePath); // pass ControllerDevicePath
1067
1068 //
1069 // Align the VariableIndex since the controller device path may not be aligned
1070 //
1071 VariableIndex += ((sizeof (UINT32) - ((UINTN)(VariableIndex))) & (sizeof (UINT32) - 1));
1072 //
1073 // Save the Driver Info List of this PLATFORM_OVERRIDE_ITEM
1074 //
1075 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
1076 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
1077 DriverImageInfo = CR (ImageInfoListIndex, DRIVER_IMAGE_INFO, Link, DRIVER_IMAGE_INFO_SIGNATURE);
1078 CopyMem (VariableIndex, DriverImageInfo->DriverImagePath, GetDevicePathSize (DriverImageInfo->DriverImagePath));
1079 VariableIndex += GetDevicePathSize (DriverImageInfo->DriverImagePath); // pass DriverImageDevicePath
1080 //
1081 // Align the VariableIndex since the driver image device path may not be aligned
1082 //
1083 VariableIndex += ((sizeof (UINT32) - ((UINTN)(VariableIndex))) & (sizeof (UINT32) - 1));
1084 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
1085 }
1086
1087 OverrideItemListIndex = GetNextNode (MappingDataBase, OverrideItemListIndex);
1088 }
1089
1090 ASSERT (((UINTN)VariableIndex - (UINTN)VariableBuffer) == VariableNeededSize);
1091
1092 if (NumIndex == 0) {
1093 UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver");
1094 } else {
1095 UnicodeSPrint (OverrideVariableName, sizeof (OverrideVariableName), L"PlatDriOver%d", NumIndex);
1096 }
1097
1098 Status = gRT->SetVariable (
1099 OverrideVariableName,
1100 &gEfiCallerIdGuid,
1101 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
1102 VariableNeededSize,
1103 VariableBuffer
1104 );
1105 FreePool (VariableBuffer);
1106
1107 if (EFI_ERROR (Status)) {
1108 if (NumIndex > 0) {
1109 //
1110 // Delete all PlatDriOver variables when full mapping can't be set.
1111 //
1113 }
1114
1115 return Status;
1116 }
1117
1118 NumIndex++;
1119 }
1120
1121 return EFI_SUCCESS;
1122}
1123
1136EFIAPI
1138 IN EFI_HANDLE ImageHandle,
1139 OUT EFI_HANDLE *BindingHandle
1140 )
1141{
1142 EFI_STATUS Status;
1143 UINTN Index;
1144 UINTN DriverBindingHandleCount;
1145 EFI_HANDLE *DriverBindingHandleBuffer;
1146 EFI_DRIVER_BINDING_PROTOCOL *DriverBindingInterface;
1147
1148 if ((BindingHandle == NULL) || (ImageHandle == NULL)) {
1149 return NULL;
1150 }
1151
1152 //
1153 // Get all drivers which support driver binding protocol
1154 //
1155 DriverBindingHandleCount = 0;
1156 Status = gBS->LocateHandleBuffer (
1157 ByProtocol,
1158 &gEfiDriverBindingProtocolGuid,
1159 NULL,
1160 &DriverBindingHandleCount,
1161 &DriverBindingHandleBuffer
1162 );
1163 if (EFI_ERROR (Status) || (DriverBindingHandleCount == 0)) {
1164 return NULL;
1165 }
1166
1167 for (Index = 0; Index < DriverBindingHandleCount; Index++) {
1168 DriverBindingInterface = NULL;
1169 Status = gBS->OpenProtocol (
1170 DriverBindingHandleBuffer[Index],
1171 &gEfiDriverBindingProtocolGuid,
1172 (VOID **)&DriverBindingInterface,
1173 NULL,
1174 NULL,
1175 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1176 );
1177 if (EFI_ERROR (Status)) {
1178 continue;
1179 }
1180
1181 if (DriverBindingInterface->ImageHandle == ImageHandle) {
1182 *BindingHandle = DriverBindingHandleBuffer[Index];
1183 FreePool (DriverBindingHandleBuffer);
1184 return DriverBindingInterface;
1185 }
1186 }
1187
1188 //
1189 // If no Driver Binding Protocol instance is found
1190 //
1191 FreePool (DriverBindingHandleBuffer);
1192 *BindingHandle = NULL;
1193 return NULL;
1194}
1195
1202EFI_TPL
1204 VOID
1205 )
1206{
1207 EFI_TPL Tpl;
1208
1209 Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
1210 gBS->RestoreTPL (Tpl);
1211
1212 return Tpl;
1213}
1214
1241EFIAPI
1243 IN EFI_HANDLE ControllerHandle,
1244 IN OUT EFI_HANDLE *DriverImageHandle,
1245 IN LIST_ENTRY *MappingDataBase,
1246 IN EFI_HANDLE CallerImageHandle
1247 )
1248{
1249 EFI_STATUS Status;
1250 EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath;
1251 BOOLEAN ControllerFound;
1252 BOOLEAN ImageFound;
1253 EFI_HANDLE *ImageHandleBuffer;
1254 UINTN ImageHandleCount;
1255 UINTN Index;
1256 EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
1257 EFI_HANDLE DriverBindingHandle;
1258 BOOLEAN FoundLastReturned;
1259 PLATFORM_OVERRIDE_ITEM *OverrideItem;
1260 DRIVER_IMAGE_INFO *DriverImageInfo;
1261 LIST_ENTRY *OverrideItemListIndex;
1262 LIST_ENTRY *ImageInfoListIndex;
1263 EFI_DEVICE_PATH_PROTOCOL *TempDriverImagePath;
1264 EFI_HANDLE ImageHandle;
1265 EFI_HANDLE Handle;
1266 EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath;
1267 EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;
1268 UINTN DevicePathSize;
1269
1270 //
1271 // Check that ControllerHandle is a valid handle
1272 //
1273 if (ControllerHandle == NULL) {
1274 return EFI_INVALID_PARAMETER;
1275 }
1276
1277 //
1278 // Get the device path of ControllerHandle
1279 //
1280 Status = gBS->HandleProtocol (
1281 ControllerHandle,
1282 &gEfiDevicePathProtocolGuid,
1283 (VOID **)&ControllerDevicePath
1284 );
1285 if (EFI_ERROR (Status) || (ControllerDevicePath == NULL)) {
1286 return EFI_INVALID_PARAMETER;
1287 }
1288
1289 //
1290 // Search ControllerDevicePath in MappingDataBase
1291 //
1292 OverrideItem = NULL;
1293 ControllerFound = FALSE;
1294 DevicePathSize = GetDevicePathSize (ControllerDevicePath);
1295
1296 OverrideItemListIndex = GetFirstNode (MappingDataBase);
1297 while (!IsNull (MappingDataBase, OverrideItemListIndex)) {
1298 OverrideItem = CR (OverrideItemListIndex, PLATFORM_OVERRIDE_ITEM, Link, PLATFORM_OVERRIDE_ITEM_SIGNATURE);
1299 if (DevicePathSize == GetDevicePathSize (OverrideItem->ControllerDevicePath)) {
1300 if (CompareMem (
1301 ControllerDevicePath,
1302 OverrideItem->ControllerDevicePath,
1303 DevicePathSize
1304 ) == 0
1305 )
1306 {
1307 ControllerFound = TRUE;
1308 break;
1309 }
1310 }
1311
1312 OverrideItemListIndex = GetNextNode (MappingDataBase, OverrideItemListIndex);
1313 }
1314
1315 if (!ControllerFound || (OverrideItem == NULL)) {
1316 return EFI_NOT_FOUND;
1317 }
1318
1319 //
1320 // Passing in a pointer to NULL, will return the first driver device path for ControllerHandle.
1321 // Check whether the driverImagePath is not a device path that was returned on a previous call to GetDriverPath().
1322 //
1323 if (*DriverImageHandle != NULL) {
1324 if (*DriverImageHandle != OverrideItem->LastReturnedImageHandle) {
1325 return EFI_INVALID_PARAMETER;
1326 }
1327 }
1328
1329 //
1330 // The GetDriverPath() may be called recursively, because it use ConnectDevicePath() internally,
1331 // so should check whether there is a dead loop.
1332 // Here use a controller device path stack to record all processed controller device path during a GetDriverPath() call,
1333 // and check the controller device path whether appear again during the GetDriverPath() call.
1334 //
1335 if (CheckExistInStack (OverrideItem->ControllerDevicePath)) {
1336 //
1337 // There is a dependency dead loop if the ControllerDevicePath appear in stack twice
1338 //
1339 return EFI_UNSUPPORTED;
1340 }
1341
1342 PushDevPathStack (OverrideItem->ControllerDevicePath);
1343
1344 //
1345 // Check every override driver, try to load and start them
1346 //
1347 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
1348 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
1349 DriverImageInfo = CR (ImageInfoListIndex, DRIVER_IMAGE_INFO, Link, DRIVER_IMAGE_INFO_SIGNATURE);
1350 if (DriverImageInfo->ImageHandle == NULL) {
1351 //
1352 // Skip if the image is unloadable or unstartable
1353 //
1354 if ((!DriverImageInfo->UnLoadable) && ((!DriverImageInfo->UnStartable))) {
1355 TempDriverImagePath = DriverImageInfo->DriverImagePath;
1356 //
1357 // If the image device path contains an FV node, check the FV file device path is valid.
1358 // If it is invalid, try to return the valid device path.
1359 // FV address maybe changes for memory layout adjust from time to time,
1360 // use this function could promise the FV file device path is right.
1361 //
1362 Status = UpdateFvFileDevicePath (&TempDriverImagePath, NULL, CallerImageHandle);
1363 if (!EFI_ERROR (Status)) {
1364 FreePool (DriverImageInfo->DriverImagePath);
1365 DriverImageInfo->DriverImagePath = TempDriverImagePath;
1366 }
1367
1368 //
1369 // Get all Loaded Image protocol to check whether the driver image has been loaded and started
1370 //
1371 ImageFound = FALSE;
1372 ImageHandleCount = 0;
1373 Status = gBS->LocateHandleBuffer (
1374 ByProtocol,
1375 &gEfiLoadedImageProtocolGuid,
1376 NULL,
1377 &ImageHandleCount,
1378 &ImageHandleBuffer
1379 );
1380 if (EFI_ERROR (Status) || (ImageHandleCount == 0)) {
1381 return EFI_NOT_FOUND;
1382 }
1383
1384 for (Index = 0; Index < ImageHandleCount; Index++) {
1385 //
1386 // Get the EFI Loaded Image Device Path Protocol
1387 //
1388 LoadedImageDevicePath = NULL;
1389 Status = gBS->HandleProtocol (
1390 ImageHandleBuffer[Index],
1391 &gEfiLoadedImageDevicePathProtocolGuid,
1392 (VOID **)&LoadedImageDevicePath
1393 );
1394 if (EFI_ERROR (Status)) {
1395 //
1396 // Maybe not all EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL existed.
1397 //
1398 continue;
1399 }
1400
1401 DevicePathSize = GetDevicePathSize (DriverImageInfo->DriverImagePath);
1402 if (DevicePathSize == GetDevicePathSize (LoadedImageDevicePath)) {
1403 if (CompareMem (
1404 DriverImageInfo->DriverImagePath,
1405 LoadedImageDevicePath,
1406 GetDevicePathSize (LoadedImageDevicePath)
1407 ) == 0
1408 )
1409 {
1410 ImageFound = TRUE;
1411 break;
1412 }
1413 }
1414 }
1415
1416 if (ImageFound) {
1417 //
1418 // Find its related driver binding protocol
1419 // Driver binding handle may be different with its driver's Image Handle.
1420 //
1421 DriverBindingHandle = NULL;
1422 DriverBinding = GetBindingProtocolFromImageHandle (
1423 ImageHandleBuffer[Index],
1424 &DriverBindingHandle
1425 );
1426 ASSERT (DriverBinding != NULL);
1427 DriverImageInfo->ImageHandle = ImageHandleBuffer[Index];
1428 } else if (GetCurrentTpl () <= TPL_CALLBACK) {
1429 //
1430 // The driver image has not been loaded and started. Try to load and start it now.
1431 // Try to connect all device in the driver image path.
1432 //
1433 // Note: LoadImage() and StartImage() should be called under CALLBACK TPL in theory, but
1434 // since many device need to be connected in CALLBACK level environment( e.g. Usb devices )
1435 // and the Fat and Patition driver can endure executing in CALLBACK level in fact, so here permit
1436 // to use LoadImage() and StartImage() in CALLBACK TPL.
1437 //
1438 Status = ConnectDevicePath (DriverImageInfo->DriverImagePath);
1439 //
1440 // check whether it points to a PCI Option Rom image,
1441 // and try to use bus override protocol to get its first option rom image driver
1442 //
1443 TempDriverImagePath = DriverImageInfo->DriverImagePath;
1444 gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &TempDriverImagePath, &Handle);
1445 //
1446 // Get the Bus Specific Driver Override Protocol instance on the Controller Handle
1447 //
1448 Status = gBS->HandleProtocol (
1449 Handle,
1450 &gEfiBusSpecificDriverOverrideProtocolGuid,
1451 (VOID **)&BusSpecificDriverOverride
1452 );
1453 if (!EFI_ERROR (Status) && (BusSpecificDriverOverride != NULL)) {
1454 ImageHandle = NULL;
1455 Status = BusSpecificDriverOverride->GetDriver (
1456 BusSpecificDriverOverride,
1457 &ImageHandle
1458 );
1459 if (!EFI_ERROR (Status)) {
1460 //
1461 // Find its related driver binding protocol
1462 // Driver binding handle may be different with its driver's Image handle
1463 //
1464 DriverBindingHandle = NULL;
1465 DriverBinding = GetBindingProtocolFromImageHandle (
1466 ImageHandle,
1467 &DriverBindingHandle
1468 );
1469 ASSERT (DriverBinding != NULL);
1470 DriverImageInfo->ImageHandle = ImageHandle;
1471 }
1472 }
1473
1474 //
1475 // Skip if any device cannot be connected now, future passes through GetDriver() may be able to load that driver.
1476 // Only file path media or FwVol Device Path Node remain if all device is connected
1477 //
1478 TempDriverImagePath = DriverImageInfo->DriverImagePath;
1479 gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &TempDriverImagePath, &Handle);
1480 if (((DevicePathType (TempDriverImagePath) == MEDIA_DEVICE_PATH) &&
1481 (DevicePathSubType (TempDriverImagePath) == MEDIA_FILEPATH_DP)) ||
1483 )
1484 {
1485 //
1486 // Try to load the driver
1487 //
1488 TempDriverImagePath = DriverImageInfo->DriverImagePath;
1489 Status = gBS->LoadImage (
1490 FALSE,
1491 CallerImageHandle,
1492 TempDriverImagePath,
1493 NULL,
1494 0,
1495 &ImageHandle
1496 );
1497 if (!EFI_ERROR (Status)) {
1498 //
1499 // Try to start the driver
1500 //
1501 Status = gBS->StartImage (ImageHandle, NULL, NULL);
1502 if (EFI_ERROR (Status)) {
1503 DriverImageInfo->UnStartable = TRUE;
1504 DriverImageInfo->ImageHandle = NULL;
1505 } else {
1506 //
1507 // Find its related driver binding protocol
1508 // Driver binding handle may be different with its driver's Image handle
1509 //
1510 DriverBindingHandle = NULL;
1511 DriverBinding = GetBindingProtocolFromImageHandle (
1512 ImageHandle,
1513 &DriverBindingHandle
1514 );
1515 ASSERT (DriverBinding != NULL);
1516 DriverImageInfo->ImageHandle = ImageHandle;
1517 }
1518 } else {
1519 //
1520 // With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
1521 // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
1522 // If the caller doesn't have the option to defer the execution of an image, we should
1523 // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
1524 //
1525 if (Status == EFI_SECURITY_VIOLATION) {
1526 gBS->UnloadImage (ImageHandle);
1527 }
1528
1529 DriverImageInfo->UnLoadable = TRUE;
1530 DriverImageInfo->ImageHandle = NULL;
1531 }
1532 }
1533 }
1534
1535 FreePool (ImageHandleBuffer);
1536 }
1537 }
1538
1539 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
1540 }
1541
1542 //
1543 // Finish try to load and start the override driver of a controller, popup the controller's device path
1544 //
1546
1547 //
1548 // return the DriverImageHandle for ControllerHandle
1549 //
1550 FoundLastReturned = FALSE;
1551 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
1552 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
1553 DriverImageInfo = CR (ImageInfoListIndex, DRIVER_IMAGE_INFO, Link, DRIVER_IMAGE_INFO_SIGNATURE);
1554 if (DriverImageInfo->ImageHandle != NULL) {
1555 if ((*DriverImageHandle == NULL) || FoundLastReturned) {
1556 //
1557 // If DriverImageHandle is NULL, then we just need to return the first driver.
1558 // If FoundLastReturned, this means we have just encountered the previously returned driver.
1559 // For both cases, we just return the image handle of this driver.
1560 //
1561 OverrideItem->LastReturnedImageHandle = DriverImageInfo->ImageHandle;
1562 *DriverImageHandle = DriverImageInfo->ImageHandle;
1563 return EFI_SUCCESS;
1564 } else if (*DriverImageHandle == DriverImageInfo->ImageHandle) {
1565 //
1566 // We have found the previously returned driver.
1567 //
1568 FoundLastReturned = TRUE;
1569 }
1570 }
1571
1572 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
1573 }
1574
1575 return EFI_NOT_FOUND;
1576}
1577
1596EFIAPI
1598 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
1599 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath OPTIONAL,
1600 IN LIST_ENTRY *MappingDataBase,
1601 OUT UINT32 *DriverInfoNum OPTIONAL,
1602 OUT UINT32 *DriverImageNO OPTIONAL
1603 )
1604{
1605 LIST_ENTRY *OverrideItemListIndex;
1606 PLATFORM_OVERRIDE_ITEM *OverrideItem;
1607 LIST_ENTRY *ImageInfoListIndex;
1608 DRIVER_IMAGE_INFO *DriverImageInfo;
1609 BOOLEAN Found;
1610 UINT32 ImageNO;
1611 UINTN DevicePathSize;
1612
1613 if (ControllerDevicePath == NULL) {
1614 return EFI_INVALID_PARAMETER;
1615 }
1616
1617 if (MappingDataBase == NULL) {
1618 return EFI_INVALID_PARAMETER;
1619 }
1620
1621 //
1622 // Search ControllerDevicePath in MappingDataBase
1623 //
1624 Found = FALSE;
1625 OverrideItem = NULL;
1626 OverrideItemListIndex = GetFirstNode (MappingDataBase);
1627 while (!IsNull (MappingDataBase, OverrideItemListIndex)) {
1628 OverrideItem = CR (OverrideItemListIndex, PLATFORM_OVERRIDE_ITEM, Link, PLATFORM_OVERRIDE_ITEM_SIGNATURE);
1629 DevicePathSize = GetDevicePathSize (ControllerDevicePath);
1630 if (DevicePathSize == GetDevicePathSize (OverrideItem->ControllerDevicePath)) {
1631 if (CompareMem (
1632 ControllerDevicePath,
1633 OverrideItem->ControllerDevicePath,
1634 DevicePathSize
1635 ) == 0
1636 )
1637 {
1638 Found = TRUE;
1639 break;
1640 }
1641 }
1642
1643 OverrideItemListIndex = GetNextNode (MappingDataBase, OverrideItemListIndex);
1644 }
1645
1646 if (!Found || (OverrideItem == NULL)) {
1647 //
1648 // ControllerDevicePath is not in MappingDataBase
1649 //
1650 return EFI_NOT_FOUND;
1651 }
1652
1653 ASSERT (OverrideItem->DriverInfoNum != 0);
1654 if (DriverInfoNum != NULL) {
1655 *DriverInfoNum = OverrideItem->DriverInfoNum;
1656 }
1657
1658 //
1659 // If DriverImageDevicePath is NULL, skip checking DriverImageDevicePath
1660 // in the controller's Driver Image Info List
1661 //
1662 if (DriverImageDevicePath == NULL) {
1663 return EFI_SUCCESS;
1664 }
1665
1666 //
1667 // return the DriverImageHandle for ControllerHandle
1668 //
1669 ImageNO = 0;
1670 Found = FALSE;
1671 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
1672 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
1673 DriverImageInfo = CR (ImageInfoListIndex, DRIVER_IMAGE_INFO, Link, DRIVER_IMAGE_INFO_SIGNATURE);
1674 ImageNO++;
1675 DevicePathSize = GetDevicePathSize (DriverImageDevicePath);
1676 if (DevicePathSize == GetDevicePathSize (DriverImageInfo->DriverImagePath)) {
1677 if (CompareMem (
1678 DriverImageDevicePath,
1679 DriverImageInfo->DriverImagePath,
1680 GetDevicePathSize (DriverImageInfo->DriverImagePath)
1681 ) == 0
1682 )
1683 {
1684 Found = TRUE;
1685 break;
1686 }
1687 }
1688
1689 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
1690 }
1691
1692 if (!Found) {
1693 //
1694 // DriverImageDevicePath is not found in the controller's Driver Image Info List
1695 //
1696 return EFI_NOT_FOUND;
1697 } else {
1698 if (DriverImageNO != NULL) {
1699 *DriverImageNO = ImageNO;
1700 }
1701
1702 return EFI_SUCCESS;
1703 }
1704}
1705
1727EFIAPI
1729 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
1730 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
1731 IN LIST_ENTRY *MappingDataBase,
1732 IN UINT32 DriverImageNO
1733 )
1734{
1735 EFI_STATUS Status;
1736 LIST_ENTRY *OverrideItemListIndex;
1737 PLATFORM_OVERRIDE_ITEM *OverrideItem;
1738 LIST_ENTRY *ImageInfoListIndex;
1739 DRIVER_IMAGE_INFO *DriverImageInfo;
1740 BOOLEAN Found;
1741 UINT32 ImageNO;
1742 UINTN DevicePathSize;
1743
1744 if (ControllerDevicePath == NULL) {
1745 return EFI_INVALID_PARAMETER;
1746 }
1747
1748 if (DriverImageDevicePath == NULL) {
1749 return EFI_INVALID_PARAMETER;
1750 }
1751
1752 if (MappingDataBase == NULL) {
1753 return EFI_INVALID_PARAMETER;
1754 }
1755
1756 //
1757 // If the driver is already in the controller's Driver Image Info List,
1758 // just return EFI_ALREADY_STARTED.
1759 //
1760 Status = CheckMapping (
1761 ControllerDevicePath,
1762 DriverImageDevicePath,
1763 MappingDataBase,
1764 NULL,
1765 NULL
1766 );
1767 if (Status == EFI_SUCCESS) {
1768 return EFI_ALREADY_STARTED;
1769 }
1770
1771 //
1772 // Search the input ControllerDevicePath in MappingDataBase
1773 //
1774 Found = FALSE;
1775 OverrideItem = NULL;
1776 OverrideItemListIndex = GetFirstNode (MappingDataBase);
1777 while (!IsNull (MappingDataBase, OverrideItemListIndex)) {
1778 OverrideItem = CR (OverrideItemListIndex, PLATFORM_OVERRIDE_ITEM, Link, PLATFORM_OVERRIDE_ITEM_SIGNATURE);
1779 DevicePathSize = GetDevicePathSize (ControllerDevicePath);
1780 if (DevicePathSize == GetDevicePathSize (OverrideItem->ControllerDevicePath)) {
1781 if (CompareMem (
1782 ControllerDevicePath,
1783 OverrideItem->ControllerDevicePath,
1784 DevicePathSize
1785 ) == 0
1786 )
1787 {
1788 Found = TRUE;
1789 break;
1790 }
1791 }
1792
1793 OverrideItemListIndex = GetNextNode (MappingDataBase, OverrideItemListIndex);
1794 }
1795
1796 //
1797 // If cannot find, this is a new controller item
1798 // Add the Controller related PLATFORM_OVERRIDE_ITEM structrue in mapping data base
1799 //
1800 if (!Found) {
1801 OverrideItem = AllocateZeroPool (sizeof (PLATFORM_OVERRIDE_ITEM));
1802 if (OverrideItem == NULL) {
1803 ASSERT (OverrideItem != NULL);
1804 return EFI_OUT_OF_RESOURCES;
1805 }
1806
1807 OverrideItem->Signature = PLATFORM_OVERRIDE_ITEM_SIGNATURE;
1808 OverrideItem->ControllerDevicePath = DuplicateDevicePath (ControllerDevicePath);
1809 InitializeListHead (&OverrideItem->DriverInfoList);
1810 InsertTailList (MappingDataBase, &OverrideItem->Link);
1811 }
1812
1813 if (OverrideItem == NULL) {
1814 return EFI_NOT_FOUND;
1815 }
1816
1817 //
1818 // Prepare the driver image related DRIVER_IMAGE_INFO structure.
1819 //
1820 DriverImageInfo = AllocateZeroPool (sizeof (DRIVER_IMAGE_INFO));
1821 if (DriverImageInfo == NULL) {
1822 ASSERT (DriverImageInfo != NULL);
1823 return EFI_OUT_OF_RESOURCES;
1824 }
1825
1826 DriverImageInfo->Signature = DRIVER_IMAGE_INFO_SIGNATURE;
1827 DriverImageInfo->DriverImagePath = DuplicateDevicePath (DriverImageDevicePath);
1828 //
1829 // Find the driver image wanted order location
1830 //
1831 ImageNO = 0;
1832 Found = FALSE;
1833 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
1834 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
1835 if (ImageNO == (DriverImageNO - 1)) {
1836 //
1837 // find the wanted order location, insert it
1838 //
1839 InsertTailList (ImageInfoListIndex, &DriverImageInfo->Link);
1840 OverrideItem->DriverInfoNum++;
1841 Found = TRUE;
1842 break;
1843 }
1844
1845 ImageNO++;
1846 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
1847 }
1848
1849 if (!Found) {
1850 //
1851 // if not find the wanted order location, add it as last item of the controller mapping item
1852 //
1853 InsertTailList (&OverrideItem->DriverInfoList, &DriverImageInfo->Link);
1854 OverrideItem->DriverInfoNum++;
1855 }
1856
1857 return EFI_SUCCESS;
1858}
1859
1876EFIAPI
1878 IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath,
1879 IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath,
1880 IN LIST_ENTRY *MappingDataBase
1881 )
1882{
1883 EFI_STATUS Status;
1884 LIST_ENTRY *OverrideItemListIndex;
1885 PLATFORM_OVERRIDE_ITEM *OverrideItem;
1886 LIST_ENTRY *ImageInfoListIndex;
1887 DRIVER_IMAGE_INFO *DriverImageInfo;
1888 BOOLEAN Found;
1889 UINTN DevicePathSize;
1890
1891 if (ControllerDevicePath == NULL) {
1892 return EFI_INVALID_PARAMETER;
1893 }
1894
1895 if (MappingDataBase == NULL) {
1896 return EFI_INVALID_PARAMETER;
1897 }
1898
1899 //
1900 // If ControllerDevicePath is not found in mapping database, return EFI_NOT_FOUND.
1901 //
1902 Status = CheckMapping (
1903 ControllerDevicePath,
1904 DriverImageDevicePath,
1905 MappingDataBase,
1906 NULL,
1907 NULL
1908 );
1909 if (EFI_ERROR (Status)) {
1910 return EFI_NOT_FOUND;
1911 }
1912
1913 //
1914 // Search ControllerDevicePath in MappingDataBase
1915 //
1916 Found = FALSE;
1917 OverrideItem = NULL;
1918 OverrideItemListIndex = GetFirstNode (MappingDataBase);
1919 while (!IsNull (MappingDataBase, OverrideItemListIndex)) {
1920 OverrideItem = CR (OverrideItemListIndex, PLATFORM_OVERRIDE_ITEM, Link, PLATFORM_OVERRIDE_ITEM_SIGNATURE);
1921 DevicePathSize = GetDevicePathSize (ControllerDevicePath);
1922 if (DevicePathSize == GetDevicePathSize (OverrideItem->ControllerDevicePath)) {
1923 if (CompareMem (
1924 ControllerDevicePath,
1925 OverrideItem->ControllerDevicePath,
1926 DevicePathSize
1927 ) == 0
1928 )
1929 {
1930 Found = TRUE;
1931 break;
1932 }
1933 }
1934
1935 OverrideItemListIndex = GetNextNode (MappingDataBase, OverrideItemListIndex);
1936 }
1937
1938 if (!Found) {
1939 ASSERT (Found);
1940 goto Exit;
1941 }
1942
1943 Found = FALSE;
1944 ImageInfoListIndex = GetFirstNode (&OverrideItem->DriverInfoList);
1945 while (!IsNull (&OverrideItem->DriverInfoList, ImageInfoListIndex)) {
1946 DriverImageInfo = CR (ImageInfoListIndex, DRIVER_IMAGE_INFO, Link, DRIVER_IMAGE_INFO_SIGNATURE);
1947 ImageInfoListIndex = GetNextNode (&OverrideItem->DriverInfoList, ImageInfoListIndex);
1948 if (DriverImageDevicePath != NULL) {
1949 //
1950 // Search for the specified DriverImageDevicePath and remove it, then break.
1951 //
1952 DevicePathSize = GetDevicePathSize (DriverImageDevicePath);
1953 if (DevicePathSize == GetDevicePathSize (DriverImageInfo->DriverImagePath)) {
1954 if (CompareMem (
1955 DriverImageDevicePath,
1956 DriverImageInfo->DriverImagePath,
1957 GetDevicePathSize (DriverImageInfo->DriverImagePath)
1958 ) == 0
1959 )
1960 {
1961 Found = TRUE;
1962 FreePool (DriverImageInfo->DriverImagePath);
1963 RemoveEntryList (&DriverImageInfo->Link);
1964 OverrideItem->DriverInfoNum--;
1965 break;
1966 }
1967 }
1968 } else {
1969 //
1970 // Remove all existing driver image info entries, so no break here.
1971 //
1972 Found = TRUE;
1973 FreePool (DriverImageInfo->DriverImagePath);
1974 RemoveEntryList (&DriverImageInfo->Link);
1975 OverrideItem->DriverInfoNum--;
1976 }
1977 }
1978
1979 //
1980 // Confirm all driver image info entries have been removed,
1981 // if DriverImageDevicePath is NULL.
1982 //
1983 if (DriverImageDevicePath == NULL) {
1984 ASSERT (OverrideItem->DriverInfoNum == 0);
1985 }
1986
1987 //
1988 // If Override Item has no driver image info entry, then delete this item.
1989 //
1990 if (OverrideItem->DriverInfoNum == 0) {
1991 FreePool (OverrideItem->ControllerDevicePath);
1992 RemoveEntryList (&OverrideItem->Link);
1993 FreePool (OverrideItem);
1994 }
1995
1996Exit:
1997 if (!Found) {
1998 //
1999 // DriverImageDevicePath is not NULL and cannot be found in the controller's
2000 // driver image info list.
2001 //
2002 return EFI_NOT_FOUND;
2003 }
2004
2005 return EFI_SUCCESS;
2006}
UINT64 UINTN
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:443
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
Definition: BaseLib.h:2884
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
#define MEDIA_FILEPATH_DP
Definition: DevicePath.h:1098
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_MEMMAP_DP
Definition: DevicePath.h:109
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI GetNextDevicePathInstance(IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT UINTN *Size)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DuplicateDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
EFI_DXE_SERVICES * gDS
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
Definition: PrintLib.c:408
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define VOID
Definition: Base.h:269
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define CR(Record, TYPE, Field, TestSignature)
Definition: DebugLib.h:660
UINT32 EFI_FV_FILE_ATTRIBUTES
VOID *EFIAPI GetVariableAndSize(IN CHAR16 *Name, IN EFI_GUID *VendorGuid, OUT UINTN *VariableSize)
BOOLEAN EFIAPI CheckExistInStack(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_STATUS EFIAPI DeleteDriverImage(IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath, IN LIST_ENTRY *MappingDataBase)
EFI_TPL GetCurrentTpl(VOID)
EFI_STATUS EFIAPI PushDevPathStack(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_STATUS EFIAPI PopDevPathStack(OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI DeleteOverridesVariables(VOID)
EFI_STATUS EFIAPI FreeMappingDatabase(IN OUT LIST_ENTRY *MappingDataBase)
EFI_STATUS EFIAPI SaveOverridesMapping(IN LIST_ENTRY *MappingDataBase)
EFI_STATUS EFIAPI CheckMapping(IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath OPTIONAL, IN LIST_ENTRY *MappingDataBase, OUT UINT32 *DriverInfoNum OPTIONAL, OUT UINT32 *DriverImageNO OPTIONAL)
EFI_STATUS EFIAPI ConnectDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect)
EFI_STATUS EFIAPI InsertDriverImage(IN EFI_DEVICE_PATH_PROTOCOL *ControllerDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *DriverImageDevicePath, IN LIST_ENTRY *MappingDataBase, IN UINT32 DriverImageNO)
EFI_STATUS EFIAPI InitOverridesMapping(OUT LIST_ENTRY *MappingDataBase)
EFI_DRIVER_BINDING_PROTOCOL *EFIAPI GetBindingProtocolFromImageHandle(IN EFI_HANDLE ImageHandle, OUT EFI_HANDLE *BindingHandle)
UINTN EFIAPI GetOneItemNeededSize(IN LIST_ENTRY *OverrideItemListIndex)
EFI_STATUS EFIAPI GetDriverFromMapping(IN EFI_HANDLE ControllerHandle, IN OUT EFI_HANDLE *DriverImageHandle, IN LIST_ENTRY *MappingDataBase, IN EFI_HANDLE CallerImageHandle)
EFI_STATUS EFIAPI UpdateFvFileDevicePath(IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, IN EFI_GUID *FileGuid, IN EFI_HANDLE CallerImageHandle)
VOID EFIAPI Exit(IN EFI_STATUS Status)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN EFI_TPL
Definition: UefiBaseType.h:41
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
VOID EFIAPI EfiInitializeFwVolDevicepathNode(IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, IN CONST EFI_GUID *NameGuid)
Definition: UefiNotTiano.c:325
EFI_GUID *EFIAPI EfiGetNameGuidFromFwVolDevicePathNode(IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode)
Definition: UefiNotTiano.c:292
#define EFI_VARIABLE_NON_VOLATILE
@ ByProtocol
Definition: UefiSpec.h:1528
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
Definition: LoadedImage.h:53
Definition: Base.h:213