aboutsummaryrefslogtreecommitdiffstats
path: root/arch/score/kernel/entry.S
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2009-06-19 05:31:54 -0400
committerArnd Bergmann <arnd@arndb.de>2009-06-19 08:10:33 -0400
commitf673c032ed13ed8f3fda5922c2190da2892398bc (patch)
tree8e1145ed21188c77ffdfacba2b22a529c8ddb938 /arch/score/kernel/entry.S
parent78229db4c4f78f27ecf772fe7489a70530ba9862 (diff)
score: add generic sys_call_table
This adds back a sys_call_table to the score architecture, which got lost in the conversion to the generic unistd.h file. It's rather worrying that the code got submitted without a system call table, which evidently means that it got zero testing. Since the system call table has a different layout from the old one (which was modeled after the mips-o32 one), I also try to fix the entry.S path to use it. In the modified calling conventions, all system call arguments are passed as registers r4 through r9, instead of r4 through r7 plus stack for the fifth and sixth argument. This matches what other architectures to when they normally pass arguments on the stack. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/score/kernel/entry.S')
-rw-r--r--arch/score/kernel/entry.S47
1 files changed, 3 insertions, 44 deletions
diff --git a/arch/score/kernel/entry.S b/arch/score/kernel/entry.S
index 0af89b2f16b..2f169175bbd 100644
--- a/arch/score/kernel/entry.S
+++ b/arch/score/kernel/entry.S
@@ -400,6 +400,8 @@ ENTRY(handle_sys)
400 sw r4, [r0, PT_ORIG_R4] #for restart syscall 400 sw r4, [r0, PT_ORIG_R4] #for restart syscall
401 sw r7, [r0, PT_ORIG_R7] #for restart syscall 401 sw r7, [r0, PT_ORIG_R7] #for restart syscall
402 sw r27, [r0, PT_IS_SYSCALL] # it from syscall 402 sw r27, [r0, PT_IS_SYSCALL] # it from syscall
403 sw r8, [r0, 16] # argument 5 from user r8
404 sw r9, [r0, 20] # argument 6 from user r9
403 405
404 lw r9, [r0, PT_EPC] # skip syscall on return 406 lw r9, [r0, PT_EPC] # skip syscall on return
405 addi r9, 4 407 addi r9, 4
@@ -408,19 +410,14 @@ ENTRY(handle_sys)
408 cmpi.c r27, __NR_syscalls # check syscall number 410 cmpi.c r27, __NR_syscalls # check syscall number
409 bgtu illegal_syscall 411 bgtu illegal_syscall
410 412
411 slli r8, r27, 3 # get syscall routine 413 slli r8, r27, 2 # get syscall routine
412 la r11, sys_call_table 414 la r11, sys_call_table
413 add r11, r11, r8 415 add r11, r11, r8
414 lw r10, [r11] # get syscall entry 416 lw r10, [r11] # get syscall entry
415 lw r11, [r11, 4] # get number of args
416 417
417 cmpz.c r10 418 cmpz.c r10
418 beq illegal_syscall 419 beq illegal_syscall
419 420
420 cmpi.c r11, 4 # more than 4 arguments?
421 bgtu stackargs
422
423stack_done:
424 lw r8, [r28, TI_FLAGS] 421 lw r8, [r28, TI_FLAGS]
425 li r9, _TIF_SYSCALL_TRACE 422 li r9, _TIF_SYSCALL_TRACE
426 and.c r8, r8, r9 423 and.c r8, r8, r9
@@ -475,44 +472,6 @@ syscall_trace_entry:
4751: sw r4, [r0, PT_R2] # result 4721: sw r4, [r0, PT_R2] # result
476 j syscall_exit 473 j syscall_exit
477 474
478stackargs:
479 lw r8, [r0, PT_R0]
480 andri.c r9, r8, 3 # test whether user sp is align a word
481 bne bad_stack
482 subi r11, 5
483 slli r9, r11, 2
484 add.c r9, r9, r8
485
486 bmi bad_stack
487 la r9, 3f # calculate branch address
488 slli r11, r11, 3
489 sub r9, r9, r11
490 br r9
491
4922: lw r9, [r8, 20] # argument 6 from usp
493 sw r9, [r0, 20]
494
4953: lw r9, [r8, 16] # argument 5 from usp
496 sw r9, [r0, 16]
497 j stack_done
498
499 .section __ex_table,"a"
500 .word 2b, bad_stack
501 .word 3b, bad_stack
502 .previous
503
504 /*
505 * The stackpointer for a call with more than 4 arguments is bad.
506 * We probably should handle this case a bit more drastic.
507 */
508bad_stack:
509 neg r27, r27 # error
510 sw r27, [r0, PT_ORIG_R4]
511 sw r27, [r0, PT_R4]
512 ldi r8, 1 # set error flag
513 sw r8, [r0, PT_R7]
514 j syscall_return
515
516illegal_syscall: 475illegal_syscall:
517 ldi r4, -ENOSYS # error 476 ldi r4, -ENOSYS # error
518 sw r4, [r0, PT_ORIG_R4] 477 sw r4, [r0, PT_ORIG_R4]