/* * file rm_dtb_utilloc.h * * Private Resource List and Policy DTB Parsing Utilities * * ============================================================================ * (C) Copyright 2012, Texas Instruments, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * \par */ #ifndef RM_DTB_UTILLOC_H_ #define RM_DTB_UTILLOC_H_ #ifdef __cplusplus extern "C" { #endif /********************************************************************** *************Common RM DTB Parsing Defines and Functions************** **********************************************************************/ /** * @brief LIBFDT's return codes start at 1. Map a return value of 0 to an okay result * from the LIBFDT APIs */ #define RM_DTB_UTIL_RESULT_OKAY 0 /** * @brief DTB starting node offset for parsing */ #define RM_DTB_UTIL_STARTING_NODE_OFFSET 0 /** * @brief DTB starting depth for parsing */ #define RM_DTB_UTIL_STARTING_DEPTH 0 typedef struct { uint32_t base; uint32_t length; void *nextRange; } Rm_ResourceRange; typedef struct { uint32_t value; void *nextValue; } Rm_ResourceValue; /********************************************************************** ***********Resource List DTB Parsing Defines and Functions************ **********************************************************************/ /** * @brief Linux DTB alias offset not set */ #define RM_DTB_LINUX_ALIAS_OFFSET_NOT_SET 0xFFFF typedef enum { /** Resource DTB unknown property type */ Rm_resourcePropType_UNKNOWN = 0, /** Resource DTB device name property type */ Rm_resourcePropType_DEVICE_NAME = 1, /** Resource DTB resource range property type */ Rm_resourcePropType_RESOURCE_RANGE = 2, /** Resource DTB resource alias path in Linux DTB */ Rm_resourcePropType_RESOURCE_LINUX_ALIAS = 3, /** Resource DTB NameServer assignment property type */ Rm_resourcePropType_NSASSIGNMENT = 4, } Rm_ResourcePropType; typedef struct { char *path; uint32_t baseOffset; uint32_t lengthOffset; void *nextLinuxAlias; } Rm_LinuxAlias; typedef struct { char *nsName; uint32_t resourceBase; uint32_t resourceLength; void *nextNsAssignment; } Rm_NsAssignment; Rm_ResourcePropType Rm_resourceGetPropertyType(const char *propertyName); char *Rm_resourceExtractDeviceName(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_resourceFreeDeviceName(char *deviceName); Rm_ResourceRange *Rm_resourceExtractRange(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_resourceFreeRange(Rm_ResourceRange *rangeList); Rm_LinuxAlias *Rm_resourceExtractLinuxAlias(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_resourceFreeLinuxAlias(Rm_LinuxAlias *aliasList); Rm_NsAssignment *Rm_resourceExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_resourceFreeNsAssignmentList(Rm_NsAssignment *nsAssignmentList); /********************************************************************** ***************Policy DTB Parsing Defines and Functions*************** **********************************************************************/ /** * @brief Depth of the RM instance nodes in the policy DTB */ #define RM_POLICY_DTB_INSTANCE_DEPTH 1 typedef enum { /** Policy DTB unknown property type */ Rm_policyPropType_UNKNOWN = 0, /** Policy DTB resource assigned ranges property type */ Rm_policyPropType_ASSIGNED_RANGES = 1, /** Policy DTB resource allocation sizes property type */ Rm_policyPropType_ALLOCATION_SIZES = 2, /** Policy DTB assigned NameServer names property type */ Rm_policyPropType_ASSIGNED_NAMES = 3, /** Policy DTB allocation alignments property type */ Rm_policyPropType_ALLOCATION_ALIGNMENTS = 4, } Rm_PolicyPropType; typedef struct { char *assignedName; void *nextAssignedName; } Rm_AssignedNsNames; Rm_PolicyPropType Rm_policyGetPropertyType(const char *propertyName); Rm_ResourceRange *Rm_policyExtractAssignedRanges(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_policyFreeAssignedRanges(Rm_ResourceRange *rangeList); Rm_ResourceValue *Rm_policyExtractAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_policyFreeAllocationSizes(Rm_ResourceValue *allocationSizeList); Rm_AssignedNsNames *Rm_policyExtractAssignedNames(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_policyFreeAssignmentNames(Rm_AssignedNsNames *assignedNsNamesList); Rm_ResourceValue *Rm_policyExtractResourceAlignments(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_policyFreeResourceAlignments (Rm_ResourceValue *alignmentList); /********************************************************************** ****************Linux DTB Parsing Defines and Functions*************** **********************************************************************/ typedef struct { uint32_t value; void *nextValue; } Rm_LinuxValueRange; Rm_LinuxValueRange *Rm_linuxExtractValues(const void *dtbDataPtr, int32_t dtbDataLen); void Rm_linuxFreeValues(Rm_LinuxValueRange *valueList); #ifdef __cplusplus } #endif #endif /* RM_DTB_UTILLOC_H_ */