From 536665b3edc27846fe53561627cfac708530fbb7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 4 Dec 2016 13:46:42 +0000 Subject: [PATCH] coco2cart: introduce swap enabled single process model With the small core changes the 6809 banked ports can now swap while the interrupts are enabled. This relies upon the fact the vectors are always mapped so while not too hard on 6809 and 6502 the Z80 ports where the low 256 bytes are both IRQ vectors and part of the user map will probably need a bit more work. --- Kernel/platform-coco2cart/README | 4 ++-- Kernel/platform-coco2cart/tricks.s | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Kernel/platform-coco2cart/README b/Kernel/platform-coco2cart/README index f6962ef8..6c060952 100644 --- a/Kernel/platform-coco2cart/README +++ b/Kernel/platform-coco2cart/README @@ -15,7 +15,7 @@ Memory Map User View ========= 0000-00FF Interrupt stack -0100-01FF Vectors (then wasted - could hide libc.o in there ?) +0100-01FF Vectors plus the swap stack 0200-19FF Display 1A00-1BFF udata/stack 1C00-7FFF Common, data and some kernel code @@ -26,7 +26,7 @@ FF00-FFFF I/O etc Kernel Mode View ================ 0000-00FF Interrupt stack -0100-01FF Vectors +0100-01FF Vectors plus swap stack 0200-19FF Display 1A00-1BFF udata/stack 1C00-7FFF Common, data and some kernel code diff --git a/Kernel/platform-coco2cart/tricks.s b/Kernel/platform-coco2cart/tricks.s index e2e3475b..8e62a8f0 100644 --- a/Kernel/platform-coco2cart/tricks.s +++ b/Kernel/platform-coco2cart/tricks.s @@ -16,6 +16,7 @@ .globl map_process_always .globl copybank .globl _nready + .globl _inswap .globl _platform_idle # exported @@ -70,25 +71,31 @@ _switchin: orcc #0x10 ; irq off stx newpp + inc _inswap ; get process table lda P_TAB__P_PAGE_OFFSET+1,x ; LSB of 16-bit page no cmpa #0 bne not_swapped + + lds #$0200 ; $1xx is vectors and swap stack + 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 + andcc #0xef jsr _swapout ; swapout(pptr) not_swapout: - lds #$0100 ; FIXME: need to use something else - ; when we enable IRQ during this !! ldx newpp + andcc #0xef jsr _swapper ; fetch our process ldx newpp lda #1 sta P_TAB__P_PAGE_OFFSET+1,x ; marked paged in not_swapped: + orcc #0x10 + dec _inswap ; we have now new stacks so get new stack pointer before any jsr lds U_DATA__U_SP @@ -162,7 +169,18 @@ _dofork: ; process. ldx U_DATA__U_PTAB + ; + ; FIXME: review what is needed for IRQ safety here before we turn + ; on IRQs during the swapout + ; + inc _inswap + lds #$0200 ; Use the swap stack + andcc #0xef jsr _swapout + orcc #0x10 + dec _inswap + lds U_DATA__U_SP + ; 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 -- 2.34.1