[102] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Various floppy drive related functions that
|
---|
| 3 | ; Boot Menu uses.
|
---|
| 4 |
|
---|
[376] | 5 | ;
|
---|
[526] | 6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
| 7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
[376] | 8 | ;
|
---|
| 9 | ; This program is free software; you can redistribute it and/or modify
|
---|
| 10 | ; it under the terms of the GNU General Public License as published by
|
---|
| 11 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
| 12 | ; (at your option) any later version.
|
---|
[526] | 13 | ;
|
---|
[376] | 14 | ; This program is distributed in the hope that it will be useful,
|
---|
| 15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
[526] | 17 | ; GNU General Public License for more details.
|
---|
[376] | 18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
[526] | 19 | ;
|
---|
[376] | 20 |
|
---|
[3] | 21 | ; Section containing code
|
---|
| 22 | SECTION .text
|
---|
| 23 |
|
---|
| 24 | ;--------------------------------------------------------------------
|
---|
| 25 | ; Checks is floppy drive handler installed to interrupt vector 40h.
|
---|
| 26 | ;
|
---|
| 27 | ; FloppyDrive_IsInt40hInstalled
|
---|
| 28 | ; Parameters:
|
---|
| 29 | ; ES: BDA and Interrupt Vector segment (zero)
|
---|
| 30 | ; Returns:
|
---|
| 31 | ; CF: Set if INT 40h is installed
|
---|
| 32 | ; Cleared if INT 40h is not installed
|
---|
| 33 | ; Corrupts registers:
|
---|
| 34 | ; BX, CX, DI
|
---|
[86] | 35 | ;--------------------------------------------------------------------
|
---|
[3] | 36 | FloppyDrive_IsInt40hInstalled:
|
---|
[99] | 37 | %ifdef USE_AT
|
---|
[39] | 38 | push es
|
---|
| 39 | push dx
|
---|
| 40 | push ax
|
---|
[3] | 41 |
|
---|
[530] | 42 | call LoadInt40hVerifyParameters
|
---|
[152] | 43 | int BIOS_DISK_INTERRUPT_13h
|
---|
[99] | 44 | jc SHORT .Int40hIsInstalled ; Maybe there are not any floppy drives at all
|
---|
[530] | 45 | push es ; Drive Parameter Table segment
|
---|
| 46 | push di ; Drive Parameter Table offset
|
---|
[39] | 47 |
|
---|
[530] | 48 | call LoadInt40hVerifyParameters
|
---|
[152] | 49 | int BIOS_DISKETTE_INTERRUPT_40h
|
---|
[39] | 50 |
|
---|
| 51 | pop dx
|
---|
| 52 | pop cx
|
---|
| 53 | cmp dx, di ; Difference in offsets?
|
---|
| 54 | jne SHORT .Int40hNotInstalled
|
---|
| 55 | mov dx, es
|
---|
| 56 | cmp cx, dx ; Difference in segments?
|
---|
[99] | 57 | je SHORT .Int40hIsInstalled
|
---|
[39] | 58 | .Int40hNotInstalled:
|
---|
| 59 | stc
|
---|
| 60 | .Int40hIsInstalled:
|
---|
| 61 | pop ax
|
---|
| 62 | pop dx
|
---|
| 63 | pop es
|
---|
[530] | 64 |
|
---|
| 65 | %else ; if XT build
|
---|
[531] | 66 | cmp BYTE [es:BIOS_DISKETTE_INTERRUPT_40h*4+3], 0C0h ; Any ROM segment? (set CF if not)
|
---|
[530] | 67 | %endif ; USE_AT
|
---|
| 68 | cmc
|
---|
[39] | 69 | ret
|
---|
| 70 |
|
---|
[3] | 71 | ;--------------------------------------------------------------------
|
---|
[530] | 72 | ; LoadInt40hVerifyParameters
|
---|
[39] | 73 | ; Parameters:
|
---|
| 74 | ; Nothing
|
---|
| 75 | ; Returns:
|
---|
| 76 | ; AH: 08h (Get Drive Parameters)
|
---|
| 77 | ; DL: 00h (floppy drive)
|
---|
| 78 | ; ES:DI: 0:0h (to guard against BIOS bugs)
|
---|
| 79 | ; Corrupts registers:
|
---|
| 80 | ; DH
|
---|
[86] | 81 | ;--------------------------------------------------------------------
|
---|
[530] | 82 | %ifdef USE_AT
|
---|
| 83 | LoadInt40hVerifyParameters:
|
---|
| 84 | mov ah, GET_DRIVE_PARAMETERS
|
---|
| 85 | cwd ; Floppy drive 0
|
---|
[39] | 86 | mov di, dx
|
---|
[530] | 87 | mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs
|
---|
[39] | 88 | ret
|
---|
[99] | 89 | %endif
|
---|
[39] | 90 |
|
---|
| 91 |
|
---|
| 92 | ;--------------------------------------------------------------------
|
---|
[3] | 93 | ; Returns floppy drive type.
|
---|
| 94 | ; PC/XT system do not support AH=08h but FLOPPY_TYPE_525_OR_35_DD
|
---|
| 95 | ; is still returned for them.
|
---|
| 96 | ;
|
---|
| 97 | ; FloppyDrive_GetType
|
---|
| 98 | ; Parameters:
|
---|
| 99 | ; DL: Floppy Drive number
|
---|
| 100 | ; Returns:
|
---|
| 101 | ; BX: Floppy Drive Type:
|
---|
| 102 | ; FLOPPY_TYPE_525_OR_35_DD
|
---|
| 103 | ; FLOPPY_TYPE_525_DD
|
---|
| 104 | ; FLOPPY_TYPE_525_HD
|
---|
| 105 | ; FLOPPY_TYPE_35_DD
|
---|
| 106 | ; FLOPPY_TYPE_35_HD
|
---|
| 107 | ; FLOPPY_TYPE_35_ED
|
---|
| 108 | ; CF: Set if AH=08h not supported (XT systems) or error
|
---|
| 109 | ; Cleared if type read correctly (AT systems)
|
---|
| 110 | ; Corrupts registers:
|
---|
| 111 | ; AX, CX, DX, DI, ES
|
---|
| 112 | ;--------------------------------------------------------------------
|
---|
[392] | 113 | %ifdef MODULE_BOOT_MENU
|
---|
[3] | 114 | FloppyDrive_GetType:
|
---|
[530] | 115 | mov ah, GET_DRIVE_PARAMETERS
|
---|
[3] | 116 | xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
|
---|
[152] | 117 | int BIOS_DISKETTE_INTERRUPT_40h
|
---|
[3] | 118 | ret
|
---|
[392] | 119 | %endif
|
---|
[3] | 120 |
|
---|
| 121 |
|
---|
| 122 | ;--------------------------------------------------------------------
|
---|
| 123 | ; Returns number of Floppy Drives in system.
|
---|
| 124 | ;
|
---|
[258] | 125 | ; FloppyDrive_GetCountToAX
|
---|
[3] | 126 | ; Parameters:
|
---|
[258] | 127 | ; DS: RAMVARS Segment
|
---|
[3] | 128 | ; Returns:
|
---|
[258] | 129 | ; AX: Number of Floppy Drives
|
---|
[3] | 130 | ;--------------------------------------------------------------------
|
---|
[294] | 131 | FloppyDrive_GetCountToAX:
|
---|
[258] | 132 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
| 133 | call RamVars_UnpackFlopCntAndFirstToAL
|
---|
[270] | 134 | js .UseBIOSorBDA ; We didn't add in any drives, counts here are not valid
|
---|
[294] | 135 |
|
---|
[531] | 136 | adc al, 1 ; adds in the drive count bit, and adds 1 for count vs. 0-index,
|
---|
[270] | 137 | jmp .FinishCalc ; need to clear AH on the way out, and add in minimum drive numbers
|
---|
[258] | 138 |
|
---|
[294] | 139 | .UseBIOSorBDA:
|
---|
[99] | 140 | %endif
|
---|
[258] | 141 | call FloppyDrive_GetCountFromBIOS_or_BDA
|
---|
[270] | 142 |
|
---|
[294] | 143 | .FinishCalc:
|
---|
[258] | 144 | mov ah, [cs:ROMVARS.bMinFddCnt]
|
---|
| 145 | MAX_U al, ah
|
---|
| 146 | cbw
|
---|
[294] | 147 |
|
---|
[3] | 148 | ret
|
---|
| 149 |
|
---|
| 150 |
|
---|
| 151 | ;--------------------------------------------------------------------
|
---|
[530] | 152 | ; FloppyDrive_GetCountFromBIOS_or_BDA
|
---|
[3] | 153 | ; Parameters:
|
---|
| 154 | ; Nothing
|
---|
| 155 | ; Returns:
|
---|
[274] | 156 | ; AL: Number of Floppy Drives
|
---|
[294] | 157 | ; CF: Cleared if successful
|
---|
[3] | 158 | ; Set if BIOS function not supported
|
---|
| 159 | ; Corrupts registers:
|
---|
[547] | 160 | ; AH
|
---|
[3] | 161 | ;--------------------------------------------------------------------
|
---|
[530] | 162 | FloppyDrive_GetCountFromBIOS_or_BDA:
|
---|
[567] | 163 | %ifdef USE_AT
|
---|
[530] | 164 | ; Reads Floppy Drive Count from BIOS.
|
---|
| 165 | ; Does not work on most XT systems. Call .GetCountFromBDA
|
---|
| 166 | ; if this function fails.
|
---|
[567] | 167 |
|
---|
| 168 | push es
|
---|
[3] | 169 | push di
|
---|
[274] | 170 | push bx
|
---|
| 171 | push cx
|
---|
[3] | 172 | push dx
|
---|
| 173 |
|
---|
[530] | 174 | mov ah, GET_DRIVE_PARAMETERS
|
---|
[86] | 175 | cwd ; Floppy Drive 00h
|
---|
[152] | 176 | int BIOS_DISKETTE_INTERRUPT_40h
|
---|
[551] | 177 | xchg ax, dx ; Number of Floppy Drives to AL
|
---|
[3] | 178 |
|
---|
[274] | 179 | pop dx
|
---|
| 180 | pop cx
|
---|
[3] | 181 | pop bx
|
---|
| 182 | pop di
|
---|
[567] | 183 | pop es
|
---|
[3] | 184 |
|
---|
[567] | 185 | %else ; ifndef USE_AT
|
---|
[3] | 186 | ; Reads Floppy Drive Count (0...4) from BIOS Data Area.
|
---|
[294] | 187 | ; This function should be used only if .GetCountFromBIOS fails.
|
---|
[531] | 188 |
|
---|
[567] | 189 | push ds
|
---|
| 190 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
| 191 | mov al, [BDA.wEquipment] ; Load Equipment WORD low byte
|
---|
| 192 | pop ds
|
---|
| 193 |
|
---|
[531] | 194 | %ifdef USE_UNDOC_INTEL
|
---|
| 195 | and al, 0C1h
|
---|
| 196 | eAAM 64
|
---|
| 197 | %else
|
---|
[530] | 198 | mov ah, al ; Copy it to AH
|
---|
| 199 | and ax, 0C001h ; Leave bits 15..14 and 0
|
---|
| 200 | eROL_IM ah, 2 ; EW low byte bits 7..6 to 1..0
|
---|
[531] | 201 | %endif ; USE_UNDOC_INTEL
|
---|
| 202 |
|
---|
[530] | 203 | add al, ah ; AL = Floppy Drive count
|
---|
[531] | 204 | %endif ; USE_AT
|
---|
[258] | 205 |
|
---|
[3] | 206 | ret
|
---|