From: Alan Cox Date: Sat, 3 Dec 2016 21:43:29 +0000 (+0000) Subject: coco2cart: fix swapping logic X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b123340763b39b2659b17b972b7f9e6a5d7a0e44;p=FUZIX.git coco2cart: fix swapping logic --- diff --git a/Kernel/platform-coco2cart/config.h b/Kernel/platform-coco2cart/config.h index 36d52b06..eaa33ce5 100644 --- a/Kernel/platform-coco2cart/config.h +++ b/Kernel/platform-coco2cart/config.h @@ -17,7 +17,7 @@ /* And swapping */ #define SWAPDEV 0x0 /* Uses part of IDE slice 0 */ #define SWAP_SIZE 0x40 /* 32K in 512 byte blocks */ -#define SWAPBASE 0x8000 /* We swap the lot, including stashed uarea */ +#define SWAPBASE 0x8000 /* We swap the lot */ #define SWAPTOP 0xFE00 /* so it's a round number of 512 byte sectors */ #define UDATA_SIZE 0x0200 /* one block */ #define MAX_SWAPS 32 @@ -45,7 +45,7 @@ extern unsigned char vt_mangle_6847(unsigned char c); #define TICKSPERSEC 50 /* Ticks per second */ #define PROGBASE 0x8000 /* also data base */ #define PROGLOAD 0x8000 /* also data base */ -#define PROGTOP 0xF000 /* Top of program */ +#define PROGTOP 0xFE00 /* Top of program */ /* We need a tidier way to do this from the loader */ #define CMDLINE NULL /* Location of root dev name */ diff --git a/Kernel/platform-coco2cart/tricks.s b/Kernel/platform-coco2cart/tricks.s index bb436180..e2e3475b 100644 --- a/Kernel/platform-coco2cart/tricks.s +++ b/Kernel/platform-coco2cart/tricks.s @@ -75,10 +75,19 @@ _switchin: cmpa #0 bne not_swapped - jsr _swapper ; void swapper(ptptr p) + ldx U_DATA__U_PTAB + ldx P_TAB__P_PAGE_OFFSET+1,x + beq not_swapout ; it's dead don't swap it out + ldx U_DATA__U_PTAB + jsr _swapout ; swapout(pptr) +not_swapout: + lds #$0100 ; FIXME: need to use something else + ; when we enable IRQ during this !! ldx newpp - lda P_TAB__P_PAGE_OFFSET+1,x - + jsr _swapper ; fetch our process + ldx newpp + lda #1 + sta P_TAB__P_PAGE_OFFSET+1,x ; marked paged in not_swapped: ; we have now new stacks so get new stack pointer before any jsr lds U_DATA__U_SP @@ -154,14 +163,14 @@ _dofork: ldx U_DATA__U_PTAB jsr _swapout - cmpd #0 + ; now the copy operation is complete we can get rid of the stuff + ; _switchin will be expecting from our copy of the stack. + cmpx #0 bne forked_up + puls x ; We are now in the kernel child context - ; now the copy operation is complete we can get rid of the stuff - ; _switchin will be expecting from our copy of the stack. - puls x ldx fork_proc_ptr jsr _newproc @@ -177,7 +186,8 @@ _dofork: ; to be the live uarea. The parent is frozen in time and space as ; if it had done a switchout(). puls y,u,pc - -forked_up: ; d is already -1 +forked_up: + puls x + ldx #0 puls y,u,pc - rts \ No newline at end of file +