From bc9d44b4769c53fd4c2affdd8926ebb9168b6d02 Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Thu, 20 Feb 2020 17:17:44 -0800 Subject: [PATCH] Multi-boot fixes --- Doc/ChangeLog.txt | 1 + ReadMe.txt | 2 +- Source/Apps/OSLdr.asm | 15 +++-- Source/CBIOS/cbios.asm | 93 ++++++++++++++++++++++------ Source/CBIOS/ver.inc | 2 +- Source/CPM22/ver.inc | 2 +- Source/CPM3/biosldr.z80 | 25 ++++++-- Source/CPM3/boot.z80 | 131 ++++++++++++++-------------------------- Source/CPM3/diskio.z80 | 30 ++++----- Source/CPM3/ver.inc | 2 +- Source/HBIOS/ver.inc | 2 +- Source/ZSDOS/ver.inc | 2 +- 12 files changed, 169 insertions(+), 138 deletions(-) diff --git a/Doc/ChangeLog.txt b/Doc/ChangeLog.txt index 32bf83b9..c6697e08 100644 --- a/Doc/ChangeLog.txt +++ b/Doc/ChangeLog.txt @@ -49,6 +49,7 @@ Version 2.9.2 - PMS: Added "user" rom module template - PMS: Added CP/M 3 manuals - WBW: Boot from any slice +- C?M: Added Unix build process Version 2.9.1 ------------- diff --git a/ReadMe.txt b/ReadMe.txt index 98e06e8c..4fab1c64 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -7,7 +7,7 @@ *********************************************************************** Wayne Warthen (wwarthen@gmail.com) -Version 2.9.2-pre.31, 2020-02-18 +Version 2.9.2-pre.32, 2020-02-20 https://www.retrobrewcomputers.org/ RomWBW is a ROM-based implementation of CP/M-80 2.2 and Z-System for diff --git a/Source/Apps/OSLdr.asm b/Source/Apps/OSLdr.asm index 4ca2973f..15037790 100644 --- a/Source/Apps/OSLdr.asm +++ b/Source/Apps/OSLdr.asm @@ -58,6 +58,9 @@ ; could occur if the BIOS image does not conform to the ; expected structure (size, meta data location, entry point ; location, etc.) +; 3) Hardware platform has been removed from the bootloader, so the +; platform check has been removed for OS loading. This is fine +; unless you attempt to switch between UNA and RomWBW. ;_______________________________________________________________________________ ; ;=============================================================================== @@ -476,11 +479,11 @@ chkos: ; check for signature ; Already verified in chkhdr - ; compare platform id - ld a,(bioplt) ; get current HBIOS platform ID - ld hl,osplt ; point to OS image platform ID - cp (hl) ; compare - jp nz,errplt ; if not equal platform error + ;; compare platform id + ;ld a,(bioplt) ; get current HBIOS platform ID + ;ld hl,osplt ; point to OS image platform ID + ;cp (hl) ; compare + ;jp nz,errplt ; if not equal platform error ; bypass version check if UNA running ld a,(unamod) ; get UNA mode flag @@ -991,7 +994,7 @@ bufptr .dw 0 ; active pointer into buffer ; ; Messages ; -msgban .db "OSLDR v1.1 for RomWBW, 16-Jan-2018",0 +msgban .db "OSLDR v1.2 for RomWBW, 20-Feb-2020",0 msghb .db " (HBIOS Mode)",0 msgub .db " (UBIOS Mode)",0 msguse .db "Usage: OSLDR [/F] []\r\n" diff --git a/Source/CBIOS/cbios.asm b/Source/CBIOS/cbios.asm index 737280ce..d3e1cf27 100644 --- a/Source/CBIOS/cbios.asm +++ b/Source/CBIOS/cbios.asm @@ -1886,10 +1886,6 @@ INIT: LD A,DEF_IOBYTE ; LOAD DEFAULT IOBYTE LD (IOBYTE),A ; STORE IT - ; INIT DEFAULT DRIVE TO A: FOR NOW - XOR A ; ZERO - LD (DEFDRIVE),A ; STORE IT - ; CBIOS BANNER CALL NEWLINE2 ; FORMATTING LD DE,STR_BANNER ; POINT TO BANNER @@ -1998,23 +1994,49 @@ AUTOSUB: ; ; SETUP AUTO SUBMIT COMMAND (IF REQUIRED FILES EXIST) LD A,(DEFDRIVE) ; GET DEFAULT DRIVE + + ;CALL PRTHEXBYTE + + PUSH AF + INC A ; CONVERT FROM DRIVE NUM TO FCB DRIVE CODE LD (FCB_SUB),A ; SET DRIVE OF SUBMIT.COM FCB LD (FCB_PRO),A ; SET DRIVE OF PROFILE.SUB FCB +; + LD C,13 ; RESET DISK SYSTEM + CALL BDOS + + ;CALL PC_PERIOD + + POP AF +; + ;DEC A ; BACK TO ZERO INDEX + + ;LD E,A ; PUT IN E + ;LD C,14 ; SELECT DISK FUNCTION + ;CALL BDOS ; DO IT + + ;CALL PC_PERIOD ; LD C,17 ; BDOS FUNCTION: FIND FIRST LD DE,FCB_SUB ; CHECK FOR SUBMIT.COM CALL BDOS ; INVOKE BDOS TO LOOK FOR FILE + + ;CALL PRTHEXBYTE + INC A ; CHECK FOR ERR, $FF --> $00 RET Z ; ERR, DO NOT ATTEMPT AUTO SUBMIT ; LD C,17 ; BDOS FUNCTION: FIND FIRST LD DE,FCB_PRO ; CHECK FOR PROFILE.SUB CALL BDOS ; INVOKE BDOS TO LOOK FOR FILE + + ;CALL PRTHEXBYTE + INC A ; CHECK FOR ERR, $FF --> $00 RET Z ; ERR, DO NOT ATTEMPT AUTO SUBMIT ; - LD HL,CMD ; ADDRESS OF STARTUP COMMANDs + LD HL,CMD ; ADDRESS OF STARTUP COMMANDS LD DE,CCP_LOC + 7 ; START OF COMMAND BUFFER IN CCP LD BC,CMDLEN ; LENGTH OF AUTOSTART COMMAND LDIR ; PATCH COMMAND LINE INTO CCP @@ -2273,6 +2295,9 @@ CLRRAM3: #IFDEF PLTUNA ; DRV_INIT: + ; INIT DEFAULT DRIVE TO A: FOR NOW + XOR A ; ZERO + LD (DEFDRIVE),A ; STORE IT ; ; PERFORM UBIOS SPECIFIC INITIALIZATION ; BUILD DRVMAP BASED ON AVAILABLE UBIOS DISK DEVICE LIST @@ -2391,6 +2416,14 @@ DRV_INIT: ; GET BOOT UNIT/SLICE INFO LD DE,(HCB + HCB_BOOTVOL) ; BOOT VOLUME (UNIT, SLICE) LD (BOOTVOL),DE ; D -> UNIT, E -> SLICE +; + ; INIT DEFAULT + LD A,D ; BOOT UNIT? + CP 1 ; IF ROM BOOT, DEF DRIVE SHOULD BE B: + JR Z,DRV_INIT1 ; ... SO LEAVE AS IS AND SKIP AHEAD + XOR A ; ELSE FORCE TO DRIVE A: +DRV_INIT1: + LD (DEFDRIVE),A ; STORE IT ; ; SETUP THE DRVMAP STRUCTURE LD HL,(HEAPTOP) ; GET CURRENT HEAP TOP @@ -2502,6 +2535,14 @@ DRV_INIT5: ; LD B,E ; COUNT TO B ; LD C,0 ; USE C AS DEVICE LIST INDEX ; + LD DE,(HCB + HCB_BOOTVOL) ; BOOT VOLUME (UNIT, SLICE) + LD A,1 ; ROM DISK UNIT? + CP D ; CHECK IT + JR Z,DRV_INIT5A ; IF SO, SKIP BOOT DRIVE + LD B,1 ; JUST ONE SLICE PLEASE + CALL DRV_INIT8A ; DO THE BOOT DEVICE +; +DRV_INIT5A: LD A,(DRVLSTC) ; ACTIVE DRIVE LIST COUNT TO ACCUM LD B,A ; ... AND MOVE TO B FOR LOOP COUNTER LD HL,DRVLST ; HL IS PTR TO ACTIVE DRIVE LIST @@ -2532,7 +2573,21 @@ DRV_INIT7: ; PROCESS UNIT LD A,(HDSPV) ; GET SLICES PER VOLUME TO ACCUM LD B,A ; MOVE TO B FOR LOOP COUNTER ; -DRV_INIT8: ; SLICE CREATION LOOP +DRV_INIT8: + ; SLICE CREATION LOOP + ; DE=UNIT/SLICE, B=SLICE CNT + LD A,(BOOTVOL + 1) ; GET BOOT UNIT + CP 1 ; ROM BOOT? + JR Z,DRV_INIT8A ; IF SO, OK TO CONTINUE + CP D ; COMPARE TO CUR UNIT + JR NZ,DRV_INIT8A ; IF NE, OK TO CONTINUE + LD A,(BOOTVOL) ; GET BOOT SLICE + CP E ; COMPARE TO CUR SLICE + JR NZ,DRV_INIT8A ; IF NE, OK TO CONTINUE + INC E ; IS BOOT DU/SLICE, SKIP IT + JR DRV_INIT8 ; AND RESTART LOOP +; +DRV_INIT8A: ; ENTRY POINT TO SKIP BOOT DISK/LU CHECK ; ; INC DRVMAP ENTRY COUNT AND ENFORCE FOR 16 ENTRY MAXIMUM LD HL,(DRVMAPADR) ; POINT TO DRIVE MAP @@ -2615,20 +2670,20 @@ DPH_INIT1: CALL PRTDRV ; PRINT DRIVE INFO LD A,D ; A := UNIT PUSH HL ; SAVE DRIVE MAP POINTER - PUSH AF ; SAVE UNIT - ; MATCH AND SAVE DEFAULT DRIVE BASED ON BOOT UNIT/SLICE - LD HL,BOOTVOL + 1 ; POINT TO BOOT UNIT - LD A,D ; LOAD CURRENT UNIT - CP (HL) ; MATCH? - JR NZ,DPH_INIT1A ; BYPASS IF NOT BOOT UNIT - DEC HL ; POINT TO BOOT SLICE - LD A,E ; LOAD CURRENT SLICE - CP (HL) ; MATCH? - JR NZ,DPH_INIT1A ; BYPASS IF NOT BOOT SLICE - LD A,C ; LOAD THE CURRENT DRIVE NUM - LD (DEFDRIVE),A ; SAVE AS DEFAULT + ;PUSH AF ; SAVE UNIT + ;; MATCH AND SAVE DEFAULT DRIVE BASED ON BOOT UNIT/SLICE + ;LD HL,BOOTVOL + 1 ; POINT TO BOOT UNIT + ;LD A,D ; LOAD CURRENT UNIT + ;CP (HL) ; MATCH? + ;JR NZ,DPH_INIT1A ; BYPASS IF NOT BOOT UNIT + ;DEC HL ; POINT TO BOOT SLICE + ;LD A,E ; LOAD CURRENT SLICE + ;CP (HL) ; MATCH? + ;JR NZ,DPH_INIT1A ; BYPASS IF NOT BOOT SLICE + ;LD A,C ; LOAD THE CURRENT DRIVE NUM + ;LD (DEFDRIVE),A ; SAVE AS DEFAULT DPH_INIT1A: - POP AF ; RESTORE UNIT + ;POP AF ; RESTORE UNIT LD DE,(DPHTOP) ; GET ADDRESS OF NEXT DPH PUSH DE ; ... AND SAVE IT ; INVOKE THE DPH BUILD ROUTINE diff --git a/Source/CBIOS/ver.inc b/Source/CBIOS/ver.inc index 1711ccfe..14d90170 100644 --- a/Source/CBIOS/ver.inc +++ b/Source/CBIOS/ver.inc @@ -2,4 +2,4 @@ #DEFINE RMN 9 #DEFINE RUP 2 #DEFINE RTP 0 -#DEFINE BIOSVER "2.9.2-pre.31" +#DEFINE BIOSVER "2.9.2-pre.32" diff --git a/Source/CPM22/ver.inc b/Source/CPM22/ver.inc index 1711ccfe..14d90170 100644 --- a/Source/CPM22/ver.inc +++ b/Source/CPM22/ver.inc @@ -2,4 +2,4 @@ #DEFINE RMN 9 #DEFINE RUP 2 #DEFINE RTP 0 -#DEFINE BIOSVER "2.9.2-pre.31" +#DEFINE BIOSVER "2.9.2-pre.32" diff --git a/Source/CPM3/biosldr.z80 b/Source/CPM3/biosldr.z80 index 2068d5f7..de97bb36 100644 --- a/Source/CPM3/biosldr.z80 +++ b/Source/CPM3/biosldr.z80 @@ -67,10 +67,14 @@ boot1: pop af sub '0' - jr c,boot1 - cp 10 ; !!! Need to test against max disk unit num !!! - jr nc,boot1 ld (unit),a + jr c,selerr + + ld bc,0F810h ; HBIOS, get disk unit count + call 0FFF0h ; do it, E := disk unit count + ld a,(unit) ; get unit num back + cp e ; compare to entry + jr nc,selerr ; loop if too high ld de,msgslc call writestr @@ -80,11 +84,19 @@ boot1: pop af sub '0' - jr c,boot1 - cp 10 - jr nc,boot1 ld (slice),a + jr c,selerr + cp 10 + jr nc,selerr + + jr boot2 + +selerr: + ld de,msginv + call writestr + jr boot1 +boot2: ld de,crlf call writestr @@ -346,6 +358,7 @@ mult8_noadd: msgunit db 13,10,13,10,'Boot CP/M 3 from Disk Unit: $' msgslc db ' Slice: $' +msginv db 13,10,13,10,'*** Invalid Selection ***$' crlf db 13,10,'$' dpb$start: diff --git a/Source/CPM3/boot.z80 b/Source/CPM3/boot.z80 index ca0a0041..99c7bbda 100644 --- a/Source/CPM3/boot.z80 +++ b/Source/CPM3/boot.z80 @@ -124,20 +124,6 @@ dinit: or a ; set flags ret z ; !!! handle zero devices (albeit poorly) !!! -; ; loop thru devices to count total hard disk volumes -; push bc ; save the device count -; ld c,0 ; use c as device list index -; ld e,0 ; init e for hard disk volume count -; -;dinit2: -; push bc ; save loop control -; call dinit3 ; check drive -; pop bc ; restore loop control -; inc c ; next unit -; djnz dinit2 ; loop -; pop bc ; restore unit count in b -; jr dinit4 ; continue - ; loop thru devices to count total hard disk volumes ld c,0 ; init c as device list index ld d,0 ; init d as total device count @@ -152,17 +138,6 @@ dinit2: ld (drvlstc),a ; save the count jr dinit4 ; continue -;dinit3: -; push de ; save de (hard disk volume counter) -; ld b,017h ; hbios func: report device info -; rst 08 ; call hbios, unit to c -; ld a,d ; device type to a -; pop de ; restore de -; cp 050h ; hard disk device? -; ret c ; nope, return -; inc e ; increment hard disk count -; ret ; and return - dinit3: push de ; save de (hard disk volume counter) push hl ; save drive list ptr @@ -204,16 +179,6 @@ dinit3a: ret ; and return -;dinit4: ; set slices per volume (hdspv) based on hard disk volume count -; ld a,e ; hard disk volume count to a -; ld e,8 ; assume 8 slices per volume -; dec a ; dec accum to check for count = 1 -; jr z,dinit5 ; yes, skip ahead to implement 8 hdspv -; ld e,4 ; now assume 4 slices per volume -; dec a ; dec accum to check for count = 2 -; jr z,dinit5 ; yes, skip ahead to implement 4 hdspv -; ld e,2 ; in all other cases, we use 2 hdspv - dinit4: ; set slices per volume (hdspv) based on hard disk volume count ; ; *** debug *** @@ -240,40 +205,24 @@ dinit4: ; set slices per volume (hdspv) based on hard disk volume count jr z,dinit5 ; yes, skip ahead to implement 4 hdspv ld e,2 ; in all other cases, we use 2 hdspv -;dinit5: -; ld a,e ; slices per volume value to accum -; ld (hdspv),a ; save it -; -; ; setup to enumerate devices to build drvmap -; ld b,0F8h ; SYS GET -; ld c,010h ; Disk Drive Unit Count -; rst 08 ; e := disk unit count -; ld b,e ; count to b -; ld c,0 ; use c as device list index -; ld hl,0 ; dph index - dinit5: ld a,e ; slices per volume value to accum ld (hdspv),a ; save it + ld hl,0 ; dph index + + ld a,(@bootdu) ; boot disk unit + ld d,a ; ... to d + ld a,(@bootsl) ; boot slice + ld e,a ; ... to e + ld b,1 ; one slice please + call dinit8a ; make DPH for A: + ld a,(drvlstc) ; active drive list count to accum ld b,a ; ... and move to b for loop counter ld de,drvlst ; de is ptr to active drive list - ld hl,0 ; dph index -;dinit6: ; loop thru all units available -; push bc ; preserve loop control -; push hl ; preserve dph pointer -; ld b,017h ; hbios func: report device info -; rst 08 ; call hbios, d := device type -; pop hl ; restore dph pointer -; pop bc ; get unit index back in c -; push bc ; resave loop control -; call dinit7 ; update dph entries -; pop bc ; restore loop control -; inc c ; increment list index -; djnz dinit6 ; loop as needed - -dinit6: ; loop thru all units available +dinit6: + ; loop thru all units available push de ; preserve drive list ptr ex de,hl ; list ptr to hl ld c,(hl) ; get unit num from list @@ -310,18 +259,28 @@ dinit6a: djnz dinit6a ret ; finished -dinit7: ; process unit +dinit7: ; process a unit (all slices) ld e,0 ; initialize slice index ld b,1 ; default loop counter ld a,d ; device type to accum ld d,c ; unit number to d - cp 050h ; hard disk device? + cp 030h ; hard disk device? jr c,dinit8 ; nope, leave loop count at 1 ld a,(hdspv) ; get slices per volume to accum ld b,a ; move to b for loop counter -dinit8: - ; d=unit, e=slice, l=dph# +dinit8: ; test to avoid reallocating boot disk unit/slice + ld a,(@bootdu) ; boot disk unit to accum + cp d ; compare to cur unit + jr nz,dinit8a ; if ne, ok to continue + ld a,(@bootsl) ; boot slice to accum + cp e ; compare to cur slice + jr nz,dinit8a ; if ne, ok to continue + inc e ; is boot du/slice, skip it + jr dinit8 ; and restart loop + +dinit8a: + ; d=unit, e=slice, l=dph#, b=slice cnt ld a,l ; dph # to accum cp 16 ; dph table size ret z ; bail out if overflow @@ -337,9 +296,9 @@ dinit8: ld (hl),e ; update slice number dec hl ; backup to unit number ld (hl),d ; update unit number - inc e ; next slice pop hl ; restore dph # inc hl ; next dph # + inc e ; next slice djnz dinit8 ; loop till done with unit ret @@ -362,25 +321,25 @@ stpsiz equ $ - stpimg ?ldccp: - if zpm - - ; Swap A: and system drive (make A: the system drive) - ld bc,(@dtbl) ; get drive A DPH - ld hl,@dtbl ; point to boot drive DPH - ld a,(@sysdr) - rlca - call addhla - ld e,(hl) ; set boot drive to drive A DPH - ld (hl),c ; ... and save boot drive DPH - inc hl - ld d,(hl) - ld (hl),b - ld (@dtbl),de ; set drive a DPH to boot drive - - xor a ; update @sysdr - ld (@sysdr),a - - endif + ;if zpm + ; + ;; Swap A: and system drive (make A: the system drive) + ;ld bc,(@dtbl) ; get drive A DPH + ;ld hl,@dtbl ; point to boot drive DPH + ;ld a,(@sysdr) + ;rlca + ;call addhla + ;ld e,(hl) ; set boot drive to drive A DPH + ;ld (hl),c ; ... and save boot drive DPH + ;inc hl + ;ld d,(hl) + ;ld (hl),b + ;ld (@dtbl),de ; set drive a DPH to boot drive + ; + ;xor a ; update @sysdr + ;ld (@sysdr),a + ; + ;endif ; Force CCP to use system boot drive as initial default ld a,(@sysdr) ; get system boot drive diff --git a/Source/CPM3/diskio.z80 b/Source/CPM3/diskio.z80 index d5d27c57..154d601d 100644 --- a/Source/CPM3/diskio.z80 +++ b/Source/CPM3/diskio.z80 @@ -323,21 +323,21 @@ dpb_fd111: ; 8" DS/DD Floppy Drive (1.11M) ; called for first time initialization. dsk$init: - ld a,(@rdrv) ; unit being initialized - ld hl,@bootdu - cp (hl) ; compare to boot unit - ret nz ; done if no match - - inc de ; point to slice in XDPH - inc de - inc de - ld a,(de) ; get slice - ld hl,@bootsl - cp (hl) ; compare to boot slice - ret nz ; done if not zero - - ld a,(@adrv) ; get cp/m drive - ld (@sysdr),a ; and save it + ;ld a,(@rdrv) ; unit being initialized + ;ld hl,@bootdu + ;cp (hl) ; compare to boot unit + ;ret nz ; done if no match + ; + ;inc de ; point to slice in XDPH + ;inc de + ;inc de + ;ld a,(de) ; get slice + ;ld hl,@bootsl + ;cp (hl) ; compare to boot slice + ;ret nz ; done if not zero + ; + ;ld a,(@adrv) ; get cp/m drive + ;ld (@sysdr),a ; and save it ret ; lxi h,init$table diff --git a/Source/CPM3/ver.inc b/Source/CPM3/ver.inc index edf94f0c..54c9bafd 100644 --- a/Source/CPM3/ver.inc +++ b/Source/CPM3/ver.inc @@ -3,5 +3,5 @@ rmn equ 9 rup equ 2 rtp equ 0 biosver macro - db "2.9.2-pre.31" + db "2.9.2-pre.32" endm diff --git a/Source/HBIOS/ver.inc b/Source/HBIOS/ver.inc index 1711ccfe..14d90170 100644 --- a/Source/HBIOS/ver.inc +++ b/Source/HBIOS/ver.inc @@ -2,4 +2,4 @@ #DEFINE RMN 9 #DEFINE RUP 2 #DEFINE RTP 0 -#DEFINE BIOSVER "2.9.2-pre.31" +#DEFINE BIOSVER "2.9.2-pre.32" diff --git a/Source/ZSDOS/ver.inc b/Source/ZSDOS/ver.inc index 1711ccfe..14d90170 100644 --- a/Source/ZSDOS/ver.inc +++ b/Source/ZSDOS/ver.inc @@ -2,4 +2,4 @@ #DEFINE RMN 9 #DEFINE RUP 2 #DEFINE RTP 0 -#DEFINE BIOSVER "2.9.2-pre.31" +#DEFINE BIOSVER "2.9.2-pre.32"