From ce3f7f2224dc33ce4ff626372c834dc1c71d0556 Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Mon, 4 May 2020 09:07:09 -0700 Subject: [PATCH 1/3] Small bug fix - Build error in romldr.asm when using custom boot timeout. - Handle CP/M 3 error mode variable properly. --- Source/CPM3/diskio.z80 | 12 +++++++++--- Source/HBIOS/romldr.asm | 2 +- Source/ver.inc | 2 +- Source/ver.lib | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/CPM3/diskio.z80 b/Source/CPM3/diskio.z80 index d9f3ccb1..61f63900 100644 --- a/Source/CPM3/diskio.z80 +++ b/Source/CPM3/diskio.z80 @@ -747,6 +747,9 @@ err_api: ld hl,str_err_api jr err err: + ld a,(@ermde) ; get error mode + cp 0FFh ; FFh means suppress + jr z,err_ret ; if so, go to err return push hl call ?pderr pop hl @@ -755,9 +758,12 @@ err: call ?pmsg call cin$echo cp 'Y' - ret nz - ld hl,(retry$adr) - jp (hl) + jr nz,err_ret ; return error to caller + ld hl,(retry$adr) ; get retry address + jp (hl) ; and go there +err_ret: + ld a,1 ; signal I/O error + ret ; and done str_err_retry db ", Retry (Y/N) ? ",0 str_err_nodisk db ", No disk",0 diff --git a/Source/HBIOS/romldr.asm b/Source/HBIOS/romldr.asm index db5f1750..0abb1668 100644 --- a/Source/HBIOS/romldr.asm +++ b/Source/HBIOS/romldr.asm @@ -219,7 +219,7 @@ wtkey: dec bc ; decrement ld (acmd_to),bc ; resave it ld de,625 ; 16us * 625 = 10ms - call VDELAY ; 10ms delay + call vdelay ; 10ms delay #endif ; jr wtkey ; loop diff --git a/Source/ver.inc b/Source/ver.inc index f5695008..49be83dd 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.0" +#DEFINE BIOSVER "3.1.1-pre.1" diff --git a/Source/ver.lib b/Source/ver.lib index 37b9c82d..f71eb627 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.0" + db "3.1.1-pre.1" endm From a1be61427985524e931b086bcac171b189f08561 Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Mon, 4 May 2020 13:34:36 -0700 Subject: [PATCH 2/3] Cleanup --- Source/CBIOS/cbios.asm | 105 ++++++++++++++++++++++++++-------------- Source/CPM3/diskio.z80 | 2 +- Source/HBIOS/romldr.asm | 1 - 3 files changed, 71 insertions(+), 37 deletions(-) diff --git a/Source/CBIOS/cbios.asm b/Source/CBIOS/cbios.asm index 805a43bc..7e24d981 100644 --- a/Source/CBIOS/cbios.asm +++ b/Source/CBIOS/cbios.asm @@ -1247,6 +1247,10 @@ DSK_SELECT: LD HL,0 ; ZERO LD (SEKLBA),HL ; CLEAR FIRST WORD LD (SEKLBA+2),HL ; CLEAR SECOND WORD +; + ; SET LEGACY SECTORS PER SLICE + LD HL,16640 ; LEGACY SECTORS PER SLICE + LD (SPS),HL ; SAVE IT ; ; CHECK MBR OF PHYSICAL DISK BEING SELECTED ; WILL UPDATE MEDID AND LBAOFF IF VALID CP/M PARTITION EXISTS @@ -1273,7 +1277,7 @@ DSK_SELECT: INC HL ; BUMP TO MSB LD (HL),D ; SET MSB OF DPB IN DPH ; -; ; PLUG LBA OFFSET INTO ACTIVE DPH + ; PLUG LBA OFFSET INTO ACTIVE DPH LD HL,(SEKDPH) ; POINT TO START OF DPH LD BC,16 ; OFFSET OF LBA OFFSET IN DPH ADD HL,BC ; HL := DPH.LBAOFF PTR @@ -1364,6 +1368,9 @@ DSK_MBR3: LD DE,SEKLBA ; LOC TO STORE LBA OFFSET LD BC,4 ; 4 BYTES (32 BITS) LDIR ; COPY IT + ; IF BOOT FROM PARTITION, USE NEW SECTORS PER SLICE VALUE + LD HL,16384 ; NEW SECTORS PER SLICE + LD (SPS),HL ; SAVE IT ; DSK_MBR4: ; RESTORE BANK @@ -1371,46 +1378,73 @@ DSK_MBR4: CALL HB_BNKSEL ; SELECT IT ; DSK_MBR5: -; - ; DIFFERENT ALGORITHM FOR NEW HD FORMAT - LD A,(MEDID) ; GET MEDIA ID - CP MID_HDNEW ; NEW FORMAT? - JR Z,DSK_MBR6 ; IF SO, GO THERE -; - ; OLD HD FORMAT, 65 TRACKS PER SLICE - LD A,(SLICE) ; GET SLICE - LD E,A ; E = SLICE NO - LD H,65 ; H = TRACKS PER SLICE - CALL MULT8 ; HL := H * E (TOTAL TRACK OFFSET) - LD DE,0 ; CLEAR HI WORD - LD B,8 ; 16 SPT, SHIFT 4 BITS - CALL RL32 ; DO IT - JR DSK_MBR7 ; DONE -; -DSK_MBR6: - ; NEW HD FORMAT, MULTIPLY SLICE BY 8MB - LD DE,0 ; CLEAR HIWORD - LD H,0 ; CLEAR HI BYTE OR LOWORD - LD A,(SLICE) ; GET SLICE - LD L,A ; PUT SLICE IN LOW BYTE - LD B,14 - CALL RL32 ; MULTIPLY BY 16384 SECTORS (8MB) -; -DSK_MBR7: - ; ADD IN LBA OFFSET - LD BC,(SEKLBA) ; LBA OFFSET LOWORD - ADD HL,BC - EX DE,HL - LD BC,(SEKLBA+2) ; LBA OFFSET HIWORD - ADC HL,BC - EX DE,HL - SET 7,D ; SET LBA ACCESS BIT + ; ADJUST LBA OFFSET BASED ON TARGET SLICE + LD A,(SLICE) ; GET SLICE, A IS LOOP CNT + LD HL,(SEKLBA) ; SET DE:HL + LD DE,(SEKLBA+2) ; ... TO STARTING LBA + LD BC,(SPS) ; SECTORS PER SLICE +BOOT6: + OR A ; SET FLAGS TO CHECK LOOP CNTR + JR Z,BOOT8 ; DONE IF COUNTER EXHAUSTED + ADD HL,BC ; ADD ONE SLICE TO LOW WORD + JR NC,BOOT7 ; CHECK FOR CARRY + INC DE ; IF SO, BUMP HIGH WORD +BOOT7: + DEC A ; DEC LOOP DOWNCOUNTER + JR BOOT6 ; AND LOOP +BOOT8: + LD (LBA),HL ; SAVE NEW LBA, LOW WORD + LD (LBA+2),DE ; SAVE NEW LBA, HIGH WORD ; RESAVE IT LD (SEKLBA),HL ; LOWORD LD (SEKLBA+2),DE ; HIWORD ; SUCCESSFUL FINISH XOR A ; SUCCESS RET ; DONE + + + + + +; ; DIFFERENT ALGORITHM FOR NEW HD FORMAT +; LD A,(MEDID) ; GET MEDIA ID +; CP MID_HDNEW ; NEW FORMAT? +; JR Z,DSK_MBR6 ; IF SO, GO THERE +;; +; ; OLD HD FORMAT, 65 TRACKS PER SLICE +; LD A,(SLICE) ; GET SLICE +; LD E,A ; E = SLICE NO +; LD H,65 ; H = TRACKS PER SLICE +; CALL MULT8 ; HL := H * E (TOTAL TRACK OFFSET) +; LD DE,0 ; CLEAR HI WORD +; LD B,8 ; 16 SPT, SHIFT 4 BITS +; CALL RL32 ; DO IT +; JR DSK_MBR7 ; DONE +;; +;DSK_MBR6: +; ; NEW HD FORMAT, MULTIPLY SLICE BY 8MB +; LD DE,0 ; CLEAR HIWORD +; LD H,0 ; CLEAR HI BYTE OR LOWORD +; LD A,(SLICE) ; GET SLICE +; LD L,A ; PUT SLICE IN LOW BYTE +; LD B,14 +; CALL RL32 ; MULTIPLY BY 16384 SECTORS (8MB) +;; +;DSK_MBR7: +; ; ADD IN LBA OFFSET +; LD BC,(SEKLBA) ; LBA OFFSET LOWORD +; ADD HL,BC +; EX DE,HL +; LD BC,(SEKLBA+2) ; LBA OFFSET HIWORD +; ADC HL,BC +; EX DE,HL +; SET 7,D ; SET LBA ACCESS BIT +; ; RESAVE IT +; LD (SEKLBA),HL ; LOWORD +; LD (SEKLBA+2),DE ; HIWORD +; ; SUCCESSFUL FINISH +; XOR A ; SUCCESS +; RET ; DONE ; #ENDIF ; @@ -1654,6 +1688,7 @@ DEFDRIVE .DB 0 ; DEFAULT DRIVE CCPBUF .DW 0 ; ADDRESS OF CCP BUF IN BIOS BANK MEDID .DB 0 ; TEMP STORAGE FOR MEDIA ID SLICE .DB 0 ; CURRENT SLICE +SPS .DW 0 ; SECTORS PER SLICE ; #IFDEF PLTWBW BNKBIOS .DB 0 ; BIOS BANK ID diff --git a/Source/CPM3/diskio.z80 b/Source/CPM3/diskio.z80 index 61f63900..7157619d 100644 --- a/Source/CPM3/diskio.z80 +++ b/Source/CPM3/diskio.z80 @@ -499,7 +499,7 @@ media4: media5: ; Adjust LBA offset based on target slice - ld a,(slice) ; get boot slice, A is loop cnt + ld a,(slice) ; get slice, A is loop cnt ld hl,(lba) ; set DE:HL ld de,(lba+2) ; ... to starting LBA ld bc,(sps) ; sectors per slice diff --git a/Source/HBIOS/romldr.asm b/Source/HBIOS/romldr.asm index 0abb1668..2bf562ad 100644 --- a/Source/HBIOS/romldr.asm +++ b/Source/HBIOS/romldr.asm @@ -632,7 +632,6 @@ diskboot: #if (BIOS == BIOS_WBW) ; ; Check that drive actually exists - ;ld c,a ; put in C for func call ld b,BF_SYSGET ; HBIOS func: sys get ld c,BF_SYSGET_DIOCNT ; HBIOS sub-func: disk count rst 08 ; do it, E=disk count From c4fae3c1dd1e0e555968d43bee577427e31611fc Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Mon, 4 May 2020 14:37:42 -0700 Subject: [PATCH 3/3] Bug fixes - Fixed build issue in cbios.asm - Flow improvement in romldr.asm --- Source/CBIOS/cbios.asm | 2 -- Source/HBIOS/romldr.asm | 54 +++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/Source/CBIOS/cbios.asm b/Source/CBIOS/cbios.asm index 7e24d981..57895fec 100644 --- a/Source/CBIOS/cbios.asm +++ b/Source/CBIOS/cbios.asm @@ -1393,8 +1393,6 @@ BOOT7: DEC A ; DEC LOOP DOWNCOUNTER JR BOOT6 ; AND LOOP BOOT8: - LD (LBA),HL ; SAVE NEW LBA, LOW WORD - LD (LBA+2),DE ; SAVE NEW LBA, HIGH WORD ; RESAVE IT LD (SEKLBA),HL ; LOWORD LD (SEKLBA+2),DE ; HIWORD diff --git a/Source/HBIOS/romldr.asm b/Source/HBIOS/romldr.asm index 2bf562ad..8449108c 100644 --- a/Source/HBIOS/romldr.asm +++ b/Source/HBIOS/romldr.asm @@ -646,6 +646,8 @@ diskboot: ld e,1 ; enable media check/discovery rst 08 ; do it jp nz,err_diskio ; handle error + ld a,e ; media id to A + ld (mediaid),a ; save media id ; ; If non-zero slice requested, confirm device can handle it ld a,(bootslice) ; get slice @@ -684,6 +686,9 @@ diskboot: cp $44 ; DSD? jr z,diskboot1 ; if so, OK jp err_noslice ; no such slice, handle err +; + ld a,4 ; assume legacy hard disk + ld (mediaid),a ; save media id ; #endif ; @@ -696,6 +701,11 @@ diskboot1: ; Set legacy sectors per slice ld hl,16640 ; legacy sectors per slice ld (sps),hl ; save it +; + ; Check for hard disk + ld a,(mediaid) ; load media id + cp 4 ; legacy hard disk? + jr nz,diskboot8 ; if not hd, no part table ; ; Attempt to read MBR ld de,0 ; MBR is at @@ -712,24 +722,24 @@ diskboot1: ld hl,(bl_mbrsec+$1FE) ; get signature ld a,l ; first byte cp $55 ; should be $55 - jr nz,diskboot1c ; if not, no part table + jr nz,diskboot4 ; if not, no part table ld a,h ; second byte cp $AA ; should be $AA - jr nz,diskboot1c ; if not, no part table + jr nz,diskboot4 ; if not, no part table ; ; Try to find our entry in part table and capture lba offset ld b,4 ; four entries in part table ld hl,bl_mbrsec+$1BE+4 ; offset of first entry part type -diskboot1a: +diskboot2: ld a,(hl) ; get part type cp $52 ; cp/m partition? - jr z,diskboot1b ; cool, grab the lba offset + jr z,diskboot3 ; cool, grab the lba offset ld de,16 ; part table entry size add hl,de ; bump to next entry part type - djnz diskboot1a ; loop thru table - jr diskboot1c ; too bad, no cp/m partition + djnz diskboot2 ; loop thru table + jr diskboot4 ; too bad, no cp/m partition ; -diskboot1b: +diskboot3: ; Capture the starting LBA of the CP/M partition we found ld de,4 ; LBA is 4 bytes after part type add hl,de ; point to it @@ -740,39 +750,41 @@ diskboot1b: ld hl,16384 ; new sectors per slice ld (sps),hl ; save it ; -diskboot1c: +diskboot4: ; Add slice offset ld a,(bootslice) ; get boot slice, A is loop cnt ld hl,(lba) ; set DE:HL ld de,(lba+2) ; ... to starting LBA ld bc,(sps) ; sectors per slice -diskboot2: +diskboot5: or a ; set flags to check loop ctr - jr z,diskboot4 ; done if counter exhausted + jr z,diskboot7 ; done if counter exhausted add hl,bc ; add one slice to low word - jr nc,diskboot3 ; check for carry + jr nc,diskboot6 ; check for carry inc de ; if so, bump high word -diskboot3: +diskboot6: dec a ; dec loop downcounter - jr diskboot2 ; and loop + jr diskboot5 ; and loop ; -diskboot4: +diskboot7: ld (lba),hl ; update lba, low word ld (lba+2),de ; update lba, high word ; - push hl ; save HL +diskboot8: + ; Note that we could be coming from diskboot1! ld hl,str_ldsec ; display prefix call pstr ; do it - pop hl ; restore HL + ld hl,(lba) ; recover lba loword + ld de,(lba+2) ; recover lba hiword call prthex32 ; display starting sector call pdot ; show progress ; ; Read boot info sector, third sector ld bc,2 ; sector offset add hl,bc ; add to LBA value low word - jr nc,diskboot5 ; check for carry + jr nc,diskboot9 ; check for carry inc de ; if so, bump high word -diskboot5: +diskboot9: ld bc,bl_infosec ; read buffer ld (dma),bc ; save ld a,(bootunit) ; disk unit to read @@ -832,9 +844,9 @@ diskboot5: ld de,(lba+2) ; high word of saved LBA ld bc,3 ; offset for sector 3 add hl,bc ; apply it - jr nc,diskboot6 ; check for carry + jr nc,diskboot10 ; check for carry inc de ; bump high word if so -diskboot6: +diskboot10: ld bc,(bb_cpmloc) ; load address ld (dma),bc ; and save it ld a,(loadcnt) ; get sectors to read @@ -882,7 +894,6 @@ diskboot6: ld bc,$01FC ; UNA func: set bootstrap hist rst 08 ; call UNA jp nz,err_api ; handle error - call pdot ; show progress ; #endif ; @@ -1982,6 +1993,7 @@ bid_ldr .ds 2 ; bank at startup lba .ds 4 ; lba for load, dword dma .ds 2 ; address for load sps .ds 2 ; sectors per slice +mediaid .ds 1 ; media id ; ra_tbl_loc .ds 2 ; points to active ra_tbl bootunit .ds 1 ; boot disk unit