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.runtime.Error;
38 import ti.sdo.ipc.Ipc;
39 import ti.sdo.ipc.GateMP;
40 import ti.sdo.ipc.ListMP;
41 import ti.sdo.ipc.SharedRegion;
42 import ti.sysbios.knl.Swi;
43
44 /*!
45 * ======== TransportShm ========
46 * Transport for MessageQ that acts on shared memory.
47 *
48 */
49 @InstanceFinalize
50 @InstanceInitError
51
52 module TransportShm inherits ti.sdo.ipc.interfaces.IMessageQTransport
53 {
54 /*! @_nodoc
55 * ======== openByAddr ========
56 * Open a created TransportShm instance by address
57 *
58 * Just like {@link #open}, openByAddr returns a handle to a created
59 * TransportShm instance. This function is used to open a
60 * TransportShm using a shared address instead of a name.
61 * While {@link #open} should generally be used to open transport
62 * instances that have been either locally or remotely created, openByAddr
63 * may be used to bypass a NameServer query that would typically be
64 * required of an {@link #open} call.
65 *
66 * Opening by address requires that the created instance was created
67 * by supplying a {@link #sharedAddr} parameter rather than a
68 * {@link #regionId} parameter.
69 *
70 * A status value of Status_SUCCESS is returned if the instance
71 * is successfully opened. Status_FAIL indicates that the instance
72 * is not yet ready to be opened. Status_ERROR indicates that
73 * an error was raised in the error block.
74 *
75 * Call {@link #close} when the opened instance is no longer needed.
76 *
77 * @param(sharedAddr) Shared address for the instance
78 * @param(handlePtr) Pointer to handle to be opened
79 * @param(eb) Pointer to error block
80 *
81 * @a(returns) TransportShm status
82 */
83 Int openByAddr(Ptr sharedAddr, Handle *handlePtr, Error.Block *eb);
84
85 /*!
86 * ======== close ========
87 * Close an opened instance
88 *
89 * Closing an instance will free local memory consumed by the opened
90 * instance. Instances that are opened should be closed before the
91 * instance is deleted.
92 *
93 * @param(handle) handle that is returned from an {@link #openByAddr}
94 */
95 Void close(Handle *handle);
96
97 /*! @_nodoc
98 * ======== sharedMemReq ========
99 * Amount of shared memory required for creation of each instance
100 *
101 * Can be used to make sure the {link #sharedAddr} buffer is large
102 * enough before calling create.
103 *
104 * The {@link #sharedAddr} needs to be
105 * supplied because the cache alignment settings for the region
106 * may affect the total amount of shared memory required.
107 *
108 * @param(params) Pointer to the parameters that will be used in
109 * the create.
110 *
111 * @a(returns) Number of MAUs needed to create the instance.
112 */
113 SizeT sharedMemReq(const Params *params);
114
115 /*!
116 * ======== notifyEventId ========
117 * Notify event ID for transport.
118 */
119 config UInt16 notifyEventId = 2;
120
121 instance:
122
123 /*!
124 * ======== gate ========
125 * GateMP used for critical region management of the shared memory
126 */
127 config GateMP.Handle gate = null;
128
129 /*! @_nodoc
130 * ======== openFlag ========
131 * Set to 'true' by the open() call. No one else should touch this!
132 */
133 config Bool openFlag = false;
134
135 /*!
136 * ======== sharedAddr ========
137 * Physical address of the shared memory
138 *
139 * The creator must supply the shared memory that is used to maintain
140 * shared state information.
141 */
142 config Ptr sharedAddr = null;
143
144 internal:
145
146 /*!
147 * Constants that all delegate writers need.
148 */
149 const UInt32 UP = 0xBADC0FFE;
150
151 /*!
152 * ======== swiFxn ========
153 * This function takes the messages from the transport ListMP and
154 * calls MessageQ_put to send them to their destination queue.
155 * This function is posted by the NotifyFxn.
156 *
157 * @param(arg) argument for the function
158 */
159 Void swiFxn(UArg arg);
160
161 /*!
162 * ======== notifyFxn ========
163 * This is a callback function registered with Notify. It is called
164 * when a remote processor does a Notify_sendEvent(). It is executed
165 * at ISR level. It posts the instance Swi object to execute swiFxn.
166 *
167 * @param(eventId) Notify event id
168 * @param(arg) argument for the function
169 * @param(payload) 32-bit payload value.
170 */
171 Void notifyFxn(UInt16 procId, UInt16 lineId, UInt32 eventId, UArg arg,
172 UInt32 payload);
173
174
175 struct Attrs {
176 Bits32 flag;
177 Bits32 creatorProcId;
178 Bits32 notifyEventId;
179 Bits16 priority;
180 SharedRegion.SRPtr gateMPAddr;
181 };
182
183
184 struct Instance_State {
185 Attrs *self;
186 Attrs *other;
187 ListMP.Handle localList;
188 ListMP.Handle remoteList;
189 Swi.Object swiObj;
190 Int status;
191 Ipc.ObjType objType;
192 SizeT allocSize;
193 Bool cacheEnabled;
194 UInt16 regionId;
195 UInt16 remoteProcId;
196 UInt16 priority;
197 GateMP.Handle gate;
198 };
199
200 }
201 202 203
204