[99] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for swapping drive letters.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .text
|
---|
| 6 |
|
---|
| 7 | ;--------------------------------------------------------------------
|
---|
| 8 | ; Translates drive number when entering INT 13h.
|
---|
| 9 | ;
|
---|
| 10 | ; DriveXlate_WhenEnteringInt13h
|
---|
| 11 | ; Parameters:
|
---|
| 12 | ; DL: Drive number to be possibly translated
|
---|
| 13 | ; DS: RAMVARS segment
|
---|
| 14 | ; Returns:
|
---|
| 15 | ; DL: Translated drive number
|
---|
| 16 | ; Corrupts registers:
|
---|
| 17 | ; DI
|
---|
| 18 | ;--------------------------------------------------------------------
|
---|
| 19 | ALIGN JUMP_ALIGN
|
---|
| 20 | DriveXlate_WhenEnteringInt13h:
|
---|
| 21 | inc BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
|
---|
| 22 | cmp BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt], 1
|
---|
| 23 | je SHORT DriveXlate_ToOrBack
|
---|
| 24 | ret
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | ;--------------------------------------------------------------------
|
---|
[35] | 28 | ; DriveXlate_WhenLeavingInt13hWithReturnValueInDL
|
---|
| 29 | ; Parameters:
|
---|
| 30 | ; DS: RAMVARS segment
|
---|
| 31 | ; Returns:
|
---|
| 32 | ; Nothing
|
---|
| 33 | ; Corrupts registers:
|
---|
| 34 | ; DI
|
---|
| 35 | ;--------------------------------------------------------------------
|
---|
| 36 | ALIGN JUMP_ALIGN
|
---|
| 37 | DriveXlate_WhenLeavingInt13hWithReturnValueInDL:
|
---|
| 38 | dec BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
|
---|
| 39 | ret
|
---|
| 40 |
|
---|
| 41 | ;--------------------------------------------------------------------
|
---|
[3] | 42 | ; Translates drive number when leaving INT 13h.
|
---|
| 43 | ;
|
---|
| 44 | ; DriveXlate_WhenLeavingInt13h
|
---|
| 45 | ; Parameters:
|
---|
| 46 | ; DL: Drive number to be possibly translated
|
---|
| 47 | ; DS: RAMVARS segment
|
---|
| 48 | ; Returns:
|
---|
| 49 | ; DL: Translated drive number
|
---|
| 50 | ; Corrupts registers:
|
---|
| 51 | ; DI
|
---|
| 52 | ;--------------------------------------------------------------------
|
---|
| 53 | ALIGN JUMP_ALIGN
|
---|
| 54 | DriveXlate_WhenLeavingInt13h:
|
---|
| 55 | dec BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
|
---|
| 56 | jz SHORT DriveXlate_ToOrBack
|
---|
| 57 | ret
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | ;--------------------------------------------------------------------
|
---|
| 61 | ; Translates drive number to or back.
|
---|
| 62 | ;
|
---|
| 63 | ; DriveXlate_ToOrBack
|
---|
| 64 | ; Parameters:
|
---|
| 65 | ; DL: Drive number to be possibly translated
|
---|
| 66 | ; DS: RAMVARS segment
|
---|
| 67 | ; Returns:
|
---|
| 68 | ; DL: Translated drive number
|
---|
| 69 | ; Corrupts registers:
|
---|
| 70 | ; DI
|
---|
| 71 | ;--------------------------------------------------------------------
|
---|
| 72 | ALIGN JUMP_ALIGN
|
---|
| 73 | DriveXlate_ToOrBack:
|
---|
| 74 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_DRVXLAT
|
---|
| 75 | jz SHORT .Return ; Return if translation disabled
|
---|
| 76 | xchg di, ax ; Backup AX
|
---|
| 77 | call DriveXlate_SwapFloppyDriveOrHardDisk
|
---|
| 78 | xchg ax, di
|
---|
| 79 | .Return:
|
---|
| 80 | ret
|
---|
| 81 |
|
---|
| 82 |
|
---|
| 83 | ;--------------------------------------------------------------------
|
---|
| 84 | ; Swaps Floppy Drive or Hard Disk number.
|
---|
| 85 | ;
|
---|
| 86 | ; DriveXlate_SwapFloppyDriveOrHardDisk
|
---|
| 87 | ; Parameters:
|
---|
| 88 | ; DL: Drive number to be possibly swapped
|
---|
| 89 | ; DS: RAMVARS segment
|
---|
| 90 | ; Returns:
|
---|
| 91 | ; DL: Translated drive number
|
---|
| 92 | ; Corrupts registers:
|
---|
| 93 | ; AX
|
---|
| 94 | ;--------------------------------------------------------------------
|
---|
| 95 | ALIGN JUMP_ALIGN
|
---|
| 96 | DriveXlate_SwapFloppyDriveOrHardDisk:
|
---|
[126] | 97 | mov ah, 80h ; Assume hard disk
|
---|
[3] | 98 | mov al, BYTE [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
|
---|
[126] | 99 | test dl, ah ; Hard disk?
|
---|
| 100 | jnz SHORT SwapDrive ; If so, jump to swap
|
---|
| 101 | mov al, BYTE [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
|
---|
| 102 | cbw
|
---|
[99] | 103 | ; Fall to SwapDrive
|
---|
[3] | 104 |
|
---|
| 105 | ;--------------------------------------------------------------------
|
---|
[99] | 106 | ; SwapDrive
|
---|
[3] | 107 | ; Parameters:
|
---|
| 108 | ; AL: Drive number to swap to 00h/80h
|
---|
| 109 | ; AH: 00h/80h to be swapped to stored drive number
|
---|
| 110 | ; DL: Drive number to be possibly swapped
|
---|
| 111 | ; Returns:
|
---|
| 112 | ; DL: Translated drive number
|
---|
| 113 | ; Corrupts registers:
|
---|
| 114 | ; Nothing
|
---|
| 115 | ;--------------------------------------------------------------------
|
---|
[126] | 116 | ALIGN JUMP_ALIGN
|
---|
[99] | 117 | SwapDrive:
|
---|
[3] | 118 | cmp ah, dl ; Swap DL from 00h/80h to xxh?
|
---|
| 119 | je SHORT .SwapToXXhInAL
|
---|
| 120 | cmp al, dl ; Swap DL from xxh to 00h/80h?
|
---|
| 121 | je SHORT .SwapTo00hOr80hInAH
|
---|
| 122 | ret
|
---|
| 123 | ALIGN JUMP_ALIGN
|
---|
| 124 | .SwapTo00hOr80hInAH:
|
---|
| 125 | mov dl, ah
|
---|
| 126 | ret
|
---|
| 127 | ALIGN JUMP_ALIGN
|
---|
| 128 | .SwapToXXhInAL:
|
---|
| 129 | mov dl, al
|
---|
| 130 | ret
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | ;--------------------------------------------------------------------
|
---|
| 134 | ; Resets drive swapping variables to defaults (no swapping).
|
---|
| 135 | ;
|
---|
| 136 | ; DriveXlate_Reset
|
---|
| 137 | ; Parameters:
|
---|
| 138 | ; DS: RAMVARS segment
|
---|
| 139 | ; Returns:
|
---|
| 140 | ; Nothing
|
---|
| 141 | ; Corrupts registers:
|
---|
| 142 | ; AX
|
---|
[128] | 143 | ;--------------------------------------------------------------------
|
---|
[3] | 144 | ALIGN JUMP_ALIGN
|
---|
| 145 | DriveXlate_Reset:
|
---|
| 146 | mov WORD [RAMVARS.xlateVars], 8000h ; .bFDSwap and .bHDSwap
|
---|
| 147 | mov BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt], 0
|
---|
| 148 | ret
|
---|
| 149 |
|
---|
| 150 |
|
---|
| 151 | ;--------------------------------------------------------------------
|
---|
| 152 | ; Stores drive to be swapped.
|
---|
| 153 | ;
|
---|
| 154 | ; DriveXlate_SetDriveToSwap
|
---|
| 155 | ; Parameters:
|
---|
| 156 | ; DL: Drive to swap to 00h or 80h
|
---|
| 157 | ; DS: RAMVARS segment
|
---|
| 158 | ; Returns:
|
---|
| 159 | ; Nothing
|
---|
| 160 | ; Corrupts registers:
|
---|
| 161 | ; Nothing
|
---|
[128] | 162 | ;--------------------------------------------------------------------
|
---|
[3] | 163 | ALIGN JUMP_ALIGN
|
---|
| 164 | DriveXlate_SetDriveToSwap:
|
---|
[128] | 165 | test dl, dl ; Floppy drive?
|
---|
| 166 | js SHORT .SetHardDiskToSwap
|
---|
[99] | 167 | .SetFloppyDriveToSwap:
|
---|
[3] | 168 | mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
|
---|
| 169 | ret
|
---|
| 170 | ALIGN JUMP_ALIGN
|
---|
[99] | 171 | .SetHardDiskToSwap:
|
---|
[3] | 172 | mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
|
---|
| 173 | ret
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 | ;--------------------------------------------------------------------
|
---|
| 177 | ; Checks if INT 13h function returns some value in DL
|
---|
| 178 | ; (other than the drive number that was also parameter).
|
---|
| 179 | ;
|
---|
| 180 | ; DriveXlate_DoesFunctionReturnSomethingInDL
|
---|
| 181 | ; Parameters:
|
---|
| 182 | ; AH: INT 13h BIOS Function
|
---|
| 183 | ; DL: Drive number
|
---|
| 184 | ; Returns:
|
---|
| 185 | ; CF: Set if something is returned in DL
|
---|
| 186 | ; Cleared if only drive number parameter is returned in DL
|
---|
| 187 | ; Corrupts registers:
|
---|
| 188 | ; Nothing
|
---|
[128] | 189 | ;--------------------------------------------------------------------
|
---|
[3] | 190 | ALIGN JUMP_ALIGN
|
---|
| 191 | DriveXlate_DoesFunctionReturnSomethingInDL:
|
---|
| 192 | cmp ah, 08h ; AH=08h, Read Disk Drive Parameters?
|
---|
| 193 | je SHORT DriveXlate_FunctionReturnsSomethingInDL
|
---|
[128] | 194 | test dl, dl
|
---|
| 195 | jns SHORT DriveXlate_DoesFloppyFunctionReturnSomethingInDL
|
---|
[3] | 196 | ; Fall to DriveXlate_DoesHardDiskFunctionReturnSomethingInDL
|
---|
| 197 |
|
---|
| 198 | ;--------------------------------------------------------------------
|
---|
| 199 | ; Checks if INT 13h hard disk or floppy drive function returns some
|
---|
| 200 | ; value in DL other than the drive number that was also parameter).
|
---|
| 201 | ; Some functions return different values for hard disks and floppy drives.
|
---|
| 202 | ;
|
---|
| 203 | ; DriveXlate_DoesHardDiskFunctionReturnSomethingInDL
|
---|
| 204 | ; DriveXlate_DoesFloppyFunctionReturnSomethingInDL
|
---|
| 205 | ; Parameters:
|
---|
| 206 | ; AH: INT 13h BIOS Function
|
---|
| 207 | ; DL: Hard Disk number
|
---|
| 208 | ; Returns:
|
---|
| 209 | ; CF: Set if something is returned in DL
|
---|
| 210 | ; Cleared if only drive number parameter is returned in DL
|
---|
| 211 | ; Corrupts registers:
|
---|
| 212 | ; Nothing
|
---|
[128] | 213 | ;--------------------------------------------------------------------
|
---|
[3] | 214 | ; ALIGN JUMP_ALIGN
|
---|
| 215 | DriveXlate_DoesHardDiskFunctionReturnSomethingInDL:
|
---|
| 216 | cmp ah, 15h ; AH=15h, Read Disk Drive Size?
|
---|
| 217 | je SHORT DriveXlate_FunctionReturnsSomethingInDL
|
---|
| 218 | DriveXlate_DoesFloppyFunctionReturnSomethingInDL:
|
---|
| 219 | clc
|
---|
| 220 | ret
|
---|
| 221 |
|
---|
| 222 | ALIGN JUMP_ALIGN
|
---|
| 223 | DriveXlate_FunctionReturnsSomethingInDL:
|
---|
| 224 | stc
|
---|
| 225 | ret
|
---|