| 639 | /// |
| 640 | |
| 641 | VOID |
| 642 | DTInsertProperty ( |
| 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. |
nothing calls this directly
no test coverage detected