[29] | 1 | ; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
|
---|
| 2 | ;
|
---|
| 3 | ; This file is part of AiR-BOOT
|
---|
| 4 | ;
|
---|
| 5 | ; AiR-BOOT is free software: you can redistribute it and/or modify it under
|
---|
| 6 | ; the terms of the GNU General Public License as published by the Free
|
---|
| 7 | ; Software Foundation, either version 3 of the License, or (at your option)
|
---|
| 8 | ; any later version.
|
---|
| 9 | ;
|
---|
| 10 | ; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 11 | ; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
---|
| 13 | ; details.
|
---|
| 14 | ;
|
---|
| 15 | ; You should have received a copy of the GNU General Public License along with
|
---|
| 16 | ; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | ;
|
---|
[8] | 18 | ;---------------------------------------------------------------------------
|
---|
| 19 | ; AiR-BOOT / DRIVE I/O
|
---|
| 20 | ;---------------------------------------------------------------------------
|
---|
| 21 |
|
---|
[30] | 22 |
|
---|
| 23 |
|
---|
[51] | 24 | IFDEF MODULE_NAMES
|
---|
[30] | 25 | DB 'DRIVEIO',0
|
---|
| 26 | ENDIF
|
---|
| 27 |
|
---|
[95] | 28 | ;
|
---|
| 29 | ; Check if INT13X extensions are supported.
|
---|
| 30 | ; AirBoot requires these extensions, and will halt if they are not available.
|
---|
[140] | 31 | ; Modified: [CurIO_UseExtension]
|
---|
| 32 | DriveIO_CheckFor13extensions Proc Near Uses ax bx cx dx
|
---|
[95] | 33 | mov ah, 41h
|
---|
| 34 | mov bx, 55AAh
|
---|
| 35 | mov dl, [BIOS_BootDisk] ; We check using the boot-disk
|
---|
| 36 | int 13h
|
---|
[175] | 37 | sti
|
---|
[117] | 38 |
|
---|
| 39 | IFDEF AUX_DEBUG
|
---|
| 40 | IF 0
|
---|
[123] | 41 | DBG_TEXT_OUT_AUX 'DriveIO_CheckFor13extensions:'
|
---|
| 42 | PUSHRF
|
---|
[117] | 43 | call DEBUG_DumpRegisters
|
---|
| 44 | ;~ call AuxIO_DumpParagraph
|
---|
| 45 | ;~ call AuxIO_TeletypeNL
|
---|
[134] | 46 | mov si, offset [Scratch]
|
---|
[117] | 47 | mov word ptr [si], 50h
|
---|
| 48 | mov ah, 48h
|
---|
| 49 | int 13h
|
---|
[175] | 50 | sti
|
---|
[117] | 51 | call DEBUG_DumpRegisters
|
---|
| 52 | ;~ call AuxIO_DumpSector
|
---|
[123] | 53 | POPRF
|
---|
[117] | 54 | ENDIF
|
---|
| 55 | ENDIF
|
---|
| 56 |
|
---|
[95] | 57 | jc PCCF13E_NotFound ; Error occured
|
---|
| 58 | cmp bx, 0AA55h
|
---|
| 59 | je PCCF13E_Found
|
---|
| 60 | PCCF13E_NotFound:
|
---|
| 61 | ret
|
---|
| 62 | PCCF13E_Found:
|
---|
| 63 | and cx, 1 ; Check 42h-44h,47h,48h supported
|
---|
| 64 | jz PCCF13E_NotFound ; Sig OK but no support, strange beast
|
---|
| 65 | mov byte ptr [CurIO_UseExtension], 1
|
---|
| 66 | ret
|
---|
| 67 | DriveIO_CheckFor13extensions EndP
|
---|
| 68 |
|
---|
| 69 |
|
---|
[29] | 70 | ; Note: Some routines set DS/ES to CS or even address via CS, even if its not
|
---|
| 71 | ; needed. This was done for SECURITY. So DO NOT remove it.
|
---|
| 72 | ; Its there to make sure the correct data is loaded/written to/from
|
---|
| 73 | ; harddrive.
|
---|
[8] | 74 | ;
|
---|
[29] | 75 | ; IF YOU MODIFY ANYTHING IN HERE, YOU MAY EASILY BREAK YOUR HARDDRIVE!
|
---|
[8] | 76 |
|
---|
| 77 | ; Will only load base-configuration, will NOT load IPT nor Hide-Config
|
---|
| 78 | ; Those are originally loaded on startup and will NOT get reloaded.
|
---|
[43] | 79 | DriveIO_LoadConfiguration Proc Near Uses ax bx cx dx es
|
---|
[111] | 80 |
|
---|
| 81 | IFDEF AUX_DEBUG
|
---|
| 82 | IF 0
|
---|
[123] | 83 | DBG_TEXT_OUT_AUX 'DriveIO_LoadConfiguration:'
|
---|
| 84 | PUSHRF
|
---|
[111] | 85 | ;~ call DEBUG_DumpRegisters
|
---|
| 86 | ;~ call AuxIO_DumpParagraph
|
---|
| 87 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 88 | POPRF
|
---|
[111] | 89 | ENDIF
|
---|
| 90 | ENDIF
|
---|
| 91 |
|
---|
[123] | 92 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
[43] | 93 | mov ax, cs
|
---|
| 94 | mov es, ax
|
---|
| 95 | mov bx, offset Configuration
|
---|
[78] | 96 | xor dh, dh
|
---|
| 97 | mov dl, [BIOS_BootDisk] ; Disk we booted from
|
---|
| 98 | mov cx, 0037h ; Sector 55 (CHS)
|
---|
[43] | 99 | mov ax, 0201h ; Function 02, read 1 sector...
|
---|
| 100 | int 13h
|
---|
[175] | 101 | sti ; Enable ints
|
---|
[43] | 102 | jnc DIOLC_NoError
|
---|
| 103 | call MBR_LoadError ; Will Abort BootUp
|
---|
[123] | 104 |
|
---|
| 105 |
|
---|
[43] | 106 | DIOLC_NoError:
|
---|
| 107 | ret
|
---|
| 108 | DriveIO_LoadConfiguration EndP
|
---|
[8] | 109 |
|
---|
[43] | 110 | DriveIO_SaveConfiguration Proc Near Uses ax bx cx dx ds es si
|
---|
[111] | 111 |
|
---|
| 112 | IFDEF AUX_DEBUG
|
---|
| 113 | IF 0
|
---|
[123] | 114 | DBG_TEXT_OUT_AUX 'DriveIO_SaveConfiguration:'
|
---|
| 115 | PUSHRF
|
---|
[164] | 116 | call DEBUG_DumpRegisters
|
---|
[111] | 117 | ;~ call AuxIO_DumpParagraph
|
---|
| 118 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 119 | POPRF
|
---|
[111] | 120 | ENDIF
|
---|
| 121 | ENDIF
|
---|
| 122 |
|
---|
[43] | 123 | mov ax, cs
|
---|
| 124 | mov ds, ax
|
---|
| 125 | mov es, ax ; Safety first (CS==DS==ES)
|
---|
| 126 | ; --- Overwrite Floppy-Name with "FloppyDrive"
|
---|
| 127 | mov si, offset TXT_Floppy_Drive
|
---|
| 128 | mov di, offset PartitionTable
|
---|
| 129 | sub di, 30 ; Adjust to Floppy-Name
|
---|
| 130 | mov cx, 11
|
---|
| 131 | rep movsb
|
---|
| 132 | mov si, offset Configuration ; Calculate new checksum
|
---|
| 133 | xor bx, bx
|
---|
[31] | 134 |
|
---|
[43] | 135 | ; Changed from 5 to calculated value (not here, see compat. issue below)
|
---|
| 136 | ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
|
---|
| 137 | ; Size of the ab-configuration in 512 byte sectors
|
---|
| 138 | ;mov cx, (MBR_BackUpMBR - Configuration) / 200h
|
---|
[31] | 139 |
|
---|
[43] | 140 | ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
|
---|
[54] | 141 | ; AB v1.0.8+ *should* stores a 7 sector configuration with a
|
---|
[43] | 142 | ; 7 sector checksum.
|
---|
[54] | 143 | ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8+
|
---|
[43] | 144 | ; config as corrupted, while this is not the case.
|
---|
[54] | 145 | ; So, for compatibility reasons, in v1.0.8+, the checksum stored is over
|
---|
[43] | 146 | ; 5 sectors, to be compatible with v1.07.
|
---|
| 147 | ; This may change (be corrected) in future versions !
|
---|
| 148 | mov cx,5
|
---|
[32] | 149 |
|
---|
[43] | 150 | mov dx, [CFG_CheckConfig]
|
---|
| 151 | mov [CFG_CheckConfig], bx
|
---|
| 152 | DIOSC_Loop:
|
---|
| 153 | call MBR_GetCheckOfSector
|
---|
| 154 | loop DIOSC_Loop
|
---|
| 155 | mov [CFG_CheckConfig], bx
|
---|
| 156 | ; --------------------------------------------------------------------
|
---|
| 157 | ; ES == CS
|
---|
| 158 | mov bx, offset Configuration
|
---|
[78] | 159 | xor dh, dh
|
---|
| 160 | mov dl, [BIOS_BootDisk] ; Disk we booted from
|
---|
| 161 | mov cx, 0037h ; Sector 55 (CHS)
|
---|
[31] | 162 |
|
---|
[43] | 163 | ; Changed from 5 to calculated value
|
---|
| 164 | ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
|
---|
| 165 | ; Size of the ab-configuration in 512 byte sectors
|
---|
| 166 | mov al, (MBR_BackUpMBR - Configuration) / 200h
|
---|
| 167 | mov ah,03h
|
---|
[123] | 168 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
[43] | 169 | int 13h
|
---|
[175] | 170 | sti
|
---|
[43] | 171 | jnc DIOSC_NoError
|
---|
| 172 | call MBR_SaveError ; Will Abort BootUp
|
---|
| 173 | DIOSC_NoError:
|
---|
| 174 | ret
|
---|
| 175 | DriveIO_SaveConfiguration EndP
|
---|
[8] | 176 |
|
---|
[43] | 177 | DriveIO_UpdateFloppyName Proc Near Uses bx cx dx ds si es di
|
---|
| 178 | mov ax, cs
|
---|
| 179 | mov ds, ax
|
---|
| 180 | mov es, ax
|
---|
[8] | 181 |
|
---|
[49] | 182 | mov ah, 00h ; Function 0 - Reset Drive
|
---|
[43] | 183 | xor dl, dl
|
---|
| 184 | int 13h
|
---|
[175] | 185 | sti
|
---|
[43] | 186 | xor dx, dx ; Cylinder=0, Head=0
|
---|
| 187 | mov cx, 1 ; Sector=1, Drive=0
|
---|
| 188 | mov bx, offset TmpSector ; ES:BX - TmpSector
|
---|
| 189 | mov ax, 0201h ; Function 2 - Load Sector
|
---|
| 190 | int 13h
|
---|
| 191 | jnc DIOUFN_AllFine
|
---|
[8] | 192 |
|
---|
[43] | 193 | ; --- Overwrite Floppy-Name with "No Disc"
|
---|
| 194 | mov si, offset TXT_Floppy_NoDisc
|
---|
| 195 | xor ax, ax
|
---|
| 196 | DIOUFN_WriteFloppyName:
|
---|
| 197 | mov di, offset PartitionTable
|
---|
| 198 | sub di, 30 ; Adjust to Floppy-Name
|
---|
| 199 | mov cl, 11
|
---|
| 200 | rep movsb
|
---|
| 201 | ret ; AX=-1 -> GotDisc, =0 -> NoDisc
|
---|
[8] | 202 |
|
---|
[43] | 203 | ; --- Floppy found and read, data in TempSector
|
---|
| 204 | DIOUFN_AllFine:
|
---|
| 205 | mov ax, -1
|
---|
| 206 | mov si, offset TXT_Floppy_NoName
|
---|
| 207 | cmp wptr es:[bx+54], 'AF'
|
---|
| 208 | jne DIOUFN_WriteFloppyName
|
---|
| 209 | cmp wptr es:[bx+56], '1T'
|
---|
| 210 | jne DIOUFN_WriteFloppyName
|
---|
| 211 | cmp bptr es:[bx+58], '2'
|
---|
| 212 | jne DIOUFN_WriteFloppyName
|
---|
| 213 | mov si, bx
|
---|
| 214 | add si, 43 ; FAT12 - Volume Label Location
|
---|
| 215 | jmp DIOUFN_WriteFloppyName
|
---|
| 216 | DriveIO_UpdateFloppyName EndP
|
---|
[8] | 217 |
|
---|
| 218 | ; =============================================================================
|
---|
| 219 | ; HARDDRIVE / GENERAL ACCESS
|
---|
| 220 | ; =============================================================================
|
---|
| 221 | ; The following routines are used for harddisc/floppy access.
|
---|
[26] | 222 | ; The access is done via INT 13h/CHS or INT 13h/LBA.
|
---|
| 223 | ; Access will be done prefered by INT 13h/CHS, because it's (I wonder!) much
|
---|
[8] | 224 | ; faster, than the LBA-method. I don't know, why LBA is so slow. Perhaps BIOS.
|
---|
| 225 | ;
|
---|
[26] | 226 | ; Internal access (to AiR-BOOT) is always done via INT 13h/CHS.
|
---|
[8] | 227 |
|
---|
[43] | 228 | DriveIO_GetHardDriveCount Proc Near Uses ds si
|
---|
| 229 | push ds
|
---|
| 230 | push si
|
---|
| 231 | push 0040h
|
---|
| 232 | pop ds
|
---|
| 233 | mov si, 0075h
|
---|
[164] | 234 | mov dh, ds:[si] ; 40:75 -> POST: Total Harddiscs == DH
|
---|
[43] | 235 | pop si
|
---|
| 236 | pop ds
|
---|
[51] | 237 | mov [TotalHarddiscs], dh
|
---|
[43] | 238 | ret
|
---|
| 239 | DriveIO_GetHardDriveCount EndP
|
---|
[29] | 240 |
|
---|
| 241 |
|
---|
| 242 | ; Fills our LBA-Usage table. It holds the LBA-address, where BIOS/CHS access is
|
---|
| 243 | ; stopped and BIOS/LBA access is started.
|
---|
| 244 | ; This is calculated by Sector*Heads. Comparing will get done with Bit 25-10
|
---|
| 245 | ; on LBA sectors, so we actually divide sector number by 1024.
|
---|
[43] | 246 | DriveIO_InitLBASwitchTable Proc Near Uses es di
|
---|
| 247 | mov di, offset LBASwitchTable
|
---|
[51] | 248 | mov dh, [TotalHarddiscs]
|
---|
[78] | 249 | mov dl, 80h ; First disk to process
|
---|
[43] | 250 | DIOILUT_DriveLoop:
|
---|
| 251 | push dx
|
---|
| 252 | push di
|
---|
| 253 | mov ah, 08h
|
---|
| 254 | int 13h ; DISK - GET DRIVE PARAMETERS
|
---|
[175] | 255 | sti ; Enable ints
|
---|
[43] | 256 | mov ah, 0FBh ; Assume 255 heads/63 sectors, if error
|
---|
| 257 | jc DIOILUT_Error
|
---|
| 258 | and cl, 111111b ; Isolate lower 6 bits of CL -> sector count
|
---|
[123] | 259 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
[43] | 260 | ;movzx ax, cl
|
---|
| 261 | mov al,cl
|
---|
| 262 | mov ah,0
|
---|
[30] | 263 |
|
---|
[43] | 264 | mov bl, dh ; DH -> max head number
|
---|
| 265 | mul bl ; AX = Sectors*Heads
|
---|
| 266 | shl ah, 1
|
---|
| 267 | shl ah, 1 ; Shift 2 bits, so we are able to compare to
|
---|
| 268 | ; bit 16-23 of the LBA address
|
---|
| 269 | DIOILUT_Error:
|
---|
| 270 | pop di
|
---|
| 271 | pop dx
|
---|
| 272 | mov bptr ds:[di], ah ; Save that value
|
---|
| 273 | inc di ; Go to next BYTE
|
---|
[78] | 274 | inc dl ; Next disk
|
---|
| 275 | dec dh ; Decrease disks to process
|
---|
| 276 | jnz DIOILUT_DriveLoop ; Next disk if DH != 0
|
---|
[43] | 277 | ret
|
---|
| 278 | DriveIO_InitLBASwitchTable EndP
|
---|
[29] | 279 |
|
---|
[30] | 280 | ; #########################################################################
|
---|
| 281 | ; Routine: Loads partition to ExecBase and checks for validity
|
---|
| 282 | ; #########################################################################
|
---|
| 283 | ; Calling : bx:ax - Absolute sector
|
---|
| 284 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
| 285 | ; Returns : Carry Set if invalid partition encountered
|
---|
| 286 | ; Preserve: all registers
|
---|
| 287 | ; #########################################################################
|
---|
[43] | 288 | DriveIO_LoadPartition Proc Near Uses si
|
---|
[117] | 289 |
|
---|
| 290 | IFDEF AUX_DEBUG
|
---|
| 291 | IF 0
|
---|
[123] | 292 | DBG_TEXT_OUT_AUX 'DriveIO_LoadPartition:'
|
---|
| 293 | PUSHRF
|
---|
[117] | 294 | call DEBUG_DumpRegisters
|
---|
| 295 | ;~ call AuxIO_DumpParagraph
|
---|
| 296 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 297 | POPRF
|
---|
[117] | 298 | ENDIF
|
---|
| 299 | ENDIF
|
---|
| 300 |
|
---|
[43] | 301 | mov wptr cs:[CurPartition_Location+0], ax
|
---|
| 302 | mov wptr cs:[CurPartition_Location+2], bx
|
---|
| 303 | mov wptr cs:[CurPartition_Location+4], dx
|
---|
| 304 | mov wptr cs:[CurPartition_Location+6], cx ; Saves the location
|
---|
[164] | 305 | mov si, offset [PartitionSector] ; DS:SI - ExecBase
|
---|
[123] | 306 |
|
---|
| 307 |
|
---|
| 308 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
[43] | 309 | call DriveIO_LoadSector
|
---|
[123] | 310 |
|
---|
[216] | 311 | ; ----------------------------------------------------- [Check for GPT]
|
---|
| 312 | ; Check the 4 P-Table entries for a GPT identifier
|
---|
| 313 | ; If found, set CY and exit to indicate no partitions are found.
|
---|
| 314 | ; This prevents the disk from appearing in the menu with an 'unknown'
|
---|
| 315 | ; partition identifier.
|
---|
| 316 | cmp byte ptr [si+01c2h], 0eeh ; Check Entry #1
|
---|
| 317 | stc
|
---|
| 318 | jz DIOLP_Success
|
---|
| 319 | cmp byte ptr [si+01d2h], 0eeh ; Check Entry #2
|
---|
| 320 | stc
|
---|
| 321 | jz DIOLP_Success
|
---|
| 322 | cmp byte ptr [si+01e2h], 0eeh ; Check Entry #3
|
---|
| 323 | stc
|
---|
| 324 | jz DIOLP_Success
|
---|
| 325 | cmp byte ptr [si+01f2h], 0eeh ; Check Entry #4
|
---|
| 326 | stc
|
---|
| 327 | jz DIOLP_Success
|
---|
| 328 |
|
---|
[217] | 329 | ; ---------------------------------------------------- [Check for LUKS]
|
---|
| 330 | ; Check for LUKS signature
|
---|
| 331 | ; If the LUKS signature is foud, set CY and exit to indicate no
|
---|
| 332 | ; are found partitions. This prevents LUKS disks from appearing in the
|
---|
| 333 | ; menu in the off chance the luks-sector has a 0xaa55 at offset 0x01fe.
|
---|
| 334 | cmp word ptr [si+00h], 554ch ; 'LU'
|
---|
| 335 | jne @F
|
---|
| 336 | cmp word ptr [si+02h], 534bh ; 'KS'
|
---|
| 337 | stc
|
---|
| 338 | jz DIOLP_Success
|
---|
| 339 |
|
---|
| 340 | @@:
|
---|
[43] | 341 | clc
|
---|
| 342 | cmp wptr [si+LocBR_Magic], 0AA55h
|
---|
| 343 | je DIOLP_Success
|
---|
| 344 | ; We check, if we are scanning partitions. In that case, if CHS is not 0/0/1
|
---|
| 345 | ; we will display a "bad partition table" message and halt the system.
|
---|
| 346 | cmp cx, 0001h
|
---|
| 347 | jne DIOLP_Failed
|
---|
| 348 | or dh, dh
|
---|
| 349 | jnz DIOLP_Failed
|
---|
| 350 | stc ; Set carry, so no partition table
|
---|
| 351 | DIOLP_Success:
|
---|
[30] | 352 |
|
---|
| 353 |
|
---|
[117] | 354 |
|
---|
[43] | 355 | ret
|
---|
| 356 | DIOLP_Failed:
|
---|
| 357 | jmp DriveIO_GotLoadError
|
---|
| 358 | DriveIO_LoadPartition EndP
|
---|
[8] | 359 |
|
---|
[30] | 360 | ; #########################################################################
|
---|
| 361 | ; Routine: Writes a partition from ExecBase to its original sector
|
---|
| 362 | ; #########################################################################
|
---|
| 363 | ; Calling : none
|
---|
| 364 | ; Returns : none
|
---|
| 365 | ; Preserve: all registers
|
---|
| 366 | ; #########################################################################
|
---|
[43] | 367 | DriveIO_SavePartition Proc Near Uses ax bx cx dx si
|
---|
[111] | 368 |
|
---|
| 369 | IFDEF AUX_DEBUG
|
---|
| 370 | IF 0
|
---|
[123] | 371 | DBG_TEXT_OUT_AUX 'DriveIO_SavePartition:'
|
---|
| 372 | PUSHRF
|
---|
[164] | 373 | call DEBUG_DumpRegisters
|
---|
[111] | 374 | ;~ call AuxIO_DumpParagraph
|
---|
| 375 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 376 | POPRF
|
---|
[111] | 377 | ENDIF
|
---|
| 378 | ENDIF
|
---|
| 379 |
|
---|
[43] | 380 | mov ax, wptr cs:[CurPartition_Location+0]
|
---|
| 381 | mov bx, wptr cs:[CurPartition_Location+2]
|
---|
| 382 | mov dx, wptr cs:[CurPartition_Location+4]
|
---|
| 383 | mov cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location
|
---|
| 384 | mov si, offset PartitionSector ; DS:SI - ExecBase
|
---|
| 385 | cmp wptr [si+LocBR_Magic], 0AA55h ; Checks for signature, if not found
|
---|
| 386 | jne DIOSP_SevereError ; we assume a really bad error
|
---|
| 387 | call DriveIO_SaveSector
|
---|
| 388 | DIOSP_SevereError:
|
---|
| 389 | ret
|
---|
| 390 | DriveIO_SavePartition EndP
|
---|
[8] | 391 |
|
---|
| 392 |
|
---|
| 393 |
|
---|
[147] | 394 | ;##############################################################################
|
---|
| 395 | ;# The location of LVM sectors depends on the OS/2 geometry used when the disk
|
---|
| 396 | ;# was prepared. This geometry is present in the Master LVM sector, which has
|
---|
| 397 | ;# already been located if it exists. All partitions, whether primary or
|
---|
| 398 | ;# logical, have an entry in a partition table. For primary partitions this
|
---|
| 399 | ;# table is located in the MBR, while for logical partitions this table is
|
---|
| 400 | ;# located in the EBR for that logical partition. An LVM record is located
|
---|
| 401 | ;# LVM_SPT-1 sectors above an MBR or EBR. The Master LVM record contains the
|
---|
| 402 | ;# information for all primary partitions. For logical partitions, the LVM
|
---|
| 403 | ;# sector only has one entry, because EBRs are chained. The global LVM info,
|
---|
| 404 | ;# like disk-name, sectors per track, etc. is replicated between the Master
|
---|
| 405 | ;# LVM sector and LVM sectors corresponding to logical partitions. This info
|
---|
| 406 | ;# is kept in sync by the OS/2 LVM Engine.
|
---|
| 407 | ;##############################################################################
|
---|
| 408 | ;# ACTION : Attempts to load the corresponding LVM sector for a partition
|
---|
| 409 | ;# ----------------------------------------------------------------------------
|
---|
| 410 | ;# EFFECTS : Modifies DAP structure and fills or clears sector buffer
|
---|
| 411 | ;# ----------------------------------------------------------------------------
|
---|
[149] | 412 | ;# IN : MEM - Location info is in [CurPartition_Location]
|
---|
[147] | 413 | ;# ----------------------------------------------------------------------------
|
---|
[149] | 414 | ;# OUT : CF=1 - failure, no valid LVM sector was loaded
|
---|
| 415 | ;# : SI - Points to the sector buffer ([LVMSector])
|
---|
[147] | 416 | ;##############################################################################
|
---|
| 417 | DriveIO_LoadLVMSector Proc Near Uses ax bx cx dx di
|
---|
[111] | 418 |
|
---|
| 419 | IFDEF AUX_DEBUG
|
---|
[152] | 420 | IF 0
|
---|
[123] | 421 | DBG_TEXT_OUT_AUX 'DriveIO_LoadLVMSector:'
|
---|
| 422 | PUSHRF
|
---|
[117] | 423 | call DEBUG_DumpRegisters
|
---|
[147] | 424 | ;~ call AuxIO_DumpSector
|
---|
[111] | 425 | ;~ call AuxIO_DumpParagraph
|
---|
| 426 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 427 | POPRF
|
---|
[111] | 428 | ENDIF
|
---|
| 429 | ENDIF
|
---|
| 430 |
|
---|
[147] | 431 | ; Clear the sector buffer
|
---|
| 432 | mov si, offset [LVMSector]
|
---|
| 433 | call ClearSectorBuffer
|
---|
[30] | 434 |
|
---|
[147] | 435 | ; Quit with CY if LVM is ignored in SETUP
|
---|
| 436 | test byte ptr [CFG_IgnoreLVM], 1 ; ZF=0 means ignore LVM
|
---|
| 437 | jnz DIOLLVMS_NoLVMSector ; Quit if so
|
---|
[30] | 438 |
|
---|
[147] | 439 | ; Load the location of the current partition being acted upon.
|
---|
| 440 | ; Note that this is not the actual LBA of the partition, but the
|
---|
| 441 | ; sector that has the partition table that contains the entry
|
---|
| 442 | ; for the partition. In other words, for primary partitions the LBA
|
---|
| 443 | ; address points to the MBR while for extended partitions it points
|
---|
| 444 | ; to an EBR. In both cases the LVM sector is located LVM_SPT-1 above.
|
---|
| 445 | ; Also note that the BIOS CHS values (DH and CX) below are not used,
|
---|
| 446 | ; because we explicitly use LBA sector loading.
|
---|
| 447 | mov ax, wptr cs:[CurPartition_Location+0] ; LBA lo of MBR/EBR
|
---|
| 448 | mov bx, wptr cs:[CurPartition_Location+2] ; LBA hi of MBR/EBR
|
---|
| 449 | mov dx, wptr cs:[CurPartition_Location+4] ; BIOS disk num & head
|
---|
| 450 | mov cx, wptr cs:[CurPartition_Location+6] ; BIOS cyl & sec
|
---|
| 451 |
|
---|
[152] | 452 | ; Do the actual loading.
|
---|
| 453 | ; This is in a separate function so that LVM records can also be
|
---|
| 454 | ; loaded using the MBR/EBR LBA addresses from IPT entries.
|
---|
| 455 | call DriveIO_LoadLVMSectorXBR
|
---|
| 456 | jc DIOLLVMS_NoLVMSector
|
---|
| 457 |
|
---|
| 458 | ; We're done, indicate success and return
|
---|
| 459 | clc
|
---|
| 460 | jmp DIOLLVMS_Done
|
---|
| 461 |
|
---|
| 462 | DIOLLVMS_NoLVMSector:
|
---|
| 463 |
|
---|
| 464 | ; Clear the sector buffer
|
---|
| 465 | mov si, offset [LVMSector]
|
---|
| 466 | call ClearSectorBuffer
|
---|
| 467 | mov bptr [si+LocLVM_SignatureStart], 0
|
---|
| 468 |
|
---|
| 469 | ; Indicate no valid LVM sector was loaded
|
---|
| 470 | stc
|
---|
| 471 |
|
---|
| 472 | DIOLLVMS_Done:
|
---|
| 473 |
|
---|
| 474 | ret
|
---|
| 475 | DriveIO_LoadLVMSector EndP
|
---|
| 476 |
|
---|
| 477 |
|
---|
| 478 |
|
---|
| 479 |
|
---|
| 480 |
|
---|
| 481 | ;------------------------------------------------------------------------------
|
---|
| 482 | ; Attempts to load the corresponding LVM sector for a partition
|
---|
| 483 | ;------------------------------------------------------------------------------
|
---|
| 484 | ; IN : AX - LBA lo of MBR or EBR
|
---|
| 485 | ; : BX - LBA hi of MBR or EBR
|
---|
| 486 | ; ; DL - BIOS disk number
|
---|
| 487 | ; ; SI - Pointer to sector buffer (usually [LVMSec])
|
---|
| 488 | ; OUT : CF=0 - A valid LVM sector was loaded
|
---|
| 489 | ; NOTE : LocIPT_AbsolutePartTable and LocIPT_Drive can provide LBA and DISK
|
---|
| 490 | ;------------------------------------------------------------------------------
|
---|
| 491 | DriveIO_LoadLVMSectorXBR Proc Near
|
---|
| 492 |
|
---|
| 493 | IFDEF AUX_DEBUG
|
---|
[164] | 494 | IF 0
|
---|
[152] | 495 | DBG_TEXT_OUT_AUX 'DriveIO_LoadLVMSectorXBR:'
|
---|
| 496 | PUSHRF
|
---|
| 497 | call DEBUG_DumpRegisters
|
---|
| 498 | ;~ call AuxIO_DumpSector
|
---|
| 499 | ;~ call AuxIO_DumpParagraph
|
---|
| 500 | ;~ call AuxIO_TeletypeNL
|
---|
| 501 | POPRF
|
---|
| 502 | ENDIF
|
---|
| 503 | ENDIF
|
---|
| 504 |
|
---|
| 505 | ; Save all registers
|
---|
| 506 | pusha
|
---|
| 507 |
|
---|
[149] | 508 | ; Calculate the entry in the DISKINFO array for this disk,
|
---|
| 509 | ; and put the LVM_SPT in DI
|
---|
| 510 | push bx
|
---|
| 511 | call DriveIO_CalcDiskInfoPointer
|
---|
| 512 | mov di, [bx+LocDISKINFO_LVM_Secs]
|
---|
| 513 | pop bx
|
---|
| 514 |
|
---|
| 515 | ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
|
---|
| 516 | test di, di ; See if it is 0
|
---|
[152] | 517 | jz DriveIO_LoadLVMSectorXBR_no_lvm ; Quit if so
|
---|
[149] | 518 |
|
---|
[147] | 519 | ; Adjust the location to point to the LVM sector
|
---|
| 520 | add ax, di ; Add the LVM sectors-per-track
|
---|
| 521 | adc bx, 0 ; Propagate LBA lo overflow to LBA hi
|
---|
| 522 | sub ax, 1 ; LVM sector is located one sector below
|
---|
| 523 | sbb bx, 0 ; Propagate borrow to LBA hi
|
---|
| 524 |
|
---|
[152] | 525 | ; Load the LVM sector into sector buffer pointed to by SI
|
---|
[147] | 526 | mov di, ds ; Segment of that buffer
|
---|
| 527 | call DriveIO_ReadSectorLBA ; Read the LVM sector
|
---|
| 528 |
|
---|
[117] | 529 | IFDEF AUX_DEBUG
|
---|
[164] | 530 | IF 0
|
---|
[149] | 531 | DBG_TEXT_OUT_AUX 'LVMSecLoaded'
|
---|
[123] | 532 | PUSHRF
|
---|
[147] | 533 | call DEBUG_DumpRegisters
|
---|
[152] | 534 | ;~ call AuxIO_DumpSector
|
---|
| 535 | mov cx, 3
|
---|
| 536 | @@:
|
---|
| 537 | call AuxIO_DumpParagraph
|
---|
| 538 | call AuxIO_TeletypeNL
|
---|
| 539 | add si, 16
|
---|
| 540 | loop @B
|
---|
[147] | 541 | ;~ call AuxIO_DumpParagraph
|
---|
[117] | 542 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 543 | POPRF
|
---|
[117] | 544 | ENDIF
|
---|
| 545 | ENDIF
|
---|
[30] | 546 |
|
---|
[152] | 547 | jc DriveIO_LoadLVMSectorXBR_no_lvm ; Quit on error
|
---|
[149] | 548 |
|
---|
| 549 | ; Check the validity of the LVM sector, quit with CY if invalid
|
---|
| 550 | call LVM_ValidateSector ; Check signature and CRC
|
---|
[152] | 551 | jnc DriveIO_LoadLVMSectorXBR_no_lvm ; Quit if not valid
|
---|
[149] | 552 |
|
---|
[147] | 553 | ; We're done, indicate success and return
|
---|
| 554 | clc
|
---|
[152] | 555 | jmp DriveIO_LoadLVMSectorXBR_done
|
---|
[117] | 556 |
|
---|
[152] | 557 | DriveIO_LoadLVMSectorXBR_no_lvm:
|
---|
[147] | 558 | ; Indicate no valid LVM sector was loaded
|
---|
| 559 | stc
|
---|
| 560 |
|
---|
[152] | 561 | DriveIO_LoadLVMSectorXBR_done:
|
---|
| 562 | ; Restore all registers
|
---|
| 563 | popa
|
---|
[147] | 564 |
|
---|
[43] | 565 | ret
|
---|
[152] | 566 | DriveIO_LoadLVMSectorXBR EndP
|
---|
[29] | 567 |
|
---|
[51] | 568 |
|
---|
[150] | 569 | ;##############################################################################
|
---|
| 570 | ;# The location of LVM sectors depends on the OS/2 geometry used when the disk
|
---|
| 571 | ;# was prepared. This geometry is present in the Master LVM sector, which has
|
---|
| 572 | ;# already been located if it exists. All partitions, whether primary or
|
---|
| 573 | ;# logical, have an entry in a partition table. For primary partitions this
|
---|
| 574 | ;# table is located in the MBR, while for logical partitions this table is
|
---|
| 575 | ;# located in the EBR for that logical partition. An LVM record is located
|
---|
| 576 | ;# LVM_SPT-1 sectors above an MBR or EBR. The Master LVM record contains the
|
---|
| 577 | ;# information for all primary partitions. For logical partitions, the LVM
|
---|
| 578 | ;# sector only has one entry, because EBRs are chained. The global LVM info,
|
---|
| 579 | ;# like disk-name, sectors per track, etc. is replicated between the Master
|
---|
| 580 | ;# LVM sector and LVM sectors corresponding to logical partitions. This info
|
---|
| 581 | ;# is kept in sync by the OS/2 LVM Engine.
|
---|
| 582 | ;##############################################################################
|
---|
| 583 | ;# ACTION : Attempts to save the corresponding LVM sector for a partition
|
---|
| 584 | ;# ----------------------------------------------------------------------------
|
---|
| 585 | ;# EFFECTS : Modifies DAP structure and writes LVM sector to disk
|
---|
| 586 | ;# ----------------------------------------------------------------------------
|
---|
| 587 | ;# IN : MEM - Location info is in [CurPartition_Location]
|
---|
| 588 | ;# : SI - Pointer to sector buffer
|
---|
| 589 | ;# ----------------------------------------------------------------------------
|
---|
| 590 | ;# OUT : CF=1 - failure, no valid LVM sector was saved
|
---|
| 591 | ;##############################################################################
|
---|
| 592 | DriveIO_SaveLVMSector Proc Near Uses ax bx cx dx di
|
---|
[111] | 593 |
|
---|
| 594 | IFDEF AUX_DEBUG
|
---|
[152] | 595 | IF 0
|
---|
[123] | 596 | DBG_TEXT_OUT_AUX 'DriveIO_SaveLVMSector:'
|
---|
| 597 | PUSHRF
|
---|
[150] | 598 | call DEBUG_DumpRegisters
|
---|
[111] | 599 | ;~ call AuxIO_DumpParagraph
|
---|
| 600 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 601 | POPRF
|
---|
[111] | 602 | ENDIF
|
---|
| 603 | ENDIF
|
---|
| 604 |
|
---|
[150] | 605 | ; Quit with CY if LVM is ignored in SETUP
|
---|
| 606 | test byte ptr [CFG_IgnoreLVM], 1 ; ZF=0 means ignore LVM
|
---|
[152] | 607 | jnz DIOSLVMS_NoLVMSector ; Quit if so
|
---|
[50] | 608 |
|
---|
[150] | 609 | ; Load the location of the current partition being acted upon.
|
---|
| 610 | ; Note that this is not the actual LBA of the partition, but the
|
---|
| 611 | ; sector that has the partition table that contains the entry
|
---|
| 612 | ; for the partition. In other words, for primary partitions the LBA
|
---|
| 613 | ; address points to the MBR while for extended partitions it points
|
---|
| 614 | ; to an EBR. In both cases the LVM sector is located LVM_SPT-1 above.
|
---|
| 615 | ; Also note that the BIOS CHS values (DH and CX) below are not used,
|
---|
| 616 | ; because we explicitly use LBA sector loading.
|
---|
| 617 | mov ax, wptr cs:[CurPartition_Location+0] ; LBA lo of MBR/EBR
|
---|
| 618 | mov bx, wptr cs:[CurPartition_Location+2] ; LBA hi of MBR/EBR
|
---|
| 619 | mov dx, wptr cs:[CurPartition_Location+4] ; BIOS disk num & head
|
---|
| 620 | mov cx, wptr cs:[CurPartition_Location+6] ; BIOS cyl & sec
|
---|
[50] | 621 |
|
---|
[152] | 622 | ; Do the actual saving.
|
---|
| 623 | ; This is in a separate function so that LVM records can also be
|
---|
| 624 | ; saved using the MBR/EBR LBA addresses from IPT entries.
|
---|
| 625 | call DriveIO_SaveLVMSectorXBR
|
---|
| 626 | jc DIOSLVMS_NoLVMSector
|
---|
| 627 |
|
---|
| 628 | ; We're done, indicate success and return
|
---|
| 629 | clc
|
---|
| 630 | jmp DIOSLVMS_Done
|
---|
| 631 |
|
---|
| 632 | DIOSLVMS_NoLVMSector:
|
---|
| 633 | ; Indicate no valid LVM sector was saved
|
---|
| 634 | stc
|
---|
| 635 |
|
---|
| 636 | DIOSLVMS_Done:
|
---|
| 637 | ret
|
---|
| 638 | DriveIO_SaveLVMSector EndP
|
---|
| 639 |
|
---|
| 640 |
|
---|
| 641 | ;------------------------------------------------------------------------------
|
---|
| 642 | ; Attempts to save the corresponding LVM sector for a partition
|
---|
| 643 | ;------------------------------------------------------------------------------
|
---|
| 644 | ; IN : AX - LBA lo of MBR or EBR
|
---|
| 645 | ; : BX - LBA hi of MBR or EBR
|
---|
| 646 | ; ; DL - BIOS disk number
|
---|
| 647 | ; ; SI - Pointer to sector buffer (usually [LVMSec])
|
---|
| 648 | ; OUT : CF=0 - A valid LVM sector was saved
|
---|
| 649 | ; NOTE : LocIPT_AbsolutePartTable and LocIPT_Drive can provide LBA and DISK
|
---|
| 650 | ;------------------------------------------------------------------------------
|
---|
| 651 | DriveIO_SaveLVMSectorXBR Proc Near
|
---|
| 652 |
|
---|
[157] | 653 | IFDEF AUX_DEBUG
|
---|
[169] | 654 | IF 1
|
---|
[157] | 655 | DBG_TEXT_OUT_AUX 'DriveIO_SaveLVMSectorXBR:'
|
---|
| 656 | PUSHRF
|
---|
| 657 | call DEBUG_DumpRegisters
|
---|
[169] | 658 | call AuxIO_DumpSector
|
---|
[157] | 659 | ;~ call AuxIO_DumpParagraph
|
---|
| 660 | ;~ call AuxIO_TeletypeNL
|
---|
| 661 | POPRF
|
---|
| 662 | ENDIF
|
---|
| 663 | ENDIF
|
---|
| 664 |
|
---|
[152] | 665 | ; Save all registers
|
---|
| 666 | pusha
|
---|
| 667 |
|
---|
| 668 | ; Check the validity of the LVM sector, quit with CY if invalid
|
---|
| 669 | push ax ; Save LBA lo
|
---|
| 670 | call LVM_ValidateSector ; Check signature and CRC
|
---|
| 671 | pop ax ; Restore LBA lo
|
---|
| 672 | jnc DriveIO_SaveLVMSectorXBR_no_lvm ; Quit if not valid
|
---|
| 673 |
|
---|
[150] | 674 | ; Calculate the entry in the DISKINFO array for this disk,
|
---|
| 675 | ; and put the LVM_SPT in DI
|
---|
| 676 | push bx
|
---|
| 677 | call DriveIO_CalcDiskInfoPointer
|
---|
| 678 | mov di, [bx+LocDISKINFO_LVM_Secs]
|
---|
| 679 | pop bx
|
---|
| 680 |
|
---|
| 681 | ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
|
---|
| 682 | test di, di ; See if it is 0
|
---|
[152] | 683 | jz DriveIO_SaveLVMSectorXBR_no_lvm ; Quit if so
|
---|
[150] | 684 |
|
---|
| 685 | ; Adjust the location to point to the LVM sector
|
---|
| 686 | add ax, di ; Add the LVM sectors-per-track
|
---|
| 687 | adc bx, 0 ; Propagate LBA lo overflow to LBA hi
|
---|
| 688 | sub ax, 1 ; LVM sector is located one sector below
|
---|
| 689 | sbb bx, 0 ; Propagate borrow to LBA hi
|
---|
| 690 |
|
---|
[169] | 691 | ; Writing an LVM sector is always the result of modifications to a
|
---|
| 692 | ; previously loaded one. So, now that we have the LBA address of the
|
---|
| 693 | ; LVM sector, the one about to be overwritten should be there.
|
---|
| 694 | ; If it's not, something is seriously wrong and we quit immetiately.
|
---|
| 695 | pusha ; Push our context except the flags
|
---|
| 696 | mov si, offset [Scratch] ; Sector buffer to load the LVM sector
|
---|
| 697 | call ClearSectorBuffer ; Make sure no old LVM info is present
|
---|
| 698 | mov di, ds ; Segment of buffer
|
---|
| 699 | call DriveIO_ReadSectorLBA ; Load the old LVM sector
|
---|
| 700 | call LVM_ValidateSector ; CF=1 if valid
|
---|
| 701 | cmc ; Complement for disk i/o semantics
|
---|
| 702 | popa ; Restore our context except the flags
|
---|
| 703 |
|
---|
| 704 | ; OOPS, There was no LVM sector there !!
|
---|
| 705 | jc DriveIO_SaveLVMSectorXBR_no_lvm
|
---|
| 706 |
|
---|
[152] | 707 | ; Save the LVM sector pointed to by SI
|
---|
| 708 | mov di, ds ; Segment of that buffer
|
---|
[169] | 709 | call DriveIO_WriteSectorLBA ; Write the LVM sector
|
---|
[152] | 710 |
|
---|
[117] | 711 | IFDEF AUX_DEBUG
|
---|
[169] | 712 | IF 1
|
---|
[150] | 713 | DBG_TEXT_OUT_AUX 'LVMSecSaved'
|
---|
| 714 | PUSHRF
|
---|
[117] | 715 | call DEBUG_DumpRegisters
|
---|
[150] | 716 | call AuxIO_DumpSector
|
---|
| 717 | ;~ call AuxIO_DumpParagraph
|
---|
| 718 | ;~ call AuxIO_TeletypeNL
|
---|
| 719 | POPRF
|
---|
[117] | 720 | ENDIF
|
---|
| 721 | ENDIF
|
---|
[50] | 722 |
|
---|
[152] | 723 | jc DriveIO_SaveLVMSectorXBR_no_lvm ; Quit on error
|
---|
[150] | 724 |
|
---|
| 725 | ; We're done, indicate success and return
|
---|
| 726 | clc
|
---|
[152] | 727 | jmp DriveIO_SaveLVMSectorXBR_done
|
---|
[150] | 728 |
|
---|
[152] | 729 | DriveIO_SaveLVMSectorXBR_no_lvm:
|
---|
[169] | 730 | ; Indicate no valid LVM sector was saved
|
---|
[150] | 731 | stc
|
---|
| 732 |
|
---|
[152] | 733 | DriveIO_SaveLVMSectorXBR_done:
|
---|
| 734 | ; Restore all registers
|
---|
| 735 | popa
|
---|
| 736 |
|
---|
[43] | 737 | ret
|
---|
[152] | 738 | DriveIO_SaveLVMSectorXBR EndP
|
---|
[29] | 739 |
|
---|
[43] | 740 |
|
---|
[8] | 741 |
|
---|
[26] | 742 | ; Special error message instead of "LOAD ERROR" during partition scanning,
|
---|
| 743 | ; so users will notice that something is bad with their partition table(s)
|
---|
[43] | 744 | DriveIO_GotLoadError Proc Near
|
---|
[170] | 745 | IFDEF AUX_DEBUG
|
---|
| 746 | IF 1
|
---|
| 747 | DBG_TEXT_OUT_AUX 'DriveIO_GotLoadError:'
|
---|
| 748 | PUSHRF
|
---|
| 749 | call DEBUG_DumpRegisters
|
---|
| 750 | ;~ call AuxIO_DumpParagraph
|
---|
| 751 | ;~ call AuxIO_TeletypeNL
|
---|
| 752 | POPRF
|
---|
| 753 | ENDIF
|
---|
| 754 | ENDIF
|
---|
[46] | 755 | test byte ptr cs:[CurIO_Scanning], 1 ; Must be CS:, cause DS!=CS maybe here
|
---|
[43] | 756 | jnz InScanMode
|
---|
| 757 | jmp MBR_LoadError
|
---|
| 758 | InScanMode:
|
---|
| 759 | mov si, offset TXT_BrokenPartitionTable
|
---|
| 760 | push cs
|
---|
| 761 | pop ds
|
---|
| 762 | call MBR_Teletype
|
---|
| 763 | mov si, offset BrokenHDD
|
---|
| 764 | sub dl, 50h ; 80h -> '0'
|
---|
| 765 | cmp dl, 39h
|
---|
| 766 | jbe DIOGLE_BelowA
|
---|
| 767 | add dl, 7 ; 3Ah -> 'A'
|
---|
| 768 | DIOGLE_BelowA:
|
---|
| 769 | mov bptr [si+5], dl
|
---|
| 770 | call MBR_Teletype
|
---|
[40] | 771 |
|
---|
[43] | 772 | ; JWasm: cannot jump to local label in other procedure.
|
---|
| 773 | ; Changed to halt here.
|
---|
| 774 | ;jmp MBRLE_Halt
|
---|
| 775 | DriveIO_GotLoadError_halt:
|
---|
| 776 | jmp DriveIO_GotLoadError_halt
|
---|
| 777 | DriveIO_GotLoadError EndP
|
---|
[26] | 778 |
|
---|
[30] | 779 | ; #########################################################################
|
---|
| 780 | ; Routine: Loads a specified sector to DS:DI
|
---|
| 781 | ; #########################################################################
|
---|
| 782 | ; Calling : bx:ax - Absolute sector
|
---|
| 783 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
| 784 | ; ds:si - Destination-Adress
|
---|
| 785 | ; Returns : none
|
---|
| 786 | ; Preserve: all registers
|
---|
| 787 | ; #########################################################################
|
---|
[51] | 788 | DriveIO_LoadSector Proc Near Uses ax bx cx dx ds si es di
|
---|
[110] | 789 |
|
---|
[111] | 790 | IFDEF AUX_DEBUG
|
---|
| 791 | IF 0
|
---|
[123] | 792 | DBG_TEXT_OUT_AUX 'DriveIO_LoadSector:'
|
---|
| 793 | PUSHRF
|
---|
[117] | 794 | call DEBUG_DumpRegisters
|
---|
[111] | 795 | ;~ call AuxIO_DumpParagraph
|
---|
| 796 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 797 | POPRF
|
---|
[111] | 798 | ENDIF
|
---|
| 799 | ENDIF
|
---|
| 800 |
|
---|
[43] | 801 | ; Is the drive not a harddrive?
|
---|
| 802 | cmp dl, 80h
|
---|
| 803 | jb DIOLS_UseNormal
|
---|
[36] | 804 |
|
---|
[46] | 805 | test byte ptr cs:[CurIO_UseExtension], 1
|
---|
[43] | 806 | jz DIOLS_UseNormal
|
---|
| 807 | ; Are we forced do use LBA via Setting?
|
---|
| 808 | jnz DIOLS_UseExtension
|
---|
[36] | 809 |
|
---|
[51] | 810 | ; Upper 8 bits of LBA-address set?
|
---|
| 811 | ; Then use LBA (maximum boundary is 16320x16x63 = FB0400h)
|
---|
[43] | 812 | or bh, bh
|
---|
| 813 | jnz DIOLS_UseExtension
|
---|
| 814 | ; Compare Switch-Table value to bit 16-23 of LBA-address
|
---|
| 815 | mov di, dx
|
---|
| 816 | and di, 007Fh
|
---|
| 817 | cmp bptr cs:[LBASwitchTable+di], bl
|
---|
| 818 | jbe DIOLS_UseExtension
|
---|
[111] | 819 |
|
---|
[43] | 820 | DIOLS_UseNormal:
|
---|
[111] | 821 |
|
---|
| 822 | IFDEF AUX_DEBUG
|
---|
| 823 | IF 0
|
---|
[123] | 824 | DBG_TEXT_OUT_AUX 'DriveIO_ReadSectorCHS:'
|
---|
| 825 | PUSHRF
|
---|
[111] | 826 | call DEBUG_DumpRegisters
|
---|
| 827 | call AuxIO_DumpParagraph
|
---|
| 828 | call AuxIO_TeletypeNL
|
---|
[123] | 829 | POPRF
|
---|
[111] | 830 | ENDIF
|
---|
| 831 | ENDIF
|
---|
| 832 |
|
---|
| 833 | mov di, 3 ; retry count
|
---|
[43] | 834 | DIOLS_ErrorLoop:
|
---|
| 835 | push ds
|
---|
| 836 | pop es
|
---|
| 837 | mov bx, si ; ES:BX - Destination
|
---|
| 838 | mov ax, 0201h ; Function 2 - Load Sector
|
---|
| 839 | int 13h
|
---|
[175] | 840 | sti ; enable ints
|
---|
[43] | 841 | jnc DIOLS_Success
|
---|
[111] | 842 | dec di ; decrement retry count
|
---|
[43] | 843 | jnz DIOLS_ErrorLoop
|
---|
[110] | 844 |
|
---|
[43] | 845 | ; Sector load failed...
|
---|
| 846 | jmp DriveIO_GotLoadError
|
---|
[8] | 847 |
|
---|
[43] | 848 | DIOLS_UseExtension:
|
---|
[110] | 849 |
|
---|
| 850 | mov di, ds ; segment for transfer address
|
---|
| 851 | call DriveIO_ReadSectorLBA ; extended read
|
---|
| 852 | jc DriveIO_GotLoadError ; halt on error
|
---|
| 853 |
|
---|
| 854 | ;~ push cx
|
---|
| 855 | ;~ mov cs:[INT13X_DAP_NumBlocks], 1 ; Copy ONE sector
|
---|
| 856 | ;~ mov wptr cs:[INT13X_DAP_Transfer+0], si
|
---|
| 857 | ;~ mov cx, ds
|
---|
| 858 | ;~ mov wptr cs:[INT13X_DAP_Transfer+2], cx ; Fill out Transfer Adress
|
---|
| 859 | ;~ mov wptr cs:[INT13X_DAP_Absolute+0], ax
|
---|
| 860 | ;~ mov wptr cs:[INT13X_DAP_Absolute+2], bx ; Fill out Absolute Sector
|
---|
| 861 | ;~ push cs
|
---|
| 862 | ;~ pop ds
|
---|
| 863 | ;~ mov si, offset [INT13X_DAP]
|
---|
| 864 | ;~ mov ah, 42h ; Extended Read
|
---|
| 865 | ;~ int 13h
|
---|
| 866 | ;~ pop cx
|
---|
| 867 | ;~ jnc DIOLS_Success
|
---|
| 868 |
|
---|
[43] | 869 | ; Sector load failed...
|
---|
[110] | 870 | ;~ jmp DriveIO_GotLoadError
|
---|
[8] | 871 |
|
---|
[43] | 872 | DIOLS_Success:
|
---|
[117] | 873 |
|
---|
| 874 | IFDEF AUX_DEBUG
|
---|
| 875 | IF 0
|
---|
[123] | 876 | DBG_TEXT_OUT_AUX 'sector loaded'
|
---|
| 877 | PUSHRF
|
---|
[117] | 878 | ;~ call DEBUG_DumpRegisters
|
---|
[123] | 879 | ;~ call AuxIO_DumpSector
|
---|
| 880 | mov cx, 32
|
---|
| 881 | @@:
|
---|
| 882 | call AuxIO_DumpParagraph
|
---|
| 883 | call AuxIO_TeletypeNL
|
---|
| 884 | add si, 16
|
---|
| 885 | loop @B
|
---|
| 886 | POPRF
|
---|
[117] | 887 | ENDIF
|
---|
| 888 | ENDIF
|
---|
[43] | 889 | ret
|
---|
| 890 | DriveIO_LoadSector EndP
|
---|
[8] | 891 |
|
---|
[32] | 892 |
|
---|
[126] | 893 | ;##############################################################################
|
---|
| 894 | ;# ACTION : Loads the Master Boot Record from the specified drive into buffer
|
---|
| 895 | ;# ----------------------------------------------------------------------------
|
---|
| 896 | ;# EFFECTS : Modifies DAP structure and fills or clears transfer buffer
|
---|
| 897 | ;# ----------------------------------------------------------------------------
|
---|
| 898 | ;# IN : DL - BIOS disk number (80h,81h,etc)
|
---|
| 899 | ;# : SI - Pointer to transfer buffer
|
---|
| 900 | ;# ----------------------------------------------------------------------------
|
---|
| 901 | ;# OUT : CF=1 - failure
|
---|
| 902 | ;# : AL.0 - MBR signature present
|
---|
| 903 | ;# : AL.1 - Primary partitions present
|
---|
| 904 | ;# : AL.2 - Extended partitions present
|
---|
| 905 | ;# : AL.3 - AiR-BOOT signature present
|
---|
| 906 | ;# : AL.4:7 - Reserved, returned as 0
|
---|
| 907 | ;# : AH.0:7 - Reserved, returned as 0
|
---|
| 908 | ;##############################################################################
|
---|
| 909 | DriveIO_LoadMBR Proc Near uses bx cx dx si di
|
---|
[32] | 910 |
|
---|
[126] | 911 | ; Always clear the transfer buffer first
|
---|
| 912 | call ClearSectorBuffer
|
---|
| 913 |
|
---|
| 914 | ; Assume an invalid MBR
|
---|
| 915 | xor ax, ax
|
---|
| 916 |
|
---|
| 917 | ; Accept only valid harddisks
|
---|
| 918 | call DriveIO_IsValidHarddisk
|
---|
| 919 | jc DriveIO_LoadMBR_exit
|
---|
| 920 |
|
---|
| 921 | ; Save the address of the transfer buffer
|
---|
| 922 | mov di, si
|
---|
| 923 |
|
---|
| 924 | ; Read the MBR from disk
|
---|
| 925 | xor ax, ax ; LBA low
|
---|
| 926 | xor bx, bx ; LBA high
|
---|
| 927 | xor dh, dh ; Head 0
|
---|
| 928 | mov cx, 1 ; Sector 1
|
---|
| 929 | call DriveIO_LoadSector ; Read the sector from disk
|
---|
| 930 |
|
---|
| 931 | ; Check the loaded MBR for a signature
|
---|
| 932 | xor ax, ax ; Assume an invalid MBR
|
---|
| 933 | mov dx, [si+LocBR_Magic] ; Get word from MBR signature location
|
---|
| 934 | cmp dx, 0aa55h ; Is it the magic value ?
|
---|
| 935 | jne DriveIO_LoadMBR_exit ; Nope, no need to test anything else
|
---|
| 936 |
|
---|
| 937 | ; Indicate we have a MBR signature
|
---|
| 938 | or al, 01h
|
---|
| 939 |
|
---|
| 940 | ; Advance to the partition table
|
---|
| 941 | add si, 01beh
|
---|
| 942 |
|
---|
| 943 | ; Total of 4 entries to check
|
---|
| 944 | mov cx, 4
|
---|
| 945 |
|
---|
| 946 | DriveIO_LoadMBR_next_entry:
|
---|
| 947 | mov dl, [si+LocBRPT_SystemID] ; Get partition-type / system-id
|
---|
| 948 | add si, 10h ; Point to next entry
|
---|
| 949 | test dl, dl ; Nothing in this one ?
|
---|
| 950 | loopz DriveIO_LoadMBR_next_entry ; Then check next entry
|
---|
| 951 |
|
---|
| 952 | ; All entries checked and last one was also empty, we're done
|
---|
| 953 | jz DriveIO_LoadMBR_check_ab
|
---|
| 954 |
|
---|
| 955 | ; Found a non-empty entry, set bits according to its type
|
---|
| 956 | cmp dl, 05h ; Old style extended container ?
|
---|
| 957 | jne @F ; Nope...
|
---|
| 958 | or al, 04h ; Yep, mark ext. container present
|
---|
| 959 | @@: cmp dl, 0fh ; New style extended container ?
|
---|
| 960 | jne @F ; Nope...
|
---|
| 961 | or al, 04h ; Yep, mark ext. container present
|
---|
| 962 | @@: or al, 02h ; Then is must be a primary
|
---|
| 963 | jcxz DriveIO_LoadMBR_check_ab ; CX=0? Then all entries processed,
|
---|
| 964 | jmp DriveIO_LoadMBR_next_entry ; otherwise check next entry
|
---|
| 965 |
|
---|
| 966 | ; Check if an AiR-BOOT signature is present
|
---|
| 967 | DriveIO_LoadMBR_check_ab:
|
---|
| 968 | mov si, offset [MBR_ABSig] ; Offset of AiR-BOOT signature
|
---|
| 969 | inc di ; Advance buffer pointer
|
---|
| 970 | inc di ; to AiR-BOOT signature location
|
---|
| 971 | mov cx, 7 ; Length of AiR-BOOT signature
|
---|
| 972 | cld ; Direction upwards
|
---|
| 973 | repe cmpsb ; Compare 7 bytes
|
---|
| 974 | jne DriveIO_LoadMBR_exit ; Nope, no AiR-BOOT on this disk
|
---|
| 975 | or al, 08h ; Yep, AiR-BOOT is on this disk
|
---|
| 976 | ;~ jmp DriveIO_LoadMBR_exit
|
---|
| 977 |
|
---|
| 978 | DriveIO_LoadMBR_exit:
|
---|
| 979 | ret
|
---|
| 980 | DriveIO_LoadMBR EndP
|
---|
| 981 |
|
---|
| 982 |
|
---|
[102] | 983 | ;##############################################################################
|
---|
| 984 | ;# ACTION : Reads a sector from disk using INT13 extensions
|
---|
| 985 | ;# ----------------------------------------------------------------------------
|
---|
[117] | 986 | ;# EFFECTS : Modifies DAP structure and fills transfer buffer
|
---|
| 987 | ;# ----------------------------------------------------------------------------
|
---|
[118] | 988 | ;# IN : BX:AX - LBA address of sector
|
---|
[102] | 989 | ;# : DI:SI - SEG:OFF of transfer buffer
|
---|
| 990 | ;# ----------------------------------------------------------------------------
|
---|
[118] | 991 | ;# OUT : CF=1 - failure
|
---|
[102] | 992 | ;##############################################################################
|
---|
[118] | 993 | DriveIO_ReadSectorLBA Proc Near
|
---|
[102] | 994 |
|
---|
[111] | 995 | IFDEF AUX_DEBUG
|
---|
| 996 | IF 0
|
---|
[123] | 997 | DBG_TEXT_OUT_AUX 'DriveIO_ReadSectorLBA:'
|
---|
| 998 | PUSHRF
|
---|
[111] | 999 | call DEBUG_DumpRegisters
|
---|
| 1000 | call AuxIO_DumpParagraph
|
---|
| 1001 | call AuxIO_TeletypeNL
|
---|
[123] | 1002 | POPRF
|
---|
[111] | 1003 | ENDIF
|
---|
| 1004 | ENDIF
|
---|
| 1005 |
|
---|
[118] | 1006 | ; Push all registers
|
---|
| 1007 | pusha
|
---|
| 1008 | push ds
|
---|
| 1009 | push es
|
---|
| 1010 |
|
---|
[102] | 1011 | ; One sector to read
|
---|
[105] | 1012 | mov cs:[INT13X_DAP_NumBlocks], 1
|
---|
[32] | 1013 |
|
---|
[102] | 1014 | ; Setup transfer address
|
---|
[105] | 1015 | mov wptr cs:[INT13X_DAP_Transfer+0], si ; offset
|
---|
| 1016 | mov wptr cs:[INT13X_DAP_Transfer+2], di ; segment
|
---|
[32] | 1017 |
|
---|
[102] | 1018 | ; Setup LBA64 address of requested sector
|
---|
[118] | 1019 | mov wptr cs:[INT13X_DAP_Absolute+0], ax ; low word lower part
|
---|
[105] | 1020 | mov wptr cs:[INT13X_DAP_Absolute+2], bx ; high word lower part
|
---|
| 1021 | mov wptr cs:[INT13X_DAP_Absolute+4], 0 ; low word upper part
|
---|
| 1022 | mov wptr cs:[INT13X_DAP_Absolute+6], 0 ; high word upper part
|
---|
[32] | 1023 |
|
---|
[43] | 1024 | ; Address of packet
|
---|
[105] | 1025 | mov si, offset [INT13X_DAP] ; disk address packet
|
---|
[32] | 1026 |
|
---|
[43] | 1027 | ; Do the extended read
|
---|
[102] | 1028 | mov ah, 42h ; read function
|
---|
| 1029 | int 13h ; transfer to bios
|
---|
[175] | 1030 | sti ; enable ints
|
---|
[32] | 1031 |
|
---|
[102] | 1032 | ; Error occured
|
---|
| 1033 | jc DriveIO_ReadSectorLBA_exit
|
---|
[32] | 1034 |
|
---|
[102] | 1035 | ; AH should also be zero
|
---|
| 1036 | test ah, ah
|
---|
[43] | 1037 | stc
|
---|
[102] | 1038 | jnz DriveIO_ReadSectorLBA_exit
|
---|
[32] | 1039 |
|
---|
[102] | 1040 | ; Disk read succeeded, clear CF
|
---|
| 1041 | clc
|
---|
[32] | 1042 |
|
---|
[102] | 1043 | DriveIO_ReadSectorLBA_exit:
|
---|
[118] | 1044 |
|
---|
| 1045 | ; Pop all registers
|
---|
| 1046 | pop es
|
---|
| 1047 | pop ds
|
---|
| 1048 | popa
|
---|
| 1049 |
|
---|
[43] | 1050 | ret
|
---|
[102] | 1051 | DriveIO_ReadSectorLBA EndP
|
---|
[32] | 1052 |
|
---|
| 1053 |
|
---|
[102] | 1054 |
|
---|
[103] | 1055 | ;##############################################################################
|
---|
| 1056 | ;# ACTION : Writes a sector to disk using INT13 extensions
|
---|
| 1057 | ;# ----------------------------------------------------------------------------
|
---|
[117] | 1058 | ;# EFFECTS : Modifies DAP structure and mofifies the disk
|
---|
| 1059 | ;# ----------------------------------------------------------------------------
|
---|
[118] | 1060 | ;# IN : BX:AX - LBA address of sector
|
---|
[103] | 1061 | ;# : DI:SI - SEG:OFF of transfer buffer
|
---|
| 1062 | ;# ----------------------------------------------------------------------------
|
---|
[118] | 1063 | ;# OUT : CF=1 - failure
|
---|
[103] | 1064 | ;##############################################################################
|
---|
[118] | 1065 | DriveIO_WriteSectorLBA Proc Near
|
---|
[103] | 1066 |
|
---|
[111] | 1067 | IFDEF AUX_DEBUG
|
---|
| 1068 | IF 0
|
---|
[123] | 1069 | DBG_TEXT_OUT_AUX 'DriveIO_WriteSectorLBA:'
|
---|
| 1070 | PUSHRF
|
---|
[111] | 1071 | call DEBUG_DumpRegisters
|
---|
| 1072 | call AuxIO_DumpParagraph
|
---|
| 1073 | call AuxIO_TeletypeNL
|
---|
[123] | 1074 | POPRF
|
---|
[111] | 1075 | ENDIF
|
---|
| 1076 | ENDIF
|
---|
| 1077 |
|
---|
[118] | 1078 | ; Push all registers
|
---|
| 1079 | pusha
|
---|
| 1080 | push ds
|
---|
| 1081 | push es
|
---|
[103] | 1082 |
|
---|
| 1083 | ; One sector to read
|
---|
[105] | 1084 | mov cs:[INT13X_DAP_NumBlocks], 1
|
---|
[103] | 1085 |
|
---|
| 1086 | ; Setup transfer address
|
---|
[105] | 1087 | mov wptr cs:[INT13X_DAP_Transfer+0], si ; offset
|
---|
| 1088 | mov wptr cs:[INT13X_DAP_Transfer+2], di ; segment
|
---|
[103] | 1089 |
|
---|
| 1090 | ; Setup LBA64 address of requested sector
|
---|
[118] | 1091 | mov wptr cs:[INT13X_DAP_Absolute+0], ax ; low word lower part
|
---|
[105] | 1092 | mov wptr cs:[INT13X_DAP_Absolute+2], bx ; high word lower part
|
---|
| 1093 | mov wptr cs:[INT13X_DAP_Absolute+4], 0 ; low word upper part
|
---|
| 1094 | mov wptr cs:[INT13X_DAP_Absolute+6], 0 ; high word upper part
|
---|
[103] | 1095 |
|
---|
| 1096 | ; Address of packet
|
---|
[105] | 1097 | mov si, offset [INT13X_DAP] ; disk address packet
|
---|
[103] | 1098 |
|
---|
| 1099 | ; Do the extended write
|
---|
[118] | 1100 | xor al, al ; no write verify
|
---|
[103] | 1101 | mov ah, 43h ; write function
|
---|
| 1102 | int 13h ; transfer to bios
|
---|
[175] | 1103 | sti ; enable ints
|
---|
[103] | 1104 |
|
---|
| 1105 | ; Error occured
|
---|
| 1106 | jc DriveIO_WriteSectorLBA_exit
|
---|
| 1107 |
|
---|
| 1108 | ; AH should also be zero
|
---|
| 1109 | test ah, ah
|
---|
| 1110 | stc
|
---|
| 1111 | jnz DriveIO_WriteSectorLBA_exit
|
---|
| 1112 |
|
---|
| 1113 | ; Disk write succeeded, clear CF
|
---|
| 1114 | clc
|
---|
| 1115 |
|
---|
| 1116 | DriveIO_WriteSectorLBA_exit:
|
---|
[118] | 1117 |
|
---|
[168] | 1118 | ; Skip the removable drive check on success
|
---|
| 1119 | jnc @F
|
---|
| 1120 |
|
---|
| 1121 | ; Here, CF=1 because of a failure.
|
---|
| 1122 | ; This could be from a removable drive that is set to read-only,
|
---|
| 1123 | ; in which case we want to fake success. What this boils down to
|
---|
| 1124 | ; is that CY must be set to !IsRemovable.
|
---|
| 1125 | call DriveIO_CalcDiskInfoPointer ; Get DISKINFO pointer
|
---|
| 1126 | mov dx, [bx+LocDISKINFO_I13X_Flags] ; Get INT13X flags
|
---|
| 1127 | xor dl, 04h ; Invert 'removable' bit
|
---|
| 1128 | and dl, 04h ; Mask it out
|
---|
| 1129 | rcr dl, 3 ; Move it to CY
|
---|
| 1130 |
|
---|
| 1131 | @@:
|
---|
| 1132 |
|
---|
[118] | 1133 | ; Pop all registers
|
---|
| 1134 | pop es
|
---|
| 1135 | pop ds
|
---|
| 1136 | popa
|
---|
| 1137 |
|
---|
[103] | 1138 | ret
|
---|
| 1139 | DriveIO_WriteSectorLBA EndP
|
---|
| 1140 |
|
---|
| 1141 |
|
---|
| 1142 |
|
---|
[115] | 1143 |
|
---|
| 1144 | ;##############################################################################
|
---|
| 1145 | ;# The Master LVM sector is *not* necessarily located at the end of the BIOS
|
---|
| 1146 | ;# view of TRACK0. Its location depends on the *OS/2 geometry* active when the
|
---|
| 1147 | ;# disk was partitioned. For disks < 502MiB this will most likely be LBA sector
|
---|
| 1148 | ;# 62, but for disks >502MiB, *extended* OS/2 geometry was used and DANIS506
|
---|
| 1149 | ;# uses SPT=127 for disks < 1TiB while IBMS506 uses SPT=255.
|
---|
| 1150 | ;# When a huge disk < 1TiB was partitioned with IBMS506, thus using SPT=255,
|
---|
| 1151 | ;# and the driver was later changed to DANIS506, DANI uses SPT=255, eventhough
|
---|
| 1152 | ;# the disk < 1TiB. Whether it is DANI that is LVM aware or something else
|
---|
| 1153 | ;# (maybe LVM itself) that makes DANI use the correct geometry has yet to be
|
---|
| 1154 | ;# investigated.
|
---|
| 1155 | ;#
|
---|
| 1156 | ;# Related geometry issues are also present with USB sticks, which can get
|
---|
| 1157 | ;# assigned a geometry by OS/2, which can depend if the stick was partitioned
|
---|
| 1158 | ;# on foreign systems or not, or even OS/2 manufacturing a geometry that is not
|
---|
| 1159 | ;# the same as the BIOS reports to us here. In both cases, fixed disks and
|
---|
| 1160 | ;# removable disks, the geometry recorded in the BPB of a partition can also
|
---|
| 1161 | ;# influence the geometry that OS/2 assigns. This is the case when 'preparing'
|
---|
| 1162 | ;# disks for LVM use, in which case BPB values could be incorporated.
|
---|
| 1163 | ;#
|
---|
| 1164 | ;# What this all boils down to, is that the geometry reported by the BIOS is
|
---|
| 1165 | ;# of no practical use, especially not when taking BIOS USB MSD emulation into
|
---|
| 1166 | ;# account. These are among the reasons why AirBoot needs to use LBA addressing
|
---|
| 1167 | ;# when handling LVM stuff and why LBA use cannot be disabled in the SETUP
|
---|
| 1168 | ;# anymore.
|
---|
| 1169 | ;#
|
---|
| 1170 | ;# So, a Master LVM sector can be present on any sector from LBA 254 downwards
|
---|
| 1171 | ;# and the only way to locate the correct one is to scan all the way down and,
|
---|
| 1172 | ;# if one is found, do proper validation on its values, because it may also be
|
---|
| 1173 | ;# a 'phantom' LVM sector left over from previous partition layouts.
|
---|
| 1174 | ;# Most of such 'phantoms' can be filtered out by verifying the location of
|
---|
| 1175 | ;# the found sector against the OS/2 geometry it specifies itself, which means
|
---|
| 1176 | ;# it must be located at the LBA of the SPT-1 it specifies.
|
---|
| 1177 | ;##############################################################################
|
---|
| 1178 | ;# ACTION : Locates the Master LVM sector on the specified disk
|
---|
| 1179 | ;# ----------------------------------------------------------------------------
|
---|
[124] | 1180 | ;# EFFECTS : Leaves [Scratch] with last sector read or cleared
|
---|
[115] | 1181 | ;# ----------------------------------------------------------------------------
|
---|
| 1182 | ;# IN : DL - BIOS disk number of drive to search
|
---|
| 1183 | ;# ----------------------------------------------------------------------------
|
---|
| 1184 | ;# OUT : CF=1 - found
|
---|
| 1185 | ;# : BX:AX - LBA address of LVM sector if found, 0 otherwise
|
---|
| 1186 | ;##############################################################################
|
---|
| 1187 | DriveIO_LocateMasterLVMSector Proc Near uses cx dx si di ds es
|
---|
| 1188 |
|
---|
| 1189 | IFDEF AUX_DEBUG
|
---|
[164] | 1190 | IF 0
|
---|
[123] | 1191 | DBG_TEXT_OUT_AUX 'DriveIO_LocateMasterLVMSector:'
|
---|
| 1192 | PUSHRF
|
---|
[119] | 1193 | call DEBUG_DumpRegisters
|
---|
[115] | 1194 | ;~ call AuxIO_DumpSector
|
---|
| 1195 | ;~ call AuxIO_DumpParagraph
|
---|
| 1196 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 1197 | POPRF
|
---|
[115] | 1198 | ENDIF
|
---|
| 1199 | ENDIF
|
---|
| 1200 |
|
---|
| 1201 | ; LBA address to start scanning down from
|
---|
| 1202 | mov cx, 255
|
---|
| 1203 |
|
---|
| 1204 | ; Make sure ES==DS
|
---|
| 1205 | push ds
|
---|
| 1206 | pop es
|
---|
| 1207 |
|
---|
[119] | 1208 | ; Because JCXZ is used, LBA sector 0 is never loaded and checked.
|
---|
| 1209 | ; This is of course no problem since it is the MBR.
|
---|
[115] | 1210 | DriveIO_LocateMasterLVMSector_next:
|
---|
[124] | 1211 | mov si, offset [Scratch] ; Use scratch area to load sectors
|
---|
| 1212 | call ClearSectorBuffer ; Clear the scratch area
|
---|
[115] | 1213 | clc ; Indicate Master LVM sector not found
|
---|
| 1214 | jcxz DriveIO_LocateMasterLVMSector_done
|
---|
| 1215 |
|
---|
[124] | 1216 | ; Read the LBA sector specified in CX
|
---|
[118] | 1217 | mov ax, cx ; LBA low
|
---|
| 1218 | xor bx, bx ; LBA high
|
---|
[124] | 1219 | mov di, ds ; Segment of scratch buffer
|
---|
| 1220 | mov si, offset [Scratch] ; Offset of scratch buffer
|
---|
[115] | 1221 | call DriveIO_ReadSectorLBA ; Read the sector
|
---|
[123] | 1222 | lahf ; Save CF
|
---|
[115] | 1223 | dec cx ; Prepare LBA of next sector to read
|
---|
| 1224 | sahf ; Restore CF
|
---|
| 1225 | ; No need to do any LVM sector validation when read error, read next
|
---|
| 1226 | jc DriveIO_LocateMasterLVMSector_next
|
---|
| 1227 |
|
---|
| 1228 | ; See if the read sector has a valid signature and checksum
|
---|
| 1229 | call LVM_ValidateSector
|
---|
| 1230 |
|
---|
| 1231 | ; NC indicates invalid or none-LVM sector, read next
|
---|
| 1232 | jnc DriveIO_LocateMasterLVMSector_next
|
---|
| 1233 |
|
---|
| 1234 | ; We have found a valid LVM sector !
|
---|
| 1235 | ; So it contains the OS/2 geometry for the disk.
|
---|
| 1236 | ; That means this LVM sector itself must be located on the last sector
|
---|
| 1237 | ; of the SPT value its OS/2 geometery specifies, which, in LBA terms
|
---|
| 1238 | ; is LVM SPT-1 -- let's check that...
|
---|
[124] | 1239 | mov bx, offset [Scratch] ; Offset of the loaded LVM sector
|
---|
[115] | 1240 | mov al, [bx+LocLVM_Secs] ; Get the LVM SPT value (<=255)
|
---|
| 1241 | dec al ; Adjust to LVM LBA
|
---|
| 1242 | mov ah, cl ; Get next LVM LBA to search
|
---|
| 1243 | inc ah ; This one was found here
|
---|
| 1244 | cmp al, ah ; If same, LVM LBA location OK
|
---|
| 1245 | jne DriveIO_LocateMasterLVMSector_next
|
---|
| 1246 |
|
---|
| 1247 | ; The LVM sector we found is at the location it should be on disk,
|
---|
| 1248 | ; so it's almost 99% sure this is the correct one.
|
---|
| 1249 | ; Now we should compare the start and sizes of the partitions in the
|
---|
| 1250 | ; MBR with the partitions specified in this LVM record.
|
---|
| 1251 | ; We'll implement that later after some more research.
|
---|
| 1252 | ; For now we assume this is the correct Master LVM sector for the disk.
|
---|
| 1253 | inc cx ; CX was prepared to read next, correct that
|
---|
[118] | 1254 | stc ; Indicate we have found the Master LVM sector
|
---|
[115] | 1255 |
|
---|
| 1256 | DriveIO_LocateMasterLVMSector_done:
|
---|
| 1257 | mov bx, 0 ; A Master LVM sector always has high LBA=0
|
---|
| 1258 | mov ax, cx ; Low LBA of Master LVM sector
|
---|
| 1259 |
|
---|
| 1260 | ; We leave it up to the caller to store the value in a proper place
|
---|
| 1261 | ret
|
---|
| 1262 | DriveIO_LocateMasterLVMSector EndP
|
---|
| 1263 |
|
---|
| 1264 |
|
---|
| 1265 |
|
---|
[51] | 1266 | ;
|
---|
| 1267 | ; ############################################################
|
---|
| 1268 | ; # Check for a valid MBR-sector to be written to disk #
|
---|
| 1269 | ; ############################################################
|
---|
| 1270 | ;
|
---|
| 1271 | ; In
|
---|
| 1272 | ; --
|
---|
| 1273 | ; DL = Physical Disk
|
---|
| 1274 | ; BX:CX = LBA sector
|
---|
| 1275 | ; DI:SI = Source buffer
|
---|
| 1276 | ;
|
---|
| 1277 | ; Out
|
---|
| 1278 | ; ---
|
---|
| 1279 | ; CY = 1 if invalid MBR in source buffer, 0 if valid
|
---|
| 1280 | ;
|
---|
| 1281 | ; This routine is called when DriveIO_SaveSector attempts to write to the MBR.
|
---|
| 1282 | ; It checks if the sector to be written has some sensible values in certain
|
---|
| 1283 | ; places. In fact, if the sector is written to the boot-disk, the AiR-BOOT
|
---|
| 1284 | ; signature should be present and the partition table should be the same
|
---|
| 1285 | ; as the one at the start of the AiR-BOOT code in memory, except maybe for the
|
---|
| 1286 | ; active flags.
|
---|
| 1287 | ; For other disks, only the active flags are checked to be 00h or 80h and
|
---|
| 1288 | ; the AA55h MBR signature.
|
---|
| 1289 | ;
|
---|
| 1290 | DriveIO_ProtectMBR Proc Near
|
---|
| 1291 | pusha ; Push all registers
|
---|
| 1292 | push es ; Push ES because we need it for string instructions
|
---|
| 1293 | push cs ; Make ES point...
|
---|
| 1294 | pop es ; to CS
|
---|
[32] | 1295 |
|
---|
[51] | 1296 | ; Save the pointer to the sector to write in BX
|
---|
| 1297 | mov bx,si
|
---|
| 1298 |
|
---|
| 1299 | ;
|
---|
| 1300 | ; If the sector to be written is not the boot-disk, then skip
|
---|
| 1301 | ; checking the AiR-BOOT MBR.
|
---|
| 1302 | ;
|
---|
[78] | 1303 | cmp dl, [BIOS_BootDisk]
|
---|
| 1304 | jne DriveIO_ProtectMBR_is_not_bootdisk
|
---|
[51] | 1305 |
|
---|
| 1306 | ;
|
---|
| 1307 | ; The boot-disk is accessed so the sector to be written must be
|
---|
| 1308 | ; the AiR-BOOT MBR. This is the same as the first 512 bytes
|
---|
| 1309 | ; relocated to 8000:0000 and this the start of the AB-code.
|
---|
| 1310 | ;
|
---|
| 1311 | mov si,bx ; Get pointer to sector to write
|
---|
| 1312 | xor di,di ; Point DI to start of AB-code (MBR)
|
---|
| 1313 | mov cx, offset [MBR_PartTable] ; Bytes upto P-table must be same
|
---|
| 1314 | cld ; Compare upwards
|
---|
| 1315 | repe cmpsb ; Compare upto P-table
|
---|
| 1316 |
|
---|
| 1317 | ; If not the same this is not the an AiR-BOOT boot-disk MBR !
|
---|
| 1318 | jne DriveIO_ProtectMBR_not_valid_MBR ; SEVERE ERROR !
|
---|
| 1319 |
|
---|
| 1320 | ; Continue with signature check
|
---|
| 1321 | jmp DriveIO_ProtectMBR_check_signature
|
---|
| 1322 |
|
---|
| 1323 |
|
---|
| 1324 | ;
|
---|
| 1325 | ; The disk is not the boot-disk so we don't know what kind of MBR is on it.
|
---|
| 1326 | ; Some sanity checks should be here.
|
---|
| 1327 | ;
|
---|
| 1328 | DriveIO_ProtectMBR_is_not_bootdisk:
|
---|
| 1329 |
|
---|
| 1330 | ;
|
---|
| 1331 | ; sanity checks...
|
---|
| 1332 | ;
|
---|
| 1333 |
|
---|
| 1334 | ; Continue with signature check
|
---|
| 1335 | jmp DriveIO_ProtectMBR_check_signature
|
---|
| 1336 |
|
---|
| 1337 |
|
---|
| 1338 | DriveIO_ProtectMBR_check_signature:
|
---|
| 1339 | ; See if the sector to write contains a valid signature
|
---|
| 1340 | mov si,bx ; Get pointer to sector to write
|
---|
| 1341 | mov di, offset [MBR_Sig] ; Offset to MBR signature
|
---|
| 1342 | add si,di ; Make SI point to it in sec to write
|
---|
| 1343 | lodsw ; Load it
|
---|
| 1344 | cmp ax,0aa55h ; See if it is valid
|
---|
| 1345 |
|
---|
| 1346 | ; If no signature this cannot be a valid MBR !
|
---|
| 1347 | jne DriveIO_ProtectMBR_not_valid_MBR ; SEVERE ERROR !
|
---|
| 1348 |
|
---|
| 1349 |
|
---|
| 1350 | ;
|
---|
| 1351 | ; The sector to be written seems to be valid.
|
---|
| 1352 | ; Set CY=0 to indicate a valid MBR.
|
---|
| 1353 | ;
|
---|
| 1354 | DriveIO_ProtectMBR_is_valid_MBR:
|
---|
| 1355 | clc
|
---|
| 1356 | jmp DriveIO_ProtectMBR_end
|
---|
| 1357 |
|
---|
| 1358 | ;
|
---|
| 1359 | ; Something is terribly wrong; a non-MBR sector seems about to be written.
|
---|
| 1360 | ; Set CY=1 and let the calling code handle this situation.
|
---|
| 1361 | ;
|
---|
| 1362 | DriveIO_ProtectMBR_not_valid_MBR:
|
---|
| 1363 | stc
|
---|
| 1364 | jmp DriveIO_ProtectMBR_end
|
---|
| 1365 |
|
---|
| 1366 | ;
|
---|
| 1367 | ; Return to the caller with no registers modyfied except FLAGS.
|
---|
| 1368 | ;
|
---|
| 1369 | DriveIO_ProtectMBR_end:
|
---|
| 1370 | pop es
|
---|
| 1371 | popa
|
---|
| 1372 | ret
|
---|
| 1373 | DriveIO_ProtectMBR Endp
|
---|
| 1374 |
|
---|
| 1375 |
|
---|
| 1376 |
|
---|
[30] | 1377 | ; #########################################################################
|
---|
[51] | 1378 | ; Routine: Checks if the MBR is addressed by either CHS or LBA
|
---|
| 1379 | ; #########################################################################
|
---|
| 1380 | ; Calling : bx:ax - Absolute sector
|
---|
| 1381 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
| 1382 | ; Returns : ZF=1 if MBR is addressed, else ZF=0
|
---|
| 1383 | ; Preserve: all registers
|
---|
| 1384 | ; #########################################################################
|
---|
| 1385 | DriveIO_MBR_Addressed Proc
|
---|
| 1386 | push ax
|
---|
| 1387 | push bx
|
---|
| 1388 |
|
---|
| 1389 | or bx,ax ; Results in 0 in BX if MBR is addressed by LBA
|
---|
| 1390 | jz DriveIO_MBR_Addressed_done
|
---|
| 1391 |
|
---|
| 1392 | mov ax,cx ; Results in 1 in AX if CYL 0, SEC 1 is addressed
|
---|
| 1393 | add al,dh ; Results in 1 in AX if HEAD 0 is addressed
|
---|
| 1394 | dec ax ; Results in 0 in AX if MBR is addressed by CHS
|
---|
| 1395 |
|
---|
| 1396 | DriveIO_MBR_Addressed_done:
|
---|
| 1397 | pop bx
|
---|
| 1398 | pop ax
|
---|
| 1399 | ret
|
---|
| 1400 | DriveIO_MBR_Addressed EndP
|
---|
| 1401 |
|
---|
| 1402 |
|
---|
| 1403 |
|
---|
| 1404 |
|
---|
| 1405 | ; #########################################################################
|
---|
[30] | 1406 | ; Routine: Writes DS:SI to a specified sector
|
---|
| 1407 | ; #########################################################################
|
---|
| 1408 | ; Calling : bx:ax - Absolute sector
|
---|
| 1409 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
| 1410 | ; ds:si - Source-Adress
|
---|
| 1411 | ; Returns : none
|
---|
| 1412 | ; Preserve: all registers
|
---|
| 1413 | ; #########################################################################
|
---|
[51] | 1414 | DriveIO_SaveSector Proc Near Uses ax bx cx dx ds si es di
|
---|
[50] | 1415 |
|
---|
[111] | 1416 | IFDEF AUX_DEBUG
|
---|
| 1417 | IF 0
|
---|
[123] | 1418 | DBG_TEXT_OUT_AUX 'DriveIO_SaveSector:'
|
---|
| 1419 | PUSHRF
|
---|
[164] | 1420 | call DEBUG_DumpRegisters
|
---|
[111] | 1421 | ;~ call AuxIO_DumpParagraph
|
---|
| 1422 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 1423 | POPRF
|
---|
[111] | 1424 | ENDIF
|
---|
| 1425 | ENDIF
|
---|
[51] | 1426 |
|
---|
[117] | 1427 |
|
---|
| 1428 | ;!
|
---|
| 1429 | ;! DEBUG_BLOCK
|
---|
| 1430 | ;! Force write to LBA0 to test interception routine.
|
---|
| 1431 | ;! Do *NOT* enable unless you are debugging, will overwrite MBR !
|
---|
| 1432 | ;!
|
---|
| 1433 | IFDEF AUX_DEBUG
|
---|
| 1434 | IF 0
|
---|
| 1435 | pushf
|
---|
| 1436 | pusha
|
---|
[51] | 1437 | xor ax,ax
|
---|
| 1438 | xor bx,bx
|
---|
| 1439 | xor cx,cx
|
---|
| 1440 | inc cx
|
---|
| 1441 | xor dh,dh
|
---|
[117] | 1442 | popa
|
---|
| 1443 | popf
|
---|
[51] | 1444 | ENDIF
|
---|
[117] | 1445 | ENDIF
|
---|
[51] | 1446 |
|
---|
| 1447 | ;
|
---|
| 1448 | ; Check if the MBR is the destination for the write.
|
---|
| 1449 | ; ZF=1 if so.
|
---|
| 1450 | ;
|
---|
| 1451 | call DriveIO_MBR_Addressed
|
---|
| 1452 | jnz DriveIO_SaveSector_continue_write
|
---|
| 1453 |
|
---|
| 1454 |
|
---|
| 1455 | ; MBR is addressed, check the sector that is requested to be written.
|
---|
| 1456 | ; For the bootdisk it should contain the AiR-BOOT signature, valid
|
---|
| 1457 | ; partition-table entries and the AA55h signature.
|
---|
| 1458 | ; If not, something is terribly wrong in some piece of the AB code.
|
---|
| 1459 | ; For any other disk (80h+) at least a valid partition table should
|
---|
| 1460 | ; be present together with the AA55h signature.
|
---|
| 1461 | call DriveIO_ProtectMBR
|
---|
| 1462 | jnc DriveIO_SaveSector_continue_write
|
---|
| 1463 |
|
---|
| 1464 |
|
---|
| 1465 | ;
|
---|
| 1466 | ; WE HAVE A SEVERE ERROR CONDITION !
|
---|
| 1467 | ; SOME AB CODE TRIES TO WRITE A NON-MBR TO THE DISK !
|
---|
| 1468 | ; ASK THE USER TO REPORT THIS !
|
---|
| 1469 | ; HALT THE SYSTEM !
|
---|
| 1470 | ;
|
---|
| 1471 |
|
---|
| 1472 | ; Show error-box
|
---|
| 1473 | mov cx, 0C04h
|
---|
| 1474 | mov si, offset NonMBRwrite
|
---|
| 1475 | call SETUP_ShowErrorBox
|
---|
| 1476 | mov cx, 0C04h
|
---|
| 1477 | mov si, offset NonMBRwrite_rep
|
---|
| 1478 | call SETUP_ShowErrorBox
|
---|
| 1479 |
|
---|
| 1480 |
|
---|
[117] | 1481 | IFDEF AUX_DEBUG
|
---|
| 1482 | IF 0
|
---|
| 1483 | pushf
|
---|
| 1484 | pusha
|
---|
| 1485 | mov si, offset [NonMBRwrite]
|
---|
[51] | 1486 | call AuxIO_TeletypeNL
|
---|
| 1487 | call AuxIO_Print
|
---|
| 1488 | call AuxIO_TeletypeNL
|
---|
[117] | 1489 | popa
|
---|
| 1490 | popf
|
---|
[51] | 1491 | ENDIF
|
---|
[117] | 1492 | ENDIF
|
---|
[51] | 1493 |
|
---|
| 1494 | ; Show popup and halt the system.
|
---|
| 1495 | jmp HaltSystem
|
---|
| 1496 |
|
---|
| 1497 |
|
---|
| 1498 |
|
---|
| 1499 | ;
|
---|
| 1500 | ; Continue the write if not MBR sector or MBR to write is validated.
|
---|
| 1501 | ;
|
---|
| 1502 | DriveIO_SaveSector_continue_write:
|
---|
[46] | 1503 | test byte ptr cs:[CurIO_UseExtension], 1
|
---|
[43] | 1504 | jz DIOSS_UseNormal
|
---|
| 1505 | ; Are we forced do use LBA via Setting?
|
---|
[54] | 1506 | ; Always use INT13X on v1.0.8+.
|
---|
[50] | 1507 | ;~ test byte ptr cs:[CFG_ForceLBAUsage], 1
|
---|
| 1508 | ;~ jnz DIOSS_UseExtension
|
---|
| 1509 | jmp DIOSS_UseExtension
|
---|
[43] | 1510 | ; Is the drive not a harddrive?
|
---|
| 1511 | cmp dl, 80h
|
---|
| 1512 | jb DIOSS_UseNormal
|
---|
| 1513 | ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)
|
---|
| 1514 | or bh, bh
|
---|
| 1515 | jnz DIOSS_UseExtension
|
---|
| 1516 | ; Compare Switch-Table value to bit 16-23 of LBA-address
|
---|
| 1517 | mov di, dx
|
---|
| 1518 | and di, 007Fh
|
---|
| 1519 | cmp bptr cs:[LBASwitchTable+di], bl
|
---|
| 1520 | jbe DIOSS_UseExtension
|
---|
[110] | 1521 |
|
---|
[43] | 1522 | DIOSS_UseNormal:
|
---|
[111] | 1523 |
|
---|
| 1524 | IFDEF AUX_DEBUG
|
---|
| 1525 | IF 0
|
---|
[123] | 1526 | DBG_TEXT_OUT_AUX 'DriveIO_WriteSectorCHS:'
|
---|
| 1527 | PUSHRF
|
---|
[111] | 1528 | call DEBUG_DumpRegisters
|
---|
| 1529 | call AuxIO_DumpParagraph
|
---|
| 1530 | call AuxIO_TeletypeNL
|
---|
[123] | 1531 | POPRF
|
---|
[111] | 1532 | ENDIF
|
---|
| 1533 | ENDIF
|
---|
| 1534 |
|
---|
| 1535 | mov di, 3 ; retry count
|
---|
[43] | 1536 | DIOSS_ErrorLoop:
|
---|
| 1537 | push ds
|
---|
| 1538 | pop es
|
---|
| 1539 | mov bx, si ; ES:BX - Destination
|
---|
| 1540 | mov ax, 0301h ; Function 3 - Write Sector
|
---|
| 1541 | int 13h
|
---|
[175] | 1542 | sti ; Enable ints
|
---|
[43] | 1543 | jnc DIOSS_Success
|
---|
[111] | 1544 | dec di ; decrement retry count
|
---|
[43] | 1545 | jnz DIOSS_ErrorLoop
|
---|
| 1546 | call MBR_SaveError
|
---|
[8] | 1547 |
|
---|
[43] | 1548 | DIOSS_UseExtension:
|
---|
[8] | 1549 |
|
---|
[110] | 1550 | mov di, ds ; segment for transfer address
|
---|
| 1551 | call DriveIO_WriteSectorLBA ; extended write
|
---|
| 1552 | jc MBR_SaveError ; halt on error
|
---|
| 1553 |
|
---|
| 1554 | ;~ push cx
|
---|
| 1555 | ;~ mov cs:[INT13X_DAP_NumBlocks], 1 ; Copy ONE sector
|
---|
| 1556 | ;~ mov wptr cs:[INT13X_DAP_Transfer+0], si
|
---|
| 1557 | ;~ mov cx, ds
|
---|
| 1558 | ;~ mov wptr cs:[INT13X_DAP_Transfer+2], cx ; Fill out Transfer Adress
|
---|
| 1559 | ;~ mov wptr cs:[INT13X_DAP_Absolute+0], ax
|
---|
| 1560 | ;~ mov wptr cs:[INT13X_DAP_Absolute+2], bx ; Fill out Absolute Sector
|
---|
| 1561 | ;~ push cs
|
---|
| 1562 | ;~ pop ds
|
---|
| 1563 | ;~ mov si, offset [INT13X_DAP]
|
---|
| 1564 | ;~ mov ax, 4300h ; Extended Write (No Verify)
|
---|
| 1565 | ;~ int 13h
|
---|
| 1566 | ;~ pop cx
|
---|
| 1567 | ;~ jnc DIOSS_Success
|
---|
| 1568 | ;~ call MBR_SaveError
|
---|
| 1569 |
|
---|
[43] | 1570 | DIOSS_Success:
|
---|
| 1571 | ret
|
---|
[8] | 1572 | DriveIO_SaveSector EndP
|
---|
[30] | 1573 |
|
---|
| 1574 |
|
---|
| 1575 |
|
---|
[136] | 1576 |
|
---|
| 1577 | ;##############################################################################
|
---|
| 1578 | ;# When a disk has a Master LVM sector, it means it has been prepared for use
|
---|
| 1579 | ;# by OS/2 and contains important information about how OS/2 views its geometry
|
---|
| 1580 | ;# and other disk related properties. This function assumes the LBA address
|
---|
| 1581 | ;# of the Master LVM sector has already been located and simply loads the
|
---|
| 1582 | ;# sector into [LVMSector].
|
---|
| 1583 | ;#
|
---|
| 1584 | ;# Note that because this is an operation similar to the regular loading of
|
---|
| 1585 | ;# sectors, the disk I/O semantics are used here. This means CF=0 when an LVM
|
---|
| 1586 | ;# sector is successfully loaded and CF=1 otherwise.
|
---|
| 1587 | ;##############################################################################
|
---|
| 1588 | ;# ACTION : Loads the Master LVM sector if one exists
|
---|
| 1589 | ;# ----------------------------------------------------------------------------
|
---|
| 1590 | ;# EFFECTS : Modifies DAP structure and [LVMSector]
|
---|
| 1591 | ;# ----------------------------------------------------------------------------
|
---|
| 1592 | ;# IN : DL - BIOS disk number (80h,81h,etc)
|
---|
| 1593 | ;# ----------------------------------------------------------------------------
|
---|
| 1594 | ;# OUT : CF=0 - Valid Master LVM sector found and loaded
|
---|
| 1595 | ;##############################################################################
|
---|
[43] | 1596 | DriveIO_LoadMasterLVMSector Proc Near
|
---|
[111] | 1597 |
|
---|
| 1598 | IFDEF AUX_DEBUG
|
---|
| 1599 | IF 0
|
---|
[123] | 1600 | DBG_TEXT_OUT_AUX 'DriveIO_LoadMasterLVMSector:'
|
---|
| 1601 | PUSHRF
|
---|
[111] | 1602 | ;~ call DEBUG_DumpRegisters
|
---|
| 1603 | ;~ call AuxIO_DumpParagraph
|
---|
| 1604 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 1605 | POPRF
|
---|
[111] | 1606 | ENDIF
|
---|
| 1607 | ENDIF
|
---|
[30] | 1608 |
|
---|
[136] | 1609 | ; Save all registers
|
---|
[111] | 1610 | pusha
|
---|
[30] | 1611 |
|
---|
[136] | 1612 | ; Check if BIOS disk number is valid
|
---|
| 1613 | call DriveIO_IsValidHarddisk
|
---|
| 1614 | jc DriveIO_LoadMasterLVMSector_error
|
---|
[32] | 1615 |
|
---|
[136] | 1616 | ; Calculate the entry in the DISKINFO array for this disk
|
---|
| 1617 | call DriveIO_CalcDiskInfoPointer
|
---|
[32] | 1618 |
|
---|
[136] | 1619 | ; Save the entry for later recalls
|
---|
| 1620 | mov bp, bx
|
---|
[32] | 1621 |
|
---|
[136] | 1622 | ; Get the LBA address of the Master LVM sector
|
---|
| 1623 | mov ax, [bx+LocDISKINFO_LVM_MasterLBA+00h]
|
---|
| 1624 | mov bx, [bx+LocDISKINFO_LVM_MasterLBA+02h]
|
---|
[32] | 1625 |
|
---|
[136] | 1626 | ; LBA of Master LVM sector cannot be 0, so none was found during
|
---|
| 1627 | ; the gathering of disk information.
|
---|
| 1628 | mov cx, ax
|
---|
| 1629 | or cx, bx
|
---|
| 1630 | jz DriveIO_LoadMasterLVMSector_error
|
---|
[32] | 1631 |
|
---|
[136] | 1632 | ; Load it into [LVMSector]
|
---|
| 1633 | mov di, ds
|
---|
| 1634 | mov si, offset [LVMSector]
|
---|
| 1635 | call DriveIO_ReadSectorLBA
|
---|
| 1636 | jc DriveIO_LoadMasterLVMSector_error
|
---|
[30] | 1637 |
|
---|
[136] | 1638 | ; Validate the Master LVM sector
|
---|
[100] | 1639 | call LVM_ValidateSector
|
---|
[30] | 1640 |
|
---|
[136] | 1641 | ; Complement success indicator to conform to semantics of this function
|
---|
| 1642 | cmc
|
---|
[117] | 1643 |
|
---|
[136] | 1644 | ; Master LVM sector was valid and is now loaded in [LVMSector]
|
---|
| 1645 | jnc DriveIO_LoadMasterLVMSector_ret
|
---|
[117] | 1646 |
|
---|
[136] | 1647 | DriveIO_LoadMasterLVMSector_error:
|
---|
[30] | 1648 |
|
---|
[136] | 1649 | ; Clear the sector buffer for safety reasons
|
---|
| 1650 | mov si, offset [LVMSector]
|
---|
| 1651 | call ClearSectorBuffer
|
---|
[30] | 1652 |
|
---|
[136] | 1653 | ; Indicate no Master LVM sector loaded
|
---|
| 1654 | stc
|
---|
[114] | 1655 |
|
---|
[136] | 1656 | DriveIO_LoadMasterLVMSector_ret:
|
---|
[32] | 1657 |
|
---|
[136] | 1658 | ; Restore all registers
|
---|
| 1659 | popa
|
---|
[32] | 1660 |
|
---|
| 1661 | ret
|
---|
[30] | 1662 | DriveIO_LoadMasterLVMSector Endp
|
---|
| 1663 |
|
---|
| 1664 |
|
---|
| 1665 |
|
---|
| 1666 |
|
---|
[137] | 1667 | ;##############################################################################
|
---|
| 1668 | ;# There is much information to know about the connected disks.
|
---|
| 1669 | ;# We also want this information clustered per disk and available before
|
---|
| 1670 | ;# further disk and partition scanning takes place.
|
---|
| 1671 | ;# This function gathers such information like INT13, INT13X, MBR, LVM, more.
|
---|
| 1672 | ;# Especially important is the LVM information, because that contains the
|
---|
| 1673 | ;# geometry OS/2 uses to access the disk. Other important information is the
|
---|
| 1674 | ;# presence of valid MBRs, logical partitions and whatnot.
|
---|
| 1675 | ;# This function gathers such information and stores it in a DISKINFO structure
|
---|
| 1676 | ;# for which an instance exists for every disk found.
|
---|
| 1677 | ;##############################################################################
|
---|
| 1678 | ;# ACTION : Gather disk information and store this in the BSS
|
---|
| 1679 | ;# ----------------------------------------------------------------------------
|
---|
| 1680 | ;# EFFECTS : Modifies DAP structure and the buffers it uses, fills DISKINFO[n]
|
---|
| 1681 | ;# ----------------------------------------------------------------------------
|
---|
| 1682 | ;# IN : DL - BIOS disk number (80h,81h,etc)
|
---|
| 1683 | ;# ----------------------------------------------------------------------------
|
---|
| 1684 | ;# OUT : CF=1 - failure
|
---|
| 1685 | ;##############################################################################
|
---|
| 1686 | DriveIO_GatherDiskInfo Proc Near
|
---|
[136] | 1687 |
|
---|
[137] | 1688 | IFDEF AUX_DEBUG
|
---|
[164] | 1689 | IF 0
|
---|
[137] | 1690 | DBG_TEXT_OUT_AUX 'DriveIO_GatherDiskInfo:'
|
---|
| 1691 | PUSHRF
|
---|
| 1692 | call DEBUG_DumpRegisters
|
---|
| 1693 | ;~ call AuxIO_DumpParagraph
|
---|
| 1694 | ;~ call AuxIO_TeletypeNL
|
---|
| 1695 | POPRF
|
---|
| 1696 | ENDIF
|
---|
| 1697 | ENDIF
|
---|
[30] | 1698 |
|
---|
[137] | 1699 | ; Push all registers we use
|
---|
| 1700 | pusha
|
---|
| 1701 | push ds
|
---|
| 1702 | push es
|
---|
[30] | 1703 |
|
---|
[137] | 1704 | ; Make sure ES=DS
|
---|
| 1705 | push ds
|
---|
| 1706 | pop es
|
---|
[30] | 1707 |
|
---|
[137] | 1708 | ; Check if BIOS disk number is valid
|
---|
| 1709 | call DriveIO_IsValidHarddisk
|
---|
| 1710 | jc DriveIO_GatherDiskInfo_error
|
---|
[30] | 1711 |
|
---|
[137] | 1712 | ; Calculate the entry in the DISKINFO array for this disk
|
---|
| 1713 | call DriveIO_CalcDiskInfoPointer
|
---|
[30] | 1714 |
|
---|
[137] | 1715 | ; Save the entry for later recalls
|
---|
| 1716 | mov bp, bx
|
---|
[30] | 1717 |
|
---|
[137] | 1718 | ; Store the BIOS disk number in the structure
|
---|
| 1719 | mov [bx+LocDISKINFO_DiskNum], dl
|
---|
[30] | 1720 |
|
---|
[137] | 1721 | ; ------------------------------------------------------------------- [ INT13 ]
|
---|
[30] | 1722 |
|
---|
[137] | 1723 | ; Get BIOS Disk Parameters (legacy method)
|
---|
| 1724 | mov ah, 08h ; Get Disk Parameters
|
---|
| 1725 | int 13h ; Call BIOS
|
---|
[175] | 1726 | sti ; Enable ints
|
---|
[30] | 1727 |
|
---|
[137] | 1728 | ; CF=1 or AH!=0 indicates error
|
---|
| 1729 | jc DriveIO_GatherDiskInfo_error
|
---|
| 1730 | test ah, ah
|
---|
| 1731 | jnz DriveIO_GatherDiskInfo_error
|
---|
[30] | 1732 |
|
---|
[137] | 1733 | ; Recall DISKINFO entry
|
---|
| 1734 | mov bx, bp
|
---|
[30] | 1735 |
|
---|
[137] | 1736 | ; Store SPT (WORD)
|
---|
| 1737 | xor ah, ah ; Zero extend SPT to 16 bits
|
---|
| 1738 | mov al, cl ; Hi 2 bits max cyl and max sec
|
---|
| 1739 | and al, 3fh ; Mask max sec (1-based)
|
---|
| 1740 | mov [bx+LocDISKINFO_I13_Secs], ax ; Store SPT
|
---|
[30] | 1741 |
|
---|
[137] | 1742 | ; Store HEADS (WORD)
|
---|
| 1743 | xor dl, dl ; Zero extend HEADS to 16 bits
|
---|
| 1744 | xchg dl, dh ; Get max head (0-based)
|
---|
| 1745 | inc dx ; Head count
|
---|
| 1746 | mov [bx+LocDISKINFO_I13_Heads], dx ; Store HEADS
|
---|
[30] | 1747 |
|
---|
[137] | 1748 | ; Store CYLS (WORD)
|
---|
| 1749 | shr cl, 6 ; Hi 2 bits of max cyl to 1:0
|
---|
| 1750 | xchg cl, ch ; Max cyl (0-based)
|
---|
| 1751 | inc cx ; Cyl count
|
---|
| 1752 | mov [bx+LocDISKINFO_I13_Cyls], cx ; Store CYLS
|
---|
[30] | 1753 |
|
---|
[137] | 1754 | ; Recall BIOS disk number
|
---|
| 1755 | mov dl, [bx+LocDISKINFO_DiskNum]
|
---|
[30] | 1756 |
|
---|
[137] | 1757 | ; ------------------------------------------------------------------ [ INT13X ]
|
---|
[30] | 1758 |
|
---|
[137] | 1759 | ; Get BIOS Disk Parameters (extended method)
|
---|
| 1760 | mov si, offset [Scratch] ; Buffer to return disk info
|
---|
| 1761 | mov ax, 80h ; Size of buffer
|
---|
| 1762 | mov [si], ax ; Store it in first word
|
---|
| 1763 | mov ah, 48h ; Get Extended Disk Parameters
|
---|
| 1764 | int 13h ; Call BIOS
|
---|
[175] | 1765 | sti ; Enable ints
|
---|
[30] | 1766 |
|
---|
[137] | 1767 | ; CF=1 or AH!=0 indicates error
|
---|
| 1768 | jc DriveIO_GatherDiskInfo_error
|
---|
| 1769 | test ah, ah
|
---|
| 1770 | jnz DriveIO_GatherDiskInfo_error
|
---|
[30] | 1771 |
|
---|
[137] | 1772 | ; Store flags (WORD)
|
---|
| 1773 | cld ; Direction up
|
---|
| 1774 | lodsw ; Buffersize, discard
|
---|
| 1775 | lodsw ; Flags (CHS valid etc)
|
---|
| 1776 | mov [bx+LocDISKINFO_I13X_Flags], ax ; Store them
|
---|
[111] | 1777 |
|
---|
[137] | 1778 | ; Store CYLS (DWORD)
|
---|
| 1779 | lodsw ; Cyl count low
|
---|
| 1780 | mov [bx+LocDISKINFO_I13X_Cyls+00h], ax ; Store CYLS low
|
---|
| 1781 | lodsw ; Cyl count high
|
---|
| 1782 | mov [bx+LocDISKINFO_I13X_Cyls+02h], ax ; Store CYLS high
|
---|
[111] | 1783 |
|
---|
[137] | 1784 | ; Store HEADS (DWORD)
|
---|
| 1785 | lodsw ; Head count low
|
---|
| 1786 | mov [bx+LocDISKINFO_I13X_Heads+00h], ax ; Store HEADS low
|
---|
| 1787 | lodsw ; Head count high
|
---|
| 1788 | mov [bx+LocDISKINFO_I13X_Heads+02h], ax ; Store HEADS high
|
---|
[30] | 1789 |
|
---|
[137] | 1790 | ; Store SPT (DWORD)
|
---|
| 1791 | lodsw ; Secs per track low
|
---|
| 1792 | mov [bx+LocDISKINFO_I13X_Secs+00h], ax ; Store SPT low
|
---|
| 1793 | lodsw ; Secs per track high
|
---|
| 1794 | mov [bx+LocDISKINFO_I13X_Secs+02h], ax ; Store SPT high
|
---|
[30] | 1795 |
|
---|
[137] | 1796 | ; Store total LBA sectors (QWORD)
|
---|
| 1797 | lea di, [bx+LocDISKINFO_I13X_SecsLBA]
|
---|
| 1798 | mov cx, 4
|
---|
| 1799 | rep movsw
|
---|
[30] | 1800 |
|
---|
[137] | 1801 | ; Store sector size (WORD)
|
---|
| 1802 | lodsw
|
---|
| 1803 | mov [bx+LocDISKINFO_I13X_SecSize], ax
|
---|
[30] | 1804 |
|
---|
[137] | 1805 | ; Store bus name (4 bytes, space padded, v3.0+)
|
---|
| 1806 | lea si, [Scratch+24h]
|
---|
| 1807 | lea di, [bx+LocDISKINFO_I13X_HostBus]
|
---|
| 1808 | movsw
|
---|
| 1809 | movsw
|
---|
[30] | 1810 |
|
---|
[137] | 1811 | ; Store interface name (8 bytes, space padded, v3.0+)
|
---|
| 1812 | lea di, [bx+LocDISKINFO_I13X_Interface]
|
---|
| 1813 | mov cx, 4
|
---|
| 1814 | rep movsw
|
---|
[30] | 1815 |
|
---|
[137] | 1816 | ; Should gather some more INT13X info here,
|
---|
| 1817 | ; like maybe Advanced Format stuff or so.
|
---|
| 1818 | ; We'll investigate that at a later time.
|
---|
[30] | 1819 |
|
---|
[137] | 1820 | ; --------------------------------------------------------------------- [ MBR ]
|
---|
[30] | 1821 |
|
---|
[137] | 1822 | ; Load the MBR
|
---|
| 1823 | mov si, offset [TmpSector]
|
---|
| 1824 | call DriveIO_LoadMBR
|
---|
[30] | 1825 |
|
---|
[137] | 1826 | ; Store MBR flags (valid sig, partitions present, airboot installed)
|
---|
| 1827 | mov [bx+LocDISKINFO_MbrFlags], al
|
---|
[30] | 1828 |
|
---|
[137] | 1829 | ; Recall BIOS disk number
|
---|
| 1830 | mov dl, [bx+LocDISKINFO_DiskNum]
|
---|
[30] | 1831 |
|
---|
[137] | 1832 | ; --------------------------------------------------------------------- [ LVM ]
|
---|
[30] | 1833 |
|
---|
[137] | 1834 | ; Locate the Master LVM sector, if any
|
---|
| 1835 | call DriveIO_LocateMasterLVMSector
|
---|
[30] | 1836 |
|
---|
[137] | 1837 | ; Save Master LVM sector LBA high
|
---|
| 1838 | mov cx, bx
|
---|
[30] | 1839 |
|
---|
[137] | 1840 | ; Recall DISKINFO entry
|
---|
| 1841 | mov bx, bp
|
---|
[30] | 1842 |
|
---|
[137] | 1843 | ; Store Master LVM sector LBA
|
---|
| 1844 | mov [bx+LocDISKINFO_LVM_MasterLBA+00h], ax
|
---|
| 1845 | mov [bx+LocDISKINFO_LVM_MasterLBA+02h], cx
|
---|
[30] | 1846 |
|
---|
[137] | 1847 | ; No Master LVM sector found, so skip storing LVM info for this disk
|
---|
| 1848 | jnc DriveIO_GatherDiskInfo_no_master_lvm
|
---|
[30] | 1849 |
|
---|
[137] | 1850 | ; Load the Master LVM sector into [LVMSector]
|
---|
| 1851 | call DriveIO_LoadMasterLVMSector
|
---|
[30] | 1852 |
|
---|
[137] | 1853 | ; No valid Master LVM sector, so skip storing LVM info for this disk
|
---|
| 1854 | jc DriveIO_GatherDiskInfo_no_master_lvm
|
---|
[30] | 1855 |
|
---|
[137] | 1856 | ; A valid Master LVM sector has been loaded into [LVMSector]
|
---|
| 1857 | mov si, offset [LVMSector]
|
---|
[30] | 1858 |
|
---|
[137] | 1859 | ; Get the number of sectors per track (OS/2 geometry)
|
---|
| 1860 | mov ax, [si+LocLVM_Secs+00h]
|
---|
| 1861 | mov cx, [si+LocLVM_Secs+02h]
|
---|
[30] | 1862 |
|
---|
[137] | 1863 | ; Store it
|
---|
| 1864 | mov [bx+LocDISKINFO_LVM_Secs+00h], ax
|
---|
| 1865 | mov [bx+LocDISKINFO_LVM_Secs+02h], cx
|
---|
[30] | 1866 |
|
---|
[137] | 1867 | ; Get the number of heads (OS/2 geometry)
|
---|
| 1868 | mov ax, [si+LocLVM_Heads+00h]
|
---|
| 1869 | mov cx, [si+LocLVM_Heads+02h]
|
---|
[30] | 1870 |
|
---|
[137] | 1871 | ; Store it
|
---|
| 1872 | mov [bx+LocDISKINFO_LVM_Heads+00h], ax
|
---|
| 1873 | mov [bx+LocDISKINFO_LVM_Heads+02h], cx
|
---|
[30] | 1874 |
|
---|
[137] | 1875 | ; Should gather some more LVM info here,
|
---|
| 1876 | ; like OS/2 extended geometry and other flags.
|
---|
| 1877 | ; We'll implement that at a later time.
|
---|
[30] | 1878 |
|
---|
[137] | 1879 | DriveIO_GatherDiskInfo_no_master_lvm:
|
---|
[30] | 1880 |
|
---|
[137] | 1881 | ; When no Master LVM sector was found,
|
---|
| 1882 | ; the LVM info in the DISKINFO structure for the disk
|
---|
| 1883 | ; will be ZERO because the area was cleared in PRECRAP.
|
---|
[30] | 1884 |
|
---|
[137] | 1885 | ; Indicate success
|
---|
| 1886 | clc
|
---|
| 1887 |
|
---|
| 1888 | jmp DriveIO_GatherDiskInfo_ret
|
---|
| 1889 |
|
---|
| 1890 | DriveIO_GatherDiskInfo_error:
|
---|
| 1891 | stc
|
---|
[43] | 1892 | DriveIO_GatherDiskInfo_ret:
|
---|
[137] | 1893 |
|
---|
| 1894 |
|
---|
| 1895 | IFDEF AUX_DEBUG
|
---|
[164] | 1896 | IF 0
|
---|
[137] | 1897 | DBG_TEXT_OUT_AUX '[DISKINFO]'
|
---|
| 1898 | PUSHRF
|
---|
| 1899 | call DEBUG_DumpRegisters
|
---|
| 1900 | ;~ call AuxIO_DumpParagraph
|
---|
| 1901 | ;~ call AuxIO_TeletypeNL
|
---|
| 1902 | mov si, bp
|
---|
| 1903 | mov cx, 4
|
---|
| 1904 | @@:
|
---|
| 1905 | call AuxIO_DumpParagraph
|
---|
| 1906 | call AuxIO_TeletypeNL
|
---|
| 1907 | add si, 16
|
---|
| 1908 | loop @B
|
---|
| 1909 | mov si, offset [Scratch]
|
---|
| 1910 | mov cx, 4
|
---|
| 1911 | @@:
|
---|
| 1912 | call AuxIO_DumpParagraph
|
---|
| 1913 | call AuxIO_TeletypeNL
|
---|
| 1914 | add si, 16
|
---|
| 1915 | loop @B
|
---|
| 1916 | mov si, offset [LVMSector]
|
---|
| 1917 | mov cx, 7
|
---|
| 1918 | @@:
|
---|
| 1919 | call AuxIO_DumpParagraph
|
---|
| 1920 | call AuxIO_TeletypeNL
|
---|
| 1921 | add si, 16
|
---|
| 1922 | loop @B
|
---|
| 1923 | POPRF
|
---|
| 1924 | ENDIF
|
---|
| 1925 | ENDIF
|
---|
| 1926 |
|
---|
| 1927 | ; Restore registers
|
---|
[43] | 1928 | pop es
|
---|
[137] | 1929 | pop ds
|
---|
| 1930 | popa
|
---|
[30] | 1931 |
|
---|
[43] | 1932 | ret
|
---|
[30] | 1933 | DriveIO_GatherDiskInfo EndP
|
---|
| 1934 |
|
---|
[130] | 1935 | ;------------------------------------------------------------------------------
|
---|
[143] | 1936 | ; Scan all disks to gather information
|
---|
| 1937 | ;------------------------------------------------------------------------------
|
---|
| 1938 | ; IN : None
|
---|
| 1939 | ; OUT : CF=1 - some failure occured
|
---|
| 1940 | ; : ZF=1 - no harddisks
|
---|
| 1941 | ; NOTE : This does the preliminary gathering of disk information
|
---|
| 1942 | ;------------------------------------------------------------------------------
|
---|
| 1943 | DriveIO_ScanDisks Proc Near
|
---|
| 1944 |
|
---|
| 1945 | IFDEF AUX_DEBUG
|
---|
[164] | 1946 | IF 0
|
---|
[143] | 1947 | DBG_TEXT_OUT_AUX 'DriveIO_ScanDisks:'
|
---|
| 1948 | PUSHRF
|
---|
| 1949 | call DEBUG_DumpRegisters
|
---|
| 1950 | ;~ call AuxIO_DumpParagraph
|
---|
| 1951 | ;~ call AuxIO_TeletypeNL
|
---|
| 1952 | POPRF
|
---|
| 1953 | ENDIF
|
---|
| 1954 | ENDIF
|
---|
| 1955 |
|
---|
| 1956 | ; Save all registers
|
---|
| 1957 | pusha
|
---|
| 1958 |
|
---|
| 1959 | ; Get number of disks in DH
|
---|
| 1960 | call DriveIO_GetHardDriveCount
|
---|
| 1961 |
|
---|
| 1962 | ; Check if there are any disks to scan
|
---|
| 1963 | xor cx, cx ; Prepare 16-bit counter
|
---|
| 1964 | mov cl, dh ; Number of disks now in CX
|
---|
| 1965 | jcxz DriveIO_ScanDisks_end ; Quit if no disks
|
---|
| 1966 |
|
---|
| 1967 | ; Scan disks from 80h upward
|
---|
| 1968 | mov dl, 80h ; BIOS number of first disk
|
---|
| 1969 | DriveIO_ScanDisks_next:
|
---|
| 1970 | call DriveIO_GatherDiskInfo ; Gather info for this disk
|
---|
| 1971 | jc DriveIO_ScanDisks_end ; Quit if some error occured
|
---|
| 1972 | inc dl ; Advance to next disk
|
---|
| 1973 | loop DriveIO_ScanDisks_next ; Scan next disk if there is one
|
---|
| 1974 | test dl, dl ; Set ZF=0
|
---|
| 1975 | clc ; Indicate success
|
---|
| 1976 |
|
---|
| 1977 | DriveIO_ScanDisks_end:
|
---|
| 1978 | ; Restore all registers
|
---|
| 1979 | popa
|
---|
| 1980 |
|
---|
| 1981 | ret
|
---|
| 1982 | DriveIO_ScanDisks EndP
|
---|
| 1983 |
|
---|
| 1984 | ;------------------------------------------------------------------------------
|
---|
[130] | 1985 | ; Calculate pointer to entry in DISKINFO structure
|
---|
| 1986 | ;------------------------------------------------------------------------------
|
---|
| 1987 | ; IN : DL BIOS disk number (80h etc)
|
---|
| 1988 | ; OUT : BX Pointer to entry
|
---|
| 1989 | ; NOTE : BIOS disk number must be valid
|
---|
| 1990 | ;------------------------------------------------------------------------------
|
---|
| 1991 | DriveIO_CalcDiskInfoPointer Proc Near
|
---|
| 1992 | xchg bx, ax ; AX is used for calculation
|
---|
| 1993 | mov al, DISKINFO_Size ; Size of DISKINFO structure
|
---|
| 1994 | mov ah, dl ; BIOS disk number
|
---|
| 1995 | sub ah, 80h ; Now 0-based index
|
---|
| 1996 | mul ah ; Now offset into DISKINFO array
|
---|
| 1997 | add ax, offset [DiskInformation] ; Base of DISKINFO array
|
---|
| 1998 | xchg bx, ax ; BX now points to entry for disk
|
---|
| 1999 | ret
|
---|
| 2000 | DriveIO_CalcDiskInfoPointer EndP
|
---|
[30] | 2001 |
|
---|
[120] | 2002 | ;------------------------------------------------------------------------------
|
---|
| 2003 | ; Check if the BIOS disk number in DL is a harddisk and in range
|
---|
| 2004 | ;------------------------------------------------------------------------------
|
---|
| 2005 | ; IN : DL BIOS disk number (80h etc)
|
---|
| 2006 | ; OUT : CF=1 if invalid disk number or out of range
|
---|
| 2007 | ; NOTE : Only modifies flags
|
---|
| 2008 | ;------------------------------------------------------------------------------
|
---|
| 2009 | DriveIO_IsValidHarddisk Proc Near Uses dx
|
---|
| 2010 | cmp dl, 80h ; BIOS disk number must be at least 80h
|
---|
| 2011 | jb @F ; Not a harddisk, exit with CY
|
---|
| 2012 | mov dh, dl ; Save to do compare
|
---|
| 2013 | sub dh, 80h ; Now 0 based disk number
|
---|
| 2014 | inc dh ; Now 1 based disk number
|
---|
| 2015 | cmp [TotalHarddiscs], dh ; Out of range, exit with CY
|
---|
| 2016 | @@: ret
|
---|
| 2017 | DriveIO_IsValidHarddisk EndP
|
---|
[30] | 2018 |
|
---|
[120] | 2019 |
|
---|
[30] | 2020 | ; Values for sectors per track table corresponding to DriveIO_IsHugeDrive return value.
|
---|
[137] | 2021 | ;~ secs_per_track_table db 63,127,255,255,255,255
|
---|
[30] | 2022 |
|
---|
[123] | 2023 | ;~ db_lmlvm db 'Load Master LVM -- disk: ',0
|
---|