1 /*
2 * file rm_transportloc.h
3 *
4 * Private data structures of Resource Manager transport layer.
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_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 RM_TRANSPORT_PACKET_MAX_SIZE_BYTES */
67 #define RM_PACKET_SIZE_CHECK \
68 RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_ResourceRequestPkt)); \
69 RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_ResourceResponsePkt)); \
70 RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_NsRequestPkt)); \
71 RM_COMPILE_TIME_SIZE_CHECK(RM_TRANSPORT_PACKET_MAX_SIZE_BYTES >= sizeof(Rm_NsResponsePkt)); \
73 /* RM transport list node */
74 typedef struct Rm_Transport_s {
75 /* RM instance this node was registered to */
76 Rm_Handle rmHandle;
77 /* Application transport handle provided by application */
78 Rm_AppTransportHandle appTransportHandle;
79 /* Remote RM instance type */
80 Rm_InstType remoteInstType;
81 /* Transport callout functions provided by application during transport
82 * registration */
83 Rm_TransportCallouts callouts;
84 /* Link to next transport node */
85 struct Rm_Transport_s *nextTransport;
86 } Rm_Transport;
88 /**********************************************************************
89 ************************* RM Packet Defs *****************************
90 **********************************************************************/
92 /* Resource Request Packet Types */
93 typedef enum {
94 /* Resource allocate for init request */
95 Rm_resReqPktType_ALLOCATE_INIT = 0,
96 /* Resource allocate for use request */
97 Rm_resReqPktType_ALLOCATE_USE,
98 /* Resource status request */
99 Rm_resReqPktType_GET_STATUS,
100 /* Free resource */
101 Rm_resReqPktType_FREE,
102 /* Get name resource */
103 Rm_resReqPktType_GET_NAMED
104 } Rm_ResourceReqPktType;
106 /* Resource Request Packet - Packet sent to CDs and Servers to request
107 * a resource service that cannot be handled on the local RM instance due to
108 * permission restrictions. */
109 typedef struct {
110 /* Transaction ID associated with the request packet */
111 uint32_t requestId;
112 /* Resource request type */
113 Rm_ResourceReqPktType resourceReqType;
114 /* RM instance name from which the request packet originated. Used by
115 * receiving instance to route the response */
116 char pktSrcInstName[RM_NAME_MAX_CHARS];
117 /* Name of RM instance that is issuing the service request. The instance
118 * name will be used to validate the request against the RM policy defined
119 * for the instance. */
120 char serviceSrcInstName[RM_NAME_MAX_CHARS];
121 /* Resource request information */
122 Rm_ResourceInfo resourceInfo;
123 } Rm_ResourceRequestPkt;
125 /* Resource Response Packet - Packet sent to RM instances that requested
126 * a resource service. The packet will contain resource response
127 * information based on the request */
128 typedef struct {
129 /* responseID will equal the requestId received in the resource request
130 * packet. This ID should be associated with a transaction stored in
131 * the RM instance that sent the resource request packet */
132 uint32_t responseId;
133 /* State of the request. Resource request denied, or error. The
134 * return values are externally visible in rm.h */
135 int32_t requestState;
136 /* Resource response information */
137 Rm_ResourceInfo resourceInfo;
138 } Rm_ResourceResponsePkt;
140 /* NameServer Request Packet Types */
141 typedef enum {
142 /* Request to map the specified name to the specified resources */
143 Rm_nsReqPktType_MAP_RESOURCE = 0,
144 /* Request to unmap the specified name from the specifed resources */
145 Rm_nsReqPktType_UNMAP_RESOURCE
146 } Rm_NsReqPktType;
148 /* NameServer Request Packet - Packet sent by RM instances containing
149 * NameServer mapping or unmapping data */
150 typedef struct {
151 /* Transaction ID associated with the NameServer request packet */
152 uint32_t requestId;
153 /* NameServer request type */
154 Rm_NsReqPktType nsRequestType;
155 /* RM instance name from which the request packet originated. Used by
156 * receiving instance to route the response */
157 char pktSrcInstName[RM_NAME_MAX_CHARS];
158 /* RM instance name making the service request. Policies may restrict who
159 * can and cannot map and unmap resources via the RM NameServer */
160 char serviceSrcInstName[RM_NAME_MAX_CHARS];
161 /* Resource request information */
162 Rm_ResourceInfo resourceInfo;
163 } Rm_NsRequestPkt;
165 /* NameServer Response Packet - Provides NameServer transaction response
166 * data to RM instances that request a name map or unmap */
167 typedef struct {
168 /* responseID will equal the requestId received in the NameServer request
169 * packet. This ID should be associated with a transaction stored in
170 * the RM instance that sent the resource request packet */
171 uint32_t responseId;
172 /* State of the request. Resource request denied, or error. The
173 * return values are externally visible in rm.h */
174 int32_t requestState;
175 } Rm_NsResponsePkt;
177 Rm_Transport *rmTransportFindRemoteInstType(Rm_Transport *transports, Rm_InstType remoteInstType);
179 #ifdef __cplusplus
180 }
181 #endif
183 #endif /* RM_TRANSPORTLOC_H_ */