forked from MirrorRepos/RomWBW
Browse Source
A full implementation of UCSD p-System IV.0 for RomWBW. Derived from the official Z80 Adaptable p-System. My first real programming was on this system. So many memories...patch v3.1.1-pre.192
32 changed files with 1170 additions and 16 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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 |
|||
@ -0,0 +1,6 @@ |
|||
@echo off |
|||
setlocal |
|||
|
|||
if exist *.bin del *.bin |
|||
if exist *.lst del *.lst |
|||
if exist *.img del *.img |
|||
@ -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 |
|||
@ -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 |
|||
@ -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. <Track Offset> = 8MB * <Disk Number> |
|||
; 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 |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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 |
|||
@ -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 |
|||
Binary file not shown.
Loading…
Reference in new issue