From da1f14ee2fb7d9162e91c53233b68deab3c536dd Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 21 May 2017 21:35:16 +0100 Subject: [PATCH] v68-banked: Get us to the point things work if we don't swap. If we do swap it breaks. Not yet sure why. --- Kernel/platform-v68-banked/README | 18 ++++++++++++++---- Kernel/platform-v68-banked/config.h | 8 ++++---- Kernel/platform-v68-banked/main.c | 6 +++++- Kernel/platform-v68-banked/tricks.S | 14 +++++++------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/Kernel/platform-v68-banked/README b/Kernel/platform-v68-banked/README index 0ace3875..fcd8aede 100644 --- a/Kernel/platform-v68-banked/README +++ b/Kernel/platform-v68-banked/README @@ -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 diff --git a/Kernel/platform-v68-banked/config.h b/Kernel/platform-v68-banked/config.h index 373c5097..3f665f90 100644 --- a/Kernel/platform-v68-banked/config.h +++ b/Kernel/platform-v68-banked/config.h @@ -14,10 +14,10 @@ #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) diff --git a/Kernel/platform-v68-banked/main.c b/Kernel/platform-v68-banked/main.c index 451869c7..d791689a 100644 --- a/Kernel/platform-v68-banked/main.c +++ b/Kernel/platform-v68-banked/main.c @@ -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; diff --git a/Kernel/platform-v68-banked/tricks.S b/Kernel/platform-v68-banked/tricks.S index 6018ca4f..0a5a96a4 100644 --- a/Kernel/platform-v68-banked/tricks.S +++ b/Kernel/platform-v68-banked/tricks.S @@ -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 -- 2.34.1