source: trunk/bootcode/airboot.asm@ 96

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

Removed Linux noise [v1.1.1-testing]

This stuff was already commented out and not applicable anymore.
It was used to directly boot Linux kernels from FAT some eons ago.
Linux is supported by chain-loading GRUB.

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File size: 93.2 KB
Line 
1;
2; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
3;
4; This file is part of AiR-BOOT
5;
6; AiR-BOOT is free software: you can redistribute it and/or modify it under
7; the terms of the GNU General Public License as published by the Free
8; Software Foundation, either version 3 of the License, or (at your option)
9; any later version.
10;
11; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
12; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
13; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14; details.
15;
16; You should have received a copy of the GNU General Public License along with
17; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
18;
19
20
21
22
23
24
25
26;##############################################################################
27; AiR-BOOT / DEFINITIONS
28;##############################################################################
29
30;
31; Include AiR-BOOT Version Information.
32; This version-info is defined using simpel EQU's so it can serve as a
33; single source for other formats. The AiR-BOOT signature and the
34; OS/2 BLDLEVEL use this basic version information.
35;
36include ../include/version.inc
37
38;
39; Include OS/2 BLDLEVEL Information.
40; It uses the version-information in VERSION.INC to build it's signature.
41;
42include bldlevel.inc
43
44;
45; Include some macro's.
46; This file contains the ORIGIN macro that is used to detect overlaps.
47;
48include ../include/asm.inc
49
50
51; We actually don't want to use this directive because it generates extra
52; NOP instructions that we can do without.
53; TASM also has a bug in that when the .ERR2 directive is used when
54; the .386 directive is in effect, the JUMPS directive is also active
55; and cannot be turned off.
56; NOJUMPS seems to have no effect in this situation.
57; In this case 4 NOP instructions are generated after forward referencing jump
58; instructions, to allow for automatic recoding by TASM.
59; This seems to be a TASM bug. (v2,v3,v4, dunno v5)
60IFDEF TASM
61 ;~ JUMPS
62ENDIF
63
64
65;
66; If defined then each module is prefixed with it's name.
67; This is used for debugging purposes but it also increases code space.
68; It should be off in release code.
69;
70;~ MODULE_NAMES EQU
71
72
73
74; -----------------------------------------------------------------------------
75; DEBUG
76; -----------------------------------------------------------------------------
77
78;
79; Enable this to include Debug Modules and enable COM-port debugging.
80; To have room for the debug-code, the FX-code can only be enabled
81; when AUX_DEBUG is not defined.
82;
83AUX_DEBUG EQU
84
85;
86; To have FX enabled, make sure FX_ENABLE is defined.
87; There is no need (for now) to remove Cooper Bars from the setup-menu
88; because AiR-BOOT does not crash when enabling Cooper Bars while FX
89; is not compiled in. Only TAB to post-screen does not work.
90; Way to go Martin !
91;
92IFNDEF AUX_DEBUG
93FX_ENABLED EQU
94ENDIF
95
96
97
98; -----------------------------------------------------------------------------
99; AUX
100; -----------------------------------------------------------------------------
101;
102; bits 7-5 = datarate
103; (000=110,001=150,010=300,011=600,100=1200,101=2400,110=4800,111=9600 bps)
104; bits 4-3 = parity
105; (00 or 10 = none, 01 = odd, 11 = even)
106; bit 2 = stop-bits
107; (set = 2 stop-bits, clear = 1 stop-bit)
108; bits 1-0 = data-bits
109; (00 = 5, 01 = 6, 10 = 7, 11 = 8)
110;
111
112; 9600 bps, no parity, 1 stop-bit, 8 bits per char
113AUX_INIT_PARMS EQU 11100011b
114
115; Com-port for debugging, 0 is disabled
116BIOS_COM_PORT EQU 1
117
118; Default word value for BIOS_AuxParms variable
119; Note that is has moved since v1.07
120BIOS_AUXPARMS_DEFAULT EQU (AUX_INIT_PARMS SHL 8) OR BIOS_COM_PORT
121
122; Default byte value for BIOS_BootDisk variable
123BIOS_BOOTDISK_DEFAULT EQU 80h
124
125
126
127; -----------------------------------------------------------------------------
128; LABELS
129; -----------------------------------------------------------------------------
130; Address labels after code-move
131BootBaseSeg equ 08000h ; Pre-boot, in the low 640K
132BootBasePtr equ 0h ; We put our MBR to this location
133BootBaseExec equ BootBasePtr+offset MBR_RealStart
134StackSeg equ 07000h ; Put the stack below the code
135StartBaseSeg equ 00000h ; Pre-boot, we are in low memory
136StartBasePtr equ 07C00h ; BIOS starts our MBR at 0:7C00
137
138
139
140; -----------------------------------------------------------------------------
141; VIDEO
142; -----------------------------------------------------------------------------
143; Video pages, no INT 10h is used for menu-drawing etc.
144VideoIO_Page0 equ 0B800h
145VideoIO_Page1 equ 0B900h
146VideoIO_Page2 equ 0BA00h
147VideoIO_Page4 equ 0BC00h
148VideoIO_FXSegment equ 0A000h
149
150; Special line-drawing characters
151TextChar_WinLineRight equ 0C4h
152TextChar_WinLineDown equ 0B3h
153TextChar_WinRep1 equ 0D1h
154TextChar_WinRep2 equ 0C5h
155TextChar_WinRep3 equ 0CFh
156TextChar_WinRep4 equ 0B5h
157TextChar_WinRep5 equ 0C6h
158TextChar_WinRep6 equ 0D8h
159
160
161
162; -----------------------------------------------------------------------------
163; PARTITION TABLE
164; -----------------------------------------------------------------------------
165; Offsets for Partition-Entries in MBR/EBRs
166LocBRPT_LenOfEntry equ 16 ; Length of a standard MBR or EPR entry
167LocBRPT_Flags equ 0 ; Bootable, Hidden, etc.
168LocBRPT_BeginCHS equ 1 ; Packed CHS value
169LocBRPT_BeginHead equ 1 ; Start head, usually < 16
170LocBRPT_BeginSector equ 2 ; Start sector, max 63 + cyl high bits
171LocBRPT_BeginCylinder equ 3 ; Start cylinder 8+2 bits, max 1023
172LocBRPT_SystemID equ 4 ; Type of system using the partition
173LocBRPT_EndCHS equ 5 ; Packed CHS value
174LocBRPT_EndHead equ 5 ; End head, usually < 16
175LocBRPT_EndSector equ 6 ; End sector, max 63 + cyl high bits
176LocBRPT_EndCylinder equ 7 ; End cylinder 8+2 bits, max 1023
177LocBRPT_RelativeBegin equ 8 ; LBA32 address of partition
178LocBRPT_AbsoluteLength equ 12 ; 32-bit length of partition
179
180; Signature relative to start of MBR/EBR
181LocBR_Magic equ 510 ; Offset of 0AA55h signature
182
183; -----------------------------------------------------------------------------
184; LVM RECORD
185; -----------------------------------------------------------------------------
186; Used as a quick compare in LVM.ASM
187LocLVM_SignatureByte0 equ 02h
188
189; Offsets for LVM Information Sector.
190; These are relative to the start of the LVM sector.
191LocLVM_SignatureStart equ 00h ; 02h,'RMBPMFD' (8 bytes)
192LocLVM_CRC equ 08h ; CRC is a DWORD
193LocLVM_Heads equ 1ch ; Number of heads
194LocLVM_Secs equ 20h ; Sectors per Track
195LocLVM_DiskName equ 24h ; Name of the disk
196LocLVM_StartOfEntries equ 3ch ; (contains maximum of 4 entries)
197LocLVM_LenOfEntry equ 3ch ; Length of an LVM-entry
198
199; An LVM info-sector can contain information on max. 4 partitions.
200; All 4 entries will be used when there 4 primary partitions defined.
201; For logical partitions, the LVM info-sector is located below the start
202; of the logical partition and only one LVM entry is used in that logical
203; LVM info-sector.
204LocLVM_MaxEntries equ 4 ; Max entries in an LVM-sector
205
206
207; -----------------------------------------------------------------------------
208; LVM ENTRY
209; -----------------------------------------------------------------------------
210; Offsets for LVM entry.
211; These are relative to the start of the entry.
212LocLVM_VolumeID equ 00h ; DWORD
213LocLVM_PartitionID equ 04h ; DWORD
214LocLVM_PartitionSize equ 08h ; DWORD
215LocLVM_PartitionStart equ 0ch ; DWORD
216LocLVM_OnBootMenu equ 10h ; is on IBM BM Bootmenu
217LocLVM_Startable equ 11h ; is Startable (newly installed system)
218LocLVM_VolumeLetter equ 12h ; Drive Letter for partition (C-Z or 0)
219LocLVM_Unknown equ 13h ; unknown BYTE (can be used ?)
220LocLVM_InstallLetter equ 13h ; unknown BYTE (can be used ?)
221
222; Truncated to 11 chars when displayed in menu.
223; MiniLVM sets both to the same value.
224; Also, MiniLVM uses a 0-byte terminator, so the maximum length is 19d.
225; Same goes for LocLVM_DiskName.
226; These offsets are relative to an LVM entry.
227LocLVM_VolumeName equ 14h ; 20 bytes
228LocLVM_PartitionName equ 28h ; 20 bytes (Used in menu)
229
230; LVM constants.
231LocLVM_LabelLen equ 14h ; Length of LVM Label (Disk/Part/Vol)
232LocLVM_DiskNameLen equ 14h ; Length of LVM DiskName
233LocLVM_VolumeNameLen equ 14h ; Length of LVM VolumeName
234LocLVM_PartitionNameLen equ 14h ; Length of LVM PartitionName
235
236
237; -----------------------------------------------------------------------------
238; AiR-BOOT IPT
239; -----------------------------------------------------------------------------
240; Offsets for IPT (Internal Partition Table)
241LocIPT_MaxPartitions equ max_partitions ; 45 in v1.07+
242LocIPT_LenOfSizeElement equ 6 ; Size of one Size-Element
243LocIPT_LenOfIPT equ 34 ; Length of an IPT-entry
244LocIPT_Serial equ 0 ; Serial from MBR ?
245LocIPT_Name equ 4 ; Name from FS or LVM (part/vol)
246LocIPT_Drive equ 15 ; Drive-ID (80h,81h)
247LocIPT_SystemID equ 16 ; Partition-Type (06,07,etc)
248LocIPT_Flags equ 17 ; AiR-BOOT Flags for part (see below)
249LocIPT_BootRecordCRC equ 18 ; CRC of Boot-Record
250LocIPT_LocationBegin equ 20 ; Begin of Partition
251LocIPT_LocationPartTable equ 23 ; PartitionTable of Partition
252LocIPT_AbsoluteBegin equ 26 ; Absolute Sector of Begin
253LocIPT_AbsolutePartTable equ 30 ; Absolute Sector of PartTable
254
255
256; AiR-BOOT IPT-Flags
257LocIPT_DefaultFlags equ 00000011b ; Don't know if boot-able :)
258LocIPT_DefaultNonBootFlags equ 00000010b ; VIBR Detection is always on
259
260Flags_Bootable equ 00000001b
261Flags_VIBR_Detection equ 00000010b
262Flags_HideFeature equ 00000100b
263Flags_DriveLetter equ 00001000b ; OS/2 FAT16/HPFS only
264Flags_ExtPartMShack equ 00010000b ; Ext. Partition M$-Hack req ?
265Flags_NoPartName equ 01000000b
266Flags_NowFound equ 10000000b ; temp only in OldPartTable
267Flags_SpecialMarker equ 10000000b ; temp only for HiddenSetup
268
269FileSysFlags_BootAble equ 00000001b ; Is this Partition boot-able ?
270FileSysFlags_FAT32 equ 00010000b ; FAT 32 specific name getting
271FileSysFlags_NoName equ 00100000b ; No Name - use PartitionName
272FileSysFlags_DriveLetter equ 01000000b ; DriveLetter Feature possible
273
274
275; -----------------------------------------------------------------------------
276; AiR-BOOT HPT
277; -----------------------------------------------------------------------------
278; Hidden Partition Table
279; Length of an HPT-entry ((45 * 6 bits-per-part) / 8) * 45
280; 33.75 = 34 bytes for HPT-entry, coincidently same as length of IPT-entry.
281; Packed table !
282LocHPT_LenOfHPT equ 34
283
284
285; -----------------------------------------------------------------------------
286; NAVIGATION KEYS
287; -----------------------------------------------------------------------------
288; Navigation keys
289Keys_Up equ 48h
290Keys_Down equ 50h
291Keys_Left equ 4Bh
292Keys_Right equ 4Dh
293Keys_PageUp equ 49h
294Keys_PageDown equ 51h
295Keys_GrayPlus equ 4Eh
296Keys_GrayMinus equ 4Ah
297Keys_Plus equ 1Bh
298Keys_Minus equ 35h
299Keys_ENTER equ 1Ch
300Keys_ESC equ 1h
301Keys_F1 equ 3Bh
302Keys_F10 equ 44h
303Keys_C equ 2Eh ; Add. Check for Ctrl!
304Keys_Y equ 2Ch
305Keys_Z equ 15h
306Keys_N equ 31h
307Keys_TAB equ 0Fh
308Keys_Delete equ 53h
309Keys_Backspace equ 0Eh
310Keys_Space equ 20h
311
312Keys_Flags_EnterSetup equ 1100b ; Strg+Alt (AL)
313
314
315; -----------------------------------------------------------------------------
316; MISC
317; -----------------------------------------------------------------------------
318; Initial value for the FreeDriveletterMap
319; Meaning A,B not free; C-Z free, rest unused. (right to left)
320; Each partition with an assigned drive-letter clears a bit in this map.
321; (Not implemented yet)
322InitialFreeDriveletterMap equ 00000011111111111111111111111100b
323
324;
325; The first harddisk is BIOS coded 80h.
326; This makes a total of 128 disks that could be supported using this coding.
327; This value is used to store disk-information and this info is allocated
328; in the BSS. 64 disks ought to be enough for everybody :-)
329;
330MaxDisks equ 64
331
332
333
334
335
336
337;##############################################################################
338; AiR-BOOT / MAIN-CODE
339;##############################################################################
340
341;
342; Because of the TASM-bug the processor had to be changed to turn JUMPS
343; off. Existing movzx instructions were replaced with 286 equivalent code.
344; Out of range relative jumps have been recoded.
345;
346; Since version 1.0.8, JWasm is the preferred assembler and Tasm will be
347; dropped. Also, the chances of AiR-BOOT being used on a 286-machine are
348; very slim, so a future version will revert back to .386 and also incorporate
349; 32-bit code. This will enable some enhanced constructs such as scaled
350; indexing, bit-instructions, 32-bit registers and what not.
351;
352.286
353
354;
355; For Tasm, MODEL is needed for the USES directive to work.
356; So always use a model when assembling with Tasm otherwise registers on
357; function calls that use USES are not saved and restored.
358; The model itself, has no real effect because we generate a binary image
359; and not a segmented executable.
360; For the other assemblers we define no model to get rid of the default C/C++
361; segments for future object-linked versions of AiR-BOOT.
362;
363IFDEF TASM
364 ;~ .model large, basic
365 .model tiny,c
366ENDIF
367
368;
369; The below is used to switch between the original 1-segment (code_seg) layout
370; and the new 2-segment (code_seg and bss_data) layout.
371; It will be removed in future versions.
372; The 2-segment layout was needed for JWasm because it does not treat
373; db ? at the end of a code segment as bss-data.
374; Therefore, a true BSS segment is now used.
375; Both the code_seg and the bss_data are grouped to the logical AIRBOOT
376; segment.
377; Note that this influences the offsets in the BSS in the list-file and
378; the wdis disassembly file (.WDA).
379; They are now segment-relative. The true offset is resolved at link
380; time.
381;
382SEGMENTED EQU
383
384 IFDEF SEGMENTED
385 AIRBOOT GROUP LDRIMAGE,VOLATILE
386 ENDIF
387
388 ; Our code-segment starts here.
389 LDRIMAGE SEGMENT USE16 PUBLIC 'CODE'
390
391 IFDEF SEGMENTED
392 ASSUME CS:AIRBOOT, DS:AIRBOOT, ES:nothing, SS:nothing
393 ELSE
394 ASSUME CS:LDRIMAGE,DS:LDRIMAGE,ES:nothing, SS:nothing
395 ENDIF
396
397
398
399;==============================================================================
400; Sector 1
401;==============================================================================
402
403;------------------------------------------------------------------------------
404 ; We are not a .COM file at 100h but a BINARY image
405 ; of which only the 1st sector gets loaded at 0000:07c00h
406 ; by the BIOS. The code in this 1st sector is position
407 ; independent and moves itself to a new location at 8000:0000h.
408 ; Then it jumps to a new entry-point and loads the rest of
409 ; the image to the new location.
410 org 00000h
411;------------------------------------------------------------------------------
412
413
414;
415; Since AiR-BOOT is a boot-loader residing in track0, the first 512 bytes
416; have the layout of a Master Boot Record (MBR). When AiR-BOOT get's installed,
417; the first 512 bytes of this code get's merged with the Partition Table.
418; The rest is installed in the remaining sectors with sector 62 (LBA 61)
419; being the last sector used by AiR-BOOT. Sector 63 is reserved for IBM LVM.
420; The last sector used by AiR-BOOT is a copy of the MBR that AiR-BOOT makes
421; every time a system gets booted.
422;
423
424;
425; Due to the addition of an extra 'I13X' sugnature and code to preserve the
426; values of the registers on entry, the MBR-code has become a bit messy.
427; This will be cleaned-up in future versions.
428;
429
430;
431; Martin had a short jump followed by the AiRBOOT signature at first.
432; Then he encountered strange behaviour by some M$ operating-systems
433; if the the first insruction was not a CLI.
434; But there was no room to insert the CLI and of course he did not want to
435; change the location of the AiR-BOOT signature.
436; He solved this by inserting the M$ needed CLI at offset 0 followed by a short
437; jump that uses the 'A' of the AiR-BOOT signature as the jump displacement.
438;
439
440
441; -----------------------------------------------------------------------------
442; FIRST ENTRY-POINT
443; -----------------------------------------------------------------------------
444; BOOKMARK: FIRST ENTRY-POINT (Invoked by BIOS)
445; ######################################################
446; # ENTRY-POINT WHERE THE BIOS TRANSFERS CONTROL TO US #
447; ######################################################
448AiR_BOOT:
449 ; Some M$ operating systems need a CLI
450 ; here otherwise they will go beserk
451 ; and will do funny things during
452 ; boot phase, it's laughable!
453 MBR_1stOpc: cli
454
455 ; JMP-Short -> MBR_Start
456 ; Uses the 'A' from the signature as the displacement !
457 MBR_JmpOpc db 0EBh
458
459 ; ID String, Date (DD,MM,CC,YY), Version Number, Language ID
460 ;~ db 'AiRBOOT',24h,02h,20h,12h,01h,08h,TXT_LanguageID
461 MBR_ABSig: InsertAirbootSignature TXT_LanguageID
462
463 ; Total Code Sectors Count.
464 ; Actual value will be inserted by FIXCODE.
465 MBR_CodeSecs db 1
466
467 ; Total Code Sectors Count, dynamically calculated.
468 ;~ db (code_end-$)/512
469
470 ; Check-Sum for Code
471 MBR_CheckCode dw 0
472
473
474
475; -----------------------------------------------------------------------------
476; THIRD ENTRY-POINT
477; -----------------------------------------------------------------------------
478; BOOKMARK: THIRD ENTRY-POINT (Relocate code)
479;
480; No single instruction below should be changed, added or removed in the code
481; below as this will cause the jump-link to go haywire.
482;
483MBR_Start:
484 ;
485 ; When we arrive here, no registers have been used yet.
486 ; So, they still contain the values the BIOS left in them.
487 ; We want to preserve those value's for later inspection
488 ; by putting them on the stack.
489 ;
490
491 ; No space for this instruction here.
492 ; We'll enable interrupts later.
493 ;sti ; This opcode is dedicated to:
494 ; =MICROSOFT JUMP DEPARTMENT=
495
496 ; Push all registers with values provided by the BIOS
497 ; on the stack.
498 pusha
499
500 ;
501 ; Setup some base stuff
502 ; AX got loaded wrongly for debug, changed the instructions
503 ; without modifying the number of bytes.
504 ; Don't comment-out the redundant instruction below because it
505 ; *will* change the number of bytes and break the jump-chain.
506 ;
507
508 ; The segment we are moving ourself from (NOT USED)
509 ;mov ax, StartBaseSeg
510 ;mov ds, ax
511
512 ; Make sure DS points to CS.
513 push cs
514 pop ds
515
516 ; Setup the source and destination for the code move.
517 mov si, StartBasePtr ; The offset we move ourself from
518 mov ax, BootBaseSeg ; The target segment we move to
519 mov es, ax
520 ;mov di, BootBasePtr ; The target offset we move to
521 ; Changed the instruction to make room.
522 ; So, BootBasePtr is not used !
523 ; The offset in the target segment is assumed to be 0000
524 ; anyway.
525 xor di,di
526 ;sti
527
528 ; Size of the MBR in words.
529 mov cx, 256 ; Pre-boot environment
530
531 ;
532 ; This moves this 512-byte sector, loaded by the BIOS at
533 ; 0000:7c00 to 8000:0000.
534 ;
535 cld
536 rep movsw
537
538 ; Temporary save SS and SP so we still have access to this
539 ; stack after we have setup our own.
540 mov cx,ss
541 mov bx,sp
542
543 ; Code an intersegment jump to the new location.
544 ; jmp BootBaseSeg:BootBaseExec
545 ; Note that DX:BX containts the old SS:SP.
546 db 0EAh
547 dw BootBaseExec ; This is MBR_RealStart + BootBasePtr
548 dw BootBaseSeg ; This is 08000h
549
550
551
552
553; -----------------------------------------------------------------------------
554; SIMPLE MBR FUNCTIONS
555; -----------------------------------------------------------------------------
556;
557; Some MBR-functions to provide absolute minimum functionality.
558;
559
560;
561; BOOKMARK: Halt System
562; Entry-point for halting the system.
563;
564MBR_HaltSystem:
565 mov ax, 8600h
566 xor cx, cx
567 mov dx, 500
568 int 15h ; Wait to display the whole screen :]
569MBR_HaltSys:
570 ;~ cli
571 jmp MBR_HaltSys
572
573
574 ; Base of some MBR variables
575 ORIGIN 0003Ch
576
577MBR_Variables:
578
579; Comport settings.
580; It had to be moved to create room for the double I13X signature.
581; It cannot be in the config-area (sector 55)
582; because that area is crc-protected and would not allow 'poking'.
583BIOS_AuxParms dw BIOS_AUXPARMS_DEFAULT
584
585; When the BIOS turns over control to the MBR, DL holds the BIOS disk-number
586; from which the boot was initiated. This would normally be 80h, corresponding
587; to the first physical disk. However, some modern BIOSses can directly boot
588; from other disks, so AirBoot cannot assume being loaded from 80h anymore.
589; So here we store the BIOS disk-number passed in DL when AirBoot got control.
590BIOS_BootDisk db BIOS_BOOTDISK_DEFAULT ; Get overwritten with 'DL'
591
592; Reserved space for future variables.
593IFDEF AUX_DEBUG
594reserved db 5 dup('X')
595ELSE
596reserved db 5 dup(0)
597ENDIF
598
599
600
601
602; -----------------------------------------------------------------------------
603; SECOND ENTRY-POINT
604; -----------------------------------------------------------------------------
605
606 ;
607 ; We arrive here after the first jump using the 'A' of the
608 ; AiR-BOOT signature. So we ensure the jump is always at
609 ; this offset. We jump here, because Martin needed to
610 ; insert a CLI on start and did not want to change the
611 ; AiR-BOOT signature because of Microsoft inventions...
612 ;
613 ORIGIN 00044h
614
615 ; Jump again...
616 ; This time to the code that relocates to 8000:0000.
617 ; BOOKMARK: SECOND ENTRY_POINT (Skipped over AB signature)
618 jmp MBR_Start
619
620;
621; Entry-point when loading fails.
622;
623 db 'LOAD ERROR!', 0
624MBR_LoadError Proc Near
625 mov si, offset $-12
626 push cs
627 pop ds
628 call MBR_Teletype
629 MBRLE_Halt:
630 jmp MBRLE_Halt
631MBR_LoadError EndP
632
633;
634; Entry-point when saving fails.
635;
636 db 'SAVE ERROR!', 0
637MBR_SaveError Proc Near
638 mov si, offset $-12
639 push cs
640 pop ds
641 call MBR_Teletype
642 MBRSE_Halt:
643 jmp MBRSE_Halt
644MBR_SaveError EndP
645
646
647; Put text on the screen using the BIOS tele-type function.
648; No attributes like color are supported.
649; In: SI - Pointer to begin of string (EOS is 0)
650; Destroyed: SI
651MBR_Teletype Proc Near Uses ax bx cx
652 mov ah, 0Eh
653 mov bx, 7
654 MBRT_Loop:
655 lodsb
656 or al, al
657 jz MBRT_End
658 int 10h
659 jmp MBRT_Loop
660 MBRT_End:
661 ret
662MBR_Teletype EndP
663
664;
665; Rousseau: DO NOT ADD CODE TO THIS SECTION !
666;
667
668; In: BX - Base Check
669; DS:SI - Pointer to 512-byte-area to be included
670; Out: BX - Base Check Result
671; Destroyed: SI will get updated (+512)
672MBR_GetCheckOfSector Proc Near Uses ax cx
673 mov cx, 256
674 MBRGCOS_Loop:
675 lodsw
676 xor ax, 0BABEh
677 xor bx, ax
678 loop MBRGCOS_Loop
679 or bx, bx
680 jnz MBRGCOS_NoFixUp
681 mov bx, 1 ; dont allow 0, cause 0 == empty
682 MBRGCOS_NoFixUp:
683 ret
684MBR_GetCheckOfSector EndP
685
686
687
688
689
690
691; -----------------------------------------------------------------------------
692; ENTRY-POINT OF MOVED CODE
693; -----------------------------------------------------------------------------
694
695;
696; When we arrive here we are running at 8000:0000.
697; CX:BX contains the SS:SP of the old stack.
698;
699
700;
701; This is where the rest of AiR-BOOT gets loaded from track0.
702;
703; BOOKMARK: Running at relocated position (Load additional sectors)
704;------------------------------------------------------------------------------
705MBR_RealStart:
706 ;
707 ; Setup new stack and other segment registers.
708 ;
709 mov ax, StackSeg ; 07000h, below the moved code
710 mov ss, ax
711 mov sp, 7FFEh ; Even is better
712 push es ; ES holds segment where we moved to
713 pop ds ; Set DS=ES to Code Segment
714
715 ;
716 ; Push the old SS:SP which was saved in CX:BX on the new stack.
717 ;
718 push cx ; Old SS
719 push bx ; Old SP
720
721 ;
722 ; Store the BIOS disk-number AirBoot was loaded from.
723 ;
724 mov [BIOS_BootDisk], dl
725
726 ; Load the configuration-sectors from disk.
727 ; These are the main configuration sector and the various
728 ; tables that follow it upto but not including the MBR backup.
729 mov bx, offset Configuration ; Location in RAM
730 mov cx, 0037h ; Config sector is at 55d
731 mov al, (MBR_BackUpMBR - Configuration) / 200h
732 mov ah, 02h
733 ; DL is already loaded with BIOS disk-number
734 int 13h ; Call BIOS service
735 jnc MBR_ConfigCopy_NoError
736
737 ; Some error occured
738 MBR_ConfigCopy_LoadError:
739 jmp MBR_LoadError ; Will Abort BootUp
740
741 ; Load the code-sectors from disk.
742 ; [MBR_CodeSecs] is filled in by the FIXCODE helper that post
743 ; processes the AIRBOOT loader image after it has been built.
744 MBR_ConfigCopy_NoError:
745 mov bx, offset FurtherMoreLoad ; Directly after MBR
746 mov cx, 0002h ; Start at 2nd sector
747 mov al, [MBR_CodeSecs] ; Number of code sectors
748 mov ah, 02h ; Read sectors
749 ; DL is already loaded with BIOS disk-number
750 int 13h ; Call BIOS service
751 jnc MBR_RealStart_NoError
752
753 ; Some error occured
754 jmp MBR_LoadError ; Will Abort BootUp
755
756
757 ; I13X Signatures
758 ORIGIN 000d0h
759
760 ; [v1.05+]
761 ; Signature for IBM's LVM to detect our "powerful" features ;)
762 ;
763 ; [v1.0.8+]
764 ; Reworked MBR code to be able to create a
765 ; double 'I13X' signature.
766 ; MBR's created with LVM eCS v1.x have the signature at 0d5h
767 ; MBR's created with LVM eCS v2.x have the signature at 0d0h
768 ; See eCS bugtracker issue #3002
769 ;
770 ; Update: These are actually MOV EAX,'X31I' instructions
771 ; in the eCS LVM MBR-code. They are at different places in
772 ; the v1.x and v2.x LVM MBR-code. Other code might depend on
773 ; their presence. Let's protect their location.
774 db 'I13X',0,'I13X',0
775
776
777 MBR_RealStart_NoError:
778 ; Now Check Code with CheckSum
779 mov si, offset FurtherMoreLoad
780
781 ;movzx cx, bptr ds:[10h]
782 mov cl, ds:[10h]
783 mov ch,0
784
785 ; Claculate checksum
786 xor bx, bx
787 MBR_RealStart_CheckCodeLoop:
788 call MBR_GetCheckOfSector
789 loop MBR_RealStart_CheckCodeLoop
790
791 ; Verify checksum
792 cmp MBR_CheckCode, bx
793 ;~ je MBR_RealStart_CheckSuccess ; CRC verified
794 jmp MBR_RealStart_CheckSuccess ; Ignore CRC
795
796 ; Oops, checksum mismatch -- halt the system
797 mov si, offset TXT_ERROR_Attention
798 call MBR_Teletype
799 mov si, offset TXT_ERROR_CheckCode
800 call MBR_Teletype
801 mov si, offset TXT_ERROR_CheckFailed
802 call MBR_Teletype
803 jmp MBR_HaltSystem
804
805
806 ;
807 ; OK, all loading went fine so the rest of the code
808 ; is present now, so we jump to it.
809 ; The old SS:SP is still on the stack.
810 ;
811 MBR_RealStart_CheckSuccess:
812 jmp AiR_BOOT_Start
813
814
815
816
817
818;------------------------------------------------------------------------------
819include text/txtmbr.asm ; All translateable Text in MBR
820;------------------------------------------------------------------------------
821
822 ; Disk Signature
823 ORIGIN 001B8h
824
825
826 ; Disk Signature
827 ; Note that in an LVM 2.x MBR this collides
828 ; with the dummy PTE that it uses to look for IBM-BM
829 ; on the second harddisk.
830 ; AiR-BOOT installer will merge the field
831 ; from the MBR it replaces.
832 MBR_DrvSig db 'DSIG'
833
834 ; Unused word at 01BCh.
835 ; An LVM 2.x MBR puts 0CC33h here.
836 ; AiR-BOOT installer will merge the field
837 ; from the MBR it replaces.
838 MBR_Spare dw '$$'
839
840
841 ; Partition Table.
842 ORIGIN 001BEh
843
844 ; The 4 entries just for show.
845 ; AiR-BOOT installer will merge them from the MBR it replaces.
846 MBR_PartTable:
847 db 16 dup('0')
848 db 16 dup('1')
849 db 16 dup('2')
850 db 16 dup('3')
851
852 ; Boot Sigbature
853 MBR_Sig dw 0aa55h
854
855
856
857
858
859
860
861;==============================================================================
862; Sector 2
863;==============================================================================
864
865; -----------------------------------------------------------------------------
866; FILE-SYSTEM TABLES
867; -----------------------------------------------------------------------------
868
869 ; First sector the rest of the loader image
870 ORIGIN 00200h
871
872;
873; Everything beyond this point is loaded on startup
874; and is NOT existant at first
875;
876FurtherMoreLoad:
877
878;
879; Filesystem table correlating id with name.
880;
881
882 ; first Normal-Partition-ID, Hidden-Partition-ID
883 ; and Default-Partition-Flags.
884 ; 01h -> Boot-Able
885 ; 10h -> FAT32 - Name Getting Scheme
886 ; 20h -> No Name To Get (use Partition Name from IPT)
887 ; 40h -> 'L' flag possible
888 db 'AiRSYS-TABLE'
889FileSysIDs db 01h, 11h,01h, 04h,014h,01h, 06h,016h,41h, 0Eh,00Eh,01h
890 db 07h, 17h,41h, 08h,017h,21h, 35h,035h,20h,0FCh,017h,41h
891 db 09h, 19h,11h, 0Bh,01Bh,11h, 0Ch,01Ch,11h,0EBh,0EBh,01h
892 db 63h, 63h,21h, 81h,081h,21h, 83h,083h,21h, 40h,040h,21h
893 db 0A5h,0A5h,21h,0A6h,0A6h,21h, 82h,082h,20h,0A7h,0A7h,21h
894 db 63h, 63h,21h, 4Dh,04Dh,21h, 4Eh,04Eh,21h, 4Fh,04Fh,21h
895 db 01h, 01h,01h, 01h,001h,01h, 01h,001h,01h, 01h,001h,01h
896 db 01h, 01h,01h, 01h,001h,01h, 01h,001h,01h, 01h,001h,01h
897 db 01h, 01h,01h, 01h,001h,01h, 01h,001h,01h, 01h,001h,01h
898 db 01h, 01h,01h,0FDh,0FDh,20h, 84h,084h,20h,0A0h,0A0h,20h
899 db 0Ah, 0Ah,20h,0FEh,0FEh,21h,0FFh,0FFh,21h, 00h,000h,21h
900 db 16 dup (0)
901
902FileSysNames db 'FAT12 ', 'FAT16 ', 'FAT16Big', 'FAT16Big'
903 db 'HPFS ', 'NTFS ', 'LVM-Data', 'JFS '
904 db 'FAT32 ', 'FAT32 ', 'FAT32 ', 'BeOS '
905 db 'Unix ', 'Minix ', 'Linux ', 'Venix ' ; x row ;)
906 db 'BSD/386 ', 'OpenBSD ', 'LinuxSwp', 'NeXTSTEP'
907 db 'GNU HURD', 'QNX ', 'QNX ', 'QNX '
908 db ' ', ' ', ' ', ' '
909 db ' ', ' ', ' ', ' '
910 db ' ', ' ', ' ', ' '
911 db ' ', 'Kernel ', ' ', '0V-Award'
912; db 'OS/2 Man', 'via BIOS', 'Floppy ', 'Unknown '
913 db 'OS2-BMGR', 'via BIOS', 'Floppy ', 'Unknown '
914 ; -> 44 Partition-Types
915
916
917
918
919
920
921;==============================================================================
922; Sector 3
923;==============================================================================
924
925; -----------------------------------------------------------------------------
926; ENTRY-POINT AFTER LOADING THE REST OF THE CODE
927; -----------------------------------------------------------------------------
928
929 ; The entry-point jumped to from the MBR code
930 ORIGIN 00400h
931
932
933;##############################################################################
934;# AiR_BOOT_Start :: This is where the real work begins #
935;# -------------------------------------------------------------------------- #
936;# At this point, all of AirBoot is loaded, including its configuration. #
937;# First, some setup is done, which includes the initialization of variables #
938;# in the BSS. After that, disks are scanned for partitions and the required #
939;# house keeping is done to incorporate changes from the previous boot. Then #
940;# the partition list is prepared and the menu is presented. #
941;##############################################################################
942; BOOKMARK: AiR_BOOT_Start (AiR-BOOT now completely loaded)
943AiR_BOOT_Start:
944
945
946 ;
947 ; Enable interrupts.
948 ;
949 sti
950
951 ;
952 ; Pop the old SS:SP from the stack and save it in the BSS.
953 ; Note that this is outside the normal variable area that gets cleared.
954 ; This allows AiR-BOOT to restart itself when debugging and come-up
955 ; with access to the original values of registers the BIOS passed.
956 ;
957 pop [OldSP]
958 pop [OldSS]
959
960
961 ; Verify we still got the BIOS disk in DL
962 IFDEF AUX_DEBUG
963 mov ax, dx
964 call AuxIO_TeletypeHexWord
965 call AuxIO_TeletypeNL
966 mov ax, bx
967 call AuxIO_TeletypeHexWord
968 call AuxIO_TeletypeNL
969 xor ah, ah
970 mov al, [BIOS_BootDisk]
971 call AuxIO_TeletypeHexWord
972 call AuxIO_TeletypeNL
973 ENDIF
974
975; -----------------------------------------------------------------------------
976; IBM-BM BOOT PREPARATION
977; -----------------------------------------------------------------------------
978 ;
979 ; Since v1.0.8, AiR-BOOT is able to chainload IBM-BM.
980 ; When IBM-BM resides above the 1024-cylinder limit, the 'I13X'
981 ; signature is required at 3000:0000, FS needs to contain 3000h
982 ; and the 32-bit LBA address needs to follow the 'I13X' signature.
983 ; For booting IBM-BM from the second disk, a copy of the MBR of the
984 ; first disk is also required at 0000:7E00.
985 ; This information is derived from the eCS 2.x LVM MBR.
986 ;
987 ; So, now is a good time to copy the MBR of the first disk to
988 ; 0000:7E00 in case the partition that will be started is IBM-BM.
989 ; This copy is located at 8000:0000 and DS already points to this
990 ; segment. The 'I13X' signature and FS will be setup later.
991 ;
992 pusha ; Save all the general purpose regs
993 push es ; We need ES too, so save its value
994 xor ax,ax ; Segment 0000h
995 mov es,ax ; Make ES point to it
996 mov si,offset BootBasePtr ; Start of AiR-BOOT which has the MBR
997 mov di,7e00h ; Destination for the MBR for IBM-BM
998 mov cx,100h ; 256 words = 512 bytes
999 cld ; Direction from low to high
1000 rep movsw ; Copy the 256 words of the MBR
1001 pop es ; Restore previous value of ES
1002 popa ; Restore all the general purpose regs
1003
1004
1005; -----------------------------------------------------------------------------
1006; PRECRAP
1007; -----------------------------------------------------------------------------
1008
1009 ;
1010 ; First it clears the BSS area.
1011 ; Note that the old SS:SP is stored outside this area so this
1012 ; does not get lost.
1013 ; Then initialize various runtime variables and structures.
1014 ;
1015 ; BOOKMARK: Pre Crap
1016 call PRECRAP_Main
1017 ; Number of harddisks and other system-info is now known.
1018
1019 ;!
1020 ;! DEBUG_BLOCK
1021 ;! Let's see what the BIOS supplied us with...
1022 ;! Uncomment below to activate.
1023 ;!
1024 __DUMP_BIOS_REGS__ EQU
1025 IFDEF AUX_DEBUG
1026 IFDEF __DUMP_BIOS_REGS__
1027 pushf
1028 pusha
1029 ; Print title.
1030 mov si,offset [bios_reg]
1031 call AuxIO_Print
1032 ; Save the current stack (SS:SP).
1033 mov ax,ss
1034 mov [CurrentSS],ax
1035 mov [CurrentSP],sp
1036
1037 ; Restore the old stack.
1038 mov ss,[OldSS]
1039 mov sp,[OldSP]
1040
1041 ; Pop the registers with the BIOS values.
1042 popa
1043 ; Push them back for AiR-BOOT restart (debug mode).
1044 pusha
1045 ; Dump them to the serial-port.
1046 call DEBUG_DumpRegisters
1047 ; Restore the current stack.
1048 mov ax,[CurrentSS]
1049 mov ss,ax
1050 mov sp,[CurrentSP]
1051
1052 ; Restore registers.
1053 popa
1054 popf
1055 ENDIF
1056 ENDIF
1057
1058
1059 ;!
1060 ;! DEBUG_BLOCK
1061 ;! Dump the registers at this point.
1062 ;! Uncomment below to activate.
1063 ;!
1064 IFDEF AUX_DEBUG
1065 ;~ call DEBUG_DumpRegisters
1066 ; Dump drive-letters of dl-feature before partitions are
1067 ; scanned and processed.
1068 call DEBUG_DumpDriveLetters
1069 call DEBUG_DumpVolumeLetters
1070 call DEBUG_DumpPartitionXref
1071 ENDIF
1072
1073; -----------------------------------------------------------------------------
1074; PARTITION SCAN
1075; -----------------------------------------------------------------------------
1076
1077
1078
1079
1080
1081
1082 ;
1083 ; BOOKMARK: Scan all partitions
1084 ;
1085 call PARTSCAN_ScanForPartitions
1086 ; Internal Partition Table is now populated.
1087
1088 ;!
1089 ;! DEBUG_BLOCK
1090 ;! Dump various tables.
1091 ;! Uncomment below to activate.
1092 ;!
1093 IFDEF AUX_DEBUG
1094 ;~ call DEBUG_DumpIPT
1095 ;~ call DEBUG_DumpPartitionPointers
1096 ;~ call DEBUG_DumpNewPartTable
1097 ;~ call DEBUG_DumpDriveLetters
1098 call DEBUG_DumpDriveLetters
1099 call DEBUG_DumpVolumeLetters
1100 call DEBUG_DumpPartitionXref
1101 ENDIF
1102
1103
1104; -----------------------------------------------------------------------------
1105; RESTORE FORCED DRIVELETTER CORRELATION [LVM]
1106; -----------------------------------------------------------------------------
1107
1108 ;
1109 ; Reconnect forced drive-letters to their corresponding
1110 ; partitions.
1111 ;
1112 ; BOOKMARK: Update Driveletters so they are in-sync again
1113 call PARTSCAN_UpdateDriveLetters
1114 ; Driveletter <-> Partition correlation is now restored.
1115
1116
1117
1118 ;!
1119 ;! DEBUG_BLOCK
1120 ;! Dump various tables.
1121 ;! Uncomment below to activate.
1122 ;!
1123 IFDEF AUX_DEBUG
1124 ;~ call DEBUG_DumpIPT
1125 ;~ call DEBUG_DumpPartitionPointers
1126 ;~ call DEBUG_DumpNewPartTable
1127 ;~ call DEBUG_DumpDriveLetters
1128 call DEBUG_DumpDriveLetters
1129 call DEBUG_DumpVolumeLetters
1130 call DEBUG_DumpPartitionXref
1131 ENDIF
1132
1133
1134; -----------------------------------------------------------------------------
1135; SHOW WE ARE ALIVE
1136; -----------------------------------------------------------------------------
1137
1138 ;
1139 ; Put some info about AiR-BOOT and the system on the screen.
1140 ;
1141
1142 ; Display number of physical disks found
1143 mov si, offset DisksFound
1144 call MBR_Teletype
1145 mov al, [TotalHarddiscs]
1146 call VideoIO_SyncPos
1147 call VideoIO_PrintByteDynamicNumber
1148 xor si,si
1149 call MBR_TeletypeNL
1150
1151 ; Display number of partitions found
1152 mov si, offset PartitionsFound
1153 call MBR_Teletype
1154 mov al, [CFG_Partitions]
1155 call VideoIO_SyncPos
1156 call VideoIO_PrintByteDynamicNumber
1157
1158 ; Dump summier disk-info for disks found
1159 xor si,si
1160 call MBR_TeletypeNL
1161 call MBR_TeletypeNL
1162 call VideoIO_SyncPos
1163 mov dl,80h
1164 call VideoIO_DumpDiskInfo
1165
1166
1167
1168
1169
1170; -----------------------------------------------------------------------------
1171; eComStation PHASE1 CHECK
1172; -----------------------------------------------------------------------------
1173
1174 ;
1175 ; BOOKMARK: Check for OS/2 being installed
1176 ; Here we check if OS/2 is being installed.
1177 ; If so, we forgo the menu and directly boot it.
1178 ;
1179
1180 ; If the first byte of the name of the Install Volume is not 0
1181 ; then we potentially have a phase1 boot.
1182 test byte ptr [OS2_InstallVolume],0ffh
1183 ; Nope, so continue normally.
1184 jz MBR_Main_ContinueBoot
1185
1186 ; Setup phase1.
1187 ; It is still possible that a name was set for the
1188 ; Install Volume that does not exist.
1189 ; In that case CY will be clear and AL=0FFh.
1190 call PART_SetupPhase1
1191 ; Oops, Install Volume not found, continue normally.
1192 jnc MBR_Main_ContinueBoot
1193
1194
1195 ;
1196 ; == Install Volume Found ==
1197 ;
1198
1199
1200 ;!
1201 ;! DEBUG_BLOCK
1202 ;! Dump various tables.
1203 ;! Uncomment below to activate.
1204 ;!
1205 IFDEF AUX_DEBUG
1206 ;~ call DEBUG_DumpIPT
1207 ;~ call DEBUG_DumpPartitionPointers
1208 ;~ call DEBUG_DumpPartitionXref
1209 ;~ call DEBUG_DumpNewPartTable
1210 ;~ call DEBUG_DumpDriveLetters
1211 ENDIF
1212
1213
1214 ; BOOKMARK: Scan for Partitions (Only if OS/2 install going on)
1215 ; Because one or more partitions are possibly added, the
1216 ; PartitionXref table is not 'in sync' and could cause the
1217 ; wrong system to be automatically booted.
1218 ; So we rescan all partitions causing the PartitionXref
1219 ; table to be filled with correct values so the auto-boot
1220 ; from the new partition will work correctly.
1221 call PARTSCAN_ScanForPartitions
1222
1223
1224 ;!
1225 ;! DEBUG_BLOCK
1226 ;! Dump various tables.
1227 ;! Uncomment below to activate.
1228 ;!
1229 IFDEF AUX_DEBUG
1230 ;~ call DEBUG_DumpIPT
1231 ;~ call DEBUG_DumpPartitionPointers
1232 ;~ call DEBUG_DumpPartitionXref
1233 ;~ call DEBUG_DumpNewPartTable
1234 ;~ call DEBUG_DumpDriveLetters
1235 ENDIF
1236
1237 ; Setup automatic boot to forgo the Menu.
1238 ; PART_SetupPhase1 has filled in the other variables.
1239 mov byte ptr [CFG_AutomaticBoot],1
1240
1241 ;
1242 ; At this point the AiR-BOOT configuration has been altered
1243 ; to automatically boot the newly installed system without
1244 ; displaying the menu.
1245 ; Code further down the road will take care of that.
1246 ;
1247 jmp MBR_Main_ContinueBoot
1248
1249
1250
1251
1252 ;
1253 ; Wether a new system is being installed or not,
1254 ; booting continues here.
1255 ;
1256 MBR_Main_ContinueBoot:
1257
1258 ;
1259 ; Inform user how to switch between post-screen and menu
1260 ; by putting this info on the screen.
1261 ;
1262 xor si,si
1263 call MBR_TeletypeNL
1264 xor si,si
1265 call MBR_TeletypeNL
1266 call MBR_TeletypeSyncPos
1267 xor si,si
1268 call MBR_TeletypeNL
1269 call MBR_TeletypeNL
1270 mov si, offset ShowMenu
1271 call MBR_TeletypeBold
1272
1273
1274 ;
1275 ; Debug stop.
1276 ;
1277
1278 ;
1279 ; ####################### WAIT FOR KEY ########################
1280 ;
1281
1282 ; Wait for key so we can see debug log if ab-menu hangs.
1283 ;~ xor ax, ax
1284 ;~ int 16h
1285 ;call SOUND_Beep
1286
1287
1288 ; Copy BIOS POST to Second Page
1289 mov ax, VideoIO_Page1
1290 call VideoIO_BackUpTo
1291
1292 ;call SOUND_Beep
1293
1294
1295 ; BOOKMARK: Save Configuration
1296 ; Save configuration so phase1 boot-through is disabled
1297 ; on next boot.
1298 mov byte ptr [OS2_InstallVolume], 0
1299 call DriveIO_SaveConfiguration
1300
1301
1302
1303 ;
1304 ; See if setup needs to be entered.
1305 ;
1306 MBR_Main_ReEnterSetup:
1307 call SETUP_CheckEnterSETUP
1308
1309 ;
1310 ; Do some post processing.
1311 ;
1312 ; BOOKMARK: After Crap
1313 call AFTERCRAP_Main
1314
1315 MBR_Main_ReEnterBootMenuPre:
1316 ; SetUp PartitionPointers for BootMenu (filter non-bootable)
1317 call PART_CalculateMenuPartPointers
1318
1319 ; ...and count that one...
1320 cmp byte ptr [PartitionPointerCount], 0
1321 jne MBR_Main_SomethingBootAble
1322 mov si, offset TXT_NoBootAble
1323 call MBR_Teletype
1324 jmp MBR_HaltSystem
1325
1326 MBR_Main_SomethingBootAble:
1327 ; FixUp Values, define Timed Setup booting, etc.
1328 call PART_FixUpDefaultPartitionValues
1329
1330
1331
1332 ; -------------------------------------------------- BOOT-MENU
1333 MBR_Main_ReEnterBootMenu:
1334 call BOOTMENU_ResetMenuVars ; reset has to be done
1335 test byte ptr [CFG_AutomaticBoot], 1
1336 jz MBR_Main_NoAutomaticBooting
1337
1338
1339 ; ------------------------------------------ AUTOMATIC BOOTING
1340 ; Select automatic partition, disable automatic booting for
1341 ; next time and boot system...
1342 mov byte ptr [CFG_AutomaticBoot], 0
1343 call PASSWORD_AskSystemPwd
1344 mov al, Menu_EntryAutomatic
1345
1346 ;mov al, 2
1347
1348 mov Menu_EntrySelected, al ; zero based
1349 jmp MBR_Main_NoBootMenu
1350
1351
1352 MBR_Main_NoAutomaticBooting:
1353
1354 ;call SOUND_Beep
1355
1356 test byte ptr [CFG_BootMenuActive], 0FFh
1357 jnz MBR_Main_GotBootMenu
1358 ; ----------------------------------------------- NO BOOT-MENU
1359 ; Select default partition and boot system...
1360 call PASSWORD_AskSystemPwd
1361
1362 ;call VideoIO_DBG_WriteString2
1363
1364 mov al, Menu_EntryDefault
1365 ;mov al,0 ; zero based
1366 mov Menu_EntrySelected, al
1367 jmp MBR_Main_NoBootMenu
1368
1369 MBR_Main_GotBootMenu:
1370 ; ------------------------------------------ BOOT-MENU VISUALS
1371
1372
1373 IFDEF FX_ENABLED
1374 call FX_StartScreen
1375 ENDIF
1376
1377 ; BOOKMARK: Build Main Menu
1378 call BOOTMENU_BuildBackground
1379 call BOOTMENU_BuildMain
1380
1381 IFDEF FX_ENABLED
1382 call FX_EndScreenRight
1383 ENDIF
1384
1385 call PASSWORD_AskSystemPwd
1386 call BOOTMENU_ResetTimedBoot
1387
1388 ; BOOKMARK: Display Main Menu
1389 call BOOTMENU_Execute
1390
1391 jc MBR_Main_ReEnterSetup
1392 call BOOTMENU_SetVarsAfterMenu
1393
1394 ; ---------------------------------------------------- BOOTING
1395 MBR_Main_NoBootMenu:
1396
1397 IFDEF FX_ENABLED
1398 call FX_StartScreen
1399 ENDIF
1400
1401 ; BOOKMARK: Display bye-screen and start selected partition
1402 call BOOTMENU_BuildGoodBye
1403
1404 IFDEF FX_ENABLED
1405 call FX_EndScreenRight
1406 ENDIF
1407
1408 call PASSWORD_AskChangeBootPwd
1409
1410 call ANTIVIR_SaveBackUpMBR
1411
1412 ; Preload the selected menu-entry
1413 ; However, this value will be wrong if OS/2 phase1 is
1414 ; active and the installation partition is newly created.
1415 ; See below for the adjustment.
1416 mov dl, byte ptr [Menu_EntrySelected]
1417
1418
1419 ;
1420 ; Prepare to start the partition.
1421 ;
1422 jmp MBR_Main_StartPartition
1423
1424
1425
1426; -----------------------------------------------------------------------------
1427; START PARTITION
1428; -----------------------------------------------------------------------------
1429
1430 MBR_Main_StartPartition:
1431
1432 IFDEF AUX_DEBUG
1433 ;~ call DEBUG_DumpIPT
1434 ;~ call DEBUG_DumpPartitionPointers
1435 ;~ call DEBUG_DumpPartitionXref
1436 ;~ call DEBUG_DumpNewPartTable
1437 ENDIF
1438
1439
1440 ; -------------------------------------------- START PARTITION
1441 ; THIS DOES NOT RETURN !
1442 call PART_StartPartition
1443
1444
1445
1446
1447;
1448; This entry-point restarts AiR-BOOT almost from scratch.
1449; It skips the movement of the MBR but otherwise it is a functional restart.
1450; The old BIOS SS:SP where the registers on entry are stored is passed along.
1451; This entry-point is used for debugging purposes.
1452;
1453; BOOKMARK: AiR-BOOT Restart (used for debugging)
1454AirbootRestart:
1455 mov bx, [OldSP] ; Old SP when BIOS transferred control to AB
1456 mov cx, [OldSS] ; Old SS when BIOS transferred control to AB
1457 xor dh, dh ; Head 0
1458 mov dl, [BIOS_BootDisk] ; Disk AirBoot was loaded from
1459 jmp MBR_RealStart
1460
1461
1462;
1463; This entry-point displays a popup that the system is halted
1464; and then halts the system.
1465; It is entered on severe error conditions.
1466;
1467; BOOKMARK: Halt System
1468HaltSystem:
1469 call VideoIO_ClearScreen
1470 mov ax,0ababh
1471 mov cx, 0C04h
1472 mov si, offset SystemHalted
1473 call SETUP_ShowErrorBox
1474 ; Halt the system.
1475 jmp MBR_HaltSystem
1476
1477
1478
1479
1480
1481
1482 ;
1483 ; The following section includes various assembler modules
1484 ; at the source level. These contain functionality for a
1485 ; multitude of categories like disk-access, video-io, lvm,
1486 ; debugging, etc. Later versions of AiR-BOOT will use such
1487 ; modules at the object-file level so they can be shared
1488 ; more easily.
1489 ;
1490
1491
1492; -----------------------------------------------------------------------------
1493; INCLUDED FILE SECTION
1494; -----------------------------------------------------------------------------
1495
1496; BOOKMARK: Include Section
1497
1498;
1499; Include other code-modules here.
1500;
1501
1502b_std_txt:
1503include regular/std_text.asm ; Standard (non-translateable text)
1504size_std_txt = $-b_std_txt
1505
1506b_driveio:
1507include regular/driveio.asm ; Drive I/O, Config Load/Save
1508size_driveio = $-b_driveio
1509
1510b_lvm:
1511include special/lvm.asm ; LVM-specific code
1512size_lvm = $-b_lvm
1513
1514b_videoio:
1515include regular/videoio.asm ; Video I/O
1516size_videoio = $-b_videoio
1517
1518b_timer:
1519include regular/timer.asm ; Timer
1520size_timer = $-b_timer
1521
1522b_partmain:
1523include regular/partmain.asm ; Regular Partition Routines
1524size_partmain = $-b_partmain
1525
1526b_partscan:
1527include regular/partscan.asm ; Partition Scanning
1528size_partscan = $-b_partscan
1529
1530b_bootmenu:
1531include regular/bootmenu.asm ; Boot-Menu
1532size_bootmenu = $-b_bootmenu
1533
1534b_password:
1535include regular/password.asm ; Password related
1536size_password = $-b_password
1537
1538b_other:
1539include regular/other.asm ; Other Routines
1540size_other = $-b_other
1541
1542b_main:
1543include setup/main.asm ; The whole AiR-BOOT SETUP
1544size_main = $-b_main
1545
1546b_math:
1547include regular/math.asm ; Math functions (like 32-bit multiply)
1548size_math = $-b_math
1549
1550b_txtother:
1551include text/txtother.asm ; All translateable Text-Strings
1552size_txtother = $-b_txtother
1553
1554b_txtmenus:
1555include text/txtmenus.asm ; All translateable Menu-text
1556size_txtmenus = $-b_txtmenus
1557
1558b_charset:
1559include text/charset.asm ; Special Video Charsets (if needed)
1560size_charset = $-b_charset
1561
1562b_conv:
1563include regular/conv.asm ; Various conversion routines
1564size_conv = $-b_conv
1565
1566b_virus:
1567include special/virus.asm ; Virus Detection / Anti-Virus
1568size_virus = $-b_virus
1569
1570b_billsuxx:
1571include special/f00k/billsuxx.asm ; Extended Partition - Microsoft-Hack
1572size_billsuxx = $-b_billsuxx
1573
1574b_sound:
1575include special/sound.asm ; Sound
1576size_sound = $-b_sound
1577
1578b_apm:
1579include special/apm.asm ; Power Managment Support
1580size_apm = $-b_apm
1581
1582
1583
1584;
1585; Cyrillic support.
1586;
1587IFDEF TXT_IncludeCyrillic
1588b_ccharset:
1589 include special/charset.asm ; Charset Support (e.g. Cyrillic)
1590size_ccharset = $-b_ccharset
1591ENDIF
1592
1593; Various debugging routines, uses AUXIO and CONV
1594IFDEF AUX_DEBUG
1595b_debug:
1596include regular/debug.asm ; Debug module
1597size_debug = $-b_debug
1598b_auxio:
1599include regular/auxio.asm ; Com-port support for debugging
1600size_auxio = $-b_auxio
1601ENDIF
1602
1603;
1604; We only include this if FX_ENABLED is defined.
1605; FX is disabled when debugging to have more room for debug-code.
1606; The module compiles to 50eh = 1294 bytes, so that is a lot.
1607;
1608IFDEF FX_ENABLED
1609b_fx:
1610include special/fx.asm ; l33t Cooper-Bars/Scrolling <bg>
1611size_fx = $-b_fx
1612ENDIF
1613
1614
1615 ;
1616 ; End of code marker.
1617 ;
1618 ; BOOKMARK: END OF CODE
1619 db 'BABE'
1620 db 'FACE'
1621
1622
1623; -----------------------------------------------------------------------------
1624; END OF CODE
1625; -----------------------------------------------------------------------------
1626code_end:
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637; -----------------------------------------------------------------------------
1638; BLDLEVEL INFORMATION
1639; -----------------------------------------------------------------------------
1640
1641 ; BOOKMARK: BLDLEVEL Information
1642 ORIGIN 068A0h
1643
1644;
1645; The space between this offset and code_end is the space
1646; available for code.
1647;
1648zzz_code_space = $ - code_end
1649
1650
1651bld_level:
1652 ;
1653 ; Here we insert the OS/2 BLDLEVEL Information.
1654 ; It is composed of the AiR-BOOT version-info and other
1655 ; information. It is unique for each release of AiR-BOOT.
1656 ;
1657
1658 ;
1659 ; ?? When AUX_DEBUG is enabled and the above org is active,
1660 ; the BLDLEVEL gets corrupted eventhough it gets inserted here
1661 ; explicitly. The effect is almost like an 'OR' or a merge
1662 ; with the already generated FX code.
1663 ; Tasm and JWasm produce different results.
1664 ; ??
1665 ;
1666 InsertBuildLevel
1667
1668
1669
1670
1671
1672;==============================================================================
1673; Sector 53
1674;==============================================================================
1675
1676 ;
1677 ; From here on, the layout of the image consists of:
1678 ; - AiR-BOOT Protection Image
1679 ; - AiR-BOOT Configuration
1680 ; - DriveLetters
1681 ; - Install Volume
1682 ; - Floppy/CDROM/BIOS BOOT ENTRIES
1683 ; - Internal Partition Table (IPT)
1684 ; - Hidden Partition Table (HPT)
1685 ; - MBR Backup
1686 ;
1687
1688 ;
1689 ; After that, the BSS follows with several runtime
1690 ; variables and structures.
1691 ; The BSS is not part of the image on disk of course.
1692 ;
1693
1694; -----------------------------------------------------------------------------
1695; PROTECTION IMAGE
1696; -----------------------------------------------------------------------------
1697
1698 ;
1699 ; This is the AiR-BOOT MBR Protection Image.
1700 ; The stuff generated here gets overwritten when the
1701 ; MBR_PROT module, which is assembled separately,
1702 ; gets binary merged.
1703 ; So you won't find the string below in the generated binary.
1704 ;
1705 ; BOOKMARK: AiR-BOOT MBR Protection Image
1706 ORIGIN 06900h
1707
1708
1709
1710
1711;
1712; Hardcoded to 768 bytes (MBR_PROT.ASM)
1713; The string below is searched for by the FIXCODE helper and *must* be
1714; page (256 bytes) aligned.
1715;
1716; It seems to be possible to shrink the protection-image to 768 bytes.
1717; That gives us an additional 256 bytes of code-space.
1718; MBR-PROT.ASM,FIXCODE.C,PARTMAIN.ASM and AIR-BOOT.ASM need to be adjusted for that.
1719; Also the granularity needs to change from 512 bytes to 256 bytes since
1720; 6900h is not a 512-byte boundary.
1721;
1722; 20120908 - Done.
1723;
1724MBR_Protection db 'AiR-BOOT MBR-Protection Image'
1725
1726 ; Just fill.
1727 ;~ db 1024-($-MBR_Protection) dup('M')
1728 db 768-($-MBR_Protection) dup('M')
1729
1730
1731
1732
1733
1734
1735
1736;==============================================================================
1737; Sector 55
1738;==============================================================================
1739; -----------------------------------------------------------------------------
1740; AiR-BOOT CONFIGURATION
1741; -----------------------------------------------------------------------------
1742
1743 ;
1744 ; This section contains the AiR-BOOT configuration.
1745 ; Note that it has a version that should be updated
1746 ; when stuff is added.
1747 ; Also add stuff to the end so that offsets of other
1748 ; variables remain vaild.
1749 ;
1750 ; BOOKMARK: AiR-BOOT Configuration Sector
1751 ORIGIN 06C00h
1752
1753Configuration:
1754 ; This is the signature for the AiR-BOOT Configuration.
1755 ; Note that this configuration section, like the code section,
1756 ; is CRC protected. This means that poking values in these
1757 ; sections on the disk will invalidate AiR-BOOT and cause it
1758 ; to halt. This is a protection method against other software
1759 ; modifying stuff in track 0.
1760 db 'AiRCFG-TABLE',0adh
1761 db 01h, 10h, 'U' ; "Compressed" ID String
1762 ; Version 1.02 was for code 1.06, 1.03 was internal
1763 ; and 1.04,1.05 and 1.06 do not exist.
1764 ;
1765 ; 1.07 was used with AB v1.07 and introduced the phase1
1766 ; system-name. For the rest it is compatible with v1.02.
1767 ;
1768 ; 1.0.8 is introduced with AB v1.0.8 and indicates the movement
1769 ; of several components and the packing of the hideparttable.
1770 ; The core configuration has not changed but the generated
1771 ; configuration has. The v1.0.8 installer handles upgrading.
1772 ;
1773 ; It has been decided that uneven minor numbers will be
1774 ; test-versions. Therefore v1.0.8 has been bumbed to v1.1.0.
1775 ;
1776 ; It is not required for the config to have the
1777 ; same version as the code, so in the future
1778 ; the code version might be higher than the
1779 ; config version if there are no changes to the latter.
1780 ;
1781
1782CFG_LastTimeEditLow dw 0 ; Last Time Edited Stamp (will incr every setup)
1783CFG_LastTimeEditHi dw 0 ; second 16 bit part...
1784
1785CFG_CheckConfig dw 0 ; Check-Sum for Configuration
1786
1787CFG_Partitions db 0 ; Count of partitions in IPT
1788CFG_MiscFlags db 1 ; Miscellaneous Flags (See EQUates)
1789CFG_PartDefault db 0 ; Default-Partition (Base=0)
1790
1791CFG_PartLast db 0 ; Which Partition was booted last time ? (Base=0)
1792CFG_TimedBoot db 0 ; Timed Boot Enable (for REAL Enable look TimedBootEnable)
1793CFG_TimedSecs db 15 ; Timed Boot - How Many Seconds Till Boot
1794CFG_TimedDelay dw 123 ; Timed Boot - Delay
1795CFG_TimedBootLast db 1 ; Timed Boot - Boot From Last Drive Booted From
1796CFG_RememberBoot db 1 ; Remember Manual Boot Choice
1797CFG_RememberTimed db 0 ; Remember if Timed Boot (if both disabled: Boot Default)
1798CFG_IncludeFloppy db 1 ; Include Floppy Drives in Boot-Menu
1799CFG_BootMenuActive db 1 ; Display Boot-Menu (if Disabled: Boot Default)
1800 ; v0.29+ -> 2 - Detailed Bootmenu
1801CFG_PartitionsDetect db 1 ; Autodetect New Partitions (Auto-Add!)
1802CFG_PasswordSetup db 0 ; Ask Password when entering Setup
1803CFG_PasswordSystem db 0 ; Ask Password when booting System
1804CFG_PasswordChangeBoot db 0 ; Ask Password when changing boot partition
1805CFG_ProtectMBR db 0 ; Protect MBR via TSR ?
1806CFG_IgnoreWriteToMBR db 0 ; Just ignore writes to MBR, otherwise crash
1807CFG_FloppyBootGetName db 0 ; Gets floppy name for display purposes
1808CFG_DetectVirus db 0 ; Detect Virus ?
1809CFG_DetectStealth db 0 ; Detect Stealth-Virus ?
1810CFG_DetectVIBR db 0 ; Detect BootRecord-Virus ?
1811CFG_AutoEnterSetup db 0 ; Automatic Enter Setup (first install!)
1812CFG_MasterPassword dw 0101Fh ; Encoded Password (this is just CR)
1813 dw 07A53h
1814 dw 0E797h
1815 dw 0A896h
1816CFG_BootPassword dw 0101Fh ; Another CR... ;-)
1817 dw 07A53h
1818 dw 0E797h
1819 dw 0A896h
1820 db 0 ; Rude-Protection - Removed since v0.28b
1821CFG_LinuxRootPartition db 0 ; Linux Root Partition (Base=0)
1822CFG_TimedKeyHandling db 0 ; Timed Key Handling (for Timed Boot)
1823 ; 0 - Do Nothing
1824 ; 1 - Reset Time
1825 ; 2 - Stop Time
1826CFG_MakeSound db 0 ; Should be clear ;)
1827CFG_FloppyBootGetTimer db 0 ; Floppy Name will get updated every 2 secs
1828CFG_ResumeBIOSbootSeq db 1 ; If BIOS Boot Sequence should be resumed
1829 ; 0 - Disabled
1830 ; 1 - CD-ROM
1831 ; 2 - Network
1832 ; 3 - ZIP/LS120
1833CFG_CooperBars db 0 ; If Cooper Bars should be shown
1834CFG_LinuxCommandLine db 75 dup (0) ; Linux Command Line
1835CFG_LinuxKrnlPartition db 0FFh ; FAT-16 Linux Kernel Partition (Base=0)
1836 ; FFh -> Disabled
1837CFG_LinuxDefaultKernel db 'DEFAULT', 4 dup (32), 0 ; Default Kernel Name
1838CFG_LinuxLastKernel db 11 dup (32), 0 ; Last-Booted Kernel Name
1839CFG_ExtPartitionMShack db 0 ; Extended Partition M$-Hack Global Enable
1840CFG_AutomaticBoot db 0 ; Automatic Booting (only one bootup)
1841CFG_PartAutomatic db 0 ; Partition-No for automatic booting
1842CFG_ForceLBAUsage db 1 ; LBA-BIOS-API forced on any HDD I/O
1843CFG_IgnoreLVM db 0 ; Ignores any LVM-Information
1844
1845
1846;
1847; THERE IS ROOM RESERVED HERE FOR MORE VARIABLES
1848;
1849
1850 ;
1851 ; Drive Letters.
1852 ;
1853 ; BOOKMARK: Stored Drive Letters
1854 ORIGIN 06CB0h
1855
1856
1857; -----------------------------------------------------------------------------
1858; DRIVE LETTERS
1859; -----------------------------------------------------------------------------
1860
1861;
1862; Moved here to make room for packed hiddenparttable.
1863; This gets filled with drive-letters that are assigned using the dl-feature.
1864;
1865DriveLetters db LocIPT_MaxPartitions dup (0)
1866 ; Format is:
1867 ;============
1868 ; Drive-Letter : BYTE (80h-C:, 81h-D:)
1869 ; --------------------> 1 Byte * 45
1870
1871
1872
1873; -----------------------------------------------------------------------------
1874; INSTALL VOLUME
1875; -----------------------------------------------------------------------------
1876
1877 ;
1878 ; Allways have the name of the installation volume
1879 ; at this offset.
1880 ; So future config changes will not break auto-install.
1881 ;
1882 ; BOOKMARK: Name of OS/2 Installation Volume
1883 ORIGIN 06D00h
1884
1885; SET(A)BOOT stores the volume name of the OS/2 system being installed here.
1886; It is truncated to 11 chars because AiR-BOOT currently does not support
1887; longer labelnames. The name is also capitalized.
1888OS2_InstallVolume db 0,'NOPHASEONE' ,0
1889
1890;
1891; THERE IS ROOM RESERVED HERE FOR MORE VARIABLES
1892;
1893
1894
1895; -----------------------------------------------------------------------------
1896; FLOPPY/CDROM/BIOS BOOT ENTRIES
1897; -----------------------------------------------------------------------------
1898
1899 ;
1900 ; 06DABh - 06C00h = 01ABh = 427 bytes.
1901 ; Entries allocated down from 06E00 boundary.
1902 ;
1903 ; BOOKMARK: Floppy/CD-ROM/BIOS Boot Entries
1904 ORIGIN 06DABh ; 427 Boundry
1905
1906; (432 - 5 = 427)
1907AutoDrvLetter db 0
1908AutoDrvLetterSerial dd 0
1909
1910; This entry is also 34 bytes long (466 - 34 = 432)
1911BIOScontIPTentry:
1912 db 0, 0, 0, 0, ' '
1913 db 0, 0FEh, Flags_Bootable
1914 dw 0 ; No Checksum :)
1915 db 0, 1, 0
1916 db 0, 1, 0 ; Location of Partition/Boot Record
1917 dd 0, 0
1918
1919; VIR variables are for the AiR-BOOT Anti Virus Code
1920; Most of them are backups of Interrupt Points, so we can check, if a
1921; stealth virus is on-line, we can intercept its call.
1922; Normal (non stealth) virus are trapped simply by rereading the MBR sector.
1923; If a virus is found, we will restore MBR from Sektor 60/62 and stop the
1924; system from working, so the user has to press reset.
1925; That's saver than a Reboot.
1926;
1927; If a virus is found on the partition to boot, the system will ONLY halt,
1928; nothing more, because we can not remove it. The user shall do it :)
1929; Those viruses are detected via a real nasty method...Checksum-Checking of the
1930; boot-record, which is to be executed. If it does not match the one in our
1931; internal partition table, we will stop. You may however switch this detection
1932; off or just reset it by switching 'VIBR Detection'.
1933
1934; 478 - 12 = 466 ; 466 Sub-Part
1935CFG_VIR_INT08 dd 0 ; pointer to saved 08h entry point
1936CFG_VIR_INT13 dd 0 ; pointer to saved 13h entry point
1937CFG_VIR_INT1C dd 0 ; pointer to saved 1Ch entry point
1938
1939; 478 Boundry (512-34)
1940; This entry is also 34 bytes long
1941FloppyIPTentry db 0, 0, 0, 0, 'FloppyDrive'
1942 db 0, 0FFh, Flags_Bootable
1943 dw 0 ; No Checksum :)
1944 db 0, 1, 0
1945 db 0, 1, 0 ; Location of Partition/Boot Record
1946 dd 0, 0
1947
1948
1949
1950; -----------------------------------------------------------------------------
1951; INTERNAL PARTITION TABLE (IPT)
1952; -----------------------------------------------------------------------------
1953
1954 ;
1955 ; AiR-BOOT Internal Partition Table (IPT)
1956 ;
1957 ; BOOKMARK: Internal Partition Table
1958 ORIGIN % (image_size - 0a00h - (image_size - image_size_60secs))
1959
1960
1961;
1962; Rousseau: This is the start of the AiR-BOOT IPT
1963;
1964PartitionTable db (LocIPT_MaxPartitions * LocIPT_LenOfIPT) dup (0)
1965; no-partitions detected... :]
1966; db 1, 0, 0, 0, 'Harddisc 1'
1967; db 0, 0FFh, Flags_BootAble
1968; dw 0 ; No Checksum :)
1969; db 0, 0, 1
1970; db 0, 0, 1 ; Location of Partition/Boot Record
1971; dd 0, 0
1972
1973 ; Format is:
1974 ;============
1975 ; SerialNumber * 4
1976 ; PartitionName * 11
1977 ; Drive * 1
1978 ; SystemID * 1 (means the partition type)
1979 ; Flags * 1
1980 ; Checksum * 2 (for virus checking)
1981 ; LocationBegin * 3 (where the partition begins)
1982 ; LocationPartTab * 3 (where the partition table is)
1983 ; AbsoluteBegin * 4 (where the partition begins, in absolute sectors)
1984 ; AbsolutePartTab * 4 (where the partition table is, in absolute sectors)
1985 ; --------------------> 34 Bytes (total maximum partition-entries = 30)
1986
1987
1988
1989 ; No need to check overlap here because this string will
1990 ; be overwritten if the maximum partition count is reached.
1991 ; So this is not a critical boundary.
1992 ORG (image_size - 600h - (image_size - image_size_60secs) / 2 - 10)
1993
1994 db 'AiRBOOTPAR' ; 1K internal partition table
1995
1996
1997
1998; -----------------------------------------------------------------------------
1999; HIDDEN PARTITION TABLE (HPT)
2000; -----------------------------------------------------------------------------
2001
2002 ;
2003 ; Hidden Partition Table (6-bit packed as of v1.0.8)
2004 ;
2005 ; BOOKMARK: Hidden Partition Table (packed)
2006 ORIGIN % (image_size - 600h - (image_size - image_size_60secs) / 2)
2007
2008HidePartitionTable db (LocIPT_MaxPartitions * LocHPT_LenOfHPT) dup (0FFh)
2009 ; Format is:
2010 ;============
2011 ; PartitionPtr : BYTE * 30
2012 ; --------------------> 30 Bytes * 45
2013
2014;
2015; Driveletters were here.
2016; Moved down to make room for packed hideparttable.
2017;
2018
2019
2020 ;
2021 ; End of hidden partition table.
2022 ; Check overlap here for security reasons.
2023 ;
2024 ORIGIN % (image_size - 200h - 5)
2025
2026; 79fa - end of packed hide table
2027 db 'ABHID' ; 1K internal Hide-partition table
2028
2029
2030
2031
2032;==============================================================================
2033; Sector 62
2034;==============================================================================
2035; -----------------------------------------------------------------------------
2036; MBR BACKUP
2037; -----------------------------------------------------------------------------
2038
2039 ;
2040 ; AiR-BOOT MBR Backup.
2041 ;
2042 ; BOOKMARK: MBR Backup
2043 ORIGIN % (image_size - 200h)
2044
2045
2046MBR_BackUpMBR db 'AiR-BOOT MBR-BackUp',\
2047 ' - Just to fill this sector with something',0
2048AirBootRocks db 'AiR-BOOT Rocks!',0
2049
2050 db (512 - ($-MBR_BackUpMBR) - 2) dup('M')
2051
2052 ; End of Image signature.
2053 ;
2054 ORIGIN % (image_size - 2)
2055 dw 0BABEh
2056
2057
2058 ;
2059 ; End of Image.
2060 ;
2061 ORIGIN % (image_size)
2062
2063
2064
2065;
2066; Terminate LDRIMAGE segment.
2067;
2068IFDEF SEGMENTED
2069LDRIMAGE ENDS
2070ENDIF
2071
2072
2073
2074
2075
2076
2077
2078;##############################################################################
2079; BSS SEGMENT
2080;##############################################################################
2081
2082; BOOKMARK: BSS Segment
2083
2084;
2085; Open BSS segment.
2086;
2087IFDEF SEGMENTED
2088VOLATILE SEGMENT USE16 PUBLIC 'BSS'
2089ENDIF
2090
2091
2092
2093sobss:
2094;------------------------------------------------------------------------------
2095
2096 ;
2097 ; Removed ORG for BSS data to be more compatible
2098 ; with segment-concatenated layout.
2099 ;
2100 ; What happens before this space ??
2101 ; If org 0 corruption occurs.
2102 ;
2103
2104 ;
2105 ; Filling hiddenparttable goes out-of-bounds !
2106 ; Fixed with 6-bit packing.
2107 ;
2108
2109;
2110; If segmented, offsets are relative to the BSS segment.
2111; They are resolved at link-time.
2112; If not segmented, offsets are relative to the CODE segment.
2113;
2114IFDEF SEGMENTED
2115 ORG 02400h
2116ELSE
2117 ORG 0A000h
2118ENDIF
2119
2120
2121; -----------------------------------------------------------------------------
2122; START OF BSS DATA
2123; -----------------------------------------------------------------------------
2124
2125; This space actually gets initialized in PreCrap to NUL (till EndOfVariables)
2126BeginOfVariables:
2127
2128
2129; -----------------------------------------------------------------------------
2130; SECTOR BUFFERS
2131; -----------------------------------------------------------------------------
2132; BOOKMARK: Sector Buffers
2133PartitionSector db 512 dup (?) ; Temporary Sector for Partition
2134PBRSector db 512 dup (?) ; Temporary Sector for JFS/HPFS writeback
2135LVMSector db 512 dup (?) ; Temporary Sector for LVM
2136TmpSector db 512 dup (?) ; Temporary Sector
2137Scratch db 512 dup (?) ; Scratch buffer
2138
2139; -----------------------------------------------------------------------------
2140; NEW PARTITION TABLE
2141; -----------------------------------------------------------------------------
2142; Everything used to build a new IPT and reference it to the old one
2143; BOOKMARK: New Partition Table
2144NewPartTable db 1536 dup (?) ; New Partition Table
2145
2146
2147; -----------------------------------------------------------------------------
2148; NEW HIDE PARTITION TABLE
2149; -----------------------------------------------------------------------------
2150; BOOKMARK: New Hide-Partition Table
2151NewHidePartTable db LocIPT_MaxPartitions * LocHPT_LenOfHPT dup (?)
2152
2153 ;~ even
2154
2155; -----------------------------------------------------------------------------
2156; NEW DRIVE LETTERS
2157; -----------------------------------------------------------------------------
2158; BOOKMARK: Logical Drive-Letters
2159NewDriveLetters db LocIPT_MaxPartitions dup (?)
2160
2161 ;~ even
2162
2163; -----------------------------------------------------------------------------
2164; PARTITION SIZE TABLE
2165; -----------------------------------------------------------------------------
2166; Size-Table (6 bytes per partition)
2167; BOOKMARK: Partition Size Table
2168PartitionSizeTable db LocIPT_MaxPartitions * 6 dup (?)
2169
2170
2171; -----------------------------------------------------------------------------
2172; PARTITION POINTERS
2173; -----------------------------------------------------------------------------
2174; Maximum is 52 word entries till now
2175; BOOKMARK: Partition Pointers
2176PartitionPointers dw 52 dup (?)
2177
2178; Count of total Partition Pointers
2179PartitionPointerCount db ?
2180
2181; -----------------------------------------------------------------------------
2182; XREF TABLE
2183; -----------------------------------------------------------------------------
2184
2185; X-Reference Table (holds new partnr, index is old part nr)
2186; BOOKMARK: Xref Table
2187PartitionXref db LocIPT_MaxPartitions dup (?)
2188
2189; -----------------------------------------------------------------------------
2190; VOLUME LETTERS
2191; -----------------------------------------------------------------------------
2192
2193; Volume-Letters
2194; 0 - no LVM support
2195; 1 - LVM support, but no letter
2196; 'C'-'Z' - assigned drive letter
2197; BOOKMARK: Volume Drive Letters
2198PartitionVolumeLetters db LocIPT_MaxPartitions dup (?)
2199
2200
2201
2202; -----------------------------------------------------------------------------
2203; MISC VARS AND FLAGS
2204; -----------------------------------------------------------------------------
2205; BOOKMARK: Misc Vars and Flags
2206TotalHarddiscs db ? ; Total harddrives (by POST)
2207LBASwitchTable db 128 dup (?) ; Bit 25-18 for CHS/LBA Switching
2208NewPartitions db ? ; Freshly found partitions
2209 ; Independent of SaveConfiguration
2210TooManyPartitions db ? ; Non-zero if too many partitions found
2211
2212VideoIO_Segment dw ? ; Segment for Video I/O
2213
2214ExtendedAbsPos dd ? ; Extended Partition Absolute Position
2215ExtendedAbsPosSet db ? ; If Absolute Position set
2216
2217CurPartition_Location dw 4 dup (?) ; Where did current partition come from?
2218CurIO_UseExtension db ? ; 1-Use INT 13h EXTENSIONS
2219 ; (filled out by PreCrap)
2220CurIO_Scanning db ? ; 1-AiR-BOOT is scanning partitions
2221 ; (for detailed error message)
2222
2223; [Linux support removed since v1.02]
2224;GotLinux db ? ; 1-Linux found
2225
2226
2227; -----------------------------------------------------------------------------
2228; MENU RELATED VARS
2229; -----------------------------------------------------------------------------
2230Menu_EntrySelected db ? ; Which partition we boot this time...
2231Menu_UpperPart db ? ; Which number (Base=0) is the partition upper pos
2232Menu_AbsoluteX db ? ; Pos where Menu stuff starts
2233Menu_TotalParts db ? ; Copy of CFG_BootParts
2234Menu_TotalLines db ? ; Total Lines on Screen used for BootMenu
2235Menu_EntryDefault db ? ; Default Entry in filtered View
2236Menu_EntryLast db ? ; LastBooted Entry in filtered View
2237Menu_EntryAutomatic db ? ; Automatic Entry in filtered View
2238 ; - All adjusted to menu locations
2239
2240; -----------------------------------------------------------------------------
2241; PARTITION RELATED VARS
2242; -----------------------------------------------------------------------------
2243PartSetup_UpperPart db ? ; Partition-Setup (like Menu_UpperPart)
2244PartSetup_ActivePart db ? ; Active Partition
2245PartSetup_HiddenUpper db ? ; (like Menu_UpperPart)
2246PartSetup_HiddenX db ? ; Pos for Hidden-Setup
2247PartSetup_HiddenAdd db ? ; Adjust for Hidden-Setup
2248
2249; -----------------------------------------------------------------------------
2250; TIMER / SETUP RELATED VARS
2251; -----------------------------------------------------------------------------
2252TimedBootEnable db ? ; Local Enable/Disable for timed boot
2253TimedTimeOut dd ? ; TimeOut Timer for TimedBoot (too much time here;)
2254TimedSecondLeft db ? ; How many seconds are left till boom ?
2255TimedSecondBack db ? ; To get a modification noticed
2256TimedBootUsed db ? ; Timed Boot used for bootup ?
2257FloppyGetNameTimer dd ? ; Timer for Floppy-Get-Name
2258SETUP_KeysOnEntry db ? ; which Shift Status was there, when booting ?
2259SETUP_ExitEvent db ? ; Exit Event to end SETUP
2260TempPasswordEntry db 17 dup (?)
2261SETUP_OldPwd db 17 dup (?)
2262SETUP_NewPwd db 17 dup (?)
2263SETUP_VerifyPwd db 17 dup (?)
2264StartSoundPlayed db ?
2265ChangePartNameSave db ? ; Save label after user-edit ?
2266SyncLvmLabels db ? ; Sync LVM labels after user-edit ?
2267
2268
2269; -----------------------------------------------------------------------------
2270; FX RELATED VARS
2271; -----------------------------------------------------------------------------
2272FX_UseCount dw ?
2273FX_OverallTimer dw ?
2274FX_WideScrollerTimer dw ?
2275FX_WideScrollerCurPos dw ?
2276FX_WideScrollerSpeed db ?
2277FX_WideScrollerSpeedState db ?
2278FX_WideScrollerDirection db ?
2279FX_WideScrollerAbsDirection db ?
2280FX_WideScrollerBounceSpeed db ?
2281FX_CooperBarsTimer dw ?
2282
2283; Dynamically Generated Tables - do not need to get initialized with NUL
2284FX_CooperColors db 672 dup (?) ; 7 cooper bars*96 - runtime calculated
2285FX_CooperState db 7 dup (?)
2286FX_SinusPos db 7 dup (?)
2287FX_CooperPos dw 7 dup (?)
2288
2289
2290; -----------------------------------------------------------------------------
2291; CHARSET BUFFER
2292; -----------------------------------------------------------------------------
2293CharsetTempBuffer db 4096 dup (?) ; Uninitialized Charset buffer
2294
2295; -----------------------------------------------------------------------------
2296; LVM CRC TABLE
2297; -----------------------------------------------------------------------------
2298LVM_CRCTable dd 256 dup (?) ; LVM-CRC (->SPECiAL\LVM.asm)
2299
2300
2301
2302;
2303; Rousseau: added some stuff.
2304;
2305; -----------------------------------------------------------------------------
2306; ECS PHASE1 RELATED
2307; -----------------------------------------------------------------------------
2308Phase1Active db ?
2309OldPartitionCount db ?
2310
2311
2312; -----------------------------------------------------------------------------
2313; DISK PARAMETERS
2314; -----------------------------------------------------------------------------
2315 ;EVEN
2316HugeDisk db MaxDisks dup(?)
2317TrueSecs dd MaxDisks dup(?)
2318
2319; BIOS geometry of the boot-drive
2320; Note that heads cannot be 256 due to legacy DOS/BIOS bug
2321; If Int13X is supported those values are used, otherwise the legacy values.
2322BIOS_Cyls dd MaxDisks dup(?)
2323BIOS_Heads dd MaxDisks dup(?)
2324BIOS_Secs dd MaxDisks dup(?)
2325BIOS_Bytes dw MaxDisks dup(?)
2326BIOS_TotalSecs dq MaxDisks dup(?)
2327
2328; LBA geometry of the boot-drive
2329; Note that these values are taken from the BPB of a partition boot-record
2330LVM_Cyls dd MaxDisks dup(?)
2331LVM_Heads dd MaxDisks dup(?)
2332LVM_Secs dd MaxDisks dup(?)
2333LVM_Bytes dw MaxDisks dup(?)
2334LVM_TotalSecs dq MaxDisks dup(?)
2335
2336; OS/2 geometry of the boot-drive
2337; Note that these values are taken from the BPB of a partition boot-record
2338LOG_Cyls dd MaxDisks dup(?)
2339LOG_Heads dd MaxDisks dup(?)
2340LOG_Secs dd MaxDisks dup(?)
2341LOG_Bytes dw MaxDisks dup(?)
2342LOG_TotalSecs dq MaxDisks dup(?)
2343
2344; Get's initialized at startup to: 00000011111111111111111111111100b
2345; Meaning A,B not free; C-Z free, rest unused. (right to left)
2346; Each partition with an assigned drive-letter clears a bit in this map.
2347FreeDriveletterMap dd ?
2348
2349; LBA address of master LVM sector, zero if non-existant
2350MasterLVMLBA dd ?
2351
2352
2353; -----------------------------------------------------------------------------
2354; I13X BUFFER
2355; -----------------------------------------------------------------------------
2356;
2357; BOOKMARK: Temporary buffer for 48h INT13X bios call.
2358;
2359
2360 ; Size of the buffer.
2361 ; this param *must* be filled in.
2362 ; Code inserts it.
2363i13xbuf dw 1 dup (?)
2364
2365 ; The buffer itself.
2366 db 126 dup(?)
2367
2368 ; Size of buffer calculated.
2369 ; (excluding the size word at the start).
2370 i13xbuf_size = $-offset i13xbuf-2
2371
2372 ; Some debug area.
2373dbg_scratch db 512 dup(?)
2374
2375
2376; End of transient variables.
2377EndOfVariables:
2378
2379
2380
2381
2382; -----------------------------------------------------------------------------
2383; OLD AND NEW STACKS
2384; -----------------------------------------------------------------------------
2385; BOOKMARK: Storage for Old and New Stack Pointers
2386;
2387; These need to be outside the variable section because AiR-BOOT can restart
2388; itself in debug-mode. If the OldSP and OldSS would be in the variable area,
2389; they would be cleared on AiR-BOOT restart.
2390;
2391
2392; The variable section is cleared word-wise, so it could clear one byte extra
2393; depending on the alignment and size. This DD prevents the OldSP and OldSS
2394; to be partly overwritten by the clearing routine.
2395 dd ?
2396
2397; SS:SP from before our relocation.
2398; The registers values when the BIOS transferred control to us were pushed
2399; on this stack.
2400
2401OldSP dw ?
2402OldSS dw ?
2403
2404; SS:SP currently in use.
2405; They are temporarily dumped here so we can pop the resgisters from
2406; the old stack to display them in debug mode.
2407CurrentSP dw ?
2408CurrentSS dw ?
2409
2410
2411
2412;
2413; End of BSS segment.
2414;
2415eobss:
2416
2417;
2418; Close BSS segment.
2419;
2420IFDEF SEGMENTED
2421 VOLATILE ENDS
2422ELSE
2423 LDRIMAGE ENDS
2424ENDIF
2425
2426 ; BOOKMARK: End of Module
2427 END AiR_BOOT
2428
Note: See TracBrowser for help on using the repository browser.