From 9b17be62644fce63c0bf4ee0faad31ddb5d05cfb Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 29 Dec 2024 14:56:31 +0000 Subject: [PATCH] z80retro: start fixing up the z80retro conversion to the new compiler This gets the SD card and boot sorted but console input is not happy --- Kernel/platform/platform-z80retro/Makefile | 8 +++++--- .../platform/platform-z80retro/boot-romwbw.S | 12 +++++------ Kernel/platform/platform-z80retro/crt0.S | 2 +- Kernel/platform/platform-z80retro/z80retro.S | 20 ++++++++++++++++++- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Kernel/platform/platform-z80retro/Makefile b/Kernel/platform/platform-z80retro/Makefile index 30cafedd1..8957e2fc5 100644 --- a/Kernel/platform/platform-z80retro/Makefile +++ b/Kernel/platform/platform-z80retro/Makefile @@ -64,7 +64,7 @@ image: bootblock perl -lpe '$$_=hex' fuzix.tmpmap | paste -d" " - fuzix.tmpmap | sort -n | cut -d" " -f 2- >../../fuzix.map ../../tools/pack85 <../../fuzix.map fuzix.bin ../../fuzix.bin # Attach the kernel to the boot block - cat boot-romwbw.bin ../../fuzix.bin >fuzix.romwbw + #cat boot-romwbw.bin ../../fuzix.bin >fuzix.romwbw clean: rm -f $(OBJS) $(JUNK) core *~ @@ -86,7 +86,9 @@ diskimage: image dd if=$(FUZIX_ROOT)/Standalone/filesystem-src/parttab.40M of=$(IMAGES)/disk.img bs=40017920 conv=sync # Add the file system dd if=$(IMAGES)/filesys.img of=$(IMAGES)/disk.img bs=512 seek=2048 conv=notrunc - # Add the kernel - dd if=fuzix.romwbw of=$(IMAGES)/disk.img bs=512 seek=2 conv=notrunc + # Add the bootstrap + dd if=boot-romwbw.bin of=$(IMAGES)/disk.img bs=512 seek=2 conv=notrunc + # And kernel + dd if=../../fuzix.bin of=$(IMAGES)/disk.img bs=512 seek=4 conv=notrunc # Make an emulator image of it cat $(FUZIX_ROOT)/Standalone/filesystem-src/idehdr.40M $(IMAGES)/disk.img > $(IMAGES)/emu-ide.img diff --git a/Kernel/platform/platform-z80retro/boot-romwbw.S b/Kernel/platform/platform-z80retro/boot-romwbw.S index a808f12a1..15684da50 100644 --- a/Kernel/platform/platform-z80retro/boot-romwbw.S +++ b/Kernel/platform/platform-z80retro/boot-romwbw.S @@ -72,22 +72,22 @@ bootit: ld e, 32 ; 32 sectors (16K) push bc rst 8 ; Can error but if so wtf do we do ? - ld hl,0x8000 + ld hl,0x8100 ld de,0x0100 - ld bc,0x4000 ; We've loaded 0100-40FF + ld bc,0x3F00 ; We've loaded 0100-4000 ldir pop bc ld hl,0x8000 - ld e,32 ; Load the next 16K + ld e,32 ; Load the next 16K push bc rst 8 ld hl,0x8000 ; Move it into place - ld de,0x4100 + ld de,0x4000 ld bc,0x4000 ldir pop bc - ld hl,0x8100 ; Now load 8100 up - ld e, 55 ; takes us up to F100. If that's not enough + ld hl,0x8000 ; Now load 8000 up + ld e, 55 ; takes us up to F000. If that's not enough ; before unpack we have a problem as we ; will need to move the loader rst 8 diff --git a/Kernel/platform/platform-z80retro/crt0.S b/Kernel/platform/platform-z80retro/crt0.S index 0eefcc092..46e9eb983 100644 --- a/Kernel/platform/platform-z80retro/crt0.S +++ b/Kernel/platform/platform-z80retro/crt0.S @@ -12,7 +12,7 @@ init: ; must be at 0x0100 as we are loaded at that ld sp, kstack_top ; Move the common memory where it belongs - ld hl, __data + ld hl, __bss ld de, __common ld bc, __common_size ldir diff --git a/Kernel/platform/platform-z80retro/z80retro.S b/Kernel/platform/platform-z80retro/z80retro.S index fda433836..b32c7d84d 100644 --- a/Kernel/platform/platform-z80retro/z80retro.S +++ b/Kernel/platform/platform-z80retro/z80retro.S @@ -459,7 +459,10 @@ inchar_s: .export _sd_spi_rx_sector _sd_spi_tx_byte: - ld e,l + pop hl + pop de + push de + push hl sd_tx: ; bit 0 rl e @@ -506,9 +509,12 @@ sd_tx: ; Receive is by far the most important path ; _sd_spi_rx_byte: + push bc ld c,0xFF call sd_rx + pop bc ld l,e + ld h,0 ret ; FIXME - rotate C @@ -572,6 +578,11 @@ sd_rx: ret _sd_spi_rx_sector: + pop de + pop hl + push hl + push de + push bc ld bc,0xFF ; 0 for count 255 for reload of A ld a,(_td_raw) or a @@ -591,9 +602,15 @@ rx_byte: ld (hl),e inc hl djnz rx_byte + pop bc jp map_kernel _sd_spi_tx_sector: + pop de + pop hl + push hl + push de + push bc ld b,0 ld a,(_td_raw) or a @@ -613,6 +630,7 @@ tx_byte: inc hl call sd_tx djnz tx_byte + pop bc jp map_kernel ;