]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - include/rm_treeloc.h
Started adding Shared Server implementation
[keystone-rtos/rm-lld.git] / include / rm_treeloc.h
1 /*
2  *  file  rm_treeloc.h
3  *
4  *  Prototypes and data structures for the various RM Trees.
5  *
6  *  ============================================================================
7  *      (C) Copyright 2012-2013, Texas Instruments, Inc.
8  * 
9  *  Redistribution and use in source and binary forms, with or without 
10  *  modification, are permitted provided that the following conditions 
11  *  are met:
12  *
13  *    Redistributions of source code must retain the above copyright 
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  *    Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the 
18  *    documentation and/or other materials provided with the   
19  *    distribution.
20  *
21  *    Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
26  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
27  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
29  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
31  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
34  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
35  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  *  \par
38 */
40 #ifndef RM_TREELOC_H_
41 #define RM_TREELOC_H_
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 /* Standard includes */
48 #include <stdint.h>
50 /* RM external includes */
51 #include <ti/drv/rm/rm.h>
53 /* Tree algorithm includes */
54 #include <ti/drv/rm/util/tree.h>
56 /**********************************************************************
57  *************** Tree Node Data Structure Definitions *****************
58  **********************************************************************/
60 /* NameServer node configuration structure */
61 typedef struct {
62     /* Name to assign to the resource values */
63     char     *objName;
64     /* Resource name assigned to the NameServer name */
65     char     *resourceName;
66     /* Resource base value assigned to the NameServer name */    
67     uint32_t  resourceBase;
68     /* Resource length value (starting from base) assigned to the NameServer name */    
69     uint32_t  resourceLength;
70 } Rm_NameServerNodeCfg;
72 /* NameServer node */
73 typedef struct _Rm_NameServerNode {
74     /* Tree algorithm data structure */
75     RB_ENTRY(_Rm_NameServerNode) linkage;
76     /* Name string */
77     char                         objName[RM_NAME_MAX_CHARS];
78     /* Resource name */
79     char                         resourceName[RM_NAME_MAX_CHARS];
80     /* Resource base value */
81     uint32_t                     resourceBase;
82     /* Resource length value */
83     uint32_t                     resourceLength;
84 } Rm_NameServerNode;
86 /* NameServer tree root entry type definition */
87 typedef RB_HEAD(_Rm_NameServerTree, _Rm_NameServerNode) Rm_NameServerTree;
89 /* Valid instance node */
90 typedef struct _Rm_PolicyValidInstNode {
91     /* Tree algorithm data structure */
92     RB_ENTRY(_Rm_PolicyValidInstNode) linkage;
93     /* Valid instance name string */
94     char                              name[RM_NAME_MAX_CHARS];
95     /* Number of existing resource allocations the instance is
96      * reference in.  Resource frees involving the instance
97      * will decrement this count.  A valid instance node cannot
98      * be deleted until this value is zero */
99     uint32_t                          allocRefCount;
100     /* TRUE: Delete this valid instance node once the allocRefCount
101      *       reaches zero
102      * FALSE: Do not delete */
103     int8_t                            deletePending;
104 } Rm_PolicyValidInstNode;
106 /* Valid instance tree root entry type definition */
107 typedef RB_HEAD(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode) Rm_PolicyValidInstTree;
109 /* Resource node owner linked list node */
110 typedef struct Rm_Owner_s {
111     /* Pointer to the valid instance node that currently
112      * owns or partially owns the resource */
113     Rm_PolicyValidInstNode *instNameNode;
114     /* Link to the next owner of the resoruce if the resource is shared */
115     struct Rm_Owner_s      *nextOwner;
116 } Rm_Owner;
118 /* Resource node */
119 typedef struct _Rm_ResourceNode {
120     /* Tree algorithm data structure */
121     RB_ENTRY(_Rm_ResourceNode) linkage;
122     /* Resource base value */
123     uint32_t                   base;
124     /* Resource length value.  With base this node covers a resource's values
125      * from base to base+length-1 */
126     uint32_t                   length;
127     /* Number of times this resource node has been allocated to a valid
128      * instance.  This value will decrement for each free operation */
129     uint16_t                   allocationCount;
130     /* Linked list of existing owners.  Will be NULL if no owners exist
131      * for the resource node */
132     Rm_Owner                   *ownerList;
133 } Rm_ResourceNode;
135 /* Resource tree root entry type definition */
136 typedef RB_HEAD(_Rm_AllocatorResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
138 /**********************************************************************
139  ****************** Tree Node Function Definitions ********************
140  **********************************************************************/
142 void rmNameServerTreeInv(Rm_NameServerTree *treeRoot);
143 void rmNameServerTreeWb(Rm_NameServerTree *treeRoot);
144 Rm_NameServerNode *rmNameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg);
145 void rmNameServerNodeFree(Rm_NameServerNode *node);
146 int rmNameServerNodeCompare(Rm_NameServerNode *node1, Rm_NameServerNode *node2); 
147 void rmNameServerNodeInv(Rm_NameServerNode *node);
149 void rmPolicyValidInstTreeInv(Rm_PolicyValidInstTree *treeRoot);
150 void rmPolicyValidInstTreeWb(Rm_PolicyValidInstTree *treeRoot);
151 Rm_PolicyValidInstNode *rmPolicyValidInstNodeNew(char *instName);
152 void rmPolicyValidInstNodeFree(Rm_PolicyValidInstNode *node);
153 int rmPolicyValidInstNodeCompare(Rm_PolicyValidInstNode *node1, Rm_PolicyValidInstNode *node2);
154 void rmPolicyValidInstNodeInv(Rm_PolicyValidInstNode *node);
156 void rmResourceTreeInv(Rm_ResourceTree *treeRoot);
157 void rmResourceTreeWb(Rm_ResourceTree *treeRoot);
158 Rm_ResourceNode *rmResourceNodeNew(uint32_t resourceBase, uint32_t resourceLength);
159 void rmResourceNodeFree(Rm_ResourceNode *node);
160 int rmResourceNodeCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2);
161 void rmResourceNodeInv(Rm_ResourceNode *node);
163 /**********************************************************************
164  ******************** Tree Prototype Generation ***********************
165  **********************************************************************/
166  
167 RB_PROTOTYPE(_Rm_NameServerTree, _Rm_NameServerNode, linkage, rmNameServerNodeCompare, rmNameServerNodeInv)
168 RB_PROTOTYPE(_Rm_PolicyValidInstTree, _Rm_PolicyValidInstNode, linkage, rmPolicyValidInstNodeCompare, rmPolicyValidInstNodeInv)
169 RB_PROTOTYPE(_Rm_AllocatorResourceTree, _Rm_ResourceNode, linkage, rmResourceNodeCompare, rmResourceNodeInv)
171 #ifdef __cplusplus
173 #endif
175 #endif /* RM_TREELOC_H_ */