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 114

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 fafa1971
/*
2 114 albert.wat
 * S1 Core - Boot code
3 32 fafa1971
 *
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 112 albert.wat
        /* Base address for Power-On Reser is 0xFFF0000020, adding 8 NOPs to artificially create the 0x20 offset */
39
        nop
40
        nop
41
        nop
42
        nop
43
        nop
44
        nop
45
        nop
46
        nop
47
 
48
        /* Initialize windowed local, output and input GPRs */
49
        wrpr %g0, %g0, %cwp             !! CWP = 0
50
        wrpr %g0, 0x6, %cansave         !! CANSAVE = 6
51
        wrpr %g0, %g0, %canrestore      !! CANRESTORE = 0
52
        wrpr %g0, %g0, %otherwin        !! OTHERWIN = 0
53
        wrpr %g0, 0x7, %cleanwin        !! CLEANWIN = 7
54
        wrpr %g0, 0x7, %wstate          !! WSTATE = (b)000_111
55
        add %g0, 0x1, %l1               !! l1 = 1
56
        add %g0, 0x1, %o1               !! o1 = 1
57
        add %g0, 0x1, %i1               !! i1 = 1
58
        add %l1, 0x1, %l2               !! l1 = 2
59
        add %o1, 0x1, %o2               !! o1 = 2
60
        add %i1, 0x1, %i2               !! i1 = 2
61
        add %l2, 0x1, %l3               !! l1 = 3
62
        add %o2, 0x1, %o3               !! o1 = 3
63
        add %i2, 0x1, %i3               !! i1 = 3
64
        nop; nop; nop; nop
65 102 fafa1971
 
66 112 albert.wat
        /* Set the LSU Diagnostic Register to enable all ways for L1-icache and L1-dcache and using the "random replacement" algorithm */
67
        clr %l1                         !! Clear l1
68
        mov 0x10, %g1
69
        stxa %l1, [%g1] (66)            !! LSU_DIAG_REG = b00
70 32 fafa1971
 
71 112 albert.wat
        /* Set the LSU Control Register to enable L1-icache and L1-dcache */
72
!       mov 3, %l1
73
!       stxa %l1, [%g0] (69)
74 73 fafa1971
 
75 112 albert.wat
        /* Set hpstate.red = 0 and hpstate.enb = 1 */
76
        rdhpr %hpstate, %l1
77
        wrhpr %l1, 0x820, %hpstate
78 88 fafa1971
 
79 112 albert.wat
        /* Clear L1-icache and L1-dcache SFSR */
80
        mov 0x18, %g1
81
        stxa %g0, [%g0 + %g1] 0x50      !! IMMU Synchronous Fault Status (SFS) register=0
82
        stxa %g0, [%g0 + %g1] 0x58      !! DMMU Synchronous Fault Status (SFS) register=0
83 32 fafa1971
 
84 112 albert.wat
        /* SPARC Error Enable Reg. */
85 102 fafa1971
        !! in file defines.h constant cregs_sparc_error_en_reg_r64:=3
86 88 fafa1971
        !! so the effect should be "trap on correctable error" and "trap on uncorrectable error"
87 112 albert.wat
        or %g0, 0x3, %l1                !! l1 = 3
88
        stxa %l1, [%g0] (75)            !! SPARC_Error_Enable_reg = 3
89 32 fafa1971
 
90 112 albert.wat
        /* Set HTBA: HTBA[63:14] = 0x12 */
91
        mov 1, %g1                      !! g1 = 1
92
        sllx %g1, 18, %l1               !! l1 = 40000
93
        sllx %g1, 15, %g1               !! g1 = 8000
94
        or %l1, %g1, %l1                !! l1 = 48000
95
        wrhpr %l1, %g0, %htba           !! bits 63-14 select Hpriv trap vector
96 32 fafa1971
 
97 112 albert.wat
        /**************************************************/
98
        /* Instructions merged from file hboot_tlb_init.s */
99
        /**************************************************/
100 32 fafa1971
 
101 112 albert.wat
        /* Init all itlb entries */
102 102 fafa1971
        mov     0x30, %g1
103
        mov     %g0, %g2
104
itlb_init_loop:
105
        stxa    %g0, [%g1] 0x50         !! IMMU TLB Tag Access register=0
106
        stxa    %g0, [%g2] 0x55         !! IMMU TLB Data Access register=0, g2 values from 0x000 to 0x7f8
107
        add     %g2, 8, %g2             !! increment the g2 register 8 bytes every time (64 bits)
108
        cmp     %g2, 0x200              !! compare g2 with 512 (512*8=4096=0x1000), but max VA=0x7F8
109
        bne     itlb_init_loop          !! if (g2!=512) then run another loop
110
        nop
111 112 albert.wat
 
112
        /* Init all dtlb entries */
113 102 fafa1971
        mov     0x30, %g1
114
        mov     %g0, %g2
115
dtlb_init_loop:
116
        stxa    %g0, [%g1] 0x58         !! DMMU TLB Tag Access register=0
117
        stxa    %g0, [%g2] 0x5d         !! DMMU TLB Data Access register=0, g2 values from 0x000 to 0x7f8
118
        add     %g2, 8, %g2             !! increment the g2 register 64 bits each time
119
        cmp     %g2, 0x200              !! compare g2 with 512
120
        bne     dtlb_init_loop          !! if (g2!=512) then run another loop
121
        nop
122 112 albert.wat
 
123
        /* Clear itlb/dtlb valid */
124 102 fafa1971
        stxa    %g0, [%g0] 0x60         !! ASI_ITLB_INVALIDATE_ALL(IMMU TLB Invalidate register)=0
125
        mov     0x8, %g1
126
        stxa    %g0, [%g0 + %g1] 0x60   !! ASI_DTLB_INVALIDATE_ALL(DMMU TLB Invalidate register)=0
127 112 albert.wat
 
128
        /********************************/
129
        /* End of inserted instructions */
130
        /********************************/
131 102 fafa1971
 
132 112 albert.wat
        /* Initialize primary context register = 0 */
133 32 fafa1971
        mov 0x8, %l1
134
        stxa %g0, [%l1] 0x21
135 112 albert.wat
        /* Initialize secondary context register = 0 */
136 32 fafa1971
        mov 0x10, %l1
137 112 albert.wat
        stxa %g0, [%l1] 0x21
138 32 fafa1971
 
139 112 albert.wat
        /* LSU_CTL_REG[3]=1 (DMMU enabled)
140
           LSU_CTL_REG[2]=1 (IMMU enabled)
141
           LSU_CTL_REG[1]=0 (L1-dcache disabled)
142
           LSU_CTL_REG[0]=0 (L1-icache disabled) */
143
        mov 0xC, %l1                    !! all enabled
144
        stxa %l1, [%g0] (69)
145 32 fafa1971
 
146 112 albert.wat
        /* Jump to program in RAM */
147
        sethi %hi(0), %g1
148
        sethi %hi(0x40000), %g2         !! Jump address in RAM
149
        mov %g1, %g1
150
        mov %g2, %g2
151
        sllx %g1, 0x20, %g1
152
        or %g2, %g1, %g2
153 77 fafa1971
 
154 112 albert.wat
        /* HTSTATE[TL=1] */
155
        rdhpr %hpstate, %g3
156
        wrpr 1, %tl                     !! current trap level = 1
157
        mov 0x0, %l1                    !! l1 = 0
158
        wrhpr %g3, %g0, %htstate        !! reset HTSTATE reg that store hyperpriviliged state after a trap
159
        wrpr 0, %tl                     !! current trap level = 0 (No Trap)
160
        mov 0x0, %o0                    !! please don’t delete since used in customized IMMU miss trap
161 73 fafa1971
 
162 112 albert.wat
        /* Jump in RAM */
163
        jmp %g2                         !! jump to 0x40000
164
!!      wrhpr %g0, 0x804, %hpstate      !! ensure bit 11 of the HPSTATE register is set
165
        nop
166
        nop

powered by: WebSVN 2.1.0

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