coco2cart: fix swapping logic
authorAlan Cox <alan@linux.intel.com>
Sat, 3 Dec 2016 21:43:29 +0000 (21:43 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 3 Dec 2016 21:43:29 +0000 (21:43 +0000)
Kernel/platform-coco2cart/config.h
Kernel/platform-coco2cart/tricks.s

index 36d52b0..eaa33ce 100644 (file)
@@ -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 */
index bb43618..e2e3475 100644 (file)
@@ -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
+