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 88

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 35 fafa1971
        !! Enable L2-ucache: Unused in S1 Core
39 32 fafa1971
/*
40 35 fafa1971
        setx    cregs_l2_ctl_reg_r64, %g1, %l1                          !! aka "wr  %g0, 5, %asr26" "clr  %l1"
41 32 fafa1971
        mov     0xa9, %g1
42
        sllx    %g1, 32, %g1
43
 
44
        stx     %l1, [%g1 + 0x00]
45
        stx     %l1, [%g1 + 0x40]
46
        stx     %l1, [%g1 + 0x80]
47
        stx     %l1, [%g1 + 0xc0]
48
*/
49
 
50 35 fafa1971
        !! Set LSU Diagnostic Register to use all ways for L1-icache and L1-dcache
51 73 fafa1971
 
52 88 fafa1971
        !!setx  cregs_lsu_diag_reg_r64, %g1, %l1
53
        !! cregs_lsu_diag_reg_r64 has value 0 in file defines.h;
54
        !! this instruction has been expanded to:
55 73 fafa1971
        sethi %hh(0x0),%g1
56
        or    %g1,%hm(0x0),%g1
57
        sllx  %g1,32,%g1
58
        sethi %hi(0x0),%l1
59
        or    %l1,%g1,%l1
60
        or    %l1,%lo(0x0),%l1
61
 
62 88 fafa1971
        !! clear to zero the register ASI_LSU_DIAG_REG thus enabling all ways of cache and using the "random replacement" algorithm
63 73 fafa1971
        mov     0x10, %g1
64 88 fafa1971
        stxa %l1, [%g1] (66)
65 32 fafa1971
 
66 36 fafa1971
        !! Set LSU Control Register to enable L1-icache and L1-dcache: not enabled in S1 Core
67
/*
68 35 fafa1971
        setx    (CREGS_LSU_CTL_REG_IC | (CREGS_LSU_CTL_REG_DC << 1)), %g1, %l1  !! aka "mov  3, %l1"
69 36 fafa1971
        stxa  %l1, [ %g0 ] (69)                                                 !! aka "stxa    %l1, [%g0] ASI_LSU_CTL_REG"
70
*/
71 88 fafa1971
 
72 35 fafa1971
        !! Set hpstate.red = 0 and hpstate.enb = 1
73 32 fafa1971
        rdhpr   %hpstate, %l1
74 73 fafa1971
        and %l1,0x820,%l2
75
        xor %l2,0x800,%l2
76 88 fafa1971
        wrhpr %l1,%l2,%hpstate          !! this mechanism should ensure red=0 and enb=1 leaving the other 2 bits of the register unchanged;
77
        !!wrhpr %l1, 0x820, %hpstate    !! with the old instruction we got red=0 and enb=1 only if previously they were red=1 and enb=0
78 73 fafa1971
 
79 88 fafa1971
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
80
!! Instructions added from file hboot_tlb_init.s !!
81
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
82 73 fafa1971
 
83 88 fafa1971
!! Init all itlb entries
84 77 fafa1971
    mov 0x30, %g1
85
    mov %g0, %g2
86 88 fafa1971
itlb_init_loop:
87
        !! clear data and tag entries of the TLB buffer
88
        stxa    %g0, [ %g1 ] 0x50       !! IMMU TLB Tag Access register=0
89
        stxa    %g0, [ %g2 ] 0x55       !! IMMU TLB Data Access register=0, g2 values from 0x000 to 0x7f8
90 32 fafa1971
 
91 88 fafa1971
        add     %g2, 8, %g2             !! increment the g2 register 8 bytes every time (64 bits)
92
        cmp     %g2, 0x200              !! compare g2 with 512 (512*8=4096=0x1000), but max VA=0x7F8
93
        bne     itlb_init_loop          !! if (g2!=512) then run another loop
94
        nop
95 73 fafa1971
 
96 88 fafa1971
!! Init all dtlb entries
97 77 fafa1971
        mov     0x30, %g1
98
        mov     %g0, %g2
99
dtlb_init_loop:
100 88 fafa1971
        stxa    %g0, [ %g1 ] 0x58       !! DMMU TLB Tag Access register=0
101
        stxa    %g0, [ %g2 ] 0x5d       !! ASI_DTLB_DATA_ACCESS_REG(DMMU TLB Data Access) is 0, g2 values from 0x000 to 0x7f8
102 73 fafa1971
 
103 88 fafa1971
        add     %g2, 8, %g2             !! increment the g2 register 8 bytes every time (64 bits)
104
        cmp     %g2, 0x200              !! compare g2 with 512
105
        bne     dtlb_init_loop          !! if (g2!=512) then run another loop
106 77 fafa1971
        nop
107 73 fafa1971
 
108 88 fafa1971
!! Clear itlb/dtlb valid
109
        stxa    %g0, [%g0] 0x60         !! ASI_ITLB_INVALIDATE_ALL(IMMU TLB Invalidate register)=0
110 77 fafa1971
        mov     0x8, %g1
111 88 fafa1971
        stxa    %g0, [%g0 + %g1] 0x60   !! ASI_DTLB_INVALIDATE_ALL(DMMU TLB Invalidate register)=0
112 73 fafa1971
 
113
 
114 88 fafa1971
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
115
!! End of instrted instructions, from here we are again in old file boot.s !!
116
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
117 73 fafa1971
 
118 35 fafa1971
        !! Initialize Interrupt Queue Registers: Currently disabled in S1 Core
119 32 fafa1971
/*
120
        wr %g0, 0x25, %asi
121
 
122
        stxa %g0, [0x3c0] %asi
123
        stxa %g0, [0x3c8] %asi
124
        stxa %g0, [0x3d0] %asi
125
        stxa %g0, [0x3d8] %asi
126
 
127
        stxa %g0, [0x3e0] %asi
128
        stxa %g0, [0x3e8] %asi
129
        stxa %g0, [0x3f0] %asi
130
        stxa %g0, [0x3f8] %asi
131
 
132
        wrpr    0, %tl
133
        wrpr    0, %g0, %gl
134
        wr      %g0, cregs_fprs_imm, %fprs
135
        wr      %g0, cregs_ccr_imm, %ccr
136
 
137
        wr      %g0, cregs_asi_imm, %asi
138
        setx    cregs_tick_r64, %g1, %g2
139 35 fafa1971
        !! FIXME set other ticks also
140 32 fafa1971
        wrpr    %g2, %tick
141
        setx    cregs_stick_r64, %g1, %g2
142
 
143
        wr      %g2, %g0, %sys_tick
144
        mov     0x1, %g2
145
        sllx    %g2, 63, %g2
146
        wr      %g2, %g0, %tick_cmpr
147
 
148
        wr      %g2, %g0, %sys_tick_cmpr
149
        wrhpr   %g2, %g0, %hsys_tick_cmpr
150
        mov     %g0, %y
151
        wrpr    cregs_pil_imm, %pil
152
 
153
        wrpr    cregs_cwp_imm, %cwp
154
        wrpr    cregs_cansave_imm, %cansave
155
        wrpr    cregs_canrestore_imm, %canrestore
156
        wrpr    cregs_otherwin_imm, %otherwin
157
 
158
        wrpr    cregs_cleanwin_imm, %cleanwin
159
        wrpr    cregs_wstate_imm, %wstate
160
*/
161
 
162 35 fafa1971
        !! Clear L1-icache and L1-dcache SFSR
163 32 fafa1971
        mov     0x18, %g1
164 77 fafa1971
        stxa    %g0, [%g0 + %g1] 0x50 !IMMU Synchronous Fault Status register=0
165
        stxa    %g0, [%g0 + %g1] 0x58 !DMMU Synchronous Fault Status register=0
166 32 fafa1971
 
167 35 fafa1971
        !! Enable error trap
168 88 fafa1971
        !! setx cregs_sparc_error_en_reg_r64, %g1, %l1
169
        !! this instruction has been expanded using constant value cregs_sparc_error_en_reg_r64=3 (from file defines.h)
170
        !! so the effect should be "trap on correctable error" and "trap on uncorrectable error"
171 73 fafa1971
        sethi %hh(0x3),%g1
172
        or    %g1,%hm(0x3),%g1
173
        sllx  %g1,32,%g1
174
        sethi %hi(0x3),%l1
175
        or    %l1,%g1,%l1
176
        or    %l1,%lo(0x3),%l1
177 88 fafa1971
        stxa  %l1, [%g0] (75)                           !! copy the content of the l1 register into the "SPARC Error Enable reg"
178 32 fafa1971
 
179 35 fafa1971
        !! Enable L2-ucache error trap: Unused in S1 Core
180 32 fafa1971
/*
181
        setx    cregs_l2_error_en_reg_r64, %g1, %l1
182
 
183
        mov     0xaa, %g1
184
        sllx    %g1, 32, %g1
185
        stx     %l1, [%g1 + 0x00]
186
        stx     %l1, [%g1 + 0x40]
187
 
188
        stx     %l1, [%g1 + 0x80]
189
        stx     %l1, [%g1 + 0xc0]
190
*/
191
 
192 88 fafa1971
        !! Load Partition ID (permits to multiple OSs to share the same TLB)
193
        rd      %asr26, %l1                             !! %asr26 corresponds to the "Strand Status and Control register"
194
        set     0x0300, %g1                             !! same as "sethi %hi(0x1c00), %g1" "or  %g1, 0x300, %g1"
195 32 fafa1971
        and     %l1, %g1, %l1
196 73 fafa1971
 
197 35 fafa1971
        srlx    %l1, 8, %l1                             !! %l1 has thread ID
198 32 fafa1971
 
199 88 fafa1971
        !!setx  part_id_list, %g1, %g2  (part_id_list is defined in file hboot.s)
200
        !! this instruction is expanded as:
201
        sethi  %hi(0), %g1
202
        sethi  %hi(0x4c000), %g2
203
        mov  %g1, %g1
204
        mov  %g2, %g2
205
        sllx  %g1, 0x20, %g1
206
        or  %g2, %g1, %g2
207 32 fafa1971
 
208 88 fafa1971
        sllx    %l1, 3, %l1                                     !! offset - partition list
209
        ldx     [%g2 + %l1], %g2                                !! %g2 contains partition ID
210 32 fafa1971
        mov     0x80, %g1
211 88 fafa1971
        stxa    %g2, [%g1] 0x58                                 !! I/DMMU Partition ID=g2
212 32 fafa1971
 
213 35 fafa1971
        !! Set Hypervisor Trap Base Address
214 88 fafa1971
        !! setx HV_TRAP_BASE_PA, %l0, %l7
215
        !! being HV_TRAP_BASE_PA=0x80000 it expands to:
216 73 fafa1971
        sethi %hh(0x80000),%g1
217
        or    %g1,%hm(0x80000),%g1
218
        sllx  %g1,32,%g1
219
        sethi %hi(0x80000),%l1
220
        or    %l1,%g1,%l1
221
        or    %l1,%lo(0x80000),%l1
222
 
223 88 fafa1971
        wrhpr %l7, %g0, %htba                                   !! bits 63-14 select the trap vector for a trap served in Hyperprivileged mode
224 32 fafa1971
 
225 35 fafa1971
        !! Load TSB config/base from memory and write to corresponding ASI's
226
        !! set tsb-reg (4 at present) for one partition
227
        !! 2 i-config, 2-dconfig
228 32 fafa1971
 
229 77 fafa1971
        !!setx  tsb_config_base_list, %l0, %g1
230 35 fafa1971
        !! this instructions expands as
231 88 fafa1971
        sethi  %hi(0), %l0
232
        sethi  %hi(0x4c000), %g1
233
        mov  %l0, %l0
234
        or  %g1, 0x140, %g1
235
        sllx  %l0, 0x20, %l0
236
        or  %g1, %l0, %g1
237 77 fafa1971
 
238 35 fafa1971
        sllx    %g2, 7, %g2                                     !! %g2 contains offset to tsb_config_base_list
239
        add     %g1, %g2, %g1                                   !! %g1 contains pointer to tsb_config_base_list
240 32 fafa1971
 
241 35 fafa1971
        !! IMMU_CXT_Z_CONFIG   (0x37, VA=0x00)
242 32 fafa1971
        ldx     [%g1], %l1
243
        stxa    %l1, [%g0] 0x37
244
 
245 35 fafa1971
        !! IMMU_CXT_NZ_CONFIG  (0x3f, VA=0x00)
246 32 fafa1971
        ldx     [%g1+8], %l1
247
        stxa    %l1, [%g0] 0x3f
248
 
249 35 fafa1971
        !! IMMU_CXT_Z_PS0_TSB  (0x35, VA=0x0)
250
        !! IMMU_CXT_Z_PS1_TSB  (0x36, VA=0x0)
251 32 fafa1971
        ldx     [%g1+16], %l1
252
        stxa    %l1, [%g0] 0x35
253
        ldx     [%g1+32], %l1
254
        stxa    %l1, [%g0] 0x36
255
 
256 35 fafa1971
        !! IMMU_CXT_NZ_PS0_TSB (0x3d, VA=0x00)
257
        !! IMMU_CXT_NZ_PS1_TSB (0x3e, VA=0x00)
258 32 fafa1971
        ldx     [%g1+24], %l1
259
        stxa    %l1, [%g0] 0x3d
260
        ldx     [%g1+40], %l1
261
        stxa    %l1, [%g0] 0x3e
262
 
263 35 fafa1971
        !! DMMU_CXT_Z_CONFIG   (0x33, VA=0x00)
264 32 fafa1971
        ldx     [%g1+64], %l1
265
        stxa    %l1, [%g0] 0x33
266
 
267 35 fafa1971
        !! DMMU_CXT_NZ_CONFIG  (0x3b, VA=0x00)
268 32 fafa1971
        ldx     [%g1+72], %l1
269
        stxa    %l1, [%g0] 0x3b
270
 
271 35 fafa1971
        !! DMMU_CXT_Z_PS0_TSB  (0x31, VA=0x00)
272
        !! DMMU_CXT_Z_PS1_TSB  (0x32, VA=0x00)
273 32 fafa1971
        ldx     [%g1+80], %l1
274
        stxa    %l1, [%g0] 0x31
275
        ldx     [%g1+96], %l1
276
        stxa    %l1, [%g0] 0x32
277
 
278 35 fafa1971
        !! DMMU_CXT_NZ_PS0_TSB (0x39, VA=0x00)
279
        !! DMMU_CXT_NZ_PS0_TSB (0x3a, VA=0x00)
280 32 fafa1971
        ldx     [%g1+88], %l1
281
        stxa    %l1, [%g0] 0x39
282
        ldx     [%g1+104], %l1
283
        stxa    %l1, [%g0] 0x3a
284
 
285 35 fafa1971
        !! Demap all itlb and dtlb
286 32 fafa1971
        mov     0x80, %o2
287 77 fafa1971
        stxa    %g0, [%o2] 0x57                 !!registro ASI_IMMU_DEMAP=0 (IMMU TLB demap)
288
        stxa    %g0, [%o2] 0x5f                 !!registro ASI_DMMU_DEMAP=0 (DMMU TLB demap)
289 32 fafa1971
 
290 35 fafa1971
        !! Initialize primary context register
291 32 fafa1971
        mov 0x8, %l1
292
        stxa %g0, [%l1] 0x21
293
 
294 35 fafa1971
        !! Initialize secondary context register
295 32 fafa1971
        mov 0x10, %l1
296
        stxa %g0, [%l1] 0x21
297
 
298 35 fafa1971
        !! Initialize dtsb entry for i context zero ps0, ps1
299 36 fafa1971
/*
300 35 fafa1971
        !! Set LSU Control Register to enable icache, dcache, immu, dmmu
301
        setx    cregs_lsu_ctl_reg_r64, %g1, %l1                                 !! aka "mov  0xf, %l1"
302 36 fafa1971
*/
303
        !! Set LSU Control Register to enable immu, dmmu but NOT icache, dcache
304
        mov  0xc, %l1
305 88 fafa1971
        stxa  %l1, [%g0] (69)
306
        !! Register 69 is "Load/Store Unit Control Register", and value 0xC=1100 corresponds to:
307
        !! .dm=1 (DMMU ENABLE)
308
        !! .Im=1 (IMMU ENABLE)
309
        !! .dc=0 (dcache not enabled)
310
        !! .ic=0 (icache not enabled)
311
 
312
        !! setx HPriv_Reset_Handler, %g1, %g2
313 35 fafa1971
        !! this instructions expands as
314 88 fafa1971
        sethi  %hi(0), %g1
315
        sethi  %hi(0x144000), %g2
316
        mov  %g1, %g1
317
        mov  %g2, %g2
318
        sllx  %g1, 0x20, %g1
319
        or  %g2, %g1, %g2
320 32 fafa1971
 
321
        rdhpr   %hpstate, %g3
322 88 fafa1971
        wrpr    1, %tl                                  !! current trap level = 1
323 77 fafa1971
 
324 88 fafa1971
        !! setx cregs_htstate_r64, %g1, %g4
325
        !! this instructions expands as
326 73 fafa1971
        sethi %hh(0x0),%g1
327
        or    %g1,%hm(0x0),%g1
328
        sllx  %g1,32,%g1
329
        sethi %hi(0x0),%l1
330
        or    %l1,%g1,%l1
331
        or    %l1,%lo(0x0),%l1
332
 
333 88 fafa1971
        wrhpr   %g4, %g0, %htstate      !! it should reset the HTSTATE register that store the hyperpriviliged state after a trap
334
        wrpr    0, %tl                   !! current trap level corrente = 0 (No Trap)
335 35 fafa1971
        mov     0x0, %o0                !! aka "clr %o0", don't delete since used in customized IMMU miss trap
336 32 fafa1971
        jmp     %g2
337 88 fafa1971
        wrhpr   %g0, 0x800, %hpstate    !! ensure bit 11 of the HPSTATE register is set (to avoid unwanted behaviors)
338 32 fafa1971
        nop
339
        nop
340
 

powered by: WebSVN 2.1.0

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