1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
47
48 import xdc.runtime.Error;
49 import ti.sdo.utils.NameServer;
50
51 /*!
52 * ======== ListMP ========
53 * Shared memory linked list
54 *
55 * @p(html)
56 * This module has a common header that can be found in the {@link ti.ipc}
57 * package. Application code should include the common header file (not the
58 * RTSC-generated one):
59 *
60 * <PRE>#include <ti/ipc/ListMP.h></PRE>
61 *
62 * The RTSC module must be used in the application's RTSC configuration file
63 * (.cfg):
64 *
65 * <PRE>ListMP = xdc.useModule('ti.sdo.ipc.ListMP');</PRE>
66 *
67 * Documentation for all runtime APIs, instance configuration parameters,
68 * error codes macros and type definitions available to the application
69 * integrator can be found in the
70 * <A HREF="../../../../doxygen/html/files.html">Doxygen documenation</A>
71 * for the IPC product. However, the documentation presented on this page
72 * should be referred to for information specific to the RTSC module, such as
73 * module configuration, Errors, and Asserts.
74 * @p
75 */
76 @InstanceInitError
77 @InstanceFinalize
78
79 module ListMP
80 {
81 /*!
82 * ======== BasicView ========
83 * @_nodoc
84 * ROV view structure representing a ListMP instance.
85 */
86 metaonly struct BasicView {
87 String label;
88 String type;
89 String gate;
90 }
91
92 /*!
93 * ======== ElemView ========
94 * @_nodoc
95 * ROV view structure representing a single list element.
96 */
97 metaonly struct ElemView {
98 Int index;
99 String srPtr;
100 String addr;
101 }
102
103 /*!
104 * ======== rovViewInfo ========
105 * @_nodoc
106 */
107 @Facet
108 metaonly config xdc.rov.ViewInfo.Instance rovViewInfo =
109 xdc.rov.ViewInfo.create({
110 viewMap: [
111 ['Basic',
112 {
113 type: xdc.rov.ViewInfo.INSTANCE,
114 viewInitFxn: 'viewInitBasic',
115 structName: 'BasicView'
116 }
117 ],
118 ['Lists',
119 {
120 type: xdc.rov.ViewInfo.INSTANCE_DATA,
121 viewInitFxn: 'viewInitLists',
122 structName: 'ElemView'
123 }
124 ],
125 ]
126 });
127
128 /*!
129 * ======== maxRuntimeEntries ========
130 * Maximum number of ListMP's that can be dynamically created
131 * and added to the NameServer.
132 */
133 metaonly config UInt maxRuntimeEntries = NameServer.ALLOWGROWTH;
134
135 /*!
136 * ======== maxNameLen ========
137 * Maximum length for names.
138 */
139 metaonly config UInt maxNameLen = 32;
140
141 /*!
142 * ======== tableSection ========
143 * Section name is used to place the names table
144 */
145 metaonly config String tableSection = null;
146
147
148 instance:
149
150 /*!
151 * ======== gate ========
152 * GateMP used for critical region management of the shared memory
153 *
154 * Using the default value of NULL will result in the default GateMP
155 * being used for context protection.
156 */
157 config GateMP.Handle gate = null;
158
159 /*! @_nodoc
160 * ======== openFlag ========
161 * Set to 'true' by the {@link #open}.
162 */
163 config Bool openFlag = false;
164
165 /*! @_nodoc
166 * ======== sharedAddr ========
167 * Physical address of the shared memory
168 *
169 * The shared memory that will be used for maintaining shared state
170 * information. This is an optional parameter to create. If value
171 * is null, then the shared memory for the new instance will be
172 * allocated from the heap in {@link #regionId}.
173 */
174 config Ptr sharedAddr = null;
175
176 /*!
177 * ======== name ========
178 * Name of the instance
179 *
180 * The name must be unique among all ListMP instances in the sytem.
181 * When using {@link #regionId} to create a new instance, the name must
182 * not be null.
183 */
184 config String name = null;
185
186 /*!
187 * ======== regionId ========
188 * SharedRegion ID.
189 *
190 * The ID corresponding to the index of the shared region in which this
191 * shared instance is to be placed. This is used in create() only when
192 * {@link #name} is not null.
193 */
194 config UInt16 regionId = 0;
195
196 /*! @_nodoc
197 * ======== metaListMP ========
198 * Used to store elem before the object is initialized.
199 */
200 metaonly config any metaListMP[];
201
202
203 internal:
204
205 const UInt32 CREATED = 0x12181964;
206
207 /*!
208 * ======== Elem ========
209 * Opaque ListMP element
210 *
211 * A field of this type must be placed at the head of client structs.
212 */
213 @Opaque struct Elem {
214 volatile SharedRegion.SRPtr next;
215 volatile SharedRegion.SRPtr prev;
216 };
217
218
219 /*!
220 * ======== nameSrvPrms ========
221 * This Params object is used for temporary storage of the
222 * module wide parameters that are for setting the NameServer instance.
223 */
224 metaonly config NameServer.Params nameSrvPrms;
225
226 /*!
227 * ======== elemClear ========
228 * Clears a ListMP element's pointers
229 *
230 * This API is not for removing elements from a ListMP, and
231 * should never be called on an element in a ListMP--only on deListed
232 * elements.
233 *
234 * @param(elem) element to be cleared
235 */
236 Void elemClear(Elem *elem);
237
238
239 Void postInit(Object *obj, Error.Block *eb);
240
241 /*! Structure of attributes in shared memory */
242 struct Attrs {
243 Bits32 status;
244 SharedRegion.SRPtr gateMPAddr;
245 Elem head;
246 };
247
248
249 struct Instance_State {
250 Attrs *attrs;
251 Ptr nsKey;
252 Ipc.ObjType objType;
253 GateMP.Handle gate;
254 SizeT allocSize;
255 UInt16 regionId;
256 Bool cacheEnabled;
257 SizeT cacheLineSize;
258 };
259
260
261 struct Module_State {
262 NameServer.Handle nameServer;
263 };
264 }