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 35

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
 * - L2 cache handling commented out since not implemented in S1 Core   ;
10
 * - 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 33 fafa1971
#include "defines.h"
39
 
40 35 fafa1971
        !! Enable L2-ucache: Unused in S1 Core
41 32 fafa1971
/*
42 35 fafa1971
        setx    cregs_l2_ctl_reg_r64, %g1, %l1                          !! aka "wr  %g0, 5, %asr26" "clr  %l1"
43 32 fafa1971
        mov     0xa9, %g1
44
        sllx    %g1, 32, %g1
45
 
46
        stx     %l1, [%g1 + 0x00]
47
        stx     %l1, [%g1 + 0x40]
48
        stx     %l1, [%g1 + 0x80]
49
        stx     %l1, [%g1 + 0xc0]
50
*/
51
 
52 35 fafa1971
        !! Set LSU Diagnostic Register to use all ways for L1-icache and L1-dcache
53
        setx    cregs_lsu_diag_reg_r64, %g1, %l1                                !! aka "clr  %l1"
54 32 fafa1971
        mov     0x10, %g1
55 35 fafa1971
        stxa    %l1, [%g1] ASI_LSU_DIAG_REG                                     !! aka "stxa %l1, [%g1] (66)"
56 32 fafa1971
 
57 35 fafa1971
        !! Set LSU Control Register to enable L1-icache and L1-dcache
58
        setx    (CREGS_LSU_CTL_REG_IC | (CREGS_LSU_CTL_REG_DC << 1)), %g1, %l1  !! aka "mov  3, %l1"
59
        stxa    %l1, [%g0] ASI_LSU_CTL_REG                                      !! aka "stxa  %l1, [ %g0 ] (69)"
60 32 fafa1971
 
61 35 fafa1971
        !! Set hpstate.red = 0 and hpstate.enb = 1
62 32 fafa1971
        rdhpr   %hpstate, %l1
63
        wrhpr   %l1, 0x820, %hpstate
64
 
65 35 fafa1971
        !! Initialize Interrupt Queue Registers: Currently disabled in S1 Core
66 32 fafa1971
/*
67
        wr %g0, 0x25, %asi
68
 
69
        stxa %g0, [0x3c0] %asi
70
        stxa %g0, [0x3c8] %asi
71
        stxa %g0, [0x3d0] %asi
72
        stxa %g0, [0x3d8] %asi
73
 
74
        stxa %g0, [0x3e0] %asi
75
        stxa %g0, [0x3e8] %asi
76
        stxa %g0, [0x3f0] %asi
77
        stxa %g0, [0x3f8] %asi
78
 
79
        wrpr    0, %tl
80
        wrpr    0, %g0, %gl
81
        wr      %g0, cregs_fprs_imm, %fprs
82
        wr      %g0, cregs_ccr_imm, %ccr
83
 
84
        wr      %g0, cregs_asi_imm, %asi
85
        setx    cregs_tick_r64, %g1, %g2
86 35 fafa1971
        !! FIXME set other ticks also
87 32 fafa1971
        wrpr    %g2, %tick
88
        setx    cregs_stick_r64, %g1, %g2
89
 
90
        wr      %g2, %g0, %sys_tick
91
        mov     0x1, %g2
92
        sllx    %g2, 63, %g2
93
        wr      %g2, %g0, %tick_cmpr
94
 
95
        wr      %g2, %g0, %sys_tick_cmpr
96
        wrhpr   %g2, %g0, %hsys_tick_cmpr
97
        mov     %g0, %y
98
        wrpr    cregs_pil_imm, %pil
99
 
100
        wrpr    cregs_cwp_imm, %cwp
101
        wrpr    cregs_cansave_imm, %cansave
102
        wrpr    cregs_canrestore_imm, %canrestore
103
        wrpr    cregs_otherwin_imm, %otherwin
104
 
105
        wrpr    cregs_cleanwin_imm, %cleanwin
106
        wrpr    cregs_wstate_imm, %wstate
107
*/
108
 
109 35 fafa1971
        !! Clear L1-icache and L1-dcache SFSR
110 32 fafa1971
        mov     0x18, %g1
111
        stxa    %g0, [%g0 + %g1] 0x50
112
        stxa    %g0, [%g0 + %g1] 0x58
113
 
114 35 fafa1971
        !! Enable error trap
115
        setx    cregs_sparc_error_en_reg_r64, %g1, %l1                  !! aka "mov  3, %l1"
116
        stxa    %l1, [%g0] ASI_SPARC_ERROR_EN_REG                       !! aka "stxa  %l1, [%g0] (75)"
117 32 fafa1971
 
118 35 fafa1971
        !! Enable L2-ucache error trap: Unused in S1 Core
119 32 fafa1971
/*
120
        setx    cregs_l2_error_en_reg_r64, %g1, %l1
121
 
122
        mov     0xaa, %g1
123
        sllx    %g1, 32, %g1
124
        stx     %l1, [%g1 + 0x00]
125
        stx     %l1, [%g1 + 0x40]
126
 
127
        stx     %l1, [%g1 + 0x80]
128
        stx     %l1, [%g1 + 0xc0]
129
*/
130
 
131 35 fafa1971
        !! Load Partition ID
132 32 fafa1971
        rd      %asr26, %l1
133 35 fafa1971
        set     0x0300, %g1                             !! aka "sethi %hi(0x1c00), %g1" "or  %g1, 0x300, %g1"
134 32 fafa1971
        and     %l1, %g1, %l1
135 35 fafa1971
        srlx    %l1, 8, %l1                             !! %l1 has thread ID
136 32 fafa1971
 
137
        setx    part_id_list, %g1, %g2
138 35 fafa1971
        !! this instruction expands as
139
        !! "sethi  %hi(0), %g1"
140
        !! "sethi  %hi(0x4c000), %g2"
141
        !! "mov  %g1, %g1"
142
        !! "mov  %g2, %g2"
143
        !! "sllx  %g1, 0x20, %g1"
144
        !! "or  %g2, %g1, %g2"
145 32 fafa1971
 
146 35 fafa1971
        sllx    %l1, 3, %l1                                                     !! offset - partition list
147
        ldx     [%g2 + %l1], %g2                                                !! %g2 contains partition ID
148 32 fafa1971
        mov     0x80, %g1
149
        stxa    %g2, [%g1] 0x58
150
 
151 35 fafa1971
        !! Set Hypervisor Trap Base Address
152
        setx HV_TRAP_BASE_PA, %l0, %l7                                          !! sethi %hi(0x80000), %l7
153 32 fafa1971
        wrhpr %l7, %g0, %htba
154
 
155 35 fafa1971
        !! Load TSB config/base from memory and write to corresponding ASI's
156
        !! set tsb-reg (4 at present) for one partition
157
        !! 2 i-config, 2-dconfig
158 32 fafa1971
 
159
        setx    tsb_config_base_list, %l0, %g1
160 35 fafa1971
        !! this instructions expands as
161
        !! sethi  %hi(0), %l0
162
        !! sethi  %hi(0x4c000), %g1
163
        !! mov  %l0, %l0
164
        !! or  %g1, 0x140, %g1
165
        !! sllx  %l0, 0x20, %l0
166
        !! or  %g1, %l0, %g1
167 32 fafa1971
 
168 35 fafa1971
        sllx    %g2, 7, %g2                                     !! %g2 contains offset to tsb_config_base_list
169
        add     %g1, %g2, %g1                                   !! %g1 contains pointer to tsb_config_base_list
170 32 fafa1971
 
171 35 fafa1971
        !! IMMU_CXT_Z_CONFIG   (0x37, VA=0x00)
172 32 fafa1971
        ldx     [%g1], %l1
173
        stxa    %l1, [%g0] 0x37
174
 
175 35 fafa1971
        !! IMMU_CXT_NZ_CONFIG  (0x3f, VA=0x00)
176 32 fafa1971
        ldx     [%g1+8], %l1
177
        stxa    %l1, [%g0] 0x3f
178
 
179 35 fafa1971
        !! IMMU_CXT_Z_PS0_TSB  (0x35, VA=0x0)
180
        !! IMMU_CXT_Z_PS1_TSB  (0x36, VA=0x0)
181 32 fafa1971
        ldx     [%g1+16], %l1
182
        stxa    %l1, [%g0] 0x35
183
        ldx     [%g1+32], %l1
184
        stxa    %l1, [%g0] 0x36
185
 
186 35 fafa1971
        !! IMMU_CXT_NZ_PS0_TSB (0x3d, VA=0x00)
187
        !! IMMU_CXT_NZ_PS1_TSB (0x3e, VA=0x00)
188 32 fafa1971
        ldx     [%g1+24], %l1
189
        stxa    %l1, [%g0] 0x3d
190
        ldx     [%g1+40], %l1
191
        stxa    %l1, [%g0] 0x3e
192
 
193 35 fafa1971
        !! DMMU_CXT_Z_CONFIG   (0x33, VA=0x00)
194 32 fafa1971
        ldx     [%g1+64], %l1
195
        stxa    %l1, [%g0] 0x33
196
 
197 35 fafa1971
        !! DMMU_CXT_NZ_CONFIG  (0x3b, VA=0x00)
198 32 fafa1971
        ldx     [%g1+72], %l1
199
        stxa    %l1, [%g0] 0x3b
200
 
201 35 fafa1971
        !! DMMU_CXT_Z_PS0_TSB  (0x31, VA=0x00)
202
        !! DMMU_CXT_Z_PS1_TSB  (0x32, VA=0x00)
203 32 fafa1971
        ldx     [%g1+80], %l1
204
        stxa    %l1, [%g0] 0x31
205
        ldx     [%g1+96], %l1
206
        stxa    %l1, [%g0] 0x32
207
 
208 35 fafa1971
        !! DMMU_CXT_NZ_PS0_TSB (0x39, VA=0x00)
209
        !! DMMU_CXT_NZ_PS0_TSB (0x3a, VA=0x00)
210 32 fafa1971
        ldx     [%g1+88], %l1
211
        stxa    %l1, [%g0] 0x39
212
        ldx     [%g1+104], %l1
213
        stxa    %l1, [%g0] 0x3a
214
 
215 35 fafa1971
        !! Demap all itlb and dtlb
216 32 fafa1971
        mov     0x80, %o2
217
        stxa    %g0, [%o2] 0x57
218
        stxa    %g0, [%o2] 0x5f
219
 
220 35 fafa1971
        !! Initialize primary context register
221 32 fafa1971
        mov 0x8, %l1
222
        stxa %g0, [%l1] 0x21
223
 
224 35 fafa1971
        !! Initialize secondary context register
225 32 fafa1971
        mov 0x10, %l1
226
        stxa %g0, [%l1] 0x21
227
 
228 35 fafa1971
        !! Initialize dtsb entry for i context zero ps0, ps1
229
        !! Set LSU Control Register to enable icache, dcache, immu, dmmu
230
        setx    cregs_lsu_ctl_reg_r64, %g1, %l1                                 !! aka "mov  0xf, %l1"
231
        stxa    %l1, [%g0] ASI_LSU_CTL_REG                                      !! aka "stxa  %l1, [%g0] (69)"
232 32 fafa1971
 
233
        setx    HPriv_Reset_Handler, %g1, %g2
234 35 fafa1971
        !! this instructions expands as
235
        !! sethi  %hi(0), %g1
236
        !! sethi  %hi(0x144000), %g2
237
        !! mov  %g1, %g1
238
        !! mov  %g2, %g2
239
        !! sllx  %g1, 0x20, %g1
240
        !! or  %g2, %g1, %g2
241 32 fafa1971
 
242
        rdhpr   %hpstate, %g3
243
        wrpr    1, %tl
244 35 fafa1971
        setx    cregs_htstate_r64, %g1, %g4                     !! aka "clr  %g4"
245 32 fafa1971
        wrhpr   %g4, %g0, %htstate
246
        wrpr    0, %tl
247 35 fafa1971
        mov     0x0, %o0                !! aka "clr %o0", don't delete since used in customized IMMU miss trap
248 32 fafa1971
        jmp     %g2
249
        wrhpr   %g0, 0x800, %hpstate
250
        nop
251
        nop
252
 
253
 

powered by: WebSVN 2.1.0

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