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 * @def Resource_S_SUCCESS
69 * @brief Operation is successful.
70 */
71 const Int S_SUCCESS = 0;
73 /*!
74 * @def Resource_E_NOTFOUND
75 * @brief Element was not found in table
76 */
77 const Int E_NOTFOUND = -1;
79 /*!
80 * @def Resource_RscTable
81 *
82 * @brief An open-ended type-length-value based resource table
83 */
84 struct RscTable {
85 UInt32 ver;
86 UInt32 num;
87 UInt32 reserved[2];
88 UInt32 offset[1];
89 };
91 /*!
92 * @def Resource_MemEntry
93 *
94 * @brief A Resource Table memory type record
95 */
96 struct MemEntry {
97 UInt32 type;
98 UInt32 da; /* Device Virtual Address */
99 UInt32 pa; /* Physical Address */
100 UInt32 len;
101 UInt32 flags;
102 UInt32 reserved;
103 Char name[32];
104 };
106 /*!
107 * @brief Virtual to Physical address translation function
108 *
109 * @sa Resource_physToVirt
110 */
111 @DirectCall
112 Int virtToPhys(UInt32 da, UInt32 *pa);
114 /*!
115 * @brief Physical to Virtual address translation function
116 *
117 * @sa Resource_virtToPhys
118 */
119 @DirectCall
120 Int physToVirt(UInt32 pa, UInt32 *da);
122 /*!
123 * @brief Get the Trace Buffer address from resource table.
124 *
125 * @return Pointer to trace buffer, or NULL if not found.
126 */
127 @DirectCall
128 Ptr getTraceBufPtr();
130 /*!
131 * @brief Get the nth (vqId) vring address from the VDEV struct.
132 *
133 * @return NULL if no VDEV found, or vqId is not found.
134 */
135 @DirectCall
136 Ptr getVringDA(UInt32 vqId);
138 internal: /* not for client use */
140 /*!
141 * @brief Use resource and resourceLen so table could be properly
142 * allocated
143 *
144 */
145 Void init();
147 /*!
148 * @brief Return the i-th entry in the resource table if the entry
149 * is of type CARVEOUT or DEVMEM, or NULL otherwise.
150 *
151 */
152 MemEntry *getMemEntry(UInt index);
154 struct Module_State {
155 RscTable *pTable; /* Resource Resource Table pointer */
156 };
157 }