OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcDeviceTreeLib.c File Reference
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcDeviceTreeLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>

Go to the source code of this file.

Macros

#define DEVICE_TREE_GET_NEXT_PROPERTY(Prop)
 

Functions

STATIC DTEntry DTSkipProperties (IN DTEntry Entry)
 
STATIC DTEntry DTSkipTree (IN DTEntry Root)
 
STATIC DTEntry GetFirstChild (IN DTEntry Parent)
 
STATIC DTEntry GetNextChild (IN DTEntry Sibling)
 
STATIC CONST CHAR8 * GetNextComponent (IN CONST CHAR8 *Cp, IN CHAR8 *Bp)
 
STATIC DTEntry FindChild (IN DTEntry Cur, IN CHAR8 *Buf)
 
EFI_STATUS DTLookupEntry (IN CONST DTEntry SearchPoint, IN CONST CHAR8 *PathName, IN DTEntry *FoundEntry)
 
EFI_STATUS DTCreateEntryIterator (IN CONST DTEntry StartEntry, IN DTEntryIterator *Iterator)
 
EFI_STATUS DTDisposeEntryIterator (IN DTEntryIterator Iterator)
 
EFI_STATUS DTEnterEntry (IN DTEntryIterator Iterator, IN DTEntry ChildEntry)
 
EFI_STATUS DTExitEntry (IN DTEntryIterator Iterator, IN DTEntry *CurrentPosition)
 
EFI_STATUS DTIterateEntries (IN DTEntryIterator Iterator, IN DTEntry *NextEntry)
 
EFI_STATUS DTRestartEntryIteration (IN DTEntryIterator Iterator)
 
EFI_STATUS DTGetProperty (IN CONST DTEntry Entry, IN CHAR8 *PropertyName, IN VOID **PropertyValue, IN UINT32 *PropertySize)
 
EFI_STATUS DTCreatePropertyIterator (IN CONST DTEntry Entry, IN DTPropertyIterator Iterator)
 
EFI_STATUS DTIterateProperties (IN DTPropertyIterator Iterator, IN CHAR8 **FoundProperty)
 
EFI_STATUS DTRestartPropertyIteration (IN DTPropertyIterator Iterator)
 
EFI_STATUS DumpDeviceTreeNodeRecusively (IN DTEntry Entry)
 
VOID DumpDeviceTree (VOID)
 
VOID DTInit (IN VOID *Base, IN UINT32 *Length)
 
UINT32 DTDeleteProperty (IN CHAR8 *NodeName, IN CHAR8 *DeletePropertyName)
 
VOID DTInsertProperty (IN CHAR8 *NodeName, IN CHAR8 *InsertPropertyName, IN CHAR8 *AddPropertyName, IN VOID *AddPropertyValue, IN UINT32 ValueLength, IN BOOLEAN InsertAfter)
 

Variables

STATIC DTEntry mDTRootNode
 
STATIC UINT32 * mDTLength
 
STATIC UINT32 mDTNodeDepth
 
STATIC OpaqueDTPropertyIterator mOpaquePropIter
 

Detailed Description

Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcDeviceTreeLib.c.

Macro Definition Documentation

◆ DEVICE_TREE_GET_NEXT_PROPERTY

#define DEVICE_TREE_GET_NEXT_PROPERTY ( Prop)
Value:
(DTProperty *)(((UINT8 *)(UINTN)(Prop)) \
+ sizeof (*Prop) + ALIGN_VALUE (Prop->Length, sizeof (UINT32)))

Definition at line 31 of file OcDeviceTreeLib.c.

Function Documentation

◆ DTCreateEntryIterator()

EFI_STATUS DTCreateEntryIterator ( IN CONST DTEntry StartEntry,
IN DTEntryIterator * Iterator )

An Entry Iterator maintains three variables that are of interest to clients. First is an "OutermostScope" which defines the outer boundry of the iteration. This is defined by the starting entry and includes that entry plus all of its embedded entries. Second is a "currentScope" which is the entry the iterator is currently in. And third is a "currentPosition" which is the last entry returned during an iteration.

Create Entry Iterator Create the iterator structure. The outermostScope and currentScope of the iterator are set to "startEntry". If "startEntry" = NULL, the outermostScope and currentScope are set to the root entry. The currentPosition for the iterator is set to "nil".

Definition at line 228 of file OcDeviceTreeLib.c.

◆ DTCreatePropertyIterator()

EFI_STATUS DTCreatePropertyIterator ( IN CONST DTEntry Entry,
IN DTPropertyIterator Iterator )

Create Property Iterator Create the property iterator structure. The target entry is defined by entry.

Definition at line 396 of file OcDeviceTreeLib.c.

◆ DTDeleteProperty()

UINT32 DTDeleteProperty ( IN CHAR8 * NodeName,
IN CHAR8 * DeletePropertyName )
Parameters
[in]NodeName
[in]DeletePropertyName

Definition at line 598 of file OcDeviceTreeLib.c.

◆ DTDisposeEntryIterator()

EFI_STATUS DTDisposeEntryIterator ( IN DTEntryIterator Iterator)

Dispose Entry Iterator

Definition at line 262 of file OcDeviceTreeLib.c.

◆ DTEnterEntry()

EFI_STATUS DTEnterEntry ( IN DTEntryIterator Iterator,
IN DTEntry ChildEntry )

Enter Child Entry Move an Entry Iterator into the scope of a specified child entry. The currentScope of the iterator is set to the entry specified in "childEntry". If "childEntry" is nil, the currentScope is set to the entry specified by the currentPosition of the iterator.

Definition at line 278 of file OcDeviceTreeLib.c.

◆ DTExitEntry()

EFI_STATUS DTExitEntry ( IN DTEntryIterator Iterator,
IN DTEntry * CurrentPosition )

Exit to Parent Entry Move an Entry Iterator out of the current entry back into the scope of its parent entry. The currentPosition of the iterator is reset to the current entry (the previous currentScope), so the next iteration call will continue where it left off. This position is returned in parameter "currentPosition".

Definition at line 309 of file OcDeviceTreeLib.c.

◆ DTGetProperty()

EFI_STATUS DTGetProperty ( IN CONST DTEntry Entry,
IN CHAR8 * PropertyName,
IN VOID ** PropertyValue,
IN UINT32 * PropertySize )

Get the value of the specified property for the specified entry.

Definition at line 367 of file OcDeviceTreeLib.c.

◆ DTInit()

VOID DTInit ( IN VOID * Base,
IN UINT32 * Length )
Parameters
[in]BasePointer to the Device Tree
[in]LengthPointer to location containg the Device Tree length

Definition at line 579 of file OcDeviceTreeLib.c.

◆ DTInsertProperty()

VOID DTInsertProperty ( IN CHAR8 * NodeName,
IN CHAR8 * InsertPropertyName,
IN CHAR8 * AddPropertyName,
IN VOID * AddPropertyValue,
IN UINT32 ValueLength,
IN BOOLEAN InsertAfter OPTIONAL )
Parameters
[in]NodeName
[in]InsertPropertyName
[in]AddPropertyName
[in]AddPropertyValue
[in]ValueLength
[in]InsertAfter

Definition at line 661 of file OcDeviceTreeLib.c.

◆ DTIterateEntries()

EFI_STATUS DTIterateEntries ( IN DTEntryIterator Iterator,
IN DTEntry * NextEntry )

Iterate Entries Iterate and return entries contained within the entry defined by the current scope of the iterator. Entries are returned one at a time. When int == kIterationDone, all entries have been exhausted, and the value of nextEntry will be Nil.

Definition at line 335 of file OcDeviceTreeLib.c.

◆ DTIterateProperties()

EFI_STATUS DTIterateProperties ( IN DTPropertyIterator Iterator,
IN CHAR8 ** FoundProperty )

Iterate Properites Iterate and return properties for given entry. EFI_END_OF_MEDIA, all properties have been exhausted.

Definition at line 409 of file OcDeviceTreeLib.c.

◆ DTLookupEntry()

EFI_STATUS DTLookupEntry ( IN CONST DTEntry SearchPoint,
IN CONST CHAR8 * PathName,
IN DTEntry * FoundEntry )

Lookup Entry Locates an entry given a specified subroot (searchPoint) and path name. If the searchPoint pointer is NULL, the path name is assumed to be an absolute path name rooted to the root of the device tree.

Definition at line 177 of file OcDeviceTreeLib.c.

◆ DTRestartEntryIteration()

EFI_STATUS DTRestartEntryIteration ( IN DTEntryIterator Iterator)

Restart Entry Iteration Restart an iteration within the current scope. The iterator is reset such that iteration of the contents of the currentScope entry can be restarted. The outermostScope and currentScope of the iterator are unchanged. The currentPosition for the iterator is set to "nil".

Definition at line 357 of file OcDeviceTreeLib.c.

◆ DTRestartPropertyIteration()

EFI_STATUS DTRestartPropertyIteration ( IN DTPropertyIterator Iterator)

Restart Property Iteration Used to re-iterate over a list of properties. The Property Iterator is reset to the beginning of the list of properties for an entry.

Definition at line 432 of file OcDeviceTreeLib.c.

◆ DTSkipProperties()

STATIC DTEntry DTSkipProperties ( IN DTEntry Entry)

Definition at line 55 of file OcDeviceTreeLib.c.

◆ DTSkipTree()

STATIC DTEntry DTSkipTree ( IN DTEntry Root)

Definition at line 76 of file OcDeviceTreeLib.c.

◆ DumpDeviceTree()

VOID DumpDeviceTree ( VOID )

Definition at line 560 of file OcDeviceTreeLib.c.

◆ DumpDeviceTreeNodeRecusively()

EFI_STATUS DumpDeviceTreeNodeRecusively ( IN DTEntry Entry)

Definition at line 443 of file OcDeviceTreeLib.c.

◆ FindChild()

STATIC DTEntry FindChild ( IN DTEntry Cur,
IN CHAR8 * Buf )

Definition at line 136 of file OcDeviceTreeLib.c.

◆ GetFirstChild()

STATIC DTEntry GetFirstChild ( IN DTEntry Parent)

Definition at line 98 of file OcDeviceTreeLib.c.

◆ GetNextChild()

STATIC DTEntry GetNextChild ( IN DTEntry Sibling)

Definition at line 107 of file OcDeviceTreeLib.c.

◆ GetNextComponent()

STATIC CONST CHAR8 * GetNextComponent ( IN CONST CHAR8 * Cp,
IN CHAR8 * Bp )

Definition at line 116 of file OcDeviceTreeLib.c.

Variable Documentation

◆ mDTLength

STATIC UINT32* mDTLength

Definition at line 43 of file OcDeviceTreeLib.c.

◆ mDTNodeDepth

STATIC UINT32 mDTNodeDepth

Definition at line 45 of file OcDeviceTreeLib.c.

◆ mDTRootNode

STATIC DTEntry mDTRootNode

Definition at line 38 of file OcDeviceTreeLib.c.

◆ mOpaquePropIter

STATIC OpaqueDTPropertyIterator mOpaquePropIter

Definition at line 47 of file OcDeviceTreeLib.c.