From: Justin Sobota Date: Fri, 30 Nov 2012 16:49:22 +0000 (-0500) Subject: Added DTB value extraction functions for Resource List and Policy DTBs X-Git-Tag: DEV.RM_LLD.02.00.00.01~10^2~34 X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Frm-lld.git;a=commitdiff_plain;h=eba196944f599e819f175d75816ca9a4c8d0a411 Added DTB value extraction functions for Resource List and Policy DTBs --- diff --git a/device/global-policy.dtb b/device/global-policy.dtb new file mode 100644 index 0000000..2d18b06 Binary files /dev/null and b/device/global-policy.dtb differ diff --git a/device/resources.dtb b/device/resources.dtb new file mode 100644 index 0000000..8b59a9d Binary files /dev/null and b/device/resources.dtb differ diff --git a/device/resources2.dtb b/device/resources2.dtb new file mode 100644 index 0000000..43ee8c7 Binary files /dev/null and b/device/resources2.dtb differ diff --git a/device/tci6614-global-policy.dts b/device/tci6614-global-policy.dts new file mode 100644 index 0000000..6ff1de2 --- /dev/null +++ b/device/tci6614-global-policy.dts @@ -0,0 +1,97 @@ +/dts-v1/; + +/ { + policy-type = "global"; /* Policy type i.e. global-policy or + * startup-policy */ + + /* Format for defining resources available to all RM instances and system + * tasks */ + unrestricted { + /* System resources with resource-name that matches a resource name + * provided in both the global device list and by components + * utilizing RM */ + timers { + /* resource name property where the name provided must match a + * resource name defined in a component utilizing RM */ + resource-name = "timers"; + /* assigned range property - defines the range of this resource + * available to the instance node. + * The format is - base = the first value in the range + * of the available resource + * num = number of this type of + * resource starting at base */ + assigned-ranges = <0 5 7 13>; /* range specifies 6 isn't used */ + /* Maximum allocatable resource block size. Block allocations + * typically used for resources with large pools such as general + * purpose QM queues and memory */ + allocation-size = <1>; + /* Name resources of this type registered with the NameServer that + * are available. Name must match a name registered with the + * NameServer */ + assigned-ns-names = "Shared_Timer","The_Other_Timer"; + }; + qmss { + qmss-gp-queues { + resource-name = "general-queues"; + assigned-ranges = <0 2000>; + allocation-sizes = <32>; + }; + qmss-accum-queues { + resource-name = "accumulator-queues"; + assigned-ranges = <4000 32>; + allocation-sizes = <1>; + }; + }; + }; + + /* Format for assigning resources to specific RM instances */ + rm-inst0 { + /* instance-name must match the instName provided to the Rm_init + * API when creating the RM instance */ + instance-name = "RM_Server"; + + timers { + resource-name = "timers"; + assigned-ranges = <14 15>; + allocation-sizes = <1>; + }; + qmss { + qmss-gp-queues { + resource-name = "general-queues"; + assigned-range = <2000 1000>; + allocation-sizes = <32>; + }; + }; + }; + + /* Format for assigning resources to specific RM instances */ + rm-inst1 { + instance-name = "RM_Client"; + + qmss { + qmss-gp-queues { + resource-name = "general-queues"; + assigned-ranges = <3000 1000>; + allocation-sizes = <32>; + }; + }; + }; + + /* Format for assigning resources to specific system tasks */ + system-task0 { + /* [BIOS-ONLY] task-name must match the taskName provided to BIOS + * when creating the task */ + task-name = "test-task"; + /* [LINUX-ONLY] task-id must match the PID assigned by Linux when + * a task is created */ + // task-id = ; + + timers { + resource-name = "timers"; + assigned-ranges = <16>; + allocation-sizes = <1>; + }; + }; +}; + + diff --git a/device/tci6614-resources.dts b/device/tci6614-resources.dts new file mode 100644 index 0000000..0505e96 --- /dev/null +++ b/device/tci6614-resources.dts @@ -0,0 +1,60 @@ +/dts-v1/; + +/ { + device-name = "TCI6614"; + + /* Device Resource Definitions */ + + timers { + resource-name = "timers"; /* BIOS will have a resource defined with + * resourceName "Timers" when requesting + * timer services from the RM */ + resource-range = <0 16>; /* 16 Timers in the device starting at index 0 and + * ending at index 15 */ + allocator = "integer"; /* Initialize and use an integer allocator + * for the timer resource */ + ns-assignment = "Shared_Timer" , <56>; /* Initialize timer 5 as a named + * resource for sharing via the RM + * nameserver by name + * Shared_Timer */ + ns-assign1 = "this" , <1000000>; /* Initialize timer 5 as a named + * resource for sharing via the RM + * nameserver by name + * Shared_Timer */ + ns-assign2 = "Shared_Timers" , <356>; /* Initialize timer 5 as a named + * resource for sharing via the RM + * nameserver by name + * Shared_Timer */ + ns-assign3 = "Shared_Timers" , <56>; /* Initialize timer 5 as a named + * resource for sharing via the RM + * nameserver by name + * Shared_Timer */ + }; + + /* Multiple resource definition for QMSS since there are different queue + * types */ + qmss { + qmss-gp-queues { + resource-name = "general-queues"; /* QMSS LLD will have a resource + * defined with resourceName + * "GP-Queues" when requesting + * queue services from the RM */ + resource-range = <0 4000>; /* Device has 4000 general purpose queues + * starting at index 0 and ending at index + * 3999 */ + allocator = "tree"; /* Initialize and use a tree allocator + * for the general purpose queues */ + }; + qmss-accum-queues { + resource-name = "accumulator-queues"; /* QMSS LLD will have a resource + * defined with resourceName + * "Accum-Queues" when requesting + * queue services from the RM */ + resource-range = <4001 32>; /* Device has 32 accumulator queues + * starting at index 4000 and ending at + * index 4031 */ + allocator = "integer"; /* Initialize and use an integer allocator + * for the accumulator queues */ + }; + }; +}; diff --git a/device/test_tree1.dtb b/device/test_tree1.dtb new file mode 100644 index 0000000..e137200 Binary files /dev/null and b/device/test_tree1.dtb differ diff --git a/include/rm_dtb_utilloc.h b/include/rm_dtb_utilloc.h new file mode 100644 index 0000000..3b5749b --- /dev/null +++ b/include/rm_dtb_utilloc.h @@ -0,0 +1,142 @@ +/* + * 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************** + **********************************************************************/ + +typedef struct { + uint32_t base; + uint32_t length; + void *nextRange; +} Rm_ResourceRange; + +/********************************************************************** + ***********Resource List DTB Parsing Defines and Functions************ + **********************************************************************/ + +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 name property type */ + Rm_resourcePropType_RESOURCE_NAME = 2, + /** Resource DTB resource range property type */ + Rm_resourcePropType_RESOURCE_RANGE = 3, + /** Resource DTB resource allocator property type */ + Rm_resourcePropType_RESOURCE_ALLOCATOR = 4, + /** Resource DTB NameServer assignment property type */ + Rm_resourcePropType_NSASSIGNMENT = 5, +} Rm_ResourcePropType; + +typedef struct { + char *nsName; + uint32_t resourceValue; + 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); +char *Rm_resourceExtractResourceName(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_resourceFreeResourceName(char *resourceName); +Rm_ResourceRange *Rm_resourceExtractResourceRange(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_resourceFreeResourceRange(Rm_ResourceRange *rangeList); +char *Rm_resourceExtractResourceAllocator(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_resourceFreeResourceAllocator(char *resourceAllocatorType); +Rm_NsAssignment *Rm_resourceExtractNsAssignment(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_resourceFreeNsAssignmentList(Rm_NsAssignment *nsAssignmentList); + +/********************************************************************** + ***************Policy DTB Parsing Defines and Functions*************** + **********************************************************************/ + +typedef enum { + /** Policy DTB unknown property type */ + Rm_policyPropType_UNKNOWN = 0, + /** Policy DTB policy type property type */ + Rm_policyPropType_POLICY_TYPE = 1, + /** Policy DTB instance name property type */ + Rm_policyPropType_INSTANCE_NAME = 2, + /** Policy DTB resource name property type */ + Rm_policyPropType_RESOURCE_NAME = 3, + /** Policy DTB resource assigned ranges property type */ + Rm_policyPropType_RESOURCE_ASSIGNED_RANGES = 4, + /** Policy DTB resource allocation sizes property type */ + Rm_policyPropType_RESOURCE_ALLOCATION_SIZES = 5, + /** Policy DTB assigned NameServer names property type */ + Rm_policyPropType_ASSIGNED_NS_NAMES = 6, +} Rm_PolicyPropType; + +typedef struct { + uint32_t allocationSize; + void *nextAllocationSize; +} Rm_AllocationSize; + +typedef struct { + char *assignedName; + void *nextAssignedName; +} Rm_AssignedNsNames; + +Rm_PolicyPropType Rm_policyGetPropertyType(const char *propertyName); +char *Rm_policyExtractPolicyType(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_policyFreePolicyType(char *policyType); +char *Rm_policyExtractInstanceName(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_policyFreeInstanceName(char *instanceName); +Rm_ResourceRange *Rm_policyExtractResourceAssignedRanges(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_policyFreeResourceAssignedRanges(Rm_ResourceRange *rangeList); +Rm_AllocationSize *Rm_policyExtractAllocationSizes(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_policyFreeAllocationSizesPropList(Rm_AllocationSize *allocationSizeList); +Rm_AssignedNsNames *Rm_policyExtractAssignedNsNames(const void *dtbDataPtr, int32_t dtbDataLen); +void Rm_policyFreeAssignmentNsNamesList(Rm_AssignedNsNames *assignedNsNamesList); + +#ifdef __cplusplus +} +#endif + +#endif /* RM_DTB_UTILLOC_H_ */ + diff --git a/include/rm_loc.h b/include/rm_loc.h index efaf817..e047bf8 100644 --- a/include/rm_loc.h +++ b/include/rm_loc.h @@ -1,5 +1,5 @@ /* - * file rmloc.h + * file rm_loc.h * * General private data structures of Resource Manager. * @@ -118,15 +118,6 @@ typedef struct #define RM_MAX_POLICY_SIZE_BYTES (64) // Placeholder: This will change // during development - -#define var(n) ((uint32_t)((uint8_t *)&x)[n]) -static inline uint32_t dtb32_to_cpu(uint32_t x) -{ - return (var(0) << 24) | (var(1) << 16) | (var(2) << 8) | var(3); -} -#define cpu_to_dtb32(x) fdt32_to_cpu(x) - - /** Pointer to RM instance's transport routing map */ typedef void *Rm_TransportRouteMap; diff --git a/rm_osal.h b/rm_osal.h index 32b22e6..9e92e7e 100644 --- a/rm_osal.h +++ b/rm_osal.h @@ -83,7 +83,7 @@ extern void* Osal_rmMalloc (uint32_t num_bytes); -extern void Osal_rmFree (void *ptr, uint32_t size, bool shared); +extern void Osal_rmFree (void *ptr, uint32_t size); extern void* Osal_rmCsEnter (void); extern void Osal_rmCsExit (void *CsHandle); extern void* Osal_rmMtCsEnter (void); diff --git a/src/Module.xs b/src/Module.xs index ff372df..16de9a4 100644 --- a/src/Module.xs +++ b/src/Module.xs @@ -18,6 +18,7 @@ var rmFile = [ "src/rm_policy.c", "src/rm_services.c", "src/rm_transport.c", + "src/rm_dtb_util.c", "src/libfdt/fdt.c", "src/libfdt/fdt_ro.c", "src/libfdt/fdt_rw.c", diff --git a/src/libfdt/TODO b/src/libfdt/TODO new file mode 100644 index 0000000..288437e --- /dev/null +++ b/src/libfdt/TODO @@ -0,0 +1,3 @@ +- Tree traversal functions +- Graft function +- Complete libfdt.h documenting comments diff --git a/src/libfdt/libfdt_env.h b/src/libfdt/libfdt_env.h index e80b0f8..449bf60 100644 --- a/src/libfdt/libfdt_env.h +++ b/src/libfdt/libfdt_env.h @@ -5,19 +5,19 @@ #include #include -#define _A(n) ((unsigned long long)((uint8_t *)&x)[n]) +#define _B(n) ((unsigned long long)((uint8_t *)&x)[n]) static inline uint32_t fdt32_to_cpu(uint32_t x) { - return (_A(0) << 24) | (_A(1) << 16) | (_A(2) << 8) | _A(3); + return (_B(0) << 24) | (_B(1) << 16) | (_B(2) << 8) | _B(3); } #define cpu_to_fdt32(x) fdt32_to_cpu(x) static inline uint64_t fdt64_to_cpu(uint64_t x) { - return (_A(0) << 56) | (_A(1) << 48) | (_A(2) << 40) | (_A(3) << 32) - | (_A(4) << 24) | (_A(5) << 16) | (_A(6) << 8) | _A(7); + return (_B(0) << 56) | (_B(1) << 48) | (_B(2) << 40) | (_B(3) << 32) + | (_B(4) << 24) | (_B(5) << 16) | (_B(6) << 8) | _B(7); } #define cpu_to_fdt64(x) fdt64_to_cpu(x) -#undef _A +#undef _B #endif /* _LIBFDT_ENV_H */ diff --git a/src/libfdt/libfdt_env.h.original b/src/libfdt/libfdt_env.h.original deleted file mode 100644 index 449bf60..0000000 --- a/src/libfdt/libfdt_env.h.original +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _LIBFDT_ENV_H -#define _LIBFDT_ENV_H - -#include -#include -#include - -#define _B(n) ((unsigned long long)((uint8_t *)&x)[n]) -static inline uint32_t fdt32_to_cpu(uint32_t x) -{ - return (_B(0) << 24) | (_B(1) << 16) | (_B(2) << 8) | _B(3); -} -#define cpu_to_fdt32(x) fdt32_to_cpu(x) - -static inline uint64_t fdt64_to_cpu(uint64_t x) -{ - return (_B(0) << 56) | (_B(1) << 48) | (_B(2) << 40) | (_B(3) << 32) - | (_B(4) << 24) | (_B(5) << 16) | (_B(6) << 8) | _B(7); -} -#define cpu_to_fdt64(x) fdt64_to_cpu(x) -#undef _B - -#endif /* _LIBFDT_ENV_H */ diff --git a/src/rm.c b/src/rm.c index aca1104..e14884b 100644 --- a/src/rm.c +++ b/src/rm.c @@ -53,6 +53,7 @@ #include #include #include +#include /* RM LIBFDT includes */ #include @@ -204,7 +205,7 @@ int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId) } /* Free the memory associated with the transaction. */ - Rm_osalFree((void *)transaction, sizeof(Rm_Transaction), false); + Rm_osalFree((void *)transaction, sizeof(Rm_Transaction)); } Rm_osalMtCsExit(key); @@ -645,10 +646,13 @@ void reverse_properties(void *fdt, int32_t offset) { int32_t len; const char *name; - char nameTest[] = "resource-range"; + char *resourceName, *allocator; const void *data; - uint32_t *dataPtr; - uint32_t i; + Rm_ResourceRange *range = NULL; + Rm_ResourceRange *startOfRange = NULL; + Rm_NsAssignment *nsAssignment = NULL; + Rm_NsAssignment *startOfNsAssignment = NULL; + Rm_ResourcePropType propType; data = fdt_getprop_by_offset(fdt, offset, &name, &len); if (!data) @@ -656,12 +660,37 @@ void reverse_properties(void *fdt, int32_t offset) else { Rm_osalLog("Property name: %s with length: %d offset: %d and address: %x\n", name, len, offset, data); - Rm_osalLog("Property value: %s\n", (char *)data); - - if(strcmp(nameTest, name) == 0) + + propType = Rm_resourceGetPropertyType(name); + if (propType == Rm_resourcePropType_RESOURCE_NAME) + { + Rm_osalLog("Resource Name: %s\n", resourceName = Rm_resourceExtractResourceName(data, len)); + Rm_resourceFreeResourceName(resourceName); + } + else if (propType == Rm_resourcePropType_RESOURCE_RANGE) + { + startOfRange = range = Rm_resourceExtractResourceRange(data, len); + while (range != NULL) + { + Rm_osalLog("Resource base: %d and length: %d\n", range->base, range->length); + range = (Rm_ResourceRange *) range->nextRange; + } + Rm_resourceFreeResourceRange(startOfRange); + } + else if (propType == Rm_resourcePropType_NSASSIGNMENT) + { + startOfNsAssignment = nsAssignment = Rm_resourceExtractNsAssignment(data, len); + while (nsAssignment != NULL) + { + Rm_osalLog("NameServer assignment name: %s and value: %d\n", nsAssignment->nsName, nsAssignment->resourceValue); + nsAssignment = (Rm_NsAssignment *) nsAssignment->nextNsAssignment; + } + Rm_resourceFreeNsAssignmentList(startOfNsAssignment); + } + else if (propType == Rm_resourcePropType_RESOURCE_ALLOCATOR) { - dataPtr = (uint32_t *)data; - Rm_osalLog("Range value: %d %d\n", dtb32_to_cpu(dataPtr[0]), dtb32_to_cpu(dataPtr[1])); + Rm_osalLog("Resource Allocator: %s\n", allocator = Rm_resourceExtractResourceAllocator(data, len)); + Rm_resourceFreeResourceAllocator(allocator); } } diff --git a/src/rm_transport.c b/src/rm_transport.c index bbb9f51..9864eae 100644 --- a/src/rm_transport.c +++ b/src/rm_transport.c @@ -222,7 +222,7 @@ Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst, Rm_TransportHandle tr } /* Free the memory associated with the node. */ - Rm_osalFree((void *) transportNode, sizeof(Rm_TransportNode), false); + Rm_osalFree((void *) transportNode, sizeof(Rm_TransportNode)); } return (RM_TRANSPORT_SUCCESSFUL);