diff --git a/Binary/ReadMe.txt b/Binary/ReadMe.txt index 6118199f..0021d0d3 100644 --- a/Binary/ReadMe.txt +++ b/Binary/ReadMe.txt @@ -75,8 +75,8 @@ The VDU video board requires a dedicated onboard ROM containing the font data. The "vdu.rom" file contains the binary data to program onto that chip. -Disk Images (fd_*.img, hd_*.img) ------------------------------- +Disk Images (fd_*.img, hd_*.img, psys.img) +------------------------------------------ RomWBW includes a mechanism for generating floppy disk and hard disk binary images that are ready to copy directly to a floppy, hard disk, @@ -96,16 +96,18 @@ RawWriteWin (as long as you have access to a floppy drive on your Windows computer). The resulting floppy disks will be usable on any RomWBW-based system with floppy drive(s). -Likewise, the hd_*.img files are hard disk images. Each file is -intended to be copied to the start of any type of hard disk media -(typically a CF Card or SD Card). The resulting media will be usable -on any RomWBW-based system that accepts the corresponding media type. +Likewise, the hd512_*.img and hd1024_*.img files are hard disk images. +Each file is intended to be copied to the start of any type of hard +disk media (typically a CF Card or SD Card). The resulting media will +be usable on any RomWBW-based system that accepts the corresponding +media type. -WARNING: The hdnew_*.img disk images are part of a new disk -format that is a work in progress. Do not use these disk -images without knowing exactly what you are doing! The -hd_*.img disk images continue to be the images you should -be using under normal circumstances. +NOTE: The hd512_*.img files are equivalent to the hd_*.img +files in previous distributions. The hd1024_*.img files +contained a revised file system format that increases the +maximum number of CP/M directory entries from 512 to 1024. +Refer to the ReadMe.txt in the Source/Images directory +for details. Documentation of the pre-built disk images is contained in the DiskList.txt file in this directory. @@ -115,6 +117,12 @@ the BuildImages.cmd script in the Source directory. Additional information on how to generate custom disk images is found in the Source\Images ReadMe.txt file. +The psys.img file contains a full implementation of the UCSD p-System +for the Z80 running under RomWBW. This image file must be placed on +disk media by itself (not appended or concatenated with hd*.img files. +Refer to the Source/pSys/ReadMe.txt file for more information on the +p-System implementation. + Propeller ROM Images (*.eeprom) ------------------------------- diff --git a/Doc/ChangeLog.txt b/Doc/ChangeLog.txt index f3fc30d2..44d037c0 100644 --- a/Doc/ChangeLog.txt +++ b/Doc/ChangeLog.txt @@ -67,6 +67,7 @@ Version 3.1.1 - LLS: Added a user defined mode for SD Card interfaces (not complete) - L?N: Updated ZDE to v1.8 including time stamp preservation fixes - D?M: Minor update to CP/NET client files, fix to CPNBOOT +- WBW: Added p-System IV.0 Z80 implementation Version 3.1 ----------- diff --git a/Doc/ROM Applications.pdf b/Doc/ROM Applications.pdf index 77dbe27a..cfd947b6 100644 Binary files a/Doc/ROM Applications.pdf and b/Doc/ROM Applications.pdf differ diff --git a/Doc/RomWBW Applications.pdf b/Doc/RomWBW Applications.pdf index 4c4f3a13..370de57c 100644 Binary files a/Doc/RomWBW Applications.pdf and b/Doc/RomWBW Applications.pdf differ diff --git a/Doc/RomWBW Architecture.pdf b/Doc/RomWBW Architecture.pdf index b1f981df..6fb56ef5 100644 Binary files a/Doc/RomWBW Architecture.pdf and b/Doc/RomWBW Architecture.pdf differ diff --git a/Doc/RomWBW Disk Catalog.pdf b/Doc/RomWBW Disk Catalog.pdf index ce658358..e1e9ad78 100644 Binary files a/Doc/RomWBW Disk Catalog.pdf and b/Doc/RomWBW Disk Catalog.pdf differ diff --git a/Doc/RomWBW Getting Started.pdf b/Doc/RomWBW Getting Started.pdf index 29f558e3..5e4bee5f 100644 Binary files a/Doc/RomWBW Getting Started.pdf and b/Doc/RomWBW Getting Started.pdf differ diff --git a/Doc/UCSD p-System Users Manual.pdf b/Doc/UCSD p-System Users Manual.pdf new file mode 100644 index 00000000..5affaf78 Binary files /dev/null and b/Doc/UCSD p-System Users Manual.pdf differ diff --git a/Doc/qcp27.pdf b/Doc/qcp27.pdf new file mode 100644 index 00000000..56f4996b Binary files /dev/null and b/Doc/qcp27.pdf differ diff --git a/Doc/qdos27.pdf b/Doc/qdos27.pdf new file mode 100644 index 00000000..10723a0c Binary files /dev/null and b/Doc/qdos27.pdf differ diff --git a/Doc/qpm27.pdf b/Doc/qpm27.pdf new file mode 100644 index 00000000..116b5c66 Binary files /dev/null and b/Doc/qpm27.pdf differ diff --git a/ReadMe.md b/ReadMe.md index da55ac1c..6988a610 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -3,7 +3,7 @@ ## Z80/Z180 System Software Version 3.1 Pre-release -01 Jan 2023 +13 Jan 2023 Wayne Warthen @@ -664,6 +664,11 @@ boot from disk as is. You do not need to run `SYSCOPY` on them to make them bootable. However, if you upgrade your ROM, you should use `SYSCOPY` to update the system tracks. +A full implementation of the UCSD p-System for Z80 under RomWBW is also +provided. This is a completely separate and standalone disk image called +psys.img. It contains 6 p-System filesystem slices, but these are not +interoperable with the CP/M slices described above. + ## Booting Disks When starting your system, following the hardware initialization, you @@ -845,6 +850,69 @@ tracks of the disk. I believe it was done this way to make it easier for users to transition from CP/M 3 to ZPM3. +## QPM + +QPM is another OS providing compatibility with and enhancements to CP/M +2.2. It is provided as bootable disk images for RomWBW. + +The following documentation files from the original QPM distribution are +included in the RomWBW Doc directory: + +- QP/M 2.7 Features and Facilities (qcp27.pdf) +- QP/M 2.7 Interface Guide (qdos27.pdf) +- QP/M 2.7 Installation Guide and Supplements (qpm27.pdf) + +Refer to the ReadMe.txt file in Source/Images/d_qpm for more details +regarding the RomWBW adaptation and customizations. + +### Notes + +- QPM is not available as source. This implementation was based on the + QPM binary distribution and has been minimally customized for RomWBW. + +- QINSTALL is used to customize QPM. It is included on the disk image. + You should review the notes in the ReadMe.txt file in + Source/Image/d_qpm before making changes. + +## UCSD p-System + +This is a full implementation of the UCSD p-System IV.0 for Z80 running +under RomWBW. Unlike the OSes above, p-System uses it’s own unique +filesystem and is not interoperable with other OSes. + +It was derived from the p-System Adaptable Z80 System. Unlike some other +distributions, this implements a native p-System Z80 BIOS, it does not +rely on a CP/M BIOS layer. + +The p-System is provided on a hard disk image file called psys.img. This +must be copied to it’s own dedicated hard disk media (CF Card, SD Card, +etc.). It is booted by selecting slices 0 of the corresponding hard disk +unit at the RomWBW Boot Loader prompt. + +The p-System Users Manual is included in the Doc directory of the +distribution as “UCSD p-System Users Manual.pdf”. + +Refer to the ReadMe.txt file in Source/pSys for more details. + +### Notes + +- There is no floppy support at this time. + +- The hard disk image contains 6 p-System slices which are assigned to + p-System unit numbers 4, 5, 9, 10, 11 which is standard for p-System. + Slices 0-5 are assigned sequentially to these p-System unit numbers + and it is not possible to reassign them. + +- p-System relies heavily on the use of a full screen terminal. This + implementation has been setup to expect an ANSI or DEC VT-100 terminal + or emulator. The screen output will be garbled if no such terminal or + emulator is used for console output. + +- There is no straightforward mechanism to move files in and out of + p-System. However, the .vol files in Source/pSys can be read and + modified by CiderPress. CiderPress is able to add and remove + individual files. + ## FreeRTOS Phillip Stevens has ported FreeRTOS to run under RomWBW. FreeRTOS is not diff --git a/ReadMe.txt b/ReadMe.txt index 6a7c7c8b..d1ed1570 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,6 +1,6 @@ RomWBW Getting Started Wayne Warthen (mailto:wwarthen@gmail.com) -01 Jan 2023 +13 Jan 2023 @@ -17,7 +17,7 @@ RomWBW Z80/Z180 System Software Version 3.1 Pre-release -01 Jan 2023 +13 Jan 2023 Wayne Warthen wwarthen@gmail.com @@ -736,6 +736,11 @@ boot from disk as is. You do not need to run SYSCOPY on them to make them bootable. However, if you upgrade your ROM, you should use SYSCOPY to update the system tracks. +A full implementation of the UCSD p-System for Z80 under RomWBW is also +provided. This is a completely separate and standalone disk image called +psys.img. It contains 6 p-System filesystem slices, but these are not +interoperable with the CP/M slices described above. + Booting Disks When starting your system, following the hardware initialization, you @@ -916,6 +921,70 @@ Notes distribution. I believe it was done this way to make it easier for users to transition from CP/M 3 to ZPM3. +QPM + +QPM is another OS providing compatibility with and enhancements to CP/M +2.2. It is provided as bootable disk images for RomWBW. + +The following documentation files from the original QPM distribution are +included in the RomWBW Doc directory: + +- QP/M 2.7 Features and Facilities (qcp27.pdf) +- QP/M 2.7 Interface Guide (qdos27.pdf) +- QP/M 2.7 Installation Guide and Supplements (qpm27.pdf) + +Refer to the ReadMe.txt file in Source/Images/d_qpm for more details +regarding the RomWBW adaptation and customizations. + +Notes + +- QPM is not available as source. This implementation was based on the + QPM binary distribution and has been minimally customized for + RomWBW. + +- QINSTALL is used to customize QPM. It is included on the disk image. + You should review the notes in the ReadMe.txt file in + Source/Image/d_qpm before making changes. + +UCSD p-System + +This is a full implementation of the UCSD p-System IV.0 for Z80 running +under RomWBW. Unlike the OSes above, p-System uses it’s own unique +filesystem and is not interoperable with other OSes. + +It was derived from the p-System Adaptable Z80 System. Unlike some other +distributions, this implements a native p-System Z80 BIOS, it does not +rely on a CP/M BIOS layer. + +The p-System is provided on a hard disk image file called psys.img. This +must be copied to it’s own dedicated hard disk media (CF Card, SD Card, +etc.). It is booted by selecting slices 0 of the corresponding hard disk +unit at the RomWBW Boot Loader prompt. + +The p-System Users Manual is included in the Doc directory of the +distribution as “UCSD p-System Users Manual.pdf”. + +Refer to the ReadMe.txt file in Source/pSys for more details. + +Notes + +- There is no floppy support at this time. + +- The hard disk image contains 6 p-System slices which are assigned to + p-System unit numbers 4, 5, 9, 10, 11 which is standard for + p-System. Slices 0-5 are assigned sequentially to these p-System + unit numbers and it is not possible to reassign them. + +- p-System relies heavily on the use of a full screen terminal. This + implementation has been setup to expect an ANSI or DEC VT-100 + terminal or emulator. The screen output will be garbled if no such + terminal or emulator is used for console output. + +- There is no straightforward mechanism to move files in and out of + p-System. However, the .vol files in Source/pSys can be read and + modified by CiderPress. CiderPress is able to add and remove + individual files. + FreeRTOS Phillip Stevens has ported FreeRTOS to run under RomWBW. FreeRTOS is not diff --git a/Source/BuildShared.cmd b/Source/BuildShared.cmd index ea9a7b10..8b7e0442 100644 --- a/Source/BuildShared.cmd +++ b/Source/BuildShared.cmd @@ -9,6 +9,7 @@ pushd ZCPR-DJ && call Build || exit /b & popd pushd ZSDOS && call Build || exit /b & popd pushd CPM3 && call Build || exit /b & popd pushd ZPM3 && call Build || exit /b & popd +pushd pSys && call Build || exit /b & popd pushd Apps && call Build || exit /b & popd pushd Forth && call Build || exit /b & popd pushd TastyBasic && call Build || exit /b & popd diff --git a/Source/Clean.cmd b/Source/Clean.cmd index 1af0deff..d3b69d40 100644 --- a/Source/Clean.cmd +++ b/Source/Clean.cmd @@ -10,6 +10,7 @@ pushd ZSDOS && call Clean.cmd & popd pushd CBIOS && call Clean.cmd & popd pushd CPM3 && call Clean.cmd & popd pushd ZPM3 && call Clean.cmd & popd +pushd pSys && call Clean.cmd & popd pushd Forth && call Clean.cmd & popd pushd TastyBasic && call Clean & popd pushd Fonts && call Clean.cmd & popd diff --git a/Source/Doc/GettingStarted.md b/Source/Doc/GettingStarted.md index 9554e4c8..d492f315 100644 --- a/Source/Doc/GettingStarted.md +++ b/Source/Doc/GettingStarted.md @@ -684,6 +684,11 @@ boot from disk as is. You do not need to run `SYSCOPY` on them to make them bootable. However, if you upgrade your ROM, you should use `SYSCOPY` to update the system tracks. +A full implementation of the UCSD p-System for Z80 under RomWBW is also +provided. This is a completely separate and standalone disk image +called psys.img. It contains 6 p-System filesystem slices, but these +are not interoperable with the CP/M slices described above. + ## Booting Disks When starting your system, following the hardware initialization, you @@ -869,6 +874,73 @@ which is confusing, but this is as intended by the ZPM3 distribution. I believe it was done this way to make it easier for users to transition from CP/M 3 to ZPM3. +## QPM + +QPM is another OS providing compatibility with and enhancements +to CP/M 2.2. It is provided as bootable disk images for RomWBW. + +The following documentation files from the original QPM distribution +are included in the RomWBW Doc directory: + + - QP/M 2.7 Features and Facilities (qcp27.pdf) + - QP/M 2.7 Interface Guide (qdos27.pdf) + - QP/M 2.7 Installation Guide and Supplements (qpm27.pdf) + +Refer to the ReadMe.txt file in Source/Images/d_qpm for more details +regarding the RomWBW adaptation and customizations. + +### Notes + +- QPM is not available as source. This implementation was based +on the QPM binary distribution and has been minimally customized +for RomWBW. + +- QINSTALL is used to customize QPM. It is included on the +disk image. You should review the notes in the ReadMe.txt +file in Source/Image/d_qpm before making changes. + +## UCSD p-System + +This is a full implementation of the UCSD p-System IV.0 for Z80 +running under RomWBW. Unlike the OSes above, p-System uses it's +own unique filesystem and is not interoperable with other OSes. + +It was derived from the p-System Adaptable Z80 System. Unlike +some other distributions, this implements a native p-System +Z80 BIOS, it does not rely on a CP/M BIOS layer. + +The p-System is provided on a hard disk image file called +psys.img. This must be copied to it's own dedicated hard +disk media (CF Card, SD Card, etc.). It is booted by +selecting slices 0 of the corresponding hard disk unit at +the RomWBW Boot Loader prompt. + +The p-System Users Manual is included in the Doc directory +of the distribution as "UCSD p-System Users Manual.pdf". + +Refer to the ReadMe.txt file in Source/pSys for more details. + +### Notes + +- There is no floppy support at this time. + +- The hard disk image contains 6 p-System slices which are +assigned to p-System unit numbers 4, 5, 9, 10, 11 which +is standard for p-System. Slices 0-5 are assigned +sequentially to these p-System unit numbers and it is +not possible to reassign them. + +- p-System relies heavily on the use of a full screen +terminal. This implementation has been setup to expect +an ANSI or DEC VT-100 terminal or emulator. The screen +output will be garbled if no such terminal or emulator +is used for console output. + +- There is no straightforward mechanism to move files in +and out of p-System. However, the .vol files in Source/pSys +can be read and modified by CiderPress. CiderPress is able +to add and remove individual files. + ## FreeRTOS Phillip Stevens has ported FreeRTOS to run under RomWBW. FreeRTOS is diff --git a/Source/Makefile b/Source/Makefile index d0dc7de1..b012323f 100644 --- a/Source/Makefile +++ b/Source/Makefile @@ -10,6 +10,7 @@ SUBDIRS += TastyBasic SUBDIRS += Fonts SUBDIRS += CPM22 ZCPR ZCPR-DJ ZSDOS CPM3 ZPM3 #SUBDIRS += BPBIOS +SUBDIRS += pSys SUBDIRS += RomDsk SUBDIRS += HBIOS SUBDIRS += Images diff --git a/Source/pSys/Build.cmd b/Source/pSys/Build.cmd new file mode 100644 index 00000000..f0c914c6 --- /dev/null +++ b/Source/pSys/Build.cmd @@ -0,0 +1,37 @@ +@echo off +setlocal + +set TOOLS=../../Tools + +set PATH=%TOOLS%\tasm32;%PATH% + +set TASMTABS=%TOOLS%\tasm32 + +echo. +echo Building p-System Loader for RomWBW... +echo. +tasm -t80 -g3 loader.asm loader.bin loader.lst || exit /b +if errorlevel 1 goto :eof + +echo. +echo Building p-System BIOS for RomWBW... +echo. +tasm -t80 -g3 bios.asm bios.bin bios.lst || exit /b +if errorlevel 1 goto :eof + +::echo. +::echo Creating p-System BIOS Tester boot image +::echo. +::copy /b loader.bin + bios.bin + biostest.dat psys.bin + +echo. +echo Generating p-System Boot Track... +echo. +copy /b loader.bin + bios.bin + boot.dat + fill.dat trk0.bin || exit /b + +echo. +echo Generating p-System Disk Image... +echo. +copy /b trk0.bin + psys.vol + trk0.bin + blank.vol psys.img || exit /b + +copy psys.img ..\..\Binary || exit /b \ No newline at end of file diff --git a/Source/pSys/Clean.cmd b/Source/pSys/Clean.cmd new file mode 100644 index 00000000..f9ed83d2 --- /dev/null +++ b/Source/pSys/Clean.cmd @@ -0,0 +1,6 @@ +@echo off +setlocal + +if exist *.bin del *.bin +if exist *.lst del *.lst +if exist *.img del *.img diff --git a/Source/pSys/Makefile b/Source/pSys/Makefile new file mode 100644 index 00000000..427470af --- /dev/null +++ b/Source/pSys/Makefile @@ -0,0 +1,11 @@ +OBJECTS = psys.img +TOOLS = ../../Tools +DEST = ../../Binary +OTHERS = *.bin *.lst *.img +include $(TOOLS)/Makefile.inc + +trk0.bin: loader.bin bios.bin boot.dat fill.dat + cat loader.bin bios.bin boot.dat fill.dat > trk0.bin + +psys.img: trk0.bin psys.vol blank.vol + cat trk0.bin psys.vol trk0.bin blank.vol > psys.img diff --git a/Source/pSys/ReadMe.txt b/Source/pSys/ReadMe.txt new file mode 100644 index 00000000..04d335a0 --- /dev/null +++ b/Source/pSys/ReadMe.txt @@ -0,0 +1,100 @@ +This directory contains a port of p-System IV.0 for RomWBW. + +It was derived from the p-System Adaptable Z80 System. Unlike +some other distributions, this implements a native p-System +Z80 BIOS, it does not use a CP/M BIOS layer. + +Files: + +loader.asm p-System primary loader for RomWBW +bios.asm p-System BIOS for RomWBW HBIOS source (TASM) +biostest.dat binary image of SBIOSTESTER +boot.dat binary image of p-System bootstrap +psys.vol first (boot) slice, all p-System dist files +blank.vol a generic blank p-System volume +fill.dat used to complete the track 0 build (see below) + +Notes: + +This adatation runs on a single RomWBWW HBIOS hard disk +type device (CF Cart, SD Card, IDE drive, etc.). The +image built (psys.img) should be copied to your disk media +start at the first sector. You can then boot by selecting +the corresponding disk device unit number from the RomWBW +boot loader prompt. The p-System disk image (psys.img) is +entirely different from the RomWBW CP/M-style disk images. + +The boot device hard disk is broken up into 6 logical +p-System volumes. These are referred to as p-System +slices. A single RomWBW disk device can contain either +CP/M-style slices or p-System slices, but not both. +Each p-System slices is exactly 8 MB and support for +exactly 6 slices is provided. + +The first track of each volume contains all of the code +required to boot the p-System. However, the assignment +of the volumes is always in the order that the slices +appear physically on the hard disk device. Normally, +you would just boot to slice 0 from the RomWBW Boot +Loader. + +The first track contains the following: + - 4 sector p-System primary loader for RomWBW HBIOS + - 1 sector p-System BIOS for RomWBW HBIOS + - 4 sector p-System bootstrap + - 7 sector filler to complete a full track + +The p-System bootstrap is a binary image provided in the +p-System distribution. The loader and the BIOS are +custom for RomWBW and the source is provided here. + +The layout of the first track does not conform exactly to +the recommended p-System layout. The recommended layout +is not possible because it conflicts with the RomWBW +definition for a boot track. However, the changes are +simply slilghtly different sector assignments for the +different boot componets -- the general boot sequence +and mechanism for the p-System is completely standard. + +The logical disk geometry used by this p-System +adaptation is: + - 512 byte sector length + - 16 sectors per track + - 192 tracks per disk + +This layout does not occupy the full 8MB slice size +allocated. This is to allow for future expansion of +the filesystems. + +The p-System distribution includes a BIOS tester that +is provided as a binary image. This tester was used +to test the BIOS code in this adaptation. Note that +the tester fails for the BIOS as is. After a lot of +code tracing, a definite bug was identified in the +tester that exists for 512 byte sectors (which are +supported). When the BIOS is modified to use 128 or +256 byte sectors, the tester completes perfectly. +Significant use of the BIOS shows there are no issues +for a normal running system with 512 byte sectors. + +The boot disk provided here was constructed by simply +copying all of the content from the p-System distribution +disks onto the boot disk. SYSTEM.MISCINFO was updated +for an ANSI terminal. The GOTOXY routine in +SYSTEM.PASCAL was also updated for an ANSI terminal. +Note that the BIOS conwrit routine is hacked to add +a '[' to any output escape character. This is needed +because p-System has limited terminal escape sequence +handling configuration. + +At this time, there is no straightforward way to move +files in and out of the p-System volumes. There are +ways to do this, but they are complicated. Please +contact me if you are interested. + +There is currently no support for floppy drives. + +Wayne Warthen +wwarthen@gmail.com + +3:13 PM Thursday, January 12, 2023 \ No newline at end of file diff --git a/Source/pSys/bios.asm b/Source/pSys/bios.asm new file mode 100644 index 00000000..f7107b69 --- /dev/null +++ b/Source/pSys/bios.asm @@ -0,0 +1,371 @@ +; +;----------------------------------------------------------------------- +; p-System BIOS for RomWBW HBIOS +; +;----------------------------------------------------------------------- +; +; 3:46 PM 1/13/2023 - WBW - Initial release +; +; TODO: +; +; - Assign the HBIOS console device to the p-System console instead +; of just using a hard-coded reference to Serial Unit 0. +; +; - Implement Extended BIOS. +; + +#include "../ver.inc" +; +#include "psys.inc" +; +#include "../HBIOS/hbios.inc" +; +; IORESULT values +; +ior_ok .equ 0 ; No error +ior_badblk .equ 1 ; Bad block, CRC error (parity) +ior_baddev .equ 2 ; Bad device number +ior_badio .equ 3 ; Illegal I/O request +ior_timout .equ 4 ; Data-com timeout +ior_offlin .equ 5 ; Volume is no longer on-line +ior_nofile .equ 6 ; File is no longer in directory +ior_filnamerr .equ 7 ; Illegal file name +ior_full .equ 8 ; No room; insufficient space on disk +ior_novol .equ 9 ; No such volume on-line +ior_notfnd .equ 10 ; No such file name in directory +ior_dupfil .equ 11 ; Duplicate file +ior_notclos .equ 12 ; Not closed: attempt to open an open file +ior_notopen .equ 13 ; Not open: attempt to access a closed file +ior_badfmt .equ 14 ; Bad format: error reading real or integer +ior_bufovr .equ 15 ; Ring buffer overflow +ior_diskwp .equ 16 ; Write attempt to protected disk +ior_blknumerr .equ 17 ; Illegal block number +ior_bufadrerr .equ 18 ; Illegal buffer address +ior_badsiz .equ 19 ; Bad text file size +; +; +; + .org bios_loc +; + ; Simple BIOS vectors + jp sysinit ; 0: Initialize machine + jp syshalt ; 1: Exit UCSD Pascal + jp coninit ; 2: Console initialize + jp constat ; 3: Console status + jp conread ; 4: Console input + jp conwrit ; 5: Console output + jp setdisk ; 6: Set disk number + jp settrak ; 7: Set track number + jp setsect ; 8: Set sector number + jp setbufr ; 9: Set buffer address + jp dskread ; 10: Read sector from disk + jp dskwrit ; 11: Write sector to disk + jp dskinit ; 12: Reset disk + jp dskstrt ; 13: Activate disk + jp dskstop ; 14: De-activate disk +; + ; Extended BIOS vectors + jp panic ; 15: Extended BIOS vector + jp panic ; 16: Extended BIOS vector + jp panic ; 17: Extended BIOS vector + jp panic ; 18: Extended BIOS vector + jp panic ; 19: Extended BIOS vector + jp panic ; 20: Extended BIOS vector + jp panic ; 21: Extended BIOS vector + jp panic ; 22: Extended BIOS vector + jp panic ; 23: Extended BIOS vector + jp panic ; 24: Extended BIOS vector + jp panic ; 25: Extended BIOS vector + jp panic ; 26: Extended BIOS vector + jp panic ; 27: Extended BIOS vector +; +; +; +sysinit: + ;ld a,0 + ;jp panic + + ld hl,str_banner + call prtstr + call conread + + ld b,BF_SYSGET ; HBIOS SysGet function + ld c,BF_SYSGET_BOOTINFO ; BootInfo sub-function + rst 08 ; do it, boot disk device unit in + ld a,d ; boot unit id returned in D + ld (hb_dev),a ; save for disk I/O + + ; sysinit is being called twice during startup. Once from + ; the bootstrap and then from the interpreter. So, we + ; remap the vector here to avoid doing the above stuff + ; multiple times. + ld hl,sysinit1 ; re-vector to sysinit1 + ld (bios_loc+1),hl ; update the jump table + +sysinit1: + xor a ; signal success + ret ; done + +syshalt: + ;ld a,1 + ;jp panic + + ; The syshalt vector does not seem be to invoked when + ; selecting the Halt option from the p-System menu. + ; I have no idea why. + ld b,BF_SYSRESET ; HBIOS reset function + ld c,BF_SYSRES_WARM ; warm reset is fine + rst 08 ; do it + + ; we should never get here + di ; interrupts off + halt ; ... and die + + +coninit: + ;ld a,2 + ;jp panic + + xor a ; signal success + ret ; done + +constat: + ;ld a,3 + ;jp panic + + ld b,BF_CIOIST ; serial port status function + ld c,0 ; port 0 + rst 08 ; call HBIOS + ld c,0 ; assume no chars pendin + jr z,constat1 ; if zero, no chars waiting + ld c,$FF ; signal char(s) pending +constat1: + xor a ; signal success + ret ; done + +conread: + ;ld a,4 + ;jp panic + + ld b,BF_CIOIN ; serial port read function + ld c,0 ; port 0 + rst 08 ; call HBIOS + ld c,e ; char to C + xor a ; signal success + ret ; done + +conwrit: + ;ld a,5 + ;jp panic + + ld a,c + cp 27 ; escape? + jr nz,conwrit1 ; if not, handle normally + call conwrit1 ; else, send escape + ld c,'[' ; ... followed by '[' for ANSI +conwrit1: + ld e,c ; char to write to E + ld b,BF_CIOOUT ; serial port write function + ld c,0 ; port 0 + rst 08 ; call HBIOS + xor a ; signal success + ret ; done + +setdisk: + ;ld a,6 + ;jp panic + + ld a,c ; disk number to A + ld (curdisk),a ; save for later + xor a ; signal success + ret ; done + +settrak: + ;ld a,7 + ;jp panic + + ld a,c ; track number to A + ld (curtrak),a ; save for later + xor a ; signal success + ret ; done + +setsect: + ;ld a,8 + ;jp panic + + ld a,c ; sector number to A + dec a ; from 1 indexed to 0 indexed + ld (cursect),a ; save for later + xor a ; signal success + ret + +setbufr: + ;ld a,9 + ;jp panic + + ld (curbufr),bc ; save buf adr for later + xor a ; signal success + ret ; done + +dskread: + ;ld a,10 + ;jp panic + + ;ld a,(curdisk) + ;cp 0 + ;jr nz,dskinit1 + + call chkdisk + ret nz + + call seek + ret nz + + ld b,BF_DIOREAD ; HBIOS disk read function + ld a,(hb_dev) ; HBIOS disk unit + ld c,a ; ... goes in C + ld a,(HB_CURBNK) ; get current memory bank + ld d,a ; use as target bank for transfer + ld e,1 ; read 1 sector + ld hl,(curbufr) ; disk read buffer adr + rst 08 ; do it + ret z ; return if good read + ld a,ior_badblk ; else i/o error + ret ; done + +dskwrit: + ;ld a,11 + ;jp panic + + call chkdisk + ret nz + + call seek + ret nz + + ld b,BF_DIOWRITE ; HBIOS disk read function + ld a,(hb_dev) ; HBIOS disk unit + ld c,a ; ... goes in C + ld a,(HB_CURBNK) ; get current memory bank + ld d,a ; use as target bank for transfer + ld e,1 ; read 1 sector + ld hl,(curbufr) ; disk read buffer adr + rst 08 ; do it + ret z ; return if good read + ld a,ior_badblk ; else i/o error + ret ; done + +dskinit: + ;ld a,12 + ;jp panic + + call chkdisk + ret nz + + xor a ; signal success + ret ; done + +dskstrt: + ;ld a,13 + ;jp panic + + xor a ; signal success + ret ; done + +dskstop: + ;ld a,14 + ;jp panic + + xor a ; signal success + ret ; done + +chkdisk: + ; Validate that curdisk is <= max supported + ld a,(curdisk) ; get current disk + cp disks ; compare to disk count + jr nc,chkdisk1 ; if too high, go to err + xor a ; signal success + ret ; done +chkdisk1: + ld a,ior_novol ; signal not online + or a + ret + +seek: + ; A single physical HBIOS disk device will contain p-System + ; volume slices. Each slice will be 8MB. Start by computing + ; a track offset using the p-System disk number as an + ; index. = 8MB * + ; A track contains 0x20000 bytes: + ; 512 (bytes per sec) * 16 (sec per trk) * 16 (hds per cyl) + ; So, 8MB / 0x20000 = 0x40 tracks + ld hl,0 ; starting unit track offset + ld de,$0040 ; per disk track offset + ld a,(curdisk) ; get current disk + or a ; set flags + jr z,seek2 ; disk 0 needs no offset + ld b,a ; into B for loop counter +seek1: + add hl,de ; add another offset + djnz seek1 ; and loop as needed +seek2: + push hl ; save total track offset + ld a,(curtrak) ; get current track value + push af ; save track value + and $0F ; head is low 4 bits of track + ld d,a ; save in D for head + pop af ; recover original track value + rra ; rotate to remove head bits + rra + rra + rra + and $0F ; mask off other bits + ld l,a ; save in low byte of HL + ld h,0 ; zero out high byte of HL + ld a,(cursect) ; get sector + ld e,a ; put in E + pop bc + add hl,bc ; add track offset + ld b,BF_DIOSEEK ; HBIOS seek function + ld a,(hb_dev) ; HBIOS disk unit + ld c,a ; ... goes in C + rst 08 ; do it + ret z ; if no error, done + ld a,ior_badblk ; signal I/O error + ret ; done + +prtstr: + ld a,(hl) + or a + ret z + push hl + ld c,a + call conwrit + pop hl + inc hl + jr prtstr + + +panic: + di + halt + + +hb_dev .db 3 ; HBIOS disk device unit +; +curdisk .db 0 ; Current disk number +curtrak .db 0 ; Current track number +cursect .db 0 ; Current sector number +curbufr .dw 0 ; Current disk buffer address +; +str_banner .db 13,10,"RomWBW p-System BIOS v" + .db BIOSVER + .db 13,10,13,10 + .db "Press any key...",0 +; +; +; + .fill bios_end - $ + +; + .end diff --git a/Source/pSys/biostest.dat b/Source/pSys/biostest.dat new file mode 100644 index 00000000..b1b0f82a Binary files /dev/null and b/Source/pSys/biostest.dat differ diff --git a/Source/pSys/blank.vol b/Source/pSys/blank.vol new file mode 100644 index 00000000..67df0994 Binary files /dev/null and b/Source/pSys/blank.vol differ diff --git a/Source/pSys/boot.dat b/Source/pSys/boot.dat new file mode 100644 index 00000000..a23b59a5 Binary files /dev/null and b/Source/pSys/boot.dat differ diff --git a/Source/pSys/fill.dat b/Source/pSys/fill.dat new file mode 100644 index 00000000..3f8cdec5 Binary files /dev/null and b/Source/pSys/fill.dat differ diff --git a/Source/pSys/loader.asm b/Source/pSys/loader.asm new file mode 100644 index 00000000..b03cf965 --- /dev/null +++ b/Source/pSys/loader.asm @@ -0,0 +1,375 @@ +;=============================================================================== +; LOADER.ASM +; +; BOOTLOADER FOR ROMWBW PSYSTEM +; +; CP/M DISK FORMATS ALLOW FOR RESERVED TRACKS THAT CONTAIN AN IMAGE OF THE +; OPERATING SYSTEM TO BE LOADED WHEN THE DISK IS BOOTED. THE OPERATING SYSTEM +; IMAGE ITSELF IS NORMALLY PREFIXED BY A 1-N SECTORS CONTAINING OS BOOTSTRAP +; CODE AND DISK METADATA. +; +; THE RETROBREW COMPUTING GROUP HAS BEEN USING A CONVENTION OF PREFIXING THE +; OS IMAGE WITH 3 SECTORS (512 BYTES X 3 FOR A TOTAL OF 1536 BYTES): +; +; SECTOR 1: IBM-PC STYLE BOOT BLOCK CONTAINING BOOTSTRAP, +; PARTITION TABLE, AND BOOT SIGNATURE +; SECTOR 2: RESERVED +; SECTOR 3: METADATA +; +; THE HARDWARE BIOS IS EXPECTED TO READ AND LOAD THE FIRST TWO SECTORS FROM THE +; DISK TO MEMORY ADDRESS $8000 AND JUMP TO THAT LOCATION TO BEGIN THE BOOT +; PROCESS. THE BIOS IS EXPECTED TO VERIFY THAT A STANDARD BOOT SIGNATURE +; OF $55, $AA IS PRESENT AT OFFSET $1FE-$1FF. IF THE SIGNATURE IS NOT FOUND, +; THE BIOS SHOULD ASSUME THE DISK HAS NOT BEEN PROPERLY INITIALIZED AND SHOULD +; NOT JUMP TO THE LOAD ADDRESS. +; +;=============================================================================== +; +#INCLUDE "../ver.inc" +; +#INCLUDE "psys.inc" +; +SYS_ENT .EQU $0100 ; SYSTEM (OS) ENTRY POINT ADDRESS +SYS_LOC .EQU $0100 ; STARTING ADDRESS TO LOAD SYSTEM IMAGE +SYS_END .EQU $0100 + loader_size + bios_size + boot_size ; ENDING ADDRESS OF SYSTEM IMAGE +; +SEC_SIZE .EQU 512 ; DISK SECTOR SIZE +BLK_SIZE .EQU 128 ; OS BLOCK/RECORD SIZE +; +PREFIX_SIZE .EQU (SEC_SIZE * 3) ; 3 SECTORS +; +META_SIZE .EQU 32 ; SEE BELOW +META_LOC .EQU (PREFIX_SIZE - META_SIZE) +; +PT_LOC .EQU $1BE +PT_SIZ .EQU $40 +; + .ORG 0 +; +;------------------------------------------------------------------------------- +; SECTOR 1 +; +; THIS SECTOR FOLLOWS THE CONVENTIONS OF AN IBM-PC MBR CONTAINING THE OS +; BOOTSTRAP CODE, PARTITION TABLE, AND BOOT SIGNATURE +; +;---------------------------------------------------------------------------- +; + .FILL PT_LOC - $,0 ; FILL TO START OF PARTITION TABLE +; +; RESERVE SPACE FOR STANDARD IBM-PC PARTITION TABLE. ALTHOUGH A +; PARTITION TABLE IS NOT RELEVANT FOR A FLOPPY DISK, IT DOES NO HARM. +; THE CONTENTS OF THE PARTITION TABLE MUST BE MANAGED BY FDISK80. +; +PARTTBL .FILL PT_SIZ,0 ; PARTITION TABLE, FILL WITH ZEROES +; +; THE END OF THE FIRST SECTOR MUST CONTAIN THE TWO BYTE BOOT SIGNATURE. +; +BOOTSIG .DB $55,$AA ; STANDARD BOOT SIGNATURE +; +;------------------------------------------------------------------------------- +; SECTOR 2 +; +; THIS SECTOR HAS NOT BEEN DEFINED AND IS RESERVED. +; +;---------------------------------------------------------------------------- +; + .FILL SEC_SIZE,0 ; JUST FILL SECTOR WITH ZEROES +; +;------------------------------------------------------------------------------- +; SECTOR 3 +; +; OS AND DISK METADATA +; +;---------------------------------------------------------------------------- +; + .FILL (BLK_SIZE * 3),0 ; FIRST 384 BYTES ARE NOT YET DEFINED +; +; THE FOLLOWING TWO BYTES ARE AN ADDITIONAL SIGNATURE THAT IS VERIFIED BY +; SOME HARDWARE BIOSES. +; +PR_SIG .DB $5A,$A5 ; SIGNATURE GOES HERE +; + .FILL (META_LOC - $),0 +; +; METADATA +; +PR_WP .DB 0 ; (1) WRITE PROTECT BOOLEAN +PR_UPDSEQ .DW 0 ; (2) PREFIX UPDATE SEQUENCE NUMBER (DEPRECATED?) +PR_VER .DB RMJ,RMN,RUP,RTP ; (4) OS BUILD VERSION +PR_LABEL .DB "Unlabeled$$$$$$$","$" ; (17) DISK LABEL (EXACTLY 16 BYTES!!!) + .DW 0 ; (2) DEPRECATED +PR_LDLOC .DW SYS_LOC ; (2) ADDRESS TO START LOADING SYSTEM +PR_LDEND .DW SYS_END ; (2) ADDRESS TO STOP LOADING SYSTEM +PR_ENTRY .DW SYS_ENT ; (2) ADDRESS TO ENTER SYSTEM (OS) +; +#IF (META_SIZE != ($ - META_LOC)) + .ECHO "META_SIZE VALUE IS WRONG!!!\r\n" + !!! +#ENDIF +; +#IF ($ != PREFIX_SIZE) + .ECHO "LOADER PREFIX IS WRONG SIZE!!!\r\n" + !!! +#ENDIF +; +;------------------------------------------------------------------------------- +; SECTOR 4+ +; +; PSYSTEM LOADER +; - LOAD SBIOS TO HIGH MEMORY (JUST BELOW HBIOS PROXY) +; - LOAD PSYSTEM BOOTSTRAP & JUMP TO IT +; +;---------------------------------------------------------------------------- +; +#include "../HBIOS/hbios.inc" +; +; +bel .equ 7 ; ASCII bell +bs .equ 8 ; ASCII backspace +lf .equ 10 ; ASCII linefeed +cr .equ 13 ; ASCII carriage return +; +interp_base .equ $0100 ; first loc used by the interpreter +low_memory .equ $0100 ; lowest available ram location +interleave .equ 1 ; interleaving factor (n:1) +first_track .equ 1 ; first interleaved track +skew .equ 0 ; track-to-track skew +; +; +; + .org loader_loc +; + ld sp,stack ; setup private stack +; + call nl2 ; formatting + ld hl,str_banner ; display boot banner + call pstr ; do it +; +; Copy BIOS to running location +; + ld hl,loader_end ; BIOS image is at end of loader + ld de,bios_loc ; BIOS execution location + ld bc,bios_size ; Size of BIOS + ldir ; do it +; +; Copy p-System bootstrap to running location +; + ld hl,loader_end + bios_size ; bootstrap appended after BIOS + ld de,boot_loc ; bootstrap runs here + ld bc,boot_size ; size of bootstrap code + ldir ; do it +; +; Print some interesting info +; + call nl2 ; spacing + ld hl,str_info ; info string + call pstr ; print it + ld bc,bios_loc ; bios location adr + call prthexword ; print it + ld hl,str_info2 ; additional info string + call pstr ; print it + ld bc,boot_loc ; bootstrap location adr + call prthexword ; print it + call nl2 ; spacing +; +; Push key values onto the stack +; + ld hl,seclen ; maximum number of bytes per sector + push hl + ld hl,sectors ; maximum number of sectors in table + push hl + ld hl,skew ; track-to-track skew + push hl + ld hl,first_track ; first interleaved track + push hl + ld hl,interleave ; interleaving factor + push hl + ld hl,seclen ; bytes per sector + push hl + ld hl,sectors ; sectors per track + push hl + ld hl,tracks ; tracks per disk + push hl + ld hl,bios_loc-2 ; top word of available ram - sbios address-2 + push hl + ld hl,low_memory ; bottom word of available ram + push hl + ld hl,bios_loc ; address of BIOS (start of jump table) + push hl + ld hl,interp_base ; starting address of the interpreter + push hl +#if testbios + ;ld hl,disks-1 ; maximum (highest) disk drive number + ;push hl +#endif +; + jp boot_loc ; jump to bootloader +; + ret +; +; +; Print string at HL on console, null terminated +; +pstr: + ld a,(hl) ; get next character + or a ; set flags + inc hl ; bump pointer regardless + ret z ; done if null + call cout ; display character + jr pstr ; loop till done +; +; Print volume label string at HL, '$' terminated, 16 chars max +; +pvol: + ld b,16 ; init max char downcounter +pvol1: + ld a,(hl) ; get next character + cp '$' ; set flags + inc hl ; bump pointer regardless + ret z ; done if null + call cout ; display character + djnz pvol1 ; loop till done + ret ; hit max of 16 chars +; +; Start a newline on console (cr/lf) +; +nl2: + call nl ; double newline +nl: + ld a,cr ; cr + call cout ; send it + ld a,lf ; lf + jp cout ; send it and return +; +; Print a dot on console +; +pdot: + push af + ld a,'.' + call cout + pop af + ret +; +; Print the hex byte value in A +; +prthexbyte: + push af + push de + call hexascii + ld a,d + call cout + ld a,e + call cout + pop de + pop af + ret +; +; Print the hex word value in BC +; +prthexword: + push af + ld a,b + call prthexbyte + ld a,c + call prthexbyte + pop af + ret +; +; Convert binary value in A to ASCII hex characters in DE +; +hexascii: + ld d,a + call hexconv + ld e,a + ld a,d + rlca + rlca + rlca + rlca + call hexconv + ld d,a + ret +; +; Convert low nibble of A to ASCII hex +; +hexconv: + and 0Fh ; low nibble only + add a,90h + daa + adc a,40h + daa + ret +; +; Output character from A +; +cout: + ; Save all incoming registers + push af + push bc + push de + push hl +; + ; Output character to console via HBIOS + ld e,a ; output char to E + ld c,CIO_CONSOLE ; console unit to C + ld b,BF_CIOOUT ; HBIOS func: output char + rst 08 ; HBIOS outputs character +; + ; Restore all registers + pop hl + pop de + pop bc + pop af + ret +; +; Input character to A +; +cin: + ; Save incoming registers (AF is output) + push bc + push de + push hl +; + ; Input character from console via hbios + ld c,CIO_CONSOLE ; console unit to c + ld b,BF_CIOIN ; HBIOS func: input char + rst 08 ; HBIOS reads character + ld a,e ; move character to A for return +; + ; Restore registers (AF is output) + pop hl + pop de + pop bc + ret +; +; Return input status in A (0 = no char, != 0 char waiting) +; +cst: + ; Save incoming registers (AF is output) + push bc + push de + push hl +; + ; Get console input status via HBIOS + ld c,CIO_CONSOLE ; console unit to C + ld b,BF_CIOIST ; HBIOS func: input status + rst 08 ; HBIOS returns status in A +; + ; Restore registers (AF is output) + pop hl + pop de + pop bc + ret +; +str_banner .db "RomWBW HBIOS p-System Loader v" + .db BIOSVER + .db 0 +str_info .db "Loading pSystem BIOS @ 0x",0 +str_info2 .db ", Bootstrap @ 0x",0 +; + .fill 32,0 +stack .equ $ +; + .fill loader_end - $ +; + .end diff --git a/Source/pSys/psys.inc b/Source/pSys/psys.inc new file mode 100644 index 00000000..44039ede --- /dev/null +++ b/Source/pSys/psys.inc @@ -0,0 +1,32 @@ +testbios .equ 0 +; +; p-System Loader +; +loader_size .equ $200 +loader_loc .equ $100 +loader_end .equ loader_loc + loader_size +; +; p-System BIOS +; +bios_size .equ $200 +bios_loc .equ $FE00 - bios_size +bios_end .equ bios_loc + bios_size +; +; p-System Bootstrap +; +#if testbios +boot_size .equ $300 +boot_loc .equ $8000 +boot_end .equ boot_loc + boot_size +#else +boot_size .equ $800 +boot_loc .equ $8200 +boot_end .equ boot_loc + boot_size +#endif +; +; Disk geometry +; +seclen .equ 512 ; bytes per sector +sectors .equ 16 ; sectors per track +tracks .equ 192 ; tracks per disk +disks .equ 6 ; number of pSystem disk devices diff --git a/Source/pSys/psys.vol b/Source/pSys/psys.vol new file mode 100644 index 00000000..f6baa181 Binary files /dev/null and b/Source/pSys/psys.vol differ diff --git a/Source/ver.inc b/Source/ver.inc index 04683e23..ca8935b0 100644 --- a/Source/ver.inc +++ b/Source/ver.inc @@ -2,4 +2,4 @@ #DEFINE RMN 1 #DEFINE RUP 1 #DEFINE RTP 0 -#DEFINE BIOSVER "3.1.1-pre.191" +#DEFINE BIOSVER "3.1.1-pre.192" diff --git a/Source/ver.lib b/Source/ver.lib index 1974dabc..81ca464a 100644 --- a/Source/ver.lib +++ b/Source/ver.lib @@ -3,5 +3,5 @@ rmn equ 1 rup equ 1 rtp equ 0 biosver macro - db "3.1.1-pre.191" + db "3.1.1-pre.192" endm diff --git a/Tools/simh/Sim.cfg b/Tools/simh/Sim.cfg index dc1e25ab..b21c037d 100644 --- a/Tools/simh/Sim.cfg +++ b/Tools/simh/Sim.cfg @@ -24,6 +24,7 @@ attach n8vem0 %1 ; hard disks ;set hdsk debug=read;write;verbose attach hdsk0 ..\..\Binary\hd512_combo.img +;attach hdsk0 ..\..\Binary\psys.img attach hdsk1 ..\..\Binary\hd1024_combo.img set hdsk0 format=HDSK set hdsk1 format=HDSK