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 package ti.uia.sysbios;
38
39 import xdc.runtime.Assert;
40 import xdc.rov.ViewInfo;
41 import ti.uia.runtime.UIAPacket;
42 import ti.sysbios.knl.Clock;
43 import ti.sysbios.knl.Task;
44 import ti.sysbios.knl.Event;
45 import ti.sysbios.knl.Semaphore;
46 import ti.sysbios.knl.Queue;
47 import ti.sysbios.syncs.SyncEvent;
48
49 /*!
50 * ======== Adaptor ========
51 * Single core IServiceMgrSupport implementation
52 *
53 * This module implements the IServiceMgrSupport interface
54 * and is used by the ServiceMgr on single cores. This module
55 * routes UIA data between the instrumentation host and the services
56 * via the {@link Transport} implementations. It maintains lists of
57 * free events and contrl message buffers via BIOS Semaphores and Queues.
58 *
59 * There is a Transfer Agent task (transferAgentTaskFxn). This task
60 * sends data to the instrumentation host. This task uses the
61 * {@link ServiceMgr#transportFxns} functions communicate to the host. These functions
62 * are setup by default based on the device.
63 *
64 * If {@link ti.uia.runtime.ServiceMgr#supportControl} is true, this module
65 * also creates the Receive Task (rxTaskFxn). The Receive Task receives
66 * control messages from the instrumentation host via the
67 * {@link ServiceMgr#transportFxns} functions. This task is not needed if no control
68 * messages are coming from the host.
69 *
70 * The majority of the configuration parameters are defined in the ServiceMgr.
71 * For example, the {@link ti.uia.runtime.ServiceMgr#transferAgentPriority}
72 * dictates priority of the Adaptor's Transfer Agent task. Here is the list of
73 * the ServiceMgr parameter used by the Adaptor module:
74 * @p(blist)
75 * - numEventPacketBufs
76 * - maxEventPacketSize
77 * - transferAgentStackSection
78 * - transferAgentStackSize
79 * - transferAgentPriority
80 * - supportControl
81 * - maxCtrlPacketSize
82 * - numIncomingCtrlPacketBufs
83 * - numOutgoingCtrlPacketBufs
84 * - rxTaskStackSize
85 * - rxTaskStackSection
86 * - rxTaskPriority
87 * @p
88 */
89
90 @ModuleStartup
91
92 module Adaptor inherits ti.uia.runtime.IServiceMgrSupport
93 {
94
95 /*!
96 * ======== packetSection ========
97 * Memory section for UIA packets.
98 *
99 * If this parameter is not set then the
100 * ServiceMgr.transferAgentStackSection parameter is used for the events
101 * and the ServiceMgr.rxTaskStackSection parameter is used for the control
102 * messages.
103 */
104 metaonly config String packetSection;
105
106 /*!
107 * @_nodoc
108 * ======== rxTaskFxn ========
109 * Function used for the Receive Task.
110 */
111 @DirectCall
112 Void rxTaskFxn(UArg arg0, UArg arg1);
113
114 /*!
115 * @_nodoc
116 * ======== transferAgentFxn ========
117 * Function used for the transfer agent Task.
118 */
119 @DirectCall
120 Void transferAgentTaskFxn(UArg arg0, UArg arg1);
121
122 /*!
123 * @_nodoc
124 * ======== clockFxn ========
125 * Function used to drive transfer agent's event polling
126 */
127 @DirectCall
128 Void clockFxn(UArg arg0);
129
130 internal:
131
132 /*!
133 * ======== Entry ========
134 * Structure used to place packets on a free queues
135 */
136 struct Entry {
137 Queue.Elem elem;
138 UIAPacket.Hdr packet;
139 }
140
141 /*!
142 * ======== eventBuf ========
143 * Buffer of event packets
144 */
145 config Char eventBuf[];
146
147 /*!
148 * ======== msgBuf ========
149 * Buffer of control message packets
150 */
151 config Char msgBuf[];
152
153 /*!
154 * ======== giveEnergy ========
155 * Internal helper function
156 */
157 @DirectCall
158 Void giveEnergy();
159
160 /*!
161 * ======== sendToHost ========
162 * Internal helper function
163 */
164 @DirectCall
165 Bool sendToHost(UIAPacket.Hdr *packet);
166
167 /*!
168 * ======== sendToService ========
169 * Internal helper function
170 */
171 @DirectCall
172 Void sendToService(Entry *entry);
173
174 /*!
175 * ======== runScheduledServices ========
176 * Internal helper function
177 */
178 @DirectCall
179 Void runScheduledServices();
180
181 /*!
182 * ======== Module_State ========
183 * The four queues are used as following:
184 * freeEventQ: holds "free" event packets
185 * freeMsgQ: holds "free" control message packets (both
186 * incoming and outgoing ones)
187 * incomingQ: holds all filled-in incoming messages
188 * outgoingQ: holds all filled-in outgoing messages
189 */
190 struct Module_State {
191 Event.Handle event;
192 Clock.Handle clock;
193 Semaphore.Handle freeEventSem;
194 Semaphore.Handle freeMsgSem;
195 Semaphore.Handle incomingSem;
196 Queue.Handle freeEventQ;
197 Queue.Handle freeMsgQ;
198 Queue.Handle incomingQ;
199 Queue.Handle outgoingQ;
200 SyncEvent.Handle syncEvent01;
201 Task.Handle transferAgentHandle;
202 Ptr transportMsgHandle;
203 Ptr transportEventHandle;
204 Int numMsgPacketsSent;
205 Int numMsgPacketsFailed;
206 Int numEventPacketsSent;
207 Int numEventPacketsFailed;
208 UInt32 period[];
209 UInt32 scheduled[];
210 Bool reqEnergy[];
211 };
212 }