[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / psdk_cust / ipc_3_43_00_00_eng / docs / cdoc / ti / sdo / ipc / nsremote / NameServerMessageQ-src.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html><head><title>module ti.sdo.ipc.nsremote.NameServerMessageQ</title>
3 <meta name="googlebot" content="noindex,nofollow">
4 <link rel="stylesheet" type="text/css" href="../../../../src.css"/>
5 </head>
6 <body>
7 <pre class=src>
8 1 <span class="comment">/*
9 </span> 2 <span class="comment"> * Copyright (c) 2012-2013, Texas Instruments Incorporated
10 </span> 3 <span class="comment"> * All rights reserved.
11 </span> 4 <span class="comment"> *
12 </span> 5 <span class="comment"> * Redistribution and use in source and binary forms, with or without
13 </span> 6 <span class="comment"> * modification, are permitted provided that the following conditions
14 </span> 7 <span class="comment"> * are met:
15 </span> 8 <span class="comment"> *
16 </span> 9 <span class="comment"> * * Redistributions of source code must retain the above copyright
17 </span> 10 <span class="comment"> * notice, this list of conditions and the following disclaimer.
18 </span> 11 <span class="comment"> *
19 </span> 12 <span class="comment"> * * Redistributions in binary form must reproduce the above copyright
20 </span> 13 <span class="comment"> * notice, this list of conditions and the following disclaimer in the
21 </span> 14 <span class="comment"> * documentation and/or other materials provided with the distribution.
22 </span> 15 <span class="comment"> *
23 </span> 16 <span class="comment"> * * Neither the name of Texas Instruments Incorporated nor the names of
24 </span> 17 <span class="comment"> * its contributors may be used to endorse or promote products derived
25 </span> 18 <span class="comment"> * from this software without specific prior written permission.
26 </span> 19 <span class="comment"> *
27 </span> 20 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 </span> 21 <span class="comment"> * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
29 </span> 22 <span class="comment"> * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 </span> 23 <span class="comment"> * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
31 </span> 24 <span class="comment"> * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 </span> 25 <span class="comment"> * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 </span> 26 <span class="comment"> * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
34 </span> 27 <span class="comment"> * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35 </span> 28 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
36 </span> 29 <span class="comment"> * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
37 </span> 30 <span class="comment"> * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 </span> 31 <span class="comment"> */</span>
39 32 <span class="comment">/*
40 </span> 33 <span class="comment"> * ======== NameServerMessageQ.xdc ========
41 </span> 34 <span class="comment"> */</span>
42 35
43 36 import xdc.runtime.Error;
44 37 import xdc.runtime.Assert;
45 38
46 39 import xdc.rov.ViewInfo;
47 40
48 41 import ti.sysbios.knl.Swi;
49 42 import ti.sysbios.syncs.SyncSwi;
50 43 import ti.sysbios.knl.Semaphore;
51 44 import ti.sysbios.gates.GateMutex;
52 45 import ti.sdo.ipc.MessageQ;
53 46 import ti.sdo.utils.INameServerRemote;
54 47
55 48 <span class="xdoc">/*!
56 </span> 49 <span class="xdoc"> * ======== NameServerMessageQ ========
57 </span> 50 <span class="xdoc"> * Used by NameServer to communicate to remote processors.
58 </span> 51 <span class="xdoc"> *
59 </span> 52 <span class="xdoc"> * This module is used by {<b>@link</b> ti.sdo.utils.NameServer} to communicate
60 </span> 53 <span class="xdoc"> * to remote processors using {<b>@link</b> ti.sdo.ipc.MessageQ}.
61 </span> 54 <span class="xdoc"> * There needs to be one instance between each two cores in the system.
62 </span> 55 <span class="xdoc"> * Interrupts must be enabled before using this module.
63 </span> 56 <span class="xdoc"> * This module does not require any share memory.
64 </span> 57 <span class="xdoc"> */</span>
65 58 @ModuleStartup
66 59 @InstanceFinalize
67 60
68 61 <span class=key>module</span> NameServerMessageQ <span class=key>inherits</span> INameServerRemote
69 62 {
70 63 <span class="xdoc">/*! maximum number of characters for name in bytes */</span>
71 64 <span class=key>const</span> UInt maxNameLen = 32;
72 65
73 66 <span class="xdoc">/*!
74 </span> 67 <span class="xdoc"> * Assert raised if first MessageQ created already
75 </span> 68 <span class="xdoc"> */</span>
76 69 <span class=key>config</span> Assert.Id A_reservedMsgQueueId = {
77 70 msg: <span class="string">"MessageQ Id 0 is reserved for NameServer"</span>
78 71 };
79 72
80 73 <span class="xdoc">/*!
81 </span> 74 <span class="xdoc"> * Assert raised if too many characters in the name
82 </span> 75 <span class="xdoc"> */</span>
83 76 <span class=key>config</span> Assert.Id A_nameIsTooLong = {
84 77 msg: <span class="string">"Too many characters in name"</span>
85 78 };
86 79
87 80 <span class="xdoc">/*!
88 </span> 81 <span class="xdoc"> * Error raised if all the message queue objects are taken
89 </span> 82 <span class="xdoc"> */</span>
90 83 <span class=key>config</span> Error.Id E_outOfMemory = {
91 84 msg: <span class="string">"E_outOfMemory: MessageQ_alloc faild from heap: %d"</span>
92 85 };
93 86
94 87 <span class="xdoc">/*!
95 </span> 88 <span class="xdoc"> * ======== heapId ========
96 </span> 89 <span class="xdoc"> * The heap from which to alloc a message.
97 </span> 90 <span class="xdoc"> */</span>
98 91 <span class=key>config</span> UInt16 heapId = 0;
99 92
100 93 <span class="xdoc">/*!
101 </span> 94 <span class="xdoc"> * ======== timeoutInMicroSecs ========
102 </span> 95 <span class="xdoc"> * The timeout value in terms of microseconds
103 </span> 96 <span class="xdoc"> *
104 </span> 97 <span class="xdoc"> * A NameServer request will return after this amout of time
105 </span> 98 <span class="xdoc"> * without a response. The default timeout value is 1 s.
106 </span> 99 <span class="xdoc"> * To not wait, use the value of '0'. To wait forever, use '~(0)'.
107 </span> 100 <span class="xdoc"> */</span>
108 101 <span class=key>config</span> UInt timeoutInMicroSecs = 1000000;
109 102
110 103 <span class=key>internal</span>:
111 104
112 105 <span class="comment">/*
113 </span> 106 <span class="comment"> * ======== timeout ========
114 </span> 107 <span class="comment"> * The timeout value to pass into Semaphore_pend
115 </span> 108 <span class="comment"> *
116 </span> 109 <span class="comment"> * This value is calculated based on timeoutInMicroSecs and the
117 </span> 110 <span class="comment"> * SYSBIOS clock.tickPeriod.
118 </span> 111 <span class="comment"> */</span>
119 112 <span class=key>config</span> UInt timeout;
120 113
121 114 <span class="xdoc">/*!
122 </span> 115 <span class="xdoc"> * ======== Type ========
123 </span> 116 <span class="xdoc"> * The type of the message
124 </span> 117 <span class="xdoc"> */</span>
125 118 <span class=key>enum</span> Type {
126 119 REQUEST = 0,
127 120 RESPONSE = 1
128 121 };
129 122
130 123 <span class="xdoc">/*!
131 </span> 124 <span class="xdoc"> * ======== swiFxn ========
132 </span> 125 <span class="xdoc"> * The swi function that will be executed during the call back.
133 </span> 126 <span class="xdoc"> *
134 </span> 127 <span class="xdoc"> * <b>@param(arg0)</b> argument 0 to swi function
135 </span> 128 <span class="xdoc"> * <b>@param(arg1)</b> argument 1 to swi function
136 </span> 129 <span class="xdoc"> */</span>
137 130 Void swiFxn(UArg arg0, UArg arg1);
138 131
139 132 <span class="comment">/* Instance state */</span>
140 133 <span class=key>struct</span> Instance_State {
141 134 UInt16 remoteProcId; <span class="comment">/* remote MultiProc id */</span>
142 135 };
143 136
144 137 <span class="comment">/* Module state */</span>
145 138 <span class=key>struct</span> Module_State {
146 139 MessageQ.Handle msgHandle; <span class="comment">/* messageQ for NameServer */</span>
147 140 Swi.Handle swiHandle; <span class="comment">/* instance swi object */</span>
148 141 SyncSwi.Handle syncSwiHandle; <span class="comment">/* syncSwi handle */</span>
149 142 Semaphore.Handle semRemoteWait; <span class="comment">/* sem to wait on remote proc */</span>
150 143 GateMutex.Handle gateMutex; <span class="comment">/* gate to protect critical code */</span>
151 144 Ptr msg; <span class="comment">/* pointer to response message */</span>
152 145 };
153 146 }
154 </pre>
155 </body></html>