aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'packages/xdais/ti/xdais/ires.h')
-rw-r--r--packages/xdais/ti/xdais/ires.h276
1 files changed, 276 insertions, 0 deletions
diff --git a/packages/xdais/ti/xdais/ires.h b/packages/xdais/ti/xdais/ires.h
new file mode 100644
index 0000000..ee066b7
--- /dev/null
+++ b/packages/xdais/ti/xdais/ires.h
@@ -0,0 +1,276 @@
1/*
2 * Copyright (c) 2006-2012, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33/**
34 * @file ti/xdais/ires.h
35 *
36 * @brief IRES Interface Definitions - Allows algorithms to
37 * request and receive handles representing private logical
38 * resources.
39 */
40
41/**
42 * @defgroup DSPIRES IRES
43 *
44 * The IRES interface enables algorithms to request and
45 * receive handles representing private logical resources.
46 */
47#ifndef IRES_
48#define IRES_
49
50/** @ingroup DSPIRES */
51/*@{*/
52
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#include "ires_common.h"
59
60typedef enum IRES_YieldResourceType {
61 IRES_ALL = 0, /**< Yielding all resources held by the
62 * algorithm.
63 */
64 IRES_SCRATCHMEMORY, /**< Yielding all scratch memory
65 * resources held by the algorithm.
66 */
67 IRES_SCRATCHDMA, /**< Yielding all IDMA3 resources held
68 * by the algorithm.
69 */
70 IRES_RESOURCEHANDLE /**< Yielding IRES resource handle only.
71 */
72
73} IRES_YieldResourceType;
74
75typedef Void (*IRES_ContextSaveFxn)(IALG_Handle algHandle, Void *contextArgs);
76typedef Void (*IRES_ContextRestoreFxn)
77 (IALG_Handle algHandle, Void *contextArgs);
78
79/**
80 * @brief Specifies the algorithm specific handles
81 * and context save & restore function pointers and arguments
82 * that the framework will call during a context switch.
83 */
84typedef struct IRES_YieldContext {
85
86 /**
87 * Handle of the algorithm instance issuing the "yield".
88 */
89 IALG_Handle algHandle;
90
91 /**
92 * Optional resource handle that may be used to yield a particular
93 * IRES resource.
94 * May be NULL when some other resource or ALL resources associated
95 * with an algorithm are to be yielded.
96 */
97 IRES_Handle resourceHandle;
98
99 /**
100 * The 'contextSave' function is implemented by the 'yielding' algorithm
101 * instance and must be called by the framework whenever the 'yield'
102 * results in a context switch.
103 * Any 'scratch' IRES, IALG or IDMA3 resource owned by the algorithm must
104 * be considered in volatile state during a 'yield' call, and must be
105 * re-initialized and activated following any context switch.
106 * The 'contextSave' function must save any volatile state information in
107 * its persistent memory that it needs in the subsequent 'contextRestore'
108 * function call to re-initialize and activate its scratch resources.
109 */
110 IRES_ContextSaveFxn contextSave;
111
112 /**
113 * The 'contextRestore' function is implemented by the 'yielding' algorithm
114 * instance and must be called by the framework following a context switch
115 * which occured as a result of the 'yield', prior to returning from the
116 * framework supplied 'yield-function'.
117 *
118 * Any 'scratch' IRES, IALG or IDMA3 resource owned by the algorithm must
119 * be considered in volatile state during a 'yield' call, and must be
120 * re-initialized and activated following any context swith.
121 * The 'contextRestore' function uses the saved context information in
122 * the preceeding 'contextSave' call to re-initialize and activate its
123 * scratch resources.
124 */
125 IRES_ContextRestoreFxn contextRestore;
126
127 /**
128 * The arguments that must be passed when calling the 'contextSave()'
129 * and 'contextRestore()' functions.
130 * The algorithm instance calling the 'yield function' optionally
131 * supplies any 'contextArgs' that it wants the framework to passed to the
132 * 'contextSave()' and 'contextRestore()' functions.
133 */
134 Void *contextArgs;
135
136} IRES_YieldContext;
137
138
139typedef IRES_YieldContext *IRES_YieldContextHandle;
140typedef Void *IRES_YieldArgs;
141
142/**
143 * @brief The 'yield function' pointer and 'yield arguments' are supplied
144 * to an algorithm during its IRES interface 'initialization'.
145 * The algorithm optionally calls the yield function during its
146 * 'process' stages for co-operative multi-tasking and pre-emption
147 * by a higher priority algorithm.
148 *
149 * An operating system level context switch may occur during the
150 * yield call. Whenever a context switch occurs, all
151 * scratch resources owned by the yielding algorithm must be
152 * context saved prior to the context switch and restored and
153 * initialized prior to 'resumption' by the framework/application.
154 * The 'yielding' algorithm must supply the IRES_YieldContext and
155 * the 'yield arguments' it received during IRES initialization.
156 * The framework calls the context save & restore functions
157 * provided by the yielding algorithm's IRES_YieldContext.
158 */
159typedef Void (*IRES_YieldFxn)(IRES_YieldResourceType resourceType,
160 IRES_YieldContextHandle algYieldContext, IRES_YieldArgs yieldArgs);
161
162/**
163 * @brief These fxns are used to query/grant the resources requested
164 * by the algorithm at initialization time, and to change these
165 * resources at runtime. All these fxns are implemented by the
166 * algorithm, and called by the client of the algorithm.
167 */
168typedef struct IRES_Fxns {
169
170 /**
171 * @brief Unique pointer that identifies the module implementing this
172 * interface.
173 */
174 Void *implementationId;
175
176 /**
177 * @brief Query function to obtain the list of IRES resources requested
178 * by the algorithm instance.
179 */
180 IRES_Status (*getResourceDescriptors)(IALG_Handle handle,
181 IRES_ResourceDescriptor *resourceDescriptors);
182
183 /**
184 * @brief Query function to obtain the number of IRES resources
185 * requested by the algorithm instance, which is also the number
186 * of resource descriptors that must be passed to the
187 * getResourceDescriptors() function.
188 *
189 */
190 Int32 (*numResourceDescriptors)(IALG_Handle handle);
191
192 /**
193 * @brief Assignment function to grant the algorithm instance the list
194 * of IRES resources it requested. The algorithm can initialize
195 * internal instance memory with resource information, but may not
196 * use or access the resource state until the resource is
197 * activated via the activateResource call.
198 *
199 * @remark Version of the resource handle being granted is updated in
200 * the resourceDescriptor, and may be different from the one
201 * requested.
202 */
203 IRES_Status (*initResources)(IALG_Handle handle,
204 IRES_ResourceDescriptor *resourceDescriptor,
205 IRES_YieldFxn yieldFxn, IRES_YieldArgs yieldArgs);
206
207 /**
208 * @brief Re-assignment function to grant the algorithm instance
209 * a list of "modified" IRES resources.
210 * The algorithm may choose to not support the re-assignment and
211 * indicate this by returning failure.
212 * In case of success the algorithm updates its internal state
213 * to reflect the new resource information, but may not
214 * use or access the resource state until the resource is
215 * activated via the activateResource call.
216 */
217 IRES_Status (*reinitResources)(IALG_Handle handle,
218 IRES_ResourceDescriptor *resourceDescriptor,
219 IRES_YieldFxn yieldFxn, IRES_YieldArgs yieldArgs);
220
221 /**
222 * @brief Deinitialization function to revoke back the resources
223 * that have been granted to the algorithm instance.
224 */
225 IRES_Status (*deinitResources)(IALG_Handle handle,
226 IRES_ResourceDescriptor *resourceDescriptor);
227
228 /**
229 * @brief Resource Activation call to grant the algorithm instance
230 * exclusive access to the potentially shared resource.
231 * Algorithm can now access, initialize and or restore from a
232 * previous context saved during deactivation to use the resource.
233 * Each resource must be activated individually to give the
234 * framework optimization opportunities by tracking and deciding
235 * which resources truely require activation.
236 */
237 IRES_Status (*activateResource)(IALG_Handle handle,
238 IRES_Handle resourceHandle);
239
240 /**
241 * @brief Resource Activation call to grant the algorithm instance
242 * exclusive access to all resources it acquired via IRES.
243 * Algorithm can now access, initialize and or restore from a
244 * previous context saved during deactivation to use the resources.
245 */
246 IRES_Status (*activateAllResources)(IALG_Handle handle);
247
248 /**
249 * @brief Resource Deactivation call to revoke the algorithm instance's
250 * exclusive access to the potentially shared resource.
251 * Algorithm must save any context that is needed to restore the
252 * state during the next resource activation call.
253 */
254 IRES_Status (*deactivateResource)(IALG_Handle handle,
255 IRES_Handle resourceHandle);
256
257 /**
258 * @brief Resource Deactivation call to revoke the algorithm instance's
259 * exclusive access to ALL shared resources.
260 * Algorithm must save any context that is needed to restore the
261 * state during the next resource activation call.
262 */
263 IRES_Status (*deactivateAllResources)(IALG_Handle handle);
264
265} IRES_Fxns;
266
267/*@}*/
268
269
270#ifdef __cplusplus
271}
272#endif /* extern "C" */
273
274
275#endif /* IRES_ */
276