From: Alan Cox Date: Thu, 3 Nov 2016 23:06:57 +0000 (+0000) Subject: v68-banked: a few more bits of work X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=40a002e6bdc5f92ae3072e6cb536cd32114680fe;p=FUZIX.git v68-banked: a few more bits of work Nothing yet bootable and testable, but slowly filling in the bits --- diff --git a/Kernel/platform-v68-banked/Makefile b/Kernel/platform-v68-banked/Makefile index b6f97c9d..1320914b 100644 --- a/Kernel/platform-v68-banked/Makefile +++ b/Kernel/platform-v68-banked/Makefile @@ -34,7 +34,7 @@ image: $(CROSS_LD) -M -o fuzix.elf -T fuzix.ld \ crt0.o \ p68000.o ../start.o ../version.o ../lowlevel-68000.o \ - tricks.o ../simple.o main.o ../timer.o ../kdata.o devices.o \ + tricks.o ../bankfixed.o main.o ../timer.o ../kdata.o devices.o \ ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \ ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o ../buddy.o \ ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o \ diff --git a/Kernel/platform-v68-banked/README b/Kernel/platform-v68-banked/README index a7e2b645..0ace3875 100644 --- a/Kernel/platform-v68-banked/README +++ b/Kernel/platform-v68-banked/README @@ -5,13 +5,12 @@ style) TODO -- Make bankfixed support 32bit - 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. - Write the bank copy routines (copy needed bits zero rest and optimise) -- Write optimised udata copier ? - +- Write optimised udata copier ? (movem based and reverse ?) +- Save restore bank on interrupt entry/exit diff --git a/Kernel/platform-v68-banked/crt0.S b/Kernel/platform-v68-banked/crt0.S index 9b7796cb..95594de0 100644 --- a/Kernel/platform-v68-banked/crt0.S +++ b/Kernel/platform-v68-banked/crt0.S @@ -27,6 +27,9 @@ wipebss: move.l #udata_block+1016,a7 /* udata global */ move.l #udata_block,a5 + /* ensure we have bank 0 mapped */ + clr.b $00F05000 + /* Launch the OS */ bsr init_early bsr init_hardware bsr fuzix_main diff --git a/Kernel/platform-v68-banked/main.c b/Kernel/platform-v68-banked/main.c index d5f293ee..1426b938 100644 --- a/Kernel/platform-v68-banked/main.c +++ b/Kernel/platform-v68-banked/main.c @@ -22,6 +22,14 @@ void map_init(void) { } +void pagemap_init(void) +{ + pagemap_add(3); + pagemap_add(2); + pagemap_add(1); + pagemap_add(0); /* Used for init */ +} + uaddr_t ramtop; uint8_t need_resched; @@ -61,6 +69,7 @@ arg_t _memfree(void) that has a material cost */ u_block udata_block[PTABSIZE]; +uint16_t irqstack[128]; /* This will belong in the core 68K code once finalized */ diff --git a/Kernel/platform-v68-banked/p68000.S b/Kernel/platform-v68-banked/p68000.S index f06ad0b7..9a8d6fd5 100644 --- a/Kernel/platform-v68-banked/p68000.S +++ b/Kernel/platform-v68-banked/p68000.S @@ -148,31 +148,31 @@ outcharw: devide_read_data: move.l blk_op,a0 move.b 4(a0),d0 - move.b 0x00F05000,d1 - cmp.b d0,#2 - bne motswap - move.b 5(a0),0x00F05000 + move.b $00F05000,d1 + cmp.b #2,d0 + bne notswap + move.b 5(a0),$00F05000 notswap: move.w #255,d0 devide_read_l: move.w $00F01000,(a0)+ dbra d0,devide_read_l - move.b d1,0x00F05000 + move.b d1,$00F05000 rts devide_write_data: move.l blk_op,a0 move.b 4(a0),d0 - move.b 0x00F05000,d1 - cmp.b d0,#2 - bne motswapw - move.b 5(a0),0x00F05000 + move.b $00F05000,d1 + cmp.b #2,d0 + bne notswapw + move.b 5(a0),$00F05000 notswapw: move.w #255,d0 devide_write_l: move.w (a0)+,$00F01000 dbra d0,devide_write_l - move.b d1,0x00F05000 + move.b d1,$00F05000 rts ; diff --git a/Kernel/platform-v68-banked/tricks.S b/Kernel/platform-v68-banked/tricks.S index 1d82a8a5..645257dd 100644 --- a/Kernel/platform-v68-banked/tricks.S +++ b/Kernel/platform-v68-banked/tricks.S @@ -1,7 +1,8 @@ #include "../kernel-68000.def" +#include "kernel.def" -.globl switchout,switchin,dofork,udata_shadow +.globl switchout,switchin,dofork,udata_shadow,udata_stash .mri 1 @@ -34,9 +35,9 @@ idling: cmp.b #1,d0 bne slow_path move.l U_DATA__U_PTAB(a5),a0 - cmp.b #P_READY,P_TAB__P_STATUS(a0) + cmp.b #P_READY,P_TAB__P_STATUS_OFFSET(a0) bne slow_path - mov.b #P_RUNNING,P_TAB_P_STATUS(a0) + mov.b #P_RUNNING,P_TAB__P_STATUS_OFFSET(a0) movem.l (sp)+,a0/a2-a4/a6/d2-d7 addq #2,sp and #$F8FF,sr @@ -67,7 +68,7 @@ switchin: ; We are going to copy over the process stack so use the ; other stack for this ; - lea.l #irqstack+256,sp ; switch stack to copy the udata/stack + lea.l irqstack+256,sp ; switch stack to copy the udata/stack ; ; Now switch task context @@ -112,7 +113,7 @@ skip_copyback: bne switchinfail move.b #P_RUNNING,P_TAB__P_STATUS_OFFSET(a0) - move.w P_TAB__P_PAGE_OFFSET(a0), U_DATA__U_PAGE(a5) + move.w P_TAB__P_PAGE_OFFSET(a0),U_DATA__U_PAGE(a5) ; runticks = 0 clr.w runticks @@ -174,9 +175,10 @@ dofork: movem.l a0/a2-a4/a6/d2-d7,-(sp) ; save state move.l sp,U_DATA__U_SP(a5) ; save pointer + move.l a0,-(sp) ; argument to newproc + jsr bankfork ; copy the memory - move.l a0,-(sp) ; argument to newproc ; Save the udata move.l a5,a0 lea.l udata_stash,a1 @@ -185,7 +187,7 @@ copyf: move.l (a0)+,(a1)+ dbra d0,copyf ; switch memory bank - move.l (s0),a0 + move.l (sp),a0 move.w P_TAB__P_PAGE_OFFSET(a0),d0 move.b d0,$FFF05000 @@ -196,6 +198,23 @@ copyf: move.l (a0)+,(a1)+ moveq #0,d0 ; child rts +bankfork: + ; copy the memory banks over (we copy the lot we should fast copy + ; the actual used low/high chunks and then zero the middle + ; FIXME: TODO + move.l #$02000000,a0 + ; FIXME BANK SWAP + move.l (a0),d0 + ; FIXME BANK SWAP + move.l d0,(a0)+ + cmp.l #$03000000,a0 + bne copyloop + ; FIXME BANK RESTORE + rts + badswitchmsg: ascii "_switchin: FAIL" byte 13,10,0 .even + + +udata_stash equ UDATA_STASH