]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - include/rm_loc.h
Added support for Shared Clients which piggyback onto a Shared Server instance in...
[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-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     /* Name of the RM instance that generated the packet that resulted
72      * in the creation of the service transaction.  Used to send the response
73      * packet. */
74     char                     pktSrcInstName[RM_NAME_MAX_CHARS];
75     /* Transaction service callback function */
76     Rm_ServiceCallback       callback;
77     /* Transaction state.  The codes are defined in rm.h */
78     int32_t                  state;
79     /* Transaction has been forwarded to CD or Server instance.  Waiting for response */
80     int8_t                   hasBeenForwarded;
81     /* Name of the RM instance the service originated from */
82     char                     serviceSrcInstName[RM_NAME_MAX_CHARS];    
83     /* Resource information */
84     Rm_ResourceInfo          resourceInfo;
85     /* Link to the next transaction in the queue */
86     struct Rm_Transaction_s *nextTransaction;    
87 } Rm_Transaction;
89 /* Server-specific instance data */
90 typedef struct {
91     /* Pointer to the global policy */
92     void                   *globalPolicy;
93     /* Pointer to root entry of the global policy valid instance tree */
94     Rm_PolicyValidInstTree *globalValidInstTree;
95     /* Pointer to the linked list of allocators */
96     Rm_Allocator           *allocators;
97     /* Pointer to the root entry of the NameServer */
98     Rm_NameServerTree      *nameServer;
99 } Rm_ServerInstData;
101 /* Client Delegate-specific instance data */
102 typedef struct {
103     /* Pointer to the static policy if provided */
104     void                   *staticPolicy;
105     /* Pointer to the root entry of the valid instance tree
106      * extracted from the static policy */
107     Rm_PolicyValidInstTree *staticValidInstTree;
108 } Rm_ClientDelegateInstData;
110 /* Client-specific instance data */
111 typedef struct {
112     /* Pointer to the static policy if provided */
113     void                   *staticPolicy;
114     /* Pointer to the root entry of the valid instance tree
115      * extracted from the static policy */
116     Rm_PolicyValidInstTree *staticValidInstTree;
117 } Rm_ClientInstData;
119 /* Shared Client-specific instance data */
120 typedef struct {
121     /* Shared Server instance handle */
122     Rm_Handle sharedServerHandle;
123 } Rm_SharedClientInstData;
125 /* RM instance structure */
126 typedef struct {
127     /* Name given to the RM instance.  Policy will assign resources based
128      * on the names assigned to instances at instance init */
129     char              instName[RM_NAME_MAX_CHARS];
130     /* Instance type */
131     Rm_InstType       instType;
132     /* Instance lock status.  Instance locks if static request fails when
133      * checked against global policy */
134     int8_t            isLocked;
135     /* Tracks whether the instance has registered with a CD or Server.
136      * Applicable to CD and Client instances */
137     int8_t            registeredWithDelegateOrServer;    
138     /* Pointer to the serviceHandle opened from the instance */
139     Rm_ServiceHandle *serviceHandle;
140     /* Linked list of transports registered by the application */
141     Rm_Transport     *transports;
142     /* Service transaction sequence number tracker */
143     uint32_t          transactionSeqNum;
144     /* Service transaction linked list queue */
145     Rm_Transaction   *transactionQueue; 
146     /* Block handle provided through OSAL for when RM needs to block due to
147      * a service request that requires a blocking operation to complete and
148      * a service callback function has not been provided */
149     void             *blockHandle;
150     /* Instance-type specific constructs */
151     union {
152         /* Server-specific instance data */
153         Rm_ServerInstData         server;
154         /* Client Delegate-specific instance data */
155         Rm_ClientDelegateInstData cd;
156         /* Client-specific instance data */
157         Rm_ClientInstData         client;
158         /* Shared Client-specific instance data */
159         Rm_SharedClientInstData   sharedClient;
160     } u;
161 } Rm_Inst;
163 Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst);
164 Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId);
165 int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId);
166 void rmProcessRouter(Rm_Inst *rmInst, Rm_Transaction *transaction);
168 #ifdef __cplusplus
170 #endif
172 #endif /* RM_LOC_H_ */