Subversion Repositories HelenOS

Rev

Rev 306 | Rev 313 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
308 jermar 1
#
1 jermar 2
# Copyright (C) 2001-2004 Jakub Jermar
3
# All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
7
# are met:
8
#
9
# - Redistributions of source code must retain the above copyright
10
#   notice, this list of conditions and the following disclaimer.
11
# - Redistributions in binary form must reproduce the above copyright
12
#   notice, this list of conditions and the following disclaimer in the
13
#   documentation and/or other materials provided with the distribution.
14
# - The name of the author may not be used to endorse or promote products
15
#   derived from this software without specific prior written permission.
16
#
17
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#
28
 
306 palkovsky 29
#define __ASM__
30
 
31
#include <arch/asm/regname.h>
32
#include <arch/mm/page.h>
33
#include <arch/asm/boot.h>
34
#include <arch/context.h>
35
 
1 jermar 36
.text
37
 
38
.set noat
39
.set noreorder
40
.set nomacro
41
 
42
.global kernel_image_start
43
.global tlb_refill_entry
44
.global cache_error_entry
45
.global exception_entry
46
 
306 palkovsky 47
.macro REGISTERS_STORE r
48
	sw $at,EOFFSET_AT(\r)
49
	sw $v0,EOFFSET_V0(\r)
50
	sw $v1,EOFFSET_V1(\r)
51
	sw $a0,EOFFSET_A0(\r)
52
	sw $a1,EOFFSET_A1(\r)
53
	sw $a2,EOFFSET_A2(\r)
54
	sw $a3,EOFFSET_A3(\r)
55
	sw $t0,EOFFSET_A4(\r)
56
	sw $t1,EOFFSET_T1(\r)
57
	sw $t2,EOFFSET_T2(\r)
58
	sw $t3,EOFFSET_T3(\r)
59
	sw $t4,EOFFSET_T4(\r)
60
	sw $t5,EOFFSET_T5(\r)
61
	sw $t6,EOFFSET_T6(\r)
62
	sw $t7,EOFFSET_T7(\r)
63
	sw $t8,EOFFSET_T8(\r)
64
	sw $t9,EOFFSET_T9(\r)
65
	sw $s0,EOFFSET_S0(\r)
66
	sw $s1,EOFFSET_S1(\r)
67
	sw $s2,EOFFSET_S2(\r)
68
	sw $s3,EOFFSET_S3(\r)
69
	sw $s4,EOFFSET_S4(\r)
70
	sw $s5,EOFFSET_S5(\r)
71
	sw $s6,EOFFSET_S6(\r)
72
	sw $s7,EOFFSET_S7(\r)
73
	sw $s8,EOFFSET_S8(\r)	
74
	sw $gp,EOFFSET_GP(\r)
75
	sw $ra,EOFFSET_RA(\r)
76
	mflo $k0
77
	mfhi $k1
78
	sw $k0,EOFFSET_LO(\r)
79
	sw $k1,EOFFSET_HI(\r)
80
.endm
81
 
82
.macro REGISTERS_LOAD r
83
	lw $at,EOFFSET_AT(\r)
84
	lw $v0,EOFFSET_V0(\r)
85
	lw $v1,EOFFSET_V1(\r)
86
	lw $a0,EOFFSET_A0(\r)
87
	lw $a1,EOFFSET_A1(\r)
88
	lw $a2,EOFFSET_A2(\r)
89
	lw $a3,EOFFSET_A3(\r)
90
	lw $t0,EOFFSET_A4(\r)
91
	lw $t1,EOFFSET_T1(\r)
92
	lw $t2,EOFFSET_T2(\r)
93
	lw $t3,EOFFSET_T3(\r)
94
	lw $t4,EOFFSET_T4(\r)
95
	lw $t5,EOFFSET_T5(\r)
96
	lw $t6,EOFFSET_T6(\r)
97
	lw $t7,EOFFSET_T7(\r)
98
	lw $t8,EOFFSET_T8(\r)
99
	lw $t9,EOFFSET_T9(\r)
100
	lw $s0,EOFFSET_S0(\r)
101
	lw $s1,EOFFSET_S1(\r)
102
	lw $s2,EOFFSET_S2(\r)
103
	lw $s3,EOFFSET_S3(\r)
104
	lw $s4,EOFFSET_S4(\r)
105
	lw $s5,EOFFSET_S5(\r)
106
	lw $s6,EOFFSET_S6(\r)
107
	lw $s7,EOFFSET_S7(\r)
108
	lw $s8,EOFFSET_S8(\r)
109
	lw $gp,EOFFSET_GP(\r)
110
	lw $ra,EOFFSET_RA(\r)
111
 
112
	lw $k0,EOFFSET_LO(\r)
113
	lw $k1,EOFFSET_HI(\r)
114
	mtlo $k0
115
	mthi $k1
116
.endm
117
 
118
 
1 jermar 119
.org 0x0
120
tlb_refill_entry:
50 jermar 121
	j tlb_refill_handler
122
	nop
1 jermar 123
 
124
.org 0x100
125
cache_error_entry:
50 jermar 126
	j cache_error_handler
127
	nop
125 jermar 128
 
1 jermar 129
.org 0x180
130
exception_entry:
131
exception_handler:
306 palkovsky 132
	sub $sp, REGISTER_SPACE
133
	REGISTERS_STORE $sp
125 jermar 134
 
50 jermar 135
	jal exception
136
	nop
125 jermar 137
 
306 palkovsky 138
	REGISTERS_LOAD $sp
139
	add $sp, REGISTER_SPACE
1 jermar 140
 
50 jermar 141
	eret
306 palkovsky 142
	nop
1 jermar 143
 
306 palkovsky 144
.org KA2PA(0x80000300)
145
kernel_image_start:
146
	/* Load temporary stack */
147
	lui $sp, (TEMP_STACK_START + TEMP_STACK_SIZE) >> 16
148
	ori $sp, (TEMP_STACK_START + TEMP_STACK_SIZE) & 0xffff
149
 
150
	/* Not sure about this, but might be needed for PIC code???? */
151
	lui $gp, 0x8000
152
 
153
	jal main_bsp
154
	nop
155
 
156
.org KA2PA(TEMP_STACK_START)
157
	.space TEMP_STACK_SIZE
158
 
1 jermar 159
tlb_refill_handler:
306 palkovsky 160
	sub $sp, REGISTER_SPACE
161
	REGISTERS_STORE $sp
125 jermar 162
 
50 jermar 163
	jal tlb_refill
164
	nop
125 jermar 165
 
306 palkovsky 166
	REGISTERS_LOAD $sp
167
	add $sp, REGISTER_SPACE
125 jermar 168
 
50 jermar 169
	eret
306 palkovsky 170
	nop
1 jermar 171
 
172
cache_error_handler:
306 palkovsky 173
	sub $sp, REGISTER_SPACE
174
	REGISTERS_STORE $sp
1 jermar 175
 
50 jermar 176
	jal cache_error
177
	nop
125 jermar 178
 
306 palkovsky 179
	REGISTERS_LOAD $sp
180
	add $sp, REGISTER_SPACE
1 jermar 181
 
50 jermar 182
	eret
308 jermar 183
	nop