source: trunk/bootcode/airboot.asm@ 184

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

Added 'CRC_IGNORE' option for debug building [v1.1.1-testing]

The CRC is calculated and inserted in the loader image when AiR-BOOT is
installed. Ignoring the CRC enables manually merging the loader without
using the installer. This is used for debugging in virtual machines,
where it is easy to merge the loader to the disk image of the VM.

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