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>
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
;
__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