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_allocatorloc.h>
54 #include <ti/drv/rm/include/rm_policyloc.h>
55 #include <ti/drv/rm/include/rm_transportloc.h>
56 #include <ti/drv/rm/include/rm_nameserverloc.h>
57 #include <ti/drv/rm/include/rm_treeloc.h>
59 /* Service transaction linked list node */
60 typedef struct Rm_Transaction_s {
61 /* Transaction service type */
62 Rm_ServiceType type;
63 /* Local ID of the transaction. */
64 uint32_t localId;
65 /* ID of transaction in RM instance that generated the
66 * packet that resulted in the creation of the transaction. The
67 * originating ID will be placed in the transaction's response packet
68 * The RM instance that receives the response will
69 * match the response packet with the originating request using the ID */
70 uint32_t remoteOriginatingId;
71 /* Transaction response mechanism union */
72 union {
73 /* Service callback function if received locally via Service API */
74 Rm_ServiceCallback callback;
75 /* Transport handle to send response packet on if received via Transport rcv API */
76 Rm_Transport *respTrans;
77 } u;
78 /* Transaction state. The codes are defined in rm.h */
79 int32_t state;
80 /* Transaction has been forwarded to CD or Server instance. Waiting for response */
81 int8_t hasBeenForwarded;
82 /* The transaction ID for a transaction pending on a CD while this
83 * transaction is sent to the Server as a request for data required to complete
84 * pending transaction */
85 uint32_t pendingTransactionId;
86 /* Name of the RM instance the service originated from */
87 char serviceSrcInstName[RM_NAME_MAX_CHARS];
88 /* Resource information */
89 Rm_ResourceInfo resourceInfo;
90 /* Link to the next transaction in the queue */
91 struct Rm_Transaction_s *nextTransaction;
92 } Rm_Transaction;
94 /* Server-specific instance data */
95 typedef struct {
96 /* Pointer to the global policy */
97 void *globalPolicy;
98 /* Policy size in bytes */
99 uint32_t policySize;
100 /* Pointer to root entry of the global policy valid instance tree */
101 Rm_PolicyValidInstTree *globalValidInstTree;
102 /* Pointer to the linked list of allocators */
103 Rm_Allocator *allocators;
104 /* Pointer to the root entry of the NameServer */
105 Rm_NameServerTree *nameServer;
106 } Rm_ServerInstData;
108 /* Client Delegate-specific instance data */
109 typedef struct {
110 /* Pointer to the cd policy if provided */
111 void *cdPolicy;
112 /* Pointer to the root entry of the valid instance tree
113 * extracted from the cd policy */
114 Rm_PolicyValidInstTree *cdValidInstTree;
115 /* Pointer to the linked list of allocators */
116 Rm_Allocator *allocators;
117 } Rm_ClientDelegateInstData;
119 /* Client-specific instance data */
120 typedef struct {
121 /* Pointer to the static policy if provided */
122 void *staticPolicy;
123 /* Pointer to the root entry of the valid instance tree
124 * extracted from the static policy */
125 Rm_PolicyValidInstTree *staticValidInstTree;
126 } Rm_ClientInstData;
128 /* Shared Client-specific instance data */
129 typedef struct {
130 /* Shared Server instance handle */
131 Rm_Handle sharedServerHandle;
132 } Rm_SharedClientInstData;
134 /* RM instance structure */
135 typedef struct {
136 /* Name given to the RM instance. Policy will assign resources based
137 * on the names assigned to instances at instance init */
138 char instName[RM_NAME_MAX_CHARS];
139 /* Instance type */
140 Rm_InstType instType;
141 /* Instance lock status. Instance locks if static request fails when
142 * checked against global policy */
143 int8_t isLocked;
144 /* Tracks whether the instance has registered with a CD or Server.
145 * Applicable to CD and Client instances */
146 int8_t registeredWithDelegateOrServer;
147 /* Pointer to the serviceHandle opened from the instance */
148 Rm_ServiceHandle *serviceHandle;
149 /* Linked list of transports registered by the application */
150 Rm_Transport *transports;
151 /* Service transaction sequence number tracker */
152 uint32_t transactionSeqNum;
153 /* Service transaction linked list queue */
154 Rm_Transaction *transactionQueue;
155 /* Block handle provided through OSAL for when RM needs to block due to
156 * a service request that requires a blocking operation to complete and
157 * a service callback function has not been provided */
158 void *blockHandle;
159 /* Instance-type specific constructs */
160 union {
161 /* Server-specific instance data */
162 Rm_ServerInstData server;
163 /* Client Delegate-specific instance data */
164 Rm_ClientDelegateInstData cd;
165 /* Client-specific instance data */
166 Rm_ClientInstData client;
167 /* Shared Client-specific instance data */
168 Rm_SharedClientInstData sharedClient;
169 } u;
170 } Rm_Inst;
172 Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
173 Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
174 int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
175 void rmProcessRouter(Rm_Inst *rmInst, Rm_Transaction *transaction);
177 #ifdef __cplusplus
178 }
179 #endif
181 #endif /* RM_LOC_H_ */