From: Alan Cox Date: Thu, 29 Mar 2018 22:55:49 +0000 (+0100) Subject: platform_switchout X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=15651036a04f0d5f74a585ea6cd11d5a0dc4eca0;p=FUZIX.git platform_switchout Updated everywhere that looks like it needs it --- diff --git a/Kernel/cpu-z180/z180.s b/Kernel/cpu-z180/z180.s index 967ab13b..1ef3971a 100644 --- a/Kernel/cpu-z180/z180.s +++ b/Kernel/cpu-z180/z180.s @@ -25,7 +25,7 @@ .globl _getproc .globl _trap_monitor .globl _switchin - .globl _switchout + .globl _platform_switchout .globl _dofork .globl map_kernel .globl map_process_always @@ -674,13 +674,9 @@ z180_irq_unused: ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; This function can have no arguments or auto variables. -_switchout: - di - call _chksigs +_platform_switchout: + di ; save machine state - ld hl, #0 ; return code set here is ignored, but _switchin can ; return from either _switchout OR _dofork, so they must both write ; U_DATA__U_SP with the following on the stack: diff --git a/Kernel/lib/65c816.s b/Kernel/lib/65c816.s index 4f12020b..1c3b7ff1 100644 --- a/Kernel/lib/65c816.s +++ b/Kernel/lib/65c816.s @@ -6,7 +6,7 @@ .include "../kernel816.def" .include "../platform/zeropage.inc" - .export _switchout + .export _platform_switchout .export _switchin .export _dofork @@ -29,9 +29,8 @@ .i8 .a8 -_switchout: +_platform_switchout: sei - jsr _chksigs rep #$10 ; Index to 16bit .i16 ldx #0 @@ -40,38 +39,6 @@ _switchout: phx tsx stx U_DATA__U_SP - sep #$10 ; Back to 8 for C code - - .i8 - lda _nready - bne slow_path -idling: - cli - jsr _platform_idle - sei - lda _nready - beq idling - cmp #1 - bne slow_path - - rep #$10 - .i16 - ldx U_DATA__U_PTAB - lda a:0,x - cmp #P_READY - bne slow_path - lda #P_RUNNING - sta a:P_TAB__P_STATUS_OFFSET,x - plx - stx sp - plx ; discard 0 - sep #$30 - ; Get back into the way C expects us - .i8 - .a8 - cli - rts -slow_path: ; ; Switch of task - save our udata and stack. Note we are ; saving the stack we are executing upon ! diff --git a/Kernel/platform-68hc11test/tricks.s b/Kernel/platform-68hc11test/tricks.s index 2f9be56b..e94cebe7 100644 --- a/Kernel/platform-68hc11test/tricks.s +++ b/Kernel/platform-68hc11test/tricks.s @@ -12,7 +12,7 @@ .globl getproc .globl trap_monitor .globl inint - .globl switchout + .globl platform_switchout .globl switchin .globl dofork .globl ramtop @@ -43,13 +43,11 @@ switchstack: ; restarted after calling switchout, it thinks it has just returned ; from switchout(). ; -; This function can have no arguments or auto variables. ; We have no registers to preserve as the compiler assumes a function call ; clobbers the works. ; -switchout: +platform_switchout: sei - jsr chksigs ; save machine state ldx #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-appleiie/tricks.s b/Kernel/platform-appleiie/tricks.s index 78e0dac9..d5a5f5af 100644 --- a/Kernel/platform-appleiie/tricks.s +++ b/Kernel/platform-appleiie/tricks.s @@ -1,7 +1,7 @@ ; ; 6502 version ; - .export _switchout + .export _platform_switchout .export _switchin .export _dofork .export _ramtop @@ -39,13 +39,9 @@ _ramtop: ; restarted after calling switchout, it thinks it has just returned ; from switchout(). ; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: sei - jsr _chksigs ; ; Put the C stack on the CPU stack, and store that in U_SP ; diff --git a/Kernel/platform-atarist/tricks.S b/Kernel/platform-atarist/tricks.S index 5d1b30be..70d010d8 100644 --- a/Kernel/platform-atarist/tricks.S +++ b/Kernel/platform-atarist/tricks.S @@ -1,7 +1,7 @@ #include "../kernel-68000.def" -.globl _switchout,_switchin,_dofork +.globl _platfomr_switchout,_switchin,_dofork .mri 1 @@ -9,11 +9,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: or #$0700,sr - bsr _chksigs ; save machine state clr.w -(sp) ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-coco2/tricks.s b/Kernel/platform-coco2/tricks.s index bb436180..59749932 100644 --- a/Kernel/platform-coco2/tricks.s +++ b/Kernel/platform-coco2/tricks.s @@ -20,7 +20,7 @@ # exported .globl _switchout - .globl _switchin + .globl _platform_switchin .globl _dofork .globl _ramtop @@ -37,12 +37,8 @@ _ramtop: ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: orcc #0x10 ; irq off - jsr _chksigs ; save machine state, including Y and U used by our C code ldd #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-coco2cart/tricks.s b/Kernel/platform-coco2cart/tricks.s index 8e62a8f0..b5ca7b5c 100644 --- a/Kernel/platform-coco2cart/tricks.s +++ b/Kernel/platform-coco2cart/tricks.s @@ -20,7 +20,7 @@ .globl _platform_idle # exported - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _dofork .globl _ramtop @@ -41,9 +41,8 @@ _ramtop: ; ; ; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: orcc #0x10 ; irq off - jsr _chksigs ; save machine state, including Y and U used by our C code ldd #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-coco3/tricks.s b/Kernel/platform-coco3/tricks.s index e6e14d4f..84c45d14 100644 --- a/Kernel/platform-coco3/tricks.s +++ b/Kernel/platform-coco3/tricks.s @@ -12,7 +12,7 @@ .globl _swap_finish ;; exported - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _dofork .globl _ramtop @@ -40,13 +40,8 @@ fork_proc_ptr: ;;; possibly the same process, and switches it in. When a process is ;;; restarted after calling switchout, it thinks it has just returned ;;; from switchout(). -;;; -;;; FIXME: make sure we optimise the switch to self case higher up the stack! -;;; -;;; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: orcc #0x10 ; irq off - jsr _chksigs ; check for signals ;; save machine state ldd #0 ; return zero diff --git a/Kernel/platform-dragon-nx32/tricks.s b/Kernel/platform-dragon-nx32/tricks.s index 058f7d66..fc50984c 100644 --- a/Kernel/platform-dragon-nx32/tricks.s +++ b/Kernel/platform-dragon-nx32/tricks.s @@ -18,7 +18,7 @@ .globl _platform_idle # exported - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _dofork .globl _ramtop @@ -37,12 +37,8 @@ _ramtop: ; restarted after calling switchout, it thinks it has just returned ; from switchout(). ; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: orcc #0x10 ; irq off - jsr _chksigs ; save machine state, including Y and U used by our C code ldd #0 ; return code set here is ignored, but _switchin can @@ -51,53 +47,6 @@ _switchout: pshs d,y,u sts U_DATA__U_SP ; this is where the SP is restored in _switchin - ; See if we are about to go idle - lda _nready - ; Someone else will run - go the slow path into the scheduler - bne slow_path - - ; - ; Wait for something to become ready - ; -idling: - andcc #0xef - jsr _platform_idle - orcc #0x10 - - lda _nready - beq idling - - ; Did multiple things wake up, if so we must follow the slow - ; path - cmpa #1 - bne slow_path - - ; Was the waker us ? - ldx U_DATA__U_PTAB - lda P_TAB__P_STATUS_OFFSET,x - cmpa #P_READY - ; No: follow the slow path - bne slow_path - - ; We can use the fast path for returning. - ; - ; Mark ourself running with a new time slice allocation - ; - lda #P_RUNNING - sta P_TAB__P_STATUS_OFFSET,x - ldx #0 - stx _runticks - ; - ; We idled and got the CPU back - fast path, and we know - ; we are not a pre-emption. In effect the switchout() becomes - ; a normal function call and we don't have to stash anything or - ; bank switch. - ; - andcc #0xef - puls d,y,u,pc - - -slow_path: ; Stash the uarea into process memory bank jsr map_process_always diff --git a/Kernel/platform-ibmpc/tricks.S b/Kernel/platform-ibmpc/tricks.S index 84fbbee7..a0e4897f 100644 --- a/Kernel/platform-ibmpc/tricks.S +++ b/Kernel/platform-ibmpc/tricks.S @@ -11,7 +11,7 @@ .text .globl switchin - .globl switchout + .globl platform_switchout .globl dofork @@ -68,28 +68,8 @@ fork_copy: /* Called to give up processor time. We will pop out of this in potentially some other process, but we might also come back directly */ -switchout: +platform_switchout: cli - call chksigs - movb nready,%al - cmpb $1,%al - bne slow_path -idling: - sti - call platform_idle - cli - movb nready,%al - cmpb $0,%al - je idling - - /* Ok there is something to run - but is it us ? */ - cmpb $1,%al - jne slow_path - - /* Fast path out */ - ret - -slow_path: xorw %ax,%ax pushw %ax pushw %ei diff --git a/Kernel/platform-micropack/tricks.s b/Kernel/platform-micropack/tricks.s index b789c992..5cd15b09 100644 --- a/Kernel/platform-micropack/tricks.s +++ b/Kernel/platform-micropack/tricks.s @@ -8,7 +8,7 @@ .globl _getproc .globl _trap_monitor .globl trap_illegal - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -34,9 +34,8 @@ ; from switchout(). ; ; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - call _chksigs ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-msp430fr5969/tricks.S b/Kernel/platform-msp430fr5969/tricks.S index 6ff3d596..7db70929 100644 --- a/Kernel/platform-msp430fr5969/tricks.S +++ b/Kernel/platform-msp430fr5969/tricks.S @@ -30,7 +30,7 @@ proc load_overlay ; from switchout(). .globl switchin -proc switchout +proc platform_switchout dint // interrupts off clr r12 // set return code pushm #12, r15 // save all registers (r15 to r4) diff --git a/Kernel/platform-msx1/tricks.s b/Kernel/platform-msx1/tricks.s index 1269ac32..f3b0d73c 100644 --- a/Kernel/platform-msx1/tricks.s +++ b/Kernel/platform-msx1/tricks.s @@ -38,9 +38,8 @@ _ramtop: ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; This function can have no arguments or auto variables. _platform_switchout: + di ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-multicomp09/tricks.s b/Kernel/platform-multicomp09/tricks.s index 811fc9b7..dc719cb1 100644 --- a/Kernel/platform-multicomp09/tricks.s +++ b/Kernel/platform-multicomp09/tricks.s @@ -13,7 +13,7 @@ .globl curr_tr ;; exported - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _dofork .globl _ramtop @@ -41,13 +41,8 @@ fork_proc_ptr: ;;; possibly the same process, and switches it in. When a process is ;;; restarted after calling switchout, it thinks it has just returned ;;; from switchout(). -;;; -;;; FIXME: make sure we optimise the switch to self case higher up the stack! -;;; -;;; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: orcc #0x10 ; irq off - jsr _chksigs ; check for signals ;; save machine state ldd #0 ; return zero diff --git a/Kernel/platform-nc100/tricks.s b/Kernel/platform-nc100/tricks.s index ff1ba23f..079eddb3 100644 --- a/Kernel/platform-nc100/tricks.s +++ b/Kernel/platform-nc100/tricks.s @@ -8,7 +8,7 @@ .globl _getproc .globl _trap_monitor .globl trap_illegal - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -40,12 +40,8 @@ _need_resched: ; restarted after calling switchout, it thinks it has just returned ; from switchout(). ; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; ; This function can have no arguments or auto variables. -_switchout: - di - call _chksigs +_platform_switchout: ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-pcw8256/tricks.s b/Kernel/platform-pcw8256/tricks.s index 9506e20c..cb61b91e 100644 --- a/Kernel/platform-pcw8256/tricks.s +++ b/Kernel/platform-pcw8256/tricks.s @@ -7,7 +7,7 @@ .globl _trap_monitor .globl trap_illegal .globl _inint - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -33,9 +33,8 @@ ; FIXME: make sure we optimise the switch to self case higher up the stack! ; ; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - call _chksigs ; save machine state ld a, #'O' diff --git a/Kernel/platform-pdp11/tricks.S b/Kernel/platform-pdp11/tricks.S index 30521a63..7f3cb365 100644 --- a/Kernel/platform-pdp11/tricks.S +++ b/Kernel/platform-pdp11/tricks.S @@ -6,9 +6,8 @@ .globl _switchout .globl _dofork -_switchout: +_platform_switchout: bis 0340,0177776 - jsr pc,_chksigs clr -(sp) mov r5,-(sp) mov r4,-(sp) diff --git a/Kernel/platform-plus3/tricks.s b/Kernel/platform-plus3/tricks.s index 4744ac15..9033c333 100644 --- a/Kernel/platform-plus3/tricks.s +++ b/Kernel/platform-plus3/tricks.s @@ -13,7 +13,7 @@ .globl _trap_monitor .globl trap_illegal .globl _inint - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -35,13 +35,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - call _chksigs ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-px4plus/tricks.s b/Kernel/platform-px4plus/tricks.s index a6673134..631dc117 100644 --- a/Kernel/platform-px4plus/tricks.s +++ b/Kernel/platform-px4plus/tricks.s @@ -9,7 +9,7 @@ .globl _trap_monitor .globl trap_illegal .globl _inint - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -37,15 +37,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - push af - call _chksigs - pop af ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-socz80/tricks.s b/Kernel/platform-socz80/tricks.s index 04dd0a48..7156db4b 100644 --- a/Kernel/platform-socz80/tricks.s +++ b/Kernel/platform-socz80/tricks.s @@ -10,7 +10,7 @@ .globl _trap_monitor .globl trap_illegal .globl _inint - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _dofork .globl _runticks @@ -40,9 +40,8 @@ ; from switchout(). ; ; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - call _chksigs ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-v65/tricks.s b/Kernel/platform-v65/tricks.s index d55361c2..32e809c9 100644 --- a/Kernel/platform-v65/tricks.s +++ b/Kernel/platform-v65/tricks.s @@ -1,7 +1,7 @@ ; ; 6502 version ; - .export _switchout + .export _platform_switchout .export _switchin .export _dofork .export _ramtop @@ -36,14 +36,9 @@ _ramtop: ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: sei - jsr _chksigs ; ; Put the C stack on the CPU stack, and store that in U_SP ; diff --git a/Kernel/platform-v68-banked/tricks.S b/Kernel/platform-v68-banked/tricks.S index 212bd778..09dd4138 100644 --- a/Kernel/platform-v68-banked/tricks.S +++ b/Kernel/platform-v68-banked/tricks.S @@ -1,7 +1,7 @@ #include "../kernel-68000.def" #include "kernel.def" -.globl switchout,switchin,dofork,udata_shadow,udata_stash +.globl platform_switchout,switchin,dofork,udata_shadow,udata_stash .mri 1 @@ -31,9 +31,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -switchout: +platform_switchout: or #$0700,sr - bsr chksigs ; save machine state clr.w -(sp) ; return code set here is ignored, but switchin can diff --git a/Kernel/platform-v68-softmmu/tricks.S b/Kernel/platform-v68-softmmu/tricks.S index 6b80226e..1790138e 100644 --- a/Kernel/platform-v68-softmmu/tricks.S +++ b/Kernel/platform-v68-softmmu/tricks.S @@ -2,7 +2,7 @@ #include "kernel.def" -.globl switchout,switchin,dofork,udata_shadow +.globl platform_switchout,switchin,dofork,udata_shadow .mri 1 @@ -10,9 +10,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -switchout: +platform_switchout: or #$0700,sr - bsr chksigs ; save machine state clr.w -(sp) ; return code set here is ignored, but switchin can diff --git a/Kernel/platform-v68/tricks.S b/Kernel/platform-v68/tricks.S index 477962dc..bbe20407 100644 --- a/Kernel/platform-v68/tricks.S +++ b/Kernel/platform-v68/tricks.S @@ -1,7 +1,7 @@ #include "../kernel-68000.def" -.globl switchout,switchin,dofork,udata_shadow +.globl platform_switchout,switchin,dofork,udata_shadow .mri 1 @@ -9,11 +9,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; This function can have no arguments or auto variables. -switchout: +platform_switchout: or #$0700,sr - bsr chksigs ; save machine state clr.w -(sp) ; return code set here is ignored, but switchin can diff --git a/Kernel/platform-z80pack-lite/tricks.s b/Kernel/platform-z80pack-lite/tricks.s index 4b7ec31d..703fa476 100644 --- a/Kernel/platform-z80pack-lite/tricks.s +++ b/Kernel/platform-z80pack-lite/tricks.s @@ -8,7 +8,7 @@ .globl _getproc .globl _trap_monitor .globl trap_illegal - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -40,12 +40,8 @@ _ramtop: ; restarted after calling switchout, it thinks it has just returned ; from switchout(). ; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform__switchout: di - call _chksigs ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-z80pack32/tricks.s b/Kernel/platform-z80pack32/tricks.s index 3f70cf3c..3e30fe44 100644 --- a/Kernel/platform-z80pack32/tricks.s +++ b/Kernel/platform-z80pack32/tricks.s @@ -9,7 +9,7 @@ .globl _trap_monitor .globl trap_illegal .globl _inint - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -34,13 +34,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - call _chksigs ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-zeta-v2/tricks.s b/Kernel/platform-zeta-v2/tricks.s index 0502b0da..8939fdf9 100644 --- a/Kernel/platform-zeta-v2/tricks.s +++ b/Kernel/platform-zeta-v2/tricks.s @@ -8,7 +8,7 @@ .globl _getproc .globl _trap_monitor .globl trap_illegal - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _doexec .globl _dofork @@ -40,13 +40,8 @@ _need_resched: ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; FIXME: make sure we optimise the switch to self case higher up the stack! -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - call _chksigs ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/platform-zx128/tricks.s b/Kernel/platform-zx128/tricks.s index 41519b3c..defe921f 100644 --- a/Kernel/platform-zx128/tricks.s +++ b/Kernel/platform-zx128/tricks.s @@ -7,11 +7,10 @@ .globl _ptab_alloc .globl _newproc - .globl _chksigs .globl _getproc .globl _trap_monitor .globl trap_illegal - .globl _switchout + .globl _platform_switchout .globl _switchin .globl _low_bank .globl _dup_low_page @@ -35,13 +34,8 @@ ; possibly the same process, and switches it in. When a process is ; restarted after calling switchout, it thinks it has just returned ; from switchout(). -; -; This function can have no arguments or auto variables. -_switchout: +_platform_switchout: di - push af - call _chksigs - pop af ; save machine state ld hl, #0 ; return code set here is ignored, but _switchin can diff --git a/Kernel/process.c b/Kernel/process.c index e102f549..7c9e6a4a 100644 --- a/Kernel/process.c +++ b/Kernel/process.c @@ -501,6 +501,8 @@ void unix_syscall(void) don't look for optimizations. Likewise we know a signal process will stay running/ready */ platform_switchout(); + /* We will check the signals before we return to user space + so all is good */ } ei(); chksigs();