diff --git a/Doc/ChangeLog.txt b/Doc/ChangeLog.txt index a822c7f9..e31c7dcf 100644 --- a/Doc/ChangeLog.txt +++ b/Doc/ChangeLog.txt @@ -39,9 +39,9 @@ Version 3.5 - WBW: Add Warm/Cold reboot options to CPUSPD utility - D?N: Added support for eZ80 CPU - MAP: Contributed COPYSL utility -- MAP: Added new HBIOS function SYSGET_DIOMED -- MAP: ROMLDR now uses SYSGET_DIOMED to get Slice Sector for boot -- MAP: CBIOS now uses SYSGET_DIOMED during drive selection +- MAP: Added new HBIOS function EXT_SLICE (orginally SYSGET_DIOMED) +- MAP: ROMLDR now uses EXT_SLICE to get Slice Sector for boot +- MAP: CBIOS now uses EXT_SLICE during drive selection Version 3.4 ----------- diff --git a/Doc/RomWBW System Guide.pdf b/Doc/RomWBW System Guide.pdf index dd7ad4fc..81ef8fa7 100644 Binary files a/Doc/RomWBW System Guide.pdf and b/Doc/RomWBW System Guide.pdf differ diff --git a/Source/CBIOS/cbios.asm b/Source/CBIOS/cbios.asm index b1461f49..ed29a789 100644 --- a/Source/CBIOS/cbios.asm +++ b/Source/CBIOS/cbios.asm @@ -1388,8 +1388,7 @@ DSK_MBR: LD D,A LD A,(SLICE) ; AND SLICE LD E,A - LD B,BF_SYSGET ; HBIOS FUNC: SYS GET - LD C,BF_SYSGET_DIOMED ; HBIOS SUB-FUNC: GET DISK INFO + LD B,BF_EXTSLICE ; HBIOS FUNC: SLICE RST 08 ; DO IT ; ; CHECK ERRORS FROM THE FUNCTION diff --git a/Source/Doc/SystemGuide.md b/Source/Doc/SystemGuide.md index 8ad00943..4f995772 100644 --- a/Source/Doc/SystemGuide.md +++ b/Source/Doc/SystemGuide.md @@ -388,12 +388,11 @@ differentiate (at the oerating system level) between the Classic and Modern layo However HBIOS itself typically does NOT make this distinction, since the use of these two formats is determined by the operating system based on the partition table on the media. - There are two important HBIOS functions that deal with Media ID. -[Function 0x18 -- Disk Media (DIOMEDIA)] +* [Function 0x18 -- Disk Media (DIOMEDIA)] -[SYSGET Subfunction 0x12 -- Get Extended Disk Media (DIOMED)] +* [Function 0xE0 -- Calculate Slice (EXTSLICE)] # System Boot Process @@ -1107,7 +1106,7 @@ devices. See the section [Mapping to Media ID] for information on this. To determine if an HD1K formatted partition exists on the hard disk please see the following function. -[SYSGET Subfunction 0x12 -- Get Extended Disk Media (DIOMED)] +[Function 0xE0 -- Calculate Slice (EXTSLICE)] ### Function 0x19 -- Disk Define Media (DIODEFMED) @@ -2221,6 +2220,51 @@ approximately B5. `\clearpage`{=latex} +## Extension (EXT) + +Helper (extension) functions that are not a core part of a BIOS. + +### Function 0xE0 -- Calculate Slice (EXTSLICE) + +| **Entry Parameters** | **Returned Values** | +|----------------------------------------|----------------------------------------| +| B: 0xE0 | A: Status | +| D: Disk Unit | B: Device Attributes | +| E: Slice | C: Media ID | +| | DEHL: Sector Address | + +Report the Media ID (C), and Device Attributes (B) for the for media in the +specified Disk Unit (D), and for hard disks the absolute Sector offset to the +start of the Slice (E). The Status (A) is a standard HBIOS result code. + +This function extends upon [Function 0x18 -- Disk Media (DIOMEDIA)] for hard +disk media by scanning for a partition to determine if the disk uses HD512 +or HD1K, correctly reporting MID_HD or MID_HDNEW respectively. +See the folowing for some background [Mapping to Media ID] + +It will also return the sector number of the first sector in the +slice if the slice number is valid. If the slice number is invalid +(it wont fix on the media) an error will be returned. + +The slice calculation is performed by considering the partition start +(if it exists), the size of a slice for the given format type, and ensuring +that the slice fits within the media or partition size, taking into +consideration other partitions that may exist. + +The Device Attributes (B) are the same as defined in +[Function 0x17 -- Disk Device (DIODEVICE)] + +If the Unit specified is not a hard disk the Media ID will be returned and +the slice parameter ignored. If there is no media in device, or the slice +number is invaid (Parameter Out Of Range) the function will return an error status. + +**NOTE: +This function was placed in HBIOS to be shared between the diffeent CP/M +varients supported by RomWBW. It is not strictly a BIOS function, +and may be moved in future. + +`\clearpage`{=latex} + ## System (SYS) ### Function 0xF0 -- System Reset (SYSRESET) @@ -2265,7 +2309,7 @@ The Version (DE)number is encoded as BCD where the 4 digits are: [Major Version][Minor Version][Patch Level][Build Number] -So, for example, a Version (L) number of 0x3102 would indicate +So, for example, a Version (DE) number of 0x3102 would indicate version 3.1.0, build 2. The hardware Platform (L) is identified as follows: @@ -2489,46 +2533,6 @@ the caller can use interbank calls directly to the function in the driver which bypasses the overhead of the normal function invocation lookup. -#### SYSGET Subfunction 0x12 -- Get Extended Disk Media (DIOMED) - -| **Entry Parameters** | **Returned Values** | -|----------------------------------------|---------------------------------------| -| B: 0xF8 | A: Status | -| C: 0x12 | B: Device Attributes | -| D: Disk Unit | C: Media ID | -| E: Slice | DEHL: Sector Address | - -Report the Media ID (C), and Device Attributes (B) for the for media in the -specified Disk Unit (D), and for hard disks the absolute Sector offset to the -start of the Slice (E). The Status (A) is a standard HBIOS result code. - -This function extends upon [Function 0x18 -- Disk Media (DIOMEDIA)] for hard -disk media by scanning for a partition to determine if the disk uses HD512 -or HD1K, correctly reporting MID_HD or MID_HDNEW respectively. - -**NOTE: This is contrary to the design of HBIOS. See the section -[Mapping to Media ID] for information on this. -This function was placed in HBIOS to be shared between the diffeent CP/M -varients supported by RomWBW, and may be moved in future. - -It will also return the sector number of the first sector in the -slice if the slice number is valid. If the slice number is invalid -(it wont fix on the media) an error will be returned. - -The slice calculation is performed by considering the partition start -(if it exists), the size of a slice for the given format type, and ensuring -that the slice fits within the media or partition size, taking into -consideration other partitions that may exist. - -The Device Attributes (B) are the same as defined in -[Function 0x17 -- Disk Device (DIODEVICE)] - -If the Unit specified is not a hard disk the Media ID will be returned and -the slice parameter ignored. If there is no media in device, or the slice -number is invaid (Parameter Out Of Range) the function will return an error status. - -Also see [Function 0x18 -- Disk Media (DIOMEDIA)] - #### SYSGET Subfunction 0x20 -- Get RTC Device Unit Count (RTCCNT) | **Entry Parameters** | **Returned Values** | diff --git a/Source/HBIOS/hbios.asm b/Source/HBIOS/hbios.asm index e8af05ec..2f6fdea8 100644 --- a/Source/HBIOS/hbios.asm +++ b/Source/HBIOS/hbios.asm @@ -4065,8 +4065,11 @@ HB_DISPATCH1: JP C,VDA_DISPATCH CP BF_SND + $10 ; $50-$5F: SOUND DRIVERS JP C,SND_DISPATCH - CP BF_SYS ; SKIP TO BF_SYS VALUE AT $F0 - JR C,HB_DISPERR ; ERROR IF LESS THAN BF_SYS + ; GAP TO E0 + CP BF_EXT ; SKIP TO BF_EXT VALUE AT $E0 + JR C,HB_DISPERR ; ERROR IF LESS THAN BF_EXT + CP BF_EXT + $10 ; $E0-$EF: EXTENDED + JP C,EXT_DISPATCH JP SYS_DISPATCH ; OTHERWISE SYS CALL ; FALL THRU ; @@ -4727,6 +4730,19 @@ SND_BEEP_DISP: RET ; ;-------------------------------------------------------------------------------------------------- +; EXTENDED FUNCTION DISPATCHER +;-------------------------------------------------------------------------------------------------- +; +; B: FUNCTION +; +EXT_DISPATCH: + LD A,B ; GET REQUESTED FUNCTION + AND $0F ; ISOLATE SUB-FUNCTION + JP Z,EXT_SLICE ; $E0 + DEC A + JP HB_DISPERR ; ERROR COULD NOT FIND FUNCTION +; +;-------------------------------------------------------------------------------------------------- ; SYSTEM FUNCTION DISPATCHER ;-------------------------------------------------------------------------------------------------- ; @@ -4761,6 +4777,7 @@ SYS_DISPATCH: DEC A JP Z,SYS_INT ; $FC DEC A + JP HB_DISPERR ; ERROR COULD NOT FIND FUNCTION ; HB_DISP_END .EQU $ ; @@ -4863,6 +4880,290 @@ Z280_IVT: HB_Z280IVT_END .EQU $ ; ;================================================================================================== +; EXTENSION API FUNCTIONS +;================================================================================================== +; +HB_EXTAPI_BEG .EQU $ +; +;-------------------------------------------------------------------------------------------------- +; SLICE CALCULATE - GET DISK EXTENDED HARD DISK MEDIA INFORMATION +;-------------------------------------------------------------------------------------------------- +; This function is specificly intended for Hard Drives, where it will scan +; the partition table and return a Media ID, including hd1k (MID_HDNEW). +; It will also return the absolute LBA offset of the first sector in the slice +; If the slice number is invalid (wont fit) the Status will return an error +; If the Unit is not a hard disk the Media ID will be returned and slice ignored. +;-------------------------------------------------------------------------------------------------- +; ENTRY: +; B: FUNCTION 0xE0 EXT_SLICE +; D: DISK UNIT, preferably for a hard disk. +; E: SLICE, ignored if media is not a hard disk +; RETURNS: +; A: STATUS, -6 (parameter out of range) - if Slice is invalid +; Other errors Include ERR_NOUNIT, ERR_NOMEDIA, +; If any error is raised the other return values are undefined +; B: DEVICE ATTRIBUTES, as reported by DIODEVICE +; C: MEDIAID, including MID_HDNEW if hd1k partition is found +; DEHL: LBAOFFSET, of Slice if valid, 0 otherwise. +;-------------------------------------------------------------------------------------------------- +; +SLICE_SLICE .DB 0 ; SLICE ARGUMENT (E) +SLICE_UNIT .DB 0 ; UNIT ARGUMENT (D) +SLICE_DEVATT .DB 0 ; DEVICE ATTRIBUTES +SLICE_MID .DB 0 ; DISCOVERED MEDIAID +; +SLICE_WRKSTA .EQU $ +SLICE_LBAOFF .FILL 4,0 ; START OF PARTITION / SLICE (SECTORS) +SLICE_LBASIZ .FILL 4,0 ; SIZE OF MEDIA / PARTITION (SECTORS) +SLICE_SPS .DW 0 ; DISCOVERED SECTORS PER SLICE (16BIT) +SLICE_FND .DB 0 ; DID WE FIND A NON CPM PARTITION +SLICE_WRKSIZ .EQU $ - SLICE_WRKSTA ; SIZE OF WORKING DATA +; +EXT_SLICE: + ; SAVE CALL ARGUMENTS + LD (SLICE_SLICE),DE ; STORES DE -> SLICE/UNIT PARAMETERS + + ; READ DEVICE INFORMATION USING DIODEVICE FUNCTION + LD A,(SLICE_UNIT) + LD C,A ; UNIT ID PARAMETER INTO C + LD B,BF_DIODEVICE ; DRIVER FUNCTION = DISK MEDIA + CALL DIO_DISPATCH ; CALL DIO TO GET DEVICE ATTRIBUTES + RET NZ ; ABORT ON ERROR +; + ; DEVICE ATTRIBUTES IN C + LD A,C + LD (SLICE_DEVATT),A ; STORE DEVICE ATTRIBUTES +; + ; DETERMINE MEDIA IN DRIVE USING DIOMEDIA FUNCTION + LD A,(SLICE_UNIT) + LD C,A ; UNIT ID PARAMETER INTO C + LD E,1 ; ENABLE MEDIA CHECK/DISCOVERY + LD B,BF_DIOMEDIA ; DRIVER FUNCTION = DISK MEDIA + CALL DIO_DISPATCH ; CALL DIO TO GET MEDIAID (RESULT IN E) + RET NZ ; ABORT ON ERROR +; + ; CHECK MEDIA TYPE, ONLY HD IS APPLICABLE + LD A,E ; RESULTANT MEDIA ID TO ACCUM + LD (SLICE_MID),A ; INIT VALUE, MAY BE USED LATER + OR A ; SET FLAGS + JR Z, EXT_SLICE1A ; BAIL IF NO MEDIA + CP MID_HD ; IS IT A HARD DISK + JR Z, EXT_SLICE1B ; IS HD, CONTINUE TO PROCESS HD +; + ; NOT A HARD DISK, CHECK SLICE = 0 + LD A,(SLICE_SLICE) ; GET THE SLICE + OR A ; SET FLAGS + JP NZ, EXT_SLICE5C ; SLICE NOT ZERO - SIGNAL ERROR AND RETURN +; +EXT_SLICE1A: + ; RETURN MEDIA ID (NOT HD) WITH SUCCESS + LD DE,0 ; LBA VALUE WILL BE ZERO + LD HL,0 + JP EXT_SLICE6A ; RETURN SUCCESS +; +EXT_SLICE1B: + ; FOUND HD, NEED TO PROCESS MBR / PART TABLE + ; CLEAR WORKING STORAGE + LD HL,SLICE_WRKSTA ; HL SET TO FIRST BYTE + LD (HL),0 ; CLEAR FIRST BYTE + LD D,H + LD E,L + INC DE ; DE SET TO SECOND BYTE + LD BC,SLICE_WRKSIZ - 1 ; NUMBER OF LDIR COPIES + LDIR ; BLOCK COPY TO CLEAR WORKING STORAGE +; + ; SEEK TO SECTOR ZERO (MBR TABLE) + LD B,BF_DIOSEEK ; SEEK FUNCTION + LD A,(SLICE_UNIT) ; GET UNIT + LD C,A ; PUT IN C + LD DE,$8000 ; LBA SECTOR ZERO + LD HL,0 ; ASSUME LBA ACCESS FOR NOW + CALL DIO_DISPATCH ; DO IT + RET NZ ; ABORT ON ERROR +; + ; READ SECTOR ZERO (MBR TABLE) + LD B,BF_DIOREAD ; READ FUNCTION + LD A,(SLICE_UNIT) ; GET UNIT + LD C,A ; PUT IN C + LD A,(HB_CURBNK) ; GET CURRENT BANK ID + LD D,A ; PUT IN D + LD E,1 ; SECTOR COUNT + LD HL,HB_WRKBUF ; IO BUFFER TO USE + CALL DIO_DISPATCH ; DO IT + RET NZ ; ABORT ON ERROR +; + ; CHECK MBR OF DISK TO SEE IF IT HAS A PARTITION TABLE. + LD HL,HB_WRKBUF ; DSKBUF ADR + LD DE,$1FE ; OFFSET TO SIGNATURE + ADD HL,DE ; POINT TO SIGNATURE + LD A,(HL) ; GET FIRST BYTE + CP $55 ; CHECK FIRST BYTE + JR NZ,EXT_SLICE3C ; NO MATCH, NO PART TABLE + INC HL ; NEXT BYTE + LD A,(HL) ; GET SECOND BYTE + CP $AA ; CHECK SECOND BYTE + JR NZ,EXT_SLICE3C ; NO MATCH, NO PART TABLE +; + ; FOUND PARTITION TABLE - LOOP AND PROCESS PARTITION TABLE + LD HL,HB_WRKBUF ; DSKBUF ADR + LD DE,$1BE+4 ; OFFSET OF FIRST ENTRY PART TYPE + ADD HL,DE ; POINT TO IT + LD B,4 ; FOUR ENTRIES IN PART TABLE LOOP +EXT_SLICE2A: + LD A,(HL) ; GET PART TYPE + LD DE,4 + ADD HL,DE ; MOVE HL FWD TO GET TO LBA OFFSET + CP $2E ; CP/M PARTITION? + JR Z,EXT_SLICE3B ; HD1K, GRAB THE LBA OFFSET + CP $00 ; IS ANOTHER PARTITION TYPE, NOT CPM + JR NZ,EXT_SLICE3A ; OTHER VALID PART TYPE +EXT_SLICE2B: + LD DE,12 ; REMAINING SIZE TO GET TO NEXT PARTITION +EXT_SLICE2C: + ADD HL,DE ; BUMP TO NEXT PARTITION ENTRY - TYPE + DJNZ EXT_SLICE2A ; LOOP THRU TABLE + JR EXT_SLICE3C ; READ ALL - NO CP/M PARTITION FOUND +; +EXT_SLICE3A + ; FOUND OTHER (NOT CPM) PARTITION + LD A,(SLICE_FND) ; HAVE WE ALREADY FOUND PROCESSED NON CPM + OR A ; PARTITION, AND CAPTURED ITS START SECTOR, SO + JR NZ,EXT_SLICE2B ; IGNORE AND CONTINUTE TO NEXT PARTITION ENTRY +; +; NOTE THERE SLIGHT ISSUE HERE THAT WE ONLY CONSIDER THE FIRST NON-CPM PARTITION +; TO GET THE UPPER SIZE OF MEDIA, IDEALLY WE WOULD CONSIDER ALL, AND TAKE THE LOWEWST +; STARTING SECTOR - THIS IS A COMPRIMISE - OUT OF SEQUENCE PARTITIONS ARE UNLIKELY. +; + PUSH BC ; SAVE IT, BEING USED IN PARTITION LOOP + LD BC, 4 ; IF NOT ALREADY SET - COPY 4 BYTES + LD DE, SLICE_LBASIZ ; FROM PARTION LBA OFFSET (HL) - TO WORKING LBA SIZE (DE) + LDIR ; COPY 4 BYTES + POP BC ; RESTORE +; + LD A,$FF + LD (SLICE_FND),A ; SET FOUND FLAG, SO DONT PROCESS ANY OTHERS + LD DE,8 ; AND INC HL BY 8 TO GET TO NEXT PARITION + JR EXT_SLICE2C ; CONTINUE TO NEXT PARTITION +; +EXT_SLICE3B: + ; FOUND CP/M (HD1K) PARTITION - RECORD THIS + LD A, MID_HDNEW ; DISCOVERED HD1K MEDIA + LD (SLICE_MID), A ; STORE IT + LD BC, SPS_HD1K ; DISCOVERED HD1K MEDIA + LD (SLICE_SPS), BC ; STORE IT +; + ; CAPTURE THE LBA OFFSET AND SECTOR COUNT FROM PARTITION + ; HL POINTS TO PART LBA OFFSET FIELD OF PART ENTRY + LD DE,SLICE_LBAOFF ; LOC TO STORE OFFSET AND SIZE + LD BC,8 ; 8 BYTES - LBA OFFSET AND SIZE + LDIR ; COPY IT +; + JR EXT_SLICE4A ; CONTINUE AND COMPUTE THE SLICE +; +EXT_SLICE3C: + ; NO PARTITION TABLE FOUND / NO CPM PARTITION FOUND -> HD512 + LD BC, SPS_HD512 ; WITH HD512 SECTORS PER SLICE + LD (SLICE_SPS), BC ; STORE IT + + ; DID WE FIND AN OTHER (NOT CPM) PARTITION + LD A,(SLICE_FND) ; HAVE WE ALREADY FOUND PROCESSED NON CPM + OR A ; PARTITION, AND CAPTURED ITS START SECTOR, SO + JR NZ,EXT_SLICE4A ; MEDIA SIZE IS KNOWN BASED ON START OF PARTITION + + ; FIND THE PHYSICAL CAPCITY OF THE MEDIA CALL (DIOCAP) + LD B, BF_DIOCAP ; HBIOS FUNC: TO GET DISK LBA CAPACITY + LD A, (SLICE_UNIT) + LD C, A ; PUT DISK UNIT IN C FOR FUNC CALL + CALL DIO_DISPATCH ; DO IT - RETURNS SIZE in DE:HL + RET NZ ; ABORT ON ERROR + + ; UPDATE LBA SIZE FROM MEDIA SIZE + LD (SLICE_LBASIZ), HL ; LOWER ORDER BYTES - HL + EX DE,HL + LD (SLICE_LBASIZ+2), HL ; HIGHER ORDER BYTES - DE +; +EXT_SLICE4A: + ; COMPUTE THE START SECTOR (RELATIVE) FOR SLICE -> DE:HL + LD HL,0 ; STARTING SECTOR NUMBER + LD DE,0 ; ASSUMING A 0 OFFSET, SO CAN COMPARE TO SIZE + LD BC,(SLICE_SPS) + LD A,(SLICE_SLICE) + OR A ; SLICE NUMBER - SET FLAGS TO CHECK LOOP CTR + JR Z,EXT_SLICE5A ; NOTHING TO COUNT +EXT_SLICE4B: + ADD HL,BC ; ADD ONE SLICE (SPS) TO LOW WORD + JR NC,EXT_SLICE4C ; CHECK FOR CARRY + INC DE ; IF SO, BUMP HIGH WORD +EXT_SLICE4C: + DEC A ; DEC LOOP (SLICE) COUNTER + JR NZ,EXT_SLICE4B ; AND LOOP +; +EXT_SLICE5A: + ; DE:HL NOW CONTAINS THE STARTING SECTOR FOR SLICE + PUSH HL ; SAVE THE SECTOR OFFSET (SPS * SLICE NUMBER) + PUSH DE +; + ADD HL, BC ; ADD SPS, GET REQUIRED CAPCITY (UPPER SECTOR) + JR NC, EXT_SLICE5B + INC DE +EXT_SLICE5B: + ; DEHL HAS THE REQUIRED NUMBER OF SECTORS (ON MEDIA) FOR THE SLICE + PUSH DE ; SAVE DSK_REQ (MSW) + PUSH HL ; SAVE DSK_REQ (LSW) +; + ; CHECK DSK_CAPACITY >= CAP_REQUIRED, CF SET ON OVERFLOW + ; NO NEED SAVE ACTUAL RESULT + OR A ; CLEAR CARRY FOR SBC + LD HL,(SLICE_LBASIZ+0) ; CAPACITY LSW + POP DE ; REQUIRED LSW + SBC HL,DE ; CAPACITY - REQUIRED (LSW) + LD HL,(SLICE_LBASIZ+2) ; CAPAITY MSW + POP DE ; REQUIRED MSW + SBC HL,DE ; CAPACITY - REQUIRED (MSW) +; + ; POP STARTING OFSETT SECTOR + POP DE + POP HL +; + ; REQUIRE - CAPACITY -> GENERATES BORROW IF CAPITY > REQUIREMENT + JR NC,EXT_SLICE6 ; IF WE HAVE ENOUGH CAPACITY +; +EXT_SLICE5C: + ; SLICE WONT FIT - STOP AND RETURN ERROR + LD DE,0 + LD HL,0 ; EMTY OFFSET IN DEHL + LD A,(SLICE_DEVATT) + LD B,A ; DEVICE ATTRIBUTES IN B + LD A,(SLICE_MID) + LD C,A ; RETURN MEDIA ID IN C + LD A,ERR_RANGE ; OTHERWISE SIGNAL NOT ENOUGH CAPACITY + OR A + RET +; +EXT_SLICE6: + ; FINAL CALC AND RETURN SUCCESS + ; ADD PARTITION OFFSET (START) TO DEHL TO GET ABSOLUTE SLICE OFFSET + LD BC,(SLICE_LBAOFF+0) ; LSB OF LBA OFFSET + ADD HL,BC ; ADD LSB OFFSET + EX DE,HL ; FLIP DE INTO HL + LD BC,(SLICE_LBAOFF+2) ; MSB OF LBA OFFSET + ADC HL,BC ; ADD MSB + EX DE, HL ; FLIP BACK DE:HL AS SLICE OFFSET +; +EXT_SLICE6A: + ; SLICE FITS - RETURN CORRECTLY + LD A,(SLICE_DEVATT) + LD B,A ; DEVICE ATTRIBUTES IN B + LD A,(SLICE_MID) + LD C,A ; RETURN MEDIA ID IN C + XOR A ; CLEAR FLAGS + RET ; RETUNING DE:HL AND C +; +;-------------------------------------------------------------------------------------------------- +; +HB_EXTAPI_END .EQU $ +; +;================================================================================================== ; SYSTEM API FUNCTIONS ;================================================================================================== ; @@ -5149,8 +5450,11 @@ SYS_GET: JP Z,SYS_GETDIOCNT CP BF_SYSGET_DIOFN JP Z,SYS_GETDIOFN - CP BF_SYSGET_DIOMED - JP Z,SYS_GETDIOMED + CP $12 ; LEFT FOR BACKWRD COMPATABILITY + JP Z,EXT_SLICE ; FUNCTION MOVED TO TOP LEVEL $E0 + ; REMOVING THE ABOVE CAUSED UPGRADE ISSUES FOR EARLY ADOPTERS + ; SINCE OS BOOT LOADERS DEPEND ON IT. WITHOUT CAN LEAVE OS + ; UNBOOTABLE AND MIGRATION HARDER - Oct 2024 CP BF_SYSGET_RTCCNT JP Z,SYS_GETRTCCNT CP BF_SYSGET_DSKYCNT @@ -5232,278 +5536,6 @@ SYS_GETDIOFN: LD IY,DIO_TBL ; POINT TO UNIT TABLE JP SYS_GETFN ; GO TO COMMON CODE ; -; GET DISK EXTENDED HARD DISK MEDIA INFORMATION -; This function is specificly intended for Hard Drives, where it will scan -; the partition table and return a Media ID, including hd1k (MID_HDNEW). -; It will also return the absolute LBA offset of the first sector in the slice -; If the slice number is invalid (wont fit) the Status will return an error -; If the Unit is not a hard disk the Media ID will be returned and slice ignored. -; -; ENTRY: -; B: FUNCTION 0xF8 SYSGET -; C: SUB FUNCTION 0x12 DIOMED -; D: DISK UNIT, preferably for a hard disk. -; E: SLICE, ignored if media is not a hard disk -; RETURNS: -; A: STATUS, -6 (parameter out of range) - if Slice is invalid -; Other errors Include ERR_NOUNIT, ERR_NOMEDIA, -; If any error is raised the other return values are undefined -; B: DEVICE ATTRIBUTES, as reported by DIODEVICE -; C: MEDIAID, including MID_HDNEW if hd1k partition is found -; DEHL: LBAOFFSET, of Slice if valid, 0 otherwise. -; -DIOMED_SLICE .DB 0 ; SLICE ARGUMENT (E) -DIOMED_UNIT .DB 0 ; UNIT ARGUMENT (D) -DIOMED_DEVATT .DB 0 ; DEVICE ATTRIBUTES -DIOMED_MID .DB 0 ; DISCOVERED MEDIAID -; -DIOMED_WRKSTA .EQU $ -DIOMED_LBAOFF .FILL 4,0 ; START OF PARTITION / SLICE (SECTORS) -DIOMED_LBASIZ .FILL 4,0 ; SIZE OF MEDIA / PARTITION (SECTORS) -DIOMED_SPS .DW 0 ; DISCOVERED SECTORS PER SLICE (16BIT) -DIOMED_FND .DB 0 ; DID WE FIND A NON CPM PARTITION -DIOMED_WRKSIZ .EQU $ - DIOMED_WRKSTA ; SIZE OF WORKING DATA -; -SYS_GETDIOMED: - ; SAVE CALL ARGUMENTS - LD (DIOMED_SLICE),DE ; STORES DE -> SLICE/UNIT PARAMETERS - - ; READ DEVICE INFORMATION USING DIODEVICE FUNCTION - LD A,(DIOMED_UNIT) - LD C,A ; UNIT ID PARAMETER INTO C - LD B,BF_DIODEVICE ; DRIVER FUNCTION = DISK MEDIA - CALL DIO_DISPATCH ; CALL DIO TO GET DEVICE ATTRIBUTES - RET NZ ; ABORT ON ERROR -; - ; DEVICE ATTRIBUTES IN C - LD A,C - LD (DIOMED_DEVATT),A ; STORE DEVICE ATTRIBUTES -; - ; DETERMINE MEDIA IN DRIVE USING DIOMEDIA FUNCTION - LD A,(DIOMED_UNIT) - LD C,A ; UNIT ID PARAMETER INTO C - LD E,1 ; ENABLE MEDIA CHECK/DISCOVERY - LD B,BF_DIOMEDIA ; DRIVER FUNCTION = DISK MEDIA - CALL DIO_DISPATCH ; CALL DIO TO GET MEDIAID (RESULT IN E) - RET NZ ; ABORT ON ERROR -; - ; CHECK MEDIA TYPE, ONLY HD IS APPLICABLE - LD A,E ; RESULTANT MEDIA ID TO ACCUM - LD (DIOMED_MID),A ; INIT VALUE, MAY BE USED LATER - OR A ; SET FLAGS - JR Z, SYS_GETDIOMED1A ; BAIL IF NO MEDIA - CP MID_HD ; IS IT A HARD DISK - JR Z, SYS_GETDIOMED1B ; IS HD, CONTINUE TO PROCESS HD -; - ; NOT A HARD DISK, CHECK SLICE = 0 - LD A,(DIOMED_SLICE) ; GET THE SLICE - OR A ; SET FLAGS - JP NZ, SYS_GETDIOMED5C ; SLICE NOT ZERO - SIGNAL ERROR AND RETURN -; -SYS_GETDIOMED1A: - ; RETURN MEDIA ID (NOT HD) WITH SUCCESS - LD DE,0 ; LBA VALUE WILL BE ZERO - LD HL,0 - JP SYS_GETDIOMED6A ; RETURN SUCCESS -; -SYS_GETDIOMED1B: - ; FOUND HD, NEED TO PROCESS MBR / PART TABLE - ; CLEAR WORKING STORAGE - LD HL,DIOMED_WRKSTA ; HL SET TO FIRST BYTE - LD (HL),0 ; CLEAR FIRST BYTE - LD D,H - LD E,L - INC DE ; DE SET TO SECOND BYTE - LD BC,DIOMED_WRKSIZ - 1 ; NUMBER OF LDIR COPIES - LDIR ; BLOCK COPY TO CLEAR WORKING STORAGE -; - ; SEEK TO SECTOR ZERO (MBR TABLE) - LD B,BF_DIOSEEK ; SEEK FUNCTION - LD A,(DIOMED_UNIT) ; GET UNIT - LD C,A ; PUT IN C - LD DE,$8000 ; LBA SECTOR ZERO - LD HL,0 ; ASSUME LBA ACCESS FOR NOW - CALL DIO_DISPATCH ; DO IT - RET NZ ; ABORT ON ERROR -; - ; READ SECTOR ZERO (MBR TABLE) - LD B,BF_DIOREAD ; READ FUNCTION - LD A,(DIOMED_UNIT) ; GET UNIT - LD C,A ; PUT IN C - LD A,(HB_CURBNK) ; GET CURRENT BANK ID - LD D,A ; PUT IN D - LD E,1 ; SECTOR COUNT - LD HL,HB_WRKBUF ; IO BUFFER TO USE - CALL DIO_DISPATCH ; DO IT - RET NZ ; ABORT ON ERROR -; - ; CHECK MBR OF DISK TO SEE IF IT HAS A PARTITION TABLE. - LD HL,HB_WRKBUF ; DSKBUF ADR - LD DE,$1FE ; OFFSET TO SIGNATURE - ADD HL,DE ; POINT TO SIGNATURE - LD A,(HL) ; GET FIRST BYTE - CP $55 ; CHECK FIRST BYTE - JR NZ,SYS_GETDIOMED3C ; NO MATCH, NO PART TABLE - INC HL ; NEXT BYTE - LD A,(HL) ; GET SECOND BYTE - CP $AA ; CHECK SECOND BYTE - JR NZ,SYS_GETDIOMED3C ; NO MATCH, NO PART TABLE -; - ; FOUND PARTITION TABLE - LOOP AND PROCESS PARTITION TABLE - LD HL,HB_WRKBUF ; DSKBUF ADR - LD DE,$1BE+4 ; OFFSET OF FIRST ENTRY PART TYPE - ADD HL,DE ; POINT TO IT - LD B,4 ; FOUR ENTRIES IN PART TABLE LOOP -SYS_GETDIOMED2A: - LD A,(HL) ; GET PART TYPE - LD DE,4 - ADD HL,DE ; MOVE HL FWD TO GET TO LBA OFFSET - CP $2E ; CP/M PARTITION? - JR Z,SYS_GETDIOMED3B ; HD1K, GRAB THE LBA OFFSET - CP $00 ; IS ANOTHER PARTITION TYPE, NOT CPM - JR NZ,SYS_GETDIOMED3A ; OTHER VALID PART TYPE -SYS_GETDIOMED2B: - LD DE,12 ; REMAINING SIZE TO GET TO NEXT PARTITION -SYS_GETDIOMED2C: - ADD HL,DE ; BUMP TO NEXT PARTITION ENTRY - TYPE - DJNZ SYS_GETDIOMED2A ; LOOP THRU TABLE - JR SYS_GETDIOMED3C ; READ ALL - NO CP/M PARTITION FOUND -; -SYS_GETDIOMED3A - ; FOUND OTHER (NOT CPM) PARTITION - LD A,(DIOMED_FND) ; HAVE WE ALREADY FOUND PROCESSED NON CPM - OR A ; PARTITION, AND CAPTURED ITS START SECTOR, SO - JR NZ,SYS_GETDIOMED2B ; IGNORE AND CONTINUTE TO NEXT PARTITION ENTRY -; -; NOTE THERE SLIGHT ISSUE HERE THAT WE ONLY CONSIDER THE FIRST NON-CPM PARTITION -; TO GET THE UPPER SIZE OF MEDIA, IDEALLY WE WOULD CONSIDER ALL, AND TAKE THE LOWEWST -; STARTING SECTOR - THIS IS A COMPRIMISE - OUT OF SEQUENCE PARTITIONS ARE UNLIKELY. -; - PUSH BC ; SAVE IT, BEING USED IN PARTITION LOOP - LD BC, 4 ; IF NOT ALREADY SET - COPY 4 BYTES - LD DE, DIOMED_LBASIZ ; FROM PARTION LBA OFFSET (HL) - TO WORKING LBA SIZE (DE) - LDIR ; COPY 4 BYTES - POP BC ; RESTORE -; - LD A,$FF - LD (DIOMED_FND),A ; SET FOUND FLAG, SO DONT PROCESS ANY OTHERS - LD DE,8 ; AND INC HL BY 8 TO GET TO NEXT PARITION - JR SYS_GETDIOMED2C ; CONTINUE TO NEXT PARTITION -; -SYS_GETDIOMED3B: - ; FOUND CP/M (HD1K) PARTITION - RECORD THIS - LD A, MID_HDNEW ; DISCOVERED HD1K MEDIA - LD (DIOMED_MID), A ; STORE IT - LD BC, SPS_HD1K ; DISCOVERED HD1K MEDIA - LD (DIOMED_SPS), BC ; STORE IT -; - ; CAPTURE THE LBA OFFSET AND SECTOR COUNT FROM PARTITION - ; HL POINTS TO PART LBA OFFSET FIELD OF PART ENTRY - LD DE,DIOMED_LBAOFF ; LOC TO STORE OFFSET AND SIZE - LD BC,8 ; 8 BYTES - LBA OFFSET AND SIZE - LDIR ; COPY IT -; - JR SYS_GETDIOMED4A ; CONTINUE AND COMPUTE THE SLICE -; -SYS_GETDIOMED3C: - ; NO PARTITION TABLE FOUND / NO CPM PARTITION FOUND -> HD512 - LD BC, SPS_HD512 ; WITH HD512 SECTORS PER SLICE - LD (DIOMED_SPS), BC ; STORE IT - - ; DID WE FIND AN OTHER (NOT CPM) PARTITION - LD A,(DIOMED_FND) ; HAVE WE ALREADY FOUND PROCESSED NON CPM - OR A ; PARTITION, AND CAPTURED ITS START SECTOR, SO - JR NZ,SYS_GETDIOMED4A ; MEDIA SIZE IS KNOWN BASED ON START OF PARTITION - - ; FIND THE PHYSICAL CAPCITY OF THE MEDIA CALL (DIOCAP) - LD B, BF_DIOCAP ; HBIOS FUNC: TO GET DISK LBA CAPACITY - LD A, (DIOMED_UNIT) - LD C, A ; PUT DISK UNIT IN C FOR FUNC CALL - CALL DIO_DISPATCH ; DO IT - RETURNS SIZE in DE:HL - RET NZ ; ABORT ON ERROR - - ; UPDATE LBA SIZE FROM MEDIA SIZE - LD (DIOMED_LBASIZ), HL ; LOWER ORDER BYTES - HL - EX DE,HL - LD (DIOMED_LBASIZ+2), HL ; HIGHER ORDER BYTES - DE -; -SYS_GETDIOMED4A: - ; COMPUTE THE START SECTOR (RELATIVE) FOR SLICE -> DE:HL - LD HL,0 ; STARTING SECTOR NUMBER - LD DE,0 ; ASSUMING A 0 OFFSET, SO CAN COMPARE TO SIZE - LD BC,(DIOMED_SPS) ; - LD A,(DIOMED_SLICE) - OR A ; SLICE NUMBER - SET FLAGS TO CHECK LOOP CTR - JR Z,SYS_GETDIOMED5A ; NOTHING TO COUNT -SYS_GETDIOMED4B: - ADD HL,BC ; ADD ONE SLICE (SPS) TO LOW WORD - JR NC,SYS_GETDIOMED4C ; CHECK FOR CARRY - INC DE ; IF SO, BUMP HIGH WORD -SYS_GETDIOMED4C: - DEC A ; DEC LOOP (SLICE) COUNTER - JR NZ,SYS_GETDIOMED4B ; AND LOOP -; -SYS_GETDIOMED5A: - ; DE:HL NOW CONTAINS THE STARTING SECTOR FOR SLICE - PUSH HL ; SAVE THE SECTOR OFFSET (SPS * SLICE NUMBER) - PUSH DE -; - ADD HL, BC ; ADD SPS, GET REQUIRED CAPCITY (UPPER SECTOR) - JR NC, SYS_GETDIOMED5B - INC DE -SYS_GETDIOMED5B: - ; DEHL HAS THE REQUIRED NUMBER OF SECTORS (ON MEDIA) FOR THE SLICE - PUSH DE ; SAVE DSK_REQ (MSW) - PUSH HL ; SAVE DSK_REQ (LSW) -; - ; CHECK DSK_CAPACITY >= CAP_REQUIRED, CF SET ON OVERFLOW - ; NO NEED SAVE ACTUAL RESULT - OR A ; CLEAR CARRY FOR SBC - LD HL,(DIOMED_LBASIZ+0) ; CAPACITY LSW - POP DE ; REQUIRED LSW - SBC HL,DE ; CAPACITY - REQUIRED (LSW) - LD HL,(DIOMED_LBASIZ+2) ; CAPAITY MSW - POP DE ; REQUIRED MSW - SBC HL,DE ; CAPACITY - REQUIRED (MSW) -; - ; POP STARTING OFSETT SECTOR - POP DE - POP HL -; - ; REQUIRE - CAPACITY -> GENERATES BORROW IF CAPITY > REQUIREMENT - JR NC,SYS_GETDIOMED6 ; IF WE HAVE ENOUGH CAPACITY -; -SYS_GETDIOMED5C: - ; SLICE WONT FIT - STOP AND RETURN ERROR - LD DE,0 - LD HL,0 ; EMTY OFFSET IN DEHL - LD A,(DIOMED_DEVATT) - LD B,A ; DEVICE ATTRIBUTES IN B - LD A,(DIOMED_MID) - LD C,A ; RETURN MEDIA ID IN C - LD A,ERR_RANGE ; OTHERWISE SIGNAL NOT ENOUGH CAPACITY - OR A - RET -; -SYS_GETDIOMED6: - ; FINAL CALC AND RETURN SUCCESS - ; ADD PARTITION OFFSET (START) TO DEHL TO GET ABSOLUTE SLICE OFFSET - LD BC,(DIOMED_LBAOFF+0) ; LSB OF LBA OFFSET - ADD HL,BC ; ADD LSB OFFSET - EX DE,HL ; FLIP DE INTO HL - LD BC,(DIOMED_LBAOFF+2) ; MSB OF LBA OFFSET - ADC HL,BC ; ADD MSB - EX DE, HL ; FLIP BACK DE:HL AS SLICE OFFSET -; -SYS_GETDIOMED6A: - ; SLICE FITS - RETURN CORRECTLY - LD A,(DIOMED_DEVATT) - LD B,A ; DEVICE ATTRIBUTES IN B - LD A,(DIOMED_MID) - LD C,A ; RETURN MEDIA ID IN C - XOR A ; CLEAR FLAGS - RET ; RETUNING DE:HL AND C -; ; GET RTC UNIT COUNT ; SYS_GETRTCCNT: @@ -9326,6 +9358,7 @@ SLACK .EQU BNKTOP - $ .ECHO "SYSINIT \t" \ .ECHO HB_SYSINIT_BEG \ .ECHO "\t" \ .ECHO HB_SYSINIT_END - HB_SYSINIT_BEG \ .ECHO "\n" .ECHO "DISP \t" \ .ECHO HB_DISP_BEG \ .ECHO "\t" \ .ECHO HB_DISP_END - HB_DISP_BEG \ .ECHO "\n" .ECHO "Z280IVT \t" \ .ECHO HB_Z280IVT_BEG \ .ECHO "\t" \ .ECHO HB_Z280IVT_END - HB_Z280IVT_BEG \ .ECHO "\n" + .ECHO "EXTAPI \t" \ .ECHO HB_EXTAPI_BEG \ .ECHO "\t" \ .ECHO HB_EXTAPI_END - HB_EXTAPI_BEG \ .ECHO "\n" .ECHO "SYSAPI \t" \ .ECHO HB_SYSAPI_BEG \ .ECHO "\t" \ .ECHO HB_SYSAPI_END - HB_SYSAPI_BEG \ .ECHO "\n" .ECHO "INTFUNC \t" \ .ECHO HB_INTFUNC_BEG \ .ECHO "\t" \ .ECHO HB_INTFUNC_END - HB_INTFUNC_BEG \ .ECHO "\n" .ECHO "UTIL \t" \ .ECHO HB_UTIL_BEG \ .ECHO "\t" \ .ECHO HB_UTIL_END - HB_UTIL_BEG \ .ECHO "\n" diff --git a/Source/HBIOS/hbios.inc b/Source/HBIOS/hbios.inc index f1329ec9..78ac0aca 100644 --- a/Source/HBIOS/hbios.inc +++ b/Source/HBIOS/hbios.inc @@ -84,6 +84,11 @@ BF_SNDQ_CHCNT .EQU BF_SNDQ_STATUS + 1 ; RETURN COUNT OF CHANNELS BF_SNDQ_VOLUME .EQU BF_SNDQ_STATUS + 2 ; 8 BIT NUMBER BF_SNDQ_PERIOD .EQU BF_SNDQ_STATUS + 3 ; 16 BIT NUMBER BF_SNDQ_DEV .EQU BF_SNDQ_STATUS + 4 ; RETURN DEVICE TYPE CODE AND IO PORTS - TYPE IN B, PORTS IN DE, HL +; +; EXTENSION FUNCTIONS +BF_EXT .EQU $E0 +BF_EXTSLICE .EQU BF_EXT + 0 ; SLICE CALCULATION (WAS BF_SYSGET_DIOMED) + ; BF_SYS .EQU $F0 BF_SYSRESET .EQU BF_SYS + 0 ; SOFT RESET HBIOS @@ -109,7 +114,6 @@ BF_SYSGET_CIOCNT .EQU $00 ; GET CHAR UNIT COUNT BF_SYSGET_CIOFN .EQU $01 ; GET CIO UNIT FN/DATA ADR BF_SYSGET_DIOCNT .EQU $10 ; GET DISK UNIT COUNT BF_SYSGET_DIOFN .EQU $11 ; GET DIO UNIT FN/DATA ADR -BF_SYSGET_DIOMED .EQU $12 ; GET DISK MEDIA EXTENDED INFO BF_SYSGET_RTCCNT .EQU $20 ; GET RTC UNIT COUNT BF_SYSGET_DSKYCNT .EQU $30 ; GET DSKY UNIT COUNT BF_SYSGET_VDACNT .EQU $40 ; GET VDA UNIT COUNT diff --git a/Source/HBIOS/romldr.asm b/Source/HBIOS/romldr.asm index fb41a234..7e3a0279 100644 --- a/Source/HBIOS/romldr.asm +++ b/Source/HBIOS/romldr.asm @@ -1124,8 +1124,7 @@ diskboot: #if (BIOS == BIOS_WBW) ; ; Get Extended information for the Device, and Slice - ld b,BF_SYSGET ; HBIOS func: sys get - ld c,BF_SYSGET_DIOMED ; HBIOS sub-func: get extended disk info + ld b,BF_EXTSLICE ; HBIOS func: SLICE CALC ld a,(bootunit) ; passing boot unit ld d,a ld a,(bootslice) ; and slice diff --git a/Source/ver.inc b/Source/ver.inc index 05139b74..cc0edf77 100644 --- a/Source/ver.inc +++ b/Source/ver.inc @@ -2,7 +2,7 @@ #DEFINE RMN 5 #DEFINE RUP 0 #DEFINE RTP 0 -#DEFINE BIOSVER "3.5.0-dev.90" +#DEFINE BIOSVER "3.5.0-dev.91" #define rmj RMJ #define rmn RMN #define rup RUP diff --git a/Source/ver.lib b/Source/ver.lib index 1ce0bc10..39c22608 100644 --- a/Source/ver.lib +++ b/Source/ver.lib @@ -3,5 +3,5 @@ rmn equ 5 rup equ 0 rtp equ 0 biosver macro - db "3.5.0-dev.90" + db "3.5.0-dev.91" endm