]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - rm_services.h
15904bc60d13ba09832321fddb7bd031ebfd86c1
[keystone-rtos/rm-lld.git] / rm_services.h
1 /**
2  *   @file  rmservices.h
3  *
4  *   @brief   
5  *      This is the RM include file for services provided to components that 
6  *      register a RM instance
7  *
8  *  \par
9  *  ============================================================================
10  *  @n   (C) Copyright 2012, Texas Instruments, Inc.
11  * 
12  *  Redistribution and use in source and binary forms, with or without 
13  *  modification, are permitted provided that the following conditions 
14  *  are met:
15  *
16  *    Redistributions of source code must retain the above copyright 
17  *    notice, this list of conditions and the following disclaimer.
18  *
19  *    Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the 
21  *    documentation and/or other materials provided with the   
22  *    distribution.
23  *
24  *    Neither the name of Texas Instruments Incorporated nor the names of
25  *    its contributors may be used to endorse or promote products derived
26  *    from this software without specific prior written permission.
27  *
28  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
29  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
30  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
32  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
33  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
34  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
37  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
38  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  *  \par
41 */
43 #ifndef RMSERVICES_H_
44 #define RMSERVICES_H_
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 /* RM includes */
51 #include <ti/drv/rm/rm.h>
53 /**
54 @addtogroup RMSERVICES_API
55 @{
56 */
58 /** RM Service Request State Codes and Errors */
59 /** RM Service Request State Code Base */
60 #define RM_SERVICE_STATE_BASE (0)
61 /** RM internal state okay - This value is for internal use by RM.  It should never be
62  *  seen as a return value during normal operation */
63 #define RM_SERVICE_STATE_OKAY (RM_SERVICE_STATE_BASE)
64 /** RM service is being processed.  Typically this means the service is
65  *  being sent to a higher level RM agent for processing */
66 #define RM_SERVICE_PROCESSING (RM_SERVICE_STATE_BASE+1)
67 /** RM service was approved.  The resource data in the response is valid if
68  *  the service has been approved. */
69 #define RM_SERVICE_APPROVED (RM_SERVICE_STATE_BASE+2)
70 /** Beginning of resource denied reasons */
71 #define RM_SERVICE_DENIED_BEGIN (RM_SERVICE_STATE_BASE+3)
72 /** End of resource denied reasons */
73 #define RM_SERVICE_DENIED_END (RM_SERVICE_STATE_BASE+3)
75 /** RM Service Request Error Code Base */
76 #define RM_SERVICE_ERROR_BASE (-64)
77 /** RM service request type not recognized */
78 #define RM_SERVICE_ERROR_INVALID_SERVICE_TYPE (RM_SERVICE_ERROR_BASE)
79 /** RM Service request was not provided a component callback
80  *  function.  Service requests may result in blocking operations.  A callback
81  *  function must always be provided with a service request since
82  *  blocked or non-blocked operations cannot be promised.  */
83 #define RM_SERVICE_ERROR_CALLBACK_NOT_PROVIDED (RM_SERVICE_ERROR_BASE-1)
84 /** RM service request needs to be forwarded to another RM agent but no transports
85  *  have been registered */
86 #define RM_SERVICE_ERROR_NO_TRANSPORT_REGISTERED (RM_SERVICE_ERROR_BASE-2)
87 /** RM service request needs to be forwarded but no client delegate or server has 
88  *  been registered with the RM instance */
89 #define RM_SERVICE_ERROR_NOT_REGISTERED_WITH_DEL_OR_SERVER (RM_SERVICE_ERROR_BASE-3)
90 /** RM service request needs to be forwarded but the transport packet alloc API
91  *  has not been provided */
92 #define RM_SERVICE_ERROR_TRANSPORT_PKT_ALLOC_API_NULL (RM_SERVICE_ERROR_BASE-4)
93 /** A failure occurred within a registered transport's packet alloc API */
94 #define RM_SERVICE_ERROR_TRANSPORT_ALLOC_PKT_ERROR (RM_SERVICE_ERROR_BASE-5)
95 /** RM service request needs to be forwarded but the buffer allocated by transport
96  *  is not large enough to fit the RM transport packet */
97 #define RM_SERVICE_ERROR_TRANSPORT_PKT_BUF_TOO_SMALL (RM_SERVICE_ERROR_BASE-6)
98 /** RM service request needs to be forwarded but the transport returned an error
99  *  when trying to send the RM packet to the higher level agent */
100 #define RM_SERVICE_ERROR_TRANPSPORT_SEND_ERROR (RM_SERVICE_ERROR_BASE-7)
101 /** RM service response from higher level agent did not match any requests made
102  *  by the provided RM instance */
103 #define RM_SERVICE_ERROR_TRANSACTION_DOES_NOT_EXST_FOR_THIS_RM_INSTANCE (RM_SERVICE_ERROR_BASE-8)
104 /** RM failed to allocate memory for new service transaction */
105 #define RM_SERVICE_ERROR_TRANSACTION_FAILED_TO_ALLOCATE (RM_SERVICE_ERROR_BASE-9)
106 /** RM could not find the service transaction in the RM instance's transaction queue */
107 #define RM_SERVICE_ERROR_SERVICE_TRANSACTION_DOES_NOT_EXIST (RM_SERVICE_ERROR_BASE-10)
108 /** A failure occurred within a registered transport's packet free API */
109 #define RM_SERVICE_ERROR_TRANSPORT_FREE_PKT_ERROR (RM_SERVICE_ERROR_BASE-11)
110 /** Invalid NameServer object modification on non-Server instance */
111 #define RM_SERVICE_ERROR_NAMESERVER_OBJECT_MOD_ON_INVALID_INSTANCE (RM_SERVICE_ERROR_BASE-12)
113 /**
114  * @brief Maximum number of characters in the resource names
115  */
116 #define RM_RESOURCE_NAME_MAX_CHARS (24)
118 /** 
119  * @brief RM service types
120  */
121 typedef enum {
122     /** First service type.  Used by RM for bounds checking.  Should
123      *  not be used by component. */
124     Rm_service_FIRST = 0,
125     /** RM resource allocate service */
126     Rm_service_RESOURCE_ALLOCATE = 0,
127     /** RM resource block allocate service */
128     Rm_service_RESOURCE_BLOCK_ALLOCATE = 1,
129     /** RM resource allocate by name service */
130     Rm_service_RESOURCE_ALLOCATE_BY_NAME = 2,    
131     /** RM resource free service */
132     Rm_service_RESOURCE_FREE = 3,
133     /** RM resource block free service */
134     Rm_service_RESOURCE_BLOCK_FREE = 4,
135     /** RM resource free by name service */
136     Rm_service_RESOURCE_FREE_BY_NAME = 5,
137     /** RM resource mapping to name service */
138     Rm_service_RESOURCE_MAP_TO_NAME = 6,
139     /** RM resource name unmapping service */
140     Rm_service_RESOURCE_UNMAP_NAME = 7,
141     /** Last service type.  Used by RM for bounds checking.  Should
142      *  not be used by component. */
143     Rm_service_LAST = 7
144 } Rm_ServiceType;
146 /** 
147  * @brief RM pre-main allocation request information provided by the pre-main 
148  *        startup function requesting the resource */
149 typedef struct {
150     /** Pointer to the requested pre-main allocation resource name.  The 
151      *  name provided by the component must match the resource names
152      *  provided in the global resource table and allocation policies */
153     char *resourceName;
154     /** The pre-main allocation request resource base value.  For example, 
155      *  queue number or semaphore number */
156     uint32_t resourceBase;
157     /** Range of resource starting at resourceBase */
158     uint32_t resourceRange;
159 } Rm_PreMainAllocInfo;
161 /** 
162  * @brief RM service response information provided by RM back to the 
163  *        requesting component
164  */
165 typedef struct {
166     /** State of the service request.
167      *  Non-negative result: RM has taken an action based on the request
168      *  Negative result: RM has encountered an error handling the request */
169     int32_t serviceState;
170     /** A service ID will be returned to the component if the requested service cannot
171      *  be completed immediately.  The service ID can be used by the component to identify
172      *  service responses received via the component callback function.  A service ID will not
173      *  be returned if the service request is satisfied immediately */
174     uint32_t serviceId;
175     /** The base value of the returned resource.  In the case of a block resource allocation 
176      *  response this field will contain the base value of the block. */
177     int32_t resourceBase;
178     /** The range of resources starting from resourceBase allocated in block requests */
179     uint32_t resourceRange;
180 } Rm_ServiceRespInfo;
182 /** 
183  * @brief RM service callback function structure
184  */
185 typedef struct {
186     /** Component callback function.  RM will call this function when the 
187      *  resource service request is completed. The callback function supplied
188      *  for this parameter must match this function pointer prototype. */
189     void (*serviceCallback) (Rm_ServiceRespInfo *serviceResponse);
190 } Rm_ServiceCallback;
192 /** 
193  * @brief RM service request information provided by the requesting component
194  */
195 typedef struct {
196     /** The type of RM service requested */
197     Rm_ServiceType type;
198     /** Pointer to the name of the resource requested.  The 
199      *  name provided by the component must match the resource node names
200      *  provided in the global resource table and allocation policies */
201     char *resourceName;
202 /** An allocate service can be requested with an unspecified resource base. 
203  *  If this occurs the RM Client Delegate or Server will assign the next available
204  *  resource or set of resources based on the allocation type. */
205 #define RM_RESOURCE_BASE_UNSPECIFIED (-1)  
206     /** The resource base value. */
207     int32_t resourceBase;
208     /** The range of the specified resource to be allocated starting from 
209      *  resourceBase.  Will be greater than one only for block allocate
210      *  and free service requests. */
211     uint32_t resourceRange;
212 /** An allocate service can be requested with an unspecified resource alignment.
213  *  WARNING: Only applicapable if resourceBase is unspecified
214  *
215  *  If the alignment is unspecified the RM Client Delegate or Server will allocate
216  *  the resources from a default alignment as specified in the global policy. */
217 #define RM_RESOURCE_ALIGNMENT_UNSPECIFIED (-1)      
218     /** Resource alignment in block allocation requests */
219     int32_t resourceAlignment;
220     /** The name server name associated with the resource.  Used only for 
221      *  allocate and free by name service requests */
222     char *resourceNsName;
223     /** Component specified callback function used by RM to inform components
224      *  of service requst results */
225     Rm_ServiceCallback callback;
226 } Rm_ServiceReqInfo;
228 /** 
229  * @brief RM Service Port provided to software components and applications that 
230  *        request RM services for the resources they wish to use
231  */
232 typedef struct {
233     /** RM instance handle for which the service handle was registered */
234     void *rmHandle;
235     /**
236      *  @b Description
237      *  @n  
238      *      Callout function used by components to request a resource service 
239      *      from a RM instance
240      *
241      *   @param[in] rmHandle
242      *      RM instance handle specifying the RM instance that should handle the
243      *      service request
244      *  
245      *  @param[in]  serviceRequest
246      *      Service request structure that provides details of the service requested from
247      *      the RM instance tied to this component
248      *
249      *  @param[in]  serviceResponse
250      *      Service response structure that provides details of RM's response to the
251      *      service request
252      */
253     void (*rmService)(void *rmHandle, Rm_ServiceReqInfo *serviceRequest,
254                       Rm_ServiceRespInfo *serviceResponse);
255 } Rm_ServicePort;
257 /**
258  *  @b Description
259  *  @n  
260  *      Non-blocking function used by RTSC pre-main startup functions to
261  *      allocate RM resources for usage.  Pre-main allocated resources will be 
262  *      validated by RM against a memory-mapped startup resource policy.
263  *      Pre-main allocation of unauthorized resources will result in a system
264  *      exception.
265  *
266  *      Note: Resource pre-main allocations can only occur on a core that is 
267  *            running a RM Server or Client Delegate that has a startup policy
268  *            allowing the allocation of pre-main resources
269  *
270  *  @param[in]  preMainAllocInfo
271  *      Resource pre-main allocation structure that provides details of the 
272  *      resource requested from RM for preallocation
273  *
274  *  @param[out] serviceResponse
275  *      Contains the result information regarding the pre-main allocation request
276  *
277  *  @retval
278  *      Success - 0 - Resource pre-main allocation request okay.
279  *  @retval
280  *      Failure - non-zero - Resource pre-main allocation request error.
281  */
282 void Rm_preMainAllocService (Rm_PreMainAllocInfo *preMainAllocInfo,
283                              Rm_ServiceRespInfo *serviceResponse);
285 /**
286  *  @b Description
287  *  @n  
288  *      This function returns a RM service port to the application to 
289  *      provide to software components (LLDs, BIOS, etc) that want to use RM
290  *      for resource management.
291  *
292  *  @param[in]  rmHandle
293  *      RM instance handle.  Used to return a Rm_ServicePort from an RM
294  *      instance.
295  *
296  *  @retval
297  *      Success - RM Service Port.  Used by an application or component to
298  *                request a service from RM.
299  *  @retval
300  *      Failure - NULL
301  */
302 Rm_ServicePort *Rm_getServicePort(Rm_Handle rmHandle);
304 /** 
305 @} 
306 */
308 #ifdef __cplusplus
310 #endif
312 #endif /* RMSERVICES_H_ */