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