v68-banked: Get us to the point things work if we don't swap.
authorAlan Cox <alan@linux.intel.com>
Sun, 21 May 2017 20:35:16 +0000 (21:35 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 21 May 2017 20:35:16 +0000 (21:35 +0100)
If we do swap it breaks. Not yet sure why.

Kernel/platform-v68-banked/README
Kernel/platform-v68-banked/config.h
Kernel/platform-v68-banked/main.c
Kernel/platform-v68-banked/tricks.S

index 0ace387..fcd8aed 100644 (file)
@@ -1,16 +1,26 @@
 See platform-v68
 
 This is a test tree for a configuration using banked memory (N8VEM 680x0
-style)
+style). In this configuration we place the kernel in the low 64K of the
+emulator space (protected), and we put the applications and the udata stash
+in each bank. This allows us to keep the kernel protected. We'd have far
+faster task switch if we kept udata banks all in the kernel and moved a5
+(plus did fork differently) but would then lose the 64K protection.
 
+We simulate 4 banks of 128K plus swap.
 
 TODO
+
+- Debug swap (swap out works, swap in fails)
+
 - Make bankfixed support only writing out used areas of memory
 
-Look at bankfixed/bankfixed32 split - put the smarts in bankfixed32 and then
-look at a proper swap allocator so we don't waste tons of memory.
+- Make fork copy only the needed bits
+
+Look at a bankfixed/bankfixed32 split - put the smarts in bankfixed32 and then
+look at a proper swap allocator so we don't waste tons of memory with big
+banks.
 
-- Write the bank copy routines (copy needed bits zero rest and optimise)
 - Write optimised udata copier ? (movem based and reverse ?)
 
 - Save restore bank on interrupt entry/exit
index 373c509..3f665f9 100644 (file)
 #define CONFIG_BANK_FIXED
 #define MAX_MAPS       4
 #define MAPBASE                0x00200000
-#define MAP_SIZE       0x00100000
+#define MAP_SIZE       0x00020000
 
 #define CONFIG_BANKS   1
-#define PROC_SIZE      MAP_SIZE                        /* 1MB */
+#define PROC_SIZE      MAP_SIZE                        /* 128K */
 
 #define CONFIG_SPLIT_UDATA
 #define UDATA_SIZE     1024
@@ -28,8 +28,8 @@
 #define SWAP_SIZE      ((MAP_SIZE/512) + 2)            /* 2 for the udata */
 #define SWAPBASE       PROGBASE
 #define SWAPTOP                PROGTOP
-#define MAX_SWAPS      3                               /* So can reuse the same fs */
-                                                        /* Use a bigger swap area for real uses ! */
+#define MAX_SWAPS      16
+
 #define swap_map(x)    ((uint8_t *)(x))
 
 #define SWAPDEV                (1)
index 451869c..d791689 100644 (file)
@@ -24,10 +24,14 @@ void map_init(void)
 
 void pagemap_init(void)
 {
+       /* 0 means swapped */
+       /* We number 1-4 and reply on the hardware wrapping to 0,3,2,1...
+          in the more general case if you use 0 then you need to invent
+          it */
        pagemap_add(3);
        pagemap_add(2);
        pagemap_add(1);
-       pagemap_add(0); /* Used for init */
+       pagemap_add(4);
 }
 
 uaddr_t ramtop;
index 6018ca4..0a5a96a 100644 (file)
@@ -197,8 +197,8 @@ dofork:
        ; parent state is valid
        ;
        move.w P_TAB__P_PID_OFFSET(a0),-(sp)    ;       child pid (parent return)
-       move.l usp,a0
-       movem.l a0/a2-a4/a6/d2-d7,-(sp) ;       save state
+       move.l usp,a1
+       movem.l a1-a4/a6/d2-d7,-(sp)    ;       save state
        move.l sp,U_DATA__U_SP(a5)      ;       save pointer
        ;
        ; At this point we can make a copy of the parent udata into the
@@ -231,7 +231,7 @@ copyif:     move.l (a1)+,(a0)+
        ;       We enter this on the child's mappings with its udata
        ;
        jsr newproc                     ;       Called with the child udata
-       add.w #54,sp                    ;       toss the stack frames
+       add.w #50,sp                    ;       toss the stack frames
 
        clr.w runticks
        moveq #0,d0                     ;       child
@@ -252,10 +252,10 @@ bankfork:
 
 copyloop:
        move.b d1,$FFF05000             ;       parent bank
-       move.l (a0),d0
-       move.b d2,$FFF05000             ;       child bank
-       move.l d0,(a0)+
-       cmp.l #$00300000,a0
+       move.l (a0),d2
+       move.b d0,$FFF05000             ;       child bank
+       move.l d2,(a0)+
+       cmp.l #$00220000,a0
        bne copyloop
        ; Return with child bank paged as we want it
        move.l (sp)+,d2                 ;       we swapped stack but copied d2