aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/kernel/entry.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/microblaze/kernel/entry.S')
-rw-r--r--arch/microblaze/kernel/entry.S325
1 files changed, 167 insertions, 158 deletions
diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S
index 41c30cdb2704..ca15bc5c7449 100644
--- a/arch/microblaze/kernel/entry.S
+++ b/arch/microblaze/kernel/entry.S
@@ -33,11 +33,14 @@
33 33
34#undef DEBUG 34#undef DEBUG
35 35
36/* The size of a state save frame. */ 36#ifdef DEBUG
37#define STATE_SAVE_SIZE (PT_SIZE + STATE_SAVE_ARG_SPACE) 37/* Create space for syscalls counting. */
38 38.section .data
39/* The offset of the struct pt_regs in a `state save frame' on the stack. */ 39.global syscall_debug_table
40#define PTO STATE_SAVE_ARG_SPACE /* 24 the space for args */ 40.align 4
41syscall_debug_table:
42 .space (__NR_syscalls * 4)
43#endif /* DEBUG */
41 44
42#define C_ENTRY(name) .globl name; .align 4; name 45#define C_ENTRY(name) .globl name; .align 4; name
43 46
@@ -172,72 +175,72 @@
1721: 1751:
173 176
174#define SAVE_REGS \ 177#define SAVE_REGS \
175 swi r2, r1, PTO+PT_R2; /* Save SDA */ \ 178 swi r2, r1, PT_R2; /* Save SDA */ \
176 swi r3, r1, PTO+PT_R3; \ 179 swi r3, r1, PT_R3; \
177 swi r4, r1, PTO+PT_R4; \ 180 swi r4, r1, PT_R4; \
178 swi r5, r1, PTO+PT_R5; \ 181 swi r5, r1, PT_R5; \
179 swi r6, r1, PTO+PT_R6; \ 182 swi r6, r1, PT_R6; \
180 swi r7, r1, PTO+PT_R7; \ 183 swi r7, r1, PT_R7; \
181 swi r8, r1, PTO+PT_R8; \ 184 swi r8, r1, PT_R8; \
182 swi r9, r1, PTO+PT_R9; \ 185 swi r9, r1, PT_R9; \
183 swi r10, r1, PTO+PT_R10; \ 186 swi r10, r1, PT_R10; \
184 swi r11, r1, PTO+PT_R11; /* save clobbered regs after rval */\ 187 swi r11, r1, PT_R11; /* save clobbered regs after rval */\
185 swi r12, r1, PTO+PT_R12; \ 188 swi r12, r1, PT_R12; \
186 swi r13, r1, PTO+PT_R13; /* Save SDA2 */ \ 189 swi r13, r1, PT_R13; /* Save SDA2 */ \
187 swi r14, r1, PTO+PT_PC; /* PC, before IRQ/trap */ \ 190 swi r14, r1, PT_PC; /* PC, before IRQ/trap */ \
188 swi r15, r1, PTO+PT_R15; /* Save LP */ \ 191 swi r15, r1, PT_R15; /* Save LP */ \
189 swi r16, r1, PTO+PT_R16; \ 192 swi r16, r1, PT_R16; \
190 swi r17, r1, PTO+PT_R17; \ 193 swi r17, r1, PT_R17; \
191 swi r18, r1, PTO+PT_R18; /* Save asm scratch reg */ \ 194 swi r18, r1, PT_R18; /* Save asm scratch reg */ \
192 swi r19, r1, PTO+PT_R19; \ 195 swi r19, r1, PT_R19; \
193 swi r20, r1, PTO+PT_R20; \ 196 swi r20, r1, PT_R20; \
194 swi r21, r1, PTO+PT_R21; \ 197 swi r21, r1, PT_R21; \
195 swi r22, r1, PTO+PT_R22; \ 198 swi r22, r1, PT_R22; \
196 swi r23, r1, PTO+PT_R23; \ 199 swi r23, r1, PT_R23; \
197 swi r24, r1, PTO+PT_R24; \ 200 swi r24, r1, PT_R24; \
198 swi r25, r1, PTO+PT_R25; \ 201 swi r25, r1, PT_R25; \
199 swi r26, r1, PTO+PT_R26; \ 202 swi r26, r1, PT_R26; \
200 swi r27, r1, PTO+PT_R27; \ 203 swi r27, r1, PT_R27; \
201 swi r28, r1, PTO+PT_R28; \ 204 swi r28, r1, PT_R28; \
202 swi r29, r1, PTO+PT_R29; \ 205 swi r29, r1, PT_R29; \
203 swi r30, r1, PTO+PT_R30; \ 206 swi r30, r1, PT_R30; \
204 swi r31, r1, PTO+PT_R31; /* Save current task reg */ \ 207 swi r31, r1, PT_R31; /* Save current task reg */ \
205 mfs r11, rmsr; /* save MSR */ \ 208 mfs r11, rmsr; /* save MSR */ \
206 swi r11, r1, PTO+PT_MSR; 209 swi r11, r1, PT_MSR;
207 210
208#define RESTORE_REGS \ 211#define RESTORE_REGS \
209 lwi r11, r1, PTO+PT_MSR; \ 212 lwi r11, r1, PT_MSR; \
210 mts rmsr , r11; \ 213 mts rmsr , r11; \
211 lwi r2, r1, PTO+PT_R2; /* restore SDA */ \ 214 lwi r2, r1, PT_R2; /* restore SDA */ \
212 lwi r3, r1, PTO+PT_R3; \ 215 lwi r3, r1, PT_R3; \
213 lwi r4, r1, PTO+PT_R4; \ 216 lwi r4, r1, PT_R4; \
214 lwi r5, r1, PTO+PT_R5; \ 217 lwi r5, r1, PT_R5; \
215 lwi r6, r1, PTO+PT_R6; \ 218 lwi r6, r1, PT_R6; \
216 lwi r7, r1, PTO+PT_R7; \ 219 lwi r7, r1, PT_R7; \
217 lwi r8, r1, PTO+PT_R8; \ 220 lwi r8, r1, PT_R8; \
218 lwi r9, r1, PTO+PT_R9; \ 221 lwi r9, r1, PT_R9; \
219 lwi r10, r1, PTO+PT_R10; \ 222 lwi r10, r1, PT_R10; \
220 lwi r11, r1, PTO+PT_R11; /* restore clobbered regs after rval */\ 223 lwi r11, r1, PT_R11; /* restore clobbered regs after rval */\
221 lwi r12, r1, PTO+PT_R12; \ 224 lwi r12, r1, PT_R12; \
222 lwi r13, r1, PTO+PT_R13; /* restore SDA2 */ \ 225 lwi r13, r1, PT_R13; /* restore SDA2 */ \
223 lwi r14, r1, PTO+PT_PC; /* RESTORE_LINK PC, before IRQ/trap */\ 226 lwi r14, r1, PT_PC; /* RESTORE_LINK PC, before IRQ/trap */\
224 lwi r15, r1, PTO+PT_R15; /* restore LP */ \ 227 lwi r15, r1, PT_R15; /* restore LP */ \
225 lwi r16, r1, PTO+PT_R16; \ 228 lwi r16, r1, PT_R16; \
226 lwi r17, r1, PTO+PT_R17; \ 229 lwi r17, r1, PT_R17; \
227 lwi r18, r1, PTO+PT_R18; /* restore asm scratch reg */ \ 230 lwi r18, r1, PT_R18; /* restore asm scratch reg */ \
228 lwi r19, r1, PTO+PT_R19; \ 231 lwi r19, r1, PT_R19; \
229 lwi r20, r1, PTO+PT_R20; \ 232 lwi r20, r1, PT_R20; \
230 lwi r21, r1, PTO+PT_R21; \ 233 lwi r21, r1, PT_R21; \
231 lwi r22, r1, PTO+PT_R22; \ 234 lwi r22, r1, PT_R22; \
232 lwi r23, r1, PTO+PT_R23; \ 235 lwi r23, r1, PT_R23; \
233 lwi r24, r1, PTO+PT_R24; \ 236 lwi r24, r1, PT_R24; \
234 lwi r25, r1, PTO+PT_R25; \ 237 lwi r25, r1, PT_R25; \
235 lwi r26, r1, PTO+PT_R26; \ 238 lwi r26, r1, PT_R26; \
236 lwi r27, r1, PTO+PT_R27; \ 239 lwi r27, r1, PT_R27; \
237 lwi r28, r1, PTO+PT_R28; \ 240 lwi r28, r1, PT_R28; \
238 lwi r29, r1, PTO+PT_R29; \ 241 lwi r29, r1, PT_R29; \
239 lwi r30, r1, PTO+PT_R30; \ 242 lwi r30, r1, PT_R30; \
240 lwi r31, r1, PTO+PT_R31; /* Restore cur task reg */ 243 lwi r31, r1, PT_R31; /* Restore cur task reg */
241 244
242#define SAVE_STATE \ 245#define SAVE_STATE \
243 swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* save stack */ \ 246 swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* save stack */ \
@@ -250,11 +253,11 @@
250 lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); \ 253 lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); \
251 /* FIXME: I can add these two lines to one */ \ 254 /* FIXME: I can add these two lines to one */ \
252 /* tophys(r1,r1); */ \ 255 /* tophys(r1,r1); */ \
253 /* addik r1, r1, -STATE_SAVE_SIZE; */ \ 256 /* addik r1, r1, -PT_SIZE; */ \
254 addik r1, r1, CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - STATE_SAVE_SIZE; \ 257 addik r1, r1, CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - PT_SIZE; \
255 SAVE_REGS \ 258 SAVE_REGS \
256 brid 2f; \ 259 brid 2f; \
257 swi r1, r1, PTO+PT_MODE; \ 260 swi r1, r1, PT_MODE; \
2581: /* User-mode state save. */ \ 2611: /* User-mode state save. */ \
259 lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */\ 262 lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */\
260 tophys(r1,r1); \ 263 tophys(r1,r1); \
@@ -262,12 +265,12 @@
262 /* MS these three instructions can be added to one */ \ 265 /* MS these three instructions can be added to one */ \
263 /* addik r1, r1, THREAD_SIZE; */ \ 266 /* addik r1, r1, THREAD_SIZE; */ \
264 /* tophys(r1,r1); */ \ 267 /* tophys(r1,r1); */ \
265 /* addik r1, r1, -STATE_SAVE_SIZE; */ \ 268 /* addik r1, r1, -PT_SIZE; */ \
266 addik r1, r1, THREAD_SIZE + CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - STATE_SAVE_SIZE; \ 269 addik r1, r1, THREAD_SIZE + CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - PT_SIZE; \
267 SAVE_REGS \ 270 SAVE_REGS \
268 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); \ 271 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); \
269 swi r11, r1, PTO+PT_R1; /* Store user SP. */ \ 272 swi r11, r1, PT_R1; /* Store user SP. */ \
270 swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ \ 273 swi r0, r1, PT_MODE; /* Was in user-mode. */ \
271 /* MS: I am clearing UMS even in case when I come from kernel space */ \ 274 /* MS: I am clearing UMS even in case when I come from kernel space */ \
272 clear_ums; \ 275 clear_ums; \
2732: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 2762: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE));
@@ -299,10 +302,10 @@ C_ENTRY(_user_exception):
299 lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* Reload kernel stack-ptr*/ 302 lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* Reload kernel stack-ptr*/
300 tophys(r1,r1); 303 tophys(r1,r1);
301 304
302 addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 305 addik r1, r1, -PT_SIZE; /* Make room on the stack. */
303 SAVE_REGS 306 SAVE_REGS
304 307
305 swi r1, r1, PTO + PT_MODE; /* pt_regs -> kernel mode */ 308 swi r1, r1, PT_MODE; /* pt_regs -> kernel mode */
306 brid 2f; 309 brid 2f;
307 nop; /* Fill delay slot */ 310 nop; /* Fill delay slot */
308 311
@@ -315,18 +318,18 @@ C_ENTRY(_user_exception):
315 addik r1, r1, THREAD_SIZE; 318 addik r1, r1, THREAD_SIZE;
316 tophys(r1,r1); 319 tophys(r1,r1);
317 320
318 addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 321 addik r1, r1, -PT_SIZE; /* Make room on the stack. */
319 SAVE_REGS 322 SAVE_REGS
320 swi r0, r1, PTO + PT_R3 323 swi r0, r1, PT_R3
321 swi r0, r1, PTO + PT_R4 324 swi r0, r1, PT_R4
322 325
323 swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ 326 swi r0, r1, PT_MODE; /* Was in user-mode. */
324 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 327 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP));
325 swi r11, r1, PTO+PT_R1; /* Store user SP. */ 328 swi r11, r1, PT_R1; /* Store user SP. */
326 clear_ums; 329 clear_ums;
3272: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 3302: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE));
328 /* Save away the syscall number. */ 331 /* Save away the syscall number. */
329 swi r12, r1, PTO+PT_R0; 332 swi r12, r1, PT_R0;
330 tovirt(r1,r1) 333 tovirt(r1,r1)
331 334
332/* where the trap should return need -8 to adjust for rtsd r15, 8*/ 335/* where the trap should return need -8 to adjust for rtsd r15, 8*/
@@ -345,18 +348,18 @@ C_ENTRY(_user_exception):
345 beqi r11, 4f 348 beqi r11, 4f
346 349
347 addik r3, r0, -ENOSYS 350 addik r3, r0, -ENOSYS
348 swi r3, r1, PTO + PT_R3 351 swi r3, r1, PT_R3
349 brlid r15, do_syscall_trace_enter 352 brlid r15, do_syscall_trace_enter
350 addik r5, r1, PTO + PT_R0 353 addik r5, r1, PT_R0
351 354
352 # do_syscall_trace_enter returns the new syscall nr. 355 # do_syscall_trace_enter returns the new syscall nr.
353 addk r12, r0, r3 356 addk r12, r0, r3
354 lwi r5, r1, PTO+PT_R5; 357 lwi r5, r1, PT_R5;
355 lwi r6, r1, PTO+PT_R6; 358 lwi r6, r1, PT_R6;
356 lwi r7, r1, PTO+PT_R7; 359 lwi r7, r1, PT_R7;
357 lwi r8, r1, PTO+PT_R8; 360 lwi r8, r1, PT_R8;
358 lwi r9, r1, PTO+PT_R9; 361 lwi r9, r1, PT_R9;
359 lwi r10, r1, PTO+PT_R10; 362 lwi r10, r1, PT_R10;
3604: 3634:
361/* Jump to the appropriate function for the system call number in r12 364/* Jump to the appropriate function for the system call number in r12
362 * (r12 is not preserved), or return an error if r12 is not valid. 365 * (r12 is not preserved), or return an error if r12 is not valid.
@@ -371,10 +374,14 @@ C_ENTRY(_user_exception):
371 add r12, r12, r12; 374 add r12, r12, r12;
372 375
373#ifdef DEBUG 376#ifdef DEBUG
374 /* Trac syscalls and stored them to r0_ram */ 377 /* Trac syscalls and stored them to syscall_debug_table */
375 lwi r3, r12, 0x400 + r0_ram 378 /* The first syscall location stores total syscall number */
379 lwi r3, r0, syscall_debug_table
380 addi r3, r3, 1
381 swi r3, r0, syscall_debug_table
382 lwi r3, r12, syscall_debug_table
376 addi r3, r3, 1 383 addi r3, r3, 1
377 swi r3, r12, 0x400 + r0_ram 384 swi r3, r12, syscall_debug_table
378#endif 385#endif
379 386
380 # Find and jump into the syscall handler. 387 # Find and jump into the syscall handler.
@@ -391,10 +398,10 @@ C_ENTRY(_user_exception):
391/* Entry point used to return from a syscall/trap */ 398/* Entry point used to return from a syscall/trap */
392/* We re-enable BIP bit before state restore */ 399/* We re-enable BIP bit before state restore */
393C_ENTRY(ret_from_trap): 400C_ENTRY(ret_from_trap):
394 swi r3, r1, PTO + PT_R3 401 swi r3, r1, PT_R3
395 swi r4, r1, PTO + PT_R4 402 swi r4, r1, PT_R4
396 403
397 lwi r11, r1, PTO + PT_MODE; 404 lwi r11, r1, PT_MODE;
398/* See if returning to kernel mode, if so, skip resched &c. */ 405/* See if returning to kernel mode, if so, skip resched &c. */
399 bnei r11, 2f; 406 bnei r11, 2f;
400 /* We're returning to user mode, so check for various conditions that 407 /* We're returning to user mode, so check for various conditions that
@@ -406,7 +413,7 @@ C_ENTRY(ret_from_trap):
406 beqi r11, 1f 413 beqi r11, 1f
407 414
408 brlid r15, do_syscall_trace_leave 415 brlid r15, do_syscall_trace_leave
409 addik r5, r1, PTO + PT_R0 416 addik r5, r1, PT_R0
4101: 4171:
411 /* We're returning to user mode, so check for various conditions that 418 /* We're returning to user mode, so check for various conditions that
412 * trigger rescheduling. */ 419 * trigger rescheduling. */
@@ -426,7 +433,7 @@ C_ENTRY(ret_from_trap):
426 andi r11, r11, _TIF_SIGPENDING; 433 andi r11, r11, _TIF_SIGPENDING;
427 beqi r11, 1f; /* Signals to handle, handle them */ 434 beqi r11, 1f; /* Signals to handle, handle them */
428 435
429 addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 436 addik r5, r1, 0; /* Arg 1: struct pt_regs *regs */
430 addi r7, r0, 1; /* Arg 3: int in_syscall */ 437 addi r7, r0, 1; /* Arg 3: int in_syscall */
431 bralid r15, do_signal; /* Handle any signals */ 438 bralid r15, do_signal; /* Handle any signals */
432 add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 439 add r6, r0, r0; /* Arg 2: sigset_t *oldset */
@@ -437,7 +444,7 @@ C_ENTRY(ret_from_trap):
437 VM_OFF; 444 VM_OFF;
438 tophys(r1,r1); 445 tophys(r1,r1);
439 RESTORE_REGS; 446 RESTORE_REGS;
440 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 447 addik r1, r1, PT_SIZE /* Clean up stack space. */
441 lwi r1, r1, PT_R1 - PT_SIZE;/* Restore user stack pointer. */ 448 lwi r1, r1, PT_R1 - PT_SIZE;/* Restore user stack pointer. */
442 bri 6f; 449 bri 6f;
443 450
@@ -446,7 +453,7 @@ C_ENTRY(ret_from_trap):
446 VM_OFF; 453 VM_OFF;
447 tophys(r1,r1); 454 tophys(r1,r1);
448 RESTORE_REGS; 455 RESTORE_REGS;
449 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 456 addik r1, r1, PT_SIZE /* Clean up stack space. */
450 tovirt(r1,r1); 457 tovirt(r1,r1);
4516: 4586:
452TRAP_return: /* Make global symbol for debugging */ 459TRAP_return: /* Make global symbol for debugging */
@@ -459,8 +466,8 @@ TRAP_return: /* Make global symbol for debugging */
459 466
460C_ENTRY(sys_fork_wrapper): 467C_ENTRY(sys_fork_wrapper):
461 addi r5, r0, SIGCHLD /* Arg 0: flags */ 468 addi r5, r0, SIGCHLD /* Arg 0: flags */
462 lwi r6, r1, PTO+PT_R1 /* Arg 1: child SP (use parent's) */ 469 lwi r6, r1, PT_R1 /* Arg 1: child SP (use parent's) */
463 addik r7, r1, PTO /* Arg 2: parent context */ 470 addik r7, r1, 0 /* Arg 2: parent context */
464 add r8. r0, r0 /* Arg 3: (unused) */ 471 add r8. r0, r0 /* Arg 3: (unused) */
465 add r9, r0, r0; /* Arg 4: (unused) */ 472 add r9, r0, r0; /* Arg 4: (unused) */
466 brid do_fork /* Do real work (tail-call) */ 473 brid do_fork /* Do real work (tail-call) */
@@ -480,12 +487,12 @@ C_ENTRY(ret_from_fork):
480 487
481C_ENTRY(sys_vfork): 488C_ENTRY(sys_vfork):
482 brid microblaze_vfork /* Do real work (tail-call) */ 489 brid microblaze_vfork /* Do real work (tail-call) */
483 addik r5, r1, PTO 490 addik r5, r1, 0
484 491
485C_ENTRY(sys_clone): 492C_ENTRY(sys_clone):
486 bnei r6, 1f; /* See if child SP arg (arg 1) is 0. */ 493 bnei r6, 1f; /* See if child SP arg (arg 1) is 0. */
487 lwi r6, r1, PTO + PT_R1; /* If so, use paret's stack ptr */ 494 lwi r6, r1, PT_R1; /* If so, use paret's stack ptr */
4881: addik r7, r1, PTO; /* Arg 2: parent context */ 4951: addik r7, r1, 0; /* Arg 2: parent context */
489 add r8, r0, r0; /* Arg 3: (unused) */ 496 add r8, r0, r0; /* Arg 3: (unused) */
490 add r9, r0, r0; /* Arg 4: (unused) */ 497 add r9, r0, r0; /* Arg 4: (unused) */
491 brid do_fork /* Do real work (tail-call) */ 498 brid do_fork /* Do real work (tail-call) */
@@ -493,11 +500,11 @@ C_ENTRY(sys_clone):
493 500
494C_ENTRY(sys_execve): 501C_ENTRY(sys_execve):
495 brid microblaze_execve; /* Do real work (tail-call).*/ 502 brid microblaze_execve; /* Do real work (tail-call).*/
496 addik r8, r1, PTO; /* add user context as 4th arg */ 503 addik r8, r1, 0; /* add user context as 4th arg */
497 504
498C_ENTRY(sys_rt_sigreturn_wrapper): 505C_ENTRY(sys_rt_sigreturn_wrapper):
499 brid sys_rt_sigreturn /* Do real work */ 506 brid sys_rt_sigreturn /* Do real work */
500 addik r5, r1, PTO; /* add user context as 1st arg */ 507 addik r5, r1, 0; /* add user context as 1st arg */
501 508
502/* 509/*
503 * HW EXCEPTION rutine start 510 * HW EXCEPTION rutine start
@@ -508,7 +515,7 @@ C_ENTRY(full_exception_trap):
508 addik r17, r17, -4 515 addik r17, r17, -4
509 SAVE_STATE /* Save registers */ 516 SAVE_STATE /* Save registers */
510 /* PC, before IRQ/trap - this is one instruction above */ 517 /* PC, before IRQ/trap - this is one instruction above */
511 swi r17, r1, PTO+PT_PC; 518 swi r17, r1, PT_PC;
512 tovirt(r1,r1) 519 tovirt(r1,r1)
513 /* FIXME this can be store directly in PT_ESR reg. 520 /* FIXME this can be store directly in PT_ESR reg.
514 * I tested it but there is a fault */ 521 * I tested it but there is a fault */
@@ -518,7 +525,7 @@ C_ENTRY(full_exception_trap):
518 mfs r7, rfsr; /* save FSR */ 525 mfs r7, rfsr; /* save FSR */
519 mts rfsr, r0; /* Clear sticky fsr */ 526 mts rfsr, r0; /* Clear sticky fsr */
520 rted r0, full_exception 527 rted r0, full_exception
521 addik r5, r1, PTO /* parameter struct pt_regs * regs */ 528 addik r5, r1, 0 /* parameter struct pt_regs * regs */
522 529
523/* 530/*
524 * Unaligned data trap. 531 * Unaligned data trap.
@@ -544,14 +551,14 @@ C_ENTRY(unaligned_data_trap):
544 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 551 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP));
545 SAVE_STATE /* Save registers.*/ 552 SAVE_STATE /* Save registers.*/
546 /* PC, before IRQ/trap - this is one instruction above */ 553 /* PC, before IRQ/trap - this is one instruction above */
547 swi r17, r1, PTO+PT_PC; 554 swi r17, r1, PT_PC;
548 tovirt(r1,r1) 555 tovirt(r1,r1)
549 /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 556 /* where the trap should return need -8 to adjust for rtsd r15, 8 */
550 addik r15, r0, ret_from_exc-8 557 addik r15, r0, ret_from_exc-8
551 mfs r3, resr /* ESR */ 558 mfs r3, resr /* ESR */
552 mfs r4, rear /* EAR */ 559 mfs r4, rear /* EAR */
553 rtbd r0, _unaligned_data_exception 560 rtbd r0, _unaligned_data_exception
554 addik r7, r1, PTO /* parameter struct pt_regs * regs */ 561 addik r7, r1, 0 /* parameter struct pt_regs * regs */
555 562
556/* 563/*
557 * Page fault traps. 564 * Page fault traps.
@@ -574,30 +581,30 @@ C_ENTRY(unaligned_data_trap):
574C_ENTRY(page_fault_data_trap): 581C_ENTRY(page_fault_data_trap):
575 SAVE_STATE /* Save registers.*/ 582 SAVE_STATE /* Save registers.*/
576 /* PC, before IRQ/trap - this is one instruction above */ 583 /* PC, before IRQ/trap - this is one instruction above */
577 swi r17, r1, PTO+PT_PC; 584 swi r17, r1, PT_PC;
578 tovirt(r1,r1) 585 tovirt(r1,r1)
579 /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 586 /* where the trap should return need -8 to adjust for rtsd r15, 8 */
580 addik r15, r0, ret_from_exc-8 587 addik r15, r0, ret_from_exc-8
581 mfs r6, rear /* parameter unsigned long address */ 588 mfs r6, rear /* parameter unsigned long address */
582 mfs r7, resr /* parameter unsigned long error_code */ 589 mfs r7, resr /* parameter unsigned long error_code */
583 rted r0, do_page_fault 590 rted r0, do_page_fault
584 addik r5, r1, PTO /* parameter struct pt_regs * regs */ 591 addik r5, r1, 0 /* parameter struct pt_regs * regs */
585 592
586C_ENTRY(page_fault_instr_trap): 593C_ENTRY(page_fault_instr_trap):
587 SAVE_STATE /* Save registers.*/ 594 SAVE_STATE /* Save registers.*/
588 /* PC, before IRQ/trap - this is one instruction above */ 595 /* PC, before IRQ/trap - this is one instruction above */
589 swi r17, r1, PTO+PT_PC; 596 swi r17, r1, PT_PC;
590 tovirt(r1,r1) 597 tovirt(r1,r1)
591 /* where the trap should return need -8 to adjust for rtsd r15, 8 */ 598 /* where the trap should return need -8 to adjust for rtsd r15, 8 */
592 addik r15, r0, ret_from_exc-8 599 addik r15, r0, ret_from_exc-8
593 mfs r6, rear /* parameter unsigned long address */ 600 mfs r6, rear /* parameter unsigned long address */
594 ori r7, r0, 0 /* parameter unsigned long error_code */ 601 ori r7, r0, 0 /* parameter unsigned long error_code */
595 rted r0, do_page_fault 602 rted r0, do_page_fault
596 addik r5, r1, PTO /* parameter struct pt_regs * regs */ 603 addik r5, r1, 0 /* parameter struct pt_regs * regs */
597 604
598/* Entry point used to return from an exception. */ 605/* Entry point used to return from an exception. */
599C_ENTRY(ret_from_exc): 606C_ENTRY(ret_from_exc):
600 lwi r11, r1, PTO + PT_MODE; 607 lwi r11, r1, PT_MODE;
601 bnei r11, 2f; /* See if returning to kernel mode, */ 608 bnei r11, 2f; /* See if returning to kernel mode, */
602 /* ... if so, skip resched &c. */ 609 /* ... if so, skip resched &c. */
603 610
@@ -629,7 +636,7 @@ C_ENTRY(ret_from_exc):
629 * complete register state. Here we save anything not saved by 636 * complete register state. Here we save anything not saved by
630 * the normal entry sequence, so that it may be safely restored 637 * the normal entry sequence, so that it may be safely restored
631 * (in a possibly modified form) after do_signal returns. */ 638 * (in a possibly modified form) after do_signal returns. */
632 addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 639 addik r5, r1, 0; /* Arg 1: struct pt_regs *regs */
633 addi r7, r0, 0; /* Arg 3: int in_syscall */ 640 addi r7, r0, 0; /* Arg 3: int in_syscall */
634 bralid r15, do_signal; /* Handle any signals */ 641 bralid r15, do_signal; /* Handle any signals */
635 add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 642 add r6, r0, r0; /* Arg 2: sigset_t *oldset */
@@ -641,7 +648,7 @@ C_ENTRY(ret_from_exc):
641 tophys(r1,r1); 648 tophys(r1,r1);
642 649
643 RESTORE_REGS; 650 RESTORE_REGS;
644 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 651 addik r1, r1, PT_SIZE /* Clean up stack space. */
645 652
646 lwi r1, r1, PT_R1 - PT_SIZE; /* Restore user stack pointer. */ 653 lwi r1, r1, PT_R1 - PT_SIZE; /* Restore user stack pointer. */
647 bri 6f; 654 bri 6f;
@@ -650,7 +657,7 @@ C_ENTRY(ret_from_exc):
650 VM_OFF; 657 VM_OFF;
651 tophys(r1,r1); 658 tophys(r1,r1);
652 RESTORE_REGS; 659 RESTORE_REGS;
653 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 660 addik r1, r1, PT_SIZE /* Clean up stack space. */
654 661
655 tovirt(r1,r1); 662 tovirt(r1,r1);
6566: 6636:
@@ -683,10 +690,10 @@ C_ENTRY(_interrupt):
683 tophys(r1,r1); /* MS: I have in r1 physical address where stack is */ 690 tophys(r1,r1); /* MS: I have in r1 physical address where stack is */
684 /* save registers */ 691 /* save registers */
685/* MS: Make room on the stack -> activation record */ 692/* MS: Make room on the stack -> activation record */
686 addik r1, r1, -STATE_SAVE_SIZE; 693 addik r1, r1, -PT_SIZE;
687 SAVE_REGS 694 SAVE_REGS
688 brid 2f; 695 brid 2f;
689 swi r1, r1, PTO + PT_MODE; /* 0 - user mode, 1 - kernel mode */ 696 swi r1, r1, PT_MODE; /* 0 - user mode, 1 - kernel mode */
6901: 6971:
691/* User-mode state save. */ 698/* User-mode state save. */
692 /* MS: get the saved current */ 699 /* MS: get the saved current */
@@ -696,23 +703,23 @@ C_ENTRY(_interrupt):
696 addik r1, r1, THREAD_SIZE; 703 addik r1, r1, THREAD_SIZE;
697 tophys(r1,r1); 704 tophys(r1,r1);
698 /* save registers */ 705 /* save registers */
699 addik r1, r1, -STATE_SAVE_SIZE; 706 addik r1, r1, -PT_SIZE;
700 SAVE_REGS 707 SAVE_REGS
701 /* calculate mode */ 708 /* calculate mode */
702 swi r0, r1, PTO + PT_MODE; 709 swi r0, r1, PT_MODE;
703 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 710 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP));
704 swi r11, r1, PTO+PT_R1; 711 swi r11, r1, PT_R1;
705 clear_ums; 712 clear_ums;
7062: 7132:
707 lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 714 lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE));
708 tovirt(r1,r1) 715 tovirt(r1,r1)
709 addik r15, r0, irq_call; 716 addik r15, r0, irq_call;
710irq_call:rtbd r0, do_IRQ; 717irq_call:rtbd r0, do_IRQ;
711 addik r5, r1, PTO; 718 addik r5, r1, 0;
712 719
713/* MS: we are in virtual mode */ 720/* MS: we are in virtual mode */
714ret_from_irq: 721ret_from_irq:
715 lwi r11, r1, PTO + PT_MODE; 722 lwi r11, r1, PT_MODE;
716 bnei r11, 2f; 723 bnei r11, 2f;
717 724
718 lwi r11, CURRENT_TASK, TS_THREAD_INFO; 725 lwi r11, CURRENT_TASK, TS_THREAD_INFO;
@@ -729,7 +736,7 @@ ret_from_irq:
729 beqid r11, no_intr_resched 736 beqid r11, no_intr_resched
730/* Handle a signal return; Pending signals should be in r18. */ 737/* Handle a signal return; Pending signals should be in r18. */
731 addi r7, r0, 0; /* Arg 3: int in_syscall */ 738 addi r7, r0, 0; /* Arg 3: int in_syscall */
732 addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 739 addik r5, r1, 0; /* Arg 1: struct pt_regs *regs */
733 bralid r15, do_signal; /* Handle any signals */ 740 bralid r15, do_signal; /* Handle any signals */
734 add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 741 add r6, r0, r0; /* Arg 2: sigset_t *oldset */
735 742
@@ -741,7 +748,7 @@ no_intr_resched:
741 VM_OFF; 748 VM_OFF;
742 tophys(r1,r1); 749 tophys(r1,r1);
743 RESTORE_REGS 750 RESTORE_REGS
744 addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ 751 addik r1, r1, PT_SIZE /* MS: Clean up stack space. */
745 lwi r1, r1, PT_R1 - PT_SIZE; 752 lwi r1, r1, PT_R1 - PT_SIZE;
746 bri 6f; 753 bri 6f;
747/* MS: Return to kernel state. */ 754/* MS: Return to kernel state. */
@@ -769,7 +776,7 @@ restore:
769 VM_OFF /* MS: turn off MMU */ 776 VM_OFF /* MS: turn off MMU */
770 tophys(r1,r1) 777 tophys(r1,r1)
771 RESTORE_REGS 778 RESTORE_REGS
772 addik r1, r1, STATE_SAVE_SIZE /* MS: Clean up stack space. */ 779 addik r1, r1, PT_SIZE /* MS: Clean up stack space. */
773 tovirt(r1,r1); 780 tovirt(r1,r1);
7746: 7816:
775IRQ_return: /* MS: Make global symbol for debugging */ 782IRQ_return: /* MS: Make global symbol for debugging */
@@ -792,29 +799,29 @@ C_ENTRY(_debug_exception):
792 lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* Reload kernel stack-ptr*/ 799 lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* Reload kernel stack-ptr*/
793 800
794 /* BIP bit is set on entry, no interrupts can occur */ 801 /* BIP bit is set on entry, no interrupts can occur */
795 addik r1, r1, CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - STATE_SAVE_SIZE; 802 addik r1, r1, CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - PT_SIZE;
796 SAVE_REGS; 803 SAVE_REGS;
797 /* save all regs to pt_reg structure */ 804 /* save all regs to pt_reg structure */
798 swi r0, r1, PTO+PT_R0; /* R0 must be saved too */ 805 swi r0, r1, PT_R0; /* R0 must be saved too */
799 swi r14, r1, PTO+PT_R14 /* rewrite saved R14 value */ 806 swi r14, r1, PT_R14 /* rewrite saved R14 value */
800 swi r16, r1, PTO+PT_PC; /* PC and r16 are the same */ 807 swi r16, r1, PT_PC; /* PC and r16 are the same */
801 /* save special purpose registers to pt_regs */ 808 /* save special purpose registers to pt_regs */
802 mfs r11, rear; 809 mfs r11, rear;
803 swi r11, r1, PTO+PT_EAR; 810 swi r11, r1, PT_EAR;
804 mfs r11, resr; 811 mfs r11, resr;
805 swi r11, r1, PTO+PT_ESR; 812 swi r11, r1, PT_ESR;
806 mfs r11, rfsr; 813 mfs r11, rfsr;
807 swi r11, r1, PTO+PT_FSR; 814 swi r11, r1, PT_FSR;
808 815
809 /* stack pointer is in physical address at it is decrease 816 /* stack pointer is in physical address at it is decrease
810 * by STATE_SAVE_SIZE but we need to get correct R1 value */ 817 * by PT_SIZE but we need to get correct R1 value */
811 addik r11, r1, CONFIG_KERNEL_START - CONFIG_KERNEL_BASE_ADDR + STATE_SAVE_SIZE; 818 addik r11, r1, CONFIG_KERNEL_START - CONFIG_KERNEL_BASE_ADDR + PT_SIZE;
812 swi r11, r1, PTO+PT_R1 819 swi r11, r1, PT_R1
813 /* MS: r31 - current pointer isn't changed */ 820 /* MS: r31 - current pointer isn't changed */
814 tovirt(r1,r1) 821 tovirt(r1,r1)
815#ifdef CONFIG_KGDB 822#ifdef CONFIG_KGDB
816 addi r5, r1, PTO /* pass pt_reg address as the first arg */ 823 addi r5, r1, 0 /* pass pt_reg address as the first arg */
817 la r15, r0, dbtrap_call; /* return address */ 824 addik r15, r0, dbtrap_call; /* return address */
818 rtbd r0, microblaze_kgdb_break 825 rtbd r0, microblaze_kgdb_break
819 nop; 826 nop;
820#endif 827#endif
@@ -829,16 +836,16 @@ C_ENTRY(_debug_exception):
829 addik r1, r1, THREAD_SIZE; /* calculate kernel stack pointer */ 836 addik r1, r1, THREAD_SIZE; /* calculate kernel stack pointer */
830 tophys(r1,r1); 837 tophys(r1,r1);
831 838
832 addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 839 addik r1, r1, -PT_SIZE; /* Make room on the stack. */
833 SAVE_REGS; 840 SAVE_REGS;
834 swi r16, r1, PTO+PT_PC; /* Save LP */ 841 swi r16, r1, PT_PC; /* Save LP */
835 swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ 842 swi r0, r1, PT_MODE; /* Was in user-mode. */
836 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 843 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP));
837 swi r11, r1, PTO+PT_R1; /* Store user SP. */ 844 swi r11, r1, PT_R1; /* Store user SP. */
838 lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); 845 lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE));
839 tovirt(r1,r1) 846 tovirt(r1,r1)
840 set_vms; 847 set_vms;
841 addik r5, r1, PTO; 848 addik r5, r1, 0;
842 addik r15, r0, dbtrap_call; 849 addik r15, r0, dbtrap_call;
843dbtrap_call: /* Return point for kernel/user entry + 8 because of rtsd r15, 8 */ 850dbtrap_call: /* Return point for kernel/user entry + 8 because of rtsd r15, 8 */
844 rtbd r0, sw_exception 851 rtbd r0, sw_exception
@@ -846,7 +853,7 @@ dbtrap_call: /* Return point for kernel/user entry + 8 because of rtsd r15, 8 */
846 853
847 /* MS: The first instruction for the second part of the gdb/kgdb */ 854 /* MS: The first instruction for the second part of the gdb/kgdb */
848 set_bip; /* Ints masked for state restore */ 855 set_bip; /* Ints masked for state restore */
849 lwi r11, r1, PTO + PT_MODE; 856 lwi r11, r1, PT_MODE;
850 bnei r11, 2f; 857 bnei r11, 2f;
851/* MS: Return to user space - gdb */ 858/* MS: Return to user space - gdb */
852 /* Get current task ptr into r11 */ 859 /* Get current task ptr into r11 */
@@ -865,7 +872,7 @@ dbtrap_call: /* Return point for kernel/user entry + 8 because of rtsd r15, 8 */
865 andi r11, r11, _TIF_SIGPENDING; 872 andi r11, r11, _TIF_SIGPENDING;
866 beqi r11, 1f; /* Signals to handle, handle them */ 873 beqi r11, 1f; /* Signals to handle, handle them */
867 874
868 addik r5, r1, PTO; /* Arg 1: struct pt_regs *regs */ 875 addik r5, r1, 0; /* Arg 1: struct pt_regs *regs */
869 addi r7, r0, 0; /* Arg 3: int in_syscall */ 876 addi r7, r0, 0; /* Arg 3: int in_syscall */
870 bralid r15, do_signal; /* Handle any signals */ 877 bralid r15, do_signal; /* Handle any signals */
871 add r6, r0, r0; /* Arg 2: sigset_t *oldset */ 878 add r6, r0, r0; /* Arg 2: sigset_t *oldset */
@@ -876,7 +883,7 @@ dbtrap_call: /* Return point for kernel/user entry + 8 because of rtsd r15, 8 */
876 tophys(r1,r1); 883 tophys(r1,r1);
877 /* MS: Restore all regs */ 884 /* MS: Restore all regs */
878 RESTORE_REGS 885 RESTORE_REGS
879 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space */ 886 addik r1, r1, PT_SIZE /* Clean up stack space */
880 lwi r1, r1, PT_R1 - PT_SIZE; /* Restore user stack pointer */ 887 lwi r1, r1, PT_R1 - PT_SIZE; /* Restore user stack pointer */
881DBTRAP_return_user: /* MS: Make global symbol for debugging */ 888DBTRAP_return_user: /* MS: Make global symbol for debugging */
882 rtbd r16, 0; /* MS: Instructions to return from a debug trap */ 889 rtbd r16, 0; /* MS: Instructions to return from a debug trap */
@@ -887,9 +894,9 @@ DBTRAP_return_user: /* MS: Make global symbol for debugging */
887 tophys(r1,r1); 894 tophys(r1,r1);
888 /* MS: Restore all regs */ 895 /* MS: Restore all regs */
889 RESTORE_REGS 896 RESTORE_REGS
890 lwi r14, r1, PTO+PT_R14; 897 lwi r14, r1, PT_R14;
891 lwi r16, r1, PTO+PT_PC; 898 lwi r16, r1, PT_PC;
892 addik r1, r1, STATE_SAVE_SIZE; /* MS: Clean up stack space */ 899 addik r1, r1, PT_SIZE; /* MS: Clean up stack space */
893 tovirt(r1,r1); 900 tovirt(r1,r1);
894DBTRAP_return_kernel: /* MS: Make global symbol for debugging */ 901DBTRAP_return_kernel: /* MS: Make global symbol for debugging */
895 rtbd r16, 0; /* MS: Instructions to return from a debug trap */ 902 rtbd r16, 0; /* MS: Instructions to return from a debug trap */
@@ -981,20 +988,22 @@ ENTRY(_switch_to)
981 nop 988 nop
982 989
983ENTRY(_reset) 990ENTRY(_reset)
984 brai 0x70; /* Jump back to FS-boot */ 991 brai 0; /* Jump to reset vector */
985 992
986 /* These are compiled and loaded into high memory, then 993 /* These are compiled and loaded into high memory, then
987 * copied into place in mach_early_setup */ 994 * copied into place in mach_early_setup */
988 .section .init.ivt, "ax" 995 .section .init.ivt, "ax"
996#if CONFIG_MANUAL_RESET_VECTOR
989 .org 0x0 997 .org 0x0
990 /* this is very important - here is the reset vector */ 998 brai CONFIG_MANUAL_RESET_VECTOR
991 /* in current MMU branch you don't care what is here - it is 999#endif
992 * used from bootloader site - but this is correct for FS-BOOT */ 1000 .org 0x8
993 brai 0x70
994 nop
995 brai TOPHYS(_user_exception); /* syscall handler */ 1001 brai TOPHYS(_user_exception); /* syscall handler */
1002 .org 0x10
996 brai TOPHYS(_interrupt); /* Interrupt handler */ 1003 brai TOPHYS(_interrupt); /* Interrupt handler */
1004 .org 0x18
997 brai TOPHYS(_debug_exception); /* debug trap handler */ 1005 brai TOPHYS(_debug_exception); /* debug trap handler */
1006 .org 0x20
998 brai TOPHYS(_hw_exception_handler); /* HW exception handler */ 1007 brai TOPHYS(_hw_exception_handler); /* HW exception handler */
999 1008
1000.section .rodata,"a" 1009.section .rodata,"a"