1 /*
2 * Copyright (c) 2014 Texas Instruments Incorporated - http://www.ti.com
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
33 /*
34 * ======== NotifyDriverMbx.xdc ================
35 */
36 package ti.sdo.ipc.family.vayu;
38 import ti.sdo.utils.MultiProc;
39 import ti.sdo.ipc.interfaces.INotifyDriver;
40 import ti.sdo.ipc.Notify;
42 import ti.sysbios.hal.Hwi;
44 import xdc.runtime.Assert;
45 import xdc.rov.ViewInfo;
47 /*!
48 * ======== NotifyDriverMbx ========
49 * A notify driver based on hardware mailbox.
50 *
51 * This notify driver uses hardware mailboxes to transmit notifications
52 * to remote processors. This driver implements the
53 * {@link ti.sdo.ipc.interfaces.INotifyDriver} interface.
54 *
55 * Unlike the Notify drivers available in the {@link ti.sdo.ipc.notifyDrivers}
56 * package, this driver is not generic and will only work with the Vayu
57 * family of devices.
58 *
59 * The driver does not use shared memory. The event IDs and payloads are
60 * transmitted via the hardware mailbox FIFO. The FIFO can hold up to 4
61 * mailbox messages. The number of notification that can be stored in the
62 * FIFO depends on the size of the payloads being sent via Notify_sendEvent.
63 * If the payload is less than 0x7FFFFFF, then a single message will be
64 * sent per notification. Otherwise, two mailbox messages are needed to
65 * send the notification.
66 *
67 * The behavior of Notify_sendEvent when the FIFO is full depends on the
68 * value of the 'waitClear' argument to the function. If 'waitClear' is
69 * TRUE, then Notify_sendEvent will spin waiting for enough room in the
70 * FIFO. If 'waitClear' is FALSE, then Notify_sendEvent will return
71 * Notify_E_FAIL.
72 *
73 * The Notify_enableEvent and Notify_disableEvent APIs are not supported
74 * by this driver.
75 */
76 @InstanceFinalize
77 @ModuleStartup
79 module NotifyDriverMbx inherits ti.sdo.ipc.interfaces.INotifyDriver
80 {
81 /*! @_nodoc */
82 metaonly struct BasicView {
83 String remoteProc;
84 String mailboxAddr;
85 Int subMbxId;
86 Int count;
87 }
89 /*! @_nodoc */
90 metaonly struct ModuleView {
91 UInt16 interruptTable[NUM_CORES];
92 NotifyDriverMbx.Handle drvHandles[NUM_CORES];
93 }
95 /*!
96 * ======== rovViewInfo ========
97 */
98 @Facet
99 metaonly config ViewInfo.Instance rovViewInfo =
100 ViewInfo.create({
101 viewMap: [
102 ['Basic',
103 {
104 type: ViewInfo.INSTANCE,
105 viewInitFxn: 'viewInitBasic',
106 structName: 'BasicView'
107 }
108 ]
109 // ['Module',
110 // {
111 // type: ViewInfo.MODULE,
112 // viewInitFxn: 'viewInitModule',
113 // structName: 'ModuleView'
114 // }
115 // ]
116 ]
117 });
119 /*!
120 * Assert raised when trying to use Notify_[enable/disable]Event with
121 * NotifyDriverMbx
122 */
123 config Assert.Id A_notSupported = {
124 msg: "A_notSupported: [enable/disable]Event not supported"
125 };
127 instance:
129 /*!
130 * ======== remoteProcId ========
131 * The MultiProc ID corresponding to the remote processor
132 *
133 * This is a required parameter, it is not optional.
134 */
135 config UInt16 remoteProcId = MultiProc.INVALIDID;
137 /*!
138 * ======== intVectorId ========
139 * Interrupt vector ID to be used by the driver.
140 *
141 * This parameter is only used by C66 targets.
142 * This is a required parameter, it is not optional.
143 */
144 config UInt intVectorId = ~1u;
146 internal:
147 /* total number of cores on Vayu SoC */
148 const UInt8 NUM_CORES = 11;
150 /* number of cores in eve subsystem */
151 const UInt8 NUM_EVES = 4;
153 /* number of internal eve mailboxes */
154 const UInt8 NUM_EVE_MBX = 12;
156 /* number of system mailboxes (used by IPC) */
157 const UInt8 NUM_SYS_MBX = 4;
159 /* Mailbox table for storing encoded base address, mailbox user ID,
160 * and sub-mailbox index.
161 */
162 config UInt32 mailboxTable[NUM_CORES * NUM_CORES];
164 /* base address table for the mailbox subsystem */
165 config UInt32 mailboxBaseAddr[NUM_EVE_MBX + NUM_SYS_MBX];
167 /* map MultiProc ID to virtual ID, virtId = procIdTable[procId] */
168 config UInt32 procIdTable[NUM_CORES];
170 /*! define MultiProcID for each core to avoid doing this at runtime */
171 config UInt eve1ProcId = MultiProc.INVALIDID;
172 config UInt eve2ProcId = MultiProc.INVALIDID;
173 config UInt eve3ProcId = MultiProc.INVALIDID;
174 config UInt eve4ProcId = MultiProc.INVALIDID;
175 config UInt dsp1ProcId = MultiProc.INVALIDID;
176 config UInt dsp2ProcId = MultiProc.INVALIDID;
177 config UInt ipu1_0ProcId = MultiProc.INVALIDID;
178 config UInt ipu2_0ProcId = MultiProc.INVALIDID;
179 config UInt hostProcId = MultiProc.INVALIDID;
180 config UInt ipu1_1ProcId = MultiProc.INVALIDID;
181 config UInt ipu2_1ProcId = MultiProc.INVALIDID;
183 /* plugs the interrupt and executes the callback functions */
184 Void isr(UInt16 idx);
186 /*! instance state structure */
187 struct Instance_State {
188 Bits32 evtRegMask; /* local event register mask */
189 Notify.Handle notifyHandle; /* handle to front-end object */
190 UInt16 remoteProcId; /* remote processor ID */
191 UInt16 remoteVirtId; /* remote processor virtual ID */
192 Int cpuIntrNum; /* cpu interrupt number */
193 }
195 struct Module_State {
196 /* Interrupt event IDs used to communicate with this processor.
197 * This table is indexed by virtual processor ID.
198 * TODO: move this table to NotifySetup module
199 */
200 UInt16 interruptTable[NUM_CORES];
202 /* Used by the isr to retrieve the driver handle. This table is
203 * indexed by virtual processorID.
204 */
205 NotifyDriverMbx.Handle drvHandles[NUM_CORES];
206 };
207 }