33124aaf6f39cf709da02ace5bee4b7dcb116d72
1 /*
2 * Copyright (c) 2011-2018, Texas Instruments Incorporated
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 * ======== Resource.xdc ========
35 */
37 /*!
38 * ======== Resource ========
39 * Resource Module
40 */
42 @Template("./Resource.xdt")
43 @ModuleStartup
44 module Resource {
46 /*!
47 * @def Resource_loadAddr
48 * @brief Default load address for the Resource table
49 */
50 metaonly config UInt loadAddr = 0x3000;
52 /*!
53 * @def Resource_loadSegment
54 * @brief If loadSegment is defined, loadAddr is overridden with the base
55 * address of the loadSegment
56 */
57 metaonly config String loadSegment;
59 /*!
60 * @def Resource_loadSymbol
61 * @brief If loadSymbol is defined, loadAddr is overridden with the
62 * loadSymbol as external pointer
63 */
64 metaonly config String loadSymbol;
67 /*!
68 * @def Resource_traceOnly
69 * @brief Set traceOnly to true in order to get an image with trace
70 * resources only, and without VRINGs.
71 * Implemented only for the Keystone II (TCI6638) platform.
72 */
73 metaonly config Bool traceOnly = false;
75 /*!
76 * Flag to indicate the user will provide a custom resource table
77 *
78 * If false (the default), a default resource table will be
79 * created during configuration.
80 *
81 * If true, the user must supply their own resource table.
82 * Fundamentally, this amounts to providing a well-formed
83 * resource_table structure named 'ti_ipc_remoteproc_ResourceTable'.
84 */
85 metaonly config Bool customTable = false;
87 /*!
88 * @def Resource_S_SUCCESS
89 * @brief Operation is successful.
90 */
91 const Int S_SUCCESS = 0;
93 /*!
94 * @def Resource_E_NOTFOUND
95 * @brief Element was not found in table
96 */
97 const Int E_NOTFOUND = -1;
99 /*!
100 * @def Resource_RscTable
101 *
102 * @brief An open-ended type-length-value based resource table
103 */
104 struct RscTable {
105 UInt32 ver;
106 UInt32 num;
107 UInt32 reserved[2];
108 UInt32 offset[1];
109 };
111 /*!
112 * @def Resource_MemEntry
113 *
114 * @brief A Resource Table memory type record
115 */
116 struct MemEntry {
117 UInt32 type;
118 UInt32 da; /* Device Virtual Address */
119 UInt32 pa; /* Physical Address */
120 UInt32 len;
121 UInt32 flags;
122 UInt32 reserved;
123 Char name[32];
124 };
126 /*!
127 * @brief Virtual to Physical address translation function
128 *
129 * @sa Resource_physToVirt
130 */
131 @DirectCall
132 Int virtToPhys(UInt32 da, UInt32 *pa);
134 /*!
135 * @brief Physical to Virtual address translation function
136 *
137 * @sa Resource_virtToPhys
138 */
139 @DirectCall
140 Int physToVirt(UInt32 pa, UInt32 *da);
142 /*!
143 * @brief Get the Trace Buffer address from resource table.
144 *
145 * @return Pointer to trace buffer, or NULL if not found.
146 */
147 @DirectCall
148 Ptr getTraceBufPtr();
150 /*!
151 * @brief Get the status field of the VDEV, given the fw_rsc_vdev id.
152 *
153 * @return status value which is set by Virtio device on HLOS.
154 */
155 @DirectCall
156 Char getVdevStatus(UInt32 id);
158 /*!
159 * @brief Get the nth (vqId) vring address from the VDEV struct.
160 *
161 * @return NULL if no VDEV found, or vqId is not found.
162 */
163 @DirectCall
164 Ptr getVringDA(UInt32 vqId);
166 internal: /* not for client use */
168 /*!
169 * @brief Use resource and resourceLen so table could be properly
170 * allocated
171 *
172 */
173 Void init();
175 /*!
176 * @brief Return the i-th entry in the resource table if the entry
177 * is of type CARVEOUT or DEVMEM, or NULL otherwise.
178 *
179 */
180 MemEntry *getMemEntry(UInt index);
182 struct Module_State {
183 RscTable *pTable; /* Resource Resource Table pointer */
184 };
185 }