[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 | ;
|
---|
| 18 | ;---------------------------------------------------------------------------
|
---|
| 19 | ; AiR-BOOT / LVM
|
---|
| 20 | ;---------------------------------------------------------------------------
|
---|
| 21 |
|
---|
[51] | 22 | IFDEF MODULE_NAMES
|
---|
[30] | 23 | DB 'LVM',0
|
---|
| 24 | ENDIF
|
---|
| 25 |
|
---|
[40] | 26 | LVM_InitCRCTable Proc Near
|
---|
[51] | 27 | ; Initializes our LVM-CRC-Table
|
---|
| 28 | xor cl, cl
|
---|
| 29 | mov di, offset [LVM_CRCTable]
|
---|
| 30 | LVM_ICRCT_Loop:
|
---|
| 31 | ;movzx ax, cl
|
---|
| 32 | mov al,cl
|
---|
| 33 | mov ah,0
|
---|
| 34 | xor dx, dx ; DX:AX - CRC-Value
|
---|
| 35 | mov ch, 8
|
---|
| 36 | LVM_ICRCT_Loop2:
|
---|
| 37 | shr dx, 1
|
---|
| 38 | rcr ax, 1 ; Shift value 1 to the right
|
---|
| 39 | jnc LVM_ICRCT_NoXOR
|
---|
| 40 | xor dx, 0EDB8h
|
---|
| 41 | xor ax, 8320h
|
---|
| 42 | LVM_ICRCT_NoXOR:
|
---|
| 43 | dec ch
|
---|
| 44 | jnz LVM_ICRCT_Loop2
|
---|
| 45 | mov wptr [di+0], ax
|
---|
| 46 | mov wptr [di+2], dx
|
---|
| 47 | add di, 4
|
---|
| 48 | add cl, 1
|
---|
| 49 | jnc LVM_ICRCT_Loop
|
---|
| 50 | ret
|
---|
[29] | 51 | LVM_InitCRCTable EndP
|
---|
| 52 |
|
---|
| 53 | ; Calculates an LVM-Sector CRC of a given sector
|
---|
| 54 | ; In: DS:SI - Points to Sector...
|
---|
| 55 | ; Out: DX:AX - LVM CRC
|
---|
| 56 | ; Destroyed: None
|
---|
| 57 | LVM_GetSectorCRC Proc Near Uses bx cx
|
---|
[111] | 58 |
|
---|
| 59 | IFDEF AUX_DEBUG
|
---|
| 60 | IF 0
|
---|
[123] | 61 | DBG_TEXT_OUT_AUX 'LVM_GetSectorCRC:'
|
---|
| 62 | PUSHRF
|
---|
[111] | 63 | ;~ call DEBUG_DumpRegisters
|
---|
| 64 | ;~ call AuxIO_DumpParagraph
|
---|
| 65 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 66 | POPRF
|
---|
[111] | 67 | ENDIF
|
---|
| 68 | ENDIF
|
---|
| 69 |
|
---|
[51] | 70 | push word ptr [si+LocLVM_CRC+00]
|
---|
| 71 | push word ptr [si+LocLVM_CRC+02]
|
---|
| 72 | push si
|
---|
| 73 | mov word ptr [si+LocLVM_CRC], 0
|
---|
| 74 | mov word ptr [si+LocLVM_CRC+2], 0
|
---|
| 75 | mov ax, -1
|
---|
| 76 | mov dx, -1
|
---|
| 77 | mov cx, 512
|
---|
| 78 | LVM_GSCRC_Loop:
|
---|
| 79 | xor bh, bh
|
---|
| 80 | mov bl, al ; Save last byte to BL
|
---|
| 81 | mov al, ah
|
---|
| 82 | mov ah, dl
|
---|
| 83 | mov dl, dh
|
---|
| 84 | xor dh, dh ; SHR DX:AX, 8
|
---|
| 85 | xor bl, [si]
|
---|
| 86 | inc si ; XOR last byte with [data]
|
---|
| 87 | shl bx, 1
|
---|
| 88 | shl bx, 1
|
---|
| 89 | xor ax, word ptr [LVM_CRCTable+bx+0]
|
---|
| 90 | xor dx, word ptr [LVM_CRCTable+bx+2] ; XOR with CRC-Table
|
---|
| 91 | loop LVM_GSCRC_Loop
|
---|
| 92 | pop si
|
---|
| 93 | pop word ptr [si+LocLVM_CRC+2]
|
---|
| 94 | pop word ptr [si+LocLVM_CRC]
|
---|
| 95 | ret
|
---|
[29] | 96 | LVM_GetSectorCRC EndP
|
---|
| 97 |
|
---|
[46] | 98 | ; Checks ds:[SI], if a valid LVM Signature is found (sets carry in that case)
|
---|
[29] | 99 | ; This does not check for valid LVM CRC (which also needs to be done)
|
---|
| 100 | ; In: DS:SI - Sector that needs to get checked...
|
---|
| 101 | ; Out: Carry set, if valid LVM signature found
|
---|
| 102 | ; Destroyed: None
|
---|
[40] | 103 | LVM_CheckSectorSignature Proc Near
|
---|
[51] | 104 | test byte ptr [CFG_IgnoreLVM], 1 ; We are supposed to ignore LVM, so
|
---|
| 105 | jnz LVMCSS_InvalidSignature ; any sector is bad!
|
---|
| 106 | cmp word ptr [si+LocLVM_SignatureStart], 5202h
|
---|
| 107 | jne LVMCSS_InvalidSignature
|
---|
| 108 | cmp word ptr [si+LocLVM_SignatureStart+2], 'BM'
|
---|
| 109 | jne LVMCSS_InvalidSignature
|
---|
| 110 | cmp word ptr [si+LocLVM_SignatureStart+4], 'MP'
|
---|
| 111 | jne LVMCSS_InvalidSignature
|
---|
| 112 | cmp word ptr [si+LocLVM_SignatureStart+6], 'DF'
|
---|
| 113 | jne LVMCSS_InvalidSignature
|
---|
| 114 | stc
|
---|
| 115 | ret
|
---|
| 116 | LVMCSS_InvalidSignature:
|
---|
| 117 | clc
|
---|
| 118 | ret
|
---|
[29] | 119 | LVM_CheckSectorSignature EndP
|
---|
| 120 |
|
---|
| 121 | ; Checks Sector for a valid LVM CRC is encountered
|
---|
| 122 | ; First one should check for a valid signature and call this later.
|
---|
| 123 | ; In: DS:SI - Sector that needs to get checked...
|
---|
| 124 | ; Out: Carry set, if LVM CRC valid
|
---|
| 125 | ; Destroyed: None
|
---|
[101] | 126 | LVM_CheckSectorCRC Proc Near Uses ax bx dx
|
---|
[124] | 127 | call IsSectorBufferZero ; Zero sector implies bad CRC
|
---|
[101] | 128 | jz LVMCSCRC_BadCRC
|
---|
| 129 | call LVM_GetSectorCRC ; Only use after CRC table is valid
|
---|
[51] | 130 | cmp ax, word ptr [si+LocLVM_CRC]
|
---|
| 131 | jne LVMCSCRC_BadCRC
|
---|
| 132 | cmp dx, word ptr [si+LocLVM_CRC+2]
|
---|
| 133 | jne LVMCSCRC_BadCRC
|
---|
[101] | 134 | stc ; Indicate CRC is OK
|
---|
[51] | 135 | ret
|
---|
| 136 | LVMCSCRC_BadCRC:
|
---|
[101] | 137 | clc ; Indicate BAD CRC
|
---|
[51] | 138 | ret
|
---|
[29] | 139 | LVM_CheckSectorCRC EndP
|
---|
| 140 |
|
---|
[100] | 141 | ; Checks if a sector is a valid LVM-sector
|
---|
[114] | 142 | ; Sector is considered valid LVM-sector if both signature and CRC are correct.
|
---|
| 143 | ; IN : DS:SI - Buffer with LVM-sector that needs to be checked...
|
---|
| 144 | ; OUT : AL.0 - 1 -> LVM Signature found
|
---|
| 145 | ; AL.1 - 1 -> CRC OK
|
---|
| 146 | ; CY - Signature and CRC OK, otherwise none or invalid LVM sector
|
---|
[100] | 147 | ; Destroyed: None
|
---|
| 148 | LVM_ValidateSector Proc Near
|
---|
[114] | 149 | xor ax, ax ; Assume no Signature or valid CRC
|
---|
[100] | 150 | call LVM_CheckSectorSignature ; CF=1 -> Signature OK
|
---|
[114] | 151 | rcl al, 1 ; Store CF in AL.0
|
---|
| 152 | call LVM_CheckSectorCRC ; CF=1 -> CRC OK
|
---|
| 153 | rcl ah, 1 ; Store CF in AH.0
|
---|
| 154 | shl ah, 1 ; Move it to AH.1
|
---|
| 155 | or al, ah ; Merge CY results to AL
|
---|
| 156 | cmp al, 3 ; AH=3 -> Signature and CRC OK
|
---|
| 157 | clc ; Assume invalid LVM-sector
|
---|
| 158 | jne @F
|
---|
| 159 | stc ; AH=3 -> Indicate valid LVM-sector
|
---|
| 160 | @@:
|
---|
| 161 | mov ah, 0 ; Don't leave garbage in AH
|
---|
[98] | 162 | ret
|
---|
[100] | 163 | LVM_ValidateSector EndP
|
---|
[98] | 164 |
|
---|
[29] | 165 | ; Updates Sector with valid LVM CRC
|
---|
| 166 | ; This one doesn't check, if it's really an LVM sector, so check before!
|
---|
| 167 | ; In: DS:SI - Sector that needs to get checked...
|
---|
| 168 | ; Out: None, CRC updated
|
---|
| 169 | ; Destroyed: None
|
---|
| 170 | LVM_UpdateSectorCRC Proc Near Uses ax dx
|
---|
[51] | 171 | call LVM_GetSectorCRC
|
---|
| 172 | mov word ptr [si+LocLVM_CRC], ax
|
---|
| 173 | mov word ptr [si+LocLVM_CRC+2], dx
|
---|
| 174 | ret
|
---|
[29] | 175 | LVM_UpdateSectorCRC EndP
|
---|
| 176 |
|
---|
| 177 | ; Searches for a partition in LVM Information Sector and sets SI to point to
|
---|
| 178 | ; the LVM-entry. It will also set CARRY then.
|
---|
| 179 | ; In: DX:AX - LBA starting sector of partition to be searched
|
---|
| 180 | ; DS:SI - Valid (previously checked) LVM-Information-Sector
|
---|
| 181 | ; Out: Carry set, if partition found
|
---|
| 182 | ; DS:SI - points to LVM information entry
|
---|
| 183 | ; Destroyed: None
|
---|
[111] | 184 |
|
---|
| 185 | ; INVALID LVM RECORD WHEN STICK INSERTED !
|
---|
| 186 |
|
---|
[29] | 187 | LVM_SearchForPartition Proc Near Uses cx
|
---|
[111] | 188 |
|
---|
| 189 | IFDEF AUX_DEBUG
|
---|
| 190 | IF 0
|
---|
[123] | 191 | DBG_TEXT_OUT_AUX 'LVM_SearchForPartition:'
|
---|
| 192 | PUSHRF
|
---|
[117] | 193 | call DEBUG_DumpRegisters
|
---|
[111] | 194 | ;~ call AuxIO_DumpParagraph
|
---|
| 195 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 196 | POPRF
|
---|
[111] | 197 | ENDIF
|
---|
| 198 | ENDIF
|
---|
| 199 |
|
---|
[51] | 200 | cmp byte ptr [si+LocLVM_SignatureStart], LocLVM_SignatureByte0
|
---|
| 201 | jne LVMSFP_NotFound ; Quick Check, if LVM sector there
|
---|
| 202 | add si, LocLVM_StartOfEntries
|
---|
| 203 | mov cl, LocLVM_MaxEntries
|
---|
| 204 | LVMSFP_Loop:
|
---|
| 205 | cmp ax, [si+LocLVM_PartitionStart]
|
---|
| 206 | jne LVMSFP_NextEntry
|
---|
| 207 | cmp dx, [si+LocLVM_PartitionStart+2]
|
---|
| 208 | je LVMSFP_FoundIt
|
---|
| 209 | LVMSFP_NextEntry:
|
---|
| 210 | add si, LocLVM_LenOfEntry
|
---|
| 211 | dec cl
|
---|
| 212 | jnz LVMSFP_Loop
|
---|
| 213 | LVMSFP_NotFound:
|
---|
| 214 | clc
|
---|
| 215 | ret
|
---|
| 216 | LVMSFP_FoundIt:
|
---|
| 217 | stc
|
---|
| 218 | ret
|
---|
[29] | 219 | LVM_SearchForPartition EndP
|
---|
| 220 |
|
---|
[34] | 221 |
|
---|
[154] | 222 | ;------------------------------------------------------------------------------
|
---|
| 223 | ; Get the LVM drive-letter for a partition (if available)
|
---|
| 224 | ;------------------------------------------------------------------------------
|
---|
| 225 | ; IN : SI - Pointer to IPT entry for partition
|
---|
| 226 | ; OUT : AL - LVM drive-letter
|
---|
| 227 | ; : CF=1 - No valid LVM sector found, AL not valid
|
---|
| 228 | ; NOTE : Besides the drive-letter, AL can be 0 (LVM hidden) or '*' (LVM auto)
|
---|
| 229 | ;------------------------------------------------------------------------------
|
---|
[158] | 230 | LVM_GetDriveLetter Proc Near Uses bx cx dx si di
|
---|
[153] | 231 |
|
---|
[154] | 232 | IFDEF AUX_DEBUG
|
---|
[170] | 233 | IF 0
|
---|
[154] | 234 | DBG_TEXT_OUT_AUX 'LVM_GetDriveLetter:'
|
---|
| 235 | PUSHRF
|
---|
| 236 | call DEBUG_DumpRegisters
|
---|
| 237 | ;~ call AuxIO_DumpParagraph
|
---|
| 238 | ;~ call AuxIO_TeletypeNL
|
---|
| 239 | POPRF
|
---|
| 240 | ENDIF
|
---|
| 241 | ENDIF
|
---|
| 242 |
|
---|
| 243 | ; Save IPT pointer
|
---|
| 244 | mov di, si
|
---|
| 245 |
|
---|
| 246 | ; Get the LBA addresses of the MBR or EBR from the IPT entry
|
---|
| 247 | mov dl, [si+LocIPT_Drive] ; BIOS disk number
|
---|
| 248 | mov ax, [si+LocIPT_AbsolutePartTable+00h] ; LBA lo MBR/EBR
|
---|
| 249 | mov bx, [si+LocIPT_AbsolutePartTable+02h] ; LBA hi MBR/EBR
|
---|
| 250 |
|
---|
| 251 | ; Try to load the corresponding LVM sector
|
---|
| 252 | mov si, offset [LVMSector] ; Pointer to buffer
|
---|
| 253 | call DriveIO_LoadLVMSectorXBR ; Try to load LVM sector
|
---|
| 254 | jc LVM_GetDriveLetter_no_lvm ; No success
|
---|
| 255 |
|
---|
| 256 | ; Recall IPT pointer
|
---|
| 257 | mov si, di
|
---|
| 258 |
|
---|
| 259 | ; Locate the LVM entry for the partition
|
---|
| 260 | mov ax, [si+LocIPT_AbsoluteBegin+00h] ; LBA lo of partition
|
---|
| 261 | mov dx, [si+LocIPT_AbsoluteBegin+02h] ; LBA hi of partition
|
---|
| 262 | mov si, offset [LVMSector] ; Loaded LVM sector
|
---|
| 263 | call LVM_SearchForPartition ; Locate entry
|
---|
| 264 | jnc LVM_GetDriveLetter_no_lvm ; Entry not found
|
---|
| 265 |
|
---|
| 266 | ; Get the LVM drive-letter
|
---|
| 267 | mov al, [si+LocLVM_VolumeLetter] ; Can be 0,'*',letter
|
---|
| 268 |
|
---|
| 269 | ; We're done, indicate success and return
|
---|
[34] | 270 | clc
|
---|
[154] | 271 | jmp LVM_GetDriveLetter_done
|
---|
| 272 |
|
---|
| 273 | LVM_GetDriveLetter_no_lvm:
|
---|
| 274 | ; Indicate no LVM drive-letter found
|
---|
| 275 | xor ax, ax
|
---|
| 276 | stc
|
---|
| 277 |
|
---|
| 278 | LVM_GetDriveLetter_done:
|
---|
| 279 |
|
---|
| 280 | IFDEF AUX_DEBUG
|
---|
| 281 | IF 0
|
---|
| 282 | DBG_TEXT_OUT_AUX 'lgdl_lvmsec'
|
---|
| 283 | PUSHRF
|
---|
| 284 | call DEBUG_DumpRegisters
|
---|
| 285 | mov si, offset [LVMSector]
|
---|
| 286 | call AuxIO_DumpSector
|
---|
| 287 | ;~ call AuxIO_DumpParagraph
|
---|
| 288 | ;~ call AuxIO_TeletypeNL
|
---|
| 289 | POPRF
|
---|
| 290 | ENDIF
|
---|
| 291 | ENDIF
|
---|
| 292 |
|
---|
[34] | 293 | ret
|
---|
| 294 | LVM_GetDriveLetter EndP
|
---|
| 295 |
|
---|
| 296 |
|
---|
[51] | 297 |
|
---|
[156] | 298 | ;------------------------------------------------------------------------------
|
---|
| 299 | ; Set the LVM drive-letter for a partition (if possible)
|
---|
| 300 | ;------------------------------------------------------------------------------
|
---|
| 301 | ; IN : SI - Pointer to IPT entry for partition
|
---|
| 302 | ; : AL - LVM drive-letter
|
---|
[158] | 303 | ; OUT : CF=1 - No valid LVM sector found, AL was not valid
|
---|
[156] | 304 | ; NOTE : Besides the drive-letter, AL can be 0 (LVM hidden) or '*' (LVM auto)
|
---|
| 305 | ;------------------------------------------------------------------------------
|
---|
[158] | 306 | LVM_SetDriveLetter Proc Near Uses bx cx dx si di
|
---|
[111] | 307 |
|
---|
[156] | 308 | ; THIS IS A DUMMY FUNCTION RETURNING FAILURE
|
---|
[51] | 309 |
|
---|
[156] | 310 | ; Setting LVM drive-letters is handled by the LVM drive-letter
|
---|
| 311 | ; reassignment functions. This is because when setting LVM
|
---|
| 312 | ; drive-letters, duplicates and other conditions need to be checked.
|
---|
| 313 | ; This dummy is only present because it might be implemented in the
|
---|
| 314 | ; future as part of the drive-letter reassignment logic.
|
---|
[111] | 315 |
|
---|
[156] | 316 | ; Just indicate failure and return
|
---|
| 317 | xor ax, ax
|
---|
| 318 | stc
|
---|
[51] | 319 | ret
|
---|
| 320 | LVM_SetDriveLetter EndP
|
---|
| 321 |
|
---|
| 322 |
|
---|
| 323 |
|
---|
[29] | 324 | ; Removes a given drive-letter from the whole LVM information sector
|
---|
| 325 | ; In: CH - drive-letter (ascii)
|
---|
| 326 | ; DS:SI - LVM-Information-Sector
|
---|
| 327 | ; Out: LVM-Information-Sector updated (including LVM CRC)
|
---|
| 328 | ; Destroyed: None
|
---|
| 329 | LVM_RemoveVolLetterFromSector Proc Near Uses cx
|
---|
[111] | 330 |
|
---|
| 331 | IFDEF AUX_DEBUG
|
---|
[170] | 332 | IF 0
|
---|
[123] | 333 | DBG_TEXT_OUT_AUX 'LVM_RemoveVolLetterFromSector:'
|
---|
| 334 | PUSHRF
|
---|
[111] | 335 | ;~ call DEBUG_DumpRegisters
|
---|
| 336 | ;~ call AuxIO_DumpParagraph
|
---|
| 337 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 338 | POPRF
|
---|
[111] | 339 | ENDIF
|
---|
| 340 | ENDIF
|
---|
| 341 |
|
---|
[51] | 342 | cmp bptr [si+LocLVM_SignatureStart], LocLVM_SignatureByte0
|
---|
| 343 | jne LVMRVLFS_Done ; Quick Check, if LVM sector there
|
---|
| 344 | push si
|
---|
| 345 | add si, LocLVM_StartOfEntries
|
---|
| 346 | mov cl, LocLVM_MaxEntries
|
---|
| 347 | LVMRVLFS_Loop:
|
---|
| 348 | cmp ch, [si+LocLVM_VolumeLetter]
|
---|
| 349 | jne LVMRVLFS_NextEntry
|
---|
| 350 | ; Reset drive-letter, if matched
|
---|
| 351 | mov bptr [si+LocLVM_VolumeLetter], 0 ; ASSIGN NEXT FREE HERE... (DOET DUBBEL ALS ZELFDE DL ALS SYS)
|
---|
| 352 | LVMRVLFS_NextEntry:
|
---|
| 353 | add si, LocLVM_LenOfEntry
|
---|
| 354 | dec cl
|
---|
| 355 | jnz LVMRVLFS_Loop
|
---|
| 356 | pop si
|
---|
| 357 | call LVM_UpdateSectorCRC
|
---|
| 358 | LVMRVLFS_Done:
|
---|
| 359 | ret
|
---|
[29] | 360 | LVM_RemoveVolLetterFromSector EndP
|
---|
| 361 |
|
---|
| 362 | ; Reassigns LVM volume driveletter
|
---|
| 363 | ; Will remove the drive-letter from any volume that got it currently
|
---|
| 364 | ; and finally change the drive-letter of the given partition
|
---|
| 365 | ; In: AL - drive-letter
|
---|
| 366 | ; DS:SI - points to partition, that needs that driveletter
|
---|
| 367 | ; Out: None
|
---|
| 368 | ; Destroyed: AX
|
---|
[51] | 369 |
|
---|
[29] | 370 | LVM_DoLetterReassignment Proc Near Uses bx cx dx si di
|
---|
[50] | 371 |
|
---|
[111] | 372 | IFDEF AUX_DEBUG
|
---|
[170] | 373 | IF 0
|
---|
[123] | 374 | DBG_TEXT_OUT_AUX 'LVM_DoLetterReassignment:'
|
---|
| 375 | PUSHRF
|
---|
[111] | 376 | ;~ call DEBUG_DumpRegisters
|
---|
| 377 | ;~ call AuxIO_DumpParagraph
|
---|
| 378 | ;~ call AuxIO_TeletypeNL
|
---|
[123] | 379 | POPRF
|
---|
[111] | 380 | ENDIF
|
---|
| 381 | ENDIF
|
---|
[50] | 382 |
|
---|
[51] | 383 | mov di, si ; Save SI in DI (Partition-pointer)
|
---|
| 384 | mov ch, al ; and AL in CH (drive-letter)
|
---|
| 385 | xor bx, bx
|
---|
| 386 | mov cl, CFG_Partitions
|
---|
| 387 | or cl, cl
|
---|
| 388 | jz LVMDLR_SkipRemove
|
---|
| 389 |
|
---|
| 390 | LVMDLR_RemoveLoop:
|
---|
| 391 | cmp bptr [PartitionVolumeLetters+bx], ch
|
---|
| 392 | jne LVMDLR_NextPartition
|
---|
| 393 | ; One volume that has our wanted drive-letter, so remove it!
|
---|
| 394 | mov dl, bl
|
---|
| 395 | call PART_GetPartitionPointer ; DL - partition -> SI
|
---|
| 396 | ; Now set CurPartition_Location for the DriveIO-functions to work
|
---|
| 397 | mov ax, wptr [si+LocIPT_AbsolutePartTable]
|
---|
| 398 | mov wptr [CurPartition_Location+0], ax
|
---|
| 399 | mov ax, wptr [si+LocIPT_AbsolutePartTable+2]
|
---|
| 400 | mov wptr [CurPartition_Location+2], ax
|
---|
| 401 | mov ax, wptr [si+LocIPT_LocationPartTable+1]
|
---|
| 402 | mov wptr [CurPartition_Location+6], ax
|
---|
| 403 | mov ah, bptr [si+LocIPT_LocationPartTable+0]
|
---|
| 404 | mov al, [si+LocIPT_Drive]
|
---|
| 405 | mov wptr [CurPartition_Location+4], ax
|
---|
| 406 | call DriveIO_LoadLVMSector ; SI points now to LVM-Sector
|
---|
| 407 | call LVM_RemoveVolLetterFromSector
|
---|
| 408 |
|
---|
| 409 | call DriveIO_SaveLVMSector ; Save sector
|
---|
[76] | 410 |
|
---|
[51] | 411 | LVMDLR_NextPartition:
|
---|
| 412 | inc bx
|
---|
| 413 | dec cl
|
---|
| 414 | jnz LVMDLR_RemoveLoop
|
---|
| 415 |
|
---|
| 416 | LVMDLR_SkipRemove:
|
---|
| 417 | ; Set CurPartition_Location information of destination partition
|
---|
| 418 | mov ax, wptr [di+LocIPT_AbsolutePartTable]
|
---|
| 419 | mov wptr [CurPartition_Location+0], ax
|
---|
| 420 | mov ax, wptr [di+LocIPT_AbsolutePartTable+2]
|
---|
| 421 | mov wptr [CurPartition_Location+2], ax
|
---|
| 422 | mov ah, bptr [di+LocIPT_LocationPartTable+0]
|
---|
| 423 | mov al, [di+LocIPT_Drive]
|
---|
| 424 | mov wptr [CurPartition_Location+4], ax
|
---|
| 425 | mov ax, wptr [di+LocIPT_LocationPartTable+1]
|
---|
| 426 | mov wptr [CurPartition_Location+6], ax
|
---|
| 427 | call DriveIO_LoadLVMSector ; SI points now to LVM-Sector
|
---|
| 428 | mov ax, wptr [di+LocIPT_AbsoluteBegin]
|
---|
| 429 | mov dx, wptr [di+LocIPT_AbsoluteBegin+2]
|
---|
| 430 | mov di, si ; Save SI in DI
|
---|
| 431 | call LVM_SearchForPartition
|
---|
| 432 | jnc LVMDLR_DestPartNotFound
|
---|
| 433 | ; Set new volume letter
|
---|
| 434 | mov bptr [si+LocLVM_VolumeLetter], ch
|
---|
| 435 | mov si, di ; SI - LVM Sector again
|
---|
| 436 | call LVM_UpdateSectorCRC ; Update LVM-CRC now
|
---|
| 437 |
|
---|
[76] | 438 | call DriveIO_SaveLVMSector ; Save sector
|
---|
[51] | 439 |
|
---|
| 440 | LVMDLR_DestPartNotFound:
|
---|
| 441 | ; This here is done for safety, because we misuse CurPartition_Location
|
---|
| 442 | xor ax, ax
|
---|
| 443 | mov di, offset CurPartition_Location
|
---|
| 444 | mov cx, 4
|
---|
| 445 | rep stosw ; NUL out CurPartition_Location
|
---|
| 446 | ret
|
---|
[29] | 447 | LVM_DoLetterReassignment EndP
|
---|
[51] | 448 |
|
---|
| 449 |
|
---|
| 450 | ; This walks the IPT and for each partition it obtains the LVM drive-letter
|
---|
| 451 | ; if available. This drive-letter is then marked as in-use in the Map.
|
---|
| 452 | ; The FreeDriveletterMap is used by the drive-letter reassignment function
|
---|
| 453 | ; to assign a new drive to a data-partition when a system-partition is booted
|
---|
| 454 | ; with the same drive-letter. The original drive-letter for the data-partition
|
---|
| 455 | ; is saved so it can be restored later when a system is booted that does not
|
---|
| 456 | ; use the drive-letter. Note that there can be multiple system-partitions
|
---|
| 457 | ; using the same drive-letter and data-partitions can become system-partition
|
---|
| 458 | ; by making them bootable. (and vice versa)
|
---|
| 459 | LVM_ComposeFreeDriveletterMap Proc
|
---|
| 460 |
|
---|
| 461 | ; get nr of partitions in IPT
|
---|
| 462 | ; for each partition get LVM drive-letter and reset bit in map.
|
---|
| 463 |
|
---|
| 464 | LVM_ComposeFreeDriveletterMap EndP
|
---|
| 465 |
|
---|