]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - include/rm_loc.h
Linux-dtb-alias property cleanup
[keystone-rtos/rm-lld.git] / include / rm_loc.h
1 /*
2  *  file  rm_loc.h
3  *
4  *  General private data structures of Resource Manager.
5  *
6  *  ============================================================================
7  *      (C) Copyright 2012, 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 RMLOC_H_
41 #define RMLOC_H_
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 /* RM external includes */
48 #include <ti/drv/rm/rm_services.h>
49 #include <ti/drv/rm/rm_policy.h>
50 #include <ti/drv/rm/rm_transport.h>
52 /* AVL BBST includes */
53 #include <ti/drv/rm/include/tree.h>
55 /** String stored for resource elements that are not currently allocated to anyone.  If the
56  *  resource is allocated the allocatedTo field will be populated with the RM instance
57  *  name it was allocated to. */
58 #define RM_NOT_ALLOCATED_STRING "\0"
59 /** String stored for resource elements that are reserved by the Linux kernel.  These
60  *  resources will be in use for the lifetime of the system */
61 #define RM_ALLOCATED_TO_LINUX "Linux-Kernel"
63 /** Maximum size of a transmittable RM policy in bytes */
64 #define RM_MAX_POLICY_SIZE_BYTES (64)  // Placeholder: This will change 
65                                        // during development
67 /** Pointer to RM instance's transport routing map */
68 typedef void *Rm_TransportRouteMap;
70 /** Pointer to RM instance's transaction queue */
71 typedef void *Rm_TransactionQueue;
73 /** Pointer to the RM instance's allocators */
74 typedef void *Rm_Allocators;
76 /** Pointer to the RM instance's NameServer (Valid only on Server) */
77 typedef void *Rm_NameServer;
79 /**
80  * @brief RM protocol packet resource information
81  */
82 typedef struct {
83     /** Resource name of resource affected by command */
84     char name[RM_RESOURCE_NAME_MAX_CHARS];
85     /** If applicable, start of resource range affected by command.  If
86      *  RM_RESOURCE_UNSPECIFIED is assigned the higher level RM agent*/
87     int32_t base;
88     /** If applicable, number of specified resource, starting from base, affected by command */
89     uint32_t length;
90     /** If applicable, the alignment of the resource affected by the command */
91     int32_t alignment;
92     /** If applicable, the NameServer name assigned to the specified
93      *  resource.  Used for commands centering on RM NameServer actions */
94     char nsName[RM_RESOURCE_NAME_MAX_CHARS];
95 } Rm_ResourceInfo;
97 /**
98  * @brief RM transactions are the internalized version of service requests received 
99  *        from components and RM commands received from other RM instances.
100  *        Transactions that cannot immediately be serviced are placed in the RM
101  *        instance's transaction queue.  The transactions track all service
102  *        requests within the RM infrastructure.
103  */
104 typedef struct {
105     /** Transaction service type */
106     Rm_ServiceType type;
107     /** Local ID of the transaction. */
108     uint32_t localId;
109     /** ID of transaction on lower level RM instance that generated the
110      *  packet that resulted in the creation of the transaction.  The
111      *  originating ID will be placed in the transaction's response packet
112      *  to the lower level RM instance.  The lower level RM instance will 
113      *  match the response packet with the originating request using the ID */
114     uint32_t remoteOriginatingId;
115     /** Name of the RM instance the RM packet, that spawned the transaction,
116      *  originated from */
117     char pktSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];
118     /** Transaction's associated callback function */
119     Rm_ServiceCallback callback;
120     /** Transaction state.  The codes are externally visible and tracked
121      *  in rmservices.h */
122     int32_t state;
123     /** Name of the RM instance the service originated from */
124     char serviceSrcInstName[RM_INSTANCE_NAME_MAX_CHARS];    
125     /** Resource information */
126     Rm_ResourceInfo resourceInfo;
127     /** Link to the next transaction in the queue */
128     void *nextTransaction;    
129 } Rm_Transaction;
131 typedef struct {
132     const void *rangeData;
133     int32_t rangeLen;
134     const void *nsAssignData;
135     int32_t nsAssignLen;
136     const void *linuxAliasData;
137     int32_t linuxAliasLen;
138 } Rm_ResourceProperties;
140 typedef enum {
141     Rm_allocatorOp_ALLOCATE = 0,
142     Rm_allocatorOp_FREE = 1,
143     Rm_allocatorOp_PRE_ALLOCATE = 2,
144 } Rm_AllocatorOp;
146 typedef struct {
147     char *serviceSrcInstName;
148     Rm_AllocatorOp operation;
149     /* Will contain the actual allocation/free values */
150     Rm_ResourceInfo *resourceInfo;
151 } Rm_AllocatorOpInfo;
153 typedef struct {
154     char resourceName[RM_RESOURCE_NAME_MAX_CHARS];
155     /** Pointer to the first resource entry in the allocator */
156     void *allocatorRootEntry;
157     /** Pointer to next resource allocator */
158     void *nextAllocator;
159 } Rm_Allocator;
161 typedef struct {
162     char name[RM_INSTANCE_NAME_MAX_CHARS];
163     Rm_InstType instType;
164     bool registeredWithDelegateOrServer;
165     Rm_PolicyHandle policyDtb;
166     Rm_Allocators allocators;
167     Rm_NameServer nameServer;
168     /* RM instance transport parameters */
169     Rm_TransportRouteMap routeMap;
170     /* RM Transaction sequence number counter */
171     uint32_t transactionSeqNum;
172     /* RM transaction queue */
173     Rm_TransactionQueue transactionQueue;
174     /* Transport API function pointers - not global in case application wants to
175       * hook up different transports to RM */
176     Rm_TransportCallouts transport;
177 } Rm_Inst;
179 Rm_Transaction *Rm_transactionQueueAdd(Rm_Inst *rmInst);
180 Rm_Transaction *Rm_transactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
181 int32_t Rm_transactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
182 uint32_t Rm_transactionGetSequenceNum(Rm_Inst *rmInst);
184 void Rm_transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction);
185 void Rm_transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction);
186 void Rm_transactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
188 /**********************************************************************
189  ******************* Red-Black Tree BBST Defines **********************
190  **********************************************************************/
192 /* Declare the tree structure nodes */
193 typedef struct _Rm_ResourceNode {
194     RB_ENTRY(_Rm_ResourceNode) linkage;
195     uint32_t base;
196     uint32_t length;
197     char allocatedTo[RM_INSTANCE_NAME_MAX_CHARS];
198 } Rm_ResourceNode;
200 /* Declare the tree head structure.  A structure of type Rm_ResourceTree will need to be
201  * malloc'd for each tree that is to be created. */
202 typedef RB_HEAD(_Rm_ResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
204 Rm_ResourceNode *Rm_newResourceNode(uint32_t resourceBase, uint32_t resourceLength, 
205                                     char *allocatedTo);
206 void Rm_freeResourceNode(Rm_ResourceNode *node);
207 /* Prototype for tree node comparison function
208  * element1 < element2 --> return < 0
209  * element1 = element2 --> return 0
210  * element1 > element2 --> return > 0 */
211 int Rm_ResourceNodeCompare(Rm_ResourceNode *element1, Rm_ResourceNode *element2); 
213 /* Generate the tree prototypes */
214 RB_PROTOTYPE(_Rm_ResourceTree, _Rm_ResourceNode, linkage, Rm_ResourceNodeCompare);
216 #ifdef __cplusplus
218 #endif
220 #endif /* RMLOC_H_ */