]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - include/rm_transportloc.h
828dae19a7101557cbdad266d3231d93595c9325
[keystone-rtos/rm-lld.git] / include / rm_transportloc.h
1 /*
2  *  file  rm_transportloc.h
3  *
4  *  Private data structures of Resource Manager transport layer.
5  *
6  *  ============================================================================
7  *      (C) Copyright 2012-2015, 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_TRANSPORTLOC_H_
41 #define RM_TRANSPORTLOC_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_transport.h>
51 /* RM internal includes */
52 #include <ti/drv/rm/include/rm_internal.h>
54 /* This macro generates compilier error if postulate is false, so
55  * allows 0 overhead compile time size check.  This "works" when
56  * the expression contains sizeof() which otherwise doesn't work
57  * with preprocessor */
58 #define RM_COMPILE_TIME_SIZE_CHECK(postulate)                           \
59    do {                                                                 \
60        typedef struct {                                                 \
61          uint8_t NegativeSizeIfPostulateFalse[((int)(postulate))*2 - 1];\
62        } PostulateCheck_t;                                              \
63    }                                                                    \
64    while (0)
66 /* Check assumptions RM request/response packets fit in
67  * RM_TRANSPORT_PACKET_MAX_SIZE_BYTES */
68 #define RM_PACKET_SIZE_CHECK \
69     RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
70                                sizeof(Rm_ResourceRequestPkt));       \
71     RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
72                                sizeof(Rm_ResourceResponsePkt));      \
73     RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
74                                sizeof(Rm_NsRequestPkt));             \
75     RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= \
76                                sizeof(Rm_NsResponsePkt));            \
78 /* RM transport list node */
79 typedef struct Rm_Transport_s {
80     /* RM instance this node was registered to */
81     Rm_Handle              rmHandle;
82     /* Application transport handle provided by application */
83     Rm_AppTransportHandle  appTransportHandle;
84     /* Remote RM instance type */
85     Rm_InstType            remoteInstType;
86     /* Transport callout functions provided by application during transport
87      * registration */
88     Rm_TransportCallouts   callouts;    
89     /* Link to next transport node */
90     struct Rm_Transport_s *nextTransport;
91 } Rm_Transport;
93 /**********************************************************************
94  ************************* RM Packet Defs *****************************
95  **********************************************************************/
97 /* Resource Request Packet Types */
98 typedef enum {
99     /* Resource allocate for init request */
100     Rm_resReqPktType_ALLOCATE_INIT = 0,
101     /* Resource allocate for use request */
102     Rm_resReqPktType_ALLOCATE_USE,
103     /* Resource status request */
104     Rm_resReqPktType_GET_STATUS,
105     /* Free resource */
106     Rm_resReqPktType_FREE,
107     /* Get name resource */
108     Rm_resReqPktType_GET_NAMED
109 } Rm_ResourceReqPktType;
111 /* Resource Request Packet - Packet sent to CDs and Servers to request
112  * a resource service that cannot be handled on the local RM instance due to
113  * permission restrictions. */
114 typedef struct {
115     /* Transaction ID associated with the request packet */
116     uint32_t              requestId;  
117     /* Resource request type */
118     Rm_ResourceReqPktType resourceReqType;
119     /* RM instance name from which the request packet originated.  Used by
120      * receiving instance to route the response */
121     char                  pktSrcInstName[RM_NAME_MAX_CHARS];
122     /* Name of RM instance that is issuing the service request. The instance
123      * name will be used to validate the request against the RM policy defined
124      * for the instance. */
125     char                  serviceSrcInstName[RM_NAME_MAX_CHARS];
126     /* Resource request information */
127     Rm_ResourceInfo       resourceInfo;
128 } Rm_ResourceRequestPkt;
130 /* Resource Response Packet - Packet sent to RM instances that requested
131  * a resource service.  The packet will contain resource response
132  * information based on the request */
133 typedef struct {
134     /* responseID will equal the requestId received in the resource request
135      * packet.  This ID should be associated with a transaction stored in
136      * the RM instance that sent the resource request packet */
137     uint32_t        responseId;
138     /* State of the request.  Resource request denied, or error.  The
139      * return values are externally visible in rm.h */
140     int32_t         requestState;
141     /* Resource response information */
142     Rm_ResourceInfo resourceInfo;
143 } Rm_ResourceResponsePkt;
145 /* NameServer Request Packet Types */
146 typedef enum {
147     /* Request to map the specified name to the specified resources */
148     Rm_nsReqPktType_MAP_RESOURCE = 0,
149     /* Request to unmap the specified name from the specifed resources */
150     Rm_nsReqPktType_UNMAP_RESOURCE
151 } Rm_NsReqPktType;
153 /* NameServer Request Packet - Packet sent by RM instances containing
154  * NameServer mapping or unmapping data */
155 typedef struct {
156     /* Transaction ID associated with the NameServer request packet */
157     uint32_t        requestId;
158     /* NameServer request type */
159     Rm_NsReqPktType nsRequestType;
160     /* RM instance name from which the request packet originated.  Used by
161      * receiving instance to route the response */
162     char            pktSrcInstName[RM_NAME_MAX_CHARS];
163     /* RM instance name making the service request.  Policies may restrict who
164      * can and cannot map and unmap resources via the RM NameServer */
165     char            serviceSrcInstName[RM_NAME_MAX_CHARS];
166     /* Resource request information */
167     Rm_ResourceInfo resourceInfo;
168 } Rm_NsRequestPkt;
170 /* NameServer Response Packet - Provides NameServer transaction response
171  * data to RM instances that request a name map or unmap */
172 typedef struct {
173     /* responseID will equal the requestId received in the NameServer request
174      * packet.  This ID should be associated with a transaction stored in 
175      * the RM instance that sent the resource request packet */
176     uint32_t responseId;
177     /* State of the request.  Resource request denied, or error.  The
178      * return values are externally visible in rm.h */
179     int32_t  requestState;
180 } Rm_NsResponsePkt;
182 Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports,
183                                             Rm_InstType remoteInstType);
185 #ifdef __cplusplus
187 #endif
189 #endif /* RM_TRANSPORTLOC_H_ */