]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blob - rm_services.h
142ea9a350a145821e05b5dbdbd2c3aafeec3a3b
[keystone-rtos/rm-lld.git] / rm_services.h
1 /**
2  *   @file  rm_services.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-2013, 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 RM_SERVICES_H_
44 #define RM_SERVICES_H_
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 /* RM includes */
51 #include <ti/drv/rm/rm.h>
53 /**
54 @addtogroup RM_SERVICES_API
55 @{
56 */
58 /** 
59  * @brief RM service types
60  */
61 typedef enum {
62     /** RM resource allocate for initialization service */
63     Rm_service_RESOURCE_ALLOCATE_INIT = 0,
64     /** RM resource allocate for use service */
65     Rm_service_RESOURCE_ALLOCATE_USE,
66     /** RM resource free service */
67     Rm_service_RESOURCE_FREE,
68     /** RM NameServer map resource to name service */
69     Rm_service_RESOURCE_MAP_TO_NAME,
70     /** RM NameServer get resource by name service */
71     Rm_service_RESOURCE_GET_BY_NAME,
72     /** RM NameServer unmap resource from name service */
73     Rm_service_RESOURCE_UNMAP_NAME,
74     /** DO NOT USE: Last type */
75     Rm_service_LAST
76 } Rm_ServiceType;
78 /** 
79  * @brief RM service response information used by RM to provide service
80  *        request results back to the application components
81  */
82 typedef struct {
83     /** Service request state.  The state can be an approval, denial, or error.
84      *  The latter codes start at #RM_OK, #RM_SERVICE_DENIED_BASE, and 
85      *  #RM_ERROR_BASE, respectively. */
86     int32_t serviceState;
87     /** The service ID is returned to the application in order to match service
88      *  responses received at a later time via the provided callback function
89      *  because RM required a blocking operation in order to satisfy the
90      *  resource request. */
91     uint32_t serviceId;
92     /** Affected resource name */
93     char resourceName[RM_NAME_MAX_CHARS];
94     /** The resource base value allocated, freed, or mapped to NameServer name. */
95     int32_t resourceBase;
96     /** The resource length starting at base allocated, freed, or mapped to
97      *  NameServer name. */
98     uint32_t resourceLength;
99 } Rm_ServiceRespInfo;
101 /** 
102  * @brief RM service callback function
103  */
104 typedef struct {
105     /** Component callback function.  RM calls this function when a blocking 
106      *  resource service request is complete. The callback function supplied
107      *  for this parameter must match the function pointer prototype. */
108     void (*serviceCallback) (Rm_ServiceRespInfo *serviceResponse);
109 } Rm_ServiceCallback;
111 /** 
112  * @brief RM service request information
113  */
114 typedef struct {
115     /** The type of service requested */
116     Rm_ServiceType type;
117     /** Pointer to an array containing the resource name affected by
118      *  the request.  The resource name must match a resource node name
119      *  defined in the GRL and global/static policy.  The request will be
120      *  denied if the resource name does not match any resource node names
121      *  in the policy */
122     const char *resourceName;
123 /** Informs RM to find the next available resource block of length
124  *  resourceLength and alignment resourceAlignment for allocation.  This
125  *  parameter is only valid for resource allocate service types. */
126 #define RM_RESOURCE_BASE_UNSPECIFIED (-1)  
127     /** The base value of the resource affected by the service request.
128      *  #RM_RESOURCE_BASE_UNSPECIFIED can be substituted. */
129     int32_t resourceBase;
130     /** The resource length, starting from #resourceBase affected by the
131      *  service request. */
132     uint32_t resourceLength;
133 /** Informs RM to find the next available resource block with length
134  *  resourceLength and the alignment specified in 
135  *  a) The resource node in the policy if it has the "allocation-alignment"
136  *     property defined.
137  *  b) The default alignment of 1 if no alignment is specified in the policy
138  *     for the resource.
139  *  This value is only valid if resourceBase is set to 
140  *  #RM_RESOURCE_BASE_UNSPECIFIED */
141 #define RM_RESOURCE_ALIGNMENT_UNSPECIFIED (-1)      
142     /** Alignment of the resource affected by the service request.  Only valid
143      *  if resourceBase is set to #RM_RESOURCE_BASE_UNSPECIFIED.
144      *  #RM_RESOURCE_ALIGNMENT_UNSPECIFIED can be substituted. */
145     int32_t resourceAlignment;
146     /** The NameServer name associated, or to be associated, with a resource. 
147      *  If the service type is #Rm_service_RESOURCE_GET_BY_NAME and the
148      *  #resourceBase and #resourceLength fields are not NULL a error will
149      *  occur. */
150     const char *resourceNsName;
151     /** Callback function used by RM to provide responses back to application
152      *  components after a service request resulted in a blocking operation. */
153     Rm_ServiceCallback callback;
154 } Rm_ServiceReqInfo;
156 /** 
157  * @brief RM service handle provided to application components for requesting
158  *        services
159  */
160 typedef struct {
161     /** RM instance handle for which the service handle was allocated from. */
162     void *rmHandle;
163     /**
164      *  @b Description
165      *  @n  
166      *      Processes service requests from application components.  Responses
167      *      are returned immediately if the service request could be satisfied 
168      *      without blocking.  If the service request requires a blocking operation,
169      *      such as forwarding the service request to another instance for
170      *      validation, the response will be received via the Rm_ServerCallback
171      *
172      *   @param[in] rmHandle
173      *      RM instance handle specifies the instance that handles the service
174      *      request.  The request's result, if policy checks are involved, will be
175      *      based on the permissions assigned to the rmHandle's instance name within
176      *      global/static policy.
177      *  
178      *  @param[in]  serviceRequest
179      *      Pointer to the service request structure
180      *
181      *  @param[out]  serviceResponse
182      *      Pointer to a service response structure.
183      */
184     void (*Rm_serviceHandler)(void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
185                               Rm_ServiceRespInfo *serviceResponse);
186 } Rm_ServiceHandle;
188 /**
189  *  @b Description
190  *  @n  
191  *      This function returns a RM service handle to the application to 
192  *      provide services to software components (LLDs, BIOS, etc) that want to use RM
193  *      for resource management. Only one service handle can be opened from
194  *      each RM instance.
195  *
196  *  @param[in]  rmHandle
197  *      RM instance handle from which the service handle will be opened
198  *
199  *  @param[out] result
200  *      Pointer to a signed int used to return any errors encountered during
201  *      the instance initialization process.
202  *
203  *  @retval
204  *      Success - Rm_ServiceHandle and result = #RM_OK
205  *  @retval
206  *      Failure - NULL Rm_ServiceHandle and result = #RM_ERROR_SERVICE_HANDLE_MEM_ALLOC_FAILED
207  *  @retval
208  *      Failure - NULL Rm_ServiceHandle and result = #RM_ERROR_SERVICE_HANDLE_ALREADY_OPENED
209  */
210 Rm_ServiceHandle *Rm_serviceOpenHandle(Rm_Handle rmHandle, int32_t *result);
212 /**
213  *  @b Description
214  *  @n  
215  *      This function closes a RM instance's service handle
216  *
217  *  @param[in]  rmServiceHandle
218  *      RM instance service handle to be closed.
219  *
220  *  @retval
221  *      Success - #RM_OK
222  *  @retval
223  *      Failure - #RM_ERROR_SERVICE_HANDLE_ALREADY_CLOSED
224  */
225 int32_t Rm_serviceCloseHandle(Rm_ServiceHandle *rmServiceHandle);
227 /** 
228 @} 
229 */
231 #ifdef __cplusplus
233 #endif
235 #endif /* RM_SERVICES_H_ */