OpenCores
URL https://opencores.org/ocsvn/s1_core/s1_core/trunk

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [tests/] [boot/] [boot.s] - Blame information for rev 102

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 fafa1971
/*
2
 * Simply RISC S1 Core - Boot code
3
 *
4
 * Cutdown version from the original OpenSPARC T1:
5
 *
6
 *   $T1_ROOT/verif/diag/assembly/include/hred_reset_handler.s
7
 *
8
 * Main changes:
9 36 fafa1971
 * - L1 and L2 cache handling are not enabled;
10 32 fafa1971
 * - Interrupt Queues handling currently commented out since causes troubles in S1 Core.
11
 *
12
 * Sun Microsystems' copyright notices follow:
13
 */
14
 
15
/*
16
* ========== Copyright Header Begin ==========================================
17
*
18
* OpenSPARC T1 Processor File: hred_reset_handler.s
19
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
20
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
21
*
22
* The above named program is free software; you can redistribute it and/or
23
* modify it under the terms of the GNU General Public
24
* License version 2 as published by the Free Software Foundation.
25
*
26
* The above named program is distributed in the hope that it will be
27
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
28
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
* General Public License for more details.
30
*
31
* You should have received a copy of the GNU General Public
32
* License along with this work; if not, write to the Free Software
33
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
34
*
35
* ========== Copyright Header End ============================================
36
*/
37
 
38 102 fafa1971
        !! Enable L2-ucache: currently unused in S1 Core
39 32 fafa1971
/*
40 102 fafa1971
        !! SunStudio version
41
        setx    cregs_l2_ctl_reg_r64, %g1, %l1
42
        mov     0xa9, %g1
43
        sllx    %g1, 32, %g1
44
        stx     %l1, [%g1 + 0x00]
45
        stx     %l1, [%g1 + 0x40]
46
        stx     %l1, [%g1 + 0x80]
47
        stx     %l1, [%g1 + 0xc0]
48
*/
49
 
50
/*
51
        !! GCC version
52
        wr  %g0, 5, %asr26
53
        clr  %l1
54 32 fafa1971
        mov     0xa9, %g1
55
        sllx    %g1, 32, %g1
56
        stx     %l1, [%g1 + 0x00]
57
        stx     %l1, [%g1 + 0x40]
58
        stx     %l1, [%g1 + 0x80]
59
        stx     %l1, [%g1 + 0xc0]
60
*/
61
 
62 102 fafa1971
        !! Set the LSU Diagnostic Register to enable all ways for L1-icache and L1-dcache
63
        !! and using the "random replacement" algorithm
64
/*
65
        !! SunStudio version
66
        setx    cregs_lsu_diag_reg_r64, %g1, %l1
67
        mov     0x10, %g1
68
        stxa    %l1, [%g1] ASI_LSU_DIAG_REG
69
*/
70
        !! GCC version
71
        mov   0x10, %g1
72
        stxa  %l1, [%g1] (66)
73 73 fafa1971
 
74 102 fafa1971
        !! Set the LSU Control Register to enable L1-icache and L1-dcache
75 36 fafa1971
/*
76 102 fafa1971
        !! SunStudio version
77
        setx    (CREGS_LSU_CTL_REG_IC | (CREGS_LSU_CTL_REG_DC << 1)), %g1, %l1
78
        stxa    %l1, [%g0] ASI_LSU_CTL_REG
79 36 fafa1971
*/
80 102 fafa1971
        !! GCC version
81
        mov  3, %l1
82
        stxa  %l1, [%g0] (69)
83 88 fafa1971
 
84 35 fafa1971
        !! Set hpstate.red = 0 and hpstate.enb = 1
85 102 fafa1971
/*
86
        !! SunStudio version
87
        rdhpr   %hpstate, %l1
88
        wrhpr   %l1, 0x820, %hpstate
89
*/
90
        !! GCC version
91 32 fafa1971
        rdhpr   %hpstate, %l1
92 73 fafa1971
        and %l1,0x820,%l2
93
        xor %l2,0x800,%l2
94 102 fafa1971
        wrhpr %l1,%l2,%hpstate          !! ensure red=0 and enb=1 leaving the other 2 bits of the register unchanged
95 32 fafa1971
 
96 102 fafa1971
        !! Initialize Interrupt Queue Registers: currently unused in S1 Core
97 32 fafa1971
/*
98
        wr %g0, 0x25, %asi
99
 
100
        stxa %g0, [0x3c0] %asi
101
        stxa %g0, [0x3c8] %asi
102
        stxa %g0, [0x3d0] %asi
103
        stxa %g0, [0x3d8] %asi
104
 
105
        stxa %g0, [0x3e0] %asi
106
        stxa %g0, [0x3e8] %asi
107
        stxa %g0, [0x3f0] %asi
108
        stxa %g0, [0x3f8] %asi
109
 
110
        wrpr    0, %tl
111
        wrpr    0, %g0, %gl
112
        wr      %g0, cregs_fprs_imm, %fprs
113
        wr      %g0, cregs_ccr_imm, %ccr
114
 
115
        wr      %g0, cregs_asi_imm, %asi
116
        setx    cregs_tick_r64, %g1, %g2
117 35 fafa1971
        !! FIXME set other ticks also
118 32 fafa1971
        wrpr    %g2, %tick
119
        setx    cregs_stick_r64, %g1, %g2
120
 
121
        wr      %g2, %g0, %sys_tick
122
        mov     0x1, %g2
123
        sllx    %g2, 63, %g2
124
        wr      %g2, %g0, %tick_cmpr
125
 
126
        wr      %g2, %g0, %sys_tick_cmpr
127
        wrhpr   %g2, %g0, %hsys_tick_cmpr
128
        mov     %g0, %y
129
        wrpr    cregs_pil_imm, %pil
130
 
131
        wrpr    cregs_cwp_imm, %cwp
132
        wrpr    cregs_cansave_imm, %cansave
133
        wrpr    cregs_canrestore_imm, %canrestore
134
        wrpr    cregs_otherwin_imm, %otherwin
135
 
136
        wrpr    cregs_cleanwin_imm, %cleanwin
137
        wrpr    cregs_wstate_imm, %wstate
138
*/
139
 
140 35 fafa1971
        !! Clear L1-icache and L1-dcache SFSR
141 32 fafa1971
        mov     0x18, %g1
142 102 fafa1971
        stxa    %g0, [%g0 + %g1] 0x50                   !! IMMU Synchronous Fault Status register=0
143
        stxa    %g0, [%g0 + %g1] 0x58                   !! DMMU Synchronous Fault Status register=0
144 32 fafa1971
 
145 102 fafa1971
        !! Enable error trap
146
/*
147
        !! SunStudio version
148
        setx    cregs_sparc_error_en_reg_r64, %g1, %l1
149
        stxa    %l1, [%g0] ASI_SPARC_ERROR_EN_REG
150
*/
151
        !! GCC version
152
        !! in file defines.h constant cregs_sparc_error_en_reg_r64:=3
153 88 fafa1971
        !! so the effect should be "trap on correctable error" and "trap on uncorrectable error"
154 73 fafa1971
        sethi %hh(0x3),%g1
155
        or    %g1,%hm(0x3),%g1
156
        sllx  %g1,32,%g1
157
        sethi %hi(0x3),%l1
158
        or    %l1,%g1,%l1
159
        or    %l1,%lo(0x3),%l1
160 88 fafa1971
        stxa  %l1, [%g0] (75)                           !! copy the content of the l1 register into the "SPARC Error Enable reg"
161 32 fafa1971
 
162 102 fafa1971
        !! Enable L2-ucache error trap: currently unused in S1 Core
163 32 fafa1971
/*
164
        setx    cregs_l2_error_en_reg_r64, %g1, %l1
165
 
166
        mov     0xaa, %g1
167
        sllx    %g1, 32, %g1
168
        stx     %l1, [%g1 + 0x00]
169
        stx     %l1, [%g1 + 0x40]
170
 
171
        stx     %l1, [%g1 + 0x80]
172
        stx     %l1, [%g1 + 0xc0]
173
*/
174
 
175 88 fafa1971
        !! Load Partition ID (permits to multiple OSs to share the same TLB)
176 102 fafa1971
/*
177
        !! SunStudio version
178
        rd      %asr26, %l1
179
        set     0x0300, %g1
180 32 fafa1971
        and     %l1, %g1, %l1
181 102 fafa1971
        srlx    %l1, 8, %l1             ! %l1 has thread ID
182
        setx    part_id_list, %g1, %g2
183
        sllx    %l1, 3, %l1             ! offset - partition list
184
        ldx     [%g2 + %l1], %g2        ! %g2 contains partition ID
185
        mov     0x80, %g1
186
        stxa    %g2, [%g1] 0x58
187
*/
188
/*
189
        !! GCC version
190
        rd      %asr26, %l1                             !! ASR26 is the Strand Status and Control register
191
        set     0x0300, %g1
192
        and     %l1, %g1, %l1
193 35 fafa1971
        srlx    %l1, 8, %l1                             !! %l1 has thread ID
194 88 fafa1971
        sethi  %hi(0), %g1
195
        sethi  %hi(0x4c000), %g2
196
        mov  %g1, %g1
197
        mov  %g2, %g2
198
        sllx  %g1, 0x20, %g1
199
        or  %g2, %g1, %g2
200 102 fafa1971
        sllx    %l1, 3, %l1                             !! offset - partition list
201
        ldx     [%g2 + %l1], %g2                        !! %g2 contains partition ID
202 32 fafa1971
        mov     0x80, %g1
203 102 fafa1971
        stxa    %g2, [%g1] 0x58                         !! I/DMMU Partition ID=g2
204
*/
205 35 fafa1971
        !! Set Hypervisor Trap Base Address
206 102 fafa1971
/*
207
        !! SunStudio version
208
        setx HV_TRAP_BASE_PA, %l0, %l7
209
        wrhpr %l7, %g0, %htba
210
*/
211
        !! GCC version
212 73 fafa1971
        sethi %hh(0x80000),%g1
213
        or    %g1,%hm(0x80000),%g1
214
        sllx  %g1,32,%g1
215
        sethi %hi(0x80000),%l1
216
        or    %l1,%g1,%l1
217
        or    %l1,%lo(0x80000),%l1
218 102 fafa1971
        wrhpr %l7, %g0, %htba                                   !! bits 63-14 select the trap vector
219 73 fafa1971
 
220 102 fafa1971
        !! Load TSB config/base from memory and write to corresponding ASIs
221
        !! Set tsb-reg (4 at present) for one partition
222 35 fafa1971
        !! 2 i-config, 2-dconfig
223 102 fafa1971
/*
224
        !! SunStudio version
225
        setx    tsb_config_base_list, %l0, %g1
226
*/
227
/*
228
        !! GCC version
229 88 fafa1971
        sethi  %hi(0), %l0
230
        sethi  %hi(0x4c000), %g1
231
        mov  %l0, %l0
232
        or  %g1, 0x140, %g1
233
        sllx  %l0, 0x20, %l0
234
        or  %g1, %l0, %g1
235 77 fafa1971
 
236 35 fafa1971
        sllx    %g2, 7, %g2                                     !! %g2 contains offset to tsb_config_base_list
237
        add     %g1, %g2, %g1                                   !! %g1 contains pointer to tsb_config_base_list
238 32 fafa1971
 
239 35 fafa1971
        !! IMMU_CXT_Z_CONFIG   (0x37, VA=0x00)
240 32 fafa1971
        ldx     [%g1], %l1
241
        stxa    %l1, [%g0] 0x37
242
 
243 35 fafa1971
        !! IMMU_CXT_NZ_CONFIG  (0x3f, VA=0x00)
244 32 fafa1971
        ldx     [%g1+8], %l1
245
        stxa    %l1, [%g0] 0x3f
246
 
247 35 fafa1971
        !! IMMU_CXT_Z_PS0_TSB  (0x35, VA=0x0)
248
        !! IMMU_CXT_Z_PS1_TSB  (0x36, VA=0x0)
249 32 fafa1971
        ldx     [%g1+16], %l1
250
        stxa    %l1, [%g0] 0x35
251
        ldx     [%g1+32], %l1
252
        stxa    %l1, [%g0] 0x36
253
 
254 35 fafa1971
        !! IMMU_CXT_NZ_PS0_TSB (0x3d, VA=0x00)
255
        !! IMMU_CXT_NZ_PS1_TSB (0x3e, VA=0x00)
256 32 fafa1971
        ldx     [%g1+24], %l1
257
        stxa    %l1, [%g0] 0x3d
258
        ldx     [%g1+40], %l1
259
        stxa    %l1, [%g0] 0x3e
260
 
261 35 fafa1971
        !! DMMU_CXT_Z_CONFIG   (0x33, VA=0x00)
262 32 fafa1971
        ldx     [%g1+64], %l1
263
        stxa    %l1, [%g0] 0x33
264
 
265 35 fafa1971
        !! DMMU_CXT_NZ_CONFIG  (0x3b, VA=0x00)
266 32 fafa1971
        ldx     [%g1+72], %l1
267
        stxa    %l1, [%g0] 0x3b
268
 
269 35 fafa1971
        !! DMMU_CXT_Z_PS0_TSB  (0x31, VA=0x00)
270
        !! DMMU_CXT_Z_PS1_TSB  (0x32, VA=0x00)
271 32 fafa1971
        ldx     [%g1+80], %l1
272
        stxa    %l1, [%g0] 0x31
273
        ldx     [%g1+96], %l1
274
        stxa    %l1, [%g0] 0x32
275
 
276 35 fafa1971
        !! DMMU_CXT_NZ_PS0_TSB (0x39, VA=0x00)
277
        !! DMMU_CXT_NZ_PS0_TSB (0x3a, VA=0x00)
278 32 fafa1971
        ldx     [%g1+88], %l1
279
        stxa    %l1, [%g0] 0x39
280
        ldx     [%g1+104], %l1
281
        stxa    %l1, [%g0] 0x3a
282
 
283 35 fafa1971
        !! Demap all itlb and dtlb
284 32 fafa1971
        mov     0x80, %o2
285 102 fafa1971
        stxa    %g0, [%o2] 0x57                 !! register ASI_IMMU_DEMAP=0 (IMMU TLB demap)
286
        stxa    %g0, [%o2] 0x5f                 !! register ASI_DMMU_DEMAP=0 (DMMU TLB demap)
287
*/
288 32 fafa1971
 
289 102 fafa1971
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
290
!! Instructions merged from file hboot_tlb_init.s !!
291
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
292
 
293
!! Init all itlb entries
294
        mov     0x30, %g1
295
        mov     %g0, %g2
296
itlb_init_loop:
297
        !! clear data and tag entries of the TLB buffer
298
        stxa    %g0, [%g1] 0x50         !! IMMU TLB Tag Access register=0
299
        stxa    %g0, [%g2] 0x55         !! IMMU TLB Data Access register=0, g2 values from 0x000 to 0x7f8
300
 
301
        add     %g2, 8, %g2             !! increment the g2 register 8 bytes every time (64 bits)
302
        cmp     %g2, 0x200              !! compare g2 with 512 (512*8=4096=0x1000), but max VA=0x7F8
303
        bne     itlb_init_loop          !! if (g2!=512) then run another loop
304
        nop
305
 
306
!! Init all dtlb entries
307
        mov     0x30, %g1
308
        mov     %g0, %g2
309
dtlb_init_loop:
310
        stxa    %g0, [%g1] 0x58         !! DMMU TLB Tag Access register=0
311
        stxa    %g0, [%g2] 0x5d         !! DMMU TLB Data Access register=0, g2 values from 0x000 to 0x7f8
312
 
313
        add     %g2, 8, %g2             !! increment the g2 register 64 bits each time
314
        cmp     %g2, 0x200              !! compare g2 with 512
315
        bne     dtlb_init_loop          !! if (g2!=512) then run another loop
316
        nop
317
 
318
!! Clear itlb/dtlb valid
319
        stxa    %g0, [%g0] 0x60         !! ASI_ITLB_INVALIDATE_ALL(IMMU TLB Invalidate register)=0
320
        mov     0x8, %g1
321
        stxa    %g0, [%g0 + %g1] 0x60   !! ASI_DTLB_INVALIDATE_ALL(DMMU TLB Invalidate register)=0
322
 
323
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
324
!! End of inserted instructions !!
325
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
326
 
327 35 fafa1971
        !! Initialize primary context register
328 32 fafa1971
        mov 0x8, %l1
329
        stxa %g0, [%l1] 0x21
330
 
331 35 fafa1971
        !! Initialize secondary context register
332 32 fafa1971
        mov 0x10, %l1
333
        stxa %g0, [%l1] 0x21
334
 
335 35 fafa1971
        !! Initialize dtsb entry for i context zero ps0, ps1
336 102 fafa1971
        !! Set LSU Control Register to enable icache, dcache, immu, dmmu
337 36 fafa1971
/*
338 102 fafa1971
        !! SunStudio version
339
        setx    cregs_lsu_ctl_reg_r64, %g1, %l1
340 36 fafa1971
*/
341 102 fafa1971
        !! GCC version
342
        !! LSU_CTL_REG[3]=1 (DMMU enabled)
343
        !! LSU_CTL_REG[2]=1 (IMMU enabled)
344
        !! LSU_CTL_REG[1]=1 (L1-dcache enabled)
345
        !! LSU_CTL_REG[0]=1 (L1-icache enabled)
346
        mov  0xF, %l1
347 88 fafa1971
        stxa  %l1, [%g0] (69)
348
 
349 102 fafa1971
        !! Reset handler
350
/*
351
        !! SunStudio version
352
        setx    HPriv_Reset_Handler, %g1, %g2
353
*/
354
        !! GCC version
355 88 fafa1971
        sethi  %hi(0), %g1
356
        sethi  %hi(0x144000), %g2
357
        mov  %g1, %g1
358
        mov  %g2, %g2
359
        sllx  %g1, 0x20, %g1
360
        or  %g2, %g1, %g2
361 32 fafa1971
 
362
        rdhpr   %hpstate, %g3
363 88 fafa1971
        wrpr    1, %tl                                  !! current trap level = 1
364 77 fafa1971
 
365 102 fafa1971
        !! HTSTATE
366
/*
367
        !! SunStudio version
368
        setx    cregs_htstate_r64, %g1, %g4
369
*/
370
        !! GCC version
371 73 fafa1971
        sethi %hh(0x0),%g1
372
        or    %g1,%hm(0x0),%g1
373
        sllx  %g1,32,%g1
374
        sethi %hi(0x0),%l1
375
        or    %l1,%g1,%l1
376
        or    %l1,%lo(0x0),%l1
377
 
378 102 fafa1971
        wrhpr   %g4, %g0, %htstate      !! reset HTSTATE reg that store hyperpriviliged state after a trap
379
        wrpr    0, %tl                  !! current trap level = 0 (No Trap)
380
        mov     0x0, %o0                !! please don't delete since used in customized IMMU miss trap
381 32 fafa1971
        jmp     %g2
382 102 fafa1971
!!      wrhpr   %g0, 0x800, %hpstate    !! ensure bit 11 of the HPSTATE register is set
383 32 fafa1971
        nop
384
        nop
385
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.