MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / DTInsertProperty

Function DTInsertProperty

Library/DeviceTreeLib/DeviceTreeLib.c:641–715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639///
640
641VOID
642DTInsertProperty (
643 IN CHAR8 *NodeName,
644 IN CHAR8 *InsertPropertyName,
645 IN CHAR8 *AddPropertyName,
646 IN VOID *AddPropertyValue,
647 IN UINT32 ValueLength,
648 IN BOOLEAN InsertAfter
649 )
650{
651 DTEntry Node;
652 DTPropertyIterator PropIter;
653 DTProperty *Property;
654 UINT32 EntryLength;
655 CHAR8 *DeviceTree;
656 CHAR8 *DeviceTreeEnd;
657 CHAR8 *InsertPosition;
658
659 PropIter = &mOpaquePropIter;
660 EntryLength = ALIGN_VALUE (ValueLength, sizeof (UINT32));
661 DeviceTree = NULL;
662 DeviceTreeEnd = (CHAR8 *)mDTRootNode + *mDTLength;
663 InsertPosition = NULL;
664
665 if (!EFI_ERROR(DTLookupEntry (NULL, NodeName, &Node))) {
666 if (!EFI_ERROR(DTCreatePropertyIterator (Node, PropIter))) {
667 while (!EFI_ERROR(DTIterateProperties (PropIter, &DeviceTree))) {
668 InsertPosition = DeviceTree;
669 if (AsciiStrStr (InsertPosition, InsertPropertyName) != NULL) {
670 break;
671 }
672 }
673
674 if (InsertAfter) {
675 Property = (DTProperty *) InsertPosition;
676 InsertPosition += sizeof (DTProperty) + ALIGN_VALUE (Property->Length, sizeof (UINT32));
677 }
678
679 Property = (DTProperty *)InsertPosition;
680
681 //
682 // Make space.
683 //
684 CopyMem(InsertPosition + sizeof (DTProperty) + EntryLength, InsertPosition, DeviceTreeEnd - InsertPosition);
685 ZeroMem (InsertPosition, sizeof (DTProperty) + EntryLength);
686
687 //
688 // Insert Property Name.
689 //
690 CopyMem(Property->Name, AddPropertyName, AsciiStrLen(AddPropertyName));
691
692 //
693 // Insert Property Value Length.
694 //
695 Property->Length = ValueLength;
696
697 //
698 // Insert Property Value.

Callers

nothing calls this directly

Calls 6

AsciiStrLenFunction · 0.85
DTLookupEntryFunction · 0.70
DTCreatePropertyIteratorFunction · 0.70
DTIteratePropertiesFunction · 0.70
CopyMemFunction · 0.50
ZeroMemFunction · 0.50

Tested by

no test coverage detected