From 30feeba96cb4a9d78e5635e7291fcb6146db837d Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Fri, 22 May 2015 22:20:18 +0200 Subject: [PATCH] dragon-nx32: Cruft removal and some cosmetics in tricks.s We don't need to preserve Y because it is properly stacked. Signed-off-by: Tormod Volden --- Kernel/platform-dragon-nx32/tricks.s | 32 +++++++++++----------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/Kernel/platform-dragon-nx32/tricks.s b/Kernel/platform-dragon-nx32/tricks.s index 49bcd506..d678285b 100644 --- a/Kernel/platform-dragon-nx32/tricks.s +++ b/Kernel/platform-dragon-nx32/tricks.s @@ -21,12 +21,12 @@ .globl _dofork .globl _ramtop - include "kernel.def" include "../kernel09.def" .area .common + ; ramtop must be in common although not used here _ramtop: .dw 0 @@ -55,7 +55,6 @@ _switchout: ; Stash the uarea into process memory bank jsr map_process_always - sty _swapstack+2 ldx #U_DATA ldy #U_DATA_STASH @@ -63,37 +62,32 @@ stash ldd ,x++ 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 @@ -101,21 +95,19 @@ _switchin: 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 @@ -124,8 +116,7 @@ stashb ldd ,x++ 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 @@ -160,6 +151,7 @@ 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 @@ -221,9 +213,9 @@ fork_copy: 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 -- 2.34.1