diff --git a/.gitignore b/.gitignore index ee462bf..7955f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.sym mkfs 2063-Z80-cpm.zip +Make.local diff --git a/filesystem/Make.default b/Make.default similarity index 54% rename from filesystem/Make.default rename to Make.default index c87339d..7a17eec 100644 --- a/filesystem/Make.default +++ b/Make.default @@ -1,3 +1,6 @@ +# DO NOT EDIT THIS FILE +# Override these values if needed by assigning different values in a Make.local file + # A set of default values of things that might be of # interest to more than one Makefile. @@ -8,3 +11,10 @@ SD_DEV=/dev/sda1 # This is used before burning an SD card image to make sure we are on the correct host! SD_HOSTNAME=raspberrypi + +# Be default, build for the Z80-Retro! +ASM_FLAGS=-I../lib -I../libretro + +BOOT_MSG=Z80 Retro Board 2063.3 + +-include $(TOP)/Make.local diff --git a/Makefile b/Makefile index 1cdf20d..fab5850 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ SUBDIRS=\ boot \ + retro \ tests \ hello \ - retro \ filesystem CLEAN_DIRS=$(SUBDIRS:%=clean-%) @@ -33,6 +33,8 @@ REL_FILES=\ doc \ hello \ lib \ + libretro \ + libnouveau \ retro \ tests \ filesystem/Makefile \ diff --git a/README-SD.md b/README-SD.md index 5bdcac9..0968e2d 100644 --- a/README-SD.md +++ b/README-SD.md @@ -47,7 +47,7 @@ Do *NOT* expect that you will be able to recover any data after doing this! On my raspberry PI, with only one SD adapter plugged into a USB port, I use the following command: - sudo dd if=/dev/zero of=/dev/sda bs=512 count=10 + sudo dd if=/dev/zero of=/dev/sda bs=512 count=100 conv=fsync ## Partition your SD card @@ -120,7 +120,7 @@ At this point, Liunux should recognize that the drive has one partition on it: If we write "Hello world!" into partition 1: - echo "Hello world!" | sudo dd of=/dev/sda1 bs=512 + echo "Hello world!" | sudo dd of=/dev/sda1 bs=512 conv=fsync ...then we can see it by looking at the raw disk image: diff --git a/boot/Makefile b/boot/Makefile index b86bd48..5102457 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -1,4 +1,6 @@ -ASM_FLAGS=-I../lib + +TOP=.. +include $(TOP)/Make.default all: firmware.bin @@ -7,10 +9,10 @@ clean: rm -f ldr rm -f *.lst *.bin *.hex *.sym -DATE := $(shell date --rfc-3339=seconds) +DATE := $(shell date +"%Y-%m-%d %H:%M:%S%z") GIT_VERSION := $(shell git describe --long --dirty; git show -s --format='%ci') %.bin: %.asm - cat $< | sed -e "s/@@DATE@@/$(DATE)/g" -e "s/@@GIT_VERSION@@/$(GIT_VERSION)/g" | z80asm - -o $@ --list=$(basename $@).lst --label=$(basename $@).sym $(ASM_FLAGS) + cat $< | sed -e "s/@@DATE@@/$(DATE)/g" -e "s/@@GIT_VERSION@@/$(GIT_VERSION)/g" -e "s/@@BOOT_MSG@@/$(BOOT_MSG)/g" | z80asm - -o $@ --list=$(basename $@).lst --label=$(basename $@).sym $(ASM_FLAGS) world: clean all diff --git a/boot/firmware.asm b/boot/firmware.asm index 5e61131..75e9869 100644 --- a/boot/firmware.asm +++ b/boot/firmware.asm @@ -1,6 +1,6 @@ ;**************************************************************************** ; -; Copyright (C) 2021,2022,2023 John Winans +; Copyright (C) 2021,2022,2023,2024 John Winans ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Lesser General Public @@ -53,7 +53,7 @@ include 'memory.asm' ; NOTE THAT THE SRAM IS NOT READABLE AT THIS POINT ;################################################### - ; Select SRAM low bank 14, idle the SD card, and idle printer signals + ; Select SRAM low bank, idle the SD card, etc. ld a,(gpio_out_cache) out (gpio_out),a @@ -73,14 +73,8 @@ include 'memory.asm' ld sp,.stacktop - ; Initialize the CTC so that the SIO will have a baud clock if J11-A is set to the CTC! - ;ld c,1 ; 115200 bps - ;ld c,6 ; 19200 bps - ld c,12 ; 9600 bps - call init_ctc_1 - - ; Init the SIO to run at 115200 or at the CTC rate depending on J11-A - call sioa_init + call bsp_init ; board-specific init + call con_init ; Display a hello world message. ld hl,.boot_msg @@ -100,7 +94,7 @@ include 'memory.asm' .boot_msg: db '\r\n\n' db '##############################################################################\r\n' - db 'Z80 Retro Board 2063.3\r\n' + db '@@BOOT_MSG@@\r\n' db ' git: @@GIT_VERSION@@\r\n' db ' build: @@DATE@@\r\n' db '\0' @@ -446,17 +440,15 @@ endif include 'sdcard.asm' include 'spi.asm' include 'hexdump.asm' -include 'sio.asm' -include 'ctc1.asm' +include 'console.asm' include 'puts.asm' +include 'bsp.asm' ;############################################################################## ; This is a cache of the last written data to the gpio_out port. ; The initial value here is what is written to the latch during startup. ;############################################################################## -.low_bank: equ 0x0e ; The RAM BANK to use for the bottom 32K -gpio_out_cache: db gpio_out_sd_mosi|gpio_out_sd_ssel|gpio_out_prn_stb|gpio_out_sd_clk|(.low_bank<<4) - +gpio_out_cache: db gpio_out_init ;############################################################################## ; This marks the end of the data copied from FLASH into RAM during boot diff --git a/filesystem/Makefile b/filesystem/Makefile index 10b4706..08b0de3 100644 --- a/filesystem/Makefile +++ b/filesystem/Makefile @@ -22,9 +22,11 @@ all:: -# optionally include rules from a local file: -include Make.default --include Make.local + +# Include the detault and any local override rules +# Must set TOP before including Make.default +TOP=.. +include $(TOP)/Make.default .PHONY: all clean world burn blank-all-sd diff --git a/hello/Makefile b/hello/Makefile index 95d7389..4493f34 100644 --- a/hello/Makefile +++ b/hello/Makefile @@ -1,5 +1,6 @@ -ASM_FLAGS=-I../lib +TOP=.. +include $(TOP)/Make.default all: hello.bin @@ -7,7 +8,7 @@ clean: rm -f ldr rm -f *.lst *.bin *.hex -DATE := $(shell date --rfc-3339=seconds) +DATE := $(shell date +"%Y-%m-%d %H:%M:%S%z") GIT_VERSION := $(shell git describe --long --dirty; git show -s --format='%ci') %.bin: %.asm cat $< | sed -e "s/@@DATE@@/$(DATE)/g" -e "s/@@GIT_VERSION@@/$(GIT_VERSION)/g" | z80asm - -o $@ --list=$(basename $@).lst $(ASM_FLAGS) diff --git a/hello/hello.asm b/hello/hello.asm index 1c54a36..97c7508 100644 --- a/hello/hello.asm +++ b/hello/hello.asm @@ -54,6 +54,5 @@ include 'memory.asm' include 'hexdump.asm' -include 'sio.asm' -include 'ctc1.asm' +include 'console.asm' include 'puts.asm' diff --git a/libnouveau/bsp.asm b/libnouveau/bsp.asm new file mode 100644 index 0000000..06223b6 --- /dev/null +++ b/libnouveau/bsp.asm @@ -0,0 +1,35 @@ +;**************************************************************************** +; +; Copyright (C) 2024 John Winans +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +; USA +; +; https://github.com/johnwinans/2063-Z80-cpm +; +;**************************************************************************** + +bsp_init: + ld a,0 + ;out0 (0x36),a ; RCR = 0 = disable the DRAM refresh controller + db 0xed,0x39,0x36 + ;out0 (0x32),a ; DCNTL = 0 = zero wait states + db 0xed,0x39,0x32 + + ld a,0x80 + ;out0 (0x1f),a ; CCR = 0x80 = run at 1X extal clock speed + db 0xed,0x39,0x1f + + ret diff --git a/libnouveau/console.asm b/libnouveau/console.asm new file mode 100644 index 0000000..dc51dd3 --- /dev/null +++ b/libnouveau/console.asm @@ -0,0 +1,117 @@ +;**************************************************************************** +; +; Copyright (C) 2024 John Winans +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +; USA +; +; https://github.com/johnwinans/2063-Z80-cpm +; +;**************************************************************************** + +; Drivers for the Z8S180 ASCI + +.CNTLA0: equ 0x00 +.CNTLB0: equ 0x02 +.RDR0: equ 0x08 +.ASEXT0: equ 0x12 +.STAT0: equ 0x04 +.TDR0: equ 0x06 + +;############################################################## +; Return NZ if the console UART is ready and Z (with A=0) if not ready. +; Clobbers: AF +;############################################################## +con_tx_ready: + ;IN0 A,(.STAT0) ;C4H,read status + db 11101101B,00111000B,.STAT0 + AND 2 + ret ; a = 0 = not ready + +;############################################################## +; Return NZ if the console UART is ready and Z (with A=0) if not ready. +; Clobbers: AF +;############################################################## +con_rx_ready: + ; hack to clear any overrun errors (See Errata about ASCI seizures) + ;IN0 A,(.CNTLA0) ;C4H,read status + db 11101101B,00111000B,.CNTLA0 + and ~0x08 + ;OUT0 (.CNTLA0),A + db 0xed,0x39,.CNTLA0 + + ;IN0 A,(.STAT0) ;C4H,read status + db 11101101B,00111000B,.STAT0 + AND 10000000B + ret ; 0 = not ready + + +;############################################################## +; stolen from https://groups.google.com/g/retro-comp/c/N574sGiwmaI?pli=1 +; mods are my fault :-) +;############################################################## +con_init: + LD A,01100100B ; rcv enable, xmit enable, no parity + ;LD A,01100101B ; rcv enable, xmit enable, no parity + ;OUT0 (.CNTLA0),A ; set cntla + db 0xed,0x39,.CNTLA0 + + LD A,00000000B ; div 10, div 16, div 2 18432000/1/1/10/16/1 = 115200 + ;OUT0 (.CNTLB0),A ; set cntlb + db 0xed,0x39,.CNTLB0 + + LD A,01100110B ; no cts, no dcd, no break detect + ;OUT0 (.ASEXT0),A ; set ASCI0 EXTENSION CONTROL (Z8S180 only) + db 0xed,0x39,.ASEXT0 + XOR A + ;OUT0 (.STAT0),A ; ASCI Status Reg Ch 0 + db 0xed,0x39,.STAT0 + ret + + +;############################################################## +; Wait for the transmitter to become ready and then +; print the character in the C register. +; Clobbers: AF +;############################################################## +con_tx_char: + call con_tx_ready + jr z,con_tx_char + ld a,c + + ;OUT0 (.TDR0),A ;C6H + db 0xed,0x39,.TDR0 + + ret + +;############################################################## +; Wait for the receiver to become ready and then return the +; character in the A register. +; Clobbers: AF +; +; XXX need to concern ourselves with the Errata note that +; says we need to write zero into CNTLA0, bit 3 (ERF) to +; reset an overflow error flag when set because RX will +; seize. +; +;############################################################## +con_rx_char: + call con_rx_ready + jr z,con_rx_char + + ;IN0 A,(.RDR0) + db 11101101B,00111000B,.RDR0 + + ret diff --git a/libnouveau/io.asm b/libnouveau/io.asm new file mode 100644 index 0000000..79a55b3 --- /dev/null +++ b/libnouveau/io.asm @@ -0,0 +1,42 @@ +;**************************************************************************** +; +; Copyright (C) 2024 John Winans +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +; USA +; +; https://github.com/johnwinans/2063-Z80-cpm +; +;**************************************************************************** + +; Z80 Nouveau + +gpio_in: equ 0xf0 ; GP input port +gpio_out: equ 0xf1 ; GP output port +flash_disable: equ 0xfe ; dummy-read from this port to disable the FLASH + +; bit-assignments for General Purpose output port +gpio_out_sd_mosi: equ 0x01 +gpio_out_sd_clk: equ 0x02 +gpio_out_sd_ssel: equ 0x04 + +; bit-assignments for General Purpose input port +;gpio_in_user1: equ 0x20 +gpio_in_sd_det: equ 0x40 +gpio_in_sd_miso: equ 0x80 + +; The initial value to write into the gpio_out latch. +; The value here will idle the SD card interface. +gpio_out_init: equ gpio_out_sd_mosi|gpio_out_sd_clk|gpio_out_sd_ssel diff --git a/libnouveau/list.asm b/libnouveau/list.asm new file mode 100644 index 0000000..423c569 --- /dev/null +++ b/libnouveau/list.asm @@ -0,0 +1,43 @@ +;**************************************************************************** +; +; Copyright (C) 2024 John Winans +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +; USA +; +; https://github.com/johnwinans/2063-Z80-cpm +; +;**************************************************************************** + +;########################################################################## +; Initialize the printer. +;########################################################################## +list_init: + ret + +;########################################################################## +; Return A=0 if printer is not ready. +; Return A=0xff if printer is ready. +;########################################################################## +list_stat: + ld a,0xff + ret + + +;########################################################################## +; Print the character in the C register. +;########################################################################## +list_out: + ret diff --git a/libretro/bsp.asm b/libretro/bsp.asm new file mode 100644 index 0000000..4895463 --- /dev/null +++ b/libretro/bsp.asm @@ -0,0 +1,25 @@ +;**************************************************************************** +; +; Copyright (C) 2024 John Winans +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +; USA +; +; https://github.com/johnwinans/2063-Z80-cpm +; +;**************************************************************************** + +bsp_init: + ret diff --git a/libretro/console.asm b/libretro/console.asm new file mode 100644 index 0000000..41b3eea --- /dev/null +++ b/libretro/console.asm @@ -0,0 +1,56 @@ +;**************************************************************************** +; +; Copyright (C) 2021,2024 John Winans +; +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +; USA +; +; https://github.com/johnwinans/2063-Z80-cpm +; +;**************************************************************************** + + +include 'sio.asm' +include 'ctc1.asm' + +con_init: + ;ld c,6 ; C = 6 = 19200 bps + ld c,12 ; C = 12 = 9600 bps + call init_ctc_1 ; start CTC1 in case J11-A selects it! + call sioa_init ; 115200 or 19200/9600 depending on J11-A + ret + + +;########################################################################## +; +; CP/M 2.2 Alteration Guide p17: +; Read the next console character into register A and set the parity bit +; (high order bit) to zero. If no console character is ready, wait until +; a character is typed before returning. +; +;########################################################################## +if 1 +con_rx_char: equ sioa_rx_char ; assemble the BIOS to call the sioa version direct +else +con_rx_char: + call sioa_rx_char + ; A special hacked version to dump the disk cache status when pressing the escape key + cp 0x1B ; escape key?? + ret nz ; if not an escape then return + call z,disk_dmcache_debug_wedge ; else tail-call the debug wedge + ld a,0x1B ; restore the trigger key value + ret +endif + diff --git a/lib/ctc1.asm b/libretro/ctc1.asm similarity index 100% rename from lib/ctc1.asm rename to libretro/ctc1.asm diff --git a/lib/ctc2.asm b/libretro/ctc2.asm similarity index 100% rename from lib/ctc2.asm rename to libretro/ctc2.asm diff --git a/lib/ctc3.asm b/libretro/ctc3.asm similarity index 100% rename from lib/ctc3.asm rename to libretro/ctc3.asm diff --git a/lib/io.asm b/libretro/io.asm similarity index 74% rename from lib/io.asm rename to libretro/io.asm index 39d0d97..a940c2d 100644 --- a/lib/io.asm +++ b/libretro/io.asm @@ -54,7 +54,6 @@ gpio_out_a18: equ 0x80 ; a bitmask representing all of the lobank address bits gpio_out_lobank: equ 0|(gpio_out_a15|gpio_out_a16|gpio_out_a17|gpio_out_a18) - ; bit-assignments for General Purpose input port gpio_in_prn_err: equ 0x01 gpio_in_prn_stat: equ 0x02 @@ -64,3 +63,34 @@ gpio_in_prn_ack: equ 0x10 gpio_in_user1: equ 0x20 gpio_in_sd_det: equ 0x40 gpio_in_sd_miso: equ 0x80 + + +;**************************************************************************** +; +; Memory banks: +; +; BANK Usage +; 0 SD cache bank 0 +; 1 SD cache bank 1 +; 2 SD cache bank 2 +; 3 SD cache bank 3 +; 4 +; 5 +; 6 +; 7 +; 8 +; 9 +; A +; B +; C +; D +; E CP/M zero page and low half of the TPA +; F CP/M high half of the TPA, CCP, BDOS, and BIOS +; +;**************************************************************************** + +.low_bank: equ 0x0e ; The RAM BANK to use for the bottom 32K + +; The initial value to write into the gpio_out latch. +; This will select low-bank E, idle the SD card, and idle the printer. +gpio_out_init: equ gpio_out_sd_mosi|gpio_out_sd_clk|gpio_out_sd_ssel|gpio_out_prn_stb|(.low_bank<<4) diff --git a/lib/prn.asm b/libretro/list.asm similarity index 98% rename from lib/prn.asm rename to libretro/list.asm index 66086f7..2993a9b 100644 --- a/lib/prn.asm +++ b/libretro/list.asm @@ -34,7 +34,7 @@ ; ; Clobbers AF ;########################################################################## -prn_init: +list_init: ld a,(gpio_out_cache) or gpio_out_prn_stb ; make PRN_STB high (false) ld (gpio_out_cache),a ; save in the cached output value @@ -46,7 +46,7 @@ prn_init: ; Return A=0xff if printer is ready. ; Clobbers AF ;########################################################################## -prn_stat: +list_stat: in a,(gpio_in) and gpio_in_prn_bsy ; if this bit is low then it is ready jr z,.prn_stat_ready @@ -60,7 +60,7 @@ prn_stat: ;########################################################################## ; Print the character in the C register. ;########################################################################## -prn_out: +list_out: ; Sanity check to prevent seizing the entire OS. ; If EVERY printer status input is high, then there is probably no @@ -75,7 +75,7 @@ prn_out: ; wait until the printer is ready for data ; XXX this can seize the system if the printer is offline! :-( .list_wait: - call prn_stat + call list_stat or a jr z,.list_wait ; if A=0 then is not ready diff --git a/lib/sio.asm b/libretro/sio.asm similarity index 99% rename from lib/sio.asm rename to libretro/sio.asm index fd60202..5285280 100644 --- a/lib/sio.asm +++ b/libretro/sio.asm @@ -126,7 +126,7 @@ siob_rx_char: ld a,(sio_bd) ret -con_rx_char: +;con_rx_char: sioa_rx_char: call sioa_rx_ready jr z,sioa_rx_char diff --git a/retro/Makefile b/retro/Makefile index 3e83c8b..daf1b68 100644 --- a/retro/Makefile +++ b/retro/Makefile @@ -1,12 +1,13 @@ -ASM_FLAGS=-I../lib +TOP=.. +include $(TOP)/Make.default + all: retro.bin clean: rm -f *.lst *.bin *.hex *.sym -DATE := $(shell date --rfc-3339=seconds) -#DATE := "xxx" +DATE := $(shell date +"%Y-%m-%d %H:%M:%S%z") GIT_VERSION := $(shell git describe --long --dirty; git show -s --format='%ci') %.bin: %.asm cat $< | sed -e "s/@@DATE@@/$(DATE)/g" -e "s/@@GIT_VERSION@@/$(GIT_VERSION)/g" | z80asm - -o $@ --list=$(basename $@).lst --label=$(basename $@).sym $(ASM_FLAGS) diff --git a/retro/disk_config.asm b/retro/disk_config.asm index f7cc07e..2f0d9d1 100644 --- a/retro/disk_config.asm +++ b/retro/disk_config.asm @@ -2,8 +2,8 @@ ; Configure the BIOS drive DPH structures here. ; ; WARNING -; Do *NOT* expected to mount the same drive more than one -; way and expect it to work without corrupting the drive! +; Do *NOT* expect to mount the same drive more than one +; way without corrupting it! ;**************************************************************************** ; Create a DPH & ALV for each filesystem diff --git a/retro/disk_dmcache.asm b/retro/disk_dmcache.asm index 0fe9467..b499849 100644 --- a/retro/disk_dmcache.asm +++ b/retro/disk_dmcache.asm @@ -406,7 +406,7 @@ if .dmcache_debug >= 2 push af ; save the flags so can decide to return below call iputs db ".cache_slot_fill cache hit: \0" - call bios_debug_disk + call disk_dump pop af .dbg_csm: endif @@ -417,7 +417,7 @@ endif if .dmcache_debug >= 2 call iputs db ".cache_slot_fill cache miss: \0" - call bios_debug_disk + call disk_dump endif push de ; put a copy of the CP/M track we want back onto the stack @@ -1082,7 +1082,7 @@ if .dmcache_debug >= 1 call hexdump_a call iputs db ": \0" - call bios_debug_disk + call disk_dump pop bc endif diff --git a/retro/disk_nocache.asm b/retro/disk_nocache.asm index edbee10..1a74361 100644 --- a/retro/disk_nocache.asm +++ b/retro/disk_nocache.asm @@ -245,7 +245,7 @@ endif if .nc_debug >= 1 call iputs db ".write cache miss: \0" - call bios_debug_disk + call disk_dump endif ; Remember drive that is in the cache - Trevor Jacobs - 02-15-2023 ld de,(disk_dph) diff --git a/retro/retro.asm b/retro/retro.asm index fdb59e2..185dd22 100644 --- a/retro/retro.asm +++ b/retro/retro.asm @@ -2,7 +2,7 @@ ; ; Z80 Retro! BIOS ; -; Copyright (C) 2021,2022 John Winans +; Copyright (C) 2021,2022,2024 John Winans ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Lesser General Public @@ -22,33 +22,6 @@ ; ;**************************************************************************** -;**************************************************************************** -; -; Memory banks: -; -; BANK Usage -; 0 SD cache bank 0 -; 1 SD cache bank 1 -; 2 SD cache bank 2 -; 3 SD cache bank 3 -; 4 -; 5 -; 6 -; 7 -; 8 -; 9 -; A -; B -; C -; D -; E CP/M zero page and low half of the TPA -; F CP/M high half of the TPA, CCP, BDOS, and BIOS -; -;**************************************************************************** - -.low_bank: equ 0x0e ; The RAM BANK to use for the bottom 32K - - ;########################################################################## ; set .debug to: @@ -115,9 +88,9 @@ endif BOOT: JP .bios_boot WBOOT: JP .bios_wboot CONST: JP .bios_const -CONIN: JP .bios_conin -CONOUT: JP .bios_conout -LIST: JP .bios_list +CONIN: JP con_rx_char +CONOUT: JP con_tx_char +LIST: JP list_out PUNCH: JP .bios_punch READER: JP .bios_reader HOME: JP disk_home @@ -127,7 +100,7 @@ SETSEC: JP disk_setsec SETDMA: JP disk_setdma READ: JP disk_read WRITE: JP disk_write -PRSTAT: JP .bios_prstat +PRSTAT: JP list_stat SECTRN: JP disk_sectrn @@ -150,15 +123,15 @@ SECTRN: JP disk_sectrn .bios_boot: ; This will select low-bank E, idle the SD card, and idle the printer - ld a,gpio_out_sd_mosi|gpio_out_sd_clk|gpio_out_sd_ssel|gpio_out_prn_stb|(.low_bank<<4) + ld a,gpio_out_init ld (gpio_out_cache),a out (gpio_out),a ; make sure we have a viable stack ld sp,bios_stack ; use the private BIOS stack to get started - call .init_console ; Note: console should still be initialized from the boot loader - call .init_list ; initialize the printer interface + call con_init ; Note: console should still be initialized from the boot loader + call list_init ; initialize the printer interface if .debug > 0 call iputs @@ -350,64 +323,6 @@ endif ld a,0xff ret ; A = 0xff = ready -;########################################################################## -; -; CP/M 2.2 Alteration Guide p17: -; Read the next console character into register A and set the parity bit -; (high order bit) to zero. If no console character is ready, wait until -; a character is typed before returning. -; -;########################################################################## -.bios_conin: -if 1 - jp con_rx_char -else - ; a simple hack to let us dump the dmcache status on demand - call con_rx_char - cp 0x1B ; escape key?? - ret nz ; if not an escape then return - call z,disk_dmcache_debug_wedge ; else tail-call the debug wedge - ld a,0x1B ; restore the trigger key value - ret -endif - -;########################################################################## -; -; CP/M 2.2 Alteration Guide p18: -; Send the character from register C to the console output device. The -; character is in ASCII, with high order parity bit set to zero. -; -;########################################################################## -.bios_conout: - jp con_tx_char - -;########################################################################## -; -; CP/M 2.2 Alteration Guide p18: -; Send the character from register C to the currently assigned listing -; device. The character is in ASCII with zero parity. -; -;########################################################################## -.bios_list: - jp prn_out ; tail-call the driver output routine - -.init_list: - jp prn_init ; tail-call the driver init routine - -;########################################################################## -; -; CP/M 2.2 Alteration Guide p20: -; Return the ready status of the list device. Used by the DESPOOL program -; to improve console response during its operation. The value 00 is -; returned in A of the list device is not ready to accept a character, and -; 0FFH if a character can be sent to the printer. -; -; Note that a 00 value always suffices. -; -; Clobbers AF -;########################################################################## -.bios_prstat: - jp prn_stat ; tail-call the driver status routine ;########################################################################## ; @@ -435,16 +350,6 @@ endif ld a,0x1a ret -;########################################################################## -; Initialize the console port. Note that this includes CTC port 1. -;########################################################################## -.init_console: - ;ld c,6 ; C = 6 = 19200 bps - ld c,12 ; C = 12 = 9600 bps - call init_ctc_1 ; start CTC1 in case J11-A selects it! - call sioa_init ; 115200 or 19200/9600 depending on J11-A - ret - ;########################################################################## ; Libraries @@ -452,13 +357,12 @@ endif include 'disk_callgate.asm' -include 'sio.asm' -include 'ctc1.asm' +include 'console.asm' +include 'list.asm' include 'puts.asm' include 'hexdump.asm' include 'sdcard.asm' include 'spi.asm' -include 'prn.asm' ;########################################################################## @@ -488,5 +392,4 @@ if $ < BOOT ERROR THE BIOS WRAPPED AROUND PAST 0xffff endif - end diff --git a/tests/Makefile b/tests/Makefile index 0616059..b01e32d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,4 +1,5 @@ -ASM_FLAGS=-I../lib +TOP=.. +include $(TOP)/Make.default all: spi_test.bin sd_test.bin @@ -6,7 +7,7 @@ clean: rm -f ldr rm -f *.lst *.bin *.hex *.sym -DATE := $(shell date --rfc-3339=seconds) +DATE := $(shell date +"%Y-%m-%d %H:%M:%S%z") GIT_VERSION := $(shell git describe --long --dirty; git show -s --format='%ci') %.bin: %.asm diff --git a/tests/sd_test.asm b/tests/sd_test.asm index 4adec47..f63e52d 100644 --- a/tests/sd_test.asm +++ b/tests/sd_test.asm @@ -1,6 +1,6 @@ ;**************************************************************************** ; -; Copyright (C) 2021,2022 John Winans +; Copyright (C) 2021,2022,2024 John Winans ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Lesser General Public @@ -64,14 +64,7 @@ include 'memory.asm' ld sp,.stacktop - ; Initialize the CTC so that the SIO will have a custom baud clock if J11-A is set to the CTC! - ;ld c,1 ; 115200 bps - ;ld c,6 ; 19200 bps - ld c,12 ; 9600 bps - call init_ctc_1 - - ; Init the SIO to run at 115200 or at the CTC rate depending on J11-A - call sioa_init + call con_init ; Display a hello world message. ld hl,.boot_msg @@ -252,15 +245,14 @@ endif include 'sdcard.asm' include 'spi.asm' include 'hexdump.asm' -include 'sio.asm' -include 'ctc1.asm' +include 'console.asm' include 'puts.asm' ;############################################################################## ; This is a cache of the last written data to the gpio_out port. ; The initial value here is what is written to the latch during startup. ;############################################################################## -gpio_out_cache: db gpio_out_sd_mosi|gpio_out_sd_ssel|gpio_out_prn_stb +gpio_out_cache: db gpio_out_init ;############################################################################## diff --git a/tests/spi_test.asm b/tests/spi_test.asm index cf782c3..420ba85 100644 --- a/tests/spi_test.asm +++ b/tests/spi_test.asm @@ -1,6 +1,6 @@ ;**************************************************************************** ; -; Copyright (C) 2021,2022 John Winans +; Copyright (C) 2021,2022,2024 John Winans ; ; This library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Lesser General Public @@ -51,13 +51,7 @@ stacktop: equ 0 ld sp,stacktop - ; Initialize the CTC so that the SIO will have a baud clock if J11-A is set to the CTC! - ;ld c,1 ; 115200 bps - ld c,6 ; 19200 bps - call init_ctc_1 - - ; Init the SIO to run at 115200 or 19200 depending on J11-A - call sioa_init + call con_init ; Display a startup message ld hl,boot_msg @@ -225,19 +219,16 @@ test_cmd0_msg: - - include 'spi.asm' include 'hexdump.asm' -include 'sio.asm' -include 'ctc1.asm' +include 'console.asm' include 'puts.asm' ;############################################################################## ; This is a cache of the last written data to the gpio_out port. ; The initial value here is what is written to the latch during startup. ;############################################################################## -gpio_out_cache: db gpio_out_sd_mosi|gpio_out_sd_ssel|gpio_out_prn_stb +gpio_out_cache: db gpio_out_init ;##############################################################################