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 / PARTiTiON SCANNING
|
---|
20 | ;---------------------------------------------------------------------------
|
---|
21 |
|
---|
22 |
|
---|
23 | IFDEF MODULE_NAMES
|
---|
24 | DB 'PARTSCAN',0
|
---|
25 | ENDIF
|
---|
26 |
|
---|
27 | ; Note: This is complex code. So make sure that you know what you are doing in
|
---|
28 | ; here.
|
---|
29 |
|
---|
30 | PARTSCAN_ScanForPartitions Proc Near
|
---|
31 |
|
---|
32 | IFDEF AUX_DEBUG
|
---|
33 | IF 0
|
---|
34 | DBG_TEXT_OUT_AUX 'PARTSCAN_ScanForPartitions:'
|
---|
35 | PUSHRF
|
---|
36 | ;~ call DEBUG_DumpRegisters
|
---|
37 | ;~ call AuxIO_DumpParagraph
|
---|
38 | ;~ call AuxIO_TeletypeNL
|
---|
39 | POPRF
|
---|
40 | ENDIF
|
---|
41 | ENDIF
|
---|
42 |
|
---|
43 | ; Reset X-Reference
|
---|
44 | call PARTSCAN_ResetXref
|
---|
45 |
|
---|
46 | mov dh, [TotalHarddiscs]
|
---|
47 | xor al, al
|
---|
48 | mov [NewPartitions], al
|
---|
49 |
|
---|
50 | mov byte ptr [CurIO_Scanning], 1 ; Set flag due scanning partitions
|
---|
51 | mov dl, 80h ; is first harddisc
|
---|
52 | PSSFP_HarddiscLoop:
|
---|
53 |
|
---|
54 | push dx
|
---|
55 |
|
---|
56 | ; ================================================ [ Locate Master LVM Sector ]
|
---|
57 |
|
---|
58 | ; Locate the Master LVM sector for this disk.
|
---|
59 | ; If one is found, BX:AX will hold its LBA address, otherwise zero.
|
---|
60 | ; Note that if LVM is set to be ignored in the SETUP, checking for a
|
---|
61 | ; signature will not be done and thus no Master LVM sector will be
|
---|
62 | ; found.
|
---|
63 | call DriveIO_LocateMasterLVMSector
|
---|
64 |
|
---|
65 | ; Put the LBA address in the BSS location for this disk
|
---|
66 | xor bh, bh ; Zero upper part of index
|
---|
67 | mov bl, dl ; Get BIOS drive-number
|
---|
68 | and bl, 7fh ; Strip bit 7
|
---|
69 | shl bx, 3 ; Mult by 4 for DWORD
|
---|
70 | add bx, offset [LVM_MasterSecs] ; Add the base offset
|
---|
71 | mov [bx+00h], ax ; Store LBA low
|
---|
72 | xor ax, ax ; LBA high always zero
|
---|
73 | mov [bx+02h], ax ; Store LBA high
|
---|
74 |
|
---|
75 | ;!
|
---|
76 | ;! DEBUG_BLOCK
|
---|
77 | ;! Check stored Master LVM LBA address.
|
---|
78 | ;!
|
---|
79 | IFDEF AUX_DEBUG
|
---|
80 | IF 0
|
---|
81 | DBG_TEXT_OUT_AUX '[Master LVM Sector]'
|
---|
82 | PUSHRF
|
---|
83 | xor bh, bh
|
---|
84 | mov bl, dl
|
---|
85 | and bl, 7fh
|
---|
86 | shl bx, 3
|
---|
87 | add bx, offset [LVM_MasterSecs]
|
---|
88 | mov al, [bx]
|
---|
89 | mov ah, dl
|
---|
90 | call DEBUG_DumpRegisters
|
---|
91 | POPRF
|
---|
92 | ENDIF
|
---|
93 | ENDIF
|
---|
94 |
|
---|
95 | ; ========================================================= [ Scan Partitions ]
|
---|
96 |
|
---|
97 | call PARTSCAN_ScanDriveForPartitions
|
---|
98 | pop dx
|
---|
99 | inc dl
|
---|
100 | dec dh
|
---|
101 | jnz PSSFP_HarddiscLoop
|
---|
102 | mov byte ptr [CurIO_Scanning], 0 ; Reset flag due scanning complete
|
---|
103 |
|
---|
104 | IFDEF AUX_DEBUG
|
---|
105 | IF 0
|
---|
106 | pushf
|
---|
107 | pusha
|
---|
108 | call DEBUG_DumpHidePartTables
|
---|
109 | popa
|
---|
110 | popf
|
---|
111 | ENDIF
|
---|
112 | ENDIF
|
---|
113 |
|
---|
114 | ; Use X-Reference to sync NewPartitionTable with Hide-Config
|
---|
115 | call PARTSCAN_SyncHideConfigWithXref
|
---|
116 |
|
---|
117 | IFDEF AUX_DEBUG
|
---|
118 | IF 0
|
---|
119 | pushf
|
---|
120 | pusha
|
---|
121 | call DEBUG_DumpHidePartTables
|
---|
122 | popa
|
---|
123 | popf
|
---|
124 | ENDIF
|
---|
125 | ENDIF
|
---|
126 |
|
---|
127 | ; Now we copy the new IPT over the old one...
|
---|
128 | mov si, offset NewPartTable
|
---|
129 | mov di, offset PartitionTable
|
---|
130 | ;movzx ax, NewPartitions
|
---|
131 | mov al,NewPartitions
|
---|
132 | mov ah,0
|
---|
133 |
|
---|
134 | mov CFG_Partitions, al
|
---|
135 | mov bl, LocIPT_LenOfIPT
|
---|
136 | mul bl
|
---|
137 | mov cx, ax
|
---|
138 | rep movsb
|
---|
139 |
|
---|
140 | ; and the New Logical Drive Letter table as well...
|
---|
141 | mov si, offset NewDriveLetters
|
---|
142 | mov di, offset DriveLetters
|
---|
143 | mov cx, LocIPT_MaxPartitions
|
---|
144 | rep movsb
|
---|
145 |
|
---|
146 | ; ...and finally check, if we need to set a Drive-Letter
|
---|
147 | mov dl, AutoDrvLetter
|
---|
148 | or dl, dl
|
---|
149 | jz PSSFP_NoAutoDriveLetter
|
---|
150 | ;movzx cx, CFG_Partitions
|
---|
151 | mov cl,CFG_Partitions
|
---|
152 | mov ch,0
|
---|
153 |
|
---|
154 | or cx, cx
|
---|
155 | jz PSSFP_NoAutoDriveLetter
|
---|
156 | mov si, offset PartitionTable
|
---|
157 | mov di, offset DriveLetters
|
---|
158 | mov ax, wptr [AutoDrvLetterSerial]
|
---|
159 | mov bx, wptr [AutoDrvLetterSerial+2]
|
---|
160 | PSSFP_AutoDrvLetterLoop:
|
---|
161 | cmp ax, [si+LocIPT_Serial]
|
---|
162 | jne PSSFP_AutoDrvLetterNoMatch
|
---|
163 | cmp bx, [si+LocIPT_Serial+2]
|
---|
164 | jne PSSFP_AutoDrvLetterNoMatch
|
---|
165 | ; We got a match, so set Drive-Letter in DL
|
---|
166 | or bptr [si+LocIPT_Flags], Flags_DriveLetter
|
---|
167 | mov [di], dl
|
---|
168 | PSSFP_AutoDrvLetterNoMatch:
|
---|
169 | add si, LocIPT_LenOfIPT
|
---|
170 | inc di
|
---|
171 | loop PSSFP_AutoDrvLetterLoop
|
---|
172 | mov byte ptr [AutoDrvLetter], 0 ; Disable after processing...
|
---|
173 | PSSFP_NoAutoDriveLetter:
|
---|
174 | ret
|
---|
175 | PARTSCAN_ScanForPartitions EndP
|
---|
176 |
|
---|
177 |
|
---|
178 |
|
---|
179 | ;
|
---|
180 | ; This function reconnects a forced drive-letter with it's partition
|
---|
181 | ; when partitions are removed.
|
---|
182 | ;
|
---|
183 | PARTSCAN_UpdateDriveLetters Proc
|
---|
184 |
|
---|
185 | IFDEF AUX_DEBUG
|
---|
186 | IF 0
|
---|
187 | DBG_TEXT_OUT_AUX 'PARTSCAN_UpdateDriveLetters:'
|
---|
188 | PUSHRF
|
---|
189 | ;~ call DEBUG_DumpRegisters
|
---|
190 | ;~ call AuxIO_DumpParagraph
|
---|
191 | ;~ call AuxIO_TeletypeNL
|
---|
192 | POPRF
|
---|
193 | ENDIF
|
---|
194 | ENDIF
|
---|
195 |
|
---|
196 | pusha
|
---|
197 | xor bx,bx ; index-pointer
|
---|
198 | xor cx,cx ; counter
|
---|
199 | xor dx,dx ; backup index-pointer
|
---|
200 | mov cl,LocIPT_MaxPartitions ; nr of entries to process
|
---|
201 | mov si,offset [PartitionXref] ; old-new relation table
|
---|
202 | mov di,offset [DriveLetters] ; forced drive-letters table
|
---|
203 |
|
---|
204 | ;
|
---|
205 | ; Loop over each entry in the xref-table to see if the partition
|
---|
206 | ; has been removed or has been given a new index in the IPT.
|
---|
207 | ; A removed partition has 0ffh in it's slot and for a partition
|
---|
208 | ; that has a new index in the IPT the value at the slot is different
|
---|
209 | ; from the index of the slot in the xref-table.
|
---|
210 | ;
|
---|
211 | PARTSCAN_UpdateDriveLetters_next_entry:
|
---|
212 | jcxz PARTSCAN_UpdateDriveLetters_done
|
---|
213 | dec cl ; decrement counter
|
---|
214 | mov al,[si+bx] ; get possibly old index for this entry
|
---|
215 | mov dl,bl ; save current index
|
---|
216 | inc bl ; advance index-pointer
|
---|
217 | inc al ; 0ffh will become 0, part removed so continue
|
---|
218 | jz PARTSCAN_UpdateDriveLetters_next_entry
|
---|
219 |
|
---|
220 | ;
|
---|
221 | ; If value in slot is the same as the index of the slot then
|
---|
222 | ; the partition has not moved in the IPT.
|
---|
223 | ;
|
---|
224 | dec al ; restore possibly out-of-date index
|
---|
225 | cmp al,dl ; same as array index? then ok, do next
|
---|
226 | je PARTSCAN_UpdateDriveLetters_next_entry
|
---|
227 |
|
---|
228 | ;!
|
---|
229 | ;! DEBUG_PROBE
|
---|
230 | ;!
|
---|
231 | IFDEF AUX_DEBUGx
|
---|
232 | push 1234h
|
---|
233 | call DEBUG_Probe
|
---|
234 | ENDIF
|
---|
235 |
|
---|
236 | ;
|
---|
237 | ; The partition has moved in the IPT so we lookup it's forced
|
---|
238 | ; drive-letter at the old location and put it at the new one.
|
---|
239 | ; The old location is identified by the index in the xref-table
|
---|
240 | ; and the new location is identified by the value at that index.
|
---|
241 | ; Thus, when no partitions have been deleted or added, the xref-table
|
---|
242 | ; contains the sequence 0,1,2,3,...,n,0ffh,0ffh, etc.
|
---|
243 | ; The value 0ffh means that no partition is using the slot.
|
---|
244 | ;
|
---|
245 | xor ah,ah ; no drive-letter
|
---|
246 | dec bl ; backup index-pointer one position
|
---|
247 | xchg ah,[di+bx] ; get drive-letter and store zero
|
---|
248 | xchg bl,al ; use slot value as new index
|
---|
249 | mov [di+bx],ah ; store drive-letter
|
---|
250 | xchg al,bl ; restore index-pointer
|
---|
251 | inc bl ; point to next entry
|
---|
252 | jmp PARTSCAN_UpdateDriveLetters_next_entry
|
---|
253 | PARTSCAN_UpdateDriveLetters_done:
|
---|
254 | popa
|
---|
255 | ret
|
---|
256 | PARTSCAN_UpdateDriveLetters EndP
|
---|
257 |
|
---|
258 |
|
---|
259 |
|
---|
260 |
|
---|
261 | ; Scannt die Festplatte auf jegliche Partitionstabellen...
|
---|
262 | ; Falls eine fehlerhafte Partition gefunden wird, wird abgebrochen.
|
---|
263 | ; falls eine Extended Partition (DOS) gefunden wird, wird erneut gescannt.
|
---|
264 | PARTSCAN_ScanDriveForPartitions Proc Near
|
---|
265 |
|
---|
266 | IFDEF AUX_DEBUG
|
---|
267 | IF 0
|
---|
268 | DBG_TEXT_OUT_AUX 'PARTSCAN_ScanDriveForPartitions:'
|
---|
269 | PUSHRF
|
---|
270 | ;~ call DEBUG_DumpRegisters
|
---|
271 | ;~ call AuxIO_DumpParagraph
|
---|
272 | ;~ call AuxIO_TeletypeNL
|
---|
273 | POPRF
|
---|
274 | ENDIF
|
---|
275 | ENDIF
|
---|
276 |
|
---|
277 | xor ax, ax
|
---|
278 | xor bx, bx ; Location Absoluter Sektor 0
|
---|
279 | mov cx, 0001h
|
---|
280 | xor dh, dh ; Location Zylinder 0, Side 0, Sektor 1 MBR
|
---|
281 | mov [ExtendedAbsPosSet], al
|
---|
282 | mov wptr [ExtendedAbsPos+0], ax
|
---|
283 | mov wptr [ExtendedAbsPos+2], ax
|
---|
284 | PSSDFP_LoadThisPartition:
|
---|
285 |
|
---|
286 | call DriveIO_LoadPartition ; Load a partition record
|
---|
287 |
|
---|
288 | jc PSSDFP_InvalidPartition
|
---|
289 |
|
---|
290 | ; LVM Support - Reads LVM Information Sector
|
---|
291 | call DriveIO_LoadLVMSector ; Load LVM sector
|
---|
292 |
|
---|
293 | call PARTSCAN_ScanPartition
|
---|
294 |
|
---|
295 | call DriveIO_SavePartition
|
---|
296 |
|
---|
297 | call PARTSCAN_ScanPartitionForExtended
|
---|
298 | jc PSSDFP_LoadThisPartition
|
---|
299 |
|
---|
300 | PSSDFP_InvalidPartition:
|
---|
301 | ret
|
---|
302 | PARTSCAN_ScanDriveForPartitions EndP
|
---|
303 |
|
---|
304 | ; Scans Current Partition for Extended Partitions, if found, AX,BX,CX,DX will
|
---|
305 | ; be set to this location and Carry will be set
|
---|
306 | PARTSCAN_ScanPartitionForExtended Proc Near Uses si
|
---|
307 |
|
---|
308 | IFDEF AUX_DEBUG
|
---|
309 | IF 0
|
---|
310 | DBG_TEXT_OUT_AUX 'PARTSCAN_ScanPartitionForExtended:'
|
---|
311 | PUSHRF
|
---|
312 | ;~ call DEBUG_DumpRegisters
|
---|
313 | ;~ call AuxIO_DumpParagraph
|
---|
314 | ;~ call AuxIO_TeletypeNL
|
---|
315 | POPRF
|
---|
316 | ENDIF
|
---|
317 | ENDIF
|
---|
318 |
|
---|
319 | mov si, offset PartitionSector+446 ; DS:SI - 1st partition entry
|
---|
320 | xor ax, ax
|
---|
321 | PSSPFE_ScanLoop:
|
---|
322 | mov al, [si+LocBRPT_SystemID]
|
---|
323 | cmp al, 5 ; Is Partition EXTENDED ?
|
---|
324 | je PSSPFE_ExtendedPartition
|
---|
325 | cmp al, 0Fh ; Is Partition EXTENDED (M$) ?
|
---|
326 | je PSSPFE_ExtendedPartition
|
---|
327 | jmp PSSPFE_IgnorePartition
|
---|
328 | PSSPFE_ExtendedPartition:
|
---|
329 | mov ax, wptr [si+LocBRPT_RelativeBegin]
|
---|
330 | mov bx, wptr [si+LocBRPT_RelativeBegin+2]
|
---|
331 | add ax, wptr [ExtendedAbsPos+0] ; Adjust...
|
---|
332 | adc bx, wptr [ExtendedAbsPos+2] ; (Shit Design!)
|
---|
333 | test byte ptr [ExtendedAbsPosSet], 1
|
---|
334 | jnz PSSPFE_ExtendedMainKnown
|
---|
335 | mov wptr [ExtendedAbsPos+0], ax
|
---|
336 | mov wptr [ExtendedAbsPos+2], bx
|
---|
337 | mov byte ptr [ExtendedAbsPosSet], 1
|
---|
338 | PSSPFE_ExtendedMainKnown:
|
---|
339 | mov cx, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
|
---|
340 | mov dh, bptr [si+LocBRPT_BeginHead] ; Head
|
---|
341 | mov dl, bptr [CurPartition_Location+4] ; Drive
|
---|
342 | stc
|
---|
343 | jmp PSSPFE_EndOfSearch
|
---|
344 | PSSPFE_IgnorePartition:
|
---|
345 | add si, LocBRPT_LenOfEntry
|
---|
346 | cmp si, 500+offset PartitionSector
|
---|
347 | jb PSSPFE_ScanLoop
|
---|
348 | clc
|
---|
349 | PSSPFE_EndOfSearch:
|
---|
350 | ret
|
---|
351 | PARTSCAN_ScanPartitionForExtended EndP
|
---|
352 |
|
---|
353 | ; The following routines have NOT *DS* set to CS, so we must address via ES
|
---|
354 | PARTSCAN_ScanPartition Proc Near Uses ax si
|
---|
355 |
|
---|
356 | IFDEF AUX_DEBUG
|
---|
357 | IF 0
|
---|
358 | DBG_TEXT_OUT_AUX 'PARTSCAN_ScanPartition:'
|
---|
359 | PUSHRF
|
---|
360 | ;~ call DEBUG_DumpRegisters
|
---|
361 | ;~ call AuxIO_DumpParagraph
|
---|
362 | ;~ call AuxIO_TeletypeNL
|
---|
363 | POPRF
|
---|
364 | ENDIF
|
---|
365 | ENDIF
|
---|
366 |
|
---|
367 |
|
---|
368 | mov si, offset [PartitionSector+446] ; DS:SI - 1st Partition-Entry
|
---|
369 | PSSP_ScanLoop:
|
---|
370 | mov al, bptr [si+LocBRPT_SystemID]
|
---|
371 | cmp al, 5 ; Is Partition EXTENDED ?
|
---|
372 | je PSSP_IgnorePartition
|
---|
373 | cmp al, 0Fh ; Is Partition EXTENDED (M$-DOS7) ?
|
---|
374 | je PSSP_IgnorePartition
|
---|
375 | cmp al, 0 ; Is Partition EMPTY ?
|
---|
376 | je PSSP_IgnorePartition
|
---|
377 | ; Ignore these partitions, because there are no real Partitions
|
---|
378 |
|
---|
379 | ;
|
---|
380 | ; Stop scanning if too many partitions.
|
---|
381 | ;
|
---|
382 | cmp word ptr cs:[NewPartitions],LocIPT_MaxPartitions
|
---|
383 | jae skip_check
|
---|
384 | call PARTSCAN_CheckThisPartition
|
---|
385 | jmp PSSP_IgnorePartition
|
---|
386 | skip_check:
|
---|
387 | ; Cannot boot LVM-Data partitions
|
---|
388 | pusha
|
---|
389 | mov byte ptr cs:[TooManyPartitions],1
|
---|
390 | mov cx, 0C04h
|
---|
391 | ;~ mov si, offset TXT_ERROR_TooManyPartitions
|
---|
392 | mov si, offset TXT_TooManyPartitions
|
---|
393 | add si,5 ; We stole this string, so skip new-line and dash.
|
---|
394 | ;~ call SETUP_Warning_AreYouSure
|
---|
395 | call SETUP_ShowErrorBox
|
---|
396 | popa
|
---|
397 |
|
---|
398 | PSSP_IgnorePartition:
|
---|
399 | ; Only clear the boot-flag on the boot-disk.
|
---|
400 | ; Clearing the boot-flags on other disks would prevent booting them
|
---|
401 | ; from the BIOS. (TRAC ticket #6)
|
---|
402 | cmp dl, [BIOS_BootDisk] ; See if this is boot-disk
|
---|
403 | jne PSSP_Skip_Clear_BootFlag ; Nope, skip clear flag
|
---|
404 | and byte ptr [si+LocBRPT_Flags], 7Fh ; Reset the Active-Flag
|
---|
405 | PSSP_Skip_Clear_BootFlag:
|
---|
406 | add si, LocBRPT_LenOfEntry ; 16 Bytes per partition entry
|
---|
407 | cmp si, 500+offset PartitionSector
|
---|
408 | jb PSSP_ScanLoop
|
---|
409 | ; If we are on first HDD and in primary partition table -> mark primary
|
---|
410 | mov al, [BIOS_BootDisk]
|
---|
411 | cmp bptr [CurPartition_Location+4], al ; Drive
|
---|
412 | jne PSSP_NoMarkPrimary
|
---|
413 | cmp wptr [CurPartition_Location+0], 0
|
---|
414 | jne PSSP_NoMarkPrimary
|
---|
415 | cmp wptr [CurPartition_Location+2], 0 ; Absolute Location
|
---|
416 | jne PSSP_NoMarkPrimary
|
---|
417 | call PART_MarkFirstGoodPrimary
|
---|
418 | PSSP_NoMarkPrimary:
|
---|
419 | ret
|
---|
420 | PARTSCAN_ScanPartition EndP
|
---|
421 |
|
---|
422 | MBR_NoName_Patched db 15 dup (0)
|
---|
423 |
|
---|
424 | ; Will insert this partition into NewPartTable and compare it to our "old"
|
---|
425 | ; LocIPT-table. If the same partition is found there, Flags&CRC are taken from
|
---|
426 | ; the old table, otherwise they are generated freshly.
|
---|
427 | ; Will also fill out PartitionXref to sync HideConfig later
|
---|
428 | ; In: SI - Points to Partition-Entry (16-Bytes)
|
---|
429 | PARTSCAN_CheckThisPartition Proc Near Uses di si
|
---|
430 |
|
---|
431 | local PartSystemID:byte, PartTypeFlags:byte
|
---|
432 | local PartCRC:word, PartPtr:word
|
---|
433 |
|
---|
434 | IFDEF AUX_DEBUG
|
---|
435 | IF 1
|
---|
436 | DBG_TEXT_OUT_AUX 'PARTSCAN_CheckThisPartition:'
|
---|
437 | PUSHRF
|
---|
438 | call DEBUG_DumpRegisters
|
---|
439 | ;~ call AuxIO_DumpParagraph
|
---|
440 | ;~ call AuxIO_TeletypeNL
|
---|
441 | POPRF
|
---|
442 | ENDIF
|
---|
443 | ENDIF
|
---|
444 |
|
---|
445 |
|
---|
446 | mov wptr [PartPtr], si ; Save Pointer to PartitionEntry
|
---|
447 |
|
---|
448 | mov al, bptr [si+LocBRPT_SystemID]
|
---|
449 | mov PartSystemID, al
|
---|
450 |
|
---|
451 | mov cx, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
|
---|
452 | mov dh, bptr [si+LocBRPT_BeginHead] ; Head
|
---|
453 | mov dl, bptr [CurPartition_Location+4] ; Drive
|
---|
454 | mov ax, wptr [si+LocBRPT_RelativeBegin] ; Absolute Sector
|
---|
455 | mov bx, wptr [si+LocBRPT_RelativeBegin+2]
|
---|
456 |
|
---|
457 |
|
---|
458 |
|
---|
459 |
|
---|
460 | add ax, wptr [CurPartition_Location+0] ; +Partition-Absolute
|
---|
461 | adc bx, wptr [CurPartition_Location+2] ; sectors
|
---|
462 |
|
---|
463 |
|
---|
464 | ; Sets up DS:SI - TmpSector
|
---|
465 | call DriveIO_LoadTmpSector ; Loads Boot record
|
---|
466 |
|
---|
467 |
|
---|
468 |
|
---|
469 | push si
|
---|
470 | mov bx, 4B4Dh ; Magic 'MK' :)
|
---|
471 | call MBR_GetCheckOfSector
|
---|
472 | mov PartCRC, bx ; Save Partition's-CRC
|
---|
473 |
|
---|
474 | ; ------------------------------ Gets internal infos of partition type
|
---|
475 | mov al, PartSystemID
|
---|
476 | call PART_SearchFileSysName
|
---|
477 | ; Replies AH - FileSysFlags, AL - UnhiddenID, SI - FileSystemNamePtr
|
---|
478 | mov di, si
|
---|
479 | mov PartTypeFlags, ah
|
---|
480 | mov PartSystemID, al ; Use Unhidden-ID
|
---|
481 | pop si
|
---|
482 |
|
---|
483 | ;================================
|
---|
484 | ; AL - File System ID (Unhidden)
|
---|
485 | ; AH - File System Flags
|
---|
486 | ; SI - Boot-Record of Partition
|
---|
487 | ; DI - File System Name
|
---|
488 | ;================================
|
---|
489 |
|
---|
490 | cmp PartSystemID, 07h ; We got IFS here?
|
---|
491 | jne PCCTP_IFSdone
|
---|
492 | ; Check, if 'JFS ' is at DWORD offset 36h ; Rousseau: JFS check (LVM / IPT?)
|
---|
493 | cmp wptr [si+36h], 'FJ'
|
---|
494 | jne PCCTP_IFSnoJFS
|
---|
495 | cmp wptr [si+38h], ' S'
|
---|
496 | jne PCCTP_IFSnoJFS
|
---|
497 | mov PartSystemID, 0FCh ; FC is JFS internally
|
---|
498 | jmp PCCTP_IFSdone
|
---|
499 | PCCTP_IFSnoJFS:
|
---|
500 | ; Check, if 'HPFS' is at DWORD offset 36h
|
---|
501 | cmp wptr [si+36h], 'PH'
|
---|
502 | jne PCCTP_ProbablyNTFS
|
---|
503 | cmp wptr [si+38h], 'SF'
|
---|
504 | je PCCTP_IFSdone ; 07 is HPFS internally
|
---|
505 | PCCTP_ProbablyNTFS:
|
---|
506 | inc PartSystemID ; 08 is NTFS instead of 07
|
---|
507 | PCCTP_IFSdone:
|
---|
508 |
|
---|
509 |
|
---|
510 | ; First check, if LVM Information Sector is available and this partition
|
---|
511 | ; is supported.
|
---|
512 | push ax
|
---|
513 | push dx
|
---|
514 | push si
|
---|
515 | push di
|
---|
516 | mov si, wptr [PartPtr]
|
---|
517 | mov ax, wptr [si+LocBRPT_RelativeBegin] ; Absolute Sector
|
---|
518 | mov dx, wptr [si+LocBRPT_RelativeBegin+2]
|
---|
519 | add ax, wptr [CurPartition_Location+0] ; +Partition-Absolute
|
---|
520 | adc dx, wptr [CurPartition_Location+2] ; sectors
|
---|
521 |
|
---|
522 | mov si, offset [LVMSector]
|
---|
523 |
|
---|
524 | IFDEF AUX_DEBUG
|
---|
525 | IF 0
|
---|
526 | DBG_TEXT_OUT_AUX 'LVMSector'
|
---|
527 | PUSHRF
|
---|
528 | call DEBUG_DumpRegisters
|
---|
529 | call AuxIO_DumpSector
|
---|
530 | ;~ call AuxIO_DumpParagraph
|
---|
531 | ;~ call AuxIO_TeletypeNL
|
---|
532 | POPRF
|
---|
533 | ENDIF
|
---|
534 | ENDIF
|
---|
535 |
|
---|
536 | call LVM_SearchForPartition ; Search for DX:AX partition
|
---|
537 |
|
---|
538 | jnc PCCTP_CheckBootRecord
|
---|
539 | ; Check, if volume has driveletter assigned and remember it for later
|
---|
540 | mov al, [si+LocLVM_VolumeLetter]
|
---|
541 | or al, al
|
---|
542 | jnz PCCTP_HasVolumeLetter
|
---|
543 | mov al, 1 ; 0 would mean "not LVM supported"
|
---|
544 | PCCTP_HasVolumeLetter:
|
---|
545 | ; Save VolumeLetter in separate table
|
---|
546 | ;movzx bx, NewPartitions ; NewPartitions is one behind here, so
|
---|
547 | mov bl,NewPartitions ; NewPartitions is one behind here, so
|
---|
548 | mov bh,0
|
---|
549 |
|
---|
550 | mov [PartitionVolumeLetters+bx], al ; it's already a zero-based offset
|
---|
551 | ; Now copy VolumeID and VolumeName to temporary space
|
---|
552 | mov di, offset MBR_NoName_Patched
|
---|
553 | mov ax, [si+LocLVM_PartitionID]
|
---|
554 | stosw
|
---|
555 | mov ax, [si+LocLVM_PartitionID+2]
|
---|
556 | stosw
|
---|
557 | ; Set Serial-Field to LVM-VolumeID
|
---|
558 |
|
---|
559 | push di
|
---|
560 | add si, LocLVM_VolumeName ; Use LVM VolumeName
|
---|
561 | ;add si, LocLVM_PartitionName ; Use LVM PartitionName
|
---|
562 | mov cx, 5
|
---|
563 | rep movsw ; Copy LVM-PartitionName to Temp Space
|
---|
564 | movsb ; (11 bytes in total)
|
---|
565 | pop di
|
---|
566 |
|
---|
567 |
|
---|
568 |
|
---|
569 | IFDEF AUX_DEBUG
|
---|
570 | IF 0
|
---|
571 | DBG_TEXT_OUT_AUX 'LVMSector-2'
|
---|
572 | PUSHRF
|
---|
573 | mov si, di
|
---|
574 | call AuxIO_Print
|
---|
575 | ;~ call DEBUG_DumpRegisters
|
---|
576 | ;~ call AuxIO_DumpSector
|
---|
577 | ;~ call AuxIO_DumpParagraph
|
---|
578 | ;~ call AuxIO_TeletypeNL
|
---|
579 | POPRF
|
---|
580 | ENDIF
|
---|
581 | ENDIF
|
---|
582 |
|
---|
583 |
|
---|
584 | ; Check if this is an IBM-BM partition
|
---|
585 | cmp PartSystemID, 0ah
|
---|
586 | jne PCCTP_NoIbmBm
|
---|
587 |
|
---|
588 | ; It is, so override the name given by IBM-BM by one that
|
---|
589 | ; fits in 11 chars.
|
---|
590 | mov si, offset ibm_bm_name
|
---|
591 | mov cx,5
|
---|
592 | rep movsw
|
---|
593 | movsb
|
---|
594 |
|
---|
595 |
|
---|
596 |
|
---|
597 | PCCTP_NoIbmBm:
|
---|
598 | pop di
|
---|
599 | pop si
|
---|
600 | pop dx
|
---|
601 | pop ax
|
---|
602 | mov si, offset MBR_NoName_Patched
|
---|
603 | xor ah, ah ; no Flags_NoPartName
|
---|
604 | jmp PCCTP_NameSearchInIPT
|
---|
605 |
|
---|
606 | PCCTP_CheckBootRecord:
|
---|
607 | pop di
|
---|
608 | pop si
|
---|
609 | pop dx
|
---|
610 | pop ax
|
---|
611 |
|
---|
612 | test ah, FileSysFlags_NoName ; No-Name-Flag ? -> No Partition Name
|
---|
613 |
|
---|
614 | jz PCCTP_ThereIsAName
|
---|
615 | jmp PCCTP_ThereIsNoName ; available
|
---|
616 |
|
---|
617 | PCCTP_ThereIsAName:
|
---|
618 |
|
---|
619 | ; We check for NTFS (got detected a little bit earlier in this routine)
|
---|
620 | cmp PartSystemID, 08h ; We got IFS/NTFS here?
|
---|
621 | jne PCCTP_IsNoNTFS
|
---|
622 | jmp PCCTP_ThereIsNoName ; NTFS has no volume label
|
---|
623 | PCCTP_IsNoNTFS:
|
---|
624 | add si, 2Bh ; DS:SI - Partition-Name
|
---|
625 | test ah, FileSysFlags_FAT32 ; FAT32 specific name getting ?
|
---|
626 |
|
---|
627 | jz PCCTP_ResumeNormal
|
---|
628 |
|
---|
629 | add si, 1Ch ; Fix for FAT 32, shiat
|
---|
630 | PCCTP_ResumeNormal:
|
---|
631 | mov cx, 11 ; 11 bytes length
|
---|
632 | call PART_CheckForValidPartName
|
---|
633 | jc PCCTP_ThereIsAName2
|
---|
634 |
|
---|
635 | jmp PCCTP_ThereIsNoName
|
---|
636 |
|
---|
637 | PCCTP_ThereIsAName2:
|
---|
638 |
|
---|
639 | sub si, 4 ; DS:SI -> Serial&Name (15-Bytes)
|
---|
640 | xor ah, ah ; no Flags_NoPartName
|
---|
641 | ; jmp PCCTP_NameSearchInIPT
|
---|
642 |
|
---|
643 | ;=======================================================
|
---|
644 | ; NAME SEARCH in IPT-Table
|
---|
645 | ; DS:SI - Serial&Name of Current Partition (15-Bytes)
|
---|
646 | ; AH - NoPartName-Flag (!MUST! be merged with Flags)
|
---|
647 | ;=======================================================
|
---|
648 | PCCTP_NameSearchInIPT:
|
---|
649 | xor ah, ah ; no Flags_NoPartName cause PartName valid
|
---|
650 | mov di, offset PartitionTable ; ES:DI - IPT-Start
|
---|
651 | mov dl, CFG_Partitions
|
---|
652 | or dl, dl
|
---|
653 | jnz PCCTP_SerialNameCompLoop
|
---|
654 | jmp PCCTP_CompareFailed
|
---|
655 | PCCTP_SerialNameCompLoop:
|
---|
656 | mov al, [di+LocIPT_Flags]
|
---|
657 | test al, Flags_NowFound
|
---|
658 | jnz PCCTP_SerialNameAlreadyFound
|
---|
659 | ; Now compare IPT with current Partition
|
---|
660 | mov cx, 15 ; Serial&Name (15-Bytes)
|
---|
661 | push si
|
---|
662 | push di
|
---|
663 | repz cmpsb
|
---|
664 | pop di
|
---|
665 | pop si
|
---|
666 |
|
---|
667 | jne PCCTP_NoMatchYet
|
---|
668 |
|
---|
669 | jmp PCCTP_Match
|
---|
670 |
|
---|
671 | PCCTP_NoMatchYet:
|
---|
672 |
|
---|
673 | PCCTP_SerialNameAlreadyFound:
|
---|
674 | add di, LocIPT_LenOfIPT
|
---|
675 | dec dl
|
---|
676 | jnz PCCTP_SerialNameCompLoop
|
---|
677 |
|
---|
678 | ; if we didn't find Serial&Name, let's try Name-only without Serial
|
---|
679 | mov di, offset PartitionTable ; ES:DI - IPT-Start
|
---|
680 | mov dl, CFG_Partitions
|
---|
681 | PCCTP_NameCompLoop:
|
---|
682 | mov al, [di+LocIPT_Flags]
|
---|
683 | test al, Flags_NowFound
|
---|
684 | jnz PCCTP_NameAlreadyFound
|
---|
685 | ; Now compare IPT with current Partition
|
---|
686 | mov cx, 11 ; Name only (11-Bytes)
|
---|
687 | push si
|
---|
688 | push di
|
---|
689 | add si, 4
|
---|
690 | add di, 4 ; Skip over Serial-Field
|
---|
691 | repz cmpsb
|
---|
692 | pop di
|
---|
693 | pop si
|
---|
694 | jne PCCTP_NameNoMatch
|
---|
695 | mov cx, [si+0] ; Get Serial
|
---|
696 | mov [di+0], cx
|
---|
697 | mov cx, [si+2]
|
---|
698 | mov [di+2], cx ; ...and put it into IPT
|
---|
699 | jmp PCCTP_Match
|
---|
700 | PCCTP_NameNoMatch:
|
---|
701 | PCCTP_NameAlreadyFound:
|
---|
702 | add di, LocIPT_LenOfIPT
|
---|
703 | dec dl
|
---|
704 | jnz PCCTP_NameCompLoop
|
---|
705 | PCCTP_NameCompFailed:
|
---|
706 |
|
---|
707 | ; So finally we search for Location and PartitionID
|
---|
708 | push si
|
---|
709 | ; Initialize some stuff for Location-Search
|
---|
710 | mov dh, PartSystemID
|
---|
711 | mov si, [PartPtr] ; DS:SI - Cur Partition Table
|
---|
712 | ; Relative Sector to MBR/EPR
|
---|
713 | mov cx, wptr [si+LocBRPT_RelativeBegin]
|
---|
714 | mov bx, wptr [si+LocBRPT_RelativeBegin+2]
|
---|
715 | add cx, [CurPartition_Location+0]
|
---|
716 | add bx, [CurPartition_Location+2]
|
---|
717 | ; BX:CX - Absolute First Sector of Partition on HDD
|
---|
718 | pop si
|
---|
719 | mov di, offset PartitionTable ; ES:DI - IPT-Start
|
---|
720 | mov dl, CFG_Partitions
|
---|
721 | PCCTP_NameLocCompLoop:
|
---|
722 | mov al, [di+LocIPT_Flags]
|
---|
723 | test al, Flags_NowFound
|
---|
724 | jnz PCCTP_NameLocAlreadyFound
|
---|
725 | ; Now compare IPT with current Partition
|
---|
726 | cmp dh, [di+LocIPT_SystemID]
|
---|
727 | jne PCCTP_NameLocMismatch
|
---|
728 | cmp cx, [di+LocIPT_AbsoluteBegin]
|
---|
729 | jne PCCTP_NameLocMismatch
|
---|
730 | cmp bx, [di+LocIPT_AbsoluteBegin+2]
|
---|
731 | jne PCCTP_NameLocMismatch
|
---|
732 | ; We matched location, now copy the current PartitionID and Name to
|
---|
733 | ; the old IPT.
|
---|
734 | push di
|
---|
735 | add di, LocIPT_Serial ; DS:SI - LocIPT-Serial&Name
|
---|
736 | mov cx, 15
|
---|
737 | rep movsb ; Copy 15 bytes
|
---|
738 | pop di
|
---|
739 | jmp PCCTP_Match
|
---|
740 | PCCTP_NameLocMismatch:
|
---|
741 | PCCTP_NameLocAlreadyFound:
|
---|
742 | add di, LocIPT_LenOfIPT
|
---|
743 | dec dl
|
---|
744 | jnz PCCTP_NameLocCompLoop
|
---|
745 | ; None of the searches worked, so forget it...
|
---|
746 | jmp PCCTP_CompareFailed
|
---|
747 |
|
---|
748 | PCCTP_ThereIsNoName:
|
---|
749 | ; Try to find this partition by comparing location and PartitionID
|
---|
750 | ; aka LocIPT_AbsoluteBegin:dword and LocIPT_SystemID
|
---|
751 | ; If found, simply go to the normal match-routine, otherwise use the
|
---|
752 | ; File-System-Name to build the Volume-Label for the New IPT Entry.
|
---|
753 | mov dh, PartSystemID
|
---|
754 | mov si, [PartPtr] ; DS:SI - Cur Partition Table
|
---|
755 | ; Relative Sector to MBR/EPR
|
---|
756 | mov cx, wptr [si+LocBRPT_RelativeBegin]
|
---|
757 | mov bx, wptr [si+LocBRPT_RelativeBegin+2]
|
---|
758 | add cx, [CurPartition_Location+0]
|
---|
759 | add bx, [CurPartition_Location+2]
|
---|
760 | ; Build a standard-Volume Label from FileSystemNamePtr
|
---|
761 | ; We have to call SearchFileSysName again because of NTFS
|
---|
762 | push ax
|
---|
763 | push cx
|
---|
764 | mov al, dh
|
---|
765 | call PART_SearchFileSysName ; We want SI here <- FileSystemNamePtr
|
---|
766 | mov di, offset MBR_NoName_Patched
|
---|
767 | xor ax, ax
|
---|
768 | stosw
|
---|
769 | stosw ; Set Serial-Field to "NUL"
|
---|
770 | mov cx, 4
|
---|
771 | rep movsw ; Copy FileSystemName to Temp Space
|
---|
772 | xor ax, ax
|
---|
773 | stosw
|
---|
774 | stosb ; Fill last 3 bytes with "NUL"
|
---|
775 | mov si, offset MBR_NoName_Patched
|
---|
776 | pop cx
|
---|
777 | pop ax
|
---|
778 | ;=======================================================
|
---|
779 | ; LOCATION SEARCH in IPT-Table
|
---|
780 | ; DH - PartitionID of Current Partition
|
---|
781 | ; BX:CX - AbsoluteBegin of Current Partition
|
---|
782 | ; AH - NoPartName-Flag (!MUST! be merged with Flags)
|
---|
783 | ; DS:SI - Serial&Name of Current Partition (15-Bytes)
|
---|
784 | ;=======================================================
|
---|
785 | PCCTP_LocSearchInIPT:
|
---|
786 | mov ah, Flags_NoPartName ;set Flags_NoPartName, PartName invalid
|
---|
787 | mov di, offset PartitionTable ; ES:DI - IPT-Start
|
---|
788 | mov dl, CFG_Partitions
|
---|
789 | or dl, dl
|
---|
790 | jz PCCTP_LocCompFailed
|
---|
791 | PCCTP_LocCompLoop:
|
---|
792 | mov al, [di+LocIPT_Flags]
|
---|
793 | test al, Flags_NowFound
|
---|
794 | jnz PCCTP_LocAlreadyFound
|
---|
795 | ; Now compare IPT with current Partition
|
---|
796 | cmp dh, [di+LocIPT_SystemID]
|
---|
797 | jne PCCTP_LocMismatch
|
---|
798 | cmp cx, [di+LocIPT_AbsoluteBegin]
|
---|
799 | jne PCCTP_LocMismatch
|
---|
800 | cmp bx, [di+LocIPT_AbsoluteBegin+2]
|
---|
801 | jne PCCTP_LocMismatch
|
---|
802 | jmp PCCTP_Match
|
---|
803 | PCCTP_LocMismatch:
|
---|
804 | PCCTP_LocAlreadyFound:
|
---|
805 | add di, LocIPT_LenOfIPT
|
---|
806 | dec dl
|
---|
807 | jnz PCCTP_LocCompLoop
|
---|
808 | PCCTP_LocCompFailed:
|
---|
809 | jmp PCCTP_CompareFailed
|
---|
810 |
|
---|
811 | ; ==================================
|
---|
812 | ; =MATCH=, found partition in IPT...
|
---|
813 | ; AH - NoPartName-Flag (!MUST! be merged with Flags)
|
---|
814 | ; DL - IPT Partition Number from Loop (inverted)
|
---|
815 | ; ES:DI - LocIPT-Pointer to found IPT-entry
|
---|
816 | ; ==================================
|
---|
817 | PCCTP_Match:
|
---|
818 | mov ch, ah
|
---|
819 | ; Save the new location of this partition in the Xref-Table
|
---|
820 | ; for converting HideConfig.
|
---|
821 | mov dh, dl
|
---|
822 | mov dl, CFG_Partitions
|
---|
823 | sub dl, dh
|
---|
824 | mov dh, NewPartitions ; is actually a counter
|
---|
825 | call PARTSCAN_DefXref ; DL-IPT-Partition, DH-NewPartition
|
---|
826 |
|
---|
827 | ; Get Saved-Flags...
|
---|
828 | mov cl, bptr [di+LocIPT_Flags] ; Use saved Flags
|
---|
829 |
|
---|
830 | ; ...and Saved-CRC if available...
|
---|
831 | mov ax, wptr [di+LocIPT_BootRecordCRC]
|
---|
832 | or ax, ax
|
---|
833 | jz PCCTP_UseNewComputedCRC
|
---|
834 | mov PartCRC, ax ; Use saved IPT-CRC
|
---|
835 | PCCTP_UseNewComputedCRC:
|
---|
836 | ; ...and mark partition in IPT as already found
|
---|
837 | or bptr [di+LocIPT_Flags], Flags_NowFound
|
---|
838 | ; ...get Serial&Name from IPT-table...
|
---|
839 | mov si, di
|
---|
840 | add si, LocIPT_Serial ; DS:SI - LocIPT-Serial&Name
|
---|
841 | jmp PCCTP_AddToNew
|
---|
842 |
|
---|
843 | ; =================================
|
---|
844 | ; =FAILED= search, not found in IPT
|
---|
845 | ; AH - NoPartName-Flag (!MUST! be merged with Flags)
|
---|
846 | ; DS:SI - Serial&Name of Current Partition (15-Bytes)
|
---|
847 | ; =================================
|
---|
848 | PCCTP_CompareFailed:
|
---|
849 | mov ch, ah
|
---|
850 | ; Insert Default Flags...
|
---|
851 | mov cl, LocIPT_DefaultFlags
|
---|
852 |
|
---|
853 | mov al, PartTypeFlags
|
---|
854 | ; May I auto-add partitions ?
|
---|
855 | test byte ptr [CFG_PartitionsDetect], 1
|
---|
856 | jz PCCTP_MayNotAddAny ; add, but non-bootable
|
---|
857 | test al, FileSysFlags_BootAble ; AH kam von SearchFileSysName
|
---|
858 | jnz PCCTP_PerhapsBootAble
|
---|
859 | PCCTP_MayNotAddAny:
|
---|
860 | mov cl, LocIPT_DefaultNonBootFlags
|
---|
861 | PCCTP_PerhapsBootAble:
|
---|
862 |
|
---|
863 | ; On FAT32-partitions, default to P-Flag (which means using M$-hack)
|
---|
864 | ; Anyway, this hack has to be globaly activated by the user manually...
|
---|
865 | cmp PartSystemID, 09h ; Hardcoded: FAT32
|
---|
866 | je PCCTP_NeedsExtMShack
|
---|
867 | cmp PartSystemID, 0Bh
|
---|
868 | je PCCTP_NeedsExtMShack
|
---|
869 | cmp PartSystemID, 0Ch
|
---|
870 | je PCCTP_NeedsExtMShack
|
---|
871 | cmp PartSystemID, 0Eh ; FAT16 above 8 GB
|
---|
872 | jne PCCTP_NoExtMShack
|
---|
873 | ; We only get here, when the SystemID seems to be an M$ "invention"...
|
---|
874 | PCCTP_NeedsExtMShack:
|
---|
875 | or cl, Flags_ExtPartMShack
|
---|
876 | PCCTP_NoExtMShack:
|
---|
877 |
|
---|
878 | ;================================================
|
---|
879 | ; CL - IPT-Partition-Flags, CH - NoPartName-Flag
|
---|
880 | ; DS:SI - PartSerial&Name (15-Bytes)
|
---|
881 | ;================================================
|
---|
882 | PCCTP_AddToNew:
|
---|
883 | mov al, Flags_NoPartName ; Unset NoPartName
|
---|
884 | not al
|
---|
885 | and cl, al
|
---|
886 | or cl, ch ; CL = Both CL and CH merged
|
---|
887 |
|
---|
888 | ; Calculate Pointer to IPT
|
---|
889 | mov di, offset NewPartTable ; ES:DI - NewPartTable
|
---|
890 | ;movzx ax, NewPartitions
|
---|
891 | mov al,NewPartitions
|
---|
892 | mov ah,0
|
---|
893 |
|
---|
894 | mov bl, LocIPT_LenOfIPT
|
---|
895 | mul bl
|
---|
896 | add di, ax ; ES:DI - Last+1 Entry of NewPartTable
|
---|
897 |
|
---|
898 | ; Now finally write this partition to our IPT
|
---|
899 | ;=============================================
|
---|
900 | push cx
|
---|
901 | mov cx, 15 ; Copy Serial&Name...
|
---|
902 | rep movsb
|
---|
903 | pop cx
|
---|
904 |
|
---|
905 | mov si, [PartPtr] ; DS:SI - Cur Partition Entry
|
---|
906 | mov al, bptr [CurPartition_Location+4] ; Drive
|
---|
907 | stosb
|
---|
908 | mov al, PartSystemID ; Unhidden SystemID
|
---|
909 | stosb
|
---|
910 | mov al, cl ; Partition-Flags from register...
|
---|
911 | stosb
|
---|
912 | mov ax, PartCRC ; BootRecordCRC...
|
---|
913 | stosw
|
---|
914 | mov al, bptr [si+LocBRPT_BeginHead]
|
---|
915 | stosb
|
---|
916 | mov ax, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
|
---|
917 | stosw
|
---|
918 | mov al, bptr [CurPartition_Location+5] ; Head of Part-Table
|
---|
919 | stosb
|
---|
920 | mov ax, wptr [CurPartition_Location+6] ; Cylinder/Sector
|
---|
921 | stosw
|
---|
922 | mov ax, wptr [si+LocBRPT_RelativeBegin]
|
---|
923 | mov bx, wptr [si+LocBRPT_RelativeBegin+2]
|
---|
924 | mov cx, wptr [CurPartition_Location+0] ; +Partition-Absolute
|
---|
925 | mov dx, wptr [CurPartition_Location+2] ; sectors
|
---|
926 | add ax, cx
|
---|
927 | adc bx, dx
|
---|
928 | stosw
|
---|
929 | mov ax, bx
|
---|
930 | stosw
|
---|
931 | mov ax, cx ; Absolute sector of partition table
|
---|
932 | stosw
|
---|
933 | mov ax, dx
|
---|
934 | stosw
|
---|
935 | inc byte ptr [NewPartitions]; Adjusted for Wasm ; NEW IPT Entry DONE
|
---|
936 |
|
---|
937 | cmp byte ptr [NewPartitions], LocIPT_MaxPartitions
|
---|
938 | jbe PCCTP_NotTooManyPartitions
|
---|
939 |
|
---|
940 | ; Should not be reached since scanning is stopped outside this
|
---|
941 | ; function when partition limit exceeds.
|
---|
942 | mov si, offset TXT_TooManyPartitions
|
---|
943 | call MBR_Teletype
|
---|
944 | jmp MBR_HaltSystem
|
---|
945 |
|
---|
946 |
|
---|
947 | PCCTP_NotTooManyPartitions:
|
---|
948 | ; UNHIDE PARTITION, if it was hidden previously
|
---|
949 | mov al, PartSystemID
|
---|
950 | cmp al, 08h ; internally IFS/NTFS?
|
---|
951 | je PCCTP_GotInternalIFS
|
---|
952 | cmp al, 0FCh ; internally IFS/JFS?
|
---|
953 | jne PCCTP_NoInternalIFS
|
---|
954 | PCCTP_GotInternalIFS:
|
---|
955 | mov al, 07h
|
---|
956 | PCCTP_NoInternalIFS:
|
---|
957 | mov bptr [si+LocBRPT_SystemID], al
|
---|
958 |
|
---|
959 | ; Calculate Size of this partition and put it into separate table...
|
---|
960 | ;movzx ax, NewPartitions
|
---|
961 | mov al,NewPartitions
|
---|
962 | mov ah,0
|
---|
963 |
|
---|
964 | dec ax
|
---|
965 | mov bx, ax
|
---|
966 | shl ax, 1
|
---|
967 | shl bx, 2
|
---|
968 | add ax, bx ; My way [tm] of multiplying with 6
|
---|
969 | mov di, offset PartitionSizeTable
|
---|
970 | add di, ax ; DI - Partition Size-Element
|
---|
971 | mov ax, wptr [si+LocBRPT_AbsoluteLength] ; Sector-Size
|
---|
972 | mov bx, wptr [si+LocBRPT_AbsoluteLength+2]
|
---|
973 | call PART_FillOutSizeElement
|
---|
974 | ret
|
---|
975 | PARTSCAN_CheckThisPartition EndP
|
---|
976 |
|
---|
977 | stop_scanning db 0
|
---|
978 |
|
---|
979 | ; ===================
|
---|
980 | ; X-REFERENCE STUFF -> PartitionXref
|
---|
981 | ; ===================
|
---|
982 |
|
---|
983 | ; Reset X-Reference
|
---|
984 | PARTSCAN_ResetXref Proc Near Uses ax cx di
|
---|
985 | mov di, offset PartitionXref ; X-Reference for later syncing
|
---|
986 | mov cx, LocIPT_MaxPartitions
|
---|
987 | mov ax, 0FFFFh ; Fill up with FFh
|
---|
988 | rep stosb
|
---|
989 | mov di, offset NewHidePartTable ; Temporary Hide-Config Table
|
---|
990 | ;~ mov cx, LocIPT_MaxPartitions * LocIPT_LenOfIPT
|
---|
991 | mov cx, LocIPT_MaxPartitions * LocHPT_LenOfHPT
|
---|
992 | rep stosb ; Fill up with FFFFh
|
---|
993 | mov di, offset NewDriveLetters
|
---|
994 | mov cx, LocIPT_MaxPartitions ; Temporary Logical-Drive Letter Table
|
---|
995 | xor ax, ax
|
---|
996 | rep stosb ; Fill up with 0000h
|
---|
997 | ret
|
---|
998 | PARTSCAN_ResetXref EndP
|
---|
999 |
|
---|
1000 |
|
---|
1001 |
|
---|
1002 | ; In: DL - Partition Number in IPT
|
---|
1003 | ; DH - Partition Number in NewPartitionTable
|
---|
1004 | ; Destroyed: None
|
---|
1005 | PARTSCAN_DefXref Proc Near Uses ax bx cx dx si di
|
---|
1006 | ;movzx bx, dl
|
---|
1007 | mov bl,dl
|
---|
1008 | mov bh,0
|
---|
1009 |
|
---|
1010 | mov bptr [PartitionXref+bx], dh ; X-Reference
|
---|
1011 | ; Copy Hide-Config of IPT partition to new location in new table
|
---|
1012 | mov si, offset HidePartitionTable
|
---|
1013 | mov di, offset NewHidePartTable
|
---|
1014 | ;~ mov bl, LocIPT_MaxPartitions
|
---|
1015 | mov bl, LocHPT_LenOfHPT
|
---|
1016 | mov al, dl
|
---|
1017 | mul bl
|
---|
1018 | add si, ax
|
---|
1019 | mov al, dh
|
---|
1020 | mul bl
|
---|
1021 | add di, ax
|
---|
1022 | ;~ mov cx, LocIPT_MaxPartitions
|
---|
1023 | mov cx, LocHPT_LenOfHPT
|
---|
1024 | rep movsb ; Copy Hide-Config to NewHideTable
|
---|
1025 | ; Process Logical-Drive-Letter table as well...
|
---|
1026 | ;movzx bx, dl
|
---|
1027 | mov bl,dl
|
---|
1028 | mov bh,0
|
---|
1029 |
|
---|
1030 | mov al, bptr [DriveLetters+bx] ; Get Drv-Letter from org. pos
|
---|
1031 | ;movzx bx, dh
|
---|
1032 | mov bl,dl
|
---|
1033 | mov bh,0
|
---|
1034 |
|
---|
1035 | mov bptr [NewDriveLetters+bx], al ; Put Drv-Letter to new pos
|
---|
1036 | ret
|
---|
1037 | PARTSCAN_DefXref EndP
|
---|
1038 |
|
---|
1039 |
|
---|
1040 |
|
---|
1041 | ; In: DL - Partition Number in previous IPT
|
---|
1042 | ; Out: DH - Partition Number in NewPartitionTable
|
---|
1043 | ; Destroyed: None
|
---|
1044 | PARTSCAN_GetXref Proc Near Uses bx
|
---|
1045 | ;movzx bx, dl
|
---|
1046 | mov bl,dl
|
---|
1047 | mov bh,0
|
---|
1048 |
|
---|
1049 | mov dh, bptr [PartitionXref+bx] ; X-Reference
|
---|
1050 | ret
|
---|
1051 | PARTSCAN_GetXref EndP
|
---|
1052 |
|
---|
1053 |
|
---|
1054 | ;
|
---|
1055 | ; Rousseau: Adjusted for packed hidden-part-table !
|
---|
1056 | ; Needs to be re-written.
|
---|
1057 | ;
|
---|
1058 | ; This here updates the contents of the Hide-Configuration to the current IPT
|
---|
1059 | ; table.
|
---|
1060 | PARTSCAN_SyncHideConfigWithXref Proc Near Uses ax bx cx dx si di
|
---|
1061 | mov si, offset NewHidePartTable
|
---|
1062 | mov di, offset HidePartitionTable
|
---|
1063 | mov dh, LocIPT_MaxPartitions ; Max entries in hide-tables.
|
---|
1064 |
|
---|
1065 | PSSHCWX_SyncPartLoop:
|
---|
1066 | mov cl, LocIPT_MaxPartitions ; Max entries per hide-entry.
|
---|
1067 | xor dl, dl ; Partition Lost Counter
|
---|
1068 |
|
---|
1069 | mov ch,0 ; Index.
|
---|
1070 |
|
---|
1071 | PSSHCWX_SyncLoop:
|
---|
1072 | mov bx,si
|
---|
1073 |
|
---|
1074 | ;~ lodsb ; Get Part-Pointer from Hide-Cfg
|
---|
1075 |
|
---|
1076 | push dx
|
---|
1077 | mov dl,ch
|
---|
1078 | mov dh,6
|
---|
1079 | call CONV_GetBitfieldValue
|
---|
1080 | pop dx
|
---|
1081 |
|
---|
1082 | ;~ cmp al, 0FFh
|
---|
1083 | cmp al, 3Fh
|
---|
1084 | je PSSHCWX_SyncEmpty
|
---|
1085 | ;movzx bx, al
|
---|
1086 | mov bl,al
|
---|
1087 | mov bh,0
|
---|
1088 |
|
---|
1089 | mov al, [PartitionXref+bx] ; Translate it
|
---|
1090 | ;~ cmp al, 0FFh
|
---|
1091 | cmp al, 3Fh
|
---|
1092 | je PSSHCWX_PartLost
|
---|
1093 |
|
---|
1094 | PSSHCWX_SyncEmpty:
|
---|
1095 | mov bx,di
|
---|
1096 | ;~ stosb ; Put translated pointer to new table
|
---|
1097 |
|
---|
1098 | push dx
|
---|
1099 | mov dl,ch
|
---|
1100 | mov dh,6
|
---|
1101 | call CONV_SetBitfieldValue
|
---|
1102 | pop dx
|
---|
1103 |
|
---|
1104 | inc ch
|
---|
1105 | dec cl
|
---|
1106 | jnz PSSHCWX_SyncLoop
|
---|
1107 |
|
---|
1108 | jmp PSSHCWX_SyncLoopEnd
|
---|
1109 |
|
---|
1110 | PSSHCWX_PartLost:
|
---|
1111 | inc dl ; One partition got lost...
|
---|
1112 | dec cl
|
---|
1113 | jnz PSSHCWX_SyncLoop
|
---|
1114 |
|
---|
1115 | PSSHCWX_SyncLoopEnd:
|
---|
1116 |
|
---|
1117 |
|
---|
1118 | IFDEF AUX_DEBUG
|
---|
1119 | IF 0
|
---|
1120 | pushf
|
---|
1121 | pusha
|
---|
1122 | mov al,dl
|
---|
1123 | call AuxIO_TeletypeHexByte
|
---|
1124 | call AuxIO_TeletypeNL
|
---|
1125 | popa
|
---|
1126 | popf
|
---|
1127 | ENDIF
|
---|
1128 | ENDIF
|
---|
1129 |
|
---|
1130 |
|
---|
1131 | or dl, dl
|
---|
1132 | jz PSSHCWX_NothingLost
|
---|
1133 | ;~ mov al, 0FFh ; Influences OVERWRITE BUG ! (OUT OF BOUNDS !!)
|
---|
1134 | mov al, 3Fh
|
---|
1135 |
|
---|
1136 | PSSHCWX_LostFillLoop: ; CHECK !!
|
---|
1137 | ;~ stosb
|
---|
1138 | dec cl
|
---|
1139 | jnz PSSHCWX_LostFillLoop
|
---|
1140 |
|
---|
1141 | IFDEF AUX_DEBUG
|
---|
1142 | IF 0
|
---|
1143 | pushf
|
---|
1144 | pusha
|
---|
1145 | mov ax,di
|
---|
1146 | call AuxIO_TeletypeHexWord
|
---|
1147 | call AuxIO_TeletypeNL
|
---|
1148 | popa
|
---|
1149 | popf
|
---|
1150 | ENDIF
|
---|
1151 | ENDIF
|
---|
1152 |
|
---|
1153 | PSSHCWX_NothingLost:
|
---|
1154 | add si, LocHPT_LenOfHPT
|
---|
1155 | add di, LocHPT_LenOfHPT
|
---|
1156 | dec dh
|
---|
1157 | jnz PSSHCWX_SyncPartLoop
|
---|
1158 |
|
---|
1159 | ret
|
---|
1160 | PARTSCAN_SyncHideConfigWithXref EndP
|
---|
1161 |
|
---|
1162 | ibm_bm_name db 'OS2 BootMgr',0
|
---|
1163 | ;win_bm_name: db 'BOOTMGR',0
|
---|