[3] | 1 | ; Project name : IDE BIOS
|
---|
| 2 | ; Description : Various floppy drive related functions that
|
---|
| 3 | ; Boot Menu uses.
|
---|
| 4 |
|
---|
| 5 | ; Section containing code
|
---|
| 6 | SECTION .text
|
---|
| 7 |
|
---|
| 8 | ;--------------------------------------------------------------------
|
---|
| 9 | ; Checks is floppy drive handler installed to interrupt vector 40h.
|
---|
| 10 | ;
|
---|
| 11 | ; FloppyDrive_IsInt40hInstalled
|
---|
| 12 | ; Parameters:
|
---|
| 13 | ; ES: BDA and Interrupt Vector segment (zero)
|
---|
| 14 | ; Returns:
|
---|
| 15 | ; CF: Set if INT 40h is installed
|
---|
| 16 | ; Cleared if INT 40h is not installed
|
---|
| 17 | ; Corrupts registers:
|
---|
| 18 | ; BX, CX, DI
|
---|
[86] | 19 | ;--------------------------------------------------------------------
|
---|
[39] | 20 | ;ALIGN JUMP_ALIGN
|
---|
[3] | 21 | FloppyDrive_IsInt40hInstalled:
|
---|
| 22 | cmp WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h ; Any ROM segment?
|
---|
[39] | 23 | jb SHORT .Int40hHandlerIsNotInstalled
|
---|
| 24 | call .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
|
---|
| 25 | .Int40hHandlerIsNotInstalled:
|
---|
[27] | 26 | cmc
|
---|
[3] | 27 | ret
|
---|
| 28 |
|
---|
[39] | 29 | ;--------------------------------------------------------------------
|
---|
| 30 | ; .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
|
---|
| 31 | ; Parameters:
|
---|
| 32 | ; Nothing
|
---|
| 33 | ; Returns:
|
---|
| 34 | ; CF: Cleared if INT 40h is installed
|
---|
| 35 | ; Set if INT 40h is not installed
|
---|
| 36 | ; Corrupts registers:
|
---|
| 37 | ; BX, CX, DI
|
---|
[86] | 38 | ;--------------------------------------------------------------------
|
---|
[39] | 39 | ;ALIGN JUMP_ALIGN
|
---|
| 40 | .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
|
---|
| 41 | push es
|
---|
| 42 | push dx
|
---|
| 43 | push ax
|
---|
[3] | 44 |
|
---|
[39] | 45 | call .LoadInt40hVerifyParameters
|
---|
| 46 | int INTV_DISK_FUNC
|
---|
| 47 | jc SHORT .AH08hNotSupported ; AH=08h not supported on XTs but that doesn't
|
---|
| 48 | push es ; matter since INT 40h does not need to be verified
|
---|
| 49 | push di ; on XTs
|
---|
| 50 |
|
---|
| 51 | call .LoadInt40hVerifyParameters
|
---|
| 52 | int INTV_FLOPPY_FUNC
|
---|
| 53 |
|
---|
| 54 | pop dx
|
---|
| 55 | pop cx
|
---|
| 56 | cmp dx, di ; Difference in offsets?
|
---|
| 57 | jne SHORT .Int40hNotInstalled
|
---|
| 58 | mov dx, es
|
---|
| 59 | cmp cx, dx ; Difference in segments?
|
---|
| 60 | jne SHORT .Int40hNotInstalled
|
---|
| 61 | .AH08hNotSupported:
|
---|
| 62 | clc
|
---|
| 63 | jmp SHORT .Int40hIsInstalled
|
---|
| 64 | .Int40hNotInstalled:
|
---|
| 65 | stc
|
---|
| 66 | .Int40hIsInstalled:
|
---|
| 67 | pop ax
|
---|
| 68 | pop dx
|
---|
| 69 | pop es
|
---|
| 70 | ret
|
---|
| 71 |
|
---|
[3] | 72 | ;--------------------------------------------------------------------
|
---|
[39] | 73 | ; .LoadInt40hVerifyParameters
|
---|
| 74 | ; Parameters:
|
---|
| 75 | ; Nothing
|
---|
| 76 | ; Returns:
|
---|
| 77 | ; AH: 08h (Get Drive Parameters)
|
---|
| 78 | ; DL: 00h (floppy drive)
|
---|
| 79 | ; ES:DI: 0:0h (to guard against BIOS bugs)
|
---|
| 80 | ; Corrupts registers:
|
---|
| 81 | ; DH
|
---|
[86] | 82 | ;--------------------------------------------------------------------
|
---|
[39] | 83 | ;ALIGN JUMP_ALIGN
|
---|
| 84 | .LoadInt40hVerifyParameters:
|
---|
[86] | 85 | mov ah, 08h ; Get Drive Parameters
|
---|
| 86 | cwd ; Floppy drive 0
|
---|
[39] | 87 | mov di, dx
|
---|
| 88 | mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs
|
---|
| 89 | ret
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
| 113 | ALIGN JUMP_ALIGN
|
---|
| 114 | FloppyDrive_GetType:
|
---|
| 115 | mov ah, 08h ; Get Drive Parameters
|
---|
| 116 | xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
|
---|
| 117 | int INTV_FLOPPY_FUNC
|
---|
| 118 | ret
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | ;--------------------------------------------------------------------
|
---|
| 122 | ; Returns number of Floppy Drives in system.
|
---|
| 123 | ;
|
---|
| 124 | ; FloppyDrive_GetCount
|
---|
| 125 | ; Parameters:
|
---|
| 126 | ; Nothing
|
---|
| 127 | ; Returns:
|
---|
| 128 | ; CX: Number of Floppy Drives
|
---|
| 129 | ; Corrupts registers:
|
---|
| 130 | ; Nothing
|
---|
| 131 | ;--------------------------------------------------------------------
|
---|
| 132 | ALIGN JUMP_ALIGN
|
---|
| 133 | FloppyDrive_GetCount:
|
---|
| 134 | push es
|
---|
| 135 | call FloppyDrive_GetCountFromBIOS
|
---|
| 136 | jnc SHORT .CompareToUserMinimum
|
---|
| 137 | call FloppyDrive_GetCountFromBDA
|
---|
| 138 | ALIGN JUMP_ALIGN
|
---|
| 139 | .CompareToUserMinimum:
|
---|
| 140 | MAX_U cl, [cs:ROMVARS.bMinFddCnt]
|
---|
| 141 | xor ch, ch
|
---|
| 142 | pop es
|
---|
| 143 | ret
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | ;--------------------------------------------------------------------
|
---|
| 147 | ; Reads Floppy Drive Count from BIOS.
|
---|
| 148 | ; Does not work on most XT systems. Call FloppyDrive_GetCountFromBDA
|
---|
| 149 | ; if this function fails.
|
---|
| 150 | ;
|
---|
| 151 | ; FloppyDrive_GetCountFromBIOS
|
---|
| 152 | ; Parameters:
|
---|
| 153 | ; Nothing
|
---|
| 154 | ; Returns:
|
---|
| 155 | ; CL: Number of Floppy Drives
|
---|
| 156 | ; CF: Cleared if successfull
|
---|
| 157 | ; Set if BIOS function not supported
|
---|
| 158 | ; Corrupts registers:
|
---|
| 159 | ; CH, ES
|
---|
| 160 | ;--------------------------------------------------------------------
|
---|
| 161 | ALIGN JUMP_ALIGN
|
---|
| 162 | FloppyDrive_GetCountFromBIOS:
|
---|
| 163 | push di
|
---|
| 164 | push dx
|
---|
| 165 | push bx
|
---|
| 166 | push ax
|
---|
| 167 |
|
---|
| 168 | mov ah, 08h ; Get Drive Parameters
|
---|
[86] | 169 | cwd ; Floppy Drive 00h
|
---|
[3] | 170 | int INTV_FLOPPY_FUNC
|
---|
| 171 | mov cl, dl ; Number of Floppy Drives to CL
|
---|
| 172 |
|
---|
| 173 | pop ax
|
---|
| 174 | pop bx
|
---|
| 175 | pop dx
|
---|
| 176 | pop di
|
---|
| 177 | ret
|
---|
| 178 |
|
---|
| 179 |
|
---|
| 180 | ;--------------------------------------------------------------------
|
---|
| 181 | ; Reads Floppy Drive Count (0...4) from BIOS Data Area.
|
---|
| 182 | ; This function should be used only if FloppyDrive_GetCountFromBIOS fails.
|
---|
| 183 | ;
|
---|
| 184 | ; FloppyDrive_GetCountFromBDA
|
---|
| 185 | ; Parameters:
|
---|
| 186 | ; Nothing
|
---|
| 187 | ; Returns:
|
---|
| 188 | ; CL: Number of Floppy Drives
|
---|
| 189 | ; Corrupts registers:
|
---|
| 190 | ; CH, ES
|
---|
| 191 | ;--------------------------------------------------------------------
|
---|
| 192 | ALIGN JUMP_ALIGN
|
---|
| 193 | FloppyDrive_GetCountFromBDA:
|
---|
| 194 | LOAD_BDA_SEGMENT_TO es, cx
|
---|
| 195 | mov cl, [es:BDA.wEquipment] ; Load Equipment WORD low byte
|
---|
| 196 | mov ch, cl ; Copy it to CH
|
---|
| 197 | and cx, 0C001h ; Leave bits 15..14 and 0
|
---|
| 198 | eROL_IM ch, 2 ; EW low byte bits 7..6 to 1..0
|
---|
| 199 | add cl, ch ; CL = Floppy Drive count
|
---|
| 200 | ret
|
---|