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 import xdc.runtime.Assert;
39
40 /*!
41 * ======== GateSmp ========
42 * Hwi, Swi & Task Gate
43 *
44 * GateSmp uses disabling and enabling of interrupts, Swis and Tasks for the
45 * resource locking mechanism. Such a gate guarantees exclusive access to the
46 * CPU. This gate can be used whenever the resource is being shared by Tasks,
47 * Swis, and/or Hwis.
48 *
49 * The duration between the enter and leave should be as short as possible
50 * to minimize Hwi latency.
51 *
52 * GateSmp inherits from xdc.runtime.IGateProvider, therefore supports nesting.
53 *
54 * @p(html)
55 * <h3> Calling Context </h3>
56 * <table border="1" cellpadding="3">
57 * <colgroup span="1"></colgroup> <colgroup span="5" align="center">
58 * </colgroup>
59 *
60 * <tr><th> Function </th><th> Hwi </th><th> Swi </th><th> Task </th>
61 * <th> Main </th><th> Startup </th></tr>
62 * <!-- -->
63 * <tr><td> {@link #Params_init} </td><td> Y </td><td> Y </td>
64 * <td> Y </td><td> Y </td><td> Y </td></tr>
65 * <tr><td> {@link #query} </td><td> Y </td><td> Y </td>
66 * <td> Y </td><td> Y </td><td> Y </td></tr>
67 * <tr><td> {@link #construct} </td><td> Y </td><td> Y </td>
68 * <td> Y </td><td> Y </td><td> N </td></tr>
69 * <tr><td> {@link #create} </td><td> N* </td><td> N* </td>
70 * <td> Y </td><td> Y </td><td> N </td></tr>
71 * <tr><td> {@link #delete} </td><td> N* </td><td> N* </td>
72 * <td> Y </td><td> Y </td><td> N </td></tr>
73 * <tr><td> {@link #destruct} </td><td> Y </td><td> Y </td>
74 * <td> Y </td><td> Y </td><td> N </td></tr>
75 * <tr><td> {@link #enter} </td><td> Y </td><td> Y </td>
76 * <td> Y </td><td> Y** </td><td> Y** </td></tr>
77 * <tr><td> {@link #leave} </td><td> Y </td><td> Y </td>
78 * <td> Y </td><td> Y** </td><td> Y** </td></tr>
79 * <tr><td> {@link #sync} </td><td> Y </td><td> Y </td>
80 * <td> Y </td><td> Y** </td><td> Y** </td></tr>
81 * <tr><td colspan="6"> Definitions: <br />
82 * <ul>
83 * <li> <b>Hwi</b>: API is callable from a Hwi thread. </li>
84 * <li> <b>Swi</b>: API is callable from a Swi thread. </li>
85 * <li> <b>Task</b>: API is callable from a Task thread. </li>
86 * <li> <b>Main</b>: API is callable during any of these phases: </li>
87 * <ul>
88 * <li> In your module startup after this module is started
89 * (e.g. GateSmp_Module_startupDone() returns TRUE). </li>
90 * <li> During xdc.runtime.Startup.lastFxns. </li>
91 * <li> During main().</li>
92 * <li> During BIOS.startupFxns.</li>
93 * </ul>
94 * <li> <b>Startup</b>: API is callable during any of these phases:</li>
95 * <ul>
96 * <li> During xdc.runtime.Startup.firstFxns.</li>
97 * <li> In your module startup before this module is started
98 * (e.g. GateSmp_Module_startupDone() returns FALSE).</li>
99 * </ul>
100 * <li> <b>*</b>: Assuming blocking Heap is used for creation. </li>
101 * <li> <b>**</b>: Must be used in enter/leave pairs. </li>
102 * </ul>
103 * </td></tr>
104 *
105 * </table>
106 * @p
107 */
108
109 module GateSmp inherits xdc.runtime.IGateProvider
110 {
111
112 /*!
113 * ======== BasicView ========
114 * @_nodoc
115 */
116 metaonly struct BasicView {
117 String label;
118 String owner;
119 String gateValue;
120 UInt stalls;
121 UInt noStalls;
122 UInt totalStalls;
123 UInt maxStall;
124 }
125
126 /*!
127 * ======== rovViewInfo ========
128 * @_nodoc
129 */
130 @Facet
131 metaonly config ViewInfo.Instance rovViewInfo =
132 ViewInfo.create({
133 viewMap: [
134 ['Basic', {type: ViewInfo.INSTANCE, viewInitFxn: 'viewInitBasic', structName: 'BasicView'}],
135 ]
136 });
137
138 /*! Assert if nested "enter" called. */
139 config Assert.Id A_nestedEnter = {
140 msg: "A_nestedEnter: Can't nest 'enter' calls."
141 };
142
143 /*!
144 * Gate statistics collection flag. Default is disabled.
145 */
146 config bool enableStats = false;
147
148 instance:
149
150 /*!
151 * ======== enter ========
152 * Enter this gate
153 *
154 * @a(constraints)
155 * Must be called with interrupts enabled
156 */
157 override IArg enter();
158
159 /*!
160 * ======== leave ========
161 * Leave this gate
162 *
163 * @a(constraints)
164 * Must be called with interrupts enabled
165 */
166 override Void leave(IArg key);
167
168 /*!
169 * Sync execution with the other M3 core.
170 */
171 Void sync();
172
173 internal:
174
175
176
177 struct Instance_State {
178 volatile UInt32 gateWord;
179 volatile UInt owner;
180
181
182 UInt stalls;
183 UInt noStalls;
184 UInt totalStalls;
185 UInt maxStall;
186 };
187 }