.globl _dofork
.globl _ramtop
-
include "kernel.def"
include "../kernel09.def"
.area .common
+ ; ramtop must be in common although not used here
_ramtop:
.dw 0
; Stash the uarea into process memory bank
jsr map_process_always
- sty _swapstack+2
ldx #U_DATA
ldy #U_DATA_STASH
std ,y++
cmpx #U_DATA+U_DATA__TOTALSIZE
bne stash
- ldy _swapstack+2
; get process table in
jsr map_kernel
- ; find another process to run (may select this one again) returns it
- ; in X
+ ; find another (or same) process to run, returned in X
jsr _getproc
jsr _switchin
; we should never get here
jsr _trap_monitor
-_swapstack .dw 0
- .dw 0
-
badswitchmsg: .ascii "_switchin: FAIL"
.db 13
.db 10
.db 0
+newpp .dw 0
+
; new process pointer is in X
_switchin:
orcc #0x10 ; irq off
- ;pshs x
- stx _swapstack
- ; get process table - must be in already from switchout
- ; jsr map_kernel
+ stx newpp
+ ; get process table
lda P_TAB__P_PAGE_OFFSET+1,x ; LSB of 16-bit page no
- ; if we are switching to the same process
+ ; check if we are switching to the same process
cmpa U_DATA__U_PAGE+1
beq nostash
cmpa #0
bne not_swapped
jsr _swapper ; void swapper(ptptr p)
- ldx _swapstack
+ ldx newpp
lda P_TAB__P_PAGE_OFFSET+1,x
not_swapped:
jsr map_process_a
; fetch uarea from process memory
- sty _swapstack+2
ldx #U_DATA_STASH
ldy #U_DATA
stashb ldd ,x++
std ,y++
cmpx #U_DATA_STASH+U_DATA__TOTALSIZE
bne stashb
- ldy _swapstack+2
; we have now new stacks so get new stack pointer before any jsr
lds U_DATA__U_SP
jsr map_kernel
nostash:
- ;puls x
- ldx _swapstack
+ ldx newpp
; check u_data->u_ptab matches what we wanted
cmpx U_DATA__U_PTAB
bne switchinfail
jmp _trap_monitor
.area .data
+
fork_proc_ptr: .dw 0 ; (C type is struct p_tab *) -- address of child process p_tab entry
.area .common
lda U_DATA__U_PAGE+1 ; old bank
ldx #0x8000 ; PROGBASE
ldu U_DATA__U_TOP
- jsr copybank ; preserves A,B, clobbers X,U
+ jsr copybank ; preserves A,B, clobbers X,U
-; stash parent urea (including kernel stack)
+; stash parent uarea (including kernel stack)
jsr map_process_a
ldx #U_DATA
ldu #U_DATA_STASH