source: trunk/bootcode/airboot.asm@ 76

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

Removed the ancient 'ReleaseCode' conditional [v1.1.1-testing]

This was used in pre v1.07 versions to create a DOS .COM executable
for debugging. It has never been used in v1.07+ versions and debugging
is now done using the serial port from native AirBoot. Time to get rid
of this unused stuff.

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