source: trunk/BOOTCODE/SPECIAL/LVM.ASM@ 30

Last change on this file since 30 was 30, checked in by Ben Rietbroek, 14 years ago

AiR-BOOT v1.07 -- As released with eCS v2.1. [2011-05-06]
Signature-date: 2006-03-13. (incorrect)
Trunk contains buildable v1.07 version as distributed with eCS v2.1.
Directory 'tags' contains v1.06 & v1.07 reference versions
built for all languages. Note that language ID for 'Dutch' changed
from 'DT' to 'NL' in v1.07 and that the v1.06 reference version also
uses 'NL' for 'Dutch'.
Also note that helper programs like the installer and setaboot are
are only modified for the OS/2 versions in v1.07.
The signature-date for v1.07 incorrectly states the same
date as for v1.06. The signature-version is correct.
Removed other binaries. (cd-rom images, old releases, etc.)
The tags serve as reference versions:

  • v1.06: rebuilt from source. (tags/v1.06r)
  • v1.07: built as released with eCS v2.1. (tags/v1.07r)
File size: 9.7 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 ModuleNames
23DB 'LVM',0
24ENDIF
25
26LVM_InitCRCTable Proc Near Uses
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
35 xor dx, dx ; DX:AX - CRC-Value
36 mov ch, 8
37 LVM_ICRCT_Loop2:
38 shr dx, 1
39 rcr ax, 1 ; Shift value 1 to the right
40 jnc LVM_ICRCT_NoXOR
41 xor dx, 0EDB8h
42 xor ax, 8320h
43 LVM_ICRCT_NoXOR:
44 dec ch
45 jnz LVM_ICRCT_Loop2
46 mov wptr [di+0], ax
47 mov wptr [di+2], dx
48 add di, 4
49 add cl, 1
50 jnc LVM_ICRCT_Loop
51 ret
52LVM_InitCRCTable EndP
53
54; Calculates an LVM-Sector CRC of a given sector
55; In: DS:SI - Points to Sector...
56; Out: DX:AX - LVM CRC
57; Destroyed: None
58LVM_GetSectorCRC Proc Near Uses bx cx
59 push wptr [si+LocLVM_CRC]
60 push wptr [si+LocLVM_CRC+2]
61 push si
62 mov wptr [si+LocLVM_CRC], 0
63 mov wptr [si+LocLVM_CRC+2], 0
64 mov ax, -1
65 mov dx, -1
66 mov cx, 512
67 LVM_GSCRC_Loop:
68 xor bh, bh
69 mov bl, al ; Save last byte to BL
70 mov al, ah
71 mov ah, dl
72 mov dl, dh
73 xor dh, dh ; SHR DX:AX, 8
74 xor bl, [si]
75 inc si ; XOR last byte with [data]
76 shl bx, 1
77 shl bx, 1
78 xor ax, wptr [LVM_CRCTable+bx+0]
79 xor dx, wptr [LVM_CRCTable+bx+2] ; XOR with CRC-Table
80 loop LVM_GSCRC_Loop
81 pop si
82 pop wptr [si+LocLVM_CRC+2]
83 pop wptr [si+LocLVM_CRC]
84 ret
85LVM_GetSectorCRC EndP
86
87; Checks DS:[SI], if a valid LVM Signature is found (sets carry in that case)
88; This does not check for valid LVM CRC (which also needs to be done)
89; In: DS:SI - Sector that needs to get checked...
90; Out: Carry set, if valid LVM signature found
91; Destroyed: None
92LVM_CheckSectorSignature Proc Near Uses
93 test [CFG_IgnoreLVM], 1 ; We are supposed to ignore LVM, so
94 jnz LVMCSS_InvalidSignature ; any sector is bad!
95 cmp wptr [si+LocLVM_SignatureStart], 5202h ; Rousseau: identify LVM sector
96 jne LVMCSS_InvalidSignature
97 cmp wptr [si+LocLVM_SignatureStart+2], 'BM'
98 jne LVMCSS_InvalidSignature
99 cmp wptr [si+LocLVM_SignatureStart+4], 'MP'
100 jne LVMCSS_InvalidSignature
101 cmp wptr [si+LocLVM_SignatureStart+6], 'DF'
102 jne LVMCSS_InvalidSignature
103 stc
104 ret
105 LVMCSS_InvalidSignature:
106 clc
107 ret
108LVM_CheckSectorSignature EndP
109
110; Checks Sector for a valid LVM CRC is encountered
111; First one should check for a valid signature and call this later.
112; In: DS:SI - Sector that needs to get checked...
113; Out: Carry set, if LVM CRC valid
114; Destroyed: None
115LVM_CheckSectorCRC Proc Near Uses ax dx
116 call LVM_GetSectorCRC
117 cmp ax, wptr [si+LocLVM_CRC]
118 jne LVMCSCRC_BadCRC
119 cmp dx, wptr [si+LocLVM_CRC+2]
120 jne LVMCSCRC_BadCRC
121 stc
122 ret
123 LVMCSCRC_BadCRC:
124 clc
125 ret
126LVM_CheckSectorCRC EndP
127
128; Updates Sector with valid LVM CRC
129; This one doesn't check, if it's really an LVM sector, so check before!
130; In: DS:SI - Sector that needs to get checked...
131; Out: None, CRC updated
132; Destroyed: None
133LVM_UpdateSectorCRC Proc Near Uses ax dx
134 call LVM_GetSectorCRC
135 mov wptr [si+LocLVM_CRC], ax
136 mov wptr [si+LocLVM_CRC+2], dx
137 ret
138LVM_UpdateSectorCRC EndP
139
140; Searches for a partition in LVM Information Sector and sets SI to point to
141; the LVM-entry. It will also set CARRY then.
142; In: DX:AX - LBA starting sector of partition to be searched
143; DS:SI - Valid (previously checked) LVM-Information-Sector
144; Out: Carry set, if partition found
145; DS:SI - points to LVM information entry
146; Destroyed: None
147LVM_SearchForPartition Proc Near Uses cx
148 cmp bptr [si+LocLVM_SignatureStart], LocLVM_SignatureByte0
149 jne LVMSFP_NotFound ; Quick Check, if LVM sector there
150 add si, LocLVM_StartOfEntries
151 mov cl, LocLVM_MaxEntries
152 LVMSFP_Loop:
153 cmp ax, [si+LocLVM_PartitionStart]
154 jne LVMSFP_NextEntry
155 cmp dx, [si+LocLVM_PartitionStart+2]
156 je LVMSFP_FoundIt
157 LVMSFP_NextEntry:
158 add si, LocLVM_LenOfEntry
159 dec cl
160 jnz LVMSFP_Loop
161 LVMSFP_NotFound:
162 clc
163 ret
164 LVMSFP_FoundIt:
165 stc
166 ret
167LVM_SearchForPartition EndP
168
169; Removes a given drive-letter from the whole LVM information sector
170; In: CH - drive-letter (ascii)
171; DS:SI - LVM-Information-Sector
172; Out: LVM-Information-Sector updated (including LVM CRC)
173; Destroyed: None
174LVM_RemoveVolLetterFromSector Proc Near Uses cx
175 cmp bptr [si+LocLVM_SignatureStart], LocLVM_SignatureByte0
176 jne LVMRVLFS_Done ; Quick Check, if LVM sector there
177 push si
178 add si, LocLVM_StartOfEntries
179 mov cl, LocLVM_MaxEntries
180 LVMRVLFS_Loop:
181 cmp ch, [si+LocLVM_VolumeLetter]
182 jne LVMRVLFS_NextEntry
183 ; Reset drive-letter, if matched
184 mov bptr [si+LocLVM_VolumeLetter], 0
185 LVMRVLFS_NextEntry:
186 add si, LocLVM_LenOfEntry
187 dec cl
188 jnz LVMRVLFS_Loop
189 pop si
190 call LVM_UpdateSectorCRC
191 LVMRVLFS_Done:
192 ret
193LVM_RemoveVolLetterFromSector EndP
194
195; Reassigns LVM volume driveletter
196; Will remove the drive-letter from any volume that got it currently
197; and finally change the drive-letter of the given partition
198; In: AL - drive-letter
199; DS:SI - points to partition, that needs that driveletter
200; Out: None
201; Destroyed: AX
202LVM_DoLetterReassignment Proc Near Uses bx cx dx si di
203 mov di, si ; Save SI in DI (Partition-pointer)
204 mov ch, al ; and AL in CH (drive-letter)
205 xor bx, bx
206 mov cl, CFG_Partitions
207 or cl, cl
208 jz LVMDLR_SkipRemove
209 LVMDLR_RemoveLoop:
210 cmp bptr [PartitionVolumeLetters+bx], ch
211 jne LVMDLR_NextPartition
212 ; One volume that has our wanted drive-letter, so remove it!
213 mov dl, bl
214 call PART_GetPartitionPointer ; DL - partition -> SI
215 ; Now set CurPartition_Location for the DriveIO-functions to work
216 mov ax, wptr [si+LocIPT_AbsolutePartTable]
217 mov wptr [CurPartition_Location+0], ax
218 mov ax, wptr [si+LocIPT_AbsolutePartTable+2]
219 mov wptr [CurPartition_Location+2], ax
220 mov ax, wptr [si+LocIPT_LocationPartTable+1]
221 mov wptr [CurPartition_Location+6], ax
222 mov ah, bptr [si+LocIPT_LocationPartTable+0]
223 mov al, [si+LocIPT_Drive]
224 mov wptr [CurPartition_Location+4], ax
225 call DriveIO_LoadLVMSector ; SI points now to LVM-Sector
226 call LVM_RemoveVolLetterFromSector
227 IFDEF ReleaseCode
228 call DriveIO_SaveLVMSector ; Save sector
229 ENDIF
230 LVMDLR_NextPartition:
231 inc bx
232 dec cl
233 jnz LVMDLR_RemoveLoop
234 LVMDLR_SkipRemove:
235 ; Set CurPartition_Location information of destination partition
236 mov ax, wptr [di+LocIPT_AbsolutePartTable]
237 mov wptr [CurPartition_Location+0], ax
238 mov ax, wptr [di+LocIPT_AbsolutePartTable+2]
239 mov wptr [CurPartition_Location+2], ax
240 mov ah, bptr [di+LocIPT_LocationPartTable+0]
241 mov al, [di+LocIPT_Drive]
242 mov wptr [CurPartition_Location+4], ax
243 mov ax, wptr [di+LocIPT_LocationPartTable+1]
244 mov wptr [CurPartition_Location+6], ax
245 call DriveIO_LoadLVMSector ; SI points now to LVM-Sector
246 mov ax, wptr [di+LocIPT_AbsoluteBegin]
247 mov dx, wptr [di+LocIPT_AbsoluteBegin+2]
248 mov di, si ; Save SI in DI
249 call LVM_SearchForPartition
250 jnc LVMDLR_DestPartNotFound
251 ; Set new volume letter
252 mov bptr [si+LocLVM_VolumeLetter], ch
253 mov si, di ; SI - LVM Sector again
254 call LVM_UpdateSectorCRC ; Update LVM-CRC now
255 IFDEF ReleaseCode
256 call DriveIO_SaveLVMSector ; Save sector
257 ENDIF
258 LVMDLR_DestPartNotFound:
259 ; This here is done for safety, because we misuse CurPartition_Location
260 xor ax, ax
261 mov di, offset CurPartition_Location
262 mov cx, 4
263 rep stosw ; NUL out CurPartition_Location
264 ret
265LVM_DoLetterReassignment EndP
Note: See TracBrowser for help on using the repository browser.