source: trunk/bootcode/special/lvm.asm@ 145

Last change on this file since 145 was 124, checked in by Ben Rietbroek, 8 years ago

Use SI instead of BX for actions on sector buffers [v1.1.1-testing]

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File size: 25.1 KB
Line 
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
22IFDEF MODULE_NAMES
23DB 'LVM',0
24ENDIF
25
26LVM_InitCRCTable Proc Near
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
51LVM_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
57LVM_GetSectorCRC Proc Near Uses bx cx
58
59IFDEF AUX_DEBUG
60 IF 0
61 DBG_TEXT_OUT_AUX 'LVM_GetSectorCRC:'
62 PUSHRF
63 ;~ call DEBUG_DumpRegisters
64 ;~ call AuxIO_DumpParagraph
65 ;~ call AuxIO_TeletypeNL
66 POPRF
67 ENDIF
68ENDIF
69
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
96LVM_GetSectorCRC EndP
97
98; Checks ds:[SI], if a valid LVM Signature is found (sets carry in that case)
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
103LVM_CheckSectorSignature Proc Near
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
119LVM_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
126LVM_CheckSectorCRC Proc Near Uses ax bx dx
127 call IsSectorBufferZero ; Zero sector implies bad CRC
128 jz LVMCSCRC_BadCRC
129 call LVM_GetSectorCRC ; Only use after CRC table is valid
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
134 stc ; Indicate CRC is OK
135 ret
136 LVMCSCRC_BadCRC:
137 clc ; Indicate BAD CRC
138 ret
139LVM_CheckSectorCRC EndP
140
141; Checks if a sector is a valid LVM-sector
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
147; Destroyed: None
148LVM_ValidateSector Proc Near
149 xor ax, ax ; Assume no Signature or valid CRC
150 call LVM_CheckSectorSignature ; CF=1 -> Signature OK
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
162 ret
163LVM_ValidateSector EndP
164
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
170LVM_UpdateSectorCRC Proc Near Uses ax dx
171 call LVM_GetSectorCRC
172 mov word ptr [si+LocLVM_CRC], ax
173 mov word ptr [si+LocLVM_CRC+2], dx
174 ret
175LVM_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
184
185; INVALID LVM RECORD WHEN STICK INSERTED !
186
187LVM_SearchForPartition Proc Near Uses cx
188
189IFDEF AUX_DEBUG
190 IF 0
191 DBG_TEXT_OUT_AUX 'LVM_SearchForPartition:'
192 PUSHRF
193 call DEBUG_DumpRegisters
194 ;~ call AuxIO_DumpParagraph
195 ;~ call AuxIO_TeletypeNL
196 POPRF
197 ENDIF
198ENDIF
199
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
219LVM_SearchForPartition EndP
220
221
222; Gets a drive-letter from the LVM-info of a partition. (if it exists)
223; In: BX:CX - LBA starting sector of partition to be searched
224; DL = Physical Disk in BIOS notation. (80h+)
225; Out: CY=1 if LVM-info found, 0 if no LVM-info.
226; AL - drive-letter from LVM-info or zero if no drive-letter
227; assigned or no LVM-info.
228LVM_GetDriveLetter Proc Near Uses bx cx dx si di ds es
229
230IFDEF AUX_DEBUG
231 IF 0
232 DBG_TEXT_OUT_AUX 'LVM_GetDriveLetter:'
233 PUSHRF
234 ;~ call DEBUG_DumpRegisters
235 ;~ call AuxIO_DumpParagraph
236 ;~ call AuxIO_TeletypeNL
237 POPRF
238 ENDIF
239ENDIF
240
241
242
243 ; For primary partitions this information is stored in the last
244 ; sector of track0; for all four partition entries in case they
245 ; they are all primary ones.
246 ;
247 ; LVM DLAT info for logical partitions is stored in the sector
248 ; preceding the start of the partition.
249 ;
250 ; Because the LVM info of a logical partition is the easiest to find,
251 ; we do that first. The LVM info for primary partitions is located
252 ; dependent on the geometry in use, so we use a special locater
253 ; call for that. Also, since the LVM info for primaries contains
254 ; info on all 4 entries, we need the partition index to obtain the
255 ; correct drive-letter.
256 ;
257
258 ; See if this is a primary partition
259 ; CY will be set if it is and AL will contain the 0-based
260 ; index in the P-table.
261 ; If it's a logical partition, CY will be clear and AL
262 ; will be set to 0ffh indicating an invalid index.
263 call PART_IsPrimaryPartition
264IF 0
265 pushf
266 pusha
267 call VideoIO_PrintHexWord
268 popa
269 popf
270ENDIF
271 mov al,0
272 rcl al,1 ; CY if primary
273 mov dh,al ; Save PRI or LOG
274
275 ; Save PRI/LOG indicator for later use
276 push dx
277
278 ; Load *possible* LVM sector
279 ; This load is only valid if the partition is logical, in which case
280 ; the LVM sector is below the start of the partition.
281 ; If primary, the LVM sector is at a location that
282 ; DriveIO_LoadMasterLVMSector will find out.
283
284 ; Push LBA address
285 push bx
286 push cx
287
288 ; Adjust for logical LVM-sector
289 sub cx,1
290 sbb bx,0
291
292 ; Load the LVM sector
293 push si
294 push di
295 mov si,offset [LVMSector]
296 mov di,ds
297 mov ax, cx ; LBA low is now in AX
298 call DriveIO_ReadSectorLBA
299 pop di
300 pop si
301
302 ; Restore LBA address
303 pop cx
304 pop bx
305
306 ; Restore PRI/LOG partition indicator in DH
307 pop dx
308
309 ; Test PRI or not
310 test dh,dh
311 ; It's not a PRI so we can use the previously loaded LVM sector
312 jz LVM_GetDriveLetter_is_not_pri
313
314 ;
315 ; It's a PRI so we use the special locator function.
316 ; This locator takes care of extended OS/2 geometry should that be used
317 ;
318IF 0
319 ; DH=0 or 1, DL=disk (8?h)
320 pushf
321 pusha
322 mov ax, dx
323 call VideoIO_PrintHexWord
324 mov al,'-'
325 call VideoIO_PrintSingleChar
326 popa
327 popf
328ENDIF
329 ; THIS ONE FAULTERS WHEN DISKS > 1
330 call DriveIO_LoadMasterLVMSector
331
332IF 0
333 ; INVALID LVM SECTOR !!
334 pushf
335 pusha
336 mov ax,0000h
337 rcl al,1
338 call VideoIO_PrintHexWord ; LVMSector
339 mov al,'-'
340 call VideoIO_PrintSingleChar
341 mov si, offset [LVMSector]
342 mov ax, si
343 call VideoIO_PrintHexWord ; LVMSector
344 lodsw
345 call VideoIO_PrintHexWord ; sig
346 lodsw
347 call VideoIO_PrintHexWord ; sig
348 mov al,'-'
349 call VideoIO_PrintSingleChar
350 popa
351 popf
352ENDIF
353
354 LVM_GetDriveLetter_is_not_pri:
355
356
357 ;
358 ; At this stage the LVM-info sector has been loaded at [LVMSector].
359 ; From here we look for an LVM entry for the partition.
360 ; If one is found, based on it's LBA-start, it's driveletter is used
361 ; in case byte 25h in the BPB is zero.
362 ;
363
364
365 ; Search for the partition in the LVM info.
366 ; If found, CY is set and SI points to LVM entry.
367 push si
368 mov ax,cx
369 mov dx,bx ; DL DESTROYED
370 mov si,offset [LVMSector]
371 call LVM_SearchForPartition
372
373IF 0
374 pushf
375 pusha
376 mov ax, 0000h
377 rcl al, 1
378 call VideoIO_PrintHexWord
379 mov ax, si
380 call VideoIO_PrintHexWord
381 popa
382 popf
383ENDIF
384
385IFDEF AUX_DEBUG
386 IF 0
387 DBG_TEXT_OUT_AUX 'LVM_GetDriveLetter:'
388 PUSHRF
389 call DEBUG_DumpRegisters
390 call AuxIO_DumpParagraph
391 call AuxIO_TeletypeNL
392 POPRF
393 ENDIF
394ENDIF
395
396 mov bx,si ; BX now points to LVM entry
397 mov dx,0
398 pop si
399
400 mov al,0 ; Setup null driveletter
401 ; Oops, no valid LVM record was used so we have a null driveletter.
402 jnc LVM_GetDriveLetter_null_lvm_dl
403
404 ;
405 ; At this point BX points to the LVM-entry related to the
406 ; partition, whether it was a logical or a primary one.
407 ;
408 mov al,[bx+LocLVM_VolumeLetter]
409 ; Test for zero dtive-letter.
410 test al,al
411 ; Preset CY in case drive-letter is zero.
412 clc
413 jz LVM_GetDriveLetter_null_lvm_dl
414
415 ; We have a non-zero drive-letter, so set CY.
416 stc
417
418 LVM_GetDriveLetter_null_lvm_dl:
419 ret
420LVM_GetDriveLetter EndP
421
422
423
424; Sets a drive-letter in the LVM-info of a partition. (if it exists)
425; In: BX:CX - LBA starting sector of partition to be searched
426; DL = Physical Disk in BIOS notation. (80h+)
427; AL = DriveLetter to set (can be zero to hide partition from LVM)
428; Out: CY=1 if LVM-info found, 0 if no LVM-info.
429LVM_SetDriveLetter Proc Near Uses bx cx dx si di ds es
430
431 local disk:byte
432 local drive_letter:byte
433 local pri_ind:byte
434 local lvm_log_high:word
435 local lvm_log_low:word
436 ; For primary partitions this information is stored in the last
437 ; sector of track0; for all four partition entries in case they
438 ; they are all primary ones.
439 ;
440 ; LVM DLAT info for logical partitions is stored in the sector
441 ; preceding the start of the partition.
442 ;
443 ; Because the LVM info of a logical partition is the easiest to find,
444 ; we do that first. The LVM info for primary partitions is located
445 ; dependent on the geometry in use, so we use a special locater
446 ; call for that. Also, since the LVM info for primaries contains
447 ; info on all 4 entries, we need the partition index to obtain the
448 ; correct drive-letter.
449 ;
450
451IFDEF AUX_DEBUG
452 IF 0
453 DBG_TEXT_OUT_AUX 'LVM_SetDriveLetter:'
454 PUSHRF
455 ;~ call DEBUG_DumpRegisters
456 ;~ call AuxIO_DumpParagraph
457 ;~ call AuxIO_TeletypeNL
458 POPRF
459 ENDIF
460ENDIF
461
462 mov [disk], dl
463
464 ; Store the drive-letter for later use
465 mov [drive_letter], al
466
467
468 ; See if this is a primary partition
469 ; CY will be set if it is and AL will contain the 0-based
470 ; index in the P-table.
471 ; If it's a logical partition, CY will be clear and AL
472 ; will be set to 0ffh indicating an invalid index.
473 call PART_IsPrimaryPartition
474 mov al,0
475 rcl al,1 ; CY if primary
476 mov dh,al ; Save PRI or LOG
477 mov [pri_ind],al
478
479 ; Save PRI/LOG indicator for later use
480 push dx
481
482 ; Load *possible* LVM sector
483 ; This load is only valid if the partition is logical, in which case
484 ; the LVM sector is below the start of the partition.
485 ; If primary, the LVM sector is at a location that
486 ; DriveIO_LoadMasterLVMSector will find out.
487
488 ; Push LBA address
489 push bx
490 push cx
491
492 ; Adjust for logical LVM-sector
493 sub cx,1
494 sbb bx,0
495
496 ; Store LBA address of LVM-sector
497 mov [lvm_log_low],cx
498 mov [lvm_log_high],bx
499
500 ; Load the LVM sector
501 push si
502 push di
503 mov si,offset [LVMSector]
504 mov di,ds
505 mov ax, cx ; LBA low is now in AX
506 call DriveIO_ReadSectorLBA
507 pop di
508 pop si
509
510 ; Restore LBA address
511 pop cx
512 pop bx
513
514 ; Restore PRI/LOG partition indicator in DH
515 pop dx
516
517 ; Test PRI or not
518 test dh,dh
519 ; It's not a PRI so we can use the previously loaded LVM sector
520 jz LVM_SetDriveLetter_is_not_pri
521
522 ;
523 ; It's a PRI so we use the special locator function.
524 ; This locator takes care of extended OS/2 geometry should that be used
525 ;
526 call DriveIO_LoadMasterLVMSector
527 jnc LVM_SetDriveLetter_null_lvm_dl
528
529 mov ax, word ptr [MasterLVMLBA] ; ARRAY VAN MAKEN !
530 mov [lvm_log_low], ax
531 mov [lvm_log_high], 0
532
533 LVM_SetDriveLetter_is_not_pri:
534
535 ;
536 ; At this stage the LVM-info sector has been loaded at [LVMSector].
537 ; From here we look for an LVM entry for the partition.
538 ; If one is found, based on it's LBA-start, it's driveletter is used
539 ; in case byte 25h in the BPB is zero.
540 ;
541
542 ; Search for the partition in the LVM info.
543 ; If found, CY is set and SI points to LVM entry.
544 push si
545 mov ax,cx
546 mov dx,bx
547 mov si,offset [LVMSector]
548 call LVM_SearchForPartition
549 mov bx,si ; BX now points to LVM entry
550 pop si
551
552 mov al,0 ; Setup null driveletter
553 ; Oops, no valid LVM record was used so we have a null driveletter.
554 jnc LVM_SetDriveLetter_null_lvm_dl
555
556 ;
557 ; At this point BX points to the LVM-entry related to the
558 ; partition, whether it was a logical or a primary one.
559 ;
560 mov al, [drive_letter]
561 mov [bx+LocLVM_VolumeLetter],al
562
563 mov si, offset [LVMSector]
564 call LVM_UpdateSectorCRC
565
566 mov dl, [disk]
567 mov bx, [lvm_log_high]
568 mov ax, [lvm_log_low]
569
570 call DriveIO_SaveSector
571
572 LVM_SetDriveLetter_null_lvm_dl:
573 ret
574LVM_SetDriveLetter EndP
575
576
577
578; Removes a given drive-letter from the whole LVM information sector
579; In: CH - drive-letter (ascii)
580; DS:SI - LVM-Information-Sector
581; Out: LVM-Information-Sector updated (including LVM CRC)
582; Destroyed: None
583LVM_RemoveVolLetterFromSector Proc Near Uses cx
584
585IFDEF AUX_DEBUG
586 IF 0
587 DBG_TEXT_OUT_AUX 'LVM_RemoveVolLetterFromSector:'
588 PUSHRF
589 ;~ call DEBUG_DumpRegisters
590 ;~ call AuxIO_DumpParagraph
591 ;~ call AuxIO_TeletypeNL
592 POPRF
593 ENDIF
594ENDIF
595
596 cmp bptr [si+LocLVM_SignatureStart], LocLVM_SignatureByte0
597 jne LVMRVLFS_Done ; Quick Check, if LVM sector there
598 push si
599 add si, LocLVM_StartOfEntries
600 mov cl, LocLVM_MaxEntries
601 LVMRVLFS_Loop:
602 cmp ch, [si+LocLVM_VolumeLetter]
603 jne LVMRVLFS_NextEntry
604 ; Reset drive-letter, if matched
605 mov bptr [si+LocLVM_VolumeLetter], 0 ; ASSIGN NEXT FREE HERE... (DOET DUBBEL ALS ZELFDE DL ALS SYS)
606 LVMRVLFS_NextEntry:
607 add si, LocLVM_LenOfEntry
608 dec cl
609 jnz LVMRVLFS_Loop
610 pop si
611 call LVM_UpdateSectorCRC
612 LVMRVLFS_Done:
613 ret
614LVM_RemoveVolLetterFromSector EndP
615
616; Reassigns LVM volume driveletter
617; Will remove the drive-letter from any volume that got it currently
618; and finally change the drive-letter of the given partition
619; In: AL - drive-letter
620; DS:SI - points to partition, that needs that driveletter
621; Out: None
622; Destroyed: AX
623
624LVM_DoLetterReassignment Proc Near Uses bx cx dx si di
625
626IFDEF AUX_DEBUG
627 IF 0
628 DBG_TEXT_OUT_AUX 'LVM_DoLetterReassignment:'
629 PUSHRF
630 ;~ call DEBUG_DumpRegisters
631 ;~ call AuxIO_DumpParagraph
632 ;~ call AuxIO_TeletypeNL
633 POPRF
634 ENDIF
635ENDIF
636
637 mov di, si ; Save SI in DI (Partition-pointer)
638 mov ch, al ; and AL in CH (drive-letter)
639 xor bx, bx
640 mov cl, CFG_Partitions
641 or cl, cl
642 jz LVMDLR_SkipRemove
643
644 LVMDLR_RemoveLoop:
645 cmp bptr [PartitionVolumeLetters+bx], ch
646 jne LVMDLR_NextPartition
647 ; One volume that has our wanted drive-letter, so remove it!
648 mov dl, bl
649 call PART_GetPartitionPointer ; DL - partition -> SI
650 ; Now set CurPartition_Location for the DriveIO-functions to work
651 mov ax, wptr [si+LocIPT_AbsolutePartTable]
652 mov wptr [CurPartition_Location+0], ax
653 mov ax, wptr [si+LocIPT_AbsolutePartTable+2]
654 mov wptr [CurPartition_Location+2], ax
655 mov ax, wptr [si+LocIPT_LocationPartTable+1]
656 mov wptr [CurPartition_Location+6], ax
657 mov ah, bptr [si+LocIPT_LocationPartTable+0]
658 mov al, [si+LocIPT_Drive]
659 mov wptr [CurPartition_Location+4], ax
660 call DriveIO_LoadLVMSector ; SI points now to LVM-Sector
661 call LVM_RemoveVolLetterFromSector
662
663 call DriveIO_SaveLVMSector ; Save sector
664
665 LVMDLR_NextPartition:
666 inc bx
667 dec cl
668 jnz LVMDLR_RemoveLoop
669
670 LVMDLR_SkipRemove:
671 ; Set CurPartition_Location information of destination partition
672 mov ax, wptr [di+LocIPT_AbsolutePartTable]
673 mov wptr [CurPartition_Location+0], ax
674 mov ax, wptr [di+LocIPT_AbsolutePartTable+2]
675 mov wptr [CurPartition_Location+2], ax
676 mov ah, bptr [di+LocIPT_LocationPartTable+0]
677 mov al, [di+LocIPT_Drive]
678 mov wptr [CurPartition_Location+4], ax
679 mov ax, wptr [di+LocIPT_LocationPartTable+1]
680 mov wptr [CurPartition_Location+6], ax
681 call DriveIO_LoadLVMSector ; SI points now to LVM-Sector
682 mov ax, wptr [di+LocIPT_AbsoluteBegin]
683 mov dx, wptr [di+LocIPT_AbsoluteBegin+2]
684 mov di, si ; Save SI in DI
685 call LVM_SearchForPartition
686 jnc LVMDLR_DestPartNotFound
687 ; Set new volume letter
688 mov bptr [si+LocLVM_VolumeLetter], ch
689 mov si, di ; SI - LVM Sector again
690 call LVM_UpdateSectorCRC ; Update LVM-CRC now
691
692 call DriveIO_SaveLVMSector ; Save sector
693
694 LVMDLR_DestPartNotFound:
695 ; This here is done for safety, because we misuse CurPartition_Location
696 xor ax, ax
697 mov di, offset CurPartition_Location
698 mov cx, 4
699 rep stosw ; NUL out CurPartition_Location
700 ret
701LVM_DoLetterReassignment EndP
702
703
704; This walks the IPT and for each partition it obtains the LVM drive-letter
705; if available. This drive-letter is then marked as in-use in the Map.
706; The FreeDriveletterMap is used by the drive-letter reassignment function
707; to assign a new drive to a data-partition when a system-partition is booted
708; with the same drive-letter. The original drive-letter for the data-partition
709; is saved so it can be restored later when a system is booted that does not
710; use the drive-letter. Note that there can be multiple system-partitions
711; using the same drive-letter and data-partitions can become system-partition
712; by making them bootable. (and vice versa)
713LVM_ComposeFreeDriveletterMap Proc
714
715; get nr of partitions in IPT
716; for each partition get LVM drive-letter and reset bit in map.
717
718LVM_ComposeFreeDriveletterMap EndP
719
Note: See TracBrowser for help on using the repository browser.