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 import xdc.runtime.Error;
37 import xdc.runtime.Assert;
38
39 import xdc.rov.ViewInfo;
40
41 import ti.sysbios.knl.Swi;
42 import ti.sysbios.syncs.SyncSwi;
43 import ti.sysbios.knl.Semaphore;
44 import ti.sysbios.gates.GateMutex;
45 import ti.sdo.ipc.MessageQ;
46 import ti.sdo.utils.INameServerRemote;
47
48 /*!
49 * ======== NameServerMessageQ ========
50 * Used by NameServer to communicate to remote processors.
51 *
52 * This module is used by {@link ti.sdo.utils.NameServer} to communicate
53 * to remote processors using {@link ti.sdo.ipc.MessageQ}.
54 * There needs to be one instance between each two cores in the system.
55 * Interrupts must be enabled before using this module.
56 * This module does not require any share memory.
57 */
58 @ModuleStartup
59 @InstanceFinalize
60
61 module NameServerMessageQ inherits INameServerRemote
62 {
63 /*! maximum number of characters for name in bytes */
64 const UInt maxNameLen = 32;
65
66 /*!
67 * Assert raised if first MessageQ created already
68 */
69 config Assert.Id A_reservedMsgQueueId = {
70 msg: "MessageQ Id 0 is reserved for NameServer"
71 };
72
73 /*!
74 * Assert raised if too many characters in the name
75 */
76 config Assert.Id A_nameIsTooLong = {
77 msg: "Too many characters in name"
78 };
79
80 /*!
81 * Error raised if all the message queue objects are taken
82 */
83 config Error.Id E_outOfMemory = {
84 msg: "E_outOfMemory: MessageQ_alloc faild from heap: %d"
85 };
86
87 /*!
88 * ======== heapId ========
89 * The heap from which to alloc a message.
90 */
91 config UInt16 heapId = 0;
92
93 /*!
94 * ======== timeoutInMicroSecs ========
95 * The timeout value in terms of microseconds
96 *
97 * A NameServer request will return after this amout of time
98 * without a response. The default timeout value is 1 s.
99 * To not wait, use the value of '0'. To wait forever, use '~(0)'.
100 */
101 config UInt timeoutInMicroSecs = 1000000;
102
103 internal:
104
105 106 107 108 109 110 111
112 config UInt timeout;
113
114 /*!
115 * ======== Type ========
116 * The type of the message
117 */
118 enum Type {
119 REQUEST = 0,
120 RESPONSE = 1
121 };
122
123 /*!
124 * ======== swiFxn ========
125 * The swi function that will be executed during the call back.
126 *
127 * @param(arg0) argument 0 to swi function
128 * @param(arg1) argument 1 to swi function
129 */
130 Void swiFxn(UArg arg0, UArg arg1);
131
132
133 struct Instance_State {
134 UInt16 remoteProcId;
135 };
136
137
138 struct Module_State {
139 MessageQ.Handle msgHandle;
140 Swi.Handle swiHandle;
141 SyncSwi.Handle syncSwiHandle;
142 Semaphore.Handle semRemoteWait;
143 GateMutex.Handle gateMutex;
144 Ptr msg;
145 };
146 }