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