1 /*
2 * Copyright (c) 2011-2013, 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_traceOnly
61 * @brief Set traceOnly to true in order to get an image with trace
62 * resources only, and without VRINGs.
63 * Implemented only for the Keystone II (TCI6638) platform.
64 */
65 metaonly config Bool traceOnly = false;
67 /*!
68 * Flag to indicate the user will provide a custom resource table
69 *
70 * If false (the default), a default resource table will be
71 * created during configuration.
72 *
73 * If true, the user must supply their own resource table.
74 * Fundamentally, this amounts to providing a well-formed
75 * resource_table structure named 'ti_ipc_remoteproc_ResourceTable'.
76 */
77 metaonly config Bool customTable = false;
79 /*!
80 * @def Resource_S_SUCCESS
81 * @brief Operation is successful.
82 */
83 const Int S_SUCCESS = 0;
85 /*!
86 * @def Resource_E_NOTFOUND
87 * @brief Element was not found in table
88 */
89 const Int E_NOTFOUND = -1;
91 /*!
92 * @def Resource_RscTable
93 *
94 * @brief An open-ended type-length-value based resource table
95 */
96 struct RscTable {
97 UInt32 ver;
98 UInt32 num;
99 UInt32 reserved[2];
100 UInt32 offset[1];
101 };
103 /*!
104 * @def Resource_MemEntry
105 *
106 * @brief A Resource Table memory type record
107 */
108 struct MemEntry {
109 UInt32 type;
110 UInt32 da; /* Device Virtual Address */
111 UInt32 pa; /* Physical Address */
112 UInt32 len;
113 UInt32 flags;
114 UInt32 reserved;
115 Char name[32];
116 };
118 /*!
119 * @brief Virtual to Physical address translation function
120 *
121 * @sa Resource_physToVirt
122 */
123 @DirectCall
124 Int virtToPhys(UInt32 da, UInt32 *pa);
126 /*!
127 * @brief Physical to Virtual address translation function
128 *
129 * @sa Resource_virtToPhys
130 */
131 @DirectCall
132 Int physToVirt(UInt32 pa, UInt32 *da);
134 /*!
135 * @brief Get the Trace Buffer address from resource table.
136 *
137 * @return Pointer to trace buffer, or NULL if not found.
138 */
139 @DirectCall
140 Ptr getTraceBufPtr();
142 /*!
143 * @brief Get the status field of the VDEV, given the fw_rsc_vdev id.
144 *
145 * @return status value which is set by Virtio device on HLOS.
146 */
147 @DirectCall
148 Char getVdevStatus(UInt32 id);
150 /*!
151 * @brief Get the nth (vqId) vring address from the VDEV struct.
152 *
153 * @return NULL if no VDEV found, or vqId is not found.
154 */
155 @DirectCall
156 Ptr getVringDA(UInt32 vqId);
158 internal: /* not for client use */
160 /*!
161 * @brief Use resource and resourceLen so table could be properly
162 * allocated
163 *
164 */
165 Void init();
167 /*!
168 * @brief Return the i-th entry in the resource table if the entry
169 * is of type CARVEOUT or DEVMEM, or NULL otherwise.
170 *
171 */
172 MemEntry *getMemEntry(UInt index);
174 struct Module_State {
175 RscTable *pTable; /* Resource Resource Table pointer */
176 };
177 }