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
37 /*!
38 * ======== Resource ========
39 * Resource Module
40 */
41
42 @Template("./Resource.xdt")
43 @ModuleStartup
44 module Resource {
45
46 /*!
47 * @def Resource_loadAddr
48 * @brief Default load address for the Resource table
49 */
50 metaonly config UInt loadAddr = 0x3000;
51
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;
58
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;
66
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;
78
79 /*!
80 * @def Resource_S_SUCCESS
81 * @brief Operation is successful.
82 */
83 const Int S_SUCCESS = 0;
84
85 /*!
86 * @def Resource_E_NOTFOUND
87 * @brief Element was not found in table
88 */
89 const Int E_NOTFOUND = -1;
90
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 };
102
103 /*!
104 * @def Resource_MemEntry
105 *
106 * @brief A Resource Table memory type record
107 */
108 struct MemEntry {
109 UInt32 type;
110 UInt32 da;
111 UInt32 pa;
112 UInt32 len;
113 UInt32 flags;
114 UInt32 reserved;
115 Char name[32];
116 };
117
118 /*!
119 * @brief Virtual to Physical address translation function
120 *
121 * @sa Resource_physToVirt
122 */
123 @DirectCall
124 Int virtToPhys(UInt32 da, UInt32 *pa);
125
126 /*!
127 * @brief Physical to Virtual address translation function
128 *
129 * @sa Resource_virtToPhys
130 */
131 @DirectCall
132 Int physToVirt(UInt32 pa, UInt32 *da);
133
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();
141
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);
149
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);
157
158 internal:
159
160 /*!
161 * @brief Use resource and resourceLen so table could be properly
162 * allocated
163 *
164 */
165 Void init();
166
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);
173
174 struct Module_State {
175 RscTable *pTable;
176 };
177 }