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

Subversion Repositories layer2

[/] [layer2/] [trunk/] [sw/] [common/] [boot.s] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 idiolatrie
################################################################################
2
# Boot Up Code                                                                 #
3
#------------------------------------------------------------------------------#
4
# REFERENCES                                                                   #
5
#                                                                              #
6
#    [1] The MIPS programmer's handbook                                        #
7
#        Erin Frquhar and Philip Bunce                                         #
8
#        San Francisco, CA, Morgan Kaufmann Publishers, 1994                   #
9
#        ISBN 1-55860-297-6                                                    #
10
#                                                                              #
11
#------------------------------------------------------------------------------#
12
# Copyright (C)2011  Mathias Hörtnagl <mathias.hoertnagl@gmail.com>            #
13
#                                                                              #
14
# This program is free software: you can redistribute it and/or modify         #
15
# it under the terms of the GNU General Public License as published by         #
16
# the Free Software Foundation, either version 3 of the License, or            #
17
# (at your option) any later version.                                          #
18
#                                                                              #
19
# This program is distributed in the hope that it will be useful,              #
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
22
# GNU General Public License for more details.                                 #
23
#                                                                              #
24
# You should have received a copy of the GNU General Public License            #
25
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
26
################################################################################
27
 
28
        .ifndef STACKSIZE             # Stack size in byte.
29
        .set    STACKSIZE, 8192
30
        .endif
31
 
32
        .comm   stack, STACKSIZE     # Global memory: stack.
33
 
34
        .text
35
        .align  2
36
################################################################################
37
# Execution Start                                                              #
38
#------------------------------------------------------------------------------#
39
        .globl  boot
40
        .ent       boot
41
boot:
42
        .set    noreorder
43
 
44
        la         $gp, _gp                   # Set global pointer.
45
        la         $sp, stack+STACKSIZE-24         # Set stack pointer.
46
 
47
        la      $v0, _bss_start         # Global variable region start.
48
        la      $v1, _bss_end           # Global variable region end.
49
 
50
clrbss:                          # Clear global variable region.
51
        sw      $0, ($v0)
52
        addiu $v0, 4
53
        blt     $v0, $v1, clrbss        # Continue execution when .bss region is clear.
54
        nop
55
 
56
   .set  noat
57
   and   $at, $0, $0             # Clear all registers.
58
   .set  at
59
   and   $v0, $0, $0
60
   and   $v1, $0, $0
61
   and   $a0, $0, $0
62
   and   $a1, $0, $0
63
   and   $a2, $0, $0
64
   and   $a3, $0, $0
65
   and   $t0, $0, $0
66
   and   $t1, $0, $0
67
   and   $t2, $0, $0
68
   and   $t3, $0, $0
69
   and   $t4, $0, $0
70
   and   $t5, $0, $0
71
   and   $t6, $0, $0
72
   and   $t7, $0, $0
73
   and   $s0, $0, $0
74
   and   $s1, $0, $0
75
   and   $s2, $0, $0
76
   and   $s3, $0, $0
77
   and   $s4, $0, $0
78
   and   $s5, $0, $0
79
   and   $s6, $0, $0
80
   and   $s7, $0, $0
81
   and   $t8, $0, $0
82
   and   $t9, $0, $0
83
   and   $k0, $0, $0
84
   and   $k1, $0, $0
85
   and   $fp, $0, $0
86
   and   $ra, $0, $0
87
 
88
        jal     main                    # Start execution of the C main procedure.
89
        nop
90
 
91
loop:                            # Final loop. Afer returning from C main loop.
92
   nop
93
        j       loop                       # Real Infinity.
94
        nop
95
   nop
96
 
97
        .set    reorder
98
        .end    boot
99
 
100
 
101
################################################################################
102
# Interrupt Start                                                              #
103
#------------------------------------------------------------------------------#
104
        # .ent  intr_handler
105
# intr_handler:
106
        # .set  noreorder
107
        # .set  noat
108
 
109
# If we do not include the Interrupt API, simply return to normal execution
110
# immediately.
111
# .ifdef _INTERRUPT
112
 
113
        # addiu $sp, $sp, -72            # Allocate space for all relevant registers.
114
        # sw       $at,  4($sp)            # Save all registers, that are used directily
115
        # sw       $v0,  8($sp)            # after a successful execution of the interrupt
116
        # sw       $v1, 12($sp)            # service routines.
117
        # sw       $a0, 16($sp)            # Registers $s0 - $s8 do not need to be saved,
118
        # sw       $a1, 20($sp)            # since the compiler stores them if they are
119
        # sw       $a2, 24($sp)            # used in a procedure.
120
        # sw       $a3, 28($sp)            # $gp is the same for the entire source code.
121
        # sw       $t0, 32($sp)            # Registers $k0 and $k1 are reserved for ASM
122
        # sw       $t1, 36($sp)            # routines. The C compiler does not use them.
123
        # sw       $t2, 40($sp)
124
        # sw       $t3, 44($sp)
125
        # sw       $t4, 48($sp)
126
        # sw       $t5, 52($sp)
127
        # sw       $t6, 56($sp)
128
        # sw       $t7, 60($sp)
129
        # sw       $t8, 64($sp)
130
        # sw       $t9, 68($sp)
131
        # sw       $ra, 72($sp)
132
 
133
        # mfc0  $k0, $13                            # Retrieve CAUSE (Pending Interrupts).
134
        #nop
135
        # mfc0  $k1, $12                            # Retrieve SR (Interrupt mask and global IE).
136
        # nop
137
        # and   $k0, $k0, $k1            # Get legal pending interrupts.
138
        # addiu $sp, $sp, -24
139
        # jal   intr_dispatch           # Jump to C interrupt dispatch routine.
140
   # srl        $a0, $k0, 8
141
   # addiu $sp, $sp, 24
142
 
143
        # lw       $at,  4($sp)            # Restore saved registers.
144
        # lw       $v0,  8($sp)
145
        # lw       $v1, 12($sp)
146
        # lw       $a0, 16($sp)
147
        # lw       $a1, 20($sp)
148
        # lw       $a2, 24($sp)
149
        # lw       $a3, 28($sp)
150
        # lw       $t0, 32($sp)
151
        # lw       $t1, 36($sp)
152
        # lw       $t2, 40($sp)
153
        # lw       $t3, 44($sp)
154
        # lw       $t4, 48($sp)
155
        # lw       $t5, 52($sp)
156
        # lw       $t6, 56($sp)
157
        # lw       $t7, 60($sp)
158
        # lw       $t8, 64($sp)
159
        # lw       $t9, 68($sp)
160
        # lw       $ra, 72($sp)
161
        # addiu $sp, $sp, 72          # Undo stack allocation.
162
 
163
# .endif
164
 
165
        # mfc0  $k1, $14                            # Retrieve EPC
166
        # nop
167
        # jr       $k1                     # Return to normal execution.
168
        # rfe                                     # Restore from exception. Pop IE stack.
169
 
170
   # .set  at
171
        # .set  reorder
172
        # .end  intr_handler
173
 
174
 
175
################################################################################
176
# Start Flash Application                                                      #
177
#------------------------------------------------------------------------------#
178
   .globl   start
179
        .ent       start
180
start:
181
        .set    noreorder
182
 
183
   lui   $k0, 0x2000
184
   jr    $k0
185
   nop
186
 
187
        .set    reorder
188
        .end    start

powered by: WebSVN 2.1.0

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