Subversion Repositories HelenOS

Rev

Rev 3386 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3386 Rev 4153
Line 29... Line 29...
29
#include <arch/asm/regname.h>
29
#include <arch/asm/regname.h>
30
#include <arch/mm/page.h>
30
#include <arch/mm/page.h>
31
#include <arch/asm/boot.h>
31
#include <arch/asm/boot.h>
32
#include <arch/context_offset.h>
32
#include <arch/context_offset.h>
33
#include <arch/stack.h>
33
#include <arch/stack.h>
34
	
34
 
35
.text
35
.text
36
 
36
 
37
.set noat
37
.set noat
38
.set noreorder
38
.set noreorder
39
.set nomacro
39
.set nomacro
Line 73... Line 73...
73
	mflo $at
73
	mflo $at
74
	sw $at, EOFFSET_LO(\r)
74
	sw $at, EOFFSET_LO(\r)
75
	mfhi $at
75
	mfhi $at
76
	sw $at, EOFFSET_HI(\r)
76
	sw $at, EOFFSET_HI(\r)
77
	
77
	
78
#ifdef CONFIG_DEBUG_ALLREGS	
-
 
79
	sw $s0, EOFFSET_S0(\r)
-
 
80
	sw $s1, EOFFSET_S1(\r)
-
 
81
	sw $s2, EOFFSET_S2(\r)
-
 
82
	sw $s3, EOFFSET_S3(\r)
-
 
83
	sw $s4, EOFFSET_S4(\r)
-
 
84
	sw $s5, EOFFSET_S5(\r)
-
 
85
	sw $s6, EOFFSET_S6(\r)
-
 
86
	sw $s7, EOFFSET_S7(\r)
-
 
87
	sw $s8, EOFFSET_S8(\r)
-
 
88
#endif
-
 
89
	
-
 
90
	sw $gp, EOFFSET_GP(\r)
78
	sw $gp, EOFFSET_GP(\r)
91
	sw $ra, EOFFSET_RA(\r)
79
	sw $ra, EOFFSET_RA(\r)
92
	sw $k1, EOFFSET_K1(\r)
80
	sw $k1, EOFFSET_K1(\r)
93
 
81
 
94
	mfc0 $t0, $status
82
	mfc0 $t0, $status
Line 130... Line 118...
130
	lw $t6, EOFFSET_T6(\r)
118
	lw $t6, EOFFSET_T6(\r)
131
	lw $t7, EOFFSET_T7(\r)
119
	lw $t7, EOFFSET_T7(\r)
132
	lw $t8, EOFFSET_T8(\r)
120
	lw $t8, EOFFSET_T8(\r)
133
	lw $t9, EOFFSET_T9(\r)
121
	lw $t9, EOFFSET_T9(\r)
134
	
122
	
135
#ifdef CONFIG_DEBUG_ALLREGS	
-
 
136
	lw $s0, EOFFSET_S0(\r)
-
 
137
	lw $s1, EOFFSET_S1(\r)
-
 
138
	lw $s2, EOFFSET_S2(\r)
-
 
139
	lw $s3, EOFFSET_S3(\r)
-
 
140
	lw $s4, EOFFSET_S4(\r)
-
 
141
	lw $s5, EOFFSET_S5(\r)
-
 
142
	lw $s6, EOFFSET_S6(\r)
-
 
143
	lw $s7, EOFFSET_S7(\r)
-
 
144
	lw $s8, EOFFSET_S8(\r)
-
 
145
#endif
-
 
146
	lw $gp, EOFFSET_GP(\r)
123
	lw $gp, EOFFSET_GP(\r)
147
	lw $ra, EOFFSET_RA(\r)
124
	lw $ra, EOFFSET_RA(\r)
148
	lw $k1, EOFFSET_K1(\r)
125
	lw $k1, EOFFSET_K1(\r)
149
	
126
	
150
	lw $at, EOFFSET_LO(\r)
127
	lw $at, EOFFSET_LO(\r)
Line 173... Line 150...
173
	# Move $k0 pointer to kernel stack
150
	# Move $k0 pointer to kernel stack
174
	lui $k0, %hi(supervisor_sp)
151
	lui $k0, %hi(supervisor_sp)
175
	ori $k0, $k0, %lo(supervisor_sp)
152
	ori $k0, $k0, %lo(supervisor_sp)
176
	# Move $k0 (superveisor_sp)
153
	# Move $k0 (superveisor_sp)
177
	lw $k0, 0($k0)
154
	lw $k0, 0($k0)
178
1:		
155
1:
179
.endm
156
.endm
180
		
157
 
181
.org 0x0
158
.org 0x0
182
kernel_image_start:
159
kernel_image_start:
183
	/* Load temporary stack */
160
	/* Load temporary stack */
184
	lui $sp, %hi(end_stack)
161
	lui $sp, %hi(end_stack)
185
	ori $sp, $sp, %lo(end_stack)
162
	ori $sp, $sp, %lo(end_stack)
186
	
163
	
187
	/* $a1 contains physical address of bootinfo_t */
-
 
188
	/* $a2 contains size of bootinfo_t */
164
	/* Not sure about this, but might
189
	
-
 
190
	beq $a2, $0, bootinfo_end
-
 
191
	
-
 
192
	/* Not sure about this, but might be needed for PIC code???? */
165
	   be needed for PIC code */
193
	lui $gp, 0x8000
166
	lui $gp, 0x8000
194
	
167
	
195
	lui $a3, %hi(bootinfo)
-
 
196
	ori $a3, $a3, %lo(bootinfo)
168
	/* $a1 contains physical address of bootinfo_t */
197
	
-
 
198
	bootinfo_loop:
-
 
199
		
-
 
200
		lw $v0, 0($a1)
-
 
201
		sw $v0, 0($a3)
-
 
202
		
-
 
203
		addi $a1, $a1, 4
-
 
204
		addi $a3, $a3, 4
-
 
205
		addi $a2, $a2, -4
-
 
206
		
-
 
207
		bgtz $a2, bootinfo_loop
-
 
208
		nop
-
 
209
		
-
 
210
	bootinfo_end:
-
 
211
	
169
	
212
	jal arch_pre_main
170
	jal arch_pre_main
213
	nop
171
	nop
214
	
172
	
215
	j main_bsp
173
	j main_bsp
Line 226... Line 184...
226
	j cache_error_handler
184
	j cache_error_handler
227
	nop
185
	nop
228
 
186
 
229
exception_entry:
187
exception_entry:
230
	j exception_handler
188
	j exception_handler
231
	nop	
189
	nop
232
	
190
 
233
exception_handler:
191
exception_handler:
234
	KERNEL_STACK_TO_K0
192
	KERNEL_STACK_TO_K0
235
	sub $k0, REGISTER_SPACE
193
	sub $k0, REGISTER_SPACE
236
	sw $sp, EOFFSET_SP($k0)
194
	sw $sp, EOFFSET_SP($k0)
237
	move $sp, $k0
195
	move $sp, $k0
238
	
196
	
239
	mfc0 $k0, $cause
197
	mfc0 $k0, $cause
240
	
198
	
241
	sra $k0, $k0, 0x2		# cp0_exc_cause() part 1
199
	sra $k0, $k0, 0x2    # cp0_exc_cause() part 1
242
	andi $k0, $k0, 0x1f		# cp0_exc_cause() part 2
200
	andi $k0, $k0, 0x1f  # cp0_exc_cause() part 2
243
	sub $k0, 8			# 8 = SYSCALL
201
	sub $k0, 8           # 8 = SYSCALL
244
	
202
	
245
	beqz $k0, syscall_shortcut
203
	beqz $k0, syscall_shortcut
246
	add $k0, 8			# Revert $k0 back to correct exc number
204
	add $k0, 8           # Revert $k0 back to correct exc number
247
	
205
	
248
	REGISTERS_STORE_AND_EXC_RESET $sp
206
	REGISTERS_STORE_AND_EXC_RESET $sp
249
	
207
	
250
	move $a1, $sp
208
	move $a1, $sp
251
	jal exc_dispatch		# exc_dispatch(excno, register_space)
209
	jal exc_dispatch     # exc_dispatch(excno, register_space)
252
	move $a0, $k0
210
	move $a0, $k0
253
 
211
 
254
	REGISTERS_LOAD $sp
212
	REGISTERS_LOAD $sp
255
	# The $sp is automatically restored to former value
213
	# The $sp is automatically restored to former value
256
	eret
214
	eret