1 //
2 // misc.c - miscellaneous constants
3 //
4 // $Id: //depot/rel/Foxhill/dot.8/Xtensa/OS/hal/misc.c#1 $
5 
6 // Copyright (c) 2004-2005 Tensilica Inc.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included
17 // in all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 
27 #include <xtensa/config/core.h>
28 
29 
30 // Software release info (not configuration-specific!):
31 const unsigned int  Xthal_release_major		= XTHAL_RELEASE_MAJOR;
32 const unsigned int  Xthal_release_minor		= XTHAL_RELEASE_MINOR;
33 const char * const  Xthal_release_name		= XTHAL_RELEASE_NAME;
34 #ifdef XTHAL_RELEASE_INTERNAL
35 const char * const  Xthal_release_internal	= XTHAL_RELEASE_INTERNAL;
36 #else
37 const char * const  Xthal_release_internal	= 0;
38 #endif
39 /*  Old format, for backward compatibility:  */
40 const unsigned int Xthal_rev_no = (XTHAL_MAJOR_REV<<16)|XTHAL_MINOR_REV;
41 
42 // number of registers in register window, or number of registers if not windowed
43 const unsigned int  Xthal_num_aregs		= XCHAL_NUM_AREGS;
44 const unsigned char Xthal_num_aregs_log2	= XCHAL_NUM_AREGS_LOG2;
45 
46 const unsigned char Xthal_memory_order		= XCHAL_MEMORY_ORDER;
47 const unsigned char Xthal_have_windowed		= XCHAL_HAVE_WINDOWED;
48 const unsigned char Xthal_have_density		= XCHAL_HAVE_DENSITY;
49 const unsigned char Xthal_have_booleans		= XCHAL_HAVE_BOOLEANS;
50 const unsigned char Xthal_have_loops		= XCHAL_HAVE_LOOPS;
51 const unsigned char Xthal_have_nsa		= XCHAL_HAVE_NSA;
52 const unsigned char Xthal_have_minmax		= XCHAL_HAVE_MINMAX;
53 const unsigned char Xthal_have_sext		= XCHAL_HAVE_SEXT;
54 const unsigned char Xthal_have_clamps		= XCHAL_HAVE_CLAMPS;
55 const unsigned char Xthal_have_mac16		= XCHAL_HAVE_MAC16;
56 const unsigned char Xthal_have_mul16		= XCHAL_HAVE_MUL16;
57 const unsigned char Xthal_have_fp		= XCHAL_HAVE_FP;
58 const unsigned char Xthal_have_speculation	= XCHAL_HAVE_SPECULATION;
59 const unsigned char Xthal_have_exceptions	= XCHAL_HAVE_EXCEPTIONS;
60 const unsigned char Xthal_xea_version		= XCHAL_XEA_VERSION;
61 const unsigned char Xthal_have_interrupts	= XCHAL_HAVE_INTERRUPTS;
62 const unsigned char Xthal_have_highlevel_interrupts	= XCHAL_HAVE_HIGHLEVEL_INTERRUPTS;
63 const unsigned char Xthal_have_nmi		= XCHAL_HAVE_NMI;
64 const unsigned char Xthal_have_prid		= XCHAL_HAVE_PRID;
65 const unsigned char Xthal_have_release_sync	= XCHAL_HAVE_RELEASE_SYNC;
66 const unsigned char Xthal_have_s32c1i		= XCHAL_HAVE_S32C1I;
67 const unsigned char Xthal_have_threadptr	= XCHAL_HAVE_THREADPTR;
68 
69 const unsigned char Xthal_have_pif		= XCHAL_HAVE_PIF;
70 const unsigned short Xthal_num_writebuffer_entries	= XCHAL_NUM_WRITEBUFFER_ENTRIES;
71 
72 const unsigned int  Xthal_build_unique_id	= XCHAL_BUILD_UNIQUE_ID;
73 // Release info for hardware targeted by software upgrades:
74 const unsigned int  Xthal_hw_configid0		= XCHAL_HW_CONFIGID0;
75 const unsigned int  Xthal_hw_configid1		= XCHAL_HW_CONFIGID1;
76 const unsigned int  Xthal_hw_release_major	= XCHAL_HW_VERSION_MAJOR;
77 const unsigned int  Xthal_hw_release_minor	= XCHAL_HW_VERSION_MINOR;
78 const char * const  Xthal_hw_release_name	= XCHAL_HW_VERSION_NAME;
79 const unsigned int  Xthal_hw_min_version_major	= XCHAL_HW_MIN_VERSION_MAJOR;
80 const unsigned int  Xthal_hw_min_version_minor	= XCHAL_HW_MIN_VERSION_MINOR;
81 const unsigned int  Xthal_hw_max_version_major	= XCHAL_HW_MAX_VERSION_MAJOR;
82 const unsigned int  Xthal_hw_max_version_minor	= XCHAL_HW_MAX_VERSION_MINOR;
83 #ifdef XCHAL_HW_RELEASE_INTERNAL
84 const char * const  Xthal_hw_release_internal	= XCHAL_HW_RELEASE_INTERNAL;
85 #else
86 const char * const  Xthal_hw_release_internal	= 0;
87 #endif
88 
89 /*  MMU related info...  */
90 
91 const unsigned char Xthal_have_spanning_way	= XCHAL_HAVE_SPANNING_WAY;
92 const unsigned char Xthal_have_identity_map	= XCHAL_HAVE_IDENTITY_MAP;
93 const unsigned char Xthal_have_mimic_cacheattr	= XCHAL_HAVE_MIMIC_CACHEATTR;
94 const unsigned char Xthal_have_xlt_cacheattr	= XCHAL_HAVE_XLT_CACHEATTR;
95 const unsigned char Xthal_have_cacheattr	= XCHAL_HAVE_CACHEATTR;
96 const unsigned char Xthal_have_tlbs		= XCHAL_HAVE_TLBS;
97 #if XCHAL_HAVE_MPU
98 const unsigned char Xthal_mmu_asid_bits		= 0;
99 const unsigned char Xthal_mmu_asid_kernel	= 0;
100 const unsigned char Xthal_mmu_rings		= 0;
101 const unsigned char Xthal_mmu_ring_bits		= 0;
102 const unsigned char Xthal_mmu_sr_bits		= 0;
103 const unsigned char Xthal_mmu_ca_bits		= 0;
104 #else
105 const unsigned char Xthal_mmu_asid_bits		= XCHAL_MMU_ASID_BITS;
106 const unsigned char Xthal_mmu_asid_kernel	= XCHAL_MMU_ASID_KERNEL;
107 const unsigned char Xthal_mmu_rings		= XCHAL_MMU_RINGS;
108 const unsigned char Xthal_mmu_ring_bits		= XCHAL_MMU_RING_BITS;
109 const unsigned char Xthal_mmu_sr_bits		= XCHAL_MMU_SR_BITS;
110 const unsigned char Xthal_mmu_ca_bits		= XCHAL_MMU_CA_BITS;
111 #endif
112 #if XCHAL_HAVE_TLBS
113 const unsigned int  Xthal_mmu_max_pte_page_size	= XCHAL_MMU_MAX_PTE_PAGE_SIZE;
114 const unsigned int  Xthal_mmu_min_pte_page_size	= XCHAL_MMU_MIN_PTE_PAGE_SIZE;
115 const unsigned char Xthal_itlb_way_bits	= XCHAL_ITLB_WAY_BITS;
116 const unsigned char Xthal_itlb_ways	= XCHAL_ITLB_WAYS;
117 const unsigned char Xthal_itlb_arf_ways	= XCHAL_ITLB_ARF_WAYS;
118 const unsigned char Xthal_dtlb_way_bits	= XCHAL_DTLB_WAY_BITS;
119 const unsigned char Xthal_dtlb_ways	= XCHAL_DTLB_WAYS;
120 const unsigned char Xthal_dtlb_arf_ways	= XCHAL_DTLB_ARF_WAYS;
121 #else
122 const unsigned int  Xthal_mmu_max_pte_page_size	= 0;
123 const unsigned int  Xthal_mmu_min_pte_page_size	= 0;
124 const unsigned char Xthal_itlb_way_bits	= 0;
125 const unsigned char Xthal_itlb_ways	= 0;
126 const unsigned char Xthal_itlb_arf_ways	= 0;
127 const unsigned char Xthal_dtlb_way_bits	= 0;
128 const unsigned char Xthal_dtlb_ways	= 0;
129 const unsigned char Xthal_dtlb_arf_ways	= 0;
130 #endif
131 
132 
133 /*  Internal memories...  */
134 
135 const unsigned char Xthal_num_instrom	= XCHAL_NUM_INSTROM;
136 const unsigned char Xthal_num_instram	= XCHAL_NUM_INSTRAM;
137 const unsigned char Xthal_num_datarom	= XCHAL_NUM_DATAROM;
138 const unsigned char Xthal_num_dataram	= XCHAL_NUM_DATARAM;
139 const unsigned char Xthal_num_xlmi	= XCHAL_NUM_XLMI;
140 
141 /*  Define arrays of internal memories' addresses and sizes:  */
142 #define MEMTRIPLET(n,mem,memcap)	_MEMTRIPLET(n,mem,memcap)
143 #define _MEMTRIPLET(n,mem,memcap)	MEMTRIPLET##n(mem,memcap)
144 #define MEMTRIPLET0(mem,memcap) \
145 	const unsigned int  Xthal_##mem##_vaddr[1] = { 0 }; \
146 	const unsigned int  Xthal_##mem##_paddr[1] = { 0 }; \
147 	const unsigned int  Xthal_##mem##_size [1] = { 0 };
148 #define MEMTRIPLET1(mem,memcap) \
149 	const unsigned int  Xthal_##mem##_vaddr[1] = { XCHAL_##memcap##0_VADDR }; \
150 	const unsigned int  Xthal_##mem##_paddr[1] = { XCHAL_##memcap##0_PADDR }; \
151 	const unsigned int  Xthal_##mem##_size [1] = { XCHAL_##memcap##0_SIZE };
152 #define MEMTRIPLET2(mem,memcap) \
153 	const unsigned int  Xthal_##mem##_vaddr[2] = { XCHAL_##memcap##0_VADDR, XCHAL_##memcap##1_VADDR }; \
154 	const unsigned int  Xthal_##mem##_paddr[2] = { XCHAL_##memcap##0_PADDR, XCHAL_##memcap##1_PADDR }; \
155 	const unsigned int  Xthal_##mem##_size [2] = { XCHAL_##memcap##0_SIZE,  XCHAL_##memcap##1_SIZE };
156 MEMTRIPLET(XCHAL_NUM_INSTROM, instrom, INSTROM)
157 MEMTRIPLET(XCHAL_NUM_INSTRAM, instram, INSTRAM)
158 MEMTRIPLET(XCHAL_NUM_DATAROM, datarom, DATAROM)
159 MEMTRIPLET(XCHAL_NUM_DATARAM, dataram, DATARAM)
160 MEMTRIPLET(XCHAL_NUM_XLMI,    xlmi,    XLMI)
161 
162 /*  Timer info...  */
163 
164 const unsigned char Xthal_have_ccount	= XCHAL_HAVE_CCOUNT;
165 const unsigned char Xthal_num_ccompare	= XCHAL_NUM_TIMERS;
166 
167 #ifdef INCLUDE_DEPRECATED_HAL_CODE
168 const unsigned char Xthal_have_old_exc_arch	= XCHAL_HAVE_XEA1;
169 const unsigned char Xthal_have_mmu	= XCHAL_HAVE_TLBS;
170 const unsigned int  Xthal_num_regs	= XCHAL_NUM_AREGS;	/*DEPRECATED*/
171 const unsigned char Xthal_num_irom	= XCHAL_NUM_INSTROM;	/*DEPRECATED*/
172 const unsigned char Xthal_num_iram	= XCHAL_NUM_INSTRAM;	/*DEPRECATED*/
173 const unsigned char Xthal_num_drom	= XCHAL_NUM_DATAROM;	/*DEPRECATED*/
174 const unsigned char Xthal_num_dram	= XCHAL_NUM_DATARAM;	/*DEPRECATED*/
175 const unsigned int  Xthal_configid0	= XCHAL_HW_CONFIGID0;
176 const unsigned int  Xthal_configid1	= XCHAL_HW_CONFIGID1;
177 #endif
178 
179