blob: 4337657ddc4be5c448b8b41ae4ad52d5eca5cd87 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*
2 * boot.h
3 *
4*/
5/*
6Copyright (c) 2015, Imagination Technologies Limited and/or its affiliated group companies
7
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without modification, are
11permitted provided that the following conditions are met:
12
131. Redistributions of source code must retain the above copyright notice, this list of
14conditions and the following disclaimer.
15
162. Redistributions in binary form must reproduce the above copyright notice, this list
17of conditions and the following disclaimer in the documentation and/or other materials
18provided with the distribution.
19
203. Neither the name of the copyright holder nor the names of its contributors may be
21used to endorse or promote products derived from this software without specific prior
22written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*/
34
35
36#ifndef __BOOT_H__
37#define __BOOT_H__
38
39// Segmentation Control CP0 registers
40// Example setting SegCtl2 for Legacy KUSEG (CFG4 and CFG5)
41// li t4, (SEGCTL_CFG4_AM_MUSK | SEGCTL_CFG5_AM_MUSK | SEGCTL_CFG4_PA_0 | SEGCTL_CFG5_PA_4 | SEGCTL_CFG4_EU | SEGCTL_CFG5_EU)
42// mtc0 s0, C0_SEGCTL2
43
44
45/*#define C0_SEGCTL0 $5, 2
46#define C0_SEGCTL1 $5, 3
47#define C0_SEGCTL2 $5, 4
48#define C0_CONFIG4 $16, 4
49#define C0_CONFIG5 $16, 5*/
50
51// Segmentation Control AM - Access mode bits
52// AM Masks
53#define SEGCTL_CFG0_AM_MASK 0x00000070
54#define SEGCTL_CFG2_AM_MASK 0x00000070
55#define SEGCTL_CFG4_AM_MASK 0x00000070
56
57#define SEGCTL_CFG1_AM_MASK 0x00700000
58#define SEGCTL_CFG3_AM_MASK 0x00700000
59#define SEGCTL_CFG5_AM_MASK 0x00700000
60
61// AM Settings
62// UK UnMapped Kernel
63#define SEGCTL_CFG0_AM_UK 0x00000000
64#define SEGCTL_CFG2_AM_UK 0x00000000
65#define SEGCTL_CFG4_AM_UK 0x00000000
66
67#define SEGCTL_CFG1_AM_UK 0x00000000
68#define SEGCTL_CFG3_AM_UK 0x00000000
69#define SEGCTL_CFG5_AM_UK 0x00000000
70
71// MK Mapped Kernel
72#define SEGCTL_CFG0_AM_MK 0x00000010
73#define SEGCTL_CFG2_AM_MK 0x00000010
74#define SEGCTL_CFG4_AM_MK 0x00000010
75
76#define SEGCTL_CFG1_AM_MK 0x00100000
77#define SEGCTL_CFG3_AM_MK 0x00100000
78#define SEGCTL_CFG5_AM_MK 0x00100000
79
80// MSK Mapped Supervisor Kernel
81#define SEGCTL_CFG0_AM_MSK 0x00000020
82#define SEGCTL_CFG2_AM_MSK 0x00000020
83
84#define SEGCTL_CFG1_AM_MSK 0x00200000
85#define SEGCTL_CFG3_AM_MSK 0x00200000
86#define SEGCTL_CFG5_AM_MSK 0x00200000
87
88// MUSK Mapped User Supervisor Kernel
89#define SEGCTL_CFG0_AM_MUSK 0x00000030
90#define SEGCTL_CFG2_AM_MUSK 0x00000030
91#define SEGCTL_CFG4_AM_MUSK 0x00000030
92
93#define SEGCTL_CFG1_AM_MUSK 0x00300000
94#define SEGCTL_CFG3_AM_MUSK 0x00300000
95#define SEGCTL_CFG5_AM_MUSK 0x00300000
96
97// MUSUK Mapped User and Supervisor and Unmapped Kernel
98#define SEGCTL_CFG0_AM_MUSUK 0x00000040
99#define SEGCTL_CFG2_AM_MUSUK 0x00000040
100#define SEGCTL_CFG4_AM_MUSUK 0x00000040
101
102#define SEGCTL_CFG1_AM_MUSUK 0x00400000
103#define SEGCTL_CFG3_AM_MUSUK 0x00400000
104#define SEGCTL_CFG5_AM_MUSUK 0x00400000
105
106// USK Unmapped Supervisor and Kernel Segment
107#define SEGCTL_CFG0_AM_USK 0x00000050
108#define SEGCTL_CFG2_AM_USK 0x00000050
109#define SEGCTL_CFG4_AM_USK 0x00000050
110
111#define SEGCTL_CFG1_AM_USK 0x00500000
112#define SEGCTL_CFG3_AM_USK 0x00500000
113#define SEGCTL_CFG5_AM_USK 0x00500000
114
115// UUSK Unrestricted Unmapped Segment
116#define SEGCTL_CFG0_AM_UUSK 0x00000070
117#define SEGCTL_CFG2_AM_UUSK 0x00000070
118#define SEGCTL_CFG4_AM_UUSK 0x00000070
119
120#define SEGCTL_CFG1_AM_UUSK 0x00700000
121#define SEGCTL_CFG3_AM_UUSK 0x00700000
122#define SEGCTL_CFG5_AM_UUSK 0x00700000
123
124// Segmentation Control PA - Physical Address bits
125// PA Masks
126#define SEGCTL_CFG0_PA_MASK 0x00000E00
127#define SEGCTL_CFG2_PA_MASK 0x00000E00
128#define SEGCTL_CFG4_PA_MASK 0x00000E00
129
130#define SEGCTL_CFG1_PA_MASK 0x0E000000
131#define SEGCTL_CFG3_PA_MASK 0x0E000000
132#define SEGCTL_CFG5_PA_MASK 0x0E000000
133
134// PA Settings
135// PA 0x0000 0000
136#define SEGCTL_CFG0_PA_0 0x00000000
137#define SEGCTL_CFG2_PA_0 0x00000000
138#define SEGCTL_CFG4_PA_0 0x00000000
139
140#define SEGCTL_CFG1_PA_0 0x00000000
141#define SEGCTL_CFG3_PA_0 0x00000000
142#define SEGCTL_CFG5_PA_0 0x00000000
143
144// PA 0x2000 0000
145#define SEGCTL_CFG0_PA_2 0x00000200
146#define SEGCTL_CFG2_PA_2 0x00000200
147#define SEGCTL_CFG4_PA_2 0x00000200
148
149#define SEGCTL_CFG1_PA_2 0x02000000
150#define SEGCTL_CFG3_PA_2 0x02000000
151#define SEGCTL_CFG5_PA_2 0x02000000
152
153// PA 0x4000 0000
154#define SEGCTL_CFG0_PA_4 0x00000400
155#define SEGCTL_CFG2_PA_4 0x00000400
156#define SEGCTL_CFG4_PA_4 0x00000400
157
158#define SEGCTL_CFG1_PA_4 0x04000000
159#define SEGCTL_CFG3_PA_4 0x04000000
160#define SEGCTL_CFG5_PA_4 0x04000000
161
162// PA 0x6000 0000
163#define SEGCTL_CFG0_PA_6 0x00000600
164#define SEGCTL_CFG2_PA_6 0x00000600
165#define SEGCTL_CFG4_PA_6 0x00000600
166
167#define SEGCTL_CFG1_PA_6 0x06000000
168#define SEGCTL_CFG3_PA_6 0x06000000
169#define SEGCTL_CFG5_PA_6 0x06000000
170
171// PA 0x8000 0000
172#define SEGCTL_CFG0_PA_8 0x00000800
173#define SEGCTL_CFG2_PA_8 0x00000800
174#define SEGCTL_CFG4_PA_8 0x00000800
175
176#define SEGCTL_CFG1_PA_8 0x08000000
177#define SEGCTL_CFG3_PA_8 0x08000000
178#define SEGCTL_CFG5_PA_8 0x08000000
179
180// PA 0xA000 0000
181#define SEGCTL_CFG0_PA_A 0x00000A00
182#define SEGCTL_CFG2_PA_A 0x00000A00
183#define SEGCTL_CFG4_PA_A 0x00000A00
184
185#define SEGCTL_CFG1_PA_A 0x0A000000
186#define SEGCTL_CFG3_PA_A 0x0A000000
187#define SEGCTL_CFG5_PA_A 0x0A000000
188
189// PA 0xC000 0000
190#define SEGCTL_CFG0_PA_C 0x00000C00
191#define SEGCTL_CFG2_PA_C 0x00000C00
192#define SEGCTL_CFG4_PA_C 0x00000C00
193
194#define SEGCTL_CFG1_PA_C 0x0C000000
195#define SEGCTL_CFG3_PA_C 0x0C000000
196#define SEGCTL_CFG5_PA_C 0x0C000000
197
198// PA 0xE000 0000
199#define SEGCTL_CFG0_PA_E 0x00000E00
200#define SEGCTL_CFG2_PA_E 0x00000E00
201#define SEGCTL_CFG4_PA_E 0x00000E00
202
203#define SEGCTL_CFG1_PA_E 0x0E000000
204#define SEGCTL_CFG3_PA_E 0x0E000000
205#define SEGCTL_CFG5_PA_E 0x0E000000
206
207// Segmentation Control EU - Error Condiction bits
208// EU Masks
209#define SEGCTL_CFG0_EU_MASK 0x00000008
210#define SEGCTL_CFG2_EU_MASK 0x00000008
211#define SEGCTL_CFG4_EU_MASK 0x00000008
212
213#define SEGCTL_CFG1_EU_MASK 0x00080000
214#define SEGCTL_CFG3_EU_MASK 0x00080000
215#define SEGCTL_CFG5_EU_MASK 0x00080000
216
217// EU bit setting
218#define SEGCTL_CFG0_EU 0x00000008
219#define SEGCTL_CFG2_EU 0x00000008
220#define SEGCTL_CFG4_EU 0x00000008
221
222#define SEGCTL_CFG1_EU 0x00080000
223#define SEGCTL_CFG3_EU 0x00080000
224#define SEGCTL_CFG5_EU 0x00080000
225
226// Segmentation Control C - Cache Coherency Attribute bits
227// C Masks
228#define SEGCTL_CFG0_C_MASK 0x00000007
229#define SEGCTL_CFG2_C_MASK 0x00000007
230#define SEGCTL_CFG4_C_MASK 0x00000007
231
232#define SEGCTL_CFG1_C_MASK 0x00070000
233#define SEGCTL_CFG3_C_MASK 0x00070000
234#define SEGCTL_CFG5_C_MASK 0x00070000
235
236// C Bit setting
237// UC Uncached, non Coherent
238#define SEGCTL_CFG0_C_UC 0x00000002
239#define SEGCTL_CFG2_C_UC 0x00000002
240#define SEGCTL_CFG4_C_UC 0x00000002
241
242#define SEGCTL_CFG1_C_UC 0x00020000
243#define SEGCTL_CFG3_C_UC 0x00020000
244#define SEGCTL_CFG5_C_UC 0x00020000
245
246// WB Writeback, write-allocate, non-coherent
247#define SEGCTL_CFG0_C_WB 0x00000003
248#define SEGCTL_CFG2_C_WB 0x00000003
249#define SEGCTL_CFG4_C_WB 0x00000003
250
251#define SEGCTL_CFG1_C_WB 0x00030000
252#define SEGCTL_CFG3_C_WB 0x00030000
253#define SEGCTL_CFG5_C_WB 0x00030000
254
255// CWBE Writeback, write-allocate, coherent, exclusive
256#define SEGCTL_CFG0_C_CWBE 0x00000004
257#define SEGCTL_CFG2_C_CWBE 0x00000004
258#define SEGCTL_CFG4_C_CWBE 0x00000004
259
260#define SEGCTL_CFG1_C_CWBE 0x00040000
261#define SEGCTL_CFG3_C_CWBE 0x00040000
262#define SEGCTL_CFG5_C_CWBE 0x00040000
263
264// CWB Writeback, write-allocate, coherent, exclusive on write
265#define SEGCTL_CFG0_C_CWB 0x00000005
266#define SEGCTL_CFG2_C_CWB 0x00000005
267#define SEGCTL_CFG4_C_CWB 0x00000005
268
269#define SEGCTL_CFG1_C_CWB 0x00050000
270#define SEGCTL_CFG3_C_CWB 0x00050000
271#define SEGCTL_CFG5_C_CWB 0x00050000
272
273// UCA Uncached accelerated, non-coherent
274#define SEGCTL_CFG0_C_UCA 0x00000007
275#define SEGCTL_CFG2_C_UCA 0x00000007
276#define SEGCTL_CFG4_C_UCA 0x00000007
277
278#define SEGCTL_CFG1_C_UCA 0x00070000
279#define SEGCTL_CFG3_C_UCA 0x00070000
280#define SEGCTL_CFG5_C_UCA 0x00070000
281
282#define LEAF(name)\
283 .##text;\
284 .##globl name;\
285 .##ent name;\
286name:
287
288#define L2SRAM_L2C_LEAF(name)\
289 .##section "L2SRAM_L2C_ROCODE", "ax";\
290 .##globl name;\
291 .##ent name;\
292name:
293
294#if defined(__MD93__)
295#define L2CACHE_LOCK_LEAF(name)\
296 .##section "L2CACHE_LOCK_ROCODE", "ax";\
297 .##globl name;\
298 .##ent name;\
299name:
300#else
301#define L2CACHE_LOCK_LEAF(name) LEAF(name)
302#endif
303
304#define NONCACHED_ROCODE_LEAF(name)\
305 .##section "NONCACHED_ROCODE", "ax";\
306 .##globl name;\
307 .##ent name;\
308name:
309
310#define END(name)\
311 .##size name,.-name;\
312 .##end name
313
314//#define GCR_CONFIG_ADDR 0xbfbf8000 // KSEG1 address of the GCR registers
315#define GCR_CONFIG_ADDR 0x1f000000 // KSEG1 address of the GCR registers
316#define GCR_CUSTOM_ADDR 0x1f010000 // KSEG1 address of the GCR registers
317#define GIC_P_BASE_ADDR 0x1f020000 // physical address of the GIC
318#define GIC_BASE_ADDR 0x1f020000 // KSEG1 address address of the GIC
319#define CPC_P_BASE_ADDR 0x1f008000 // physical address of the CPC
320#define CPC_BASE_ADDR 0x1f008000 // KSEG1 address address of the CPC
321#define GCR_CDMM_ADDR 0x1fc10000
322
323#define DENALI_CTL_SECTION 0xbbc00000
324#define MALTA_DISP_ADDR 0xbf000410
325
326#define STACK_BASE_ADDR 0x82000000 /* Change: Base on memory size. */
327#define STACK_SIZE_LOG2 22 /* 4Mbytes each */
328
329
330/**************************************************************************************
331 Register use while executing in this file: ("GLOBAL" denotes a common value.)
332**************************************************************************************/
333
334#if defined(__MIPS_IA__)
335#define r1_all_ones $1 /* at Will hold 0xffffffff to simplify bit insertion of 1's. GLOBAL! */
336
337// $2 - $7 (v0, v1 a0 - a3) reserved for program use
338
339#define r8_core_num $8 /* t0 Core number. Only core 0 is active after reset. */
340#define r9_vpe_num $9 /* t1 MT ASE VPE number that this TC is bound to (0 if non-MT.) */
341#define r10_has_mt_ase $10 /* t2 Core implements the MT ASE. */
342#define r11_is_cps $11 /* t3 Core is part of a Coherent Processing System. */
343
344// $12 - $15 (t4 - t7) are free to use
345// $16, $17 (s0 and s1) reserved for program use
346
347#define r18_tc_num $18 /* s2 MT ASE TC number (0 if non-MT.) */
348#define r19_more_cores $19 /* s3 Number of cores in CPS in addition to core 0. GLOBAL! */
349#define r20_more_vpes $20 /* s4 Number of vpes in this core in addition to vpe 0. */
350#define r21_more_tcs $21 /* s5 Number of tcs in vpe in addition to the first. */
351#define r22_gcr_addr $22 /* s6 Uncached (kseg1) base address of the Global Config Registers. */
352#define r23_cpu_num $23 /* s7 Unique per vpe "cpu" identifier (CP0 EBase[CPUNUM]). */
353#define r24_malta_word $24 /* t8 Uncached (kseg1) base address of Malta ascii display. GLOBAL! */
354#define r25_coreid $25 /* t9 Copy of cp0 PRiD GLOBAL! */
355#define r26_int_addr $26 /* k0 Interrupt handler scratch address. */
356#define r27_int_data $27 /* k1 Interrupt handler scratch data. */
357// $28 gp and $29 sp
358#define r30_cpc_addr $30 /* s8 Address of CPC register block after cpc_init. 0 indicates no CPC. */
359// $31 ra
360
361#else
362
363// $2 - $7 (v0, v1 a0 - a3) reserved for program use
364
365#define r8_core_num $t0 /* t0 Core number. Only core 0 is active after reset. */
366#define r9_vpe_num $t1 /* t1 MT ASE VPE number that this TC is bound to (0 if non-MT.) */
367#define r10_has_mt_ase $t2 /* t2 Core implements the MT ASE. */
368#define r11_is_cps $t3 /* t3 Core is part of a Coherent Processing System. */
369
370// $12 - $15 (t4 - t7) are free to use
371// $16, $17 (s0 and s1) reserved for program use
372
373#define r18_tc_num $s2 /* s2 MT ASE TC number (0 if non-MT.) */
374#define r19_more_cores $s3 /* s3 Number of cores in CPS in addition to core 0. GLOBAL! */
375#define r20_more_vpes $s4 /* s4 Number of vpes in this core in addition to vpe 0. */
376#define r21_more_tcs $s5 /* s5 Number of tcs in vpe in addition to the first. */
377#define r22_gcr_addr $s6 /* s6 Uncached (kseg1) base address of the Global Config Registers. */
378#define r23_cpu_num $s7 /* s7 Unique per vpe "cpu" identifier (CP0 EBase[CPUNUM]). */
379#define r24_malta_word $t8 /* t8 Uncached (kseg1) base address of Malta ascii display. GLOBAL! */
380#define r25_coreid $t9 /* t9 Copy of cp0 PRiD GLOBAL! */
381#define r26_int_addr $k0 /* k0 Interrupt handler scratch address. */
382#define r27_int_data $k1 /* k1 Interrupt handler scratch data. */
383// $28 gp and $29 sp
384#define r30_cpc_addr $s8 /* s8 Address of CPC register block after cpc_init. 0 indicates no CPC. */
385// $31 ra
386
387#endif
388#endif /* __BOOT_H__ */
389
390