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 import xdc.rov.ViewInfo;
38
39 import xdc.runtime.Assert;
40
41 /*!
42 * ======== MultiProc ========
43 * Processor Id Module Manager
44 *
45 * Many IPC modules require the ability to uniquely specify and identify
46 * processors in a multi-processor environment. The MultiProc module
47 * centeralizes processor id management into one module. Since this
48 * configuration is almost always universally required, most IPC applications
49 * require supplying configuration of this module.
50 *
51 * Each processor in the MultiProc module may be uniquely identified by
52 * either a name string or an integer ranging from 0 to MAXPROCESSORS - 1.
53 * Configuration is supplied using the {@link #setConfig} meta function.
54 *
55 * The setConfig function tells the MultiProc module:
56 * @p(blist)
57 * - The specific processor for which the application is being built
58 * - Which processors out of a set of possible processors on a device are
59 * being used by the multi-processor application
60 * @p
61 *
62 * Using the information supplied using the {@link #setConfig} meta function,
63 * The {@link #numProcessors} module configuration and the processor IDs are
64 * internally set. Please refer to the documentation for {@link #setConfig}
65 * for more details.
66 *
67 * At runtime, the {@link #getId} call returns the MultiProc id
68 * for any processor. At config-time, the {@link #getIdMeta} call returns the
69 * the same value. At both run time and static time, the
70 * {@link #numProcessors} module config is equal to the length of the
71 * procNames array supplied in {@link #setConfig}.
72 *
73 */
74
75 module MultiProc
76 {
77 metaonly struct ModuleView {
78 UInt16 id;
79 UInt16 numProcessors;
80 String nameList[];
81 }
82
83 @Facet
84 metaonly config ViewInfo.Instance rovViewInfo =
85 ViewInfo.create({
86 viewMap: [
87 [
88 'Module',
89 {
90 type: ViewInfo.MODULE,
91 viewInitFxn: 'viewInitModule',
92 structName: 'ModuleView'
93 }
94 ],
95 ]
96 });
97
98 /*!
99 * Assert raised when an invalid processor id is used
100 */
101 config Assert.Id A_invalidMultiProcId = {
102 msg: "A_invalidMultiProcId: Invalid MultiProc id"
103 };
104
105 /*!
106 * Assert raised when a NULL processor name is encountered
107 */
108 config Assert.Id A_invalidProcName = {
109 msg: "A_invalidProcName: NULL MultiProc name encountered"
110 };
111
112 /*!
113 * Invalid processor id constant
114 *
115 * This constant denotes that the processor id is not valid.
116 */
117 const UInt16 INVALIDID = 0xFFFF;
118
119 /*! @_nodoc
120 * ======== nameList ========
121 * Unique name for the each processor used in a multi-processor app
122 *
123 * This array should never be set or read directly by the MultiProc user.
124 * The nameList is used to store names configuration supplied via the
125 * {@link #setConfig} static function.
126 *
127 * At runtime, the {@link #getName} function may be used to retrieve
128 * the name of any processor given it's MultiProc id.
129 */
130 config String nameList[];
131
132 /*! @_nodoc
133 * ======== id ========
134 * Unique software id number for the processor
135 *
136 * This value should never be set or read directly by the MultiProc user.
137 * Instead, the {@link #getId}, {@link #getIdMeta}, and
138 * {@link #setLocalId} calls should be used to respectively retrieve any
139 * processors' MultiProc ids or set the local processor's MultiProc id.
140 */
141 config UInt16 id = 0;
142
143 /*!
144 * ======== numProcessors ========
145 * Number of processors in the system
146 *
147 * This configuration should only be read from and should never be set:
148 * numProcessors is internally set by the {@link #setConfig} meta function.
149 * setConfig statically sets the value of this configuration to the length
150 * of the supplied nameList array. After {@link #setConfig} has been
151 * called, it is possible to retrive the maximum # of processors by
152 * reading this module config either at run-time or at config time.
153 */
154 config UInt16 numProcessors = 1;
155
156 /*!
157 * ======== getIdMeta ========
158 * Meta version of {@link #getId}
159 *
160 * Statically returns the internally set ID based on configuration
161 * supplied via {@link #setConfig}.
162 *
163 * @param(name) MultiProc procName
164 */
165 metaonly UInt16 getIdMeta(String name);
166
167 /*!
168 * ======== getDeviceProcNames ========
169 * Returns an array of all possible processor names on the build device
170 *
171 * @(return) Array of valid MultiProc processor names
172 */
173 metaonly Any getDeviceProcNames();
174
175 /*!
176 * ======== setConfig ========
177 * Configure the MultiProc module
178 *
179 * Configuration of the MultiProc module is primarily accomplished using
180 * the setConfig API at config time. The setConfig API allows the
181 * MultiProc module to identify:
182 * @p(blist)
183 * - Which is the local processor
184 * - Which processors are being used
185 * @p
186 * The second of these two pieces of information is supplied via the
187 * nameList argument. The nameList is a non-empty set of distinct
188 * processors valid for the particular device. For a list of valid
189 * processor names for a given device, please refer to the :
190 * {@link ./../ipc/family/doc-files/procNames.html Table of
191 * Valid Names for Each Device}.
192 *
193 * The local processor is identified by using a single name from
194 * nameList. A MultiProc id is internally set to the index of
195 * 'name' in the supplied 'nameList'. I.e. in the example:
196 *
197 * @p(code)
198 * MultiProc.setConfig("DSP", ["HOST", "DSP", "OTHERCORE"]);
199 * @p
200 *
201 * The processors, "HOST", "DSP" and "OTHERCORE" get assigned MultiProc
202 * IDs 0, 1, and 2, respectively. The local processor, "DSP" is assigned
203 * an ID of '1'.
204 *
205 * If the local processor is not known at static time, it is possible to
206 * supply a null name. MultiProc will set the local id to
207 * {@link #INVALIDID} until it is set at runtime using
208 * MultiProc_setLocalId.
209 *
210 * @param(name) MultiProc name for the local processor
211 * @param(nameList) Array of all processors used by the application
212 */
213 metaonly Void setConfig(String name, String nameList[]);
214
215 /*! @_nodoc
216 * ======== getName$view ========
217 * ROV-time version of {@link #getName}
218 */
219 metaonly String getName$view(UInt id);
220
221 /*! @_nodoc
222 * ======== self$view ========
223 * ROV-time version of {@link #self}
224 */
225 metaonly UInt self$view();
226
227 /*! @_nodoc
228 * This is needed to prevent the MultiProc module from being optimized away
229 * during the whole_program[_debug] partial link.
230 */
231 Void dummy();
232
233 internal:
234
235
236 struct Module_State {
237 UInt16 id;
238 };
239 }
240
241 242 243
244