Added DTB value extraction functions for Resource List and Policy DTBs
authorJustin Sobota <jsobota@ti.com>
Fri, 30 Nov 2012 16:49:22 +0000 (11:49 -0500)
committerJustin Sobota <jsobota@ti.com>
Fri, 30 Nov 2012 16:49:22 +0000 (11:49 -0500)
15 files changed:
device/global-policy.dtb [new file with mode: 0644]
device/resources.dtb [new file with mode: 0644]
device/resources2.dtb [new file with mode: 0644]
device/tci6614-global-policy.dts [new file with mode: 0644]
device/tci6614-resources.dts [new file with mode: 0644]
device/test_tree1.dtb [new file with mode: 0644]
include/rm_dtb_utilloc.h [new file with mode: 0644]
include/rm_loc.h
rm_osal.h
src/Module.xs
src/libfdt/TODO [new file with mode: 0644]
src/libfdt/libfdt_env.h
src/libfdt/libfdt_env.h.original [deleted file]
src/rm.c
src/rm_transport.c

diff --git a/device/global-policy.dtb b/device/global-policy.dtb
new file mode 100644 (file)
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 (file)
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 (file)
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 (file)
index 0000000..6ff1de2
--- /dev/null
@@ -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 num> - 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 = <n>;
+
+        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 (file)
index 0000000..0505e96
--- /dev/null
@@ -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 (file)
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 (file)
index 0000000..3b5749b
--- /dev/null
@@ -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_ */
+
index efaf817a4c620cc6a42ebf691a58627a449ae72c..e047bf8b43052d71749de22d11d3a907d4aa0579 100644 (file)
@@ -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;
 
index 32b22e692dcdecac0d11594975b649ee9fd48517..9e92e7e79734354290815f8a5cf32453ae233ed0 100644 (file)
--- 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);
index ff372df45edef0318337e64f83c006f6db7bdd21..16de9a4f50f63e861c547c645de5ae642eb5143f 100644 (file)
@@ -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 (file)
index 0000000..288437e
--- /dev/null
@@ -0,0 +1,3 @@
+- Tree traversal functions
+- Graft function
+- Complete libfdt.h documenting comments
index e80b0f8b2be88318b921f143c93f2539b1896bf9..449bf602daf1ff59a1cfef48bc4b50c15940112b 100644 (file)
@@ -5,19 +5,19 @@
 #include <stdint.h>
 #include <string.h>
 
-#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 (file)
index 449bf60..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _LIBFDT_ENV_H
-#define _LIBFDT_ENV_H
-
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-
-#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 */
index aca11046218bf52a94fb73cfa601f356cae59a5b..e14884ba77a56d696f22a3f316fc142479c2e6cc 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -53,6 +53,7 @@
 #include <ti/drv/rm/include/rm_transportloc.h>\r
 #include <ti/drv/rm/include/rm_servicesloc.h>\r
 #include <ti/drv/rm/include/rm_nameserverloc.h>\r
+#include <ti/drv/rm/include/rm_dtb_utilloc.h>\r
 \r
 /* RM LIBFDT includes */\r
 #include <ti/drv/rm/src/libfdt/libfdt.h>\r
@@ -204,7 +205,7 @@ int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
         }\r
 \r
         /* Free the memory associated with the transaction. */\r
-        Rm_osalFree((void *)transaction, sizeof(Rm_Transaction), false);\r
+        Rm_osalFree((void *)transaction, sizeof(Rm_Transaction));\r
     }\r
 \r
     Rm_osalMtCsExit(key);\r
@@ -645,10 +646,13 @@ void reverse_properties(void *fdt, int32_t offset)
 {\r
        int32_t len;\r
        const char *name;\r
-    char nameTest[] = "resource-range";\r
+    char *resourceName, *allocator;\r
        const void *data;\r
-    uint32_t *dataPtr;\r
-    uint32_t i;\r
+    Rm_ResourceRange *range = NULL;\r
+    Rm_ResourceRange *startOfRange = NULL;\r
+    Rm_NsAssignment *nsAssignment = NULL;\r
+    Rm_NsAssignment *startOfNsAssignment = NULL;\r
+    Rm_ResourcePropType propType;\r
 \r
        data = fdt_getprop_by_offset(fdt, offset, &name, &len);\r
     if (!data)\r
@@ -656,12 +660,37 @@ void reverse_properties(void *fdt, int32_t offset)
     else\r
     {\r
         Rm_osalLog("Property name: %s with length: %d offset: %d and address: %x\n", name, len, offset, data);\r
-        Rm_osalLog("Property value: %s\n", (char *)data);\r
-        \r
-        if(strcmp(nameTest, name) == 0)\r
+\r
+        propType = Rm_resourceGetPropertyType(name);\r
+        if (propType == Rm_resourcePropType_RESOURCE_NAME)\r
+        {\r
+            Rm_osalLog("Resource Name: %s\n", resourceName = Rm_resourceExtractResourceName(data, len));\r
+            Rm_resourceFreeResourceName(resourceName);\r
+        }\r
+        else if (propType == Rm_resourcePropType_RESOURCE_RANGE)\r
+        {\r
+            startOfRange = range = Rm_resourceExtractResourceRange(data, len);\r
+            while (range != NULL)\r
+            {\r
+                Rm_osalLog("Resource base: %d and length: %d\n", range->base, range->length);\r
+                range = (Rm_ResourceRange *) range->nextRange;\r
+            }\r
+            Rm_resourceFreeResourceRange(startOfRange);\r
+        }\r
+        else if (propType == Rm_resourcePropType_NSASSIGNMENT)\r
+        {\r
+            startOfNsAssignment = nsAssignment = Rm_resourceExtractNsAssignment(data, len);\r
+            while (nsAssignment != NULL)\r
+            {\r
+                Rm_osalLog("NameServer assignment name: %s and value: %d\n", nsAssignment->nsName, nsAssignment->resourceValue);\r
+                nsAssignment = (Rm_NsAssignment *) nsAssignment->nextNsAssignment;\r
+            }\r
+            Rm_resourceFreeNsAssignmentList(startOfNsAssignment);\r
+        }   \r
+        else if (propType == Rm_resourcePropType_RESOURCE_ALLOCATOR)\r
         {\r
-            dataPtr = (uint32_t *)data;\r
-            Rm_osalLog("Range value: %d %d\n", dtb32_to_cpu(dataPtr[0]), dtb32_to_cpu(dataPtr[1]));\r
+            Rm_osalLog("Resource Allocator: %s\n", allocator = Rm_resourceExtractResourceAllocator(data, len));\r
+            Rm_resourceFreeResourceAllocator(allocator);\r
         }\r
     }\r
 \r
index bbb9f510576c219132f075316cff418ff87ee665..9864eae679a78ed33991a4d10a8b8b8488d05976 100644 (file)
@@ -222,7 +222,7 @@ Rm_TransportResult Rm_transportNodeDelete(Rm_Inst *rmInst, Rm_TransportHandle tr
         }\r
 \r
         /* Free the memory associated with the node. */\r
-        Rm_osalFree((void *) transportNode, sizeof(Rm_TransportNode), false);\r
+        Rm_osalFree((void *) transportNode, sizeof(Rm_TransportNode));\r
     }\r
 \r
     return (RM_TRANSPORT_SUCCESSFUL);\r