lowlevel-6809: Do not clobber CC on syscall SWI exit
authorTormod Volden <debian.tormod@gmail.com>
Sun, 17 May 2015 16:38:34 +0000 (18:38 +0200)
committerAlan Cox <alan@linux.intel.com>
Mon, 18 May 2015 13:03:33 +0000 (14:03 +0100)
In particular the interrupt masks were overwritten and in some
cases interrupts were disabled after returning from a syscall.

Rewrite the SWI interface to only report error through D and X.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Kernel/lowlevel-6809.s
Library/libs/fuzix6809/syscall6809.s

index 899b20d..a4d8ace 100644 (file)
@@ -140,14 +140,11 @@ unix_syscall_entry:
 not_error:
         ; no error to signal! return syscall return value instead of error code
         ldx U_DATA__U_RETVAL
-       ldd #0          ; just for setting Z flag
 unix_return:
        ; we never make a syscall from in kernel space
        SAM_USER
        stx 4,s         ; replace stacked values before rti
        std 1,s
-       tfr cc,a        ; Z determined by D
-       sta ,s          ; replace stacked CC to signal error
        rti
 
 ;
index 0f284d3..5510042 100644 (file)
@@ -6,19 +6,20 @@
 
 __syscall:
        swi
-       bne     error
-       rts
-error:
-       std     _errno          ; X is -1
+       cmpd #0                 ; D holds errno, if any
+       beq @noerr
+       std _errno              ; X is -1 in this case
+@noerr:
        rts
 
 ; for variadic functions:
 ; compensate for the 1st argument that we removed
 __syscall_mangled:
        swi
-       beq     noerr
-       std     _errno
-noerr:
+       cmpd #0
+       beq @noerr
+       std _errno
+@noerr:
        puls d          ; get return address
-       pshs d,x        ; inject a word on stack
+       pshs d,x        ; inject a word on stack, e.g. X
        rts