1379ce68018abc54de7cd08939ca2fc1cb0b1f44
1 /*
2 * file rm_loc.h
3 *
4 * General private data structures of Resource Manager.
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_LOC_H_
41 #define RM_LOC_H_
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 /* RM external includes */
48 #include <ti/drv/rm/rm.h>
49 #include <ti/drv/rm/rm_services.h>
51 /* RM internal includes */
52 #include <ti/drv/rm/include/rm_internal.h>
53 #include <ti/drv/rm/include/rm_policyloc.h>
54 #include <ti/drv/rm/include/rm_transportloc.h>
55 #include <ti/drv/rm/include/rm_nameserverloc.h>
56 #include <ti/drv/rm/include/rm_treeloc.h>
58 /* Service transaction linked list node */
59 typedef struct Rm_Transaction_s {
60 /* Transaction service type */
61 Rm_ServiceType type;
62 /* Local ID of the transaction. */
63 uint32_t localId;
64 /* ID of transaction in RM instance that generated the
65 * packet that resulted in the creation of the transaction. The
66 * originating ID will be placed in the transaction's response packet
67 * The RM instance that receives the response will
68 * match the response packet with the originating request using the ID */
69 uint32_t remoteOriginatingId;
70 /* Name of the RM instance that generated the packet that resulted
71 * in the creation of the service transaction. Used to send the response
72 * packet. */
73 char pktSrcInstName[RM_NAME_MAX_CHARS];
74 /* Transaction service callback function */
75 Rm_ServiceCallback callback;
76 /* Transaction state. The codes are defined in rm.h */
77 int32_t state;
78 /* Transaction has been forwarded to CD or Server instance. Waiting for response */
79 bool hasBeenForwarded;
80 /* Name of the RM instance the service originated from */
81 char serviceSrcInstName[RM_NAME_MAX_CHARS];
82 /* Resource information */
83 Rm_ResourceInfo resourceInfo;
84 /* Link to the next transaction in the queue */
85 struct Rm_Transaction_s *nextTransaction;
86 } Rm_Transaction;
88 /* Resource properties extracted from the GRL DTB */
89 typedef struct {
90 /* Pointer to a resource's range data within the GRL DTB */
91 const void *rangeData;
92 /* Length in bytes of a resource's range data in the GRL DTB */
93 int32_t rangeLen;
94 /* Pointer to a resource's NameServer assignment data within the GRL DTB.
95 * Will be NULL if not defined for the resource node. */
96 const void *nsAssignData;
97 /* Length in bytes of a resource's NameServer assignment data in the GRL DTB.
98 * Will be zero if not defined for the resource node. */
99 int32_t nsAssignLen;
100 /* Pointer to a resource's Linux alias data within the GRL DTB. Will be
101 * NULL if not defined for the resource node. */
102 const void *linuxAliasData;
103 /* Length in bytes of a resource's Linux alias data data in the GRL DTB.
104 * Will be zero if not defined for the resource node. */
105 int32_t linuxAliasLen;
106 } Rm_ResourceProperties;
108 /* Resource allocator operations */
109 typedef enum {
110 /* Allocate operation */
111 Rm_allocatorOp_ALLOCATE = 0,
112 /* Free operation */
113 Rm_allocatorOp_FREE,
114 /* Preallocate based on Policy DTB information operation */
115 Rm_allocatorOp_PRE_ALLOCATE
116 } Rm_AllocatorOp;
118 /* Allocator operation configuration structure */
119 typedef struct {
120 /* RM instance for which the allocator operation is taking place */
121 Rm_PolicyValidInstNode *serviceSrcInstNode;
122 /* Allocator operation type */
123 Rm_AllocatorOp operation;
124 /* Specifies the type of allocation
125 * a) Allocate to initialize
126 * b) Allocate to use */
127 uint32_t allocType;
128 /* Resources for which the allocator operation will affect */
129 Rm_ResourceInfo *resourceInfo;
130 } Rm_AllocatorOpInfo;
132 /* RM allocator linked list node */
133 typedef struct Rm_Allocator_s {
134 /* Resource name for which the allocator was created. The resource name
135 * must match a resource node defined in both the GRL and the Policy */
136 char resourceName[RM_NAME_MAX_CHARS];
137 /* Pointer to the root entry of the allocator tree */
138 void *allocatorRootEntry;
139 /* Pointer to next resource allocator node */
140 struct Rm_Allocator_s *nextAllocator;
141 } Rm_Allocator;
143 /* Static policy information */
144 typedef struct {
145 /* Pointer to the static policy if provided */
146 void *staticPolicy;
147 /* Pointer to the root entry of the valid instance tree
148 * extracted from the static policy */
149 Rm_PolicyValidInstTree *staticValidInstTree;
150 } Rm_StaticInfo;
152 /* RM instance structure */
153 typedef struct {
154 /* Name given to the RM instance. Policy will assign resources based
155 * on the names assigned to instances at instance init */
156 char instName[RM_NAME_MAX_CHARS];
157 /* Instance type */
158 Rm_InstType instType;
159 /* Instance lock status. Instance locks if static request fails when
160 * checked against global policy */
161 bool isLocked;
162 /* Pointer to the serviceHandle opened from the instance */
163 Rm_ServiceHandle *serviceHandle;
164 /* Tracks whether the instance has registered with a CD or Server.
165 * Applicable to CD and Client instances */
166 bool registeredWithDelegateOrServer;
167 /* Linked list of transports registered by the application */
168 Rm_Transport *transports;
169 /* Service transaction sequence number tracker */
170 uint32_t transactionSeqNum;
171 /* Service transaction linked list queue */
172 Rm_Transaction *transactionQueue;
173 /* [Server] Pointer to the global policy */
174 void *policy;
175 /* [Server] Pointer to root entry of the global policy valid instance tree */
176 Rm_PolicyValidInstTree *validInstances;
177 /* [Server] Pointer to the linked list of allocators */
178 Rm_Allocator *allocators;
179 /* [Server] Pointer to the root entry of the NameServer */
180 Rm_NameServerTree *nameServer;
181 /* [CD or Client] Static policy data */
182 Rm_StaticInfo staticInfo;
183 } Rm_Inst;
185 Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
186 Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
187 int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
188 Rm_Allocator *rmAllocatorFind(Rm_Allocator *allocatorList, char *resourceName);
189 void rmTransactionProcessor (Rm_Inst *rmInst, Rm_Transaction *transaction);
191 #ifdef __cplusplus
192 }
193 #endif
195 #endif /* RM_LOC_H_ */