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