DSRCS = ../dev/z80pack/devlpr.c ../dev/z80pack/devfd.c
-CSRCS = devices.c main.c devtty.c syscall_bank.c
+CSRCS = devices.c main.c devtty.c
+CBSRCS = syscall_bank.c
ASRCS = crt0.s z80pack.s
ASRCS += tricks.s commonmem.s
AOBJS = $(ASRCS:.s=.rel)
COBJS = $(CSRCS:.c=.rel)
+CBOBJS = $(CBSRCS:.c=.rel)
DOBJS = $(patsubst ../dev/z80pack/%.c,%.rel, $(DSRCS))
-OBJS = $(AOBJS) $(COBJS) $(DOBJS)
+OBJS = $(AOBJS) $(COBJS) $(DOBJS) $(CBOBJS)
CROSS_CCOPTS += -I../dev/z80pack/
$(COBJS): %.rel: %.c
$(CROSS_CC) $(CROSS_CCOPTS) -c $<
+$(CBOBJS): %.rel: %.c
+ $(CROSS_CC) $(CROSS_CCOPTS) --constseg DATAAL -c $<
+
$(DOBJS): %.rel: ../dev/z80pack/%.c
$(CROSS_CC) $(CROSS_CCOPTS) -c $<
void device_init(void)
{
int i;
- /* Add 64 swaps (4MB) to use the entire J drive */
- for (i = 0; i < MAX_SWAPS; i++)
+ /* The first swap area is reserved for the banked syscall blocks */
+ /* Add a max of 63 swaps (4MB) to use the entire J drive */
+ for (i = 1; i <= MAX_SWAPS; i++)
swapmap_add(i);
}
-mwxuy
+-r
-i fuzix.ihx
--b _CODE=0xC000
+-b _DATAAL=0xC000
+-b _CODE=0xC040
-b _DISCARD=0x5000
-b _UDATA=0x7E00
-b _CODE6=0x8000
devsys.rel
platform-micropack/devlpr.rel
platform-micropack/devtty.rel
+platform-micropack/syscall_bank.rel
-e
.globl interrupt_handler
.globl _swapper
.globl _swapout
+ .globl _curbank
+ .globl bank_switch_a
; imported debug symbols
.globl outstring, outde, outhl, outbc, outnewline, outchar, outcharhex
; We are still on the departing processes stack, which is
; fine for now.
;
+ ld a, (_curbank)
+ ld (U_DATA__U_PAGE2), a
ld sp, #_swapstack
push hl
; We will always swap out the current process
sbc hl, de ; subtract, result will be zero if DE==IX
jr nz, switchinfail
+ ld a, (U_DATA__U_INSYS)
+ or a
+ jr z, not_sys
+ ld l, a
+ ; Bank rigt ?
+ ld a, (U_DATA__U_PAGE2)
+ ; Any bank
+ or a
+ jr z, not_sys
+ ; Need to switch bank
+ ld l, a
+ call bank_switch_a
+not_sys:
; wants optimising up a bit
ld ix, (U_DATA__U_PTAB)
; next_process->p_status = P_RUNNING
.globl map_save
.globl map_restore
.globl platform_interrupt_all
+ .globl bank_switch_a
+ .globl _curbank
; exported debugging tools
.globl _trap_monitor
.globl null_handler
.globl nmi_handler
.globl interrupt_handler
+ .globl _syscall_bank
+ .globl _hd_read
.globl outcharhex
.globl outhl, outde, outbc
ld a, #1
out (29), a
-; -----------------------------------------------------------------------------
-; KERNEL MEMORY BANK (below 0xC000, only accessible when the kernel is mapped)
-; -----------------------------------------------------------------------------
.area _CODE
init_early:
; set restart vector for UZI system calls
ld (0x0030), a ; (rst 30h is unix function call vector)
- ld hl, #unix_syscall_entry
+ ld hl, #overlay_syscall_entry
ld (0x0031), hl
; Set vector for jump to NULL
out (0x01), a
ret
+overlay_syscall_entry:
+ ld hl, #18
+ add hl, sp
+ ld hl, #_syscall_bank ; FIXME load both as sdasz80 sulks
+ ld l, (hl)
+ ld a, (hl)
+ or a
+ jp z, unix_syscall_entry
+ ld a, (_curbank)
+ cp (hl)
+ call nz, bank_switch_hl
+ jp unix_syscall_entry
+ ;
+ ; Flip bank
+ ;
+bank_switch_hl:
+ ld a, (hl)
+bank_switch_a:
+ push bc
+ push de
+ push iy
+ ld (_curbank), a
+ add a, a ; 8 * 512 blocks per instance
+ add a, a
+ add a, a
+ ld h, #0
+ ld l, a
+ ld (U_DATA__U_OFFSET), hl
+ ld hl, #0x8000
+ ld (U_DATA__U_BASE), hl
+ ld hl, #0xE00
+ ld (U_DATA__U_COUNT), hl
+ ld hl, #0x0101
+ push hl
+ xor a
+ push af
+ inc sp
+ call _hd_read
+ inc sp
+ pop af
+ pop iy
+ pop de
+ pop bc
+
_need_resched:
- .db 0
+ .db 0
+_curbank:
+ .db 0