From: Alan Cox Date: Fri, 30 Nov 2018 22:33:28 +0000 (+0000) Subject: zx+3: Quic pass over the code to fix the obvious bugs X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=c80781a658376f16f262f2dc0747d199c2b55e7f;p=FUZIX.git zx+3: Quic pass over the code to fix the obvious bugs With that done we boot to a shell but the floppy driver doesn't appear to want to be friends yet. --- diff --git a/Kernel/platform-zx+3/Makefile b/Kernel/platform-zx+3/Makefile new file mode 100644 index 00000000..946f3f7b --- /dev/null +++ b/Kernel/platform-zx+3/Makefile @@ -0,0 +1,62 @@ +CSRCS = devtty.c devices.c main.c +CDSRCS = discard.c +DSRCS = ../dev/devide.c ../dev/blkdev.c ../dev/devfdc765.c ../dev/devsd.c +DDSRCS = ../dev/devide_discard.c ../dev/mbr.c ../dev/devsd_discard.c +DZSRCS = ../dev/zx/divide.c ../dev/zx/zxkeyboard.c ../dev/zx/devinput.c ../dev/zx/zxmmc.c +DDZSRCS = +ASRCS = crt0.s plus3.s zxvideo.s fdc765.s +ASRCS += tricks.s commonmem.s + +COBJS = $(CSRCS:.c=.rel) +CDOBJS = $(CDSRCS:.c=.rel) +AOBJS = $(ASRCS:.s=.rel) +DOBJS = $(patsubst ../dev/%.c,%.rel, $(DSRCS)) +DDOBJS = $(patsubst ../dev/%.c,%.rel, $(DDSRCS)) +DZOBJS = $(patsubst ../dev/zx/%.c,%.rel, $(DZSRCS)) +DDZOBJS = $(patsubst ../dev/zx/%.c,%.rel, $(DDZSRCS)) +OBJS = $(COBJS) $(CDOBJS) $(AOBJS) $(DOBJS) $(DDOBJS) $(DZOBJS) $(DDZOBJS) + +CROSS_CCOPTS += -I../dev/ -I../dev/zx/ + +CROSS_CC_SEG3 = --codeseg CODE3 + +all: $(OBJS) + +$(COBJS): %.rel: %.c + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG3) -c $< + +$(CDOBJS): %.rel: %.c + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $< + +$(DOBJS): %.rel: ../dev/%.c + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG3) -c $< + +$(DDOBJS): %.rel: ../dev/%.c + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $< + +$(DZOBJS): %.rel: ../dev/zx/%.c + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEG3) -c $< + +$(DDZOBJS): %.rel: ../dev/zx/%.c + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $< + +$(AOBJS): %.rel: %.s + $(CROSS_AS) $(ASOPTS) $< + +clean: + rm -f $(OBJS) *.lst *.asm *.sym *.rst *.rel core *~ + rm -f loader.tmp loader.ihx loader.bin padding.bin disk.raw + rm -rf fuzix.dsk + +image: + sdasz80 -o loader.s + sdldz80 -i loader.rel + makebin -s 65536 loader.ihx loader.tmp + # Extract the loader itself + dd if=loader.tmp bs=512 skip=127 | ../tools/plus3boot >loader.bin + # Padding to fill the virtual disk + dd if=/dev/zero of=padding.bin bs=512 count=360 + # Make a disk image to work from + cat loader.bin ../fuzix.bin padding.bin >disk.raw + # And generate a 40 track plus3 disk from it + ../tools/raw2dsk disk.raw fuzix.dsk \ No newline at end of file diff --git a/Kernel/platform-zx+3/README b/Kernel/platform-zx+3/README index 8ede4b9c..58f4e202 100644 --- a/Kernel/platform-zx+3/README +++ b/Kernel/platform-zx+3/README @@ -6,6 +6,11 @@ The memory mapping on this machine is a bit friendlier but it's still single This port really shows we need to support parent-first single in memory +Note: + +We keep the discard high up below the common because otherwise the packed +image overlaps itself and the ldir into discard corrupts the image + Memory Model We use +2A/+3 'special paging mode'. It's special, but limited. Sufficient for diff --git a/Kernel/platform-zx+3/config.h b/Kernel/platform-zx+3/config.h index 5f7ff33e..981a5372 100644 --- a/Kernel/platform-zx+3/config.h +++ b/Kernel/platform-zx+3/config.h @@ -1,5 +1,7 @@ #define CONFIG_IDE #define CONFIG_LARGE_IO_DIRECT /* We support direct to user I/O */ +#define CONFIG_SD +#define SD_DRIVE_COUNT 2 /* Enable to make ^Z dump the inode table for debug */ #undef CONFIG_IDUMP /* Enable to make ^A drop back into the monitor */ diff --git a/Kernel/platform-zx+3/crt0.s b/Kernel/platform-zx+3/crt0.s index ca9f2a80..0a05f8c3 100644 --- a/Kernel/platform-zx+3/crt0.s +++ b/Kernel/platform-zx+3/crt0.s @@ -34,11 +34,15 @@ ; Finally the buffers so they can expand ; .area _BUFFERS - - .area _DISCARD ; Somewhere to throw it out of the way .area _INITIALIZER + ; + ; We load these at D800 at the moment, so we avoid the + ; ldir overlap problem as we unpack. + ; + .area _DISCARD + .area _COMMONMEM .area _FONT @@ -55,6 +59,8 @@ .globl s__DATA .globl l__DISCARD .globl s__DISCARD + .globl l__FONT + .globl s__FONT .globl kstack_top .globl unix_syscall_entry @@ -87,6 +93,10 @@ _start: ld de, #s__COMMONMEM ld bc, #l__COMMONMEM ldir + ; then the font + ld de, #s__FONT + ld bc, #l__FONT + ldir ; then the discard ld de, #s__DISCARD ld bc, #l__DISCARD diff --git a/Kernel/platform-zx+3/devtty.c b/Kernel/platform-zx+3/devtty.c index c81e18f7..5e7dc531 100644 --- a/Kernel/platform-zx+3/devtty.c +++ b/Kernel/platform-zx+3/devtty.c @@ -13,7 +13,7 @@ char tbuf1[TTYSIZ]; uint8_t vtattr_cap = VTA_INVERSE|VTA_FLASH|VTA_UNDERLINE; -uint8_t curattr; +extern uint8_t curattr; static tcflag_t console_mask[4] = { _ISYS, diff --git a/Kernel/platform-zx+3/fdc765.s b/Kernel/platform-zx+3/fdc765.s index e7112409..866ab036 100644 --- a/Kernel/platform-zx+3/fdc765.s +++ b/Kernel/platform-zx+3/fdc765.s @@ -187,7 +187,7 @@ _fd765_motor_off: jp map_kernel _fd765_motor_on: - ld a,#1 + ld a,#0x08 ld (diskmotor),a ; Take effect call map_kernel diff --git a/Kernel/platform-zx+3/fuzix.lnk b/Kernel/platform-zx+3/fuzix.lnk index dddbc108..7365680a 100644 --- a/Kernel/platform-zx+3/fuzix.lnk +++ b/Kernel/platform-zx+3/fuzix.lnk @@ -3,6 +3,7 @@ -l z80 -b _CODE=0x0100 -b _COMMONMEM=0xF000 +-b _DISCARD=0xD800 platform-zx+3/crt0.rel platform-zx+3/commonmem.rel platform-zx+3/plus3.rel @@ -40,6 +41,9 @@ platform-zx+3/devtty.rel platform-zx+3/devide.rel platform-zx+3/devide_discard.rel platform-zx+3/divide.rel +platform-zx+3/devsd.rel +platform-zx+3/devsd_discard.rel +platform-zx+3/zxmmc.rel platform-zx+3/mbr.rel platform-zx+3/blkdev.rel platform-zx+3/devinput.rel diff --git a/Kernel/platform-zx+3/loader.s b/Kernel/platform-zx+3/loader.s index 5eb45500..dbfdb16b 100644 --- a/Kernel/platform-zx+3/loader.s +++ b/Kernel/platform-zx+3/loader.s @@ -25,22 +25,29 @@ ; start: di + ld bc,#0x7ffd + ld a,#0x08 ; screen on 7 + out (c),a ; ; The boot loader turns the motor off, so turn it back on but wait ; a bit otherwise some 3.5" disks won't boot right ; + motor_on: + ; Wait for the motor to catch back up - clear the screen ! + ld bc,#0x7ffd + ld a,#0x08 ; screen on 7 + out (c),a + ld hl,#0x4000 + ld de,#0x4001 + ld bc,#0x6911 + xor a + ldir + + ld bc,#0x1ffd ld a,#0x0D ; special paging 4/5/6/3. motor on out (c),a - - ; Wait for the motor to catch back up - ld bc,#0x3548 -waitm: - dec bc - ld a,b - or c - jr nz, waitm ; ; Ok now we can try and load stuff ; 9 sectors per track and we need to start from 0/2 @@ -132,10 +139,11 @@ load_sector: ld c,#0xfd ; low bits of I/O ld d,#0x20 ; mask - jp read_wait + jp read_begin read_loop: ld b,#0x3f ini +read_begin: ld b,#0x2f read_wait: in a,(c) diff --git a/Kernel/platform-zx+3/main.c b/Kernel/platform-zx+3/main.c index 00230ec0..997812c6 100644 --- a/Kernel/platform-zx+3/main.c +++ b/Kernel/platform-zx+3/main.c @@ -56,7 +56,7 @@ struct blkbuf *bufpool_end = bufpool + NBUFS; */ void platform_discard(void) { - uint16_t discard_size = 0xC000U - (uint16_t)bufpool_end; + uint16_t discard_size = ((uint16_t)&udata) - (uint16_t)bufpool_end; bufptr bp = bufpool_end; discard_size /= sizeof(struct blkbuf); diff --git a/Kernel/platform-zx+3/plus3.s b/Kernel/platform-zx+3/plus3.s index 65ef348e..f571c20e 100644 --- a/Kernel/platform-zx+3/plus3.s +++ b/Kernel/platform-zx+3/plus3.s @@ -112,7 +112,8 @@ init_hardware: ; video bank 7 out (c),a ; and we should have special mapping ; already by now - + xor a + out (0xFE),a ; black border ; screen initialization call _vtinit @@ -124,7 +125,7 @@ init_hardware: .area _COMMONMEM _program_early_vectors: - call map_process + call map_process_always call set_vectors call map_kernel set_vectors: @@ -168,7 +169,7 @@ map_for_swap: map_process_always: map_process_always_di: push af - ld a,#0x5 ; 4 5 6 3 + ld a,#0x1 ; 0 1 2 3 jr map_a_pop ; ; Save and switch to kernel @@ -182,9 +183,9 @@ map_kernel_di: map_kernel: map_kernel_restore: push af + ld a,#0x05 ; 4 5 6 3 map_a_pop: push bc - ld a,#0x01 ; 0/1/2/3 ld (current_map),a ld bc,(diskmotor) or c @@ -202,7 +203,6 @@ map_video: map_restore: push af ld a, (map_store) - ld (current_map),a jr map_a_pop ; diff --git a/Kernel/platform-zx+3/zxvideo.s b/Kernel/platform-zx+3/zxvideo.s index 250ec839..e418b2cb 100644 --- a/Kernel/platform-zx+3/zxvideo.s +++ b/Kernel/platform-zx+3/zxvideo.s @@ -18,10 +18,21 @@ .globl _curattr .globl _vtattr + .globl map_video + .globl map_kernel + ; Build the video library as the only driver ZXVID_ONLY .equ 1 +.macro VIDEO_MAP + call map_video +.endm + +.macro VIDEO_UNMAP + call map_kernel +.endm + .area _COMMONMEM .include "../dev/zx/video.s"