.globl _getproc
.globl _trap_monitor
.globl _switchin
- .globl _switchout
+ .globl _platform_switchout
.globl _dofork
.globl map_kernel
.globl map_process_always
; 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:
.include "../kernel816.def"
.include "../platform/zeropage.inc"
- .export _switchout
+ .export _platform_switchout
.export _switchin
.export _dofork
.i8
.a8
-_switchout:
+_platform_switchout:
sei
- jsr _chksigs
rep #$10 ; Index to 16bit
.i16
ldx #0
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 !
.globl getproc
.globl trap_monitor
.globl inint
- .globl switchout
+ .globl platform_switchout
.globl switchin
.globl dofork
.globl ramtop
; 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
;
; 6502 version
;
- .export _switchout
+ .export _platform_switchout
.export _switchin
.export _dofork
.export _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
;
#include "../kernel-68000.def"
-.globl _switchout,_switchin,_dofork
+.globl _platfomr_switchout,_switchin,_dofork
.mri 1
; 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
# exported
.globl _switchout
- .globl _switchin
+ .globl _platform_switchin
.globl _dofork
.globl _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
.globl _platform_idle
# exported
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _dofork
.globl _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
.globl _swap_finish
;; exported
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _dofork
.globl _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:
orcc #0x10 ; irq off
- jsr _chksigs ; check for signals
;; save machine state
ldd #0 ; return zero
.globl _platform_idle
# exported
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _dofork
.globl _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
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
.text
.globl switchin
- .globl switchout
+ .globl platform_switchout
.globl dofork
/* 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
.globl _getproc
.globl _trap_monitor
.globl trap_illegal
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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
; 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)
; 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
.globl curr_tr
;; exported
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _dofork
.globl _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:
orcc #0x10 ; irq off
- jsr _chksigs ; check for signals
;; save machine state
ldd #0 ; return zero
.globl _getproc
.globl _trap_monitor
.globl trap_illegal
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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
.globl _trap_monitor
.globl trap_illegal
.globl _inint
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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'
.globl _switchout
.globl _dofork
-_switchout:
+_platform_switchout:
bis 0340,0177776
- jsr pc,_chksigs
clr -(sp)
mov r5,-(sp)
mov r4,-(sp)
.globl _trap_monitor
.globl trap_illegal
.globl _inint
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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
.globl _trap_monitor
.globl trap_illegal
.globl _inint
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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
.globl _trap_monitor
.globl trap_illegal
.globl _inint
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _dofork
.globl _runticks
; 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
;
; 6502 version
;
- .export _switchout
+ .export _platform_switchout
.export _switchin
.export _dofork
.export _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
;
#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
; 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
#include "kernel.def"
-.globl switchout,switchin,dofork,udata_shadow
+.globl platform_switchout,switchin,dofork,udata_shadow
.mri 1
; 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
#include "../kernel-68000.def"
-.globl switchout,switchin,dofork,udata_shadow
+.globl platform_switchout,switchin,dofork,udata_shadow
.mri 1
; 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
.globl _getproc
.globl _trap_monitor
.globl trap_illegal
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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
.globl _trap_monitor
.globl trap_illegal
.globl _inint
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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
.globl _getproc
.globl _trap_monitor
.globl trap_illegal
- .globl _switchout
+ .globl _platform_switchout
.globl _switchin
.globl _doexec
.globl _dofork
; 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
.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
; 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
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();