source: trunk/AIR-BOOT/SOURCE/REGULAR/PARTMAIN.ASM@ 16

Last change on this file since 16 was 12, checked in by kiewitz, 23 years ago

AIR-BOOT v1.0.
Signature-date: 2003-01-07.
Added SW language and updated images and installers.
Updated language menus.
Note: This comment was created after rebuilding the repo. [2011-07]

File size: 34.9 KB
Line 
1
2; Disclaimer:
3;=============
4; The sourcecode is released via www.netlabs.org CVS *ONLY*.
5; You MUST NOT upload it to other servers nor republish it in any way.
6; The sourcecode is still COPYRIGHTED and NOT YET RELEASED UNDER GPL.
7; It's (c) Copyright 1998-2002 by Martin Kiewitz.
8; You may recompile the source and do *PRIVATE* modifications, but please keep
9; in mind that modifying this code needs at least *some* assembly skill. If
10; you mess up your system, because you needed to hack your way through, don't
11; blame me. Releasing a customized version of AiR-BOOT, selling it in any form
12; or reusing parts of this source is *PROHIBITED*. Ask me, if you have some
13; idea about new functionality *before* developing the code, otherwise I will
14; definitely reject it. Also please accept, that I have some basic design
15; rules on AiR-BOOT and I will maintain them at all costs, so this won't get
16; another GRUB.
17
18;---------------------------------------------------------------------------
19; AiR-BOOT / PARTiTiON REGULAR ROUTINES
20;---------------------------------------------------------------------------
21
22PART_FixUpDefaultPartitionValues Proc Near Uses dx si di
23 ; Fix-Up Default and Last Partition - If lost, search for Bootable
24 xor bl, bl
25 mov dl, CFG_PartDefault
26 call PART_FixUpPartitionNumber
27 mov CFG_PartDefault, dl
28 mov dl, CFG_PartLast
29 call PART_FixUpPartitionNumber
30 mov CFG_PartLast, dl
31 mov dl, CFG_PartAutomatic
32 call PART_FixUpPartitionNumber
33 mov CFG_PartAutomatic, dl
34
35 ; Fix-Up Linux Kernel Partition - If lost, search for FAT-16
36 mov bl, 06h
37 mov dl, CFG_LinuxKrnlPartition
38 call PART_FixUpPartitionNumber
39 mov CFG_LinuxKrnlPartition, dl
40
41 ; Fix-Up Linux Root Partition - If lost, search for Linux partition (83h)
42 mov bl, 83h
43 mov dl, CFG_LinuxRootPartition
44 call PART_FixUpPartitionNumber
45 mov CFG_LinuxRootPartition, dl
46 ret
47PART_FixUpDefaultPartitionValues EndP
48
49; Our resync process for partition number is as specified:
50;==========================================================
51; - If 0FFh -> Partition Disabled, so don't do anything to it...
52; - Try to use GetXref to get the new partition no via X-Ref Table
53; - If failed, increase partition no, till overflow or hit on specific
54; characteristic
55; On overflow -> Resume search from partition no 0
56;
57; Characteristic is a partition id. If this id is 0, then a bootable partition
58; is searched for.
59
60; Fixes a partition number, adjusting it to the new IPT after redetect
61; In: DL - Number of partition
62; BL - Requested Partition ID
63; Out: DL - New number of partition (guessed normally ;)
64PART_FixUpPartitionNumber Proc Near Uses ax cx
65 cmp dl, 0FFh
66 je PFUPN_PartitionDisabled
67 call PARTSCAN_GetXref ; DL - PartitionNo prev IPT
68 cmp dh, 0FFh ; DH -> Partition No in new IPT
69 je PFUPN_PartitionGone
70 PFUPN_PartitionDisabled:
71 ret
72
73 ; Partition is not referenced in New-IPT, so dig for requested partition
74 PFUPN_PartitionGone:
75 mov cl, CFG_Partitions
76 or cl, cl
77 jz PFUPN_NothingFound ; No partitions available -> so fail
78 or bl, bl
79 jz PFUPN_BootableSearchLoop
80 ; Search for Partition ID "BL"
81 PFUPN_PartIDsearchLoop:
82 call PART_GetPartitionPointer ; Gets SI for partition DL
83 cmp bptr ds:[si+LocIPT_SystemID], bl
84 je PFUPN_Found
85 dec cl
86 jz PFUPN_NothingFound
87 inc dl ; Increase
88 cmp CFG_Partitions, dl
89 ja PFUPN_PartIDsearchLoop
90 xor dl, dl
91 jmp PFUPN_PartIDsearchLoop
92
93 ; Search for Partition ID "BL"
94 PFUPN_BootableSearchLoop:
95 call PART_GetPartitionPointer ; Gets SI for partition DL
96 mov al, cs:[si+LocIPT_Flags]
97 and al, Flags_BootAble
98 jnz PFUPN_Found
99 dec cl
100 jz PFUPN_NothingFound
101 inc dl ; Increase
102 cmp CFG_Partitions, dl
103 ja PFUPN_PartIDsearchLoop
104 xor dl, dl
105 jmp PFUPN_PartIDsearchLoop
106
107 PFUPN_NothingFound:
108 mov dl, 0FFh ; Now being Disabled
109 PFUPN_Found:
110 ret
111PART_FixUpPartitionNumber EndP
112
113; ============================================================================
114; In: CS:SI - IPT-Entry of partition
115; ExecBaseSeg:Ptr - Actual Boot-Record of partition
116; Out: *none* (BootRecordCRD updated)
117PART_UpdateBootRecordCRC Proc Near Uses bx
118 push ds si
119 push ExecBaseSeg
120 pop ds
121 mov si, offset ExecBasePtr
122 mov bx, 4B4Dh ; Magic: 'MK'
123 call MBR_GetCheckOfSector
124 pop si ds
125 mov cs:[si+LocIPT_BootRecordCRC], bx
126 ret
127PART_UpdateBootRecordCRC EndP
128
129; ============================================================================
130; Partition-Pointer Functions
131; ============================================================================
132
133; Builds Pointer-Table straight (without filtering, w/o Floppy/CD-ROM/Kernels)
134PART_CalculateStraightPartPointers Proc Near
135 mov ax, offset PartitionTable
136 mov bx, offset PartitionPointers
137 mov cx, LocIPT_MaxPartitions
138 PCSPP_Loop:
139 mov ds:[bx], ax
140 add bx, 2
141 add ax, LocIPT_LenOfIPT
142 dec cx
143 jnz PCSPP_Loop
144 mov al, ds:[CFG_Partitions]
145 mov ds:[PartitionPointerCount], al
146 ret
147PART_CalculateStraightPartPointers EndP
148
149; This here does PartitionPointers in order for displaying in BootMenu
150; [this means filtering and including Floppy/CD-ROM/Kernels, if wanted]
151PART_CalculateMenuPartPointers Proc Near Uses si
152 mov si, offset PartitionTable
153 mov bx, offset PartitionPointers
154 test CFG_IncludeFloppy, 1
155 jz PCMPP_NoFloppyInclude
156 mov ax, offset FloppyIPTentry
157 mov ds:[bx], ax
158 add bx, 2
159 PCMPP_NoFloppyInclude:
160
161 test CFG_ResumeBIOSbootSeq, 0FFh
162 jz PCMPP_NoResumeBootSeqInclude
163 mov ax, offset BIOScontIPTentry
164 mov ds:[bx], ax
165 add bx, 2
166 PCMPP_NoResumeBootSeqInclude:
167
168 ; Now include all Linux Kernels, if any available...
169 movzx cx, LINUX_KernelNo
170 or cx, cx
171 jz PCMPP_NoLinuxKernels
172 mov ax, offset LINUX_KernelEntries
173 PCMPP_KernelLoop:
174 mov ds:[bx], ax
175 add bx, 2
176 add ax, LocIPT_LenOfIPT
177 dec cx
178 jnz PCMPP_KernelLoop
179 PCMPP_NoLinuxKernels:
180
181 movzx cx, CFG_Partitions ; LocIPT_MaxPartitions
182 or cx, cx
183 jz PCMPP_NoPartitions
184 PCMPP_Loop:
185 mov al, ds:[si+LocIPT_Flags]
186 and al, Flags_Bootable
187 jz PCMPP_IsNotBootable
188 mov ds:[bx], si
189 add bx, 2
190 PCMPP_IsNotBootable:
191 add si, LocIPT_LenOfIPT
192 dec cx
193 jnz PCMPP_Loop
194 PCMPP_NoPartitions:
195 sub bx, offset PartitionPointers
196 shr bx, 1
197 mov ds:[PartitionPointerCount], bl
198 ret
199PART_CalculateMenuPartPointers EndP
200
201; Gets a pointer to the given partition
202; In: DL - Number of partition
203; Out: SI - Pointer to it (use CS)
204PART_GetPartitionPointer Proc Near Uses bx
205 cmp dl, 0FEh
206 je PGPP_IsBIOSbootSeq ; FEh -> Resume BIOS boot Sequence
207 ja PGPP_IsFloppy ; FFh -> Floppy
208 movzx bx, dl
209 shl bx, 1
210 mov si, wptr cs:[PartitionPointers+bx]
211 ret
212 PGPP_IsBIOSbootSeq:
213 mov si, offset BIOScontIPTentry
214 ret
215 PGPP_IsFloppy:
216 mov si, offset FloppyIPTentry ; PartitionTable-LocIPT_LenOfIPT
217 ret
218PART_GetPartitionPointer EndP
219
220; Gets the number of a partition pointer
221; In: SI - Pointer to Partition
222; Out: DL - Number of partition
223PART_GetPartitionNumber Proc Near Uses bx
224 mov dl, ds:[PartitionPointerCount]
225 mov bx, offset PartitionPointers
226 PGPN_SearchLoop:
227 cmp wptr ds:[bx], si
228 je PGPN_Found
229 add bx, 2
230 dec dl
231 jnz PGPN_SearchLoop
232 mov dl, 0FFh
233 ret
234 PGPN_Found:
235 sub dl, ds:[PartitionPointerCount]
236 dec dl
237 not dl
238 ret
239PART_GetPartitionNumber EndP
240
241; Following functions are only usable, when Partition-Pointer-View is filtered
242; They will convert from and to unfiltered view (used in Boot-Menu)
243; In: DL - Number of partition in filtered view
244; Out: DL - Number of partition in straight view
245PART_ConvertToStraight Proc Near Uses
246 movzx bx, dl
247 shl bx, 1
248 mov ax, wptr cs:[PartitionPointers+bx]
249 cmp ax, offset FloppyIPTentry
250 jb PCTS_IsBIOSbootSeq
251 je PCTS_IsFloppy
252 cmp ax, offset LINUX_KernelEntries
253 jae PCTS_IsKernelEntry
254 sub ax, offset PartitionTable
255 mov bl, LocIPT_LenOfIPT
256 div bl ; Divide with IPTlength
257 mov dl, al
258 ret
259 PCTS_IsKernelEntry:
260 mov dl, 0FDh
261 ret
262 PCTS_IsBIOSbootSeq:
263 mov dl, 0FEh
264 ret
265 PCTS_IsFloppy:
266 mov dl, 0FFh
267 ret
268PART_ConvertToStraight EndP
269
270; In: DL - Number of partition in straight view
271; Out: DL - Number of partition in filtered view
272PART_ConvertFromStraight Proc Near Uses es di
273 ; First we get Partition-Offset in AX
274 movzx ax, dl
275 mov bl, LocIPT_LenOfIPT
276 mul bl
277 add ax, offset PartitionTable
278 ; Now search for this offset in our filtered Partition-Pointer-Table
279 push cs
280 pop es
281 mov di, offset PartitionPointers
282 mov cx, LocIPT_MaxPartitions
283 xor dl, dl ; Reply on Not-Found = Partition==0
284 repne scasw ; Compare-Loop
285 jne PCFS_NotFound
286 sub di, 2 ; One Back, so point to compared value
287 mov dx, di
288 sub dx, offset PartitionPointers
289 shr dx, 1
290 ; Adjust for IncludeFloppy/etc. is automatically done, due Pointer-LookUp
291 PCFS_NotFound:
292 ret
293PART_ConvertFromStraight EndP
294
295; In: AX - Pointer to IPT Entry
296; Out: SI - Pointer to corresponding Size-Element
297; Destroyed: AX
298PART_GetSizeElementPointer Proc Near Uses bx
299 cmp ax, offset LINUX_KernelEntries
300 jae PGSEP_IsKernelEntry
301 mov si, offset PartitionSizeTable
302 sub ax, offset PartitionTable
303 jmp PGSEP_Continue
304 PGSEP_IsKernelEntry:
305 mov si, offset LINUX_KernelSizeTable
306 sub ax, offset LINUX_KernelEntries
307 PGSEP_Continue:
308 mov bl, LocIPT_LenOfIPT
309 div bl ; Divide with IPTlength
310 movzx bx, al
311 shl ax, 1
312 shl bx, 2
313 add ax, bx ; My way of multiplying with 6
314 add si, ax ; SI - Partition Size-Element
315 ret
316PART_GetSizeElementPointer EndP
317
318; In: BX:AX - Sector Size (1=512 Bytes, 2=1024 Bytes, etc.)
319; ES:DI - Pointer to Size-Element (6 bytes)
320; Out: None, Size-Element filled out
321; Destroyed: AX, BX, DI
322PART_FillOutSizeElement Proc Near Uses cx dx
323 add di, 3 ; ES:DI - Last Digit of Size Digits
324 shr bx, 1
325 rcr ax, 1 ; /2 -> Sector Size is now KByte Size
326 xor cl, cl ; 0 - KByte, 1 - MByte, 2 - GByte
327 PFOSE_MakeSmallerLoop:
328 or bx, bx
329 jnz PFOSE_MakeSmaller
330 cmp ax, 9999
331 jbe PFOSE_IsSmallEnough
332 PFOSE_MakeSmaller:
333 mov dx, bx
334 and dx, 1023 ; My crazy way of dividing a 32-bit
335 shr ax, 10 ; value through 1024 using 16-bit
336 shr bx, 10 ; instructions...
337 shl dx, 6
338 or ax, dx
339 inc cl ; Value got smaller...
340 jmp PFOSE_MakeSmallerLoop
341
342 PFOSE_IsSmallEnough:
343 ; First write the type of this Size-Element (KB/MB/GB)
344 mov bx, 'BK'
345 cmp cl, 1
346 jb PFOSE_WriteType
347 je PFOSE_IsMBtype
348 mov bx, 'BG'
349 jmp PFOSE_WriteType
350 PFOSE_IsMBtype:
351 mov bx, 'BM'
352 PFOSE_WriteType:
353 mov wptr es:[di+1], bx
354 mov bx, 10 ; Digits are 10-Based
355 xor dx, dx
356 PFOSE_DigitLoop:
357 xor dx, dx
358 div bx ; AX - Digit, DX - Remainder
359 add dl, '0' ; Convert digit to ASCII digit
360 mov es:[di], dl
361 or ax, ax
362 jz PFOSE_EndOfDigitLoop
363 dec di ; Go to previous char
364 jmp PFOSE_DigitLoop
365
366 PFOSE_EndOfDigitLoop:
367 ret
368PART_FillOutSizeElement EndP
369
370; Starts Partition DL from Internal Partition Table.
371; In: DL - Number of partition (filtered view)
372; Out: No Return...
373; Destroyed: None, due no return ;-)
374; Logic: - Harddrive: loads partition Table
375; sets partition active
376; saves partition table
377; hides partitions, if needed
378; Linux-Support, if needed
379; load boot sector
380; VIBR checking, if wanted
381; install MBR Protection, if wanted
382; Special Boot Support, if needed (OS/2 Extended partitions)
383; run boot sector...
384PART_StartPartition Proc Near Uses ax dx es di
385 local BootPartNo:byte
386 ; Get Partition-Pointer (SI) to Partition-To-Boot (DL)
387 call PART_GetPartitionPointer
388
389 call PART_ConvertToStraight ; ...we save straight view for later...
390 mov BootPartNo, dl
391
392 ; We need straight pointers from now on, so calculate the table...
393 call PART_CalculateStraightPartPointers
394
395 ; SI contains the pointer to the IPT to what partition to boot
396 ; in this whole routine...it may never get messed up.
397
398 push si
399 mov dl, cs:[si+LocIPT_Drive]
400 mov dh, cs:[si+LocIPT_SystemID]
401 ; Copy Partition-Name to BootingNow area for display purposes
402 add si, LocIPT_Name
403 mov cx, 11
404 call GetLenOfName
405 mov di, offset TXT_BootingNowPartName
406 jz PSP_NoName
407 rep movsb
408 PSP_NoName:
409 xor al, al
410 stosb ; Ending Zero
411 mov si, offset TXT_BootingNow1
412 call MBR_Teletype
413 cmp dh, 0FDh
414 je PSP_IsKernel
415 or dl, dl
416 jnz PSP_IsHarddisc
417 ; When booting floppy/CD-ROM/etc., we got other text to be displayed...
418 mov si, offset TXT_BootingNowPartName
419 call MBR_Teletype
420 jmp PSP_IsFloppyCDROMetc
421
422 PSP_IsKernel:
423 IFDEF ReleaseCode
424 ; Save configuration on HDD boots (save CFG_LinuxLastKernel)
425 call DriveIO_SaveConfiguration
426 ENDIF
427 call MBR_Teletype ; Prints out BootingNow2 including KernelName
428 mov si, offset TXT_BootingNowKernel
429 call MBR_Teletype
430 jmp PSP_IsFloppyCDROMetc
431
432 PSP_IsHarddisc:
433 IFDEF ReleaseCode
434 ; Save configuration on HDD boots (save CFG_PartLast)
435 call DriveIO_SaveConfiguration
436 ENDIF
437 call MBR_Teletype ; Prints out BootingNow2 including PartitionName
438 mov si, offset TXT_BootingNowPartition
439 call MBR_Teletype
440 pop si ; restores SI (IPT-pointer)
441
442 mov ax, wptr cs:[si+LocIPT_AbsolutePartTable+0]
443 mov bx, wptr cs:[si+LocIPT_AbsolutePartTable+2]
444 mov cx, wptr cs:[si+LocIPT_LocationPartTable+1]
445 mov dh, bptr cs:[si+LocIPT_LocationPartTable+0]
446 mov dl, cs:[si+LocIPT_Drive]
447 call DriveIO_LoadPartition ; Load Table...
448 ; --------------------------------------------------- MODIFY PARTITION TABLE
449 push ExecBaseSeg
450 pop es
451 mov di, ExecBasePtr
452 add di, 446 ; DS:SI - Erster Partitionseintrag
453
454 ; Remove all active-flags for safety reasons, primary partition table will
455 ; have one partition set active by ScanPartition-routine.
456 push di
457 mov cl, 4
458 PSP_RemoveActiveFlagLoop:
459 and bptr es:[di+LocBRPT_Flags], 7Fh
460 add di, LocBRPT_LenOfEntry
461 dec cl
462 jnz PSP_RemoveActiveFlagLoop
463 pop di
464
465 ; Put the partition-to-be-booted location into registers...
466 mov ax, wptr cs:[si+LocIPT_AbsoluteBegin+0]
467 mov bx, wptr cs:[si+LocIPT_AbsoluteBegin+2]
468 sub ax, wptr cs:[si+LocIPT_AbsolutePartTable+0]
469 sbb bx, wptr cs:[si+LocIPT_AbsolutePartTable+2]
470 ; BX:AX - absolute position of partition relative to partition table
471 ; ...and search for it...
472 PSP_SearchLoop:
473 cmp ax, wptr es:[di+LocBRPT_RelativeBegin]
474 jne PSP_SearchMismatch
475 cmp bx, wptr es:[di+LocBRPT_RelativeBegin+2]
476 jne PSP_SearchMismatch
477 jmp PSP_SearchMatch
478 PSP_SearchMismatch:
479 add di, LocBRPT_LenOfEntry ; 16 Bytes per Partition-Entry
480 cmp di, 500+ExecBasePtr
481 jb PSP_SearchLoop
482 jmp MBR_HaltSystem
483
484 ; -------------------------------------------------------------- ENTRY FOUND
485 PSP_SearchMatch:
486 or byte ptr es:[di+LocBRPT_Flags], 80h ; set ACTIVE partition
487 IFDEF ReleaseCode
488 call DriveIO_SavePartition ; Saves the Partition-Table
489 ENDIF
490
491 ; ---------------------------------------------------------- OS/2 / eCS I13X
492 ; Now check if the partition to get booted is above 8 GB.
493 ; If yes, set magic bytes 'I13X' at 3000:0 for boot-loader to recognize.
494 ; This method is (c) by IBM <g>
495 mov ax, wptr cs:[si+LocIPT_AbsoluteBegin+0]
496 mov bx, wptr cs:[si+LocIPT_AbsoluteBegin+2]
497 add ax, wptr es:[di+LocBRPT_AbsoluteLength+0] ; Add length to absolute
498 adc bx, wptr es:[di+LocBRPT_AbsoluteLength+2] ; begin location
499 ; BX:AX -> Absolute End-Position of Partition
500
501 test CFG_ForceLBAUsage, 1
502 jnz PSP_ForceI13X
503 ; LBA-boundary at 16450560 (FB0400h)
504 cmp bx, 00FBh
505 jb PSP_NoI13X
506 PSP_ForceI13X:
507 push es di
508 mov ax, 3000h
509 mov es, ax
510 xor di, di
511 mov wptr es:[di], '1I'
512 mov wptr es:[di+2], 'X3'
513 pop di es
514 PSP_NoI13X:
515
516 ; now check, if we need to hide any partition
517 test byte ptr cs:[si+LocIPT_Flags], Flags_HideFeature
518 jz PSP_NoHideFeature
519 ; --------------------------------------------------------- PARTITION HIDING
520 push si
521 mov si, offset TXT_BootingHide
522 call MBR_Teletype ; display "hide active"
523 pop si
524 ; First, find Hide-Config
525 mov dl, BootPartNo ; EntryNumber is straight view
526 mov ax, LocIPT_MaxPartitions
527 mul dl
528 mov di, offset HidePartitionTable
529 add di, ax ; We got the pointer
530 ; So process Hide-Config. Read out Byte-Entries, each points to a partition
531 ; 0FFh is end-marker / maximum entries = CFG_Partitions
532 mov cl, CFG_Partitions
533 PSP_PartitionsHideLoop:
534 mov dl, cs:[di]
535 inc di
536 cmp dl, 0FFh
537 je PSP_EndOfHideProcess ; -> End of Hiding
538 call PART_HidePartition ; Now hide that partition
539 dec cl
540 jnz PSP_PartitionsHideLoop
541 PSP_EndOfHideProcess:
542 ; --- HIDE COMPLETED ---
543 ; So something got hidden and we have to remark a primary partition,
544 ; if we are booting something non-primary from 1st hdd.
545 cmp bptr ds:[si+LocIPT_Drive], 80h
546 ja PSP_HideAdjustPrimaryMark ; When booting any hdd, but 1st
547 mov ax, wptr ds:[si+LocIPT_AbsolutePartTable]
548 mov bx, wptr ds:[si+LocIPT_AbsolutePartTable+2]
549 or ax, ax
550 jnz PSP_HideAdjustPrimaryMark ; or booting non-primary partition
551 or bx, bx ; on 1st harddrive.
552 jz PSP_NoHideAdjustPrimaryMark
553 PSP_HideAdjustPrimaryMark:
554 ; Load Primary Partition Table...
555 xor ax, ax
556 xor bx, bx
557 mov cx, 0001h ; Cylinder 0, Sector 1
558 mov dx, 0080h ; First HD, Head 0
559 call DriveIO_LoadPartition ; Load Primary Partition Table
560 call PART_MarkFirstGoodPrimary
561 IFDEF ReleaseCode
562 call DriveIO_SavePartition ; Saves the Partition-Table
563 ENDIF
564 PSP_NoHideAdjustPrimaryMark:
565
566 PSP_NoHideFeature:
567 push si
568 ; ------------------------------------------------------- -"PLEASE WAIT..."-
569 PSP_IsFloppyCDROMetc:
570 mov si, offset TXT_BootingWait
571 call MBR_Teletype ; display "please wait"
572 pop si
573
574 ; Process Partition Tables, if M$-Hack required (changes Ext Part Type)
575 call MSHACK_ProcessPartTables
576
577 test CFG_BootMenuActive, 0FFh
578 jz PSP_NoMenuNoSound
579
580 ; --------------------------------------------------------------- BOOT-SOUND
581 call SOUND_ExecuteBoot
582 PSP_NoMenuNoSound:
583
584 ; -------------------------------------------------- SPECIAL BOOT PROCESSING
585 ; Check here, if the Boot shall be done via resume to BIOS...
586 mov al, bptr cs:[si+LocIPT_SystemID]
587 cmp al, 0FEh ; Via BIOS ? (aka resume BIOS boot sequence)
588 je PSP_ResumeBIOSbootSeq
589 cmp al, 0FDh ; Kernel-Booting ?
590 je PSP_KernelBooting
591 jmp PSP_StartNormal
592
593 PSP_ResumeBIOSbootSeq:
594 int 18h ; Give control back to BIOS
595 db 0EAh ; if return to here -> Reboot
596 dw 0FFF0h
597 dw 0F000h
598
599 PSP_KernelBooting:
600 call LINUX_LoadKernel ; DS:SI - Entry Pointer to Kernel
601 db 0EAh ; if return to here -> Reboot
602 dw 0FFF0h
603 dw 0F000h
604
605 ; ==================================================================
606 ; FROM THIS POINT ON, ONLY *SI* REGISTER IS NEEDED TO BE PRESERVED
607 ; ==================================================================
608
609 PSP_StartNormal:
610 mov ax, wptr cs:[si+LocIPT_AbsoluteBegin+0]
611 mov bx, wptr cs:[si+LocIPT_AbsoluteBegin+2]
612 mov cx, cs:[si+LocIPT_LocationBegin+1]
613 mov dh, cs:[si+LocIPT_LocationBegin+0]
614 mov dl, cs:[si+LocIPT_Drive]
615 call DriveIO_LoadPartition ; Loads boot-sector...
616
617 test CFG_DetectVIBR, 1
618 jz PSP_NoVIBR
619 test byte ptr cs:[si+LocIPT_Flags], Flags_VIBR_Detection
620 jz PSP_NoVIBR
621 ; ---------------------------------------------------------- CHECKS FOR VIBR
622 push ds si
623 push ExecBaseSeg
624 pop ds
625 mov si, offset ExecBasePtr
626 mov bx, 4B4Dh ; Magic: 'MK'
627 call MBR_GetCheckOfSector
628 pop si ds
629 cmp cs:[si+LocIPT_BootRecordCRC], bx
630 je PSP_NoVIBR
631 mov bx, cs:[si+LocIPT_BootRecordCRC]
632 or bx, bx
633 jz PSP_NoVIBR
634 ; Oh Oh, got a virus :(
635 mov si, offset TXT_VirusFoundMain
636 call MBR_Teletype
637 mov si, offset TXT_VirusFound2 ; VIBR-Virus
638 call MBR_Teletype
639 mov si, offset TXT_VirusFoundEnd
640 call MBR_Teletype
641 jmp MBR_HaltSystem
642
643 PSP_NoVIBR:
644 test CFG_ProtectMBR, 1
645 jz PSP_NoMBRprotect
646 ; -------------------------------------------------- INSTALLS MBR-PROTECTION
647 push si ; We need SI later...
648 ; First subtract 1024 bytes from Base-Memory...
649 push ds
650 mov ax, 40h
651 mov ds, ax
652 mov dx, word ptr ds:[13h]
653 dec dx ; 1 == 1kbyte
654 mov word ptr ds:[13h], dx
655 pop ds
656 shl dx, 6 ; trick, now DX is a segment
657
658 ; Now copy in our code (to DX:0)...
659
660 mov ax, cs
661 mov ds, ax
662 mov si, offset MBR_Protection ; DS:SI - Source Image
663 mov es, dx
664 xor di, di ; ES:DI - Destination
665 mov cx, 512
666 rep movsw ; Move 1024 bytes...
667
668 ; Now fill in variables...
669
670 xor ax, ax
671 mov ds, ax
672 mov si, 10h*4
673 xor di, di ; INT 10h Vector to MBR Protection
674 movsd
675 mov si, 13h*4 ; INT 13h Vector to MBR Protection
676 movsd
677 mov al, CFG_IgnoreWriteToMBR ; Option to MBR Protection
678 stosb
679
680 ; Now switch INT 13h vector to MBR Protection
681
682 sub si, 4
683 mov ax, 9
684 mov ds:[si], ax
685 mov ds:[si+2], dx ; Vector hardcoded at DS:0009
686 ; MBR-Protection now active :)
687 pop si ; Restore SI
688
689 ; ------------------------------------------------ SPECIAL PARTITION SUPPORT
690 ; needed by OS/2 Warp / eComStation
691 PSP_NoMBRprotect:
692 cmp bptr cs:[si+LocIPT_SystemID], 08 ; I hate Microsuck NTFS check
693 je PSP_NoSpecialSupport
694
695 push ExecBaseSeg
696 pop es
697 mov di, ExecBasePtr ; ES:DI - Actual Boot-Record
698 ; Special Support Detection
699 mov ax, wptr es:[di+24]
700 cmp ax, 003Fh ; Physical Layout-Sectors... Safety check
701 ja PSP_NoSpecialSupport
702 mov ax, wptr es:[di+26]
703 cmp ax, 00FFh ; Physical Layout-Heads... Safety check
704 ja PSP_NoSpecialSupport
705 mov al, bptr es:[di+36]
706 cmp al, 80h ; Drive Letter
707 jne PSP_NoSpecialSupport
708 ; Special Support needed
709 mov al, bptr cs:[si+LocIPT_Drive]
710 mov bptr es:[di+36], al ; Write Actual Drive-Letter
711 mov ax, cs:[si+LocIPT_AbsoluteBegin]
712 mov wptr es:[di+28], ax ; Fixing Hidden Sectors count
713 mov ax, cs:[si+LocIPT_AbsoluteBegin+2]
714 mov wptr es:[di+30], ax ; Done by OS/2 BootMan as well...
715
716 ; ------------------------------------------------ LOGICAL PARTITION SUPPORT
717 PSP_NoSpecialSupport:
718 test byte ptr cs:[si+LocIPT_Flags], Flags_DriveLetter
719 jz PSP_NoLogicalSupport
720
721 movzx bx, BootPartNo ; EntryNumber is straight view
722 mov al, bptr cs:[DriveLetters+bx]
723 mov bptr es:[di+37], al ; Write Drive Letter (OS/2 only)
724
725 ; ---------------------------------------------------- NOW START BOOT-RECORD
726 PSP_NoLogicalSupport:
727 xor ax, ax
728 xor bx, bx
729 xor cx, cx
730 mov ds, ax
731 mov es, ax ; DS == ES == 0
732 xor dh, dh ; Drive supported by BIOS
733 mov dl, cs:[si+LocIPT_Drive] ; Drive Physical No
734 db 0EAh ; JUMP TO Entry Point...Bye Bye
735 dw ExecBasePtr
736 dw ExecBaseSeg
737PART_StartPartition EndP
738
739; This routine is called to hide a partition
740; In: DL - Partition to hide
741; Destroyed: None
742PART_HidePartition Proc Near Uses ax bx cx dx si es di
743 call PART_GetPartitionPointer ; Pointer to partition (DL) -> SI
744
745 ; First load the partition table of that partition...
746 mov ax, wptr cs:[si+LocIPT_AbsolutePartTable+0]
747 mov bx, wptr cs:[si+LocIPT_AbsolutePartTable+2]
748 mov cx, wptr cs:[si+LocIPT_LocationPartTable+1]
749 mov dh, bptr cs:[si+LocIPT_LocationPartTable+0]
750 mov dl, cs:[si+LocIPT_Drive]
751 call DriveIO_LoadPartition
752 ; Partition-Table now LOADED
753 push ExecBaseSeg
754 pop es
755 mov di, ExecBasePtr
756 add di, 446 ; DS:SI - 1st partitionentry...
757
758 ; Put our partition's location into registers...
759 mov ax, wptr cs:[si+LocIPT_AbsoluteBegin+0]
760 mov bx, wptr cs:[si+LocIPT_AbsoluteBegin+2]
761 sub ax, wptr cs:[si+LocIPT_AbsolutePartTable+0]
762 sbb bx, wptr cs:[si+LocIPT_AbsolutePartTable+2]
763 ; BX:AX - absolute position of partition relative to partition table
764 ; ...and search for it...
765 PHP_SearchLoop:
766 cmp ax, wptr es:[di+LocBRPT_RelativeBegin]
767 jne PHP_SearchMismatch
768 cmp bx, wptr es:[di+LocBRPT_RelativeBegin+2]
769 jne PHP_SearchMismatch
770 jmp PHP_SearchMatch
771 PHP_SearchMismatch:
772 add di, LocBRPT_LenOfEntry ; 16 Bytes per partition entry
773 cmp di, 500+ExecBasePtr
774 jb PHP_SearchLoop
775 jmp MBR_HaltSystem ; not found, something is wrong here
776
777 ; Found entry...
778 PHP_SearchMatch:
779 mov al, bptr es:[di+LocBRPT_SystemID] ; Partition-ID into AL
780 call PART_SearchFileSysHiddenID ; Put on =STEALTH=
781 mov bptr es:[di+LocBRPT_SystemID], al
782 IFDEF ReleaseCode
783 call DriveIO_SavePartition ; Saves Partition-Table
784 ENDIF
785 ret
786PART_HidePartition EndP
787
788; This here is for marking the first "good" non-hidden partition as being
789; active. It requires the partition table at EXECBASE.
790; Some BIOSes have problems with no primary marked active. Actually this is
791; a buggy implementation, because the MBR-code should normally check,
792; *not* the BIOS. This one *could* cause havoc to some systems, but I can't
793; do anything else.
794; =In this routine DS may not be equal CS=
795PART_MarkFirstGoodPrimary Proc Near Uses ax si es di
796 push ExecBaseSeg
797 pop es
798 mov di, ExecBasePtr
799 add di, 446 ; DS:SI - First Partition-Entry
800 ; First action to do: Remove the active flag from every partition
801 push di
802 mov cl, 4
803 PMPP_RemoveActiveFlagLoop:
804 and bptr es:[di+LocBRPT_Flags], 7Fh
805 add di, LocBRPT_LenOfEntry
806 dec cl
807 jnz PMPP_RemoveActiveFlagLoop
808 pop di
809 ; First Search, will hit on any PartitionID that is:
810 ; a) not 0
811 ; b) not hidden
812 ; c) not extended partition (05h or 0Fh)
813 PMPP_Search1Loop:
814 mov al, bptr es:[di+LocBRPT_SystemID]
815 or al, al
816 jz PMPP_Search1NoHit
817 cmp al, 05h
818 je PMPP_Search1NoHit
819 cmp al, 0Fh
820 je PMPP_Search1NoHit
821 mov bl, al ; BL == AL == PartitionID
822 push si
823 call PART_SearchFileSysName
824 pop si ; AL == UnhiddenPartitionID
825 cmp al, bl ; if ID is unhidden...
826 je PMPP_SearchHit
827 PMPP_Search1NoHit:
828 add di, LocBRPT_LenOfEntry ; 16 Bytes per Partition-Entry
829 cmp di, 500+ExecBasePtr
830 jb PMPP_Search1Loop
831
832 mov di, ExecBasePtr
833 add di, 446 ; DS:SI - First Partition-Entry
834 ; Second Search, hit on anything that is not an extended partition
835 ; (05 or 0Fh)
836 PMPP_Search2Loop:
837 mov al, bptr es:[di+LocBRPT_SystemID]
838 or al, al
839 jz PMPP_Search2NoHit
840 cmp al, 05h
841 je PMPP_Search2NoHit
842 cmp al, 0Fh
843 jne PMPP_SearchHit
844 PMPP_Search2NoHit:
845 add di, LocBRPT_LenOfEntry ; 16 Bytes per Partition-Entry
846 cmp di, 500+ExecBasePtr
847 jb PMPP_Search2Loop
848 jmp PMPP_SearchFailed
849
850 PMPP_SearchHit:
851 or bptr es:[di], 80h ; SET ACTIVE PARTITION
852 PMPP_SearchFailed:
853 ret
854PART_MarkFirstGoodPrimary EndP
855
856; Searches the Name and Flags to a FileSysID (PartitionID)
857; In: AL - FileSysID
858; Out: AL - Unhidden File-System-ID, AH - Flags for this File-System
859; SI - Pointer to Name (8char)
860; Destroyed: *none*
861PART_SearchFileSysName Proc Near Uses ds bx dx
862 movzx bx, al
863 push cs
864 pop ds
865 mov si, offset FileSysIDs
866 PSFSN_SearchLoop:
867 lodsw ; AL - NormalID, AH-HiddenID
868 mov dl, ds:[si] ; DL - File-System-Flags
869 inc si
870 cmp al, bl ; Check, if Unhidden-ID matches...
871 je PSFSN_Match
872 cmp ah, bl ; Check, if Hidden-ID matches...
873 je PSFSN_Match
874 mov al, bl ; So Unhidden-ID will be Original-ID
875 cmp ah, 0 ; Unknown (last ID in table)
876 je PSFSN_Match
877 inc bh
878 jmp PSFSN_SearchLoop
879
880 PSFSN_Match:
881 ; AL is already Unhidden-ID
882 mov ah, dl
883 ; AH is now the FileSystem-Flag
884 movzx bx, bh
885 shl bx, 3 ; Offsets * 8
886 mov si, offset FileSysNames
887 add si, bx
888 ret
889PART_SearchFileSysName EndP
890
891; Searches the Hidden ID corresponding to a FileSysID (PartitionID)
892; In: AL - FileSysID
893; Out: AL - Hidden File-System-ID
894PART_SearchFileSysHiddenID Proc Near Uses ds bx
895 movzx bx, al
896 push cs
897 pop ds
898 mov si, offset FileSysIDs
899 PSFSHI_SearchLoop:
900 lodsw ; AL - NormalID, AH-HiddenID
901 inc si
902 cmp al, bl ; Check, if Unhidden-ID matches...
903 je PSFSHI_Match
904 cmp ah, bl ; Check, if Hidden-ID matches...
905 je PSFSHI_Match
906 mov ah, bl ; So Unhidden-ID will get replied...
907 cmp ah, 0 ; Unknown (last ID in table)
908 je PSFSHI_Match
909 inc bh
910 jmp PSFSHI_SearchLoop
911
912 PSFSHI_Match:
913 mov al, ah ; AL = Hidden ID
914 ret
915PART_SearchFileSysHiddenID EndP
916
917; In: DS:SI - Partition-Name, CX - Maximum/Total Length
918; Out: Carry-Flag set, if valid Partition-Name
919; Destroyed: None
920PART_CheckForValidPartName Proc Near Uses ax cx dx si
921 ; Our logic is as follows:
922 ; If all chars are U -> Invalid (due reformated signature)
923 ; If anything below 32, but 0 -> Invalid (due invalid chars)
924 ; If anything above 165 -> Invalid (due invalid chars)
925 ; If anything between 123-128 -> Invalid (due invalid chars)
926 ; DX - holds count of 'U's
927 push cx
928 or cx, cx
929 jz PCFVPN_InvalidName
930 xor dx, dx
931 PCFVPN_CheckLoop:
932 lodsb
933 cmp al, 0
934 je PCFVPN_ValidChar
935 cmp al, 32
936 jb PCFVPN_InvalidName
937 cmp al, 165
938 ja PCFVPN_InvalidName
939 cmp al, 123
940 jb PCFVPN_ValidChar
941 cmp al, 128
942 jbe PCFVPN_InvalidName
943 PCFVPN_ValidChar:
944 cmp al, 'U'
945 jne PCFVPN_NoMagic
946 inc dx
947 PCFVPN_NoMagic:
948 dec cx
949 jnz PCFVPN_CheckLoop
950 pop cx
951 cmp cx, dx
952 clc
953 je PCFVPN_WasMagic
954 stc
955 PCFVPN_WasMagic:
956 ret
957 PCFVPN_InvalidName:
958 pop cx
959 clc
960 ret
961PART_CheckForValidPartName EndP
Note: See TracBrowser for help on using the repository browser.