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

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

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