Changeset 46


Ignore:
Timestamp:
Apr 12, 2014, 8:23:32 AM (11 years ago)
Author:
Ben Rietbroek
Message:

Various Changes [2012-04-14]

WARNING!!

All commits upto and including the commit of [2012-05-13] contain
a severe bug!! Building from these sources and then disabling
the 'force LBA' feature while also using the drive-letter feature or
editing the label can DESTROY THE MBR on ALL ATTACHED DISKS!!
DO NOT DISABLE 'FORCE LBA USAGE' WHEN BUILT FROM THE THESE COMMITS!!

Changes

o Added BLDLEVEL support
o Enhanced Master Make
o Sanitized sources
o Support for Wasm and Masm6 (experimental)
o Renamed MBR_PROT.ASM to MBR-PROT.ASM
o Merged bitfield code Into Installer
o First steps for cross platform Installer
o More...

Location:
trunk
Files:
13 added
9 deleted
44 edited
10 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/.clean

    r45 r46  
    22
    33make clean
    4 make
     4
  • trunk/1README.TXT

    r37 r46  
     1===============================================================================
     2 1README.TXT -- General Information about AiR-BOOT v1.0.8
     3===============================================================================
     4
    15 AiR-BOOT (c) Copyright 1998-2009 M. Kiewitz
    26
     
    1822
    1923
    20 Note:
    21 -----
     24Preface:
     25--------
     26When you are reading this file you are either browsing the AiR-BOOT sources
     27or you have 'checked-them-out' from the Netlabs repository.
     28Either way, this is what you should be aware of:
     29- AiR-BOOT was originally invented and designed by Martin Kiewitz.
     30- Martin seems to not develop it anymore and his last version (v1.06)
     31  can be found on sourceforge.
     32- *This* version is a 'fork' and although the name is the same,
     33  it's sources reside on Netlabs and an other developer maintains it.
     34  So, please do not bother Martin with bugs in this 'fork'.
     35- This AiR-BOOT fork has been enhanced to cope with issues like 'huge disks'
     36  and it's goal is to be a replacement for the ancient IBM Boot Manager
     37  (formerly) used by eComStation.
     38- With the release of eComStation v2.1, in may 2011, this AiR-BOOT 'fork'
     39  is distributed with it and positioned as the 'preferred bootmanager'
     40  for eComStation.
     41- While AiR-BOOT is 'operating-system agnostinc', meaning that it is not tied
     42  to any particular OS, the main effort of this 'fork' is to replace IBM-BM
     43  and be highly compatible with eComStation.
     44- The secondary goal of this 'fork' is to support even more operating-systems,
     45  new 'boot-technologies' like UEFI, new partitioning schemes like GPT
     46  and more.
     47
     48
     49Note 1:
     50-------
    2251This is the "eComStation fork" of AiR-BOOT and it is maintained by a
    2352different developer. The file you are currently reading, 1README.TXT,
    2453replaces the original README.TXT as created by Martin Kiewitz.
    25 The latter can be found in README.MKW but note that the information
     54The latter can be found in README.MKW, but note that the information
    2655in there about building AiR-BOOT is completely outdated.
     56Please refer to BUILD.NFO for more information about building AiR-BOOT.
     57
     58
     59Note 2:
     60-------
     61Martin, at the time (1998+), found that it was important that AiR-BOOT could
     62be completely built on a DOS-system. In that 'era' this was a reasonable
     63requirement. With AiR-BOOT replacing IBM Boot Manager for eComStation
     64as of 2011, and upcoming stuff like EFI and GPT, AiR-BOOT itself and
     65it's 'build-environment' need to break out of the 'DOS-box'.
     66
     67This means that the 8.3 filename format cannot be retained in some situations
     68and that building AiR-BOOT cannot use DOS .BAT files anymore.
     69
     70Therefore, the 'build environment' has been 'revamped' to use Makefiles
     71and the Open Watcom tool-chain in combination with the JWasm Assembler.
     72This tool-chain can operate under DOS,Win32,OS/2 and Linux.
     73
     74While care has been taken that the major components of AiR-BOOT can still be
     75built on DOS (or DOS-emulation environments),
     76the preferred build-environment is now eComStation -or- Linux.
     77
     78If you really need to build on DOS, beware that:
     79- The DOS build-environment has limitations regarding memory and filenames.
     80- An eCS DOS-Session needs to have DPMI set from 'auto' to 'enabled'
     81  and the XMS mem-limit needs to be set to 0, to be able the use of JWasmD.
     82- It has not been tested as thoroughly as the eCS and Linux environments.
     83- It will be dropped in the future.
     84
     85
     86Note 3:
     87-------
     88An other 'operating-system' from a company that thinks it owns all computers,
     89all the disks in them, all it's users, their pets, and whatnot,
     90is also supported. AiR-BOOT can boot Windows and there is also a Win32 version
     91of the installer. (AIRBOOTW.EXE)
     92
     93However, the AiR-BOOT Installer code for Win32 is much less tested than
     94the eComStation version. This however, does not apply to the AiR-BOOT loader,
     95which will do it's very best to boot any Windows it finds.
     96
     97
     98Note 4:
     99-------
     100AiR-BOOT can also boot Linux, or more accurately, chainload GRUB.
     101For this to work, GRUB needs to be installed on the partition Linux resides
     102on, since the MBR is taken by AiR-BOOT. If GRUB is installed in the MBR it
     103needs to be moved to the PBR. The procedure for such an action depends
     104on the GRUB and Linux versions used.
     105
     106 
    27107
    28108Building AiR-BOOT
    29109-----------------
    30110- Checkout the sources from http://svn.netlabs.org/air-boot.
    31 - Setup your Open Watcom build-environment for your OS.
     111- Setup the Open Watcom build-environment for your OS.
    32112- Download JWasm for your OS.
    33 - Run wmake help to see a list of build options -or-
    34113- Run wmake without paramaters to build AiR-BOOT for all languages.
    35114
    36115See BUILD.NFO for more information.
    37116
     117
    38118Rousseau.
  • trunk/BOOTCODE/.build

    r37 r46  
    11#!/bin/bash
    22
     3export ASM=jwasm
    34make dev
  • trunk/BOOTCODE/.dist

    r45 r46  
    11#!/bin/bash
    22
    3 make dev
     3make dist
  • trunk/BOOTCODE/AIR-BOOT.ASM

    r45 r46  
    2020
    2121;------------------------------------------------------------------------------
    22 ;                                                         AiR-BOOT / MAIN-CODE
     22;                                                       AiR-BOOT / DEFINITIONS
    2323;------------------------------------------------------------------------------
    2424;
     25
     26;
     27; Include AiR-BOOT Version Information.
     28;
     29Include VERSION.INC
     30
     31;
     32; Include OS/2 BLDLEVEL Information.
     33;
     34Include BLDLEVEL.INC
    2535
    2636
     
    6676; Include Debug Modules and enable COM-port debugging.
    6777;
    68 AUX_DEBUG       EQU
     78;~ AUX_DEBUG       EQU
    6979
    7080
     
    132142VideoIO_FXSegment           equ     0A000h
    133143
    134 ; Include
     144; Include some macro's
    135145Include ../INCLUDE/ASM.INC
    136146
     
    239249Flags_HideFeature           equ     00000100b
    240250Flags_DriveLetter           equ     00001000b   ; OS/2 FAT16/HPFS only
    241 Flags_ExtPartMShack         equ     00010000b   ; Extended Partition M$-Hack req ?
     251Flags_ExtPartMShack         equ     00010000b   ; Ext. Partition M$-Hack req ?
    242252Flags_NoPartName            equ     01000000b
    243253Flags_NowFound              equ     10000000b   ; temp only in OldPartTable
     
    276286
    277287
     288
     289
     290
     291
     292;------------------------------------------------------------------------------
     293;                                                         AiR-BOOT / MAIN-CODE
     294;------------------------------------------------------------------------------
     295
    278296; ------------------------------------------
    279297; Rousseau: # Changed this from .386 to .286
     
    297315; Tasm needs a memory model for USES on PROC to work.
    298316IFDEF   TASM
    299     ;.model large, basic
     317    ;~ .model large, basic
    300318    .model  tiny,c
    301319ENDIF
     
    321339
    322340; Our code-segment starts here.
    323 LDRIMAGE    SEGMENT     USE16   PUBLIC  'MIXED'
     341LDRIMAGE    SEGMENT     USE16   PUBLIC  'CODE'
    324342
    325343IFDEF   SEGMENTED
     
    332350                                                                    ; Sector 1
    333351
    334 
    335                 ; We are not a .com file at 100h but a binary image
    336                 ; of which only the 1st sector gets loaded at 07c00h.
     352;##############################################################################
     353                ; We are not a .COM file at 100h but a BINARY image
     354                ; of which only the 1st sector gets loaded at 0000:07c00h
     355                ; by the BIOS. The code in this 1st sector is position
     356                ; independent and moves itself to a new location at 8000:0000h.
     357                ; Then it jumps to a new entry-point and loads the rest of
     358                ; the image to the new location.
    337359                org 00000h                          ; Sector 1
    338 
     360;##############################################################################
     361
     362
     363;
    339364; Start of sector 1
    340 ; This is the MBR, note the AiRBOOT signature, it's date (2006), version and
    341 ; language.
    342 ; Version 1.07 was intruduced in 2011.
    343 ; It fixes issues with huge drives and lvm and more.
    344 
    345 
     365; This is the MBR.
     366; Note the AiRBOOT signature, it's date, version and language.
     367; Version 1.07 was intruduced in 2011, version 1.0.8 in 2012.
     368; These new versions fix issues with huge drives, lvm and more.
     369; For a detailed description see AIR-BOOT.HIS.
     370;
     371
     372;
    346373; ---------------------------------------------
    347374; Rousseau: # Combined letter and jump offset #
    348375; ---------------------------------------------
    349 ; My guess is Martin had a short jump followed by the AiRBOOT signature at first.
    350 ; Then he encountered strange behaviour by some M$ operating-systems if the
    351 ; the first insruction was not a CLI.
     376; Martin had a short jump followed by the AiRBOOT signature at first.
     377; Then he encountered strange behaviour by some M$ operating-systems
     378; if the the first insruction was not a CLI.
    352379; But there was no room to insert the CLI and of course he did not want to
    353380; change the location of the AiRBOOT signature.
    354381; He solved this by inserting the M$ needed CLI at offset 0 followed by a short
    355382; jump that uses the 'A' of the AiRBOOT signature as the jump displacement.
     383;
    356384
    357385
     
    359387AiR_BOOT:
    360388
    361                 ; Some M$ operating systems need a CLI
    362                 ; here otherwise they will go beserk
    363                 ; and will do funny things during
    364                 ; boot phase, it's laughable!
    365                 cli
    366 
    367                 ; JMP-Short -> MBR_Start
    368                 ; Uses the 'A' from the signature as the displacement !
    369                 db      0EBh
    370 
    371                 ; ID String, Date (DD,MM,CC,YY), Version Number, Language ID
    372                 db      'AiRBOOT', 24h, 02h, 20h, 12h, 01h, 08h, TXT_LanguageID
    373 
    374                 ; Total Sectors Count.
    375                 ; Will get overwritten by FIXCODE.
    376                 db      1
    377 
    378                 ; Total Sectors Count,
    379                 ; Dynamic calculation.
    380                 ;~ db      (code_end-$)/512
     389        ; Some M$ operating systems need a CLI
     390        ; here otherwise they will go beserk
     391        ; and will do funny things during
     392        ; boot phase, it's laughable!
     393        cli
     394
     395        ; JMP-Short -> MBR_Start
     396        ; Uses the 'A' from the signature as the displacement !
     397        db      0EBh
     398
     399        ; ID String, Date (DD,MM,CC,YY), Version Number, Language ID
     400        ;~ db      'AiRBOOT', 24h, 02h, 20h, 12h, 01h, 08h, TXT_LanguageID
     401        InsertAirbootSignature  TXT_LanguageID
     402
     403        ; Total Sectors Count.
     404        ; Will get overwritten by FIXCODE.
     405        db      1
     406
     407        ; Total Sectors Count,
     408        ; Dynamic calculation.
     409        ;~ db      (code_end-$)/512
    381410
    382411
     
    420449                ; Code an intersegment jump to the new location
    421450                db      0EAh
    422                 dw      BootBaseExec        ; This is MBR_RealStart + BootBasePtr
    423                 dw      BootBaseSeg         ; This is 08000h
     451                dw      BootBaseExec    ; This is MBR_RealStart + BootBasePtr
     452                dw      BootBaseSeg     ; This is 08000h
    424453                ;jmp     far ptr BootBaseSeg:BootBaseExec
    425454
     
    436465                xor     cx, cx
    437466                mov     dx, 500
    438                 int     15h                 ; Wait to display the whole screen :]
    439 MBR_HaltSys:    cli
     467                int     15h         ; Wait to display the whole screen :]
     468MBR_HaltSys:
     469                cli
    440470                jmp     MBR_HaltSys
    441471;db 100 dup (0)
     
    485515        jmp     MBRLE_Halt
    486516MBR_LoadError   EndP
    487 
    488517
    489518;
     
    749778                db      16 dup (0)
    750779
    751 FileSysNames    db      'FAT12   ', 'FAT16   ', 'FAT16Big', 'FAT16Big'
    752                 db      'HPFS    ', 'NTFS    ', 'LVM-Data', 'JFS     '
    753                 db      'FAT32   ', 'FAT32   ', 'FAT32   ', 'BeOS    '
    754                 db      'Unix    ', 'Minix   ', 'Linux   ', 'Venix   ' ; x row ;)
    755                 db      'BSD/386 ', 'OpenBSD ', 'LinuxSwp', 'NeXTSTEP'
    756                 db      'GNU HURD', 'QNX     ', 'QNX     ', 'QNX     '
    757                 db      '        ', '        ', '        ', '        '
    758                 db      '        ', '        ', '        ', '        '
    759                 db      '        ', '        ', '        ', '        '
    760                 db      '        ', 'Kernel  ', '        ', '0V-Award'
    761 ;                db      'OS/2 Man', 'via BIOS', 'Floppy  ', 'Unknown '
    762                 db      'OS2-BMGR', 'via BIOS', 'Floppy  ', 'Unknown '
     780FileSysNames    db  'FAT12   ', 'FAT16   ', 'FAT16Big', 'FAT16Big'
     781                db  'HPFS    ', 'NTFS    ', 'LVM-Data', 'JFS     '
     782                db  'FAT32   ', 'FAT32   ', 'FAT32   ', 'BeOS    '
     783                db  'Unix    ', 'Minix   ', 'Linux   ', 'Venix   ' ; x row ;)
     784                db  'BSD/386 ', 'OpenBSD ', 'LinuxSwp', 'NeXTSTEP'
     785                db  'GNU HURD', 'QNX     ', 'QNX     ', 'QNX     '
     786                db  '        ', '        ', '        ', '        '
     787                db  '        ', '        ', '        ', '        '
     788                db  '        ', '        ', '        ', '        '
     789                db  '        ', 'Kernel  ', '        ', '0V-Award'
     790;                db  'OS/2 Man', 'via BIOS', 'Floppy  ', 'Unknown '
     791                db  'OS2-BMGR', 'via BIOS', 'Floppy  ', 'Unknown '
    763792                         ; -> 44 Partition-Types
    764793
     
    10111040                ;
    10121041                ;call    AuxIO_TeletypeNL
    1013                 mov     si, offset PartitionTable
     1042                ;mov     si, offset PartitionTable
    10141043                ;call    AuxIO_DumpSector
    10151044                ;call    AuxIO_TeletypeNL
     
    10201049                ; Moved here to fix that Esc out of SETUP would also save.
    10211050                ; So moved above the MBR_Main_ReEnterSetup label.
    1022                 mov     [eCS_InstallVolume], 0  ; disable phase 1 for next boot
     1051                mov     byte ptr [eCS_InstallVolume], 0  ; disable phase 1 for next boot
    10231052                call    DriveIO_SaveConfiguration
    10241053
     
    10441073
    10451074
     1075
    10461076    MBR_Main_ReEnterBootMenuPre:
    10471077
     
    10501080
    10511081                ; ...and count that one...
    1052                 cmp     PartitionPointerCount, 0
     1082                cmp     byte ptr [PartitionPointerCount], 0
    10531083                jne     MBR_Main_SomethingBootAble
    10541084                mov     si, offset TXT_NoBootAble
     
    10651095    MBR_Main_ReEnterBootMenu:
    10661096                call    BOOTMENU_ResetMenuVars ; reset has to be done
    1067                 test    CFG_AutomaticBoot, 1
     1097                test    byte ptr [CFG_AutomaticBoot], 1
    10681098                jz      MBR_Main_NoAutomaticBooting
    10691099                ; ------------------------------------------ AUTOMATIC BOOTING
    10701100                ; Select automatic partition, disable automatic booting for
    10711101                ;  next time and boot system...
    1072                 mov     CFG_AutomaticBoot, 0
     1102                mov     byte ptr [CFG_AutomaticBoot], 0
    10731103                call    PASSWORD_AskSystemPwd
    10741104                mov     al, Menu_EntryAutomatic
     
    10831113                ;call   SOUND_Beep
    10841114
    1085                 test    CFG_BootMenuActive, 0FFh
     1115                test    byte ptr [CFG_BootMenuActive], 0FFh
    10861116                jnz     MBR_Main_GotBootMenu
    10871117                ; ----------------------------------------------- NO BOOT-MENU
     
    12121242IFDEF AUX_DEBUG
    12131243b_debug:
    1214 Include REGULAR/DEBUG.ASM
     1244Include REGULAR/DEBUG.ASM       ; Debug module
    12151245size_debug = $-b_debug
    12161246b_auxio:
     
    12251255
    12261256                ;
     1257                ; Moved up.
     1258                ;
     1259
     1260                ;
    12271261                ; This is the AiR-BOOT MBR-Protection Image.
    12281262                ; 04600 / 200h = 23h = 35d sectors are before this point.
    1229                 ; The stuff generated here gets overwritten when the MBR_PROT.ASM
    1230                 ; module, which is assembled separately, gets merged.
     1263                ; The stuff generated here gets overwritten when the
     1264                ; MBR_PROT.ASM module, which is assembled separately,
     1265                ; gets merged.
    12311266                ; So you won't find the string below in the generated binary.
    12321267                ;
     
    12381273
    12391274
    1240 
     1275                ; Rousseau: It needed a sector alignment, so moved it up to
     1276                ;           have as much space as possible for the modules
     1277                ;           included here.
    12411278
    12421279
     
    12761313
    12771314
     1315
    12781316                ;
    12791317                ; Critical end of code marker.
     
    13021340
    13031341
    1304 ;
    1305 ; Let's make this always the last module in this section.
    1306 ;
    1307 Include BLDDATE.ASM                      ; Build Date generated by _build.cmd
     1342; If we are debugging, we overwrite the FX code.
     1343; As long as no FX is disabled this will do no harm.
     1344IFDEF   AUX_DEBUG
     1345                ORG     06780h
     1346ENDIF
     1347
     1348bld_level:
     1349                ;
     1350                ; Here we insert the OS/2 BLDLEVEL Information.
     1351                ; It is composed of the AiR-BOOT version-info and other
     1352                ; information.
     1353                ; It is unique for each release of AiR-BOOT.
     1354                ;
     1355                InsertBuildLevel
    13081356
    13091357                ;
     
    13181366                ;
    13191367                ; AiR-BOOT Protection Image.
     1368                ; Moved from below to have it not break the included modules
     1369                ; with it's sector alignment requirement.
    13201370                ;
    13211371                ORIGIN  06800h
     
    13241374                ; This is the AiR-BOOT MBR-Protection Image.
    13251375                ; 06800 / 200h = 34h = 52d sectors are before this point.
    1326                 ; The stuff generated here gets overwritten when the MBR_PROT.ASM
    1327                 ; module, which is assembled separately, gets merged.
     1376                ; The stuff generated here gets overwritten when the
     1377                ; MBR_PROT.ASM module, which is assembled separately,
     1378                ; gets merged.
    13281379                ; So you won't find the string below in the generated binary.
    13291380                ;
     1381
     1382                ; 06800-068FF
     1383                ; 06900-069FF
     1384                ; 06A00-06AFF
     1385                ; 06B00-06BFF
     1386
     1387;
    13301388; Hardcoded to 1k (1024 bytes) (MBR_PROT.ASM)
     1389; The string below is searched for by the FIXCODE helper and *must* be
     1390; sector (512-bytes) aligned.
     1391;
    13311392MBR_Protection  db 'AiR-BOOT MBR-Protection Image'
    13321393
     
    13341395                db  1024-($-MBR_Protection)  dup('M')
    13351396
    1336 ;LDRIMAGE        ENDS
    1337 ;DATA_SEG        SEGMENT     USE16   PUBLIC  'CODE'
    1338 
    1339 
    1340 
    1341 ;~ MYDATA  SEGMENT     COMMON    'MIXED'
    1342 ;~ qqqq     dw  'QQ'
    1343 ;~ MYDATA  ENDS
    13441397
    13451398;==============================================================================
     
    13561409
    13571410Configuration:
    1358                 ; THERE IS AN INVISIBLE CHAR HERE !!
    1359                 ; Your editor may not display the invisible
     1411                ; THERE IS A NON-ASCII CHAR HERE !!
     1412                ; Your editor may not display this non-ASCII
    13601413                ; character at the end if the 'AiRCFG-TABLE'
    13611414                ; string. When this character get's deleted,
    13621415                ; AiR-BOOT will not function because it cannot
    13631416                ; find the config-signature which includes this
    1364                 ; invisible character. The code is: 0x0ad.
     1417                ; invisible character. The code of the char is: 0x0ad.
    13651418                db  'AiRCFG-TABLE­'
    1366                 db  01h, 07h, 'U' ; "Compressed" ID String
    1367                 ; This is now version 1.07 to have it in sync with
    1368                 ; the new code version for eCS.
     1419                db  01h, 08h, 'U' ; "Compressed" ID String
    13691420                ; Version 1.02 was for code 1.06, 1.03 was internal
    13701421                ; and 1.04,1.05 and 1.06 do not exist.
     1422                ;
     1423                ; 1.07 was used with AB v1.07 and introduced the phase1
     1424                ; system-name. For the rest it is compatible with v1.02.
     1425                ;
     1426                ; 1.0.8 is introduced with AB v1.0.8 and indicates the movement
     1427                ; of several components and the packing of the hideparttable.
     1428                ; The core configuration has not changed but the generated
     1429                ; configuration has. The v1.0.8 installer handles upgrading.
     1430                ;
    13711431                ; It is not required for the config to have the
    13721432                ; same version as the code, so in the future
    13731433                ; the code version might be higher than the
    13741434                ; config version if there are no changes to the latter.
     1435                ;
    13751436
    13761437CFG_LastTimeEditLow     dw  0   ; Last Time Edited Stamp (will incr every setup)
     
    14831544                ; Entries allocated down from 06E00 boundary.
    14841545                ;
    1485                 ORIGIN  % 06DABh                                  ; 427 Boundry
     1546                ORIGIN  06DABh                                  ; 427 Boundry
    14861547
    14871548; (432 - 5 = 427)
     
    15021563; stealth virus is on-line, we can intercept its call.
    15031564; Normal (non stealth) virus are trapped simply by rereading the MBR sector.
    1504 ; If a virus is found, we will restore MBR from Sektor 60/62 and stop the system
    1505 ; from working, so the user has to press reset. That's saver than a Reboot.
     1565; If a virus is found, we will restore MBR from Sektor 60/62 and stop the
     1566; system from working, so the user has to press reset.
     1567; That's saver than a Reboot.
    15061568;
    15071569; If a virus is found on the partition to boot, the system will ONLY halt,
     
    15461608;                             dw    0    ; No Checksum :)
    15471609;                             db    0, 0, 1
    1548 ;                             db    0, 0, 1  ; Location of Partition/Boot Record
     1610;                             db    0, 0, 1 ; Location of Partition/Boot Record
    15491611;                             dd    0, 0
    15501612
     
    16161678
    16171679
    1618 MBR_BackUpMBR           db  'AiR-BOOT MBR-BackUp - Just to fill this sector with something',0
     1680MBR_BackUpMBR           db  'AiR-BOOT MBR-BackUp',\
     1681                            ' - Just to fill this sector with something',0
    16191682AirBootRocks            db  'AiR-BOOT Rocks!',0
    16201683
     
    16491712ENDIF
    16501713
     1714
     1715
    16511716sobss:
    16521717;------------------------------------------------------------------------------
     1718
    16531719                            ;
    1654                             ; Removed org for BSS data to be more compatible
     1720                            ; Removed ORG for BSS data to be more compatible
    16551721                            ; with segment-concatenated layout.
    16561722                            ;
    16571723                            ; What happens before this space ??
    16581724                            ; If org 0 corruption occurs.
     1725                            ;
     1726
     1727                            ;
    16591728                            ; Filling hiddenparttable goes out-of-bounds !
     1729                            ; Fixed with 6-bit packing.
    16601730                            ;
    1661                             org 02400h                         ; Uninitialized
    1662                             ;~ org 00200h                         ; 200h geeft 3 floppies !
     1731
     1732;
     1733; If segmented, offsets are relative to the BSS segment.
     1734; They are resolved at link-time.
     1735; If not segmented, offsets are relative to the CODE segment.
     1736;
     1737IFDEF   SEGMENTED
     1738                            ORG 02400h
     1739ELSE
     1740                            ORG 0A000h
     1741ENDIF
     1742
    16631743
    16641744; This space actually gets initialized in PreCrap to NUL (till EndOfVariables)
    16651745BeginOfVariables:
    1666 PartitionSector             db  512 dup (?) ; Temporary Sector for Partition
    1667 JfsPBR                      db  512 dup (?) ; Temporary Sector for JFS PBR writeback
    1668 LVMSector                   db  512 dup (?) ; Temporary Sector for LVM
    1669 TmpSector                   db  512 dup (?) ; Temporary Sector
     1746PartitionSector     db  512 dup (?) ; Temporary Sector for Partition
     1747JfsPBR              db  512 dup (?) ; Temporary Sector for JFS PBR writeback
     1748LVMSector           db  512 dup (?) ; Temporary Sector for LVM
     1749TmpSector           db  512 dup (?) ; Temporary Sector
     1750Scratch             db  256 dup (?) ; Scratch buffer
    16701751
    16711752; Everything used to build a new IPT and reference it to the old one
    16721753; IETS OVERSCHRIJFT DIT !!
    1673 NewPartTable                db  1536 dup (?)                    ; New Partition Table
    1674 
    1675 NewHidePartTable            db  partition_count * LocHPT_LenOfHPT dup (?)    ; New Hide-Partition Table
    1676 NewDriveLetters             db  partition_count dup (?)         ; Logical Drive-Letters
    1677 
    1678 PartitionSizeTable          db  partition_count * 6 dup (?) ; Size-Table (6 bytes per partition)
    1679 PartitionPointers           dw  52 dup (?)  ; Maximum is 52 entries till now
    1680 PartitionPointerCount       db  ?           ; Count of total Partition Pointers
    1681 PartitionXref               db  partition_count dup (?) ; X-Reference Table (holds new partnr, index is old part nr)
    1682 PartitionVolumeLetters      db  partition_count dup (?) ; Volume-Letters
    1683                                                 ;  0 - no LVM support
    1684                                                 ;  1 - LVM support, but no letter
    1685                                                 ;  'C'-'Z' - assigned drive letter
    1686 
    1687 TotalHarddiscs              db  ?           ; Total harddrives (by POST)
    1688 LBASwitchTable              db  128 dup (?) ; Bit 25-18 for CHS/LBA Switching
    1689 NewPartitions               db  ?           ; Freshly found partitions
     1754NewPartTable                db  1536 dup (?)    ; New Partition Table
     1755
     1756; New Hide-Partition Table
     1757NewHidePartTable            db  partition_count * LocHPT_LenOfHPT dup (?)
     1758
     1759; Logical Drive-Letters
     1760NewDriveLetters             db  partition_count dup (?)
     1761
     1762; Size-Table (6 bytes per partition)
     1763PartitionSizeTable          db  partition_count * 6 dup (?)
     1764
     1765; Maximum is 52 entries till now
     1766PartitionPointers           dw  52 dup (?)
     1767
     1768; Count of total Partition Pointers
     1769PartitionPointerCount       db  ?
     1770
     1771; X-Reference Table (holds new partnr, index is old part nr)
     1772PartitionXref               db  partition_count dup (?)
     1773
     1774; Volume-Letters
     1775; 0 - no LVM support
     1776; 1 - LVM support, but no letter
     1777; 'C'-'Z' - assigned drive letter
     1778PartitionVolumeLetters      db  partition_count dup (?)
     1779
     1780
     1781
     1782
     1783TotalHarddiscs          db  ?           ; Total harddrives (by POST)
     1784LBASwitchTable          db  128 dup (?) ; Bit 25-18 for CHS/LBA Switching
     1785NewPartitions           db  ?           ; Freshly found partitions
    16901786                                            ; Independent of SaveConfiguration
    1691 TooManyPartitions           db  ?           ; Non-zero if too many partitions found
    1692 
    1693 VideoIO_Segment             dw  ?           ; Segment for Video I/O
    1694 
    1695 ExtendedAbsPos              dd  ?           ; Extended Partition Absolute Position
    1696 ExtendedAbsPosSet           db  ?           ; If Absolute Position set
    1697 
    1698 CurPartition_Location       dw  4 dup (?)   ; Where did current partition come from?
    1699 CurIO_UseExtension          db  ?           ; 1-Use INT 13h EXTENSIONS
    1700                                             ; (filled out by PreCrap)
    1701 CurIO_Scanning              db  ?           ; 1-AiR-BOOT is scanning partitions
     1787TooManyPartitions       db  ?           ; Non-zero if too many partitions found
     1788
     1789VideoIO_Segment         dw  ?           ; Segment for Video I/O
     1790
     1791ExtendedAbsPos          dd  ?           ; Extended Partition Absolute Position
     1792ExtendedAbsPosSet       db  ?           ; If Absolute Position set
     1793
     1794CurPartition_Location   dw  4 dup (?)   ; Where did current partition come from?
     1795CurIO_UseExtension      db  ?           ; 1-Use INT 13h EXTENSIONS
     1796                                        ; (filled out by PreCrap)
     1797CurIO_Scanning          db  ?           ; 1-AiR-BOOT is scanning partitions
    17021798                                            ; (for detailed error message)
    17031799
     
    17051801;GotLinux                     db     ?    ; 1-Linux found
    17061802
    1707 Menu_EntrySelected          db  ?   ; Which partition we boot this time...
    1708 Menu_UpperPart              db  ?   ; Which number (Base=0) is the partition upper pos
    1709 Menu_AbsoluteX              db  ?   ; Pos where Menu stuff starts
    1710 Menu_TotalParts             db  ?   ; Copy of CFG_BootParts
    1711 Menu_TotalLines             db  ?   ; Total Lines on Screen used for BootMenu
    1712 Menu_EntryDefault           db  ?   ; Default Entry in filtered View
    1713 Menu_EntryLast              db  ?   ; LastBooted Entry in filtered View
    1714 Menu_EntryAutomatic         db  ?   ; Automatic Entry in filtered View
     1803Menu_EntrySelected  db  ?   ; Which partition we boot this time...
     1804Menu_UpperPart      db  ?   ; Which number (Base=0) is the partition upper pos
     1805Menu_AbsoluteX      db  ?   ; Pos where Menu stuff starts
     1806Menu_TotalParts     db  ?   ; Copy of CFG_BootParts
     1807Menu_TotalLines     db  ?   ; Total Lines on Screen used for BootMenu
     1808Menu_EntryDefault   db  ?   ; Default Entry in filtered View
     1809Menu_EntryLast      db  ?   ; LastBooted Entry in filtered View
     1810Menu_EntryAutomatic db  ?   ; Automatic Entry in filtered View
    17151811                                         ;  - All adjusted to menu locations
    17161812
    1717 PartSetup_UpperPart         db  ?   ; Partition-Setup (like Menu_UpperPart)
    1718 PartSetup_ActivePart        db  ?   ; Active Partition
    1719 PartSetup_HiddenUpper       db  ?   ; (like Menu_UpperPart)
    1720 PartSetup_HiddenX           db  ?   ; Pos for Hidden-Setup
    1721 PartSetup_HiddenAdd         db  ?   ; Adjust for Hidden-Setup
    1722 
    1723 TimedBootEnable             db  ?   ; Local Enable/Disable for timed boot
    1724 TimedTimeOut                dd  ?   ; TimeOut Timer for TimedBoot (too much time here ;)
    1725 TimedSecondLeft             db  ?   ; How many seconds are left till boom ?
    1726 TimedSecondBack             db  ?   ; To get a modification noticed
    1727 TimedBootUsed               db  ?   ; Timed Boot used for bootup ?
    1728 FloppyGetNameTimer          dd  ?   ; Timer for Floppy-Get-Name
    1729 SETUP_KeysOnEntry           db  ?   ; which Shift Status was there, when booting ?
    1730 SETUP_ExitEvent             db  ?   ; Exit Event to end SETUP
    1731 TempPasswordEntry           db  17 dup (?)
    1732 SETUP_OldPwd                db  17 dup (?)
    1733 SETUP_NewPwd                db  17 dup (?)
    1734 SETUP_VerifyPwd             db  17 dup (?)
    1735 StartSoundPlayed            db  ?
    1736 ChangePartNameSave          db  ?   ; Save label after user-edit ?
    1737 SyncLvmLabels               db  ?   ; Sync LVM labels after user-edit ?
     1813PartSetup_UpperPart     db  ?   ; Partition-Setup (like Menu_UpperPart)
     1814PartSetup_ActivePart    db  ?   ; Active Partition
     1815PartSetup_HiddenUpper   db  ?   ; (like Menu_UpperPart)
     1816PartSetup_HiddenX       db  ?   ; Pos for Hidden-Setup
     1817PartSetup_HiddenAdd     db  ?   ; Adjust for Hidden-Setup
     1818
     1819TimedBootEnable     db  ?   ; Local Enable/Disable for timed boot
     1820TimedTimeOut        dd  ?   ; TimeOut Timer for TimedBoot (too much time here;)
     1821TimedSecondLeft     db  ?   ; How many seconds are left till boom ?
     1822TimedSecondBack     db  ?   ; To get a modification noticed
     1823TimedBootUsed       db  ?   ; Timed Boot used for bootup ?
     1824FloppyGetNameTimer  dd  ?   ; Timer for Floppy-Get-Name
     1825SETUP_KeysOnEntry   db  ?   ; which Shift Status was there, when booting ?
     1826SETUP_ExitEvent     db  ?   ; Exit Event to end SETUP
     1827TempPasswordEntry   db  17 dup (?)
     1828SETUP_OldPwd        db  17 dup (?)
     1829SETUP_NewPwd        db  17 dup (?)
     1830SETUP_VerifyPwd     db  17 dup (?)
     1831StartSoundPlayed    db  ?
     1832ChangePartNameSave  db  ?   ; Save label after user-edit ?
     1833SyncLvmLabels       db  ?   ; Sync LVM labels after user-edit ?
    17381834
    17391835FX_UseCount                 dw  ?
     
    17481844FX_CooperBarsTimer          dw  ?
    17491845
    1750 ; [Linux support removed since v1.02]
    1751 ;FAT16_Drive                  db     ?    ; FAT-16: Drive of FAT16-partition
    1752 ;FAT16_AbsPartitionBegin      dd     ?    ; FAT-16: LBA Begin of Partition
    1753 ;FAT16_SecsPerCluster         db     ?    ; FAT-16: Sectors Per Cluster
    1754 ;FAT16_NumOfRootEntries       dw     ?    ; FAT-16: Number of Root Entries
    1755 ;FAT16_SecsPerFAT             dw     ?    ; FAT-16: Sectors Per FAT
    1756 ;FAT16_AbsFATBegin            dd     ?    ; FAT-16: LBA Begin of FAT
    1757 ;FAT16_AbsRootBegin           dd     ?    ; FAT-16: LBA Begin of Root
    1758 ;FAT16_AbsClusterBegin        dd     ?    ; FAT-16: LBA Begin of Clusters
    1759 ;FAT16_FATCacheSector         db     ?    ; FAT-16: FAT-Sector No in Cache
    1760 ;FAT16_FATCache               db   512 dup (?) ; FAT-16: FAT-Area Cache
    1761 ;
    1762 ;LINUX_KernelEntries          db   680 dup (?) ; 34*20 -> Space for Kernel-Entries
    1763 ;LINUX_KernelNo               db     ?         ; Total of Kernels in KernelEntries
    1764 ;LINUX_KernelSizeTable        db   120 dup (?) ; Size-Table (6 bytes per kernel)
    1765 ;EndOfVariables:
     1846;~ ; [Linux support removed since v1.02]
     1847;~ FAT16_Drive             db     ?    ; FAT-16: Drive of FAT16-partition
     1848;~ FAT16_AbsPartitionBegin dd     ?    ; FAT-16: LBA Begin of Partition
     1849;~ FAT16_SecsPerCluster    db     ?    ; FAT-16: Sectors Per Cluster
     1850;~ FAT16_NumOfRootEntries  dw     ?    ; FAT-16: Number of Root Entries
     1851;~ FAT16_SecsPerFAT        dw     ?    ; FAT-16: Sectors Per FAT
     1852;~ FAT16_AbsFATBegin       dd     ?    ; FAT-16: LBA Begin of FAT
     1853;~ FAT16_AbsRootBegin      dd     ?    ; FAT-16: LBA Begin of Root
     1854;~ FAT16_AbsClusterBegin   dd     ?    ; FAT-16: LBA Begin of Clusters
     1855;~ FAT16_FATCacheSector    db     ?    ; FAT-16: FAT-Sector No in Cache
     1856;~ FAT16_FATCache          db   512 dup (?) ; FAT-16: FAT-Area Cache
     1857;~ LINUX_KernelEntries     db   680 dup (?) ; 34*20 -> Space for Kernel-Entries
     1858;~ LINUX_KernelNo          db     ?         ; Total of Kernels in KernelEntries
     1859;~ LINUX_KernelSizeTable   db   120 dup (?) ; Size-Table (6 bytes per kernel)
    17661860
    17671861; Dynamically Generated Tables - do not need to get initialized with NUL
    1768 FX_CooperColors             db   672 dup (?) ; 7 cooper bars*96 - runtime calculated
    1769 FX_CooperState              db     7 dup (?)
    1770 FX_SinusPos                 db     7 dup (?)
    1771 FX_CooperPos                dw     7 dup (?)
    1772 CharsetTempBuffer           db  4096 dup (?) ; Uninitialized Charset buffer
    1773 LVM_CRCTable                dd   256 dup (?) ; LVM-CRC (->SPECiAL\LVM.asm)
     1862FX_CooperColors     db   672 dup (?) ; 7 cooper bars*96 - runtime calculated
     1863FX_CooperState      db     7 dup (?)
     1864FX_SinusPos         db     7 dup (?)
     1865FX_CooperPos        dw     7 dup (?)
     1866CharsetTempBuffer   db  4096 dup (?) ; Uninitialized Charset buffer
     1867LVM_CRCTable        dd   256 dup (?) ; LVM-CRC (->SPECiAL\LVM.asm)
     1868
    17741869
    17751870
     
    18091904LOG_TotalSecs               dq      MaxDisks  dup(?)
    18101905
    1811 ; Rousseau: moved here
     1906; End of transient variables.
    18121907EndOfVariables:
    18131908
    1814 ; Temporary buffer for 48h INT13X bios call
    1815 ; Word aligned
    1816            ;even
    1817            ;align 2
    1818 
    1819            ;db     1  dup(?)
    1820 
    1821 i13xbuf     dw  1   dup (?)     ; Size of the buffer;
    1822                                 ; this param *must* be present.
    1823                                 ; Code inserts it.
    1824             db  126 dup(?)      ; The buffer itself.
    1825             i13xbuf_size = $-offset i13xbuf-2   ; Size of buffer
    1826                                                 ; (excluding the size word at the start).
    1827 
     1909
     1910;
     1911; Temporary buffer for 48h INT13X bios call.
     1912;
     1913
     1914            ; Size of the buffer.
     1915            ; this param *must* be filled in.
     1916            ; Code inserts it.
     1917i13xbuf     dw  1   dup (?)
     1918
     1919            ; The buffer itself.
     1920            db  126 dup(?)
     1921
     1922            ; Size of buffer calculated.
     1923            ; (excluding the size word at the start).
     1924            i13xbuf_size = $-offset i13xbuf-2
     1925
     1926            ; Some debug area.
    18281927ott         db  512 dup(?)
    18291928
     
    18311930
    18321931IFDEF   SEGMENTED
    1833 VOLATILE    ENDS
     1932    VOLATILE    ENDS
    18341933ELSE
    1835 LDRIMAGE    ENDS
     1934    LDRIMAGE    ENDS
    18361935ENDIF
    18371936
  • trunk/BOOTCODE/AIR-BOOT.HIS

    r45 r46  
    2323; Rousseau: Fixes and Enhancements
    2424; ---------------------------------
    25 ;
    26 ; v1.0.8-rc2-bld20120224
    27 ;-----------------------
     25; v1.0.8-rc2-bld201204??+
     26; ---------------------
     27
     28
     29; v1.0.8-pre-rc2-bld20120330
     30; --------------------------
     31; # Merged 16-bit Assembler bitfield code to the Installer #
     32;   The installer needs to handle the v1.0.8 configuration.
     33;   This requires access to the 6-bit packed 'hideparttable'.
     34;   To 'not-reinvent-the-wheel', by coding this in C, the Assembler
     35;   bitfield functions are integrated using Open Watcom's '_asm' capability.
     36;   It may not be pretty and the functions themselves are limited,
     37;   but this method prevents maintaining seperate Asm and C implementations.
     38;   Will be improved later.
     39;
     40; # Implemented BLDLEVEL support #
     41;   AIRBOOT.BIN, the Installers and SET(A)BOOT now support OS/2 BLDLEVEL
     42;   information. This enhances identification and problem tracking/solving.
     43;   While BLDLEVEL is an OS/2 command, the BLDLEVEL information itself can
     44;   be embedded in any binary. Invoking BLDLEVEL from within OS/2 on, let's
     45;   say, the AIRBOOTL.ELF Linux executable, will also show the BLDLEVEL info.
     46;   A slight deficiency of BLDLEVEL is that is forces a format on the version.
     47;   So, AiR-BOOT v1.0.8 will be shown as v1.00.8.
     48;
     49; # Added support for Masm6 and Wasm v1.9 -- Experimental use only #
     50;   Trying to assemble with Masm6 or Wasm v1.9 reveiled some interesting
     51;   behavior aspects in general. While this version can now be assembled with
     52;   Masm6 and Wasm too, this was only done to get a 'cross-feeling' for this
     53;   project. Future versions will drop support for Tasm, Masm6 and Wasm since
     54;   much conditional assembly is needed to support all of them. This was an
     55;   experimental excercise only. JWasm is the assembler of choise for this
     56;   project and any future versions.
     57;
    2858; # Implemented stop scanning when max. partitions limit exceeded #
    2959;   Previous versions halted the system when the maximum number of partitions
     
    73103;   AiR-BOOT and it's helpers can now be built on: DOS, Win32, OS/2 and Linux.
    74104;
    75 ; # Rewrote FIXCODE.ASM in C so the tool-chain is not dependent on a DOS .COM
    76 ;   program for embedding the MBR-protection. DOS,Win32,OS/2 and Linux
    77 ;   versions of FIXCODE are now used. (EXE[MZ|PE|LX] and ELF)
     105; # Rewrote FIXCODE.ASM in C so the tool-chain is not dependent on a DOS .COM #
     106;   Now FIXCODE is built platform-specific and takes care of the embedding
     107;   of MPR-protection image.
     108;
     109; # Created FIXCODE bash-script to accomplish embedding of MBR-protection #
     110;   Building on Linux requires that no DOS-tools are used in the tool-chain.
     111;   This script essentially performs the same functionality but does not check
     112;   certain conditions, like image-too-big, etc.
     113;   It is a 'quick-hack' until the Linux version of FIXCODE is operational.
    78114;
    79115; v1.0.8-rc1-bld20120124
  • trunk/BOOTCODE/MBR-PROT/.build

    r37 r46  
    11#!/bin/bash
    22
    3 make clean
     3#make clean
    44make
  • trunk/BOOTCODE/MBR-PROT/MBR-PROT.ASM

    r45 r46  
    2424                ;
    2525                .286
    26                 ;.model large,c
     26
     27; Tasm needs a memory model for USES on PROC to work.
     28IFDEF   TASM
     29    ;~ .model large, basic
     30    .model  tiny,c
     31ENDIF
    2732
    2833;_TEXT           SEGMENT     USE16   PUBLIC  'CODE'
     
    3843
    3944                org 0000h
    40                 .386p
     45                ;.386p
     46                ;.286
    4147
    42 ; Yes you are :-)
    43 ;OldInterrupt10  dd      'kcuf'              ; we are nice aren't we ;-)
    44 ;OldInterrupt13  dd      'kcuf'
    45 
     48;
     49; Storage for old interrupt vectors.
     50;
    4651OldInterrupt10  dd      0
    4752OldInterrupt13  dd      0
     
    172177MBRP_Line3      db      'ÔÍÍÍŽAiR-BOOT (c) Copyright by M. Kiewitz 1999-2012ÃÍÍŸ'
    173178
     179xxx:
     180
    174181org             1023
    175182                db 0
  • trunk/BOOTCODE/MBR-PROT/Makefile

    r37 r46  
    1 ###############################################################
    2 # Makefile :: Builds the MBR Protection Image.                #
    3 ###############################################################
     1###############################################################################
     2# Makefile :: Builds the MBR-PROT.BIN 16-bits RAW Protection Image.           #
     3###############################################################################
    44# rousseau@ecomstation.com
    55#
     
    4545# Source Level base-name of Target to build.
    4646#
    47 BASENAME=MBR_PROT
     47BASENAME=MBR-PROT
    4848
    4949#
     
    8181# -Cp   = case sensitive symbols
    8282# -zcw  = no _ prefix on symbols (C model)
    83 ASM_FLAGS_D0=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -nt='CODE_SEG' -nd='DATA_SEG' -Fo$^. -Fw$^&.ERR
    84 ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    85 ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     83ASM_FLAGS_D0=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Fo$^&.OBJ -Sa -Fl=$^&.LST -Fw$^&.ERR
     84ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Zd -Zi -Fo$^&.OBJ -Sa -Fl=$^&.LST -Fw$^&.ERR
     85ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Zd -Zi -Fo$^&.OBJ -Sa -Fl=$^&.LST -Fw$^&.ERR
    8686!elseif "$(ASM)"=="masm"
    87 ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -fo=$^. -fr=$^&.ERR
    88 ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -d1 -fo=$^. -fr=$^&.ERR
    89 ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -d1 -fo=$^. -fr=$^&.ERR
     87ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -fo=$^&.OBJ -fr=$^&.ERR
     88ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -d1 -fo=$^&.OBJ -fr=$^&.ERR
     89ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -d1 -fo=$^&.OBJ -fr=$^&.ERR
    9090!elseif "$(ASM)"=="wasm"
    91 ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -fo=$^. -fr=$^&.ERR
    92 ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -d1 -fo=$^. -fr=$^&.ERR
    93 ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -d1 -fo=$^. -fr=$^&.ERR
     91ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -fo=$^&.OBJ -fr=$^&.ERR
     92ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -d1 -fo=$^&.OBJ -fr=$^&.ERR
     93ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -d1 -fo=$^&.OBJ -fr=$^&.ERR
    9494!elseif "$(ASM)"=="tasm"
    9595# -ml   = case sensitive symbols
    96 ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -l
    97 ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -z -zi -c -la
    98 ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -z -zi -c -la
     96ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -l
     97ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -z -zi -c -la
     98ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -z -zi -c -la
    9999!elseif "$(ASM)"=="alp"
    100100ASM_FLAGS_D0=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ALP -Mb +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
     
    133133
    134134#
    135 # This builds all the languages using normal dependency rules.
     135# This builds the target using normal dependency rules.
    136136# If this Makefile was modified, all targets are forcefully rebuilt.
    137 # At the end all intermediate files are deleted.
    138 # Use wmake dev to to development; this generated one image and leaves
    139 # the intermediate files intact.
    140 #
    141 all:    .SYMBOLIC Makefile.bu $(TARGET) footer
    142 #       @echo ALL !!
    143 #       @#MAKE $(BLD_LANGUAGES)
    144 #       @for %%i in ($(BLD_LANGUAGES)) do @%MAKE AB-%%i
    145 #       @echo $<
    146 #       @%MAKE clean
    147 
    148 
    149 #
    150 # Some targets have the .MULTIPLE directive defined.
    151 # This is because the iteration "calls" for the creation of other (meta)
    152 # targets. If .MULTIPLE would not be defined these (meta) targets would not
    153 # be "built" anymore because the are considered up-to-date.
    154 # With multiple this assumption is removed and the target is "rebuilt" for
    155 # every target that depends on it.
    156 # This mostly concerns meta operations like clean etc.,
    157 # but of course also the main building of the AIRBOOT.BIN module.
    158 #
     137#
     138all:    .SYMBOLIC Makefile.bu header $(TARGET) footer
     139
    159140
    160141#
    161142# Show the header.
    162143#
    163 header: .SYMBOLIC .MULTIPLE
     144header: .SYMBOLIC
    164145        @echo.
    165146        @echo =====================================================================
    166         @echo = MODULE: $(TARGET)    [$(%BLD_LANG)]           [16-bits Raw Binary Loader] =
     147        @echo = MODULE: $(TARGET)               [16-bits Raw Protection Image] =
    167148        @echo =====================================================================
    168149#       @echo.
     
    200181# 16-bits RAW :: MBR virus protection to be embedded in the AIRBOOT.BIN image.
    201182###############################################################################
    202 $(TARGET):      .MULTIPLE $(BASENAME).COM
     183#$(TARGET):     $(BASENAME).COM
    203184#       $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
    204         $(CP) $(BASENAME).COM $(TARGET)
     185#       $(CP) $(BASENAME).COM $(TARGET)
    205186#       @echo $(%BLD_LANG)>$^.
    206         @if exist $^. @echo             $^. $(MSG_SUCCESS) - [$(%BLD_LANG) version]
     187#       @if exist $^. @echo             $^. $(MSG_SUCCESS) - [$(%BLD_LANG) version]
    207188#       $(RM) $(TARGET)
    208189#       @echo.
     
    211192
    212193###############################################################################
    213 # 16-bits COM :: Intermediate image without embedded MBR-prot. and code count.
    214 ###############################################################################
    215 $(BASENAME).COM:        .MULTIPLE $(BASENAME).OBJ
     194# 16-bits RAW :: MBR virus protection to be embedded in the AIRBOOT.BIN image.
     195###############################################################################
     196$(TARGET):      $(BASENAME).ASM
     197        @echo TARGET: $^.       [DOS 16-bits Raw Image]
     198        $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
     199        @wdis -fi $^&.OBJ > $^&.WDA
    216200        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
    217201#       $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. form raw
    218 #       @if exist $^. @echo             $^. $(MSG_SUCCESS)
    219 #       @echo.
    220 
    221 $(BASENAME).OBJ:        .MULTIPLE $(BASENAME).ASM
    222 #       @echo.
    223         @echo TARGET: $^.       [DOS 16-bits Raw Image]
    224         $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
    225         @wdis $^. > $^&.WDA
     202        @if exist $^. @echo             $^. $(MSG_SUCCESS)
     203        @ndisasm -k9,0 $^. > $^&.NDA
     204#       @echo.
     205
     206#$(BASENAME).OBJ:       $(BASENAME).ASM
     207#       @echo.
     208#       @echo TARGET: $^.       [DOS 16-bits Raw Image]
     209#       $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
     210#       @wdis -fi $^. > $^&.WDA
    226211
    227212
     
    242227# Remove all generated files.
    243228#
    244 clean:  .SYMBOLIC .MULTIPLE
     229clean:  .SYMBOLIC
    245230#       @echo CLEANING UP
    246231#       @for %%i in ($(TARGET)) do @if exist %%i $(RM) %%i
    247232        @if exist *.COM $(RM) *.COM
     233        @if exist *.BIN $(RM) *.BIN
    248234        @if exist *.OBJ $(RM) *.OBJ
    249235        @if exist *.WDA $(RM) *.WDA
     236        @if exist *.NDA $(RM) *.NDA
    250237        @if exist *.MAP $(RM) *.MAP
    251238        @if exist *.LST $(RM) *.LST
  • trunk/BOOTCODE/Makefile

    r45 r46  
    3131#
    3232# This embedding proccess consists of three parts:
    33 # - Assembling the virus-detection code, which always results
     33# - Assembling the virus-detection code, MBR_PROT.ASM, which always results
    3434#   in a 1024 bytes image.
    3535# - Compiling the FIXCODE program that does the actual embedding.
     
    3939
    4040#
    41 # After these operations have completed, the AIRBOOT.BIN image
     41# After these operations have been completed, the AIRBOOT.BIN image
    4242# is ready to be installed.
    4343#
     
    5454
    5555
    56 #
     56
     57
     58
     59#                                                       DEFINITIONS AND STUFF
     60# _____________________________________________________________________________
     61
     62
    5763# Include a Master Makefile with several cross-platform definitions and macros.
    5864# This is used to compensate for the differences between the target platforms.
    59 #
    6065!include        ../INCLUDE/MAKEFILE.MIF
    6166
    62 #
     67
    6368# Specifies the level of debugging.
    6469# Level 0 is no debugging (release) and each higher level may use other
    6570# assembler / compiler / linker flags and define jammed-in constants
    6671# to influence source assembly / compilation.
    67 #
    6872DEBUG_LEVEL=0
    6973MAX_DEBUG_LEVEL=2
    7074
    71 #
    7275# Protect against missing or invalid debug-levels.
    73 #
    7476!ifndef DEBUG_LEVEL
    7577!error DEBUG_LEVEL not defined !
     
    8284!endif
    8385
    84 #
    8586# Source Level base-name of Target to build.
    8687# The various language versions are created by replacing TXT-files
    8788# and reassembling this file.
    88 #
    8989BASENAME=AIR-BOOT
    9090
    91 #
    9291# When you are developing, you might want to do that using your own language.
    93 # Using wmake dev will built a module called AIRBOOT.BIN with this language
     92# Using 'wmake dev' will built a module called AIRBOOT.BIN with this language
    9493# and leave all the intermediate files intact.
    95 # You also want to set this to RU because for this language an extra charset
    96 # in included, taking up extra space. If it builds with RU it will build
    97 # with all other languages.
    98 #
     94# When developing on a non-RU language version, you need to do a 'wmake RU'
     95# from time-to-time to verify that you do not run out of space.
     96# This is needed because for this language the cyrillic charset is in included,
     97# taking up extra space. If it builds for RU it will build for all other
     98# languages.
    9999DEV_BLD_LANG=EN
    100100
    101 #
    102101# These are the languages that AiR-BOOT can be assembled with.
    103102# Adding a new language requires creating the relevant TXT-files,
    104103# placing then in the correct language directory and then add the lang-ID here.
    105 # RU is last in the list since it includes a charset will run out-of-space
    106 # sooner that the other languages. If that happens at least a few will be
    107 # built for analysis.
    108 #
    109 BLD_LANGUAGES=EN DE NL FR IT SW RU
     104# RU is last in the list since it includes the cyrillic charset and thus
     105# will run out-of-space sooner that the other languages.
     106# If that happens at least the others will be built.
     107BLD_LANGUAGES=EN DE NL FR IT SW #RU
    110108#BLD_LANGUAGES=EN DE NL
    111109
    112 #
    113110# For each language the Assembler source is compiled to a binary image
    114 # with this basename. Note that it differs from the source basename.
    115 #
     111# with this basename. When building one or more language versions, the
     112# final image is renamed to contain the language it was built for.
     113# When developing the final image is not renamed.
     114# Note that it differs from the source basename.
    116115MODULE=AIRBOOT
    117116
    118 #
    119117# This is a list of the Targets to be built.
    120118# For AiR-BOOT there is only one real target: AIRBOOT.BIN.
     
    122120# Only a dev-build does not rename it so it can directly be used by
    123121# the installer.
    124 #
    125122TARGET=$(MODULE).BIN
    126123
    127 #
    128 # Assembler Tools.
    129 #
     124#~ %AB_DEV=FALSE
     125
     126# Assembler Selection.
     127# Uncomment to enable.
     128# May be overridden by environment or platform choise !
     129
     130# JWTM -- JWasm, Wasm, Tasm and Masm.
     131ASM=jwasm
     132#ASM=wasm
     133#ASM=tasm
    130134#ASM=masm
    131135#ASM=alp
    132 ASM=tasm
    133 #ASM=wasm
    134 #ASM=jwasm
    135 
    136 #
    137 # JWasm does not work on DOS, so we override it.
    138 #
     136
     137
     138
     139# If there is an assembler specified in the environment, override
     140# the choise made above, if any.
     141!if "$(%ASM)"!=""
     142ASM=$(%ASM)
     143!endif
     144
     145# If no assembler is specified then default to JWasm.
     146!ifndef ASM
     147ASM=jwasm
     148!endif
     149
     150# JWasmD needs special settings in an OS/2 VDM so we override it for DOS.
     151# To run JWasmD in an OS/2 VDM, change DPMI from AUTO to ENABLED and
     152# set the XMS memory limit to 0.
     153# JWasmR will probably run out of memory and cannot be used.
    139154!ifdef  __MSDOS__
    140155ASM=tasm
    141156!endif
    142157
    143 #
    144158# There are no masm or alp for Linux and the yasm tasm-mode is incompatible.
    145159# So we override to jwasm when a non-jwasm assembler is specified and
    146160# we are building on Linux.
    147 #
    148161!ifdef  __LINUX__
    149162!if "$(ASM)"=="masm" | "$(ASM)"=="tasm" | "$(ASM)"=="alp"
     
    152165!endif
    153166
     167#
     168# Assembler Flags.
     169#
     170
     171# JWASM
    154172!if "$(ASM)"=="jwasm"
    155173# -Cp   = case sensitive symbols
     
    157175# -Zm   = Masm51 compat -- don't use ! (Will generate incorrect offsets)
    158176ASM_FLAGS_D0=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    159 ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    160 ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    161 !elseif "$(ASM)"=="masm"
    162 ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -fo=$^. -fr=$^&.ERR
    163 ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -d1 -fo=$^. -fr=$^&.ERR
    164 ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -d1 -fo=$^. -fr=$^&.ERR
     177ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     178ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     179
     180# WASM
    165181!elseif "$(ASM)"=="wasm"
    166 ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -fo=$^. -fr=$^&.ERR
     182# -w0   = suppress warnings (wasm is nice to check for missing size qualifiers)
     183ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -w0 -fo=$^. -fr=$^&.ERR
    167184ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -d1 -fo=$^. -fr=$^&.ERR
    168185ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dWASM -zq -d1 -fo=$^. -fr=$^&.ERR
     186
     187# TASM
    169188!elseif "$(ASM)"=="tasm"
    170189# -ml   = case sensitive symbols
    171190ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -l
    172 ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -z -zi -c -la
    173 ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -z -zi -c -la
     191ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -z -zi -c -la
     192ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -z -zi -c -la
     193
     194# MASM
     195!elseif "$(ASM)"=="masm"
     196ASM_FLAGS_D0=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DMASM -c -nologo -Cp -Fo$^. -Sa -Fl$^&.LST
     197ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DMASM -c -nologo -Cp -Zd -Zi -Fo$^. -Sa -Fl$^&.LST
     198ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DMASM -c -nologo -Cp -Zd -Zi -Fo$^. -Sa -Fl$^&.LST
     199
     200# ALP -- Does not support '/' for includes so it cannot be used for now.
    174201!elseif "$(ASM)"=="alp"
    175202ASM_FLAGS_D0=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ALP -Mb +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
    176203ASM_FLAGS_D1=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ALP -Mb +Od:MS16 +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
    177204ASM_FLAGS_D2=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ALP
     205
     206# UNKNOWN
    178207!else
    179 !error Unknown Assembler specified !
     208!error Unknown Assembler specified ! *$(ASM)*
    180209!endif
    181210ASM_FLAGS=$(ASM_FLAGS_D$(DEBUG_LEVEL))
    182211
    183 #
    184 # 16-bits C Compiler
    185 #
     212
     213#
     214# Compiler Flags.
     215#
     216
     217
     218# 16-bits C Compiler.
    186219CC16=wcc
    187220CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -fo=$^.
     
    190223CC16_FLAGS=$(CC16_FLAGS_D$(DEBUG_LEVEL))
    191224
    192 #
    193 # 32-bits C Compiler
    194 #
     225# 32-bits C Compiler.
    195226CC32=wcc386
    196227CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -6r -mf -fo=$^.
    197228CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
    198229CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
    199 CC32_FLAGS_R=-w4 -e25 -zq -od -6r -mf -fo=$^.
    200230CC32_FLAGS=$(CC32_FLAGS_D$(DEBUG_LEVEL))
    201231
    202232#
    203 # Linker
    204 #
     233# Linker Flags.
     234#
     235
     236# Open Watcom Linker.
    205237LNK=wlink
    206238LNK_FLAGS_D0=op q op v disa {1014 1023} op map=$^&.MAP
     
    209241LNK_FLAGS=$(LNK_FLAGS_D$(DEBUG_LEVEL))
    210242
    211 
    212 #
    213 # This is executed before Makefile processing.
    214 #
     243# These need to be built
     244DEPTARGETS=MBR-PROT ..$(DS)TOOLS$(DS)INTERNAL
     245
     246
     247
     248#                                                       BEFORE AND AFTER TARGETS
     249# _____________________________________________________________________________
     250
     251
     252# -----------------------------------------------------------------------------
     253# ANY PROCESSING BEFOREHAND
     254# -----------------------------------------------------------------------------
    215255.BEFORE
    216256#       @echo == BEFORE ==
    217257
    218 #
    219 # This is executed after Makefile processing.
    220 #
     258
     259# -----------------------------------------------------------------------------
     260# ANY PROCESSING AFTERWARDS
     261# -----------------------------------------------------------------------------
    221262.AFTER
    222263#       @echo == AFTER ==
     
    224265        @echo $(WARN_DOS_BLD_ENV)
    225266!endif
    226 
    227 
    228 #
     267!if "$(ASM)"=="wasm" | "$(ASM)"=="masm"
     268        @echo $(WARN_OVERLAP_NOT_SUPPORTED)
     269!endif
     270
     271
     272
     273
     274#                                               PSEUDO TARGETS FOR PREPARATION
     275# _____________________________________________________________________________
     276
     277
     278# -----------------------------------------------------------------------------
     279# BUILD ALL
     280# -----------------------------------------------------------------------------
    229281# This builds all the languages using normal dependency rules.
    230282# If this Makefile was modified, all targets are forcefully rebuilt.
    231283# At the end all intermediate files are deleted.
    232 # Use wmake dev to to development; this generated one image and leaves
     284# Use wmake dev to do development; that will generate one image and leave
    233285# the intermediate files intact.
    234 #
     286# -----------------------------------------------------------------------------
    235287all:    .SYMBOLIC Makefile.bu mbrprot $(BLD_LANGUAGES) footer
    236288#       @echo ALL !!
     
    240292        @%MAKE clean
    241293
    242 #
     294
     295# -----------------------------------------------------------------------------
     296# LANGUAGE SETUP
     297# -----------------------------------------------------------------------------
    243298# Setup the relevant language files.
    244 #
     299# This is done by generating include-files for the specified language.
     300# This is a 'pre-action' before assembling the AiR-BOOT.ASM source.
     301# -----------------------------------------------------------------------------
    245302langsetup:      .SYMBOLIC .MULTIPLE
     303# Default to development language is none defined.
     304!if "$(%BLD_LANG)"==""
     305%BLD_LANG=DEV_BLD_LANG
     306!endif
     307# Generate include-files for specified language.
     308# After this, the Assembly sources are setup for the specified language.
     309# Note that this target is not used as a 'dependency' but 'called' explicitly
     310# by the $(BLD_LANGUAGES) target.
    246311        @echo Include TEXT/$(%BLD_LANG)/MBR.ASM                 > TEXT$(DS)TXTMBR.ASM
    247312        @echo Include TEXT/$(%BLD_LANG)/MENUS.ASM               > TEXT$(DS)TXTMENUS.ASM
    248         @echo Include TEXT/$(%BLD_LANG)/OTHER.ASM       > TEXT$(DS)TXTOTHER.ASM
    249 
    250 #
    251 # For every language we Assemble and Link steps are performed.
    252 # This is the symbolic meta-target for that.
    253 # If functions as an iteration (for-next loop).
    254 #
     313        @echo Include TEXT/$(%BLD_LANG)/OTHER.ASM               > TEXT$(DS)TXTOTHER.ASM
     314
     315
     316# -----------------------------------------------------------------------------
     317# BUILD ALL LANGUAGES
     318# -----------------------------------------------------------------------------
     319# For every language we Assemble and Link these steps are performed.
     320# This is the symbolic meta-target for building a language version.
     321# If functions as an iteration (for-next loop) because the 'all:' target
     322# depends on it.
     323# -----------------------------------------------------------------------------
    255324$(BLD_LANGUAGES):       .SYMBOLIC
    256325        @SET BLD_LANG=$@
     
    260329        @%MAKE langsetup
    261330        @%MAKE $(TARGET)
    262 # Supress rename message for dev-build
     331# Checking %AB_DEV does not work from target 'dev:' when non-recursively
     332# invoked. Var '%AB_DEV' *is* set correctly but conditional !if's fail on it.
     333# Bug ?
     334#       @echo $(%AB_DEV)
     335# Do not rename for dev-build
    263336!if     "$(%AB_DEV)"!="TRUE"
    264         @echo   Renaming to AIRBT-$@.BIN
     337#~ !ifndef %AB_DEV
     338        @echo.
     339        @echo   ** Renaming Target **
    265340        $(MV) $(TARGET) AIRBT-$@.BIN
    266 #       @echo $@>AIRBT-$@.BIN $(%AB_DEV)
    267 !endif
    268 
     341!endif
     342#       @echo $(%AB_DEV)
    269343#       @%MAKE clean
    270344
     
    272346#
    273347# Some targets have the .MULTIPLE directive defined.
    274 # This is because the iteration "calls" for the creation of other (meta)
    275 # targets. If .MULTIPLE would not be defined these (meta) targets would not
    276 # be "built" anymore because the are considered up-to-date.
    277 # With multiple this assumption is removed and the target is "rebuilt" for
     348# This is because the language iteration 'calls' for the creation of
     349# other (meta) targets. If .MULTIPLE were not defined these (meta) targets
     350# would not be 'built' anymore because they are considered up-to-date.
     351# With multiple this assumption is removed and the target is 'rebuilt' for
    278352# every target that depends on it.
    279 # This mostly concerns meta operations like clean etc.,
    280 # but of course also the main building of the AIRBOOT.BIN module.
    281 #
    282 
    283 #
    284 # Show the header.
    285 #
     353#
     354
     355
     356# -----------------------------------------------------------------------------
     357# SHOW THE HEADER FOR THE TARGET BEING BUILT
     358# -----------------------------------------------------------------------------
    286359header: .SYMBOLIC .MULTIPLE
    287360        @echo.
     
    292365
    293366
    294 #
    295 # Show the footer.
    296 #
     367# -----------------------------------------------------------------------------
     368# SHOW THE FOOTER
     369# -----------------------------------------------------------------------------
    297370footer: .SYMBOLIC
    298371#       $(RM) $(TARGET)
     
    301374
    302375
    303 #
     376# -----------------------------------------------------------------------------
     377# CHECK FOR MAKEFILE CHANGES
     378# -----------------------------------------------------------------------------
    304379# Create a backup of the Makefile when it is modified.
    305380# This also forces a rebuild of all targets.
    306381# So, when changing i.e. the DEBUG_LEVEL, all targets are rebuilt
    307382# using the new level.
    308 #
     383# -----------------------------------------------------------------------------
    309384Makefile.bu:    Makefile
    310385        @echo.
     
    312387        @echo.
    313388        @%MAKE clean
    314         $(CP) Makefile Makefile.bu
     389        @$(CP) Makefile Makefile.bu > $(NULDEV)
    315390
    316391
     
    318393# DOS WMake has a bug in that it expands $^& and $^. to lowercase,
    319394# even though the definition is in uppercase.
    320 # This gives problems when building in an OS/2 DOS-Box on a network
    321 # share where also a Linux build-environment is active.
    322 # The Linux build-environment is case sensitive and will not
    323 # find the lowercase files.
     395# This gives problems when building in an OS/2 DOS-Box on a (samba) network
     396# share with a case-sensitive file-system where also a Linux build-environment
     397# is active. The Linux build-environment is will not find the lowercase files.
    324398# For example, a clean from Linux will not work properly in that case.
    325399# This does not influence building DOS targets on Linux.
     400# It can be circumvented by using a case-insensitive file-system for the
     401# network share, like OS/2 JFS for instance.
     402# Linux can use OS/2 JFS and will recognize it's case insensitivity.
     403# Or you could loop-mount the samba share either with the usual cifs tools
     404# or fuse-smb.
    326405#
    327406
     
    332411# - Very limited memory
    333412# - JWasmR does not work because of memory limitations
    334 # - JWasmD does not work at all
     413# - JWasmD needs special OS/2 VDM settings
    335414# - Batch scripting is very rudimentairy
    336415#
     
    340419# on OS/2, Windows or Linux.
    341420#
    342 
    343421
    344422
     
    366444
    367445
    368 #
    369 # MAIN TARGETS
    370 #
    371 
    372 
    373 ###############################################################################
    374 # 16-bits RAW :: Final image that can be executed when activated by the BIOS.
    375 ###############################################################################
     446#                                                               MAIN TARGETS
     447# _____________________________________________________________________________
     448
     449
     450# -----------------------------------------------------------------------------
     451# FINAL AIRBOOT.BIN IMAGE
     452# -----------------------------------------------------------------------------
     453# This is the final AiR-BOOT image and has been built for the language
     454# requested. It can be installed on a system using the AiR-BOOT Installer.
     455# Note that this build-rule will be invoked multiple times if more than
     456# one language-build is requested.
     457# Also, the intermediate .COM and final .BIN targets are disassembled back
     458# with NDISASM for cross reference.
     459# -----------------------------------------------------------------------------
    376460$(TARGET):      .MULTIPLE Makefile.bu $(BASENAME).COM
    377 #       $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
     461        @echo $^.:      [Final 16-bits raw Binary Image]
     462!ifdef  __MSDOS__
     463        ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODED.EXE
     464!endif
    378465!ifdef  __OS2__
    379         ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODE.COM
     466        ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODE2.EXE
     467!endif
     468!ifdef  __NT__
     469        ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODEW.EXE
    380470!endif
    381471!ifdef  __LINUX__
    382         ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODE
    383 !endif
    384 #       @echo   FIXCODE
    385         $(CP) $(BASENAME).COM $(TARGET)
     472#       ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODE
     473        @chmod +x ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODEL.ELF
     474        ..$(DS)TOOLS$(DS)INTERNAL$(DS)FIXCODEL.ELF
     475        @chmod +x $^.
     476!endif
     477        @echo.
     478!ifndef __MSDOS__
    386479        ndisasm $(BASENAME).COM > $(BASENAME).COM.NDA
    387480        ndisasm $(TARGET) > $(TARGET).NDA
    388 #       @echo $(%BLD_LANG)>$^.
    389         @if exist $^. @echo             $^. $(MSG_SUCCESS) - [$(%BLD_LANG) version]
    390 #       $(RM) $(TARGET)
    391 #       @echo.
    392 
    393 
    394 
    395 ###############################################################################
    396 # 16-bits COM :: Intermediate image without embedded MBR-prot. and code count.
    397 ###############################################################################
     481!endif
     482        @echo.
     483        @if exist $^. @echo             ** $^. $(MSG_SUCCESS) - [$(%BLD_LANG) version] **
     484
     485
     486# -----------------------------------------------------------------------------
     487# INTERMEDIATE AIR-BOOT.COM IMAGE
     488# -----------------------------------------------------------------------------
     489# This is an intermediate image without embedded MBR-protection and code count.
     490# It needs to be post-processed with FIXBOOT.
     491#
    398492# While both DOS COM and RAW linkage generate a flat 16-bits image with
    399493# fixed-up locations, DOS COM checks that the addressibility of the image does
    400494# not exceed the upper 64kB limit while RAW just wraps it's fixups.
    401 # So we use DOS COM linkage to proteced us from overflows in the BSS segment.
     495# So we use DOS COM linkage to proteced us from overflow incorrect fixups.
     496# -----------------------------------------------------------------------------
    402497$(BASENAME).COM:        .MULTIPLE $(BASENAME).OBJ
     498        @echo $^.:      [16-bits non-100h Intermediate Image]
    403499        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
    404500#       $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. form raw
    405 #       @if exist $^. @echo             $^. $(MSG_SUCCESS)
    406 #       @echo.
    407 
    408 #
    409 # Assembled Object File
    410 #
     501
     502
     503# -----------------------------------------------------------------------------
     504# INTERMEDIATE AIR-BOOT.OBJ OBJECT MODULE
     505# -----------------------------------------------------------------------------
     506# This is the result of assembling AIR-BOOT.ASM.
     507# It is assembled back twice with WDIS for cross reference.
     508# - once as an (almost) assemblable source-file
     509# - once as a disassembly with opcodes in it
     510# -----------------------------------------------------------------------------
    411511$(BASENAME).OBJ:        .MULTIPLE $(BASENAME).ASM
    412 #       @echo.
    413         @echo TARGET: $^.       [DOS 16-bits Raw Image]
     512        @echo $^.:      [16-bits OMF Object File]
    414513        $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
    415         @wdis $^. > $^&.WDA
    416 
    417 
    418 
    419 #
    420 # MAIN ACTIONS
    421 #
    422 
    423 
    424 #
    425 # Rebuild all targets.
    426 #
     514!ifndef __MSDOS__
     515        @wdis -a -p -fi $^. > $^&.WDA
     516!endif
     517        @wdis -fi $^. > $^..WDA
     518
     519
     520
     521#                                                               MAIN ACTIONS
     522# _____________________________________________________________________________
     523
     524
     525# -----------------------------------------------------------------------------
     526# DEVELOPER TARGET
     527# -----------------------------------------------------------------------------
     528# This meta-target builds an AIRBOOT.BIN module using the DEV_BLD_LANG setting.
     529# It does not change the file-name to correspond to the language,
     530# so it can directly be used by the installer.
     531# This is the main target when developing.
     532# -----------------------------------------------------------------------------
     533dev:    .SYMBOLIC
     534        @%MAKE rmbin
     535        @%MAKE mbrprot
     536        SET AB_DEV=TRUE
     537#       @%MAKE $(DEV_BLD_LANG)
     538# We need to recurse here because the environment is used to pass AB_DEV and
     539# the testing on it does not seem to work when using @%MAKE syntax. (bug ?)
     540# We also don't want .MULTIPLE which we won't get if we build just one target.
     541        @$(MAKE) $(DEV_BLD_LANG)
     542# Display the BLDLEVEL information if we are building on OS/2.
     543!ifdef  __OS2__
     544        @echo.
     545        @bldlevel $(TARGET)
     546!endif
     547
     548# -----------------------------------------------------------------------------
     549# REBUILD ALL TARGETS
     550# -----------------------------------------------------------------------------
    427551rebuild:        .SYMBOLIC
    428552        @%MAKE clean
    429553        @%MAKE all
    430554
    431 #
    432 # Remove all generated files.
    433 #
     555
     556# -----------------------------------------------------------------------------
     557# CLEANUP (intermediate files)
     558# -----------------------------------------------------------------------------
    434559clean:  .SYMBOLIC .MULTIPLE
    435560#       @echo CLEANING UP
    436561        @for %%i in ($(TARGET)) do @if exist %%i $(RM) %%i
    437562        @if exist *.COM $(RM) *.COM
     563        @if exist *.COM $(RM) *.EXE
    438564        @if exist *.OBJ $(RM) *.OBJ
    439565        @if exist *.WDA $(RM) *.WDA
     566        @if exist *.NDA $(RM) *.NDA
    440567        @if exist *.MAP $(RM) *.MAP
    441568        @if exist *.LST $(RM) *.LST
     
    443570        @if exist *.o   $(RM) *.o
    444571
    445 #
    446 # Remove all residual .BIN files.
    447 #
     572
     573# -----------------------------------------------------------------------------
     574# REMOVE ALL RESIDUAL .BIN FILES (old builds)
     575# -----------------------------------------------------------------------------
    448576rmbin:  .SYMBOLIC
    449577        @if exist *.BIN $(RM) *.BIN
    450578
    451 #
    452 # This meta-target build a module using the DEV_BLD_LANG setting.
    453 # It does not change the file-name so it can directly be used by the
    454 # installer.
    455 #
    456 dev:    .SYMBOLIC
    457         #eee
    458         @%MAKE rmbin
    459         @%MAKE mbrprot
    460         SET AB_DEV=TRUE
    461 #       @%MAKE $(DEV_BLD_LANG)
    462 # We need to recurse here because the environment is used to pass AB_DEV.
    463 # We also don't want .MULTIPLE which we won't get if we build just one target.
    464         @$(MAKE) $(DEV_BLD_LANG)
    465 
     579
     580# -----------------------------------------------------------------------------
     581# DISTRIBUTE TO RELEASE SPACE
     582# -----------------------------------------------------------------------------
     583# This distributes all .BIN files to BOOTCODE.
     584# Then it installs the English version to RELEASES as AIRBOOT.BIN.
     585# -----------------------------------------------------------------------------
    466586dist:   .SYMBOLIC
    467         $(CP) $(TARGET) ..$(DS)RELEASE$(DS)DOS
    468 
    469 #
    470 # Help on using this Makefile.
    471 #
     587        @if exist *.BIN $(CP) *.BIN ..$(DS)RELEASE$(DS)BOOTCODE
     588        @if exist AIRBT-EN.BIN $(CP) AIRBT-EN.BIN ..$(DS)RELEASE$(DS)DOS$(DS)$(TARGET)
     589        @if exist AIRBT-EN.BIN $(CP) AIRBT-EN.BIN ..$(DS)RELEASE$(DS)WINNT$(DS)$(TARGET)
     590        @if exist AIRBT-EN.BIN $(CP) AIRBT-EN.BIN ..$(DS)RELEASE$(DS)OS2$(DS)$(TARGET)
     591        @if exist AIRBT-EN.BIN $(CP) AIRBT-EN.BIN ..$(DS)RELEASE$(DS)LINUX$(DS)$(TARGET)
     592
     593
     594# -----------------------------------------------------------------------------
     595# SHOW HELP ON USING THIS MAKEFILE
     596# -----------------------------------------------------------------------------
    472597help:   .SYMBOLIC
    473598        @echo.
     
    484609        @echo.
    485610
    486 #
    487 # Show the list of buildable targets.
    488 #
     611
     612# -----------------------------------------------------------------------------
     613# SHOW LIST OF BUILDABLE TARGETS
     614# -----------------------------------------------------------------------------
    489615show:   .SYMBOLIC
    490616        @echo.
     
    496622        @%MAKE show
    497623
    498 #
    499 # Inform user that a rebuild might help if the build process fails.
    500 #
     624
     625# -----------------------------------------------------------------------------
     626# HINT USER WHEN A BUILD FAILS
     627# -----------------------------------------------------------------------------
    501628.ERROR
    502629        @echo.
    503630        @echo           Oops!
    504631        @echo           Some error occured in this build session.
    505         @echo           If it's a linker problem, it could be
    506         @echo           the result of out-of-sync object files.
    507         @echo           Doing a wmake rebuild might solve the problem.
    508         @echo           Type wmake help for a list of actions.
     632        @echo           If you see stuff about "positive count"
     633        @echo           you have a section overlap.
     634        @echo           Check the z_* values at the end of the list-file
     635        @echo           and look for a negative gap.
     636        @echo           Type 'wmake help' in the target dir for a list of actions.
    509637#       @%MAKE help
    510638        @echo.
    511639
    512 #
    513 # How the hell can we use get more than one command in the for-loop ??
    514 #
     640
     641# -----------------------------------------------------------------------------
     642# How the hell can we use more than one command in the for-loop ??
     643# -----------------------------------------------------------------------------
    515644ttt:    .SYMBOLIC
     645# This does not work...
    516646#       @for %%i in ($(BLD_LANGUAGES)) do %%i=X; $%WMAKE;
  • trunk/BOOTCODE/REGULAR/AUXIO.ASM

    r45 r46  
    7171
    7272
     73;
     74; Send the Build Information to the COM-port.
     75;
     76AuxIO_PrintBuildInfo    Proc    Near    Uses ax cx si di
     77        ; Print header.
     78        mov     si, offset build_info
     79        call    AuxIO_Print
     80
     81        ; Prepare info in temorary buffer.
     82        mov     si,offset bld_level_date_start
     83        mov     cx,offset bld_level_date_end
     84        sub     cx,si
     85        mov     di,offset Scratch
     86        cld
     87        rep     movsb
     88
     89        ; Fill spaces until assembler specification.
     90        mov     al,' '
     91        mov     cx,37
     92        rep     stosb
     93
     94        ; Copy assembler specification.
     95IFDEF   JWASM
     96        mov     al,'['
     97        stosb
     98        mov     si,offset jwasm_txt
     99ENDIF
     100IFDEF   TASM
     101        mov     al,' '
     102        stosb
     103        mov     al,'['
     104        stosb
     105        mov     si,offset tasm_txt
     106ENDIF
     107IFDEF   WASM
     108        mov     al,' '
     109        stosb
     110        mov     al,'['
     111        stosb
     112        mov     si,offset wasm_txt
     113ENDIF
     114IFDEF   MASM
     115        mov     al,' '
     116        stosb
     117        mov     al,'['
     118        stosb
     119        mov     si,offset masm_txt
     120ELSE
     121        mov     al,' '
     122        stosb
     123        mov     al,'['
     124        stosb
     125        mov     si,offset unknown_txt
     126ENDIF
     127    AuxIO_PrintBuildInfo_a1:
     128        lodsb
     129        test    al,al
     130        jz      AuxIO_PrintBuildInfo_e1
     131        stosb
     132        jmp     AuxIO_PrintBuildInfo_a1
     133    AuxIO_PrintBuildInfo_e1:
     134        mov     al,']'
     135        stosb
     136
     137        ; Insert NULL Terminator.
     138        xor     al,al
     139        stosb
     140
     141        ; Print Info.
     142        mov     si, offset Scratch
     143        call    AuxIO_Print
     144        call    AuxIO_TeletypeNL
     145        ret
     146AuxIO_PrintBuildInfo    EndP
     147
    73148
    74149; Print char to com-port (teletype style)
  • trunk/BOOTCODE/REGULAR/BOOTMENU.ASM

    r45 r46  
    6666
    6767   mov     dl, 18h
    68    cmp     CFG_BootMenuActive, 2
     68   cmp     byte ptr [CFG_BootMenuActive], 2
    6969   jne     BMBM_NoDetailed1
    7070   mov     dl, 15h
     
    8989   mov     si, offset TXT_TopInfos_Hd
    9090   add     cl, 5
    91    cmp     CFG_BootMenuActive, 2
     91   cmp     byte ptr [CFG_BootMenuActive], 2
    9292   jne     BMBM_NoDetailed2
    9393   mov     si, offset TXT_TopInfos_HdSize
     
    121121   push    cx
    122122      add     dl, 5
    123       cmp     CFG_BootMenuActive, 2
     123      cmp     byte ptr [CFG_BootMenuActive], 2
    124124      jne     BMBM_NoDetailed3
    125125      add     dl, 8
     
    159159      jb      BMBM_3rdTweak
    160160      add     cl, 5
    161       cmp     CFG_BootMenuActive, 2
     161      cmp     byte ptr [CFG_BootMenuActive], 2
    162162      jne     BMBM_BootWinTweakLoop
    163163      add     cl, 8
     
    446446   call    VideoIO_PrintByteNumber       ;  so only showing harddrives...
    447447   add     dh, 5
    448    cmp     CFG_BootMenuActive, 2
     448   cmp     byte ptr [CFG_BootMenuActive], 2
    449449   jne     BMBPT_NoDetailed
    450450      add     dh, 8
     
    548548   jae     BMBCB_NoScrollUp
    549549  BMBCB_ScrollingUp:
    550    dec     Menu_UpperPart
     550   dec     byte ptr [Menu_UpperPart]    ; Adjusted for Wasm
    551551   cmp     dh, Menu_UpperPart
    552552   jb      BMBCB_ScrollingUp
     
    560560  BMBCB_ScrollingDown:
    561561   inc     cl
    562    inc     Menu_UpperPart
     562   inc     byte ptr [Menu_UpperPart]    ; Adjusted for Wasm
    563563   cmp     dh, cl
    564564   jae     BMBCB_ScrollingDown
     
    696696        ; restlichen Variablen berechnen...
    697697        mov     dl, Menu_TotalParts
    698         cmp     Menu_TotalParts, 14
     698        cmp     byte ptr [Menu_TotalParts], 14
    699699        jbe     BMRMV_NotMoreThan14
    700700        mov     dl, 14
     
    704704        ; Now copy the name of the Timed-Booted Partition to TimedBoot-Field
    705705        mov     dl, Menu_EntryDefault
    706         test    CFG_TimedBootLast, 1
     706        test    byte ptr [CFG_TimedBootLast], 1
    707707        jz      BMRMV_TimedBootDefault
    708708        mov     dl, Menu_EntryLast
     
    726726        ; No Straight View in here...we got filtered view since BootMenu-Startup...
    727727        mov     al, CFG_RememberTimed
    728         test    TimedBootUsed, 1
     728        test    byte ptr [TimedBootUsed], 1
    729729        jnz     BMSVAM_TimedBootUsed
    730730        mov     al, CFG_RememberBoot
     
    762762        ; Finds out, where to place the bar at first...
    763763        mov     dl, Menu_EntryDefault
    764         test    CFG_RememberBoot, 1
     764        test    byte ptr [CFG_RememberBoot], 1
    765765        jnz     BME_RememberMode
    766         test    CFG_RememberTimed, 1
     766        test    byte ptr [CFG_RememberTimed], 1
    767767        jz      BME_ForgetMode
    768768    BME_RememberMode:
     
    785785        ;call    VideoIO_DBG_WriteString2    ; Rousseau
    786786
    787         test    TimedBootEnable, 1
     787        test    byte ptr [TimedBootEnable], 1
    788788        jz      BME_NoTimedBoot
    789789        ; ------------------------------------------------ TIMED BOOT
     
    805805        pop     ax
    806806        mov     dl, Menu_EntryDefault
    807         and     CFG_TimedBootLast, 1
     807        and     byte ptr [CFG_TimedBootLast], 1
    808808        jz      BME_TimedBootDefault
    809809        mov     dl, Menu_EntryLast
    810810    BME_TimedBootDefault:
    811811        mov     Menu_EntrySelected, dl        ; Just boot default partition
    812         mov     TimedBootUsed, 1           ; set flag...
     812        mov     byte ptr [TimedBootUsed], 1           ; set flag...
    813813        clc                                ; Boot-Now!
    814814        ret
     
    819819    BME_NoTimedBoot:
    820820        ; ------------------------------------------------ FLOPPY-NAME TIMER
    821         test    CFG_FloppyBootGetTimer, 1
     821        test    byte ptr [CFG_FloppyBootGetTimer], 1
    822822        jz      BME_NoFloppyNameTimer
    823823        ; Wait 2 Seconds everytime
     
    847847
    848848    BME_RefreshFloppyName:
    849         test    CFG_IncludeFloppy, 1
     849        test    byte ptr [CFG_IncludeFloppy], 1
    850850        jz      BME_NoRefreshFloppyName
    851         test    CFG_FloppyBootGetName, 1
     851        test    byte ptr [CFG_FloppyBootGetName], 1
    852852        jz      BME_NoRefreshFloppyName
    853853        call    DriveIO_UpdateFloppyName
     
    871871        je      BME_KeyESC
    872872        ; Upper Keys do not fall under Timed Boot Key Handling
    873         test    TimedBootEnable, 1
     873        test    byte ptr [TimedBootEnable], 1
    874874        je      BME_NoTimedKeyHandling
    875         cmp     CFG_TimedKeyHandling, 1
     875        cmp     byte ptr [CFG_TimedKeyHandling], 1
    876876        jb      BME_NoTimedKeyHandling     ; = 0
    877877        je      BME_ResetTimedBoot         ; = 1
    878878        mov     al, TimedBootEnable        ; = 2
    879879        xor     al, 1                      ; Flip Flop Switch :]
    880         mov     TimedBootEnable, al
     880        mov     [TimedBootEnable], al
    881881    BME_ResetTimedBoot:
    882882        push    dx
     
    905905    BME_KeyEnter:
    906906        mov     Menu_EntrySelected, dl
    907         mov     TimedBootUsed, 0              ; reset flag...
     907        mov     byte ptr [TimedBootUsed], 0              ; reset flag...
    908908        clc                                   ; Boot-Now!
    909909        ret
     
    911911    BME_KeyF10:
    912912        mov     al, Keys_Flags_EnterSetup
    913         mov     SETUP_KeysOnEntry, al         ; Simulate user wants to enter setup
     913        mov     byte ptr [SETUP_KeysOnEntry], al         ; Simulate user wants to enter setup
    914914        stc                                   ; Go Re-Enter Setup
    915915        ret
     
    921921
    922922    BME_KeyESC:
    923         mov     al, TimedBootEnable
     923        mov     al, [TimedBootEnable]
    924924        xor     al, 1                         ; Flip Flop Switch :]
    925         mov     TimedBootEnable, al
     925        mov     [TimedBootEnable], al
    926926        push    dx
    927927        call    BOOTMENU_ResetTimedBoot     ; Reset Timer
     
    932932    BME_KeyTAB:
    933933        push    dx
    934         test    CFG_CooperBars, 1
     934        test    byte ptr [CFG_CooperBars], 1
    935935        jnz     BME_KeyTAB_ShowFX
    936936        mov     ax, 0501h                  ; Go To Page 1 -> BIOS POST crap
     
    969969        add     ax, CFG_TimedDelay
    970970        adc     dx, 0
    971         mov     wptr [TimedTimeOut], ax
    972         mov     wptr [TimedTimeOut+2], dx
     971        mov     word ptr [TimedTimeOut], ax
     972        mov     word ptr [TimedTimeOut+2], dx
    973973        ret
    974974BOOTMENU_ResetTimedBoot     EndP
  • trunk/BOOTCODE/REGULAR/CONV.ASM

    r44 r46  
    209209        mov     cl,ah       ; Get remainder in CL.
    210210        sub     cl,dh       ; Substract bitfield width to get shift-count.
    211         mov     ah,0        ; Prepare upper=0 when field snaps no byte bound.
     211        mov     ah,0        ; Prepare upper=0 when field spans no byte bound.
     212                            ; Don't change to xor ah,ah or any CY will be lost.
    212213
    213214        ; Jump if the bitfield does not span byte boundaries.
     
    219220        add     cl,8        ; Adjust shift-count.
    220221        mov     ah,[bx]     ; Get byte into AH instead.
    221         dec     bx          ; Prepare pointer to load rest of bitfield.
     222        dec     bx          ; Adjust pointer to load rest of bitfield.
     223
    222224    CONV_GetBitfieldValue_nospan:
    223225        mov     al,[bx]     ; Load (rest of) bitfield into AL.
     
    267269        sub     cl,dh       ; Substract bitfield width to get shift-count.
    268270
    269         ; Restore value.
     271        ; Restore value to poke.
    270272        pop     ax
    271273
     
    282284        push    cx          ; Save mask (CH) and shift-count (CL).
    283285        push    ax          ; Save value to store.
    284         mov     ah,0        ; Clear upper byte so we can shift in it.
     286        xor     ah,ah       ; Clear upper byte so we can shift in it.
    285287        and     al,ch       ; Mask value.
    286288        shl     ax,cl       ; Move the bitfield to the proper location.
     
    289291        mov     dl,[bx]     ; Get 2nd part of bitfield from array.
    290292        push    bx          ; We need BX so save it.
    291         mov     bh,0        ; Clear upper byte so we can shift in it.
     293        xor     bh,bh       ; Clear upper byte so we can shift in it.
    292294        mov     bl,ch       ; Put mask in BL.
    293295        shl     bx,cl       ; Shift mask to proper location.
     
    304306        ; Done.
    305307        jmp     CONV_SetBitfieldValue_end
    306 
    307308
    308309    CONV_SetBitfieldValue_nospan:
  • trunk/BOOTCODE/REGULAR/DEBUG.ASM

    r45 r46  
    175175        call    AuxIO_Print
    176176
    177         ; Build Date
    178         mov     si, offset BUILD_DATE
    179         call    AuxIO_Print
     177        ; Build Info
     178        ;~ mov     si, offset BUILD_DATE
     179        ;~ call    AuxIO_Print
     180        call    AuxIO_PrintBuildInfo
    180181
    181182        ; Start new line
  • trunk/BOOTCODE/REGULAR/DRIVEIO.ASM

    r43 r46  
    311311
    312312      ;or       bx,ax
    313       test     [ExtendedAbsPosSet],1
     313      test     byte ptr [ExtendedAbsPosSet],1
    314314      jz       pri
    315315
     
    561561; Keeps DS:SI for caller, sets carry if valid LVM sector encountered
    562562DriveIO_LoadLVMSector   Proc Near  Uses ax bx cx dx
    563         test    [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
     563        test    byte ptr [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
    564564        jnz     DIOLLVMS_NoLVMSector          ;  don't load but declare as bad!
    565565        mov     ax, wptr cs:[CurPartition_Location+0]
     
    605605; Keeps DS:SI for caller, saves at anytime w/o checks (!)
    606606DriveIO_SaveLVMSector   Proc Near  Uses ax bx cx dx
    607         test    [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
     607        test    byte ptr [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
    608608        jnz     DIOSLVMS_SevereError          ;  don't save at anytime (security!)
    609609        mov     ax, wptr cs:[CurPartition_Location+0]
     
    633633;  so users will notice that something is bad with their partition table(s)
    634634DriveIO_GotLoadError    Proc Near
    635         test    cs:CurIO_Scanning, 1          ; Must be CS:, cause DS!=CS maybe here
     635        test    byte ptr cs:[CurIO_Scanning], 1          ; Must be CS:, cause DS!=CS maybe here
    636636        jnz     InScanMode
    637637        jmp     MBR_LoadError
     
    671671        jb      DIOLS_UseNormal
    672672
    673         test    cs:[CurIO_UseExtension], 1
     673        test    byte ptr cs:[CurIO_UseExtension], 1
    674674        jz      DIOLS_UseNormal
    675675        ; Are we forced do use LBA via Setting?
     
    794794; #########################################################################
    795795DriveIO_SaveSector              Proc Near  Uses ax bx cx ds si es di
    796         test    cs:[CurIO_UseExtension], 1
     796        test    byte ptr cs:[CurIO_UseExtension], 1
    797797        jz      DIOSS_UseNormal
    798798        ; Are we forced do use LBA via Setting?
    799         test    cs:[CFG_ForceLBAUsage], 1
     799        test    byte ptr cs:[CFG_ForceLBAUsage], 1
    800800        jnz     DIOSS_UseExtension
    801801        ; Is the drive not a harddrive?
     
    12301230        pop     bx
    12311231
    1232         mov      [CurIO_UseExtension],1
     1232        mov      byte ptr [CurIO_UseExtension],1
    12331233
    12341234        popf
  • trunk/BOOTCODE/REGULAR/OTHER.ASM

    r43 r46  
    9393        rep     stosw
    9494
    95         mov     VideoIO_Segment, VideoIO_Page0
     95        mov     word ptr [VideoIO_Segment], VideoIO_Page0
    9696
    9797        ; Don't use blinking attribute
     
    106106
    107107        ; Cursor to upper-left
    108         mov     TextPosX, 0
    109         mov     TextPosY, 0
     108        mov     byte ptr [TextPosX], 0
     109        mov     byte ptr [TextPosY], 0
    110110        call    VideoIO_CursorSet
    111111
     
    122122        ;call    SOUND_Beep
    123123
    124         ; Build Date
    125         mov     si, offset BUILD_DATE
    126         call    MBR_TeletypeNL
     124        ; Show build info
     125        call    VideoIO_PrintBuildInfo
    127126
    128127    IFDEF   AUX_DEBUG
     
    305304        ; Checks for MBR Virii :) I love that job
    306305        ; =======================================
    307         test    CFG_DetectStealth, 1
     306        test    byte ptr [CFG_DetectStealth], 1
    308307        jz      PCM_NoStealthDetection
    309308        call    VIRUS_CheckForStealth
    310309    PCM_NoStealthDetection:
    311         test    CFG_DetectVirus, 1
     310        test    byte ptr [CFG_DetectVirus], 1
    312311        jz      PCM_NoVirusDetection
    313312        call    VIRUS_CheckForVirus
     
    318317        ;  Delay for some time and get Strg/Alt State
    319318        ; ============================================
    320         test    CFG_CooperBars, 1
     319        test    byte ptr [CFG_CooperBars], 1
    321320        jnz     PCM_ShortDelay
    322321        mov     al, 27                        ; About 1.5 seconds
    323         test    CFG_FloppyBootGetName, 1
     322        test    byte ptr [CFG_FloppyBootGetName], 1
    324323        jz      PCM_LongDelay
    325324    PCM_ShortDelay:
     
    345344        mov     ah, 02h
    346345        int     16h
    347         mov     SETUP_KeysOnEntry, al
     346        mov     [SETUP_KeysOnEntry], al
    348347
    349348        ; Copy device-name to the ContBIOSbootSeq-IPT entry
     
    358357        ;  Now get volume label of FloppyDrive, if wanted...
    359358        ; ===================================================
    360         test    CFG_FloppyBootGetName, 1
     359        test    byte ptr [CFG_FloppyBootGetName], 1
    361360        jz      ACM_NoFloppyGetName
    362361        call    DriveIO_UpdateFloppyName
     
    381380        and     cx, 1
    382381        jz      PCCF13E_NotFound
    383         mov     CurIO_UseExtension, 1
     382        mov     byte ptr [CurIO_UseExtension], 1
    384383        ret
    385384PRECRAP_CheckFor13extensions    EndP
     
    406405        mov      cx,5
    407406
    408         mov     dx, CFG_CheckConfig
    409         mov     CFG_CheckConfig, bx
     407        mov     dx, [CFG_CheckConfig]
     408        mov     [CFG_CheckConfig], bx
    410409    PCCC_Loop:
    411410        call    MBR_GetCheckOfSector
     
    495494        mov     bh, 0
    496495        mov     ah, 02h
    497         mov     dh,[TextPosY]
    498         mov     dl,[TextPosX]
     496        mov     dh,byte ptr [TextPosY]
     497        mov     dl,byte ptr [TextPosX]
    499498        int     10h
    500499        popf
  • trunk/BOOTCODE/REGULAR/PARTMAIN.ASM

    r45 r46  
    8181   cmp     dl, 0FEh                      ; Resume-BIOS?
    8282   ja      PFUPN_SpecialSelectionFloppy
    83    cmp     CFG_ResumeBIOSbootSeq, 0
     83   cmp     byte ptr [CFG_ResumeBIOSbootSeq], 0
    8484   je      PFUPN_SelectionGone
    8585   jmp     PFUPN_Found
    8686  PFUPN_SpecialSelectionFloppy:
    87    cmp     CFG_IncludeFloppy, 0
     87   cmp     byte ptr [CFG_IncludeFloppy], 0
    8888   je      PFUPN_SelectionGone
    8989   jmp     PFUPN_Found
     
    192192   mov     si, offset PartitionTable
    193193   mov     bx, offset PartitionPointers
    194    test    CFG_IncludeFloppy, 1
     194   test    byte ptr [CFG_IncludeFloppy], 1
    195195   jz      PCMPP_NoFloppyInclude
    196196   mov     ax, offset FloppyIPTentry
     
    199199  PCMPP_NoFloppyInclude:
    200200
    201    test    CFG_ResumeBIOSbootSeq, 0FFh
     201   test    byte ptr [CFG_ResumeBIOSbootSeq], 0FFh
    202202   jz      PCMPP_NoResumeBootSeqInclude
    203203   mov     ax, offset BIOScontIPTentry
     
    920920   ; BX:AX -> Absolute End-Position of Partition
    921921
    922    test    CFG_ForceLBAUsage, 1
     922   test    byte ptr [CFG_ForceLBAUsage], 1
    923923   jnz     PSP_ForceI13X
    924924   ; LBA-boundary at 16450560 (FB0400h) (16320x16x63)
     
    942942        ; Insert signature
    943943        xor     di, di
    944         mov     wptr es:[di+00], '1I'
    945         mov     wptr es:[di+02], 'X3'
     944        mov     word ptr es:[di+00], '1I'
     945        mov     word ptr es:[di+02], 'X3'
    946946
    947947        ;mov     wptr es:[di], 0
     
    949949
    950950        ; Insert LBA address.
    951         mov     ax, wptr [si+LocIPT_AbsoluteBegin+0]
    952         mov     wptr es:[di+04], ax
    953         mov     ax, wptr [si+LocIPT_AbsoluteBegin+2]
    954         mov     wptr es:[di+06], ax
     951        mov     ax, [si+LocIPT_AbsoluteBegin+0]
     952        mov     es:[di+04], ax
     953        mov     ax, [si+LocIPT_AbsoluteBegin+2]
     954        mov     es:[di+06], ax
    955955
    956956        pop     si
     
    10301030  PSP_NoHideFeature:
    10311031   ; Check, if we are supposed to ignore LVM altogether...
    1032    test    [CFG_IgnoreLVM], 1
     1032   test    byte ptr [CFG_IgnoreLVM], 1
    10331033   jnz     PSP_NoLVMReassignment
    10341034   ; --------------------------------------------------------- LVM REASSIGNMENT
     
    10561056   call    MSHACK_ProcessPartTables
    10571057
    1058    test    CFG_BootMenuActive, 0FFh
     1058   test    byte ptr [CFG_BootMenuActive], 0FFh
    10591059   jz      PSP_NoMenuNoSound
    10601060
     
    10651065   ; -------------------------------------------------- SPECIAL BOOT PROCESSING
    10661066   ; Check here, if the Boot shall be done via resume to BIOS...
    1067    mov     al, bptr [si+LocIPT_SystemID]
     1067   mov     al, byte ptr [si+LocIPT_SystemID]
    10681068   cmp     al, 0FEh                      ; Via BIOS ? (aka resume BIOS boot sequence)
    10691069   je      PSP_ResumeBIOSbootSeq
     
    11411141  is_harddisk:
    11421142
    1143    test    CFG_DetectVIBR, 1
     1143   test    byte ptr [CFG_DetectVIBR], 1
    11441144   jz      PSP_NoVIBR
    11451145   test    byte ptr [si+LocIPT_Flags], Flags_VIBR_Detection
     
    11661166
    11671167 PSP_NoVIBR:
    1168    test    CFG_ProtectMBR, 1
     1168   test    byte ptr [CFG_ProtectMBR], 1
    11691169   jz      PSP_NoMBRprotect
    11701170   ; -------------------------------------------------- INSTALLS MBR-PROTECTION
  • trunk/BOOTCODE/REGULAR/PARTSCAN.ASM

    r45 r46  
    3636        mov     NewPartitions, al
    3737
    38         mov     CurIO_Scanning, 1             ; Set flag due scanning partitions
     38        mov     byte ptr [CurIO_Scanning], 1             ; Set flag due scanning partitions
    3939        mov     dl, 80h                       ; is first harddisc
    4040    PSSFP_HarddiscLoop:
     
    4646        dec     dh
    4747        jnz     PSSFP_HarddiscLoop
    48         mov     CurIO_Scanning, 0             ; Reset flag due scanning complete
     48        mov     byte ptr [CurIO_Scanning], 0             ; Reset flag due scanning complete
    4949
    5050IFDEF   AUX_DEBUG
     
    124124        inc     di
    125125        loop    PSSFP_AutoDrvLetterLoop
    126         mov     AutoDrvLetter, 0              ; Disable after processing...
     126        mov     byte ptr [AutoDrvLetter], 0              ; Disable after processing...
    127127    PSSFP_NoAutoDriveLetter:
    128128        ret
     
    176176            add     ax, wptr [ExtendedAbsPos+0] ; Adjust...
    177177            adc     bx, wptr [ExtendedAbsPos+2] ; (Shit Design!)
    178             test    [ExtendedAbsPosSet], 1
     178            test    byte ptr [ExtendedAbsPosSet], 1
    179179            jnz     PSSPFE_ExtendedMainKnown
    180180            mov     wptr [ExtendedAbsPos+0], ax
    181181            mov     wptr [ExtendedAbsPos+2], bx
    182             mov     [ExtendedAbsPosSet], 1
     182            mov     byte ptr [ExtendedAbsPosSet], 1
    183183        PSSPFE_ExtendedMainKnown:
    184184            mov     cx, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
     
    212212        ; Stop scanning if too many partitions.
    213213        ;
    214         cmp     word ptr [cs:NewPartitions],LocIPT_MaxPartitions
     214        cmp     word ptr cs:[NewPartitions],LocIPT_MaxPartitions
    215215        jae     skip_check
    216216        call    PARTSCAN_CheckThisPartition
     
    219219        ; Cannot boot LVM-Data partitions
    220220        pusha
    221         mov     byte ptr [cs:TooManyPartitions],1
     221        mov     byte ptr cs:[TooManyPartitions],1
    222222        mov     cx, 0C04h
    223223        ;~ mov     si, offset TXT_ERROR_TooManyPartitions
     
    630630        mov     al, PartTypeFlags
    631631        ; May I auto-add partitions ?
    632         test    CFG_PartitionsDetect, 1
     632        test    byte ptr [CFG_PartitionsDetect], 1
    633633        jz      PCCTP_MayNotAddAny ; add, but non-bootable
    634634        test    al, FileSysFlags_BootAble     ; AH kam von SearchFileSysName
     
    710710        mov     ax, dx
    711711        stosw
    712         inc     NewPartitions                ; NEW IPT Entry DONE
    713 
    714         cmp     NewPartitions, LocIPT_MaxPartitions
     712        inc     byte ptr [NewPartitions]; Adjusted for Wasm ; NEW IPT Entry DONE
     713
     714        cmp     byte ptr [NewPartitions], LocIPT_MaxPartitions
    715715        jbe     PCCTP_NotTooManyPartitions
    716716
  • trunk/BOOTCODE/REGULAR/PASSWORD.ASM

    r40 r46  
    3131PASSWORD_AskSystemPwd           Proc Near   Uses ax bx si di
    3232   ; Asks System Password, if set...
    33    test    CFG_PasswordSystem, 1
     33   test    byte ptr [CFG_PasswordSystem], 1
    3434   jz      PASP_NoPassword
    3535      mov     ax, 0ABABh
     
    4343PASSWORD_AskChangeBootPwd       Proc Near   Uses ax bx si di
    4444   ; Asks System Password, if set...
    45    test    CFG_PasswordChangeBoot, 1
     45   test    byte ptr [CFG_PasswordChangeBoot], 1
    4646   jz      PACBP_NoPassword
    47    test    TimedBootUsed, 1
     47   test    byte ptr [TimedBootUsed], 1
    4848   jnz     PACBP_NoPassword
    4949      mov     ax, 0ABABh
     
    7070PASSWORD_AskSpecifiedPassword   Proc Near   Uses cx dx ds si es di bp
    7171   local AskPasswordMiss:byte, AskPasswordText:word, AskPasswordMagic:word, AskPasswordWhich:word
    72    mov     AskPasswordMagic, ax
    73    mov     AskPasswordText, si
    74    mov     AskPasswordWhich, di
     72   mov     [AskPasswordMagic], ax
     73   mov     [AskPasswordText], si
     74   mov     [AskPasswordWhich], di
    7575   mov     ax, cs
    7676   mov     ds, ax
     
    8080   mov     cx, 8
    8181   rep     stosb                         ; Generates empty password
    82    mov     AskPasswordMiss, 0
    83    mov     ax, AskPasswordWhich
     82   mov     byte ptr [AskPasswordMiss], 0
     83   mov     ax, [AskPasswordWhich]
    8484   or      ax, ax
    8585   jnz     PASP_BadBoyRetry              ; Only check one
     
    106106
    107107      ; ...and compare it to the specified on-board one
    108       mov     di, AskPasswordWhich
     108      mov     di, [AskPasswordWhich]
    109109      or      di, di
    110110      jnz     PASP_OnlyCheckSpecified
     
    122122
    123123     PASP_LetUserGuessPassword:          ; ;-)))
    124       mov     ax, AskPasswordMagic
    125       mov     si, AskPasswordText
     124      mov     ax, [AskPasswordMagic]
     125      mov     si, [AskPasswordText]
    126126      mov     di, offset TempPasswordEntry
    127127      call    SETUP_LetEnterPassword
    128    inc     AskPasswordMiss
    129    cmp     AskPasswordMiss, 10
     128   inc     byte ptr [AskPasswordMiss]
     129   cmp     byte ptr [AskPasswordMiss], 10
    130130   jae     PASP_BadBoyAlert
    131131   jmp     PASP_BadBoyRetry
  • trunk/BOOTCODE/REGULAR/STD_TEXT.ASM

    r45 r46  
    2525
    2626; If you modify this Copyright and release this under your own name,
    27 ;  I'm going to sue your cheap ass, rape your dog and blow up your house. =)
     27; I'm going to sue your cheap ass, rape your dog and blow up your house. =)
    2828
    2929CopyrightVersionLen   equ   6
     
    4242;Copyright             db ' AiR-BOOT v1.0.8 - (c) 2012 M. Kiewitz  <<Release Candidate 1>> (bld: 20120124)', 0
    4343;Copyright             db ' AiR-BOOT v1.0.8 - (c) 2012 M. Kiewitz  <<Release Candidate 2>> (bld: 20120224)', 0
    44 Copyright             db ' AiR-BOOT v1.0.8 - (c) 2012 M. Kiewitz  <<Internal Release 2l>> (bld: 20120224)', 0
     44
     45
     46;~ Copyright             db ' AiR-BOOT v',BLDLVL_MAJOR_VERSION,'.',BLDLVL_MIDDLE_VERSION,'.',BLDLVL_MINOR_VERSION,' - (c) ',BLDLVL_YEAR,' M. Kiewitz  <<Internal Release 2l>> (bld: ',BLDLVL_YEAR,BLDLVL_MONTH,BLDLVL_DAY,')', 0
     47
     48;
     49; Masm found the above to be too complex, so we broke it up.
     50;
     51Copyright:
     52             db ' AiR-BOOT v'
     53             db BLDLVL_MAJOR_VERSION,'.'
     54             db BLDLVL_MIDDLE_VERSION,'.'
     55             db BLDLVL_MINOR_VERSION,' - (c) '
     56             db BLDLVL_YEAR
     57             db ' M. Kiewitz  <<Internal Release 2p>> (bld: '
     58             db BLDLVL_YEAR
     59             db BLDLVL_MONTH
     60             db BLDLVL_DAY,')'
     61             db 0
     62
     63
    4564;Copyright             db ' AiR-BOOT v1.0.8 - (c) 1998-2012 M. Kiewitz, Dedicated to Gerd Kiewitz', 0
    4665
     
    6887                            db 'Contact via e-mail: ', 0, 'airboot@ecomstation.com', 0
    6988
     89; Build Information string.
     90build_info          db  'Build Date: ',0
     91jwasm_txt           db  'JWasm',0
     92masm_txt            db  'Masm',0
     93wasm_txt            db  'Wasm',0
     94tasm_txt            db  'Tasm',0
     95unknown_txt         db  '????',0
     96
    7097ContinueBIOSbootTable dw offset TXT_SETUP_MAGIC_CDROM
    7198                      dw offset TXT_SETUP_MAGIC_Network
  • trunk/BOOTCODE/REGULAR/VIDEOIO.ASM

    r40 r46  
    650650VideoIO_SyncPos                 EndP
    651651
    652 
     652;
     653; Put the Build Information at the POST BIOS screen.
     654;
     655VideoIO_PrintBuildInfo  Proc    Near    Uses ax cx si di
     656        ; Print header.
     657        mov     si, offset build_info
     658        call    MBR_Teletype
     659
     660        ; Prepare info in temorary buffer.
     661        mov     si,offset bld_level_date_start
     662        mov     cx,offset bld_level_date_end
     663        sub     cx,si
     664        mov     di,offset Scratch
     665        cld
     666        rep     movsb
     667
     668        ; Fill spaces until assembler specification.
     669        mov     al,' '
     670        mov     cx,37
     671        rep     stosb
     672
     673        ; Copy assembler specification.
     674IFDEF       JWASM
     675        mov     al,'['
     676        stosb
     677        mov     si,offset jwasm_txt
     678ELSEIFDEF   TASM
     679        mov     al,' '
     680        stosb
     681        mov     al,'['
     682        stosb
     683        mov     si,offset tasm_txt
     684
     685ELSEIFDEF   WASM
     686        mov     al,' '
     687        stosb
     688        mov     al,'['
     689        stosb
     690        mov     si,offset wasm_txt
     691ELSEIFDEF   MASM
     692        mov     al,' '
     693        stosb
     694        mov     al,'['
     695        stosb
     696        mov     si,offset masm_txt
     697ELSE
     698        mov     al,' '
     699        stosb
     700        mov     al,'['
     701        stosb
     702        mov     si,offset unknown_txt
     703ENDIF
     704    VideoIO_PrintBuildInfo_a1:
     705        lodsb
     706        test    al,al
     707        jz      VideoIO_PrintBuildInfo_e1
     708        stosb
     709        jmp     VideoIO_PrintBuildInfo_a1
     710    VideoIO_PrintBuildInfo_e1:
     711        mov     al,']'
     712        stosb
     713
     714        ; Insert NULL Terminator.
     715        xor     al,al
     716        stosb
     717
     718        ; Print Info.
     719        mov     si, offset Scratch
     720        call    MBR_TeletypeNL
     721        ret
     722VideoIO_PrintBuildInfo  EndP
    653723
    654724;VideoIO_DBG_WriteString         Proc Near   Uses ax bx cx dx si es di
  • trunk/BOOTCODE/SETUP/MAIN.ASM

    r40 r46  
    2424ENDIF
    2525
    26 LocMENU_RoutinePtr           equ          0
    27 LocMENU_VariablePtr          equ          2
    28 LocMENU_ItemNamePtr          equ          4
    29 LocMENU_ItemHelpPtr          equ          6
    30 LocMENU_ItemPack             equ          8 ; only if VariablePtr>0
     26;~ LocMENU_RoutinePtr           equ          0
     27;~ LocMENU_VariablePtr          equ          2
     28;~ LocMENU_ItemNamePtr          equ          4
     29;~ LocMENU_ItemHelpPtr          equ          6
     30;~ LocMENU_ItemPack             equ          8 ; only if VariablePtr>0
    3131
    3232SETUP_UpperFixString          db 'SETUP ',0 ; AddOn for "AiR-BOOT SETUP vX.XX"
     
    8686
    8787
    88    test    CFG_AutoEnterSetup, 1
     88   test    byte ptr [CFG_AutoEnterSetup], 1
    8989   jnz     SCES_ForceEnter
    90    mov     al, SETUP_KeysOnEntry
     90   mov     al, [SETUP_KeysOnEntry]
    9191   test    al, Keys_Flags_EnterSetup
    9292IFDEF ReleaseCode
     
    100100
    101101SETUP_Main                      Proc Near   Uses si es bp
    102    mov     SETUP_ExitEvent, 0
     102   mov     byte ptr [SETUP_ExitEvent], 0
    103103   xor     al, al                        ; -PARTITION SETUP PreDefines-
    104    mov     PartSetup_UpperPart, al       ; Upper-Partition == 0
    105    mov     PartSetup_ActivePart, al      ; Active-Partition == 0
     104   mov     [PartSetup_UpperPart], al       ; Upper-Partition == 0
     105   mov     [PartSetup_ActivePart], al      ; Active-Partition == 0
    106106
    107107   ; Setup PartitionPointers-Table...again (needed when re-entering setup)
     
    118118;   CurMenu: Left Side 0-6, Right Side 8-14 (Bit 3!)
    119119SETUP_MenuTask                  Proc Near   ; the main-menu routine
    120    cmp     SETUP_ExitEvent, 1
     120   cmp     byte ptr [SETUP_ExitEvent], 1
    121121   jne     SMT_NoImmediateExit
    122122   ret
     
    132132   jne     SMT_NotMainMenu
    133133   call    FX_EndScreenLeft              ; Do FX, if requested...
    134    test    CFG_PasswordSetup, 1
     134   test    byte ptr [CFG_PasswordSetup], 1
    135135   jz      SMT_NotMainMenu
    136136   mov     ax, 0ABABh
     
    202202   mov     ch, dh
    203203   call    SETUP_SwitchToSelectedItem    ; Calculates SI for Item-No (CH)
    204    mov     ax, word ptr ds:[si+LocMENU_RoutinePtr]
    205    mov     bx, word ptr ds:[si+LocMENU_VariablePtr]
     204   mov     ax, ds:[si+LocMENU_RoutinePtr]
     205   mov     bx, ds:[si+LocMENU_VariablePtr]
    206206   or      bx, bx                        ; VarPtr ?
    207207   jnz     SMT_DoNotExecute
     
    210210      call    ax                         ; Call to CodePtr
    211211      call    SETUP_DrawMenuOnScreen     ; Redraw after return
    212       cmp     SETUP_ExitEvent, 1
     212      cmp     byte ptr [SETUP_ExitEvent], 1
    213213      je      SMT_ExitEvent
    214214  SMT_DoNotExecute:
     
    226226   mov     ch, dh
    227227   call    SETUP_SwitchToSelectedItem    ; Calculates SI for Item-No (CH)
    228    mov     ax, word ptr ds:[si+LocMENU_RoutinePtr]
    229    mov     bx, word ptr ds:[si+LocMENU_VariablePtr]
     228   mov     ax, ds:[si+LocMENU_RoutinePtr]
     229   mov     bx, ds:[si+LocMENU_VariablePtr]
    230230   or      bx, bx                        ; VarPtr ? =0 No ItemPack
    231231   jnz     SMT_DoItemPack
     
    272272   mov     ch, dh
    273273   call    SETUP_SwitchToSelectedItem    ; Calculates SI for Item-No (CH)
    274    mov     bx, word ptr ds:[si+LocMENU_ItemHelpPtr]
     274   mov     bx, ds:[si+LocMENU_ItemHelpPtr]
    275275   or      bx, bx                        ; Help-Ptr available ?
    276276   jz      SMT_NoHelpAvailable
     
    883883   mov     cx, 0E05h
    884884   call    VideoIO_Color
    885    mov     EnterPwd_Location, 0E26h
    886    mov     EnterPwd_DefinePwd, 1
     885   mov     word ptr [EnterPwd_Location], 0E26h
     886   mov     word ptr [EnterPwd_DefinePwd], 1
    887887   jmp     SLEP_JumpToInputProcess
    888888
     
    927927   ; DL - location of cursor (first=0)
    928928  SLEP_Loop:
    929    mov     cx, EnterPwd_Location
     929   mov     cx, [EnterPwd_Location]
    930930   call    VideoIO_Locate
    931931   push    si
     
    990990   or      dl, dl
    991991   jnz     SLEP_GotSomePassword
    992    cmp     EnterPwd_DefinePwd, 1
     992   cmp     word ptr [EnterPwd_DefinePwd], 1
    993993   je      SLEP_GotSomePassword
    994994   mov     cx, 8
     
    10441044  SEMSAES_DoThis:
    10451045   xor     al, al
    1046    mov     CFG_AutoEnterSetup, al
    1047    add     CFG_LastTimeEditLow, 1
    1048    adc     CFG_LastTimeEditHi, 0         ; Update Time-Stamp
     1046   mov     byte ptr [CFG_AutoEnterSetup], al
     1047   add     word ptr [CFG_LastTimeEditLow], 1
     1048   adc     word ptr [CFG_LastTimeEditHi], 0         ; Update Time-Stamp
    10491049   IFDEF ReleaseCode
    10501050      call    DriveIO_SaveConfiguration
    10511051   ENDIF
    1052    mov     SETUP_ExitEvent, 1            ; Exit and continue boot process
     1052   mov     byte ptr [SETUP_ExitEvent], 1            ; Exit and continue boot process
    10531053  SEMSAES_UserAbort:
    10541054   ret
     
    10601060   jnz     SEMEWS_UserAbort
    10611061   ; If we were forced to enter Setup, save configuration anyway...
    1062    test    CFG_AutoEnterSetup, 1
     1062   test    byte ptr [CFG_AutoEnterSetup], 1
    10631063   jz      SEMEWS_DoThis
    10641064   jmp     SEMEWS_DoThis                 ; Cross-Jump to SaveAndExitSetup!
     
    10681068      call    DriveIO_LoadConfiguration  ; This is *NOT* IPT nor HideConfig
    10691069   ENDIF
    1070    mov     SETUP_ExitEvent, 1            ; Exit and continue boot process
     1070   mov     byte ptr [SETUP_ExitEvent], 1            ; Exit and continue boot process
    10711071  SEMEWS_UserAbort:
    10721072   ret
     
    12701270        SMCP_AlreadyGotSelection:
    12711271         ; We use BL in here for tracking how many selections left
    1272          mov     bl, CFG_Partitions
     1272         mov     bl, [CFG_Partitions]
    12731273         cmp     dl, 0FEh
    12741274         jb      SMCP_DoneAdjust
    12751275         je      SMCP_AdjustContinueBIOS
    1276          cmp     CFG_IncludeFloppy, 0
     1276         cmp     byte ptr [CFG_IncludeFloppy], 0
    12771277         jne     SMCP_DoneAdjust
    12781278         dec     dl                      ; No Floppy? -> Try Resume-BIOS
    12791279        SMCP_AdjustContinueBIOS:
    1280          cmp     CFG_ResumeBIOSbootSeq, 0
     1280         cmp     byte ptr [CFG_ResumeBIOSbootSeq], 0
    12811281         jne     SMCP_DoneAdjust
    12821282         xor     dl, dl                  ; No Resume-BIOS? -> Start partition 0
     
    12911291     SMCP_Inc_RejectPartition:
    12921292      inc     dl                         ; Increase Selection No
    1293       cmp     dl, CFG_Partitions
     1293      cmp     dl, [CFG_Partitions]
    12941294      jb      SMCP_Inc_ModifyDone
    12951295      cmp     dl, 0FFh
    12961296      je      SMCP_Inc_TryFloppy
    12971297      mov     dl, 0FEh                   ; Try Resume-BIOS
    1298       cmp     CFG_ResumeBIOSbootSeq, 0
     1298      cmp     byte ptr [CFG_ResumeBIOSbootSeq], 0
    12991299      jne     SMCP_Inc_ModifyDone
    13001300      inc     dl                         ; Try Floppy
    13011301     SMCP_Inc_TryFloppy:
    1302       cmp     CFG_IncludeFloppy, 0
     1302      cmp     byte ptr [CFG_IncludeFloppy], 0
    13031303      jne     SMCP_Inc_ModifyDone
    1304       cmp     CFG_Partitions, 0
     1304      cmp     byte ptr [CFG_Partitions], 0
    13051305      je      SMCP_NoBootable
    13061306      inc     dl                         ; Now start at partition 0 again
     
    13251325      cmp     dl, 0FFh
    13261326      jb      SMCP_Dec_TryResumeBIOS
    1327       cmp     CFG_IncludeFloppy, 0
     1327      cmp     byte ptr [CFG_IncludeFloppy], 0
    13281328      jne     SMCP_Dec_ModifyDone
    13291329      dec     dl
    13301330     SMCP_Dec_TryResumeBIOS:
    1331       cmp     CFG_ResumeBIOSbootSeq, 0
     1331      cmp     byte ptr [CFG_ResumeBIOSbootSeq], 0
    13321332      jne     SMCP_Dec_ModifyDone
    13331333     SMCP_Dec_TryPartition:
    1334       mov     dl, CFG_Partitions
     1334      mov     dl, [CFG_Partitions]
    13351335      or      dl, dl
    13361336      jz      SMCP_NoBootable
     
    13471347     SMCP_GotSelection:
    13481348   pop     bx
    1349    mov     ds:[bx], dl                   ; neue Partition setzen
     1349   mov     ds:[bx], dl                   ; Set new partition
    13501350   add     si, LocIPT_Name               ; Location of Name
    13511351   push    cs
     
    15641564SETUPMAGIC_ChangeFloppyDisplay  Proc Near   Uses cx dx si es di
    15651565   call    SETUPMAGIC_EnableDisable      ; forward call
    1566    cmp     CFG_PartDefault, 0FFh         ; Default-Selection is us?
     1566   cmp     byte ptr [CFG_PartDefault], 0FFh         ; Default-Selection is us?
    15671567   jne     SMCFD_Done
    15681568   xor     ch, ch
     
    15901590   jnz     SMCBBS_Enabled
    15911591   mov     si, offset TXT_SETUP_MAGIC_Disabled
    1592    cmp     CFG_PartDefault, 0FEh         ; Default-Selection is us?
     1592   cmp     byte ptr [CFG_PartDefault], 0FEh         ; Default-Selection is us?
    15931593   jne     SMCBBS_CopyThiz
    15941594   mov     CFG_PartDefault, dl           ; Reset Default-Selection to 1st part
  • trunk/BOOTCODE/SETUP/PART_SET.ASM

    r45 r46  
    602602   call    VideoIO_Locate                ; Goes to CX
    603603
    604    mov     ChangePartNameSave, 0         ; Don't save to BR / LVM Sector
     604   mov     byte ptr [ChangePartNameSave], 0         ; Don't save to BR / LVM Sector
    605605
    606606   ; We compare, if our IPT contains the same partition name as in BR or LVM
     
    612612   mov   bh,0
    613613
    614    cmp     [PartitionVolumeLetters+bx], 0 ; ==0 means not supported by LVM
     614   cmp     byte ptr [PartitionVolumeLetters+bx], 0 ; ==0 means not supported by LVM
    615615   je      PSCPN_NotLVMSupported
    616616
     
    618618   ; Load LVM-Sector here and seek to PartitionName
    619619   ; Set CurPartition_Location information of destination partition
    620    mov     ax, wptr [si+LocIPT_AbsolutePartTable]
    621    mov     wptr [CurPartition_Location+0], ax
    622    mov     ax, wptr [si+LocIPT_AbsolutePartTable+2]
    623    mov     wptr [CurPartition_Location+2], ax
    624    mov     ah, bptr [si+LocIPT_LocationPartTable+0]
    625    mov     al, [si+LocIPT_Drive]
    626    mov     wptr [CurPartition_Location+4], ax
    627    mov     ax, wptr [si+LocIPT_LocationPartTable+1]
    628    mov     wptr [CurPartition_Location+6], ax
     620   mov     ax, [si+LocIPT_AbsolutePartTable]
     621   mov     [CurPartition_Location+0], ax
     622   mov     ax, [si+LocIPT_AbsolutePartTable+2]
     623   mov     [CurPartition_Location+2], ax
     624   mov     ah, byte ptr [si+LocIPT_LocationPartTable+0]
     625   mov     al, byte ptr [si+LocIPT_Drive]
     626   mov     [CurPartition_Location+4], ax
     627   mov     ax, [si+LocIPT_LocationPartTable+1]
     628   mov     [CurPartition_Location+6], ax
    629629   mov     di, si                        ; Put SI into DI
    630630   call    DriveIO_LoadLVMSector
    631631   jnc     PSCPN_LVMGotError             ; Security again, if problem -> halt
    632632   push    dx
    633       mov     ax, wptr [di+LocIPT_AbsoluteBegin]
    634       mov     dx, wptr [di+LocIPT_AbsoluteBegin+2]
     633      mov     ax, [di+LocIPT_AbsoluteBegin]
     634      mov     dx, [di+LocIPT_AbsoluteBegin+2]
    635635      call    LVM_SearchForPartition
    636636   pop     dx
     
    657657   ; Load Boot-Record...
    658658   push    dx
    659       mov     ax, wptr [si+LocIPT_AbsoluteBegin+0]
    660       mov     bx, wptr [si+LocIPT_AbsoluteBegin+2]
     659      mov     ax, [si+LocIPT_AbsoluteBegin+0]
     660      mov     bx, [si+LocIPT_AbsoluteBegin+2]
    661661      mov     cx, [si+LocIPT_LocationBegin+1]
    662662      mov     dh, [si+LocIPT_LocationBegin+0]
     
    696696
    697697    ; Do no synchronization initially.
    698     mov     [SyncLvmLabels],0
     698    mov     byte ptr [SyncLvmLabels],0
    699699
    700700  ; SI = IPT_Enty, DI points to LVM VolumeName.
     
    729729        repe    cmpsb               ; Compare V and P labels
    730730        jnz     LVM_Labels_not_equal
    731         mov     [SyncLvmLabels],1   ; Same so set flag for later
     731        mov     byte ptr [SyncLvmLabels],1   ; Same so set flag for later
    732732    LVM_Labels_not_equal:
    733733        pop     di
     
    744744   jne     PSCPN_LetUserEditPartName     ; -> No BR/LVM Changing/Saving
    745745
    746    mov     ChangePartNameSave, 1         ; Remember, so we will save to BR
     746   mov     byte ptr [ChangePartNameSave], 1         ; Remember, so we will save to BR
    747747
    748748  ; SI = IPT_Enty, DI points to LVM PartitionName.
     
    754754   jnc     PSCPN_AllDone                 ; Did user abort ?
    755755
    756    test    ChangePartNameSave, 1
     756   test    byte ptr [ChangePartNameSave], 1
    757757   jz      PSCPN_AllDone                 ; Actually we just skip BR/LVM-Save
    758758
     
    763763   mov   bh,0
    764764
    765    cmp     [PartitionVolumeLetters+bx], 0 ; ==0 means not supported by LVM
     765   cmp     byte ptr [PartitionVolumeLetters+bx], 0 ; ==0 means not supported by LVM
    766766   je      PSCPN_SaveBootRecord
    767767
     
    814814
    815815        ; See if LVM-labels need to be synced.
    816         test    [SyncLvmLabels],1
     816        test    byte ptr [SyncLvmLabels],1
    817817        jz      LVM_no_sync_labels
    818818
     
    869869   ; If Partition Selected Left-Side -> go Right-Sided Window
    870870   ;                                     otherwise Left-Sided.
    871    mov     PartSetup_ActivePart, dl
     871   mov     [PartSetup_ActivePart], dl
    872872   mov     ax, 0102h
    873873   and     dl, 1
     
    875875   mov     ax, 002Ah
    876876  PHSM_FirstStep:
    877    mov     PartSetup_HiddenX, al
    878    mov     PartSetup_HiddenAdd, ah
     877   mov     [PartSetup_HiddenX], al
     878   mov     [PartSetup_HiddenAdd], ah
    879879
    880880   ; Draw Menu...
    881881   xor     dx, dx
    882    mov     PartSetup_HiddenUpper, dl
     882   mov     [PartSetup_HiddenUpper], dl
    883883   call    PARTHIDESETUP_DrawMenuBase
    884884   call    PARTHIDESETUP_RefreshPartitions
     
    919919  PHSM_KeyESC:
    920920   ; Collect Hide-Partition-Config and put it into Hide-Table
    921    mov     dl, PartSetup_ActivePart
     921   mov     dl, [PartSetup_ActivePart]
    922922
    923923IFDEF   AUX_DEBUG
     
    977977   call    VideoIO_Color
    978978   mov     bh, 05h
    979    mov     bl, PartSetup_HiddenX
     979   mov     bl, [PartSetup_HiddenX]
    980980   mov     dh, 10h
    981981   mov     dl, bl
    982982   add     dl, 25h
    983    add     dl, PartSetup_HiddenAdd
     983   add     dl, [PartSetup_HiddenAdd]
    984984   push    bx
    985985      call    VideoIO_MakeWindow
     
    10101010   ; --- Make Window-Footer - "State when booting..." at bottom right frame-line
    10111011   mov     dh, 10h
    1012    mov     dl, PartSetup_HiddenX
     1012   mov     dl, [PartSetup_HiddenX]
    10131013   add     dl, 25h
    1014    add     dl, PartSetup_HiddenAdd       ; Location 16, HiddenX->right aligned
     1014   add     dl, [PartSetup_HiddenAdd]       ; Location 16, HiddenX->right aligned
    10151015   mov     si, offset TXT_SETUP_HideFeature2
    10161016   call    GetLenOfString                ; CX - Length of HideFeature2
    10171017   sub     dl, cl                        ; Adjust Position
    10181018   push    dx
    1019       mov     dl, PartSetup_ActivePart
     1019      mov     dl, [PartSetup_ActivePart]
    10201020      call    PART_GetPartitionPointer   ; Holt den Pointer der Partition (DL) nach SI
    10211021   pop     dx
     
    10801080; Draw all partitions to Hidden-Setup aka Dynamic Content-Draw
    10811081PARTHIDESETUP_RefreshPartitions Proc Near   Uses dx
    1082    mov     dl, PartSetup_HiddenUpper
     1082   mov     dl, [PartSetup_HiddenUpper]
    10831083   mov     dh, 8
    10841084  PHSRP_Loop:
     
    10951095   call    VideoIO_Color
    10961096   mov     cx, 0603h                     ; 6, +3
    1097    add     cl, PartSetup_HiddenX
    1098    mov     dl, PartSetup_HiddenUpper
     1097   add     cl, [PartSetup_HiddenX]
     1098   mov     dl, [PartSetup_HiddenUpper]
    10991099   call    PARTSETUP_UpperScrollMarker
    11001100   add     cl, 29
    1101    add     cl, PartSetup_HiddenAdd       ; 6, +29
     1101   add     cl, [PartSetup_HiddenAdd]       ; 6, +29
    11021102   call    PARTSETUP_UpperScrollMarker
    11031103   mov     cx, 0F03h                     ; 15, +3
    1104    add     cl, PartSetup_HiddenX
     1104   add     cl, [PartSetup_HiddenX]
    11051105   add     dl, 8                         ; add 8 -> points to last partition
    1106    mov     dh, CFG_Partitions            ; Limit
     1106   mov     dh, [CFG_Partitions]            ; Limit
    11071107   call    PARTSETUP_LowerScrollMarker
    11081108   add     cl, 29
    1109    add     cl, PartSetup_HiddenAdd       ; 6, +29
     1109   add     cl, [PartSetup_HiddenAdd]       ; 6, +29
    11101110   call    PARTSETUP_LowerScrollMarker
    11111111   ret
     
    11151115   local NoOfPart :byte
    11161116   mov     ch, dl
    1117    sub     ch, PartSetup_HiddenUpper
     1117   sub     ch, [PartSetup_HiddenUpper]
    11181118   add     ch, 7
    11191119   mov     cl, 2
    1120    add     cl, PartSetup_HiddenX
     1120   add     cl, [PartSetup_HiddenX]
    11211121   ; We got location
    11221122   mov     NoOfPart, dl
     
    11301130   pop     cx
    11311131
    1132    cmp     dl, CFG_Partitions
     1132   cmp     dl, [CFG_Partitions]
    11331133   jae     PHSDPI_NoData
    11341134
     
    12221222   xor     dh, dh
    12231223  PHSBCB_NoUnderflow:
    1224    cmp     dh, CFG_Partitions
     1224   cmp     dh, [CFG_Partitions]
    12251225   jb      PHSBCB_NoOverflow
    1226    mov     dh, CFG_Partitions
     1226   mov     dh, [CFG_Partitions]
    12271227   dec     dh
    12281228  PHSBCB_NoOverflow:
     
    12301230
    12311231   ; Do we need to scroll ?
    1232    mov     al, PartSetup_HiddenUpper
     1232   mov     al, [PartSetup_HiddenUpper]
    12331233   cmp     dl, al
    12341234   jb      PHSBCB_YesScrolling
     
    12381238   mov     al, dl
    12391239   sub     al, 7
    1240    mov     PartSetup_HiddenUpper, al
     1240   mov     [PartSetup_HiddenUpper], al
    12411241   call    PARTHIDESETUP_RefreshPartitions
    12421242   jmp     PHSBCB_NoScrolling
    12431243  PHSBCB_YesScrolling:
    12441244   mov     al, dl
    1245    mov     PartSetup_HiddenUpper, al
     1245   mov     [PartSetup_HiddenUpper], al
    12461246   call    PARTHIDESETUP_RefreshPartitions
    12471247  PHSBCB_NoScrolling:
     
    12631263   mov     bh, cl     ; Color to BH
    12641264   ; First calculate location of bar
    1265    cmp     dl, PartSetup_HiddenUpper
     1265   cmp     dl, [PartSetup_HiddenUpper]
    12661266   jb      PHSRCP_NotInWindowView
    12671267   mov     ch, dl
    1268    sub     ch, PartSetup_HiddenUpper     ; CH - Position relative to HiddenUpper
     1268   sub     ch, [PartSetup_HiddenUpper]     ; CH - Position relative to HiddenUpper
    12691269   cmp     ch, 8                         ; 8 - Maximum Total in Window
    12701270   jae     PHSRCP_NotInWindowView
    12711271   add     ch, 7
    12721272   mov     cl, 26
    1273    add     cl, PartSetup_HiddenX
    1274    add     cl, PartSetup_HiddenAdd
     1273   add     cl, [PartSetup_HiddenX]
     1274   add     cl, [PartSetup_HiddenAdd]
    12751275
    12761276   mov     bl, 10                        ; Length of Bar is 10
     
    13151315        ; each points to a partition.
    13161316        ; 3Fh is end-marker / maximum entries = CFG_Partitions
    1317         mov     cl, CFG_Partitions
     1317        mov     cl, [CFG_Partitions]
    13181318        mov     bx,di   ; Pointer to hidden-parts entry for this partition.
    13191319        mov     ch,0    ; Start index in hidden-parts entry for this partition.
     
    13741374        mov     si, offset PartitionTable
    13751375        xor     ch, ch                          ; Partition index
    1376         mov     cl, CFG_Partitions              ; Nr. of partitions in IPT
     1376        mov     cl, [CFG_Partitions]            ; Nr. of partitions in IPT
    13771377        mov     ah,0                            ; Next hide-index to write.
    13781378
     
    15231523   mov   bh,0
    15241524
    1525    mov     dl, bptr [DriveLetters+bx]
     1525   mov     dl, byte ptr [DriveLetters+bx]
    15261526
    15271527   push    bx
     
    16251625   call    VideoIO_Color
    16261626   mov     bh, 06h
    1627    mov     bl, PartSetup_HiddenX
     1627   mov     bl, [PartSetup_HiddenX]
    16281628   mov     dh, 0Ah
    16291629   mov     dl, bl
     
    16981698   push    dx
    16991699      mov     cx, 0805h                  ; Position 8, 5
    1700       add     cl, PartSetup_HiddenX
     1700      add     cl, [PartSetup_HiddenX]
    17011701      call    VideoIO_Locate
    17021702      add     cl, 6                      ; Everything centered (12/2)
  • trunk/BOOTCODE/SPECIAL/F00K/BILLSUXX.ASM

    r40 r46  
    3434MSHACK_ProcessPartTables        Proc Near  Uses ax dx di
    3535   ; Check Overall M$-Hack Enable
    36    test    [CFG_ExtPartitionMShack], 1
     36   test    byte ptr [CFG_ExtPartitionMShack], 1
    3737   jz      MSHPPT_NoMShack
    3838
  • trunk/BOOTCODE/SPECIAL/FAT16.ASM

    r40 r46  
    125125;            ES - Segment, where to read Cluster to
    126126;            DI - Offset, where to read Cluster to
    127 ;       Out: DX - Cluster that follows this one, [ES:DI] filled out
     127;       Out: DX - Cluster that follows this one, es:[DI] filled out
    128128;            DI - Offset, adjusted
    129129; Destroyed: None
  • trunk/BOOTCODE/SPECIAL/FX.ASM

    r40 r46  
    5252FX_CalculateTables              EndP
    5353
    54 ; This routine will dump a color-table to ES:[DI]. Total of 96 bytes.
     54; This routine will dump a color-table to ES:es:[DI]. Total of 96 bytes.
    5555;        In: AX - Color-Separator (RGB, per value 4 bit)
    5656;            DI - Pointer to Buffer for Color-Table
     
    112112;  so the screen will be generated there instead of the current page.
    113113FX_StartScreen                  Proc Near
    114    test    CFG_CooperBars, 1
     114   test    byte ptr [CFG_CooperBars], 1
    115115   jz      FXSS_NoFX
    116    mov     VideoIO_Segment, VideoIO_Page2
     116   mov     word ptr [VideoIO_Segment], VideoIO_Page2
    117117  FXSS_NoFX:
    118118   ret
     
    123123;  copy the new screen to Page 0 and activate it.
    124124FX_EndScreenLeft                Proc Near
    125    test    CFG_CooperBars, 1
     125   test    byte ptr [CFG_CooperBars], 1
    126126   jnz     FXESL_Go
    127127   ret
     
    137137      mov     ax, VideoIO_Page2
    138138      call    VideoIO_RestoreFrom
    139       mov     VideoIO_Segment, VideoIO_Page0
     139      mov     word ptr [VideoIO_Segment], VideoIO_Page0
    140140      call    FX_EndScreenInternalCleanUp
    141141   popa
     
    144144
    145145FX_ScrollScreenLeft             Proc Near
    146    mov     FX_WideScrollerCurPos, 640
    147    mov     FX_WideScrollerDirection, 0
    148    mov     FX_WideScrollerAbsDirection, 0
     146   mov     word ptr [FX_WideScrollerCurPos], 640
     147   mov     byte ptr [FX_WideScrollerDirection], 0
     148   mov     byte ptr [FX_WideScrollerAbsDirection], 0
    149149   call    FX_EndScreenInternalGo
    150150   ret
     
    152152
    153153FX_EndScreenRight               Proc Near
    154    test    CFG_CooperBars, 1
     154   test    byte ptr [CFG_CooperBars], 1
    155155   jnz     FXESR_Go
    156156   ret
     
    166166      mov     ax, VideoIO_Page2
    167167      call    VideoIO_RestoreFrom
    168       mov     VideoIO_Segment, VideoIO_Page0
     168      mov     word ptr [VideoIO_Segment], VideoIO_Page0
    169169      call    FX_EndScreenInternalCleanUp
    170170   popa
     
    173173
    174174FX_ScrollScreenRight            Proc Near
    175    mov     FX_WideScrollerCurPos, 0
    176    mov     FX_WideScrollerDirection, 1
    177    mov     FX_WideScrollerAbsDirection, 1
     175   mov     word ptr [FX_WideScrollerCurPos], 0
     176   mov     byte ptr [FX_WideScrollerDirection], 1
     177   mov     byte ptr [FX_WideScrollerAbsDirection], 1
    178178   call    FX_EndScreenInternalGo
    179179   ret
     
    181181
    182182FX_EndScreenInternalGo          Proc Near
    183    mov     FX_WideScrollerSpeed, 1
    184    mov     FX_WideScrollerSpeedState, 1
    185    mov     FX_WideScrollerBounceSpeed, 25
     183   mov     byte ptr [FX_WideScrollerSpeed], 1
     184   mov     byte ptr [FX_WideScrollerSpeedState], 1
     185   mov     byte ptr [FX_WideScrollerBounceSpeed], 25
    186186   ; Check, if this is 1st time call...
    187    inc     FX_UseCount
    188    cmp     FX_UseCount, 1
     187   inc     word ptr [FX_UseCount]
     188   cmp     word ptr [FX_UseCount], 1
    189189   jne     FX_ES_NotFirstTime
    190    mov     FX_OverallTimer, 220
    191    mov     FX_WideScrollerTimer, 93
    192    mov     FX_CooperBarsTimer, 1
     190   mov     word ptr [FX_OverallTimer], 220
     191   mov     word ptr [FX_WideScrollerTimer], 93
     192   mov     word ptr [FX_CooperBarsTimer], 1
    193193   jmp     FX_ES_NowGoMagic
    194194  FX_ES_NotFirstTime:
    195    mov     FX_OverallTimer, 127
    196    mov     FX_WideScrollerTimer, 1
    197    mov     FX_CooperBarsTimer, -1        ; Disable coopers on further goes
     195   mov     word ptr [FX_OverallTimer], 127
     196   mov     word ptr [FX_WideScrollerTimer], 1
     197   mov     word ptr [FX_CooperBarsTimer], -1  ; Disable coopers on further goes
    198198  FX_ES_NowGoMagic:
    199199   call    FX_MakeMagicalStuff
     
    275275      jb      FX_MCS_VerticalLoop
    276276
    277       mov     ax, FX_CooperBarsTimer
     277      mov     ax, [FX_CooperBarsTimer]
    278278      dec     ax
    279279      jnz     FX_MMS_CooperBarsPending
     
    282282      mov     ax, 1
    283283     FX_MMS_CooperBarsPending:
    284       mov     FX_CooperBarsTimer, ax
    285 
    286       mov     ax, FX_WideScrollerTimer
     284      mov     [FX_CooperBarsTimer], ax
     285
     286      mov     ax, [FX_WideScrollerTimer]
    287287      dec     ax
    288288      jnz     FX_MMS_WideScrollerPending
     
    290290      mov     ax, 1
    291291     FX_MMS_WideScrollerPending:
    292       mov     FX_WideScrollerTimer, ax
    293 
    294    dec     FX_OverallTimer
     292      mov     [FX_WideScrollerTimer], ax
     293
     294   dec     word ptr [FX_OverallTimer]
    295295   jnz     FX_MMS_RetraceLoop
    296296   ret
     
    417417
    418418FX_CalculateWideScroller        Proc Near
    419    mov     bx, FX_WideScrollerCurPos
     419   mov     bx, [FX_WideScrollerCurPos]
    420420   ;movzx   cx, FX_WideScrollerSpeed
    421    mov   cl,FX_WideScrollerSpeed
     421   mov   cl, [FX_WideScrollerSpeed]
    422422   mov   ch,0
    423423
    424    test    FX_WideScrollerAbsDirection, 1
     424   test    byte ptr [FX_WideScrollerAbsDirection], 1
    425425   jnz     FXCWS_RIGHT
    426426   jmp     FXCWS_LEFT
     
    428428   ; ================================================== WideScroll: LEFT CALC
    429429  FXCWS_LEFT:
    430    test    FX_WideScrollerSpeedState, 1
     430   test    byte ptr [FX_WideScrollerSpeedState], 1
    431431   jz      FXCWS_LEFT_Bouncing
    432432   or      bx, bx
     
    437437   or      cx, cx
    438438   jnz     FXCWS_DoSpeedThing
    439    mov     FX_WideScrollerSpeedState, 1
    440    mov     FX_WideScrollerDirection, 0
    441    mov     dl, FX_WideScrollerBounceSpeed
     439   mov     byte ptr [FX_WideScrollerSpeedState], 1
     440   mov     byte ptr [FX_WideScrollerDirection], 0
     441   mov     dl, [FX_WideScrollerBounceSpeed]
    442442   shr     dl,1
    443    mov     FX_WideScrollerBounceSpeed, dl
     443   mov     [FX_WideScrollerBounceSpeed], dl
    444444   jmp     FXCWS_DoSpeedThing
    445445
    446446  FXCWS_LEFT_BounceNOW:
    447    mov     cl, FX_WideScrollerBounceSpeed
    448    mov     FX_WideScrollerSpeedState, 0
    449    mov     FX_WideScrollerDirection, 1
     447   mov     cl, [FX_WideScrollerBounceSpeed]
     448   mov     byte ptr [FX_WideScrollerSpeedState], 0
     449   mov     byte ptr [FX_WideScrollerDirection], 1
    450450   jmp     FXCWS_DoSpeedThing
    451451
    452452   ; ================================================= WideScroll: RIGHT CALC
    453453  FXCWS_RIGHT:
    454    test    FX_WideScrollerSpeedState, 1
     454   test    byte ptr [FX_WideScrollerSpeedState], 1
    455455   jz      FXCWS_RIGHT_Bouncing
    456456   cmp     bx, 640 ; 1280
     
    461461   or      cl, cl
    462462   jnz     FXCWS_DoSpeedThing
    463    mov     FX_WideScrollerSpeedState, 1
    464    mov     FX_WideScrollerDirection, 1
    465    mov     dl, FX_WideScrollerBounceSpeed
     463   mov     byte ptr [FX_WideScrollerSpeedState], 1
     464   mov     byte ptr [FX_WideScrollerDirection], 1
     465   mov     dl, [FX_WideScrollerBounceSpeed]
    466466   shr     dl, 1
    467    mov     FX_WideScrollerBounceSpeed, dl
     467   mov     [FX_WideScrollerBounceSpeed], dl
    468468   jmp     FXCWS_DoSpeedThing
    469469
    470470  FXCWS_RIGHT_BounceNOW:
    471    mov     cl, FX_WideScrollerBounceSpeed
    472    mov     FX_WideScrollerSpeedState, 0
    473    mov     FX_WideScrollerDirection, 0
     471   mov     cl, [FX_WideScrollerBounceSpeed]
     472   mov     byte ptr [FX_WideScrollerSpeedState], 0
     473   mov     byte ptr [FX_WideScrollerDirection], 0
    474474   jmp     FXCWS_DoSpeedThing
    475475
    476476   ; ================================================= WideScroll: SPEED CALC
    477477  FXCWS_DoSpeedThing:
    478    test    FX_WideScrollerSpeedState, 1
     478   test    byte ptr [FX_WideScrollerSpeedState], 1
    479479   jnz     FXCWS_SpeedUp
    480480  FXCWS_SpeedDown:
     
    493493  FXCWS_WideScrollNOW:
    494494   xor     ch, ch
    495    test    FX_WideScrollerDirection, 1
     495   test    byte ptr [FX_WideScrollerDirection], 1
    496496   jnz     FXCWS_ScrollRIGHT
    497497   sub     bx, cx
     
    508508   mov     bx, 640 ; 1280
    509509  FXCWS_NotToBig:
    510    mov     FX_WideScrollerCurPos, bx
    511    mov     FX_WideScrollerSpeed, cl
     510   mov     [FX_WideScrollerCurPos], bx
     511   mov     [FX_WideScrollerSpeed], cl
    512512   mov     ax, 160
    513513   call    FX_SetWideLength
  • trunk/BOOTCODE/SPECIAL/LVM.ASM

    r40 r46  
    8585LVM_GetSectorCRC                EndP
    8686
    87 ; Checks DS:[SI], if a valid LVM Signature is found (sets carry in that case)
     87; Checks ds:[SI], if a valid LVM Signature is found (sets carry in that case)
    8888;  This does not check for valid LVM CRC (which also needs to be done)
    8989;        In: DS:SI - Sector that needs to get checked...
     
    9191; Destroyed: None
    9292LVM_CheckSectorSignature        Proc Near
    93    test    [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
     93   test    byte ptr [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
    9494   jnz     LVMCSS_InvalidSignature       ;  any sector is bad!
    95    cmp     wptr [si+LocLVM_SignatureStart], 5202h                                ; Rousseau: identify LVM sector
     95   cmp     word ptr [si+LocLVM_SignatureStart], 5202h                                ; Rousseau: identify LVM sector
    9696   jne     LVMCSS_InvalidSignature
    97    cmp     wptr [si+LocLVM_SignatureStart+2], 'BM'
     97   cmp     word ptr [si+LocLVM_SignatureStart+2], 'BM'
    9898   jne     LVMCSS_InvalidSignature
    99    cmp     wptr [si+LocLVM_SignatureStart+4], 'MP'
     99   cmp     word ptr [si+LocLVM_SignatureStart+4], 'MP'
    100100   jne     LVMCSS_InvalidSignature
    101    cmp     wptr [si+LocLVM_SignatureStart+6], 'DF'
     101   cmp     word ptr [si+LocLVM_SignatureStart+6], 'DF'
    102102   jne     LVMCSS_InvalidSignature
    103103   stc
     
    115115LVM_CheckSectorCRC              Proc Near   Uses ax dx
    116116   call    LVM_GetSectorCRC
    117    cmp     ax, wptr [si+LocLVM_CRC]
     117   cmp     ax, word ptr [si+LocLVM_CRC]
    118118   jne     LVMCSCRC_BadCRC
    119    cmp     dx, wptr [si+LocLVM_CRC+2]
     119   cmp     dx, word ptr [si+LocLVM_CRC+2]
    120120   jne     LVMCSCRC_BadCRC
    121121   stc
     
    133133LVM_UpdateSectorCRC            Proc Near   Uses ax dx
    134134   call    LVM_GetSectorCRC
    135    mov     wptr [si+LocLVM_CRC], ax
    136    mov     wptr [si+LocLVM_CRC+2], dx
     135   mov     word ptr [si+LocLVM_CRC], ax
     136   mov     word ptr [si+LocLVM_CRC+2], dx
    137137   ret
    138138LVM_UpdateSectorCRC            EndP
  • trunk/BOOTCODE/SPECIAL/SOUND.ASM

    r30 r46  
    2727
    2828SOUND_PreBootMenu              Proc Near  Uses ax
    29    test    CFG_MakeSound, 1
     29   test    byte ptr [CFG_MakeSound], 1
    3030   jz      SOUND_PreBootMenu_SkipSound
    31    test    StartSoundPlayed, 1
     31   test    byte ptr [StartSoundPlayed], 1
    3232   jnz     SOUND_PreBootMenu_SkipSound
    3333   mov     ax, 1500
     
    3939   mov     ax, 200
    4040   call    SOUND_WaitToSilence
    41    mov     StartSoundPlayed, 1
     41   mov     byte ptr [StartSoundPlayed], 1
    4242  SOUND_PreBootMenu_SkipSound:
    4343   ret
     
    4545
    4646SOUND_ExecuteBoot              Proc Near  Uses ax
    47    test    CFG_MakeSound, 1
     47   test    byte ptr [CFG_MakeSound], 1
    4848   jz      SOUND_ExecuteBoot_SkipSound
    4949   mov     ax, 2000
  • trunk/BOOTCODE/_build.cmd

    r37 r46  
     1@SET ASM=tasm
    12@wmake dev
  • trunk/BUILD.NFO

    r37 r46  
    1 ======================================================
     1===============================================================================
    22 BUILD.NFO -- Information on building AiR-BOOT v1.0.8
    3 ======================================================
     3===============================================================================
    44
    55Building AiR-BOOT and the support tools has been completely revamped
     
    1515also adding extensive cross-platform support.
    1616
     17Several cross-reference files are generated, like object disassemblies
     18and executable header dumps. This aids development in checking for assembler
     19generation and the correctness of that code.
     20
    1721The (DOS-only) FIXCODE.COM program that is used to embed the MBR-protection
    1822in the AiR-BOOT image has been replaced by platform specific versions.
     
    2125
    2226The preferred assembler is now JWasm.
    23 Note however that JWasm/DOS does not work so this environment will use
    24 Tasm/DOS. The DOS build-environment will probably be discontinued in
     27While Tasm4/Masm6 and Wasm are also supported, their use should be of an
     28experimental nature only. Limitations for checking section overlaps
     29and other assembler specific directives inhibit the use of JWasm to
     30it's fullest capability.
     31Since JWasm is open-source and mature, there is no need to support other
     32assemblers in future releases of AiR-BOOT.
     33
     34The JWasmD extended DOS version needs DPMI 'enabled' and XMS set to 0
     35to be able to run in an eCS DOS session.
     36The DOS build-environment will probably be discontinued in
    2537the future due to it's many restrictions. DOS specific targets can
    2638be built on the other platforms.
    2739
    2840The Open Watcom tool-chain in combination with JWasm is now the
    29 default tool-chain. No syntax or operational compatibility with other
    30 assemblers or compilers is attempted.
     41default tool-chain.
    3142
    3243Building AiR-BOOT v1.0.8 requires the following tools:
     
    3546- Open Watcom 32-bits C-Compiler v1.9 or higher
    3647- Open Watcom Linker v1.9 or higher
    37 - JWasm Assembler v2.06d
     48- JWasm Assembler v2.06d or higher
    3849
    3950As a convenience a simple GNUmakefile also exists where a Makefile exists.
     
    4354Note that only the loader, installer and setaboot targets are built.
    4455No floppy, cd-rom, etc. images.
     56
     57
     58Rousseau.
  • trunk/INCLUDE/ASM.INC

    r45 r46  
    100100; This macro does a check for this condition and aborts if it exists.
    101101; If there is space between the new location and the last emitted code or data
    102 ; will be filled.
     102; it will be filled with a filler-value defined in this macro..
    103103;
    104104; There are differences between assemblers on when and how labels and values
     
    107107; That's why the actual check for overlap is done by db getting a negative
    108108; value if an overlap occured.
    109 ; So don't change the (after - before) calculations by assigning it to a
    110 ; variable; that will break this macro.
     109; Don't change the (after - before) expression to a pre-calculated label
     110; because that won't work and will break this macro.
    111111;
    112112ORIGIN  MACRO   loc
     
    119119    ; Use this value to fill the gap between the new origin and the last
    120120    ; emitted code or data.
    121     fillchar = 'X'
     121    fillchar = '0'
    122122
    123123    ; Mark the location of the last emitted code or data.
     
    125125
    126126    ; JWasm can do db 0 dup (0).
     127    ; Using db dup() causes JWasm to recognize the after label so that
     128    ; overlap calculations are correct.
    127129    IFDEF   JWASM
    128130        db  (z_&loc&_2after - z_&loc&_1before)   dup(fillchar)
    129131    ENDIF
    130132
    131     ; Tasm cannot.
     133    ; Tasm cannot do db 0 dup(0), so we exclude that condition.
     134    ; Overlap checking could be done differently in Tasm but to keep things
     135    ; easy the JWasm method above is used.
    132136    IFDEF   TASM
    133137        IF (z_&loc&_2after - z_&loc&_1before) NE 0
    134138            db  (z_&loc&_2after - z_&loc&_1before)   dup(fillchar)
    135139        ENDIF
     140    ENDIF
     141
     142    ; Masm can also do db 0 dup (0), and it does calculate correctly
     143    ; but cannot find the after label.
     144    ; Same issue as with JWasm but the db construct does not solve it for masm.
     145    ; The label-values show-up to be correct in the listing though.
     146    ; Currently overlap-checking is disabled when assembling with Masm !
     147    ; FIXME: Find a solution for Masm.
     148    IFDEF   MASM
     149        ;~ db  (z_&loc&_2after - z_&loc&_1before)   dup(fillchar)
     150        ECHO ** Warning: Overlap Check on: loc not performed !
     151    ENDIF
     152
     153    ; Wasm can also do db 0 dup (0), but it complains about brackets or so.
     154    ; Seems to be some syntax issue.
     155    ; It cannot generate a list-file so values cannot be checked.
     156    ; It does not even support ECHO so no warning can be given.
     157    ; So overlap-checking is disabled when assembling with Wasm !
     158    ; FIXME: Find a solution for Wasm.
     159    IFDEF   WASM
     160        ; NOT EVEN ECHO IS SUPPORTED !
     161        ;~ db  (z_&loc&_2after - z_&loc&_1before)   dup(fillchar)
    136162    ENDIF
    137163
     
    161187
    162188
    163 sector_size                      equ   512
    164 image_size_60secs                equ   7800h
    165 image_size_62secs                equ   7c00h
     189sector_size                      equ   512      ; Normal size of a sector.
     190image_size_60secs                equ   7800h    ; Size of the pre v1.07 image.
     191image_size_62secs                equ   7c00h    ; Size of the post v1.06 image.
    166192
    167193;image_size                       equ   image_size_60secs
    168194image_size                       equ   image_size_62secs
    169195
    170 sector_count                     equ   image_size / sector_size                  ; Image size in sectors
     196; Image size in sectors
     197sector_count                     equ   image_size / sector_size
    171198
    172199IF image_size EQ image_size_60secs
    173    partition_count               equ   30                                        ; Maximum number of partitions supported
     200    ; Maximum number of partitions supported in pre v1.07.
     201   partition_count               equ   30
    174202ELSE
    175    partition_count               equ   45                                        ; Maximum number of partitions supported
     203    ; Maximum number of partitions supported in post v1.06.
     204   partition_count               equ   45
    176205ENDIF
  • trunk/INCLUDE/MAKEFILE.MIF

    r37 r46  
    9898#
    9999WARN_DOS_BLD_ENV=Warning: The DOS build-environment has limited functionality !
     100WARN_OVERLAP_NOT_SUPPORTED=Warning: Overlap Checking not supported for assembler: "$(ASM)" !
    100101
    101102#
     
    125126DS              = \
    126127PS              = ;
     128NULDEV  = nul:
    127129BS              = _build.bat
    128130SHELL   = $(DOSSHELL)
     
    141143DS              = \
    142144PS              = ;
     145NULDEV  = nul:
    143146BS              = _build.cmd
    144147SHELL   = $(OS2SHELL)
     
    157160DS              = \
    158161PS              = ;
     162NULDEV  = nul:
    159163BS              = _build.cmd
    160164SHELL   = $(WINSHELL)
     
    173177DS              = /
    174178PS              = :
     179NULDEV  = /dev/null
    175180BS              = _build.bash
    176181SHELL   = $(LINSHELL)
  • trunk/INCLUDE/MAKEFRWD.MIF

    r37 r46  
    1111# and '%:' to forward one or more targets.
    1212#
    13 # Because GNU Make first looks for GNUmakefile, which only includes this
    14 # forwarder, it will process this file before Makefile.
    15 # The Make Utility that we forward to will process Makefile.
     13# Because GNU Make first looks for 'GNUmakefile', which only includes this
     14# forwarder, it will process this file before 'Makefile'.
     15# The Make Utility that we forward to will process 'Makefile'.
    1616#
    1717# Note that GNU Make processes the '%:' target-list sequentially.
     
    2121#
    2222# With wmake the targets are all specified in the Makefile so dependencies
    23 # are resolved. With make each target is seperately forwarded to wmake,
    24 # so no dependencies are resolved. This means that a 'make rebuild clean'
    25 # behaves exactly like that, removing all just built targets,
    26 # because the 'clean' is performed last.
    27 # The 'wmake rebuild clean' will not run the last 'clean' because 'rebuild'
     23# are resolved. With GNU Make, each target is seperately forwarded to Makefile
     24# wmake, so no dependencies are resolved.
     25# This means that a 'make rebuild clean' behaves exactly like that,
     26# removing all just built targets, because the 'clean' is performed last.
     27# A 'wmake rebuild clean' will not run the last 'clean' because 'rebuild'
    2828# runs it before doing the build, so 'clean' is considered up-to-date.
    2929#
  • trunk/INSTALL/C/.build

    r45 r46  
    11#!/bin/bash
    22
    3 make clean
     3make clean 
    44make
  • trunk/INSTALL/C/.clean

    r45 r46  
    22
    33make clean
    4 make
  • trunk/INSTALL/C/INSTALL.C

    r36 r46  
    1717//
    1818
    19 #if defined(__OS2__) && !defined(OS2)
    20    // OS/2 platform
    21    #define INCL_NOPMAPI
    22    #define INCL_BASE
    23    #define INCL_DOS
    24    #define INCL_DOSDEVIOCTL
    25    #include <os2.h>
    26    #include <malloc.h>
    27    #include <stdlib.h>                                                           // Rousseau: added to use getenv()
    28    #define PLATFORM_OS2
    29 #elif defined(__NT__)
    30    // Win32 platform
    31    #include <windows.h>
    32    #define PLATFORM_WINNT
    33 #else
    34    #error Unsupported platform
    35 #endif
    36 #include <ctype.h>
    37 #include <stdio.h>
    38 #include <conio.h>
    39 #include <string.h>
    40 
    41 
    42 #define  STATUS_NOTINSTALLED     0 // No ID found
    43 #define  STATUS_CORRUPT          1 // ID found, Checksum failure
    44 #define  STATUS_INSTALLED        2 // ID found, Checksum valid
    45 #define  STATUS_INSTALLEDMGU     3 // ID found, Checksum valid, may get updated
    46 #define  STATUS_IMPOSSIBLE       4 // Unable/Not willing to install
    47 
    48 /* Rousseau: added */
    49 #define  GPT                     0xEE                                            // GPT Disk, AiR-BOOT will abort
    50 #define  BYTES_PER_SECTOR        512                                             // This could be higher in the future
    51 #define  IMAGE_SIZE_60SECS       30720                                           // Normal image-size    (max. 30 partitions)
    52 #define  IMAGE_SIZE_62SECS       31744                                           // Extended image-size  (max. 45 partitions)
    53 //#define  IMAGE_SIZE              IMAGE_SIZE_60SECS                               // Use the normal image
    54 #define  IMAGE_SIZE              IMAGE_SIZE_62SECS                               // Use the extended image
    55 #define  SECTOR_COUNT            IMAGE_SIZE / BYTES_PER_SECTOR                   // Size of the image in sectors
    56 #define  CONFIG_OFFSET           0x6C00                                          // Byte offset of config-sector
    57 #define  SECTORS_BEFORE_CONFIG   CONFIG_OFFSET / BYTES_PER_SECTOR                // Nr of sectors before config-sector
     19
     20
     21#include    "INSTALL.H"
    5822
    5923
     
    6226//  Variables
    6327// ============================================================================
    64 CHAR   Track0[SECTOR_COUNT * BYTES_PER_SECTOR];                                  // current track 0 from harddrive
    65 CHAR   Bootcode[SECTOR_COUNT * BYTES_PER_SECTOR];                                // bootcode image from airboot.bin
    66 
    67 UCHAR  Bootcode_LanguageID    = ' ';
    68 USHORT Bootcode_Version       = 0;
    69 USHORT Bootcode_ConfigVersion = 0;
    70 
    71 UCHAR  Status_Code             = STATUS_NOTINSTALLED;
    72 UCHAR  Status_Config           = STATUS_NOTINSTALLED;
    73 USHORT Installed_CodeVersion   = 0;
    74 USHORT Installed_ConfigVersion = 0;
    75 UCHAR  Installed_LanguageID    = ' ';
    76 
    77 BOOL   Option_ForceCode        = FALSE;
    78 BOOL   Option_ForceConfig      = FALSE;
    79 BOOL   Option_Silent           = FALSE;
    80 
    81 BOOL   Option_CID              = FALSE;                                          // Rousseau: added
    82 
    83 BOOL   Install_Code            = FALSE;
    84 BOOL   Install_Config          = FALSE;
    85 BOOL   Install_IsCorrupt       = FALSE;
    86 
    87 USHORT StatusCode = 0;
    88 PSZ    ImpossibleCause = NULL;
     28
     29
     30
     31//CHAR     Track0[SECTOR_COUNT * BYTES_PER_SECTOR];                                  // current track 0 from harddrive
     32//CHAR     Bootcode[SECTOR_COUNT * BYTES_PER_SECTOR];                                // bootcode image from airboot.bin
     33
     34/*
     35// With the addition of the C DOS-version, a static buffer for both
     36// Track0 and Bootcode would overflow the DGROUP segment.
     37// Placing the buffers in another segment would increase the executable
     38// image on disk, so we would like it to be (FAR) BSS data.
     39//
     40// When experimenting with segments and #pragma data_seg(), some
     41// strange behavior was observed.
     42// WCC:
     43// Explicitly naming a segment and class for the static buffers caused
     44// wcc to generate it's default SS: based addressing.
     45// Only the -zu flag corrects this.
     46// WPP:
     47// C++ wpp used correct addressing but the segment class in the #pragma
     48// was not honored and the segment name got mangled.
     49//
     50// In both cases the volatile (transient) data would occupy space in the
     51// disk-image because.
     52// The only way seems to be putting the buffers in a separate segment using
     53// pragma's, using wcc with the -zu flag and use the wlink ORDER directive
     54// to place the FAR BSS data above the stack acompanied by a NOEMIT modifier.
     55// For this all the class names of the previous segments must be included
     56// in the wlink ORDER directive which would make the link phase dependent
     57// on segment names. This solution does not work for wpp because it mangles
     58// the segment name and overrides the custom class name to FAR_DATA.
     59//
     60// So, these buffers are now dynamically allocated.
     61// Currently they are only freed after succesful program termination,
     62// but the RTS should free them in other situations.
     63// This will be corrected later.
     64*/
     65PCHAR   Track0      = NULL;     // Buffer for Track0 from harddisk.
     66PCHAR   Bootcode    = NULL;     // Buffer for AIRBOOT.BIN image.
     67
     68UCHAR   Bootcode_LanguageID     = ' ';
     69USHORT  Bootcode_Version        = 0;
     70USHORT  Bootcode_ConfigVersion  = 0;
     71
     72UCHAR   Status_Code             = STATUS_NOTINSTALLED;
     73UCHAR   Status_Config           = STATUS_NOTINSTALLED;
     74USHORT  Installed_CodeVersion   = 0;
     75USHORT  Installed_ConfigVersion = 0;
     76UCHAR   Installed_LanguageID    = ' ';
     77
     78BOOL    Option_ForceCode        = FALSE;
     79BOOL    Option_ForceConfig      = FALSE;
     80BOOL    Option_Silent           = FALSE;
     81
     82BOOL    Option_CID              = FALSE;    // Rousseau: added
     83
     84BOOL    Install_Code            = FALSE;
     85BOOL    Install_Config          = FALSE;
     86BOOL    Install_IsCorrupt       = FALSE;
     87
     88USHORT  StatusCode              = 0;
     89PSZ     ImpossibleCause         = NULL;
     90
     91
     92
     93
     94
     95
     96// ============================================================================
     97//  Kidnapped bitfield functions needed to access the packed hideparttable
     98// ============================================================================
     99
     100/*
     101// Pragma's could be used to interface with the bitfield functions, but I was
     102// not in the mood to examine how they behave when conditions like calling
     103// convention, memory model, optimization, etc. are changed. Especially
     104// optimization generates very different code depending on the -o flags so
     105// it felt a bit 'fragile' to me to use them without further analysis.
     106// So I opted for the 'easy way' of some small prolog code to pass the
     107// parameters to the correct registers required by the core bitfield functions.
     108*/
     109
     110
     111//~ #ifdef  __386__
     112//~ #pragma aux __airboot "*___" parm caller [EBX] [EDX] [ECX] [EAX ESI EDI] value [AL];
     113//~ #else
     114//~ #pragma aux __airboot "*___" parm caller [DI BX] [DX] [CX] [AX SI] value [AL];
     115//~ #endif
     116//~ #pragma aux (__airboot) get_bitfield;
     117//~ #pragma aux (__airboot) set_bitfield;
     118
     119/* Prototypes */
     120void    bf_test();
     121char    get_bitfield(char* buffer, char index, char fieldwidth);
     122char    set_bitfield(char* buffer, char index, char fieldwidth, char value);
     123
     124//~ #ifdef  __386__
     125//~ #pragma aux get_bitfield parm [EBX] [ECX] [EDX] value [AL];
     126//~ #pragma aux set_bitfield parm [EBX] [ECX] [EDX] [EAX];
     127//~ #else
     128//~ #pragma aux get_bitfield value [DL];
     129//~ #pragma aux set_bitfield parm [BX] [CX] [DX] [AX];
     130//~ #endif
     131
     132
     133
     134// In 32-bit mode EBX is used and in 16-bit mode BX, so we abstract it's name.
     135// The rest of the bitfield code uses 16-bit registers because I kidnapped
     136// it from AiR-BOOT.
     137#define dataptr16   "BX"
     138#define dataptr32   "EBX"
     139#ifdef  __386__
     140    #define dataptr     dataptr32
     141#else
     142    #define dataptr     dataptr16
     143#endif
     144
     145
     146
     147
     148/*
     149// ----------------------------------------------------------------------------
     150// bf_test -- Test function to analyse code generation
     151// ----------------------------------------------------------------------------
     152*/
     153void    bf_test() {
     154    char*   b1 = Track0;
     155    char*   b2 = Bootcode;
     156    char    i1 = 0x11;
     157    char    i2 = 0x12;
     158    char    v1 = 0x83;
     159    char    v2 = 0x84;
     160    char    rv1 = 0xf8;
     161    char    rv2 = 0xf9;
     162
     163    rv1 = get_bitfield(b1, i1, 6);
     164    rv2 = set_bitfield(b2, i2, 6, v1+v2);
     165}
     166
     167/*
     168// ----------------------------------------------------------------------------
     169// do_bf_test -- Simple function to test the bitfield functions
     170// ----------------------------------------------------------------------------
     171*/
     172void    do_bf_test() {
     173    char    buf[512];
     174    int     i;
     175
     176    for (i=0; i<100; i++) {
     177        set_bitfield(buf, i, 6, i);
     178    }
     179
     180    set_bitfield(buf, 18, 6, 255);
     181    set_bitfield(buf, 21, 6, 255);
     182    set_bitfield(buf, 33, 6, 255);
     183    set_bitfield(buf, 37, 6, 255);
     184
     185
     186    for (i=0; i<100; i++) {
     187        printf("index: %02d, value: %02d\n", i, get_bitfield(buf, i, 6));
     188    }
     189    return;
     190}
     191
     192
     193/*
     194// ----------------------------------------------------------------------------
     195// get_bitfield -- Get a n-bit wide bitfield at index i from a buffer in memory
     196// ----------------------------------------------------------------------------
     197// This is code kidnapped from AiR-BOOT and used here to handle the packed
     198// hideparttable. A 'record' in the hideparttable is 34 bytes long and it
     199// can store 45 partition numbers using 6-bits per partition number.
     200// Bitfield widths from 1 to 8 are supported and the maxumum buffersize is
     201// 256 bytes.
     202*/
     203char    get_bitfield(char* buffer, char index, char fieldwidth) {
     204    // These are used to break-up the far pointer in large-data model 16-bit
     205    // code so the buffer can be addressed correctly.
     206    // In 32-bit flat mode they will have no effect and in 32-bit large-data
     207    // mode (imaginary) they can handle the buffer being in a seperate segment.
     208    unsigned    dseg = _FP_SEG(buffer);
     209    unsigned    dptr = _FP_OFF(buffer);
     210
     211    // Prolog code.
     212    // Handle data-segment and parameters.
     213    _asm {
     214        push    ds      ; Save DS from caller.
     215        push    dseg    ; Setup DS to
     216        pop     ds      ; address our segment. (When 16-bit large data-model)
     217
     218        mov     dl, index       ; Index to bitfield in DL.
     219        mov     dh, fieldwidth  ; Width of bitfield in DH.
     220        mov     dataptr, dptr   ; Pointer in [E]BX.
     221    }
     222
     223
     224    // This is practically a verbatim copy of the core routine from CONV.ASM.
     225    // Only a slight modification with regard to [E]BX addressing is made
     226    // so it can also function in 32-bit mode.
     227    _asm {
     228
     229        ; IN:   DL = Index to store bitfield
     230        ;       DH = Bitfield width (1-8)
     231        ;    [E]BX = Pointer to bitfield array
     232        ; OUT:  AL = Value of requested bitfield
     233        ;       AH = Mask value
     234
     235        ; Normalize bit-width in DH.
     236        dec     dh          ; Decrement bitfield width to mask invalid values.
     237        and     dh,07h      ; Only 3 bits are significant to determine width.
     238        mov     cl,dh       ; Save for later use to calculate mask.
     239        inc     dh          ; Put back to normalized value.
     240
     241        ; Calculate corresponding AND-mask in CH.
     242        mov     ch,2        ; Were going to shift 2...
     243        shl     ch,cl       ; to obtain the mask corresponding...
     244        dec     ch          ; to the bitfield width.
     245
     246        ; Calculate byte-index.
     247        mov     al,dl       ; Index in AL.
     248        inc     al          ; Increment for calculations.
     249        mul     dh          ; Multiply by bitfield width to get bits.
     250        mov     cl,8        ; Nr. of bits in a byte.
     251        div     cl          ; Divide to get byte index.
     252
     253        ; Advance pointer to byte-index.
     254        add     bl,al       ; Advance pointer...
     255        adc     bh,0        ; to byte index.
     256
     257        ; We have to 'carry on' to the high word of EBX if in 32-bit mode.
     258#ifdef  __386__
     259        pushf               ; Save the possible carry from the last addition.
     260        ror     ebx,16      ; Get high word of EBX in BX.
     261        popf                ; Restore possible carry.
     262        adc     bx,0        ; Add it and...
     263        rol     ebx,16      ; move back to have a valid 32-bit pointer again.
     264#endif
     265
     266        ; Determine if we need 1 or 2 byte access to extract the bitfield.
     267        mov     cl,ah       ; Get remainder in CL.
     268        sub     cl,dh       ; Substract bitfield width to get shift-count.
     269        mov     ah,0        ; Prepare upper=0 when field spans no byte bound.
     270                            ; Don't change to xor ah,ah or any CY will be lost.
     271
     272        ; Jump if the bitfield does not span byte boundaries.
     273        ; (Remainder - bitfield width >= 0)
     274        jae     CONV_GetBitfieldValue_nospan
     275
     276        ; Bit-field spans byte boundaries, so adjust shift-count
     277        ; and use AH to get first part of bitfield.
     278        add     cl,8        ; Adjust shift-count.
     279        mov     ah,[dataptr]     ; Get byte into AH instead.
     280        dec     dataptr          ; Adjust pointer to load rest of bitfield.
     281
     282    CONV_GetBitfieldValue_nospan:
     283        mov     al,[dataptr]     ; Load (rest of) bitfield into AL.
     284        shr     ax,cl       ; Shift bitfield to the right.
     285        mov     ah,ch       ; Get mask in AH.
     286        and     al,ah       ; Mask value.
     287        ;ret
     288    }
     289
     290
     291    // Epilog code.
     292    // Restore caller's DS.
     293    _asm {
     294        pop     ds
     295    }
     296
     297    return;
     298}
     299
     300
     301/*
     302// ----------------------------------------------------------------------------
     303// set_bitfield -- Set a n-bit wide bitfield at index i in a buffer in memory
     304// ----------------------------------------------------------------------------
     305// This is code kidnapped from AiR-BOOT and used here to handle the packed
     306// hideparttable. A 'record' in the hideparttable is 34 bytes long and it
     307// can store 45 partition numbers using 6-bits per partition number.
     308// Bitfield widths from 1 to 8 are supported and the maxumum buffersize is
     309// 256 bytes.
     310*/
     311char    set_bitfield(char* buffer, char index, char fieldwidth, char value) {
     312
     313    // These are used to break-up the far pointer in large-data model 16-bit
     314    // code so the buffer can be addressed correctly.
     315    // In 32-bit flat mode they will have no effect and in 32-bit large-data
     316    // mode (imaginary) they can handle the buffer being in a seperate segment.
     317    unsigned    dseg = _FP_SEG(buffer);
     318    unsigned    dptr = _FP_OFF(buffer);
     319
     320
     321    // Prolog code.
     322    // Handle data-segment and parameters.
     323    _asm {
     324        push    ds      ; Save DS from caller.
     325        push    dseg    ; Setup DS to
     326        pop     ds      ; address our segment. (When 16-bit large data-model)
     327
     328        mov     dl, index       ; Index to bitfield in DL.
     329        mov     dh, fieldwidth  ; Width of bitfield in DH.
     330        mov     dataptr, dptr   ; Pointer in [E]BX.
     331        mov     al, value       ; Value we want to poke in AL.
     332    }
     333
     334
     335    // This is practically a verbatim copy of the core routine from CONV.ASM.
     336    // Only a slight modification with regard to [E]BX addressing is made
     337    // so it can also function in 32-bit mode.
     338    _asm {
     339
     340        ; IN:   AL = Value to store
     341        ;       DL = Index to store bitfield
     342        ;       DH = Bitfield width (1-8)
     343        ;    [E]BX = Pointer to bitfield array
     344        ; OUT:  AL = Value of stored bitfield
     345        ;       AH = Mask value
     346
     347        ; Push value for later use.
     348        push    ax
     349
     350        ; Normalize bit-width in DH.
     351        dec     dh          ; Decrement bitfield width to mask invalid values.
     352        and     dh,07h      ; Only 3 bits are significant to determine width.
     353        mov     cl,dh       ; Save for later use to calculate mask.
     354        inc     dh          ; Put back to normalized value.
     355
     356        ; Calculate corresponding AND-mask in CH.
     357        mov     ch,2        ; Were going to shift 2...
     358        shl     ch,cl       ; to obtain the mask corresponding...
     359        dec     ch          ; to the bitfield width.
     360
     361        ; Calculate byte-index.
     362        mov     al,dl       ; Index in AL.
     363        inc     al          ; Increment for calculations.
     364        mul     dh          ; Multiply by bitfield width to get bits.
     365        mov     cl,8        ; Nr. of bits in a byte.
     366        div     cl          ; Divide to get byte index.
     367
     368        ; Advance pointer to byte-index.
     369        add     bl,al       ; Advance pointer...
     370        adc     bh,0        ; to byte index.
     371
     372        ; We have to 'carry on' to the high word of EBX if in 32-bit mode.
     373#ifdef  __386__
     374        pushf               ; Save the possible carry from the last addition.
     375        ror     ebx,16      ; Get high word of EBX in BX.
     376        popf                ; Restore possible carry.
     377        adc     bx,0        ; Add it and...
     378        rol     ebx,16      ; move back to have a valid 32-bit pointer again.
     379#endif
     380
     381        ; Determine if we need 1 or 2 byte access to extract the bitfield.
     382        mov     cl,ah       ; Get remainder in CL.
     383        sub     cl,dh       ; Substract bitfield width to get shift-count.
     384
     385        ; Restore value to poke.
     386        pop     ax
     387
     388
     389        ; Jump if the bitfield does not span byte boundaries.
     390        ; (Remainder - bitfield width >= 0)
     391        jae     CONV_SetBitfieldValue_nospan
     392
     393        ; Bit-field spans byte boundaries, so adjust shift-count
     394        ; and use 16-bit access.
     395        add     cl,8        ; Adjust shift-count.
     396
     397        ; Merge the bitfield to the array.
     398        push    cx          ; Save mask (CH) and shift-count (CL).
     399        push    ax          ; Save value to store.
     400        xor     ah,ah       ; Clear upper byte so we can shift in it.
     401        and     al,ch       ; Mask value.
     402        shl     ax,cl       ; Move the bitfield to the proper location.
     403        mov     dh,[dataptr]     ; Get 1st part of bitfield from array.
     404        dec     dataptr          ; Adjust pointer.
     405        mov     dl,[dataptr]     ; Get 2nd part of bitfield from array.
     406        push    bx          ; We need BX so save it.
     407        xor     bh,bh       ; Clear upper byte so we can shift in it.
     408        mov     bl,ch       ; Put mask in BL.
     409        shl     bx,cl       ; Shift mask to proper location.
     410        not     bx          ; Complement it to mask-out the required bitfield.
     411        and     dx,bx       ; Mask-out the required bitfield.
     412        pop     bx          ; Restore pointer.
     413        or      ax,dx       ; Merge the bitfields.
     414        mov     [dataptr],al     ; Store lower byte.
     415        inc     dataptr          ; Adjust pointer.
     416        mov     [dataptr],ah     ; Store upper byte.
     417        pop     ax          ; Restore value.
     418        pop     cx          ; Restore mask and shift-count.
     419
     420        ; Done.
     421        jmp     CONV_SetBitfieldValue_end
     422
     423    CONV_SetBitfieldValue_nospan:
     424        ; Merge the bitfield to the array.
     425        push    cx          ; Save mask (CH) and shift-count (CL).
     426        push    ax          ; Save value to store.
     427        and     al,ch       ; Mask value.
     428        shl     al,cl       ; Move the bitfield to the proper location.
     429        mov     dl,[dataptr]     ; Get byte containing bitfield.
     430        shl     ch,cl       ; Shift mask to proper location.
     431        not     ch          ; Complement it to mask-out the required bitfield.
     432        and     dl,ch       ; Mask-out the required bitfield.
     433        or      al,dl       ; Merge the bitfields.
     434        mov     [dataptr],al     ; Store byte containing bitfield.
     435        pop     ax          ; Restore value.
     436        pop     cx          ; Restore mask and shift-count.
     437
     438    CONV_SetBitfieldValue_end:
     439        mov     ah,ch       ; Get mask in AH.
     440        and     al,ah       ; Mask value.
     441        ;ret
     442    }
     443
     444    // Epilog code.
     445    // Restore caller's DS.
     446    _asm {
     447        pop     ds
     448    }
     449
     450    return value;
     451}
     452
     453
     454
     455
     456
     457
     458
    89459
    90460// ============================================================================
    91461//  Platform-specific helper functions
    92462// ============================================================================
    93 #ifdef PLATFORM_OS2
    94    USHORT CountHarddrives (void) {
    95       USHORT NumDrives = 0;
    96 
    97       if (DosPhysicalDisk(INFO_COUNT_PARTITIONABLE_DISKS, &NumDrives, sizeof(NumDrives),NULL, 0) != 0)
    98          return 0;
    99       return NumDrives;
    100     }
    101 
    102    USHORT OS2_GetIOCTLHandle () {
    103       USHORT IOCTLHandle = 0;
    104 
    105       if (DosPhysicalDisk(INFO_GETIOCTLHANDLE, &IOCTLHandle, sizeof(IOCTLHandle),"1:" , 3) != 0)
    106          return 0;
    107       return IOCTLHandle;
    108     }
    109 
    110    void OS2_FreeIOCTLHandle (USHORT IOCTLHandle) {
    111       DosPhysicalDisk(INFO_FREEIOCTLHANDLE, NULL, 0, &IOCTLHandle, sizeof(IOCTLHandle));
    112       return;
    113     }
    114 
    115    // Special feature for OS/2, finds out boot drive letter and sends this
    116    //  information to AiR-BOOT, so that it's able to set that information
    117    //  during boot phase. Otherwise the user would have to set this.
    118    UCHAR AutoDriveLetter = ' ';
    119    ULONG AutoDriveLetterSerial = 0;
    120 
    121    void OS2_GetBootAutoDriveLetter (void) {
    122       ULONG  BootDrive;
    123       struct {
    124          ULONG       ulVSN;
    125          VOLUMELABEL vol;
    126        } InfoLevel2;
    127       DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &BootDrive, sizeof(BootDrive));
    128       // BootDrive - 1-A:, 2-B:, 3-C:
    129       if ((BootDrive>2) & (!DosQueryFSInfo(BootDrive, FSIL_VOLSER, (PVOID)(&InfoLevel2), sizeof(InfoLevel2)))) {
    130          AutoDriveLetter       = BootDrive+0x7D;
    131          AutoDriveLetterSerial = InfoLevel2.ulVSN;
    132          if (!Option_CID) {
    133             printf("%X\n", InfoLevel2.ulVSN);
    134          }
    135        }
    136     }
    137 
    138    BOOL HarddriveCheckGeometry (void) {
    139       USHORT               IOCTLHandle;
    140       USHORT               SectorsPerTrack = 0;
    141       DEVICEPARAMETERBLOCK DeviceParmBlock;
    142       ULONG                ulDataLength;
    143 
    144       IOCTLHandle = OS2_GetIOCTLHandle();
    145 
    146       if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_GETPHYSDEVICEPARAMS, NULL, 0, NULL, &DeviceParmBlock, sizeof(DeviceParmBlock), &ulDataLength))
    147          SectorsPerTrack = DeviceParmBlock.cSectorsPerTrack;
    148       OS2_FreeIOCTLHandle (IOCTLHandle);
    149       //if (SectorsPerTrack > 61) return TRUE;              // >60 should also be ok for normal image (60 for image 1 for lvm)
    150       if (SectorsPerTrack > SECTOR_COUNT) return TRUE;      // Note: This is 1 sector smaller than above !!
    151       // OS/2 is only able to support 512-byte/sector media, so we dont need to check this
    152       return FALSE;
    153     }
    154 
    155    BOOL Track0Load (void) {
    156       USHORT      IOCTLHandle;
    157       ULONG       TrackLayoutLen  = sizeof(TRACKLAYOUT)+sizeof(ULONG)*(SECTOR_COUNT-1);
    158       TRACKLAYOUT *TrackLayoutPtr = malloc(TrackLayoutLen);
    159       ULONG       cbParms = sizeof(TrackLayoutPtr);
    160       ULONG       cbData  = BYTES_PER_SECTOR;
    161       int         i;
    162       BOOL        Success = FALSE;
    163 
    164       IOCTLHandle = OS2_GetIOCTLHandle();
    165 
    166       TrackLayoutPtr->bCommand      = 0x01;
    167       TrackLayoutPtr->usHead        = 0;
    168       TrackLayoutPtr->usCylinder    = 0;
    169       TrackLayoutPtr->usFirstSector = 0;
    170       TrackLayoutPtr->cSectors      = SECTOR_COUNT;
    171 
    172       for (i=0; i<SECTOR_COUNT; i++) {
    173          TrackLayoutPtr->TrackTable[i].usSectorNumber = i+1;
    174          TrackLayoutPtr->TrackTable[i].usSectorSize   = BYTES_PER_SECTOR;
    175        }
    176 
    177       if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_READPHYSTRACK,
    178            TrackLayoutPtr, cbParms, &cbParms, &Track0, cbData, &cbData))
    179          Success = TRUE;
    180       OS2_FreeIOCTLHandle (IOCTLHandle);
    181       free (TrackLayoutPtr);
    182       return Success;
    183     }
    184 
    185    BOOL Track0Write (void) {
    186       USHORT      IOCTLHandle;
    187       ULONG       TrackLayoutLen  = sizeof(TRACKLAYOUT)+sizeof(ULONG)*(SECTOR_COUNT-1);
    188       TRACKLAYOUT *TrackLayoutPtr = malloc(TrackLayoutLen);
    189       ULONG       cbParms = sizeof(TrackLayoutPtr);
    190       ULONG       cbData  = BYTES_PER_SECTOR;
    191       INT         i;
    192       BOOL        Success = FALSE;
    193 
    194       IOCTLHandle = OS2_GetIOCTLHandle();
    195 
    196 
    197       TrackLayoutPtr->bCommand      = 0x01;
    198       TrackLayoutPtr->usHead        = 0;
    199       TrackLayoutPtr->usCylinder    = 0;
    200       TrackLayoutPtr->usFirstSector = 0;
    201       TrackLayoutPtr->cSectors      = SECTOR_COUNT;
    202 
    203       for (i=0; i<SECTOR_COUNT; i++) {
    204          TrackLayoutPtr->TrackTable[i].usSectorNumber = i+1;
    205          TrackLayoutPtr->TrackTable[i].usSectorSize   = BYTES_PER_SECTOR;
    206        }
    207 
    208       if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_WRITEPHYSTRACK,
    209           TrackLayoutPtr, cbParms, &cbParms, &Track0, cbData, &cbData))
    210          Success = TRUE;
    211       OS2_FreeIOCTLHandle (IOCTLHandle);
    212       free (TrackLayoutPtr);
    213       return Success;
    214     }
    215 
    216    #define CATEGORY_DOSSYS 0xD5
    217    #define FUNCTION_REBOOT 0xAB
    218 
    219    void RebootSystem (void) {
    220       HFILE  DosHandle;
    221       ULONG  DosOpenAction;
    222 
    223       DosSleep (2000);
    224       if (!DosOpen("DOS$", &DosHandle, &DosOpenAction, 0, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE, NULL)) {
    225          DosDevIOCtl(DosHandle, CATEGORY_DOSSYS, FUNCTION_REBOOT, NULL, 0, NULL, NULL, 0, NULL);
    226          DosSleep (60000);
    227        }
    228       DosClose(DosHandle);
    229     }
     463
     464
     465/*
     466// Helper functions -- DOS implementation.
     467*/
     468#ifdef  PLATFORM_DOS
     469    USHORT CountHarddrives (void) {
     470        USHORT NumDrives = 0;
     471        // Implement !
     472        return NumDrives;
     473    }
     474
     475    USHORT OS2_GetIOCTLHandle () {
     476        USHORT IOCTLHandle = 0;
     477        // Implement !
     478        return IOCTLHandle;
     479    }
     480
     481    void OS2_FreeIOCTLHandle (USHORT IOCTLHandle) {
     482        // Implement !
     483        return;
     484    }
     485
     486
     487    BOOL HarddriveCheckGeometry (void) {
     488        USHORT               IOCTLHandle;
     489
     490        IOCTLHandle = OS2_GetIOCTLHandle();
     491        // Implement !
     492        return FALSE;
     493    }
     494
     495    BOOL Track0Load (void) {
     496        USHORT      IOCTLHandle;
     497        BOOL        Success = FALSE;
     498
     499        IOCTLHandle = OS2_GetIOCTLHandle();
     500        // Implement !
     501        return Success;
     502    }
     503
     504    BOOL Track0Write (void) {
     505        USHORT      IOCTLHandle;
     506        BOOL        Success = FALSE;
     507
     508        IOCTLHandle = OS2_GetIOCTLHandle();
     509        // Implement !
     510        return Success;
     511    }
     512
     513    void RebootSystem (void) {
     514
     515        // Implement !
     516    }
     517
    230518#endif
    231519
    232 #ifdef PLATFORM_WINNT
    233    // Checks, if we are under NT
    234    BOOL CheckWindowsVersion (void) {
    235       OSVERSIONINFO Version;
    236       Version.dwOSVersionInfoSize = sizeof(Version);
    237       GetVersionEx(&Version);
    238       if (Version.dwPlatformId == VER_PLATFORM_WIN32_NT) return TRUE;
    239       if (!Option_CID) {
    240          printf(" - This installer is for WindowsNT family only.\n");
    241          printf("    Please use DOS installer for Windows9x.\n");
    242       }
    243       return FALSE;
    244     }
    245 
    246 
    247    HANDLE WINNT_GetIOCTLHandle (void) {
    248       return CreateFile("\\\\.\\physicaldrive0", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
    249     }
    250 
    251    void WINNT_FreeIOCTLHandle (HANDLE IOCTLHandle) {
    252       CloseHandle(IOCTLHandle);
    253     }
    254 
    255    USHORT CountHarddrives (void) {
    256       return 1;
    257     }
    258 
    259    BOOL HarddriveCheckGeometry (void) {
    260       HANDLE        IOCTLHandle;
    261       DISK_GEOMETRY Geometry;
    262       USHORT        SectorsPerTrack = 0;
    263       DWORD         Dummy;
    264 
    265       IOCTLHandle = WINNT_GetIOCTLHandle();
    266       if (DeviceIoControl(IOCTLHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &Geometry, sizeof(Geometry), &Dummy, NULL))
    267          SectorsPerTrack = Geometry.SectorsPerTrack;
    268       WINNT_FreeIOCTLHandle(IOCTLHandle);
    269       //if (SectorsPerTrack > 61) return TRUE;              // >60 should also be ok for normal image (60 for image 1 for lvm)
    270       if (SectorsPerTrack > SECTOR_COUNT) return TRUE;      // Note: This is 1 sector smaller than above !!
    271       return FALSE;
    272     }
    273 
    274    BOOL Track0Load (void) {
    275       HANDLE      IOCTLHandle;
    276       DWORD       BytesRead = 0;
    277       BOOL        Success = FALSE;
    278 
    279       IOCTLHandle = WINNT_GetIOCTLHandle();
    280       SetFilePointer(IOCTLHandle, 0, 0, FILE_BEGIN);
    281       if (ReadFile(IOCTLHandle, &Track0, SECTOR_COUNT * BYTES_PER_SECTOR, &BytesRead, NULL))
    282          Success = TRUE;
    283       WINNT_FreeIOCTLHandle(IOCTLHandle);
    284       return Success;
    285     }
    286 
    287    BOOL Track0Write (void) {
    288       HANDLE      IOCTLHandle;
    289       DWORD       BytesWritten = 0;
    290       BOOL        Success = FALSE;
    291 
    292       IOCTLHandle = WINNT_GetIOCTLHandle();
    293       SetFilePointer(IOCTLHandle, 0, 0, FILE_BEGIN);
    294       if (WriteFile(IOCTLHandle, &Track0, SECTOR_COUNT * BYTES_PER_SECTOR, &BytesWritten, NULL))
    295          Success = TRUE;
    296       WINNT_FreeIOCTLHandle(IOCTLHandle);
    297       return Success;
    298     }
    299 
    300    void RebootSystem (void) {
    301       HANDLE           token;
    302       TOKEN_PRIVILEGES tokenpriv;
    303       OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token);
    304       LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tokenpriv.Privileges[0].Luid);
    305       tokenpriv.PrivilegeCount = 1;
    306       tokenpriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    307       AdjustTokenPrivileges(token, FALSE, &tokenpriv, 0, NULL, 0);
    308       ExitWindowsEx(EWX_REBOOT, 0);
     520
     521
     522/*
     523// Helper functions -- OS/2 implementation.
     524*/
     525#ifdef  PLATFORM_OS2
     526    USHORT CountHarddrives (void) {
     527        USHORT NumDrives = 0;
     528        if (DosPhysicalDisk(INFO_COUNT_PARTITIONABLE_DISKS, &NumDrives, sizeof(NumDrives),NULL, 0) != 0)
     529            return 0;
     530        return NumDrives;
     531    }
     532
     533    USHORT OS2_GetIOCTLHandle () {
     534        USHORT IOCTLHandle = 0;
     535        if (DosPhysicalDisk(INFO_GETIOCTLHANDLE, &IOCTLHandle, sizeof(IOCTLHandle),"1:" , 3) != 0)
     536            return 0;
     537        return IOCTLHandle;
     538    }
     539
     540    void OS2_FreeIOCTLHandle (USHORT IOCTLHandle) {
     541        DosPhysicalDisk(INFO_FREEIOCTLHANDLE, NULL, 0, &IOCTLHandle, sizeof(IOCTLHandle));
     542        return;
     543    }
     544
     545    // Special feature for OS/2, finds out boot drive letter and sends this
     546    //  information to AiR-BOOT, so that it's able to set that information
     547    //  during boot phase. Otherwise the user would have to set this.
     548    UCHAR AutoDriveLetter = ' ';
     549    ULONG AutoDriveLetterSerial = 0;
     550
     551    void OS2_GetBootAutoDriveLetter (void) {
     552        ULONG  BootDrive;
     553        struct {
     554            ULONG       ulVSN;
     555            VOLUMELABEL vol;
     556        } InfoLevel2;
     557        DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &BootDrive, sizeof(BootDrive));
     558        // BootDrive - 1-A:, 2-B:, 3-C:
     559        if ((BootDrive>2) & (!DosQueryFSInfo(BootDrive, FSIL_VOLSER, (PVOID)(&InfoLevel2), sizeof(InfoLevel2)))) {
     560            AutoDriveLetter       = (UCHAR) BootDrive+0x7D;
     561            AutoDriveLetterSerial = InfoLevel2.ulVSN;
     562            if (!Option_CID) {
     563                printf("%X\n", InfoLevel2.ulVSN);
     564            }
     565        }
     566    }
     567
     568    BOOL HarddriveCheckGeometry (void) {
     569        USHORT               IOCTLHandle;
     570        USHORT               SectorsPerTrack = 0;
     571        DEVICEPARAMETERBLOCK DeviceParmBlock;
     572        ULONG                ulDataLength;
     573
     574        IOCTLHandle = OS2_GetIOCTLHandle();
     575
     576        if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_GETPHYSDEVICEPARAMS, NULL, 0, NULL, &DeviceParmBlock, sizeof(DeviceParmBlock), &ulDataLength))
     577            SectorsPerTrack = DeviceParmBlock.cSectorsPerTrack;
     578        OS2_FreeIOCTLHandle (IOCTLHandle);
     579        //if (SectorsPerTrack > 61) return TRUE;              // >60 should also be ok for normal image (60 for image 1 for lvm)
     580        if (SectorsPerTrack > SECTOR_COUNT) return TRUE;      // Note: This is 1 sector smaller than above !!
     581        // OS/2 is only able to support 512-byte/sector media, so we dont need to check this
     582        return FALSE;
     583    }
     584
     585    BOOL Track0Load (void) {
     586        USHORT      IOCTLHandle;
     587        ULONG       TrackLayoutLen  = sizeof(TRACKLAYOUT)+sizeof(ULONG)*(SECTOR_COUNT-1);
     588        TRACKLAYOUT *TrackLayoutPtr = (TRACKLAYOUT*) malloc(TrackLayoutLen);
     589        ULONG       cbParms = sizeof(TrackLayoutPtr);
     590        ULONG       cbData  = BYTES_PER_SECTOR;
     591        int         i;
     592        BOOL        Success = FALSE;
     593
     594        IOCTLHandle = OS2_GetIOCTLHandle();
     595
     596        TrackLayoutPtr->bCommand      = 0x01;
     597        TrackLayoutPtr->usHead        = 0;
     598        TrackLayoutPtr->usCylinder    = 0;
     599        TrackLayoutPtr->usFirstSector = 0;
     600        TrackLayoutPtr->cSectors      = SECTOR_COUNT;
     601
     602        for (i=0; i<SECTOR_COUNT; i++) {
     603            TrackLayoutPtr->TrackTable[i].usSectorNumber = i+1;
     604            TrackLayoutPtr->TrackTable[i].usSectorSize   = BYTES_PER_SECTOR;
     605        }
     606
     607        if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_READPHYSTRACK,
     608            TrackLayoutPtr, cbParms, &cbParms, Track0, cbData, &cbData))
     609            Success = TRUE;
     610
     611        OS2_FreeIOCTLHandle (IOCTLHandle);
     612        free (TrackLayoutPtr);
     613        return Success;
     614    }
     615
     616    BOOL Track0Write (void) {
     617        USHORT      IOCTLHandle;
     618        ULONG       TrackLayoutLen  = sizeof(TRACKLAYOUT)+sizeof(ULONG)*(SECTOR_COUNT-1);
     619        TRACKLAYOUT *TrackLayoutPtr = (TRACKLAYOUT*) malloc(TrackLayoutLen);
     620        ULONG       cbParms = sizeof(TrackLayoutPtr);
     621        ULONG       cbData  = BYTES_PER_SECTOR;
     622        INT         i;
     623        BOOL        Success = FALSE;
     624
     625        IOCTLHandle = OS2_GetIOCTLHandle();
     626
     627
     628        TrackLayoutPtr->bCommand      = 0x01;
     629        TrackLayoutPtr->usHead        = 0;
     630        TrackLayoutPtr->usCylinder    = 0;
     631        TrackLayoutPtr->usFirstSector = 0;
     632        TrackLayoutPtr->cSectors      = SECTOR_COUNT;
     633
     634        for (i=0; i<SECTOR_COUNT; i++) {
     635            TrackLayoutPtr->TrackTable[i].usSectorNumber = i+1;
     636            TrackLayoutPtr->TrackTable[i].usSectorSize   = BYTES_PER_SECTOR;
     637        }
     638
     639        if (!DosDevIOCtl(IOCTLHandle, IOCTL_PHYSICALDISK, PDSK_WRITEPHYSTRACK,
     640            TrackLayoutPtr, cbParms, &cbParms, Track0, cbData, &cbData))
     641            Success = TRUE;
     642
     643        OS2_FreeIOCTLHandle (IOCTLHandle);
     644        free (TrackLayoutPtr);
     645        return Success;
     646    }
     647
     648    #define CATEGORY_DOSSYS 0xD5
     649    #define FUNCTION_REBOOT 0xAB
     650
     651    void RebootSystem (void) {
     652        HFILE  DosHandle;
     653        ULONG  DosOpenAction;
     654
     655        DosSleep (2000);
     656        if (!DosOpen("DOS$", &DosHandle, &DosOpenAction, 0, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE, NULL)) {
     657            DosDevIOCtl(DosHandle, CATEGORY_DOSSYS, FUNCTION_REBOOT, NULL, 0, NULL, NULL, 0, NULL);
     658            DosSleep (60000);
     659        }
     660        DosClose(DosHandle);
    309661    }
    310662#endif
    311663
     664
     665
     666
     667/*
     668// Helper functions -- Win32 implementation.
     669*/
     670#ifdef  PLATFORM_WINNT
     671    // Checks, if we are under NT
     672    BOOL CheckWindowsVersion (void) {
     673        OSVERSIONINFO Version;
     674        Version.dwOSVersionInfoSize = sizeof(Version);
     675        GetVersionEx(&Version);
     676        if (Version.dwPlatformId == VER_PLATFORM_WIN32_NT)
     677            return TRUE;
     678        if (!Option_CID) {
     679            printf(" - This installer is for WindowsNT family only.\n");
     680            printf("    Please use DOS installer for Windows9x.\n");
     681        }
     682        return FALSE;
     683    }
     684
     685
     686    HANDLE WINNT_GetIOCTLHandle (void) {
     687        return CreateFile("\\\\.\\physicaldrive0", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
     688    }
     689
     690    void WINNT_FreeIOCTLHandle (HANDLE IOCTLHandle) {
     691        CloseHandle(IOCTLHandle);
     692    }
     693
     694    USHORT CountHarddrives (void) {
     695        return 1;
     696    }
     697
     698    BOOL HarddriveCheckGeometry (void) {
     699        HANDLE        IOCTLHandle;
     700        DISK_GEOMETRY Geometry;
     701        USHORT        SectorsPerTrack = 0;
     702        DWORD         Dummy;
     703
     704        IOCTLHandle = WINNT_GetIOCTLHandle();
     705        if (DeviceIoControl(IOCTLHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &Geometry, sizeof(Geometry), &Dummy, NULL))
     706            SectorsPerTrack = (USHORT) Geometry.SectorsPerTrack;
     707        WINNT_FreeIOCTLHandle(IOCTLHandle);
     708        //if (SectorsPerTrack > 61) return TRUE;              // >60 should also be ok for normal image (60 for image 1 for lvm)
     709        if (SectorsPerTrack > SECTOR_COUNT)
     710            return TRUE;      // Note: This is 1 sector smaller than above !!
     711
     712        return FALSE;
     713    }
     714
     715    BOOL Track0Load (void) {
     716        HANDLE      IOCTLHandle;
     717        DWORD       BytesRead = 0;
     718        BOOL        Success = FALSE;
     719
     720        IOCTLHandle = WINNT_GetIOCTLHandle();
     721        SetFilePointer(IOCTLHandle, 0, 0, FILE_BEGIN);
     722        if (ReadFile(IOCTLHandle, Track0, SECTOR_COUNT * BYTES_PER_SECTOR, &BytesRead, NULL))
     723            Success = TRUE;
     724        WINNT_FreeIOCTLHandle(IOCTLHandle);
     725        return Success;
     726    }
     727
     728    BOOL Track0Write (void) {
     729        HANDLE      IOCTLHandle;
     730        DWORD       BytesWritten = 0;
     731        BOOL        Success = FALSE;
     732
     733        IOCTLHandle = WINNT_GetIOCTLHandle();
     734        SetFilePointer(IOCTLHandle, 0, 0, FILE_BEGIN);
     735        if (WriteFile(IOCTLHandle, Track0, SECTOR_COUNT * BYTES_PER_SECTOR, &BytesWritten, NULL))
     736            Success = TRUE;
     737        WINNT_FreeIOCTLHandle(IOCTLHandle);
     738        return Success;
     739    }
     740
     741    void RebootSystem (void) {
     742        HANDLE           token;
     743        TOKEN_PRIVILEGES tokenpriv;
     744        OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &token);
     745        LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tokenpriv.Privileges[0].Luid);
     746        tokenpriv.PrivilegeCount = 1;
     747        tokenpriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
     748        AdjustTokenPrivileges(token, FALSE, &tokenpriv, 0, NULL, 0);
     749        ExitWindowsEx(EWX_REBOOT, 0);
     750    }
     751#endif
     752
     753
     754/*
     755// Helper functions -- Linux implementation.
     756*/
     757#ifdef  PLATFORM_LINUX
     758    USHORT CountHarddrives (void) {
     759        USHORT NumDrives = 0;
     760        // Implement !
     761        return NumDrives;
     762    }
     763
     764    USHORT OS2_GetIOCTLHandle () {
     765        USHORT IOCTLHandle = 0;
     766        // Implement !
     767        return IOCTLHandle;
     768    }
     769
     770    void OS2_FreeIOCTLHandle (USHORT IOCTLHandle) {
     771        // Implement !
     772        return;
     773    }
     774
     775
     776    BOOL HarddriveCheckGeometry (void) {
     777        USHORT               IOCTLHandle;
     778
     779        IOCTLHandle = OS2_GetIOCTLHandle();
     780        // Implement !
     781        return FALSE;
     782    }
     783
     784    BOOL Track0Load (void) {
     785        USHORT      IOCTLHandle;
     786        BOOL        Success = FALSE;
     787
     788        IOCTLHandle = OS2_GetIOCTLHandle();
     789        // Implement !
     790        return Success;
     791    }
     792
     793    BOOL Track0Write (void) {
     794        USHORT      IOCTLHandle;
     795        BOOL        Success = FALSE;
     796
     797        IOCTLHandle = OS2_GetIOCTLHandle();
     798        // Implement !
     799        return Success;
     800    }
     801
     802    void RebootSystem (void) {
     803
     804        // Implement !
     805    }
     806
     807#endif
     808
     809
     810
     811
     812
     813// ============================================================================
     814//  Common Code
     815// ============================================================================
     816
     817
    312818USHORT GetChecksumOfSector (USHORT Checksum, PCHAR SectorPtr) {
    313    PUSHORT TempPtr = (PUSHORT)SectorPtr;
    314    USHORT  i;
    315    for (i=0; i<256; i++) {
    316       Checksum = *TempPtr ^ 0xBABE ^ Checksum;
    317       TempPtr++;
    318     }
    319    if (Checksum==0) Checksum = 1;
    320    return Checksum;
    321  }
     819    PUSHORT TempPtr = (PUSHORT)SectorPtr;
     820    USHORT  i;
     821    for (i=0; i<256; i++) {
     822        Checksum = *TempPtr ^ 0xBABE ^ Checksum;
     823        TempPtr++;
     824    }
     825    if (Checksum==0)
     826        Checksum = 1;
     827    return Checksum;
     828}
    322829
    323830// Loads airboot.bin into memory (if possible) and sets some variables
    324831//  also makes sure that airboot.bin has correct length
    325832BOOL LoadBootcodeFromFile (void) {
    326    FILE  *FileHandle = NULL;
    327    ULONG BootcodeSize = 0;
    328 
    329    FileHandle = fopen("airboot.bin", "rb");
    330    if (!FileHandle) {
    331       if (!Option_CID) {
    332          printf("airboot.bin not found\n");
    333       }
    334       return FALSE;
    335     }
    336    // Read whole file into memory...
    337    fseek (FileHandle, 0, SEEK_END);
    338    BootcodeSize = ftell(FileHandle);
    339    if (BootcodeSize!=IMAGE_SIZE) {
    340       fclose (FileHandle);
    341       if (!Option_CID) {
    342          printf("Invalid airboot.bin\n");
    343       }
    344       return FALSE;
    345     }
    346    fseek (FileHandle, 0, SEEK_SET);
    347    fread (&Bootcode, 1, IMAGE_SIZE, FileHandle);
    348    fclose (FileHandle);
    349 
    350 //   Read airboot.bin failed
    351 
    352    Bootcode_Version = (Bootcode[13] << 8) | Bootcode[14];
    353    Bootcode_LanguageID = Bootcode[15];
    354    Bootcode_ConfigVersion = (Bootcode[0x6C0D] << 8) | Bootcode[0x6C0E];
    355    return TRUE;
    356  }
     833    FILE  *FileHandle = NULL;
     834    ULONG BootcodeSize = 0;
     835
     836    // Try to open file...
     837    FileHandle = fopen(IMAGE_NAME, "rb");
     838    if (!FileHandle) {
     839        if (!Option_CID) {
     840            printf("%s not found\n", IMAGE_NAME);
     841        }
     842        return FALSE;
     843    }
     844
     845    // Seek to end of file to determine image size...
     846    fseek (FileHandle, 0, SEEK_END);
     847    BootcodeSize = ftell(FileHandle);
     848    if (BootcodeSize!=IMAGE_SIZE) {
     849        fclose (FileHandle);
     850        if (!Option_CID) {
     851            printf("Invalid %sn\n", IMAGE_NAME);
     852        }
     853        return FALSE;
     854    }
     855
     856    // Read whole file into memory...
     857    fseek (FileHandle, 0, SEEK_SET);
     858    fread (Bootcode, 1, IMAGE_SIZE, FileHandle);
     859    fclose (FileHandle);
     860
     861    // Extract language and version info...
     862    Bootcode_Version = (Bootcode[13] << 8) | Bootcode[14];
     863    Bootcode_LanguageID = Bootcode[15];
     864    Bootcode_ConfigVersion = (Bootcode[0x6C0D] << 8) | Bootcode[0x6C0E];
     865    return TRUE;
     866}
    357867
    358868/**
     
    362872 */
    363873void Status_CheckCode (void) {
    364    USHORT TotalCodeSectorsUsed = 0;
    365    USHORT Checksum = 0;
    366    PCHAR  SectorPtr = NULL;
    367 
    368    if (Status_Code==STATUS_IMPOSSIBLE) return;
    369    // EZ-Setup check!
    370    Status_Code = STATUS_NOTINSTALLED;
    371    if ((Track0[0x1FE]!=0x55) || (Track0[0x1FF]!=0xAA)) return;                   // No MBR signature found, so not installed
    372    if (strncmp(&Track0[2], "AiRBOOT", 7)!=0) return;                             // No AiR-BOOT signature found, so not installed
    373    // MBR and AiR-BOOT signature found...
    374    TotalCodeSectorsUsed = Track0[0x10];                                          // 34h/52 in v1.06
    375    SectorPtr = &Track0[1 * BYTES_PER_SECTOR]; // Start at sector 2
    376    // Calculate checksum of code-sectors
    377    while (TotalCodeSectorsUsed>0) {
    378       Checksum = GetChecksumOfSector(Checksum, SectorPtr);
    379       SectorPtr += BYTES_PER_SECTOR;
    380       TotalCodeSectorsUsed--;
    381     }
    382    if (Checksum!=*(PUSHORT)&Track0[0x11]) {
    383       Status_Code = STATUS_CORRUPT; return;                                      // Bad checksum for code
    384     }
    385    // Checksum fine...
    386    Installed_LanguageID  = Track0[0x0F];
    387    Installed_CodeVersion = (Track0[0x0D] << 8) | Track0[0x0E];
    388    if (Installed_CodeVersion<Bootcode_Version)
    389       Status_Code = STATUS_INSTALLEDMGU;                                         // Do upgrade
    390      else
    391       Status_Code = STATUS_INSTALLED;                                            // Same version installed
    392  }
     874    USHORT TotalCodeSectorsUsed = 0;
     875    USHORT Checksum = 0;
     876    PCHAR  SectorPtr = NULL;
     877
     878    if (Status_Code==STATUS_IMPOSSIBLE)
     879        return;
     880    // EZ-Setup check!
     881    Status_Code = STATUS_NOTINSTALLED;
     882    if ((Track0[0x1FE]!=0x55) || (Track0[0x1FF]!=0xAA))
     883        return;                   // No MBR signature found, so not installed
     884    if (strncmp(&Track0[2], "AiRBOOT", 7)!=0)
     885        return;                             // No AiR-BOOT signature found, so not installed
     886    // MBR and AiR-BOOT signature found...
     887    TotalCodeSectorsUsed = Track0[0x10];                                          // 34h/52 in v1.06
     888    SectorPtr = &Track0[1 * BYTES_PER_SECTOR]; // Start at sector 2
     889    // Calculate checksum of code-sectors
     890    while (TotalCodeSectorsUsed>0) {
     891        Checksum = GetChecksumOfSector(Checksum, SectorPtr);
     892        SectorPtr += BYTES_PER_SECTOR;
     893        TotalCodeSectorsUsed--;
     894    }
     895    if (Checksum!=*(PUSHORT)&Track0[0x11]) {
     896        Status_Code = STATUS_CORRUPT;
     897        return;                                      // Bad checksum for code
     898    }
     899    // Checksum fine...
     900    Installed_LanguageID  = Track0[0x0F];
     901    Installed_CodeVersion = (Track0[0x0D] << 8) | Track0[0x0E];
     902    if (Installed_CodeVersion<Bootcode_Version)
     903        Status_Code = STATUS_INSTALLEDMGU;                                         // Do upgrade
     904    else
     905        Status_Code = STATUS_INSTALLED;                                            // Same version installed
     906
     907    return;
     908}
    393909
    394910
    395911void Status_CheckConfig (void) {
    396    PCHAR  ConfigSectorPtr = &Track0[CONFIG_OFFSET];                              // Config sector offset hard-coded !
    397    PCHAR  SectorPtr = NULL;
    398    USHORT Checksum = 0;
    399    USHORT ConfigChecksum = 0;
    400    USHORT SectorCount = 0;
    401 
    402    /*
    403    // Note that the 'AiRCFG-TABLE' string includes the invisible 0xAD char.
    404    */
    405    if (strncmp(ConfigSectorPtr, "AiRCFG-TABLE­", 13)==0) {
    406       // AiR-BOOT signature found...
    407       SectorPtr = &Track0[54 * BYTES_PER_SECTOR];                                // Start at sector 55
    408       ConfigChecksum = *(PUSHORT)&Track0[54 * BYTES_PER_SECTOR + 20];
    409       // Remove checksum
    410       *(PUSHORT)&Track0[54 * BYTES_PER_SECTOR + 20] = 0;                         // Config sector secnum hard-coded !
    411 
    412       /*
    413       // Rousseau: # Keep compatible with v1.07 CRC #
    414       // AB v1.07 had bugs in writing the wrong number of AB config sectors.
    415       // This is fixed in v1.0.8 but the CRC has to be calculated the "v1.07 way"
    416       // otherwise v1.07 SET(A)BOOT and INSTALL2.EXE will think the AB config
    417       // is corrupted.
    418       // So the CRC is calculated over 5 sectors instead of 7.
    419       */
    420       SectorCount = 5;
    421 
    422       while (SectorCount>0) {
    423          Checksum = GetChecksumOfSector(Checksum, SectorPtr);
    424          SectorPtr += BYTES_PER_SECTOR;
    425          SectorCount--;
    426        }
    427       // Restore checksum
    428       *(PUSHORT)&Track0[54 * BYTES_PER_SECTOR + 20] = ConfigChecksum;            // Config sector secnum hard-coded !
    429       if (Checksum!=ConfigChecksum) {
    430         Status_Config = STATUS_CORRUPT; return;
     912    PCHAR  ConfigSectorPtr = &Track0[CONFIG_OFFSET];                              // Config sector offset hard-coded !
     913    PCHAR  SectorPtr = NULL;
     914    USHORT Checksum = 0;
     915    USHORT ConfigChecksum = 0;
     916    USHORT SectorCount = 0;
     917
     918    /*
     919    // Note that the 'AiRCFG-TABLE' string includes the invisible 0xAD char.
     920    */
     921    if (strncmp(ConfigSectorPtr, "AiRCFG-TABLE­", 13)==0) {
     922        // AiR-BOOT signature found...
     923        SectorPtr = &Track0[54 * BYTES_PER_SECTOR];                                // Start at sector 55
     924        ConfigChecksum = *(PUSHORT)&Track0[54 * BYTES_PER_SECTOR + 20];
     925        // Remove checksum
     926        *(PUSHORT)&Track0[54 * BYTES_PER_SECTOR + 20] = 0;                         // Config sector secnum hard-coded !
     927
     928        /*
     929        // Rousseau: # Keep compatible with v1.07 CRC #
     930        // AB v1.07 had bugs in writing the wrong number of AB config sectors.
     931        // This is fixed in v1.0.8 but the CRC has to be calculated the "v1.07 way"
     932        // otherwise v1.07 SET(A)BOOT and INSTALL2.EXE will think the AB config
     933        // is corrupted.
     934        // So the CRC is calculated over 5 sectors instead of 7.
     935        */
     936        SectorCount = 5;
     937
     938        while (SectorCount>0) {
     939            Checksum = GetChecksumOfSector(Checksum, SectorPtr);
     940            SectorPtr += BYTES_PER_SECTOR;
     941            SectorCount--;
     942        }
     943        // Restore checksum
     944        *(PUSHORT)&Track0[54 * BYTES_PER_SECTOR + 20] = ConfigChecksum;            // Config sector secnum hard-coded !
     945        if (Checksum!=ConfigChecksum) {
     946            Status_Config = STATUS_CORRUPT;
     947            return;
     948        }
     949        // Checksum fine
     950        Installed_ConfigVersion = (Track0[54 * BYTES_PER_SECTOR + 0x0D] << 8) | Track0[54 * BYTES_PER_SECTOR + 0x0E];
     951        if (Installed_ConfigVersion>=Bootcode_ConfigVersion) {
     952            Status_Config = STATUS_INSTALLED;
     953            return;
     954        }
     955        Status_Config = STATUS_INSTALLEDMGU;
     956        // Those upgrades will copy useful configuration data to the image config
     957        //  If new configuration data was added, those spaces are not overwritten
     958        // Sector 60 (MBR-BackUp) *MUST BE* copied, otherwise it would be lost.
     959        // Rousseau: Upgrade from v0.27
     960        if (Installed_ConfigVersion<=0x27) {
     961            // UPGRADE v0.27 and prior versions
     962
     963            // Sector 55
     964            // Changes: Offset  69 length 75 - Linux command line
     965            //          Offset 144 length  1 - Linux kernel partition
     966            //          Offset 145 Length 11 - Default kernel name
     967            //          Offset 156 Length  1 - Kernel name terminator 1
     968            //          Offset 157 Length 11 - Last kernel name
     969            //          Offset 168 Length  1 - Kernel name terminator 2
     970            //          Offset 169 Length  1 - Ext. partition M$-hack enable
     971            //           -> Total-length 101
     972            //          Offset 432 Length 34 - New IPT entry (BIOS continued)
     973            memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], 69 - 16);    // CHECKEN !!
     974            memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 466], &Track0[54 * BYTES_PER_SECTOR + 466], 46);       // CHECKEN !!
     975            // Sector 56-57 no changes
     976            memcpy(&Bootcode[55*512], &Track0[55 * BYTES_PER_SECTOR], 1024);
     977            // Sector 58-59
     978            // Changes: Offset 900 Length 30 - Logical driveletter table
     979            memcpy(&Bootcode[57 * BYTES_PER_SECTOR], &Track0[57 * BYTES_PER_SECTOR], 900);               // AANPASSEN 900 !!
     980            // Sector 60 copy unmodified
     981            memcpy(&Bootcode[59 * BYTES_PER_SECTOR], &Track0[59 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);  // CHECKEN !!
     982            return;
     983        }
     984        // Rousseau: Upgrade from v0.91
     985        if (Installed_ConfigVersion<=0x91) {
     986            // UPGRADE v0.91 and prior versions
     987            // Sector 55-57 no changes
     988            memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], BYTES_PER_SECTOR + 1024 - 16);   // CHACKEN !!
     989            // Sector 58-59
     990            // Changes: Offset 900 Length 30 - Logical driveletter table
     991            memcpy(&Bootcode[57 * BYTES_PER_SECTOR], &Track0[57 * BYTES_PER_SECTOR], 900);               // AANPASSEN 900 !!
     992            // Sector 60/62 copy unmodified
     993            memcpy(&Bootcode[59 * BYTES_PER_SECTOR], &Track0[59 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);
     994            return;
     995        }
     996
     997
     998        /*
     999        // HIER AANPASSEN VOOR 1.06 -> 1.07, 1.07/1.0.8-rc1 -> 1.0.8-rc2+ !
     1000        // MBR-ProtImg, DriveLetters, Packed hideparttable
     1001        */
     1002
     1003        // UPGRADE all later versions
     1004        //  We don't need to "upgrade" the configuration, we simply copy it over.
     1005        //   From Sector 55, 6 sectors in total but never header/version
     1006        // Rousseau: We copy two more sectors (8 in total) in the extended (45 partition) version.
     1007        switch (IMAGE_SIZE) {
     1008            case IMAGE_SIZE_60SECS: {
     1009                memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], BYTES_PER_SECTOR * 6 - 16);
     1010                break;
     1011            }
     1012            case IMAGE_SIZE_62SECS: {
     1013                memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], BYTES_PER_SECTOR * 8 - 16);
     1014                break;
     1015            }
     1016        }
    4311017        return;
    432        }
    433       // Checksum fine
    434       Installed_ConfigVersion = (Track0[54 * BYTES_PER_SECTOR + 0x0D] << 8) | Track0[54 * BYTES_PER_SECTOR + 0x0E];
    435       if (Installed_ConfigVersion>=Bootcode_ConfigVersion) {
    436          Status_Config = STATUS_INSTALLED; return;
    437        }
    438       Status_Config = STATUS_INSTALLEDMGU;
    439       // Those upgrades will copy useful configuration data to the image config
    440       //  If new configuration data was added, those spaces are not overwritten
    441       // Sector 60 (MBR-BackUp) *MUST BE* copied, otherwise it would be lost.
    442       // Rousseau: Upgrade from v0.27
    443       if (Installed_ConfigVersion<=0x27) {
    444          // UPGRADE v0.27 and prior versions
    445 
    446          // Sector 55
    447          // Changes: Offset  69 length 75 - Linux command line
    448          //          Offset 144 length  1 - Linux kernel partition
    449          //          Offset 145 Length 11 - Default kernel name
    450          //          Offset 156 Length  1 - Kernel name terminator 1
    451          //          Offset 157 Length 11 - Last kernel name
    452          //          Offset 168 Length  1 - Kernel name terminator 2
    453          //          Offset 169 Length  1 - Ext. partition M$-hack enable
    454          //           -> Total-length 101
    455          //          Offset 432 Length 34 - New IPT entry (BIOS continued)
    456          memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], 69 - 16);    // CHECKEN !!
    457          memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 466], &Track0[54 * BYTES_PER_SECTOR + 466], 46);       // CHECKEN !!
    458          // Sector 56-57 no changes
    459          memcpy(&Bootcode[55*512], &Track0[55 * BYTES_PER_SECTOR], 1024);
    460          // Sector 58-59
    461          // Changes: Offset 900 Length 30 - Logical driveletter table
    462          memcpy(&Bootcode[57 * BYTES_PER_SECTOR], &Track0[57 * BYTES_PER_SECTOR], 900);               // AANPASSEN 900 !!
    463          // Sector 60 copy unmodified
    464          memcpy(&Bootcode[59 * BYTES_PER_SECTOR], &Track0[59 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);  // CHECKEN !!
    465          return;
    466        }
    467       // Rousseau: Upgrade from v0.91
    468       if (Installed_ConfigVersion<=0x91) {
    469          // UPGRADE v0.91 and prior versions
    470          // Sector 55-57 no changes
    471          memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], BYTES_PER_SECTOR + 1024 - 16);   // CHACKEN !!
    472          // Sector 58-59
    473          // Changes: Offset 900 Length 30 - Logical driveletter table
    474          memcpy(&Bootcode[57 * BYTES_PER_SECTOR], &Track0[57 * BYTES_PER_SECTOR], 900);               // AANPASSEN 900 !!
    475          // Sector 60 copy unmodified
    476          memcpy(&Bootcode[59 * BYTES_PER_SECTOR], &Track0[59 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);
    477          return;
    478        }
    479       // UPGRADE all later versions
    480       //  We don't need to "upgrade" the configuration, we simply copy it over.
    481       //   From Sector 55, 6 sectors in total but never header/version
    482       // Rousseau: We copy two more sectors (8 in total) in the extended (45 partition) version.
    483       switch (IMAGE_SIZE) {
    484          case IMAGE_SIZE_60SECS: {
    485             memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], BYTES_PER_SECTOR * 6 - 16);
    486             break;
    487          }
    488          case IMAGE_SIZE_62SECS: {
    489             memcpy(&Bootcode[54 * BYTES_PER_SECTOR + 16], &Track0[54 * BYTES_PER_SECTOR + 16], BYTES_PER_SECTOR * 8 - 16);
    490             break;
    491          }
    492       }
    493 
    494       return;
    495     }
    496    // Check for prior v0.26 signature
    497    // not supported in C version anymore
    498    //  Don't have this version here for testing and I can't risk breaking
    499    //  configuration
    500  }
     1018    }
     1019    // Check for prior v0.26 signature
     1020    // not supported in C version anymore
     1021    //  Don't have this version here for testing and I can't risk breaking
     1022    //  configuration
     1023    return;
     1024}
    5011025
    5021026// Checks partition table for valid data
    5031027BOOL Virus_CheckThisMBR (PCHAR MBRptr) {                                         // Rousseau: adjusted this function
    504    USHORT PartitionNo;
    505    ////ULONG  CHSStart, CHSEnd;
    506 
    507    //printf("DEBUG: Virus_CheckThisMBR\n");
    508 
    509    if (*(PUSHORT)(MBRptr + BYTES_PER_SECTOR - 2)!=0x0AA55) return FALSE;
    510 
    511    //printf("DEBUG: Virus_CheckThisMBR - Checking Partitions\n");
    512 
    513    MBRptr += 446;
    514    for (PartitionNo=0; PartitionNo<4; PartitionNo++) {
    515       if (*(MBRptr+4) != 0) {
    516          /*
    517          // Rousseau 2011-02-04: ## Check for GPT ##
    518          */
    519          if (*(MBRptr+4) == GPT) {
    520             if (!Option_CID) {
    521                printf("ERROR: This drive is partitioned with the modern GPT layout.\n");
    522                printf("       AiR-BOOT is currently unable to handle GPT partitioned drives.\n");
    523                printf("       Installation aborted, no changes made.\n");
    524             }
    525             exit(2);
    526          }
    527 
    528          /*
    529          // Rousseau: 2011-05-05
    530          //           Last minute change to have AB install a disk with nopartitions
    531          //           on the bootdisk.
    532          //           It still checks for GPT but will skip the check below.
    533          */
    534          continue;
    535 
    536          //printf("DEBUG: Virus_CheckThisMBR - Partition: %d\n", PartitionNo);
    537          // Partition-type defined, analyse partition data
    538          ////CHSStart = (*(MBRptr+3) | ((*(MBRptr+2) >> 6) << 8)) << 16;             // Cylinder
    539          ////CHSStart |= (*(MBRptr+2) & 0x3F) | ((*(MBRptr+1) << 8));                // Sector / Head
    540          //printf("DEBUG: Virus_CheckThisMBR - CHSStart: %d\n", CHSStart);                               // 3F MASK CHECKEN !!
    541 
    542          ////CHSEnd = (*(MBRptr+7) | ((*(MBRptr+6) >> 6) << 8)) << 16;               // Cylinder
    543          ////CHSEnd |= (*(MBRptr+6) & 0x3F) | ((*(MBRptr+5) << 8));                  // Sector / Head
    544          //printf("DEBUG: Virus_CheckThisMBR - CHSEnd: %d\n", CHSEnd);
    545 
    546 
    547          /*
    548          // Rousseau 2011-02-03: ## Changed below from < to <= ##
    549          // When a partition is above 1024x255x63 (8GiB) the start and end of the partition
    550          // in the MBR is the same (1024/255/63) to indicate extended CHS-values.
    551          // This made the installer see this as a non-valid entry.
    552          // Fixme: This could use some further optimazation like checking if CHS is really 1024/255/63
    553          //        to exclude truly faulty partition-entries.
    554          */
    555          /*if (CHSStart<CHSEnd) {*/
    556          ////if (CHSStart<=CHSEnd) {
    557          ////   if (*(PULONG)(MBRptr+12)!=0) // Absolute length > 0?
    558          ////      return TRUE;
    559           ////}
    560        }
    561       // Go to next partition
    562       MBRptr += 16;
    563     }
    564    // No partitions defined/no valid partitions found
    565    // Rousseau: Still return TRUE (OK)
    566    //return FALSE;
    567    return TRUE;
    568  }
     1028    USHORT PartitionNo;
     1029    ////ULONG  CHSStart, CHSEnd;
     1030
     1031    //printf("DEBUG: Virus_CheckThisMBR\n");
     1032
     1033    if (*(PUSHORT)(MBRptr + BYTES_PER_SECTOR - 2)!=0x0AA55)
     1034        return FALSE;
     1035
     1036    //printf("DEBUG: Virus_CheckThisMBR - Checking Partitions\n");
     1037
     1038    MBRptr += 446;
     1039    for (PartitionNo=0; PartitionNo<4; PartitionNo++) {
     1040        if (*(MBRptr+4) != 0) {
     1041            /*
     1042            // Rousseau 2011-02-04: ## Check for GPT ##
     1043            */
     1044            if (*(MBRptr+4) == GPT) {
     1045                if (!Option_CID) {
     1046                    printf("ERROR: This drive is partitioned with the modern GPT layout.\n");
     1047                    printf("       AiR-BOOT is currently unable to handle GPT partitioned drives.\n");
     1048                    printf("       Installation aborted, no changes made.\n");
     1049                }
     1050                exit(2);
     1051            }
     1052
     1053            /*
     1054            // Rousseau: 2011-05-05
     1055            //           Last minute change to have AB install on a disk
     1056            //            with nopartitions on the it.  (check !)
     1057            //           It still checks for GPT but will skip the check below.
     1058            */
     1059            continue;
     1060
     1061            //printf("DEBUG: Virus_CheckThisMBR - Partition: %d\n", PartitionNo);
     1062            // Partition-type defined, analyse partition data
     1063            ////CHSStart = (*(MBRptr+3) | ((*(MBRptr+2) >> 6) << 8)) << 16;             // Cylinder
     1064            ////CHSStart |= (*(MBRptr+2) & 0x3F) | ((*(MBRptr+1) << 8));                // Sector / Head
     1065            //printf("DEBUG: Virus_CheckThisMBR - CHSStart: %d\n", CHSStart);                               // 3F MASK CHECKEN !!
     1066
     1067            ////CHSEnd = (*(MBRptr+7) | ((*(MBRptr+6) >> 6) << 8)) << 16;               // Cylinder
     1068            ////CHSEnd |= (*(MBRptr+6) & 0x3F) | ((*(MBRptr+5) << 8));                  // Sector / Head
     1069            //printf("DEBUG: Virus_CheckThisMBR - CHSEnd: %d\n", CHSEnd);
     1070
     1071
     1072            /*
     1073            // Rousseau 2011-02-03: ## Changed below from < to <= ##
     1074            // When a partition is above 1024x255x63 (8GiB) the start and end of the partition
     1075            // in the MBR is the same (1024/255/63) to indicate extended CHS-values.
     1076            // This made the installer see this as a non-valid entry.
     1077            // Fixme: This could use some further optimazation like checking if CHS is really 1024/255/63
     1078            //        to exclude truly faulty partition-entries.
     1079            //        Also depends on conventions: IBM,MS,Partition Magic,...
     1080            */
     1081            /*if (CHSStart<CHSEnd) {*/
     1082            ////if (CHSStart<=CHSEnd) {
     1083            ////   if (*(PULONG)(MBRptr+12)!=0) // Absolute length > 0?
     1084            ////      return TRUE;
     1085            ////}
     1086        }
     1087    // Go to next partition
     1088    MBRptr += 16;
     1089    }
     1090    // No partitions defined/no valid partitions found
     1091    // Rousseau: Still return TRUE (OK)
     1092    //return FALSE;
     1093    return TRUE;
     1094}
    5691095
    5701096BOOL Virus_CheckCurrentMBR (void) {
    571    return Virus_CheckThisMBR(&Track0);
    572  }
     1097    return Virus_CheckThisMBR((PCHAR) Track0);
     1098}
    5731099
    5741100BOOL Virus_CheckForBackUpMBR (void) {
    575    return Virus_CheckThisMBR(&Track0[59 * BYTES_PER_SECTOR]);
    576  }
     1101    BOOL    bMbrBackup = FALSE;
     1102
     1103    // All versions above v1.06 have expanded tables so the MBR-backup
     1104    // is located 2 sectors higher in the track0 image.
     1105    if (Installed_ConfigVersion<=0x0106)
     1106        bMbrBackup = Virus_CheckThisMBR((PCHAR) &Track0[59 * BYTES_PER_SECTOR]);
     1107    else
     1108        bMbrBackup = Virus_CheckThisMBR((PCHAR) &Track0[61 * BYTES_PER_SECTOR]);
     1109
     1110    return bMbrBackup;
     1111}
    5771112
    5781113BOOL Virus_CheckForStealth (void) {
    579    PCHAR  CurPtr = &Track0;
    580    USHORT i;
    581 
    582    for (i=0; i<511; i++) {                                                       // BYTES_PER_SECTOR RELATED ??
    583       if (*(PUSHORT)CurPtr==0x13CD) return FALSE;
    584       CurPtr++;
    585     }
    586    // No CD13h found? possible stealth
    587    return TRUE;
    588  }
     1114    PCHAR  CurPtr = (PCHAR) Track0;
     1115    USHORT i;
     1116
     1117    for (i=0; i<511; i++) {
     1118        if (*(PUSHORT)CurPtr==0x13CD) return FALSE;
     1119        CurPtr++;
     1120    }
     1121    // No CD13h found? possible stealth
     1122    return TRUE;
     1123}
    5891124
    5901125// Copies backup MBR into current MBR on current memory copy of track 0
    5911126// Rousseau: Two sectors higher in the extended version.
    5921127void Virus_CopyBackUpMBR (void) {
    593    switch (IMAGE_SIZE) {
    594       case IMAGE_SIZE_60SECS: {
    595          memcpy(&Track0, &Track0[59 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);      // sector 60
    596          break;
    597       }
    598       case IMAGE_SIZE_62SECS: {
    599          memcpy(&Track0, &Track0[61 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);      // sector 62
    600          break;
    601       }
    602    }
    603  }
     1128    switch (IMAGE_SIZE) {
     1129        case IMAGE_SIZE_60SECS: {
     1130            memcpy(Track0, &Track0[59 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);      // sector 60
     1131            break;
     1132        }
     1133        case IMAGE_SIZE_62SECS: {
     1134            memcpy(Track0, &Track0[61 * BYTES_PER_SECTOR], BYTES_PER_SECTOR);      // sector 62
     1135            break;
     1136        }
     1137    }
     1138}
    6041139
    6051140void Status_PrintF (ULONG Status, USHORT Version) {
    606    switch (Status) {
    607     case STATUS_NOTINSTALLED: {
    608        if (!Option_CID) {
    609          printf("not installed\n");
    610       }
    611        break;
    612      }
    613     case STATUS_CORRUPT: {
    614        if (!Option_CID) {
    615          printf("not intact\n");
    616       }
    617        break;
    618      }
    619     case STATUS_INSTALLED:
    620     case STATUS_INSTALLEDMGU:
    621        if (!Option_CID) {
    622          printf("intact (v%x.%1d.%1d)", Version>>8, (Version & 0x0F0)>>4, Version & 0x0F);
    623 
    624        }
    625        if (Status==STATUS_INSTALLEDMGU)
    626          if (!Option_CID) {
    627             printf(", but may be updated");
    628             printf("\n");
    629          }
    630        break;
    631     case STATUS_IMPOSSIBLE:
    632       if (!Option_CID) {
    633          printf(ImpossibleCause);
    634       }
    635        break;
    636     }
    637  }
     1141    switch (Status) {
     1142        case STATUS_NOTINSTALLED: {
     1143            if (!Option_CID) {
     1144                printf("not installed\n");
     1145            }
     1146            break;
     1147        }
     1148        case STATUS_CORRUPT: {
     1149            if (!Option_CID) {
     1150                printf("not intact\n");
     1151            }
     1152            break;
     1153        }
     1154        case STATUS_INSTALLED:
     1155        case STATUS_INSTALLEDMGU:
     1156            if (!Option_CID) {
     1157                printf("intact (v%x.%1d.%1d)", Version>>8, (Version & 0x0F0)>>4, Version & 0x0F);
     1158            }
     1159            if (Status==STATUS_INSTALLEDMGU)
     1160                if (!Option_CID) {
     1161                printf(", but may be updated");
     1162                printf("\n");
     1163                }
     1164            break;
     1165        case STATUS_IMPOSSIBLE:
     1166            if (!Option_CID) {
     1167            printf(ImpossibleCause);
     1168            }
     1169            break;
     1170    }
     1171}
    6381172
    6391173void Language_PrintF(UCHAR LanguageID) {
    640    if (Option_CID)
    641       return;
    642    switch (LanguageID) {
    643      case 'E': printf("english"); break;
    644      case 'N': printf("dutch"); break;       // Changed from 'D' to 'N'
    645      case 'G': printf("german"); break;
    646      case 'F': printf("french"); break;
    647      case 'I': printf("italian"); break;
    648      case 'R': printf("russian"); break;
    649      case 'S': printf("swedish"); break;
    650      default:  printf("unknown");
    651     }
    652  }
     1174    if (Option_CID)
     1175        return;
     1176    switch (LanguageID) {
     1177        case 'E': printf("english");    break;
     1178        case 'N': printf("dutch");      break;      // Changed from 'D' to 'N'
     1179        case 'G': printf("german");    break;
     1180        case 'F': printf("french");    break;
     1181        case 'I': printf("italian");    break;
     1182        case 'R': printf("russian");    break;
     1183        case 'S': printf("swedish");    break;
     1184        default:  printf("unknown");
     1185    }
     1186}
    6531187
    6541188// Doesn't actually write code/config, but writes it to track0 memory
    6551189void Install_WriteCode (void) {
    656    USHORT TotalCodeSectorsUsed = 0;
    657    USHORT SectorCount = 0;
    658    USHORT Checksum = 0;
    659    PCHAR  SectorPtr = NULL;
    660 
    661    // Calculate checksum for code...
    662    TotalCodeSectorsUsed = Bootcode[0x10];                                        // SECTORS USED CHECKEN !! (34h / 52d in v1.06)
    663    SectorPtr = &Bootcode[1 * BYTES_PER_SECTOR]; // Start at sector 2
    664    SectorCount = TotalCodeSectorsUsed;
    665    while (SectorCount>0) {
    666       Checksum = GetChecksumOfSector(Checksum, SectorPtr);
    667       SectorPtr += BYTES_PER_SECTOR;
    668       SectorCount--;
    669     }
    670    *(PUSHORT)&Bootcode[0x11] = Checksum;
    671 
    672    // Copy MBR till offset 0x1B8 (Windows NT hdd signature location)
    673    memcpy(&Track0, &Bootcode, 0x1B8);
    674 
    675    // Copy over code sectors...
    676    memcpy(&Track0[BYTES_PER_SECTOR], &Bootcode[BYTES_PER_SECTOR], TotalCodeSectorsUsed * BYTES_PER_SECTOR);
    677  }
     1190    USHORT TotalCodeSectorsUsed = 0;
     1191    USHORT SectorCount = 0;
     1192    USHORT Checksum = 0;
     1193    PCHAR  SectorPtr = NULL;
     1194
     1195    // Calculate checksum for code...
     1196    TotalCodeSectorsUsed = Bootcode[0x10];                                        // SECTORS USED CHECKEN !! (34h / 52d in v1.06)
     1197    SectorPtr = &Bootcode[1 * BYTES_PER_SECTOR]; // Start at sector 2
     1198    SectorCount = TotalCodeSectorsUsed;
     1199    while (SectorCount>0) {
     1200        Checksum = GetChecksumOfSector(Checksum, SectorPtr);
     1201        SectorPtr += BYTES_PER_SECTOR;
     1202        SectorCount--;
     1203    }
     1204    *(PUSHORT)&Bootcode[0x11] = Checksum;
     1205
     1206    // Copy MBR till offset 0x1B8 (Windows NT hdd signature location)
     1207    memcpy(Track0, Bootcode, 0x1B8);
     1208
     1209    // Copy over code sectors...
     1210    memcpy(&Track0[BYTES_PER_SECTOR], &Bootcode[BYTES_PER_SECTOR], TotalCodeSectorsUsed * BYTES_PER_SECTOR);
     1211}
    6781212
    6791213void Install_WriteConfig (void) {
    680    USHORT SectorCount = 0;
    681    USHORT Checksum = 0;
    682    PCHAR  SectorPtr = NULL;
    683 
    684    #ifdef PLATFORM_OS2
    685       if (AutoDriveLetter!=0) {
    686          // Add DriveLetter Automatic veriables, if set
    687          Bootcode[54 * BYTES_PER_SECTOR + 0x1AB] = AutoDriveLetter;                       // CHECKEN !
    688          *(PULONG)&Bootcode[54 * BYTES_PER_SECTOR + 0x1AC] = AutoDriveLetterSerial;
    689        }
    690    #endif
    691 
    692    // Delete current checksum
    693    *(PUSHORT)&Bootcode[54 * BYTES_PER_SECTOR + 20] = 0;
    694 
    695    SectorPtr = &Bootcode[54 * BYTES_PER_SECTOR];                                 // Start at sector 55
    696 
    697    /*
    698    // Rousseau: # Keep compatible with v1.07 CRC #
    699    // AB v1.07 had bugs in writing the wrong number of AB config sectors.
    700    // This is fixed in v1.0.8 but the CRC has to be calculated the "v1.07 way"
    701    // otherwise v1.07 SET(A)BOOT and INSTALL2.EXE will think the AB config
    702    // is corrupted.
    703    // So the CRC is calculated over 5 sectors instead of 7.
    704    */
    705    SectorCount = 5;
    706 
    707    while (SectorCount>0) {
    708       Checksum = GetChecksumOfSector(Checksum, SectorPtr);
    709       SectorPtr += BYTES_PER_SECTOR;
    710       SectorCount--;
    711     }
    712    *(PUSHORT)&Bootcode[54 * BYTES_PER_SECTOR + 20] = Checksum;
    713 
    714    // Copy configuration sectors
    715    // Rousseau: Two more sectors for extended version.
    716    switch (IMAGE_SIZE) {
    717       case IMAGE_SIZE_60SECS: {
    718          memcpy(&Track0[54 * BYTES_PER_SECTOR], &Bootcode[54 * BYTES_PER_SECTOR], 6 * BYTES_PER_SECTOR);
    719          break;
    720       }
    721       case IMAGE_SIZE_62SECS: {
    722          memcpy(&Track0[54 * BYTES_PER_SECTOR], &Bootcode[54 * BYTES_PER_SECTOR], 8 * BYTES_PER_SECTOR);
    723          break;
    724       }
    725    }
    726  }
     1214    USHORT SectorCount = 0;
     1215    USHORT Checksum = 0;
     1216    PCHAR  SectorPtr = NULL;
     1217
     1218#ifdef PLATFORM_OS2
     1219    if (AutoDriveLetter!=0) {
     1220        // Add DriveLetter Automatic veriables, if set
     1221        Bootcode[54 * BYTES_PER_SECTOR + 0x1AB] = AutoDriveLetter;                       // CHECKEN !
     1222        *(PULONG)&Bootcode[54 * BYTES_PER_SECTOR + 0x1AC] = AutoDriveLetterSerial;
     1223    }
     1224#endif
     1225
     1226    // Delete current checksum
     1227    *(PUSHORT)&Bootcode[54 * BYTES_PER_SECTOR + 20] = 0;
     1228
     1229    SectorPtr = &Bootcode[54 * BYTES_PER_SECTOR];                                 // Start at sector 55
     1230
     1231    /*
     1232    // Rousseau: # Keep compatible with v1.07 CRC #
     1233    // AB v1.07 had bugs in writing the wrong number of AB config sectors.
     1234    // This is fixed in v1.0.8 but the CRC has to be calculated the "v1.07 way"
     1235    // otherwise v1.07 SET(A)BOOT and AIRBOOT2.EXE will think the AB config
     1236    // is corrupted.
     1237    // So the CRC is calculated over 5 sectors instead of 7.
     1238    */
     1239    SectorCount = 5;
     1240
     1241    while (SectorCount>0) {
     1242        Checksum = GetChecksumOfSector(Checksum, SectorPtr);
     1243        SectorPtr += BYTES_PER_SECTOR;
     1244        SectorCount--;
     1245    }
     1246    *(PUSHORT)&Bootcode[54 * BYTES_PER_SECTOR + 20] = Checksum;
     1247
     1248    // Copy configuration sectors
     1249    // Rousseau: Two more sectors for extended version.
     1250    switch (IMAGE_SIZE) {
     1251        case IMAGE_SIZE_60SECS: {
     1252            memcpy(&Track0[54 * BYTES_PER_SECTOR], &Bootcode[54 * BYTES_PER_SECTOR], 6 * BYTES_PER_SECTOR);
     1253            break;
     1254        }
     1255        case IMAGE_SIZE_62SECS: {
     1256            memcpy(&Track0[54 * BYTES_PER_SECTOR], &Bootcode[54 * BYTES_PER_SECTOR], 8 * BYTES_PER_SECTOR);
     1257            break;
     1258        }
     1259    }
     1260
     1261    return;
     1262}
     1263
     1264
     1265
     1266
     1267
     1268
     1269// ============================================================================
     1270//  Main Entrypoint
     1271// ============================================================================
     1272
     1273
    7271274
    7281275#define MAXCMDPARMLEN 11
    7291276
    7301277int main (int argc, char **argv) {
    731    ULONG  CurArgument = 0;
    732    ULONG  ArgumentLen = 0;
    733    PCHAR  StartPos    = 0;
    734    CHAR   TempSpace[MAXCMDPARMLEN+1];
    735    UCHAR  UserKey     = ' ';
    736    BOOL   ExitOnly    = FALSE;
     1278    ULONG   CurArgument     = 0;
     1279    size_t  ArgumentLen     = 0;
     1280    PCHAR   StartPos        = 0;
     1281    UCHAR   UserKey         = ' ';
     1282    BOOL    ExitOnly        = FALSE;
     1283    CHAR    TempSpace[MAXCMDPARMLEN+1];
     1284
     1285    char* p = NULL;
     1286
     1287
     1288    do_bf_test();
     1289    exit(0);
     1290
    7371291
    7381292//   printf("AiR-BOOT Installer v1.07\n");
     
    7401294//   printf("\n-> ...Please wait... <-\n");
    7411295
    742    // Check commandline parameters
    743    CurArgument = 1;
    744    while (CurArgument<argc) {
    745       StartPos = argv[CurArgument];
    746       ArgumentLen = strlen(StartPos);
    747 
    748       if (((*StartPos=='-') || (*StartPos=='/')) && (ArgumentLen>1)) {
    749          StartPos++; ArgumentLen--;
    750          if (ArgumentLen>MAXCMDPARMLEN) ArgumentLen = MAXCMDPARMLEN;
    751          strncpy(&TempSpace, StartPos, ArgumentLen);
    752          TempSpace[ArgumentLen] = 0;
    753          StartPos = &TempSpace;
    754          while (*StartPos!=0) {
    755             *StartPos = tolower(*StartPos); StartPos++;
    756           }
    757          if (strcmp(&TempSpace, "forcecode")==0) Option_ForceCode = TRUE;
    758          if (strcmp(&TempSpace, "forceconfig")==0) Option_ForceConfig = TRUE;
    759          if (strcmp(&TempSpace, "silent")==0) Option_Silent = TRUE;
    760          if (strcmp(&TempSpace, "cid")==0) Option_CID = TRUE;
    761        }
    762       CurArgument++;
    763     }
    764 
    765    if (Option_CID) {
    766       Option_Silent = TRUE;
    767    }
    768 
    769    #ifdef PLATFORM_WINNT
    770       if (CheckWindowsVersion()==FALSE) return 1;
    771    #endif
    772 
    773    if (CountHarddrives()==0) {
    774       if (!Option_CID) {
    775          printf(" - No physical drives found on this system. Install impossible.\n");
    776       }
    777       return 3;   // Rouseau: changed from 1 to 3
    778     }
    779 
    780    if (!Option_CID) {
    781       printf(" - Loading bootcode from file...");
    782    }
    783    if (LoadBootcodeFromFile()==FALSE) return 1;
    784    if (!Option_CID) {
    785       printf("ok\n");
    786    }
    787 
    788    if (!Option_CID) {
    789       printf(" - Loading MBR from harddisc...");
    790    }
    791    if (HarddriveCheckGeometry()) {
    792       // No EZ-SETUP check here, because we are under 32-bit OS and this
    793       //  wouldn't make any sense
    794       if (!Track0Load()) {
    795          if (!Option_CID) {
    796             printf("LOAD ERROR!\n");
    797          }
    798          return 1;
    799        }
    800     } else {
    801       StatusCode = STATUS_IMPOSSIBLE;
    802       if (!Option_CID) {
    803          ImpossibleCause = "unable to install\n   Your harddisc does not have at least 63 sectors per track.";
    804       }
    805     }
    806    if (!Option_CID) {
    807       printf("ok\n");
    808    }
    809 
    810 
    811    if (!Option_CID) {
    812       printf("\n-> ...Current Status... <-\n");
    813    }
    814    Status_CheckCode();
    815    if (!Option_CID) {
    816       printf(" - AiR-BOOT is ");
    817    }
    818    Status_PrintF(Status_Code, Installed_CodeVersion);
    819    if (StatusCode==STATUS_IMPOSSIBLE) return 1;
    820    Status_CheckConfig();
    821    if (!Option_CID) {
    822       printf(" - Configuration is ");
    823    }
    824    Status_PrintF(Status_Config, Installed_ConfigVersion);
    825    // Display language as well, if code installed
    826    if ((Status_Code==STATUS_INSTALLED) || (Status_Code==STATUS_INSTALLEDMGU)) {
    827       if (!Option_CID) {
    828          printf(" - Language is ");
    829       }
    830       Language_PrintF(Installed_LanguageID);
    831       if (!Option_CID) {
    832          printf("\n");
    833       }
    834     }
    835 
    836    // =============================================================
    837    //  PRE-CHECKING, WHAT WE ARE SUPPOSED TO DO...
    838    // =============================================================
    839    if ((Option_ForceCode) || (Status_Code!=STATUS_INSTALLED) || (Installed_LanguageID!=Bootcode_LanguageID))
    840       Install_Code = TRUE;  // If LanguageID different or not installed
    841    if ((Option_ForceConfig) || (Status_Config!=STATUS_INSTALLED))
    842       Install_Config = TRUE; // If not installed
    843 
    844    if ((Status_Code==STATUS_CORRUPT) || (Status_Config==STATUS_CORRUPT))
    845       Install_IsCorrupt = TRUE; // If anything is corrupt
    846 
    847    // =============================================================
    848    //  VIRUS
    849    // =============================================================
    850    // If-Table
    851    // ---------
    852    //  Code==not installed, Config=not installed -> Check MBR
    853    //  Code==installed, config==installed -> Check MBR (-> Virus?)
    854    //  Code==not installed, config==installed -> (-> Virus?)
    855    //  Code==installed, config==not installed -> Check MBR (-> Virus?)
    856 
    857    //printf("DEBUG: Status_Code: %d, Status_Config: %d\n", Status_Code, Status_Config);  // Rousseau: DEBUG
    858 
    859    if ((Status_Code==STATUS_NOTINSTALLED) & (Status_Config==STATUS_NOTINSTALLED)) {
    860       // Nothing installed, so check MBR, if squashed...
    861       if (!Virus_CheckCurrentMBR()) {
    862          if (!Option_CID) {
    863             printf("\n\n");
    864             printf("AiR-BOOT detected that the data on your harddisc got damaged.\n");
    865             printf("If you had AiR-BOOT installed before: the corruption killed AiR-BOOT completly!\n");
    866             printf("Installation halted.\n");
    867          }
    868          return 255; // Rousseau: changed from 1 to 255
    869        }
    870        //printf("DEBUG: Installing...\n");                                               // Rousseau: DEBUG
    871     } else {
    872       if ((Status_Code==STATUS_NOTINSTALLED) | (!Virus_CheckCurrentMBR())) {
    873          // Code not installed, but Config or MBR squashed...
    874          //  -> Virus proposed, check for backup (if available)
    875          if (!Option_CID) {
    876             printf("\n\n");
    877             printf("-> ...!ATTENTION!... <-\n");
    878          }
    879          if (Virus_CheckForStealth())
     1296    // Allocate buffers for Track0 and AIRBOOT.BIN.
     1297    Track0 = malloc(SECTOR_COUNT * BYTES_PER_SECTOR);
     1298    Bootcode = malloc(SECTOR_COUNT * BYTES_PER_SECTOR);
     1299
     1300    // Exit of allocation failed.
     1301    if (!(Track0 && Bootcode)) {
     1302        if (!Option_CID) {
     1303            printf("- Unable to allocate enough memory, operation aborted!\n");
     1304        }
     1305        exit(4);
     1306    }
     1307
     1308
     1309    p = (PCHAR) &Track0;
     1310    p = (PCHAR) Track0;
     1311    p[0] = 'A';
     1312
     1313    {
     1314        int i=0;
     1315        for (i=0; i<sizeof(Track0); i++) {
     1316            Track0[i]='X';
     1317        }
     1318        for (i=0; i<sizeof(Bootcode); i++) {
     1319            Bootcode[i]='Y';
     1320        }
     1321        //~ for (i=0; i<sizeof(Bootcode2); i++) {
     1322            //~ Bootcode2[i]='Z';
     1323        //~ }
     1324    }
     1325
     1326
     1327    // Check commandline parameters
     1328    CurArgument = 1;
     1329    while (CurArgument<argc) {
     1330        StartPos = argv[CurArgument];
     1331        ArgumentLen = strlen(StartPos);
     1332
     1333        if (((*StartPos=='-') || (*StartPos=='/')) && (ArgumentLen>1)) {
     1334            StartPos++; ArgumentLen--;
     1335            if (ArgumentLen>MAXCMDPARMLEN)
     1336                ArgumentLen = MAXCMDPARMLEN;
     1337            strncpy((char *) TempSpace, StartPos, ArgumentLen);
     1338            TempSpace[ArgumentLen] = 0;
     1339            StartPos = (PCHAR) TempSpace;
     1340            while (*StartPos!=0) {
     1341                *StartPos = tolower(*StartPos); StartPos++;
     1342            }
     1343            if (strcmp((char *) TempSpace, "forcecode")==0) Option_ForceCode = TRUE;
     1344            if (strcmp((char *) TempSpace, "forceconfig")==0) Option_ForceConfig = TRUE;
     1345            if (strcmp((char *) TempSpace, "silent")==0) Option_Silent = TRUE;
     1346            if (strcmp((char *) TempSpace, "cid")==0) Option_CID = TRUE;
     1347        }
     1348        CurArgument++;
     1349    }
     1350
     1351    if (Option_CID) {
     1352        Option_Silent = TRUE;
     1353    }
     1354
     1355#ifdef PLATFORM_WINNT
     1356    if (CheckWindowsVersion()==FALSE)
     1357        return 1;
     1358#endif
     1359
     1360    if (CountHarddrives()==0) {
     1361        if (!Option_CID) {
     1362            printf(" - No physical drives found on this system. Install impossible.\n");
     1363        }
     1364        return 3;   // Rouseau: changed from 1 to 3
     1365    }
     1366
     1367    if (!Option_CID) {
     1368        printf(" - Loading bootcode from file...");
     1369    }
     1370
     1371    if (LoadBootcodeFromFile()==FALSE)
     1372        return 1;
     1373
     1374    if (!Option_CID) {
     1375        printf("ok\n");
     1376    }
     1377
     1378    if (!Option_CID) {
     1379        printf(" - Loading MBR from harddisc...");
     1380    }
     1381    if (HarddriveCheckGeometry()) {
     1382        // No EZ-SETUP check here, because we are under 32-bit OS and this
     1383        //  wouldn't make any sense
     1384        if (!Track0Load()) {
    8801385            if (!Option_CID) {
    881                printf("Your system GOT infected by a stealth-virus (or your MBR got trashed).\n");
    882             }
    883            else
     1386                printf("LOAD ERROR!\n");
     1387            }
     1388            return 1;
     1389        }
     1390    }
     1391    else {
     1392        StatusCode = STATUS_IMPOSSIBLE;
     1393        if (!Option_CID) {
     1394            ImpossibleCause = "unable to install\n   Your harddisc does not have at least 63 sectors per track.";
     1395        }
     1396    }
     1397
     1398    if (!Option_CID) {
     1399        printf("ok\n");
     1400    }
     1401
     1402
     1403    if (!Option_CID) {
     1404        printf("\n-> ...Current Status... <-\n");
     1405    }
     1406
     1407    Status_CheckCode();
     1408    if (!Option_CID) {
     1409        printf(" - AiR-BOOT is ");
     1410    }
     1411    Status_PrintF(Status_Code, Installed_CodeVersion);
     1412    if (StatusCode==STATUS_IMPOSSIBLE)
     1413        return 1;
     1414    Status_CheckConfig();
     1415    if (!Option_CID) {
     1416        printf(" - Configuration is ");
     1417    }
     1418    Status_PrintF(Status_Config, Installed_ConfigVersion);
     1419    // Display language as well, if code installed
     1420    if ((Status_Code==STATUS_INSTALLED) || (Status_Code==STATUS_INSTALLEDMGU)) {
     1421        if (!Option_CID) {
     1422            printf(" - Language is ");
     1423        }
     1424        Language_PrintF(Installed_LanguageID);
     1425        if (!Option_CID) {
     1426            printf("\n");
     1427        }
     1428    }
     1429
     1430    // =============================================================
     1431    //  PRE-CHECKING, WHAT WE ARE SUPPOSED TO DO...
     1432    // =============================================================
     1433    if ((Option_ForceCode) || (Status_Code!=STATUS_INSTALLED) || (Installed_LanguageID!=Bootcode_LanguageID))
     1434        Install_Code = TRUE;  // If LanguageID different or not installed
     1435    if ((Option_ForceConfig) || (Status_Config!=STATUS_INSTALLED))
     1436        Install_Config = TRUE; // If not installed
     1437
     1438    if ((Status_Code==STATUS_CORRUPT) || (Status_Config==STATUS_CORRUPT))
     1439        Install_IsCorrupt = TRUE; // If anything is corrupt
     1440
     1441    // =============================================================
     1442    //  VIRUS
     1443    // =============================================================
     1444    // If-Table
     1445    // ---------
     1446    //  Code==not installed, Config=not installed -> Check MBR
     1447    //  Code==installed, config==installed -> Check MBR (-> Virus?)
     1448    //  Code==not installed, config==installed -> (-> Virus?)
     1449    //  Code==installed, config==not installed -> Check MBR (-> Virus?)
     1450
     1451    //printf("DEBUG: Status_Code: %d, Status_Config: %d\n", Status_Code, Status_Config);  // Rousseau: DEBUG
     1452
     1453    if ((Status_Code==STATUS_NOTINSTALLED) & (Status_Config==STATUS_NOTINSTALLED)) {
     1454        // Nothing installed, so check MBR, if squashed...
     1455        if (!Virus_CheckCurrentMBR()) {
    8841456            if (!Option_CID) {
    885                printf("Probably your system was infected by a virus.\n");
    886                printf("Repairing AiR-BOOT will normally squash the virus.\n");
    887                printf("But to be sure it's gone, you should check your harddisc using a virus-scanner.\n");
    888             }
    889          if (!Virus_CheckCurrentMBR()) {
    890             // MBR squashed, so check backup and display message
     1457                printf("\n\n");
     1458                printf("AiR-BOOT detected that the data on your harddisc got damaged.\n");
     1459                printf("If you had AiR-BOOT installed before: the corruption killed AiR-BOOT completly!\n");
     1460                printf("Installation halted.\n");
     1461            }
     1462            return 255; // Rousseau: changed from 1 to 255
     1463        }
     1464        //printf("DEBUG: Installing...\n");                                               // Rousseau: DEBUG
     1465    }
     1466    else {
     1467        if ((Status_Code==STATUS_NOTINSTALLED) | (!Virus_CheckCurrentMBR())) {
     1468            // Code not installed, but Config or MBR squashed...
     1469            //  -> Virus proposed, check for backup (if available)
    8911470            if (!Option_CID) {
    892                printf("\n");
    893                printf("AiR-BOOT detected that the virus has broken your partition-table.\n");
    894             }
    895             if (Virus_CheckForBackUpMBR()) {
    896                if (!Option_CID) {
    897                   printf("Good news: AiR-BOOT has found a (hopefully) functional backup.\n");
    898                   printf("Shall I use this backup, instead of the current active one? (Y/N)\n");
    899                }
    900                // User selection, Y/N, if he wants to restore MBR
    901                //  *NOT* CID (silent) able
    902                do {
    903                   UserKey = getch() | 0x20;
    904                 } while (!((UserKey=='y') | (UserKey=='n')));
    905                if (UserKey=='y')
    906                   Virus_CopyBackUpMBR();
    907              } else {
     1471                printf("\n\n");
     1472                printf("-> ...!ATTENTION!... <-\n");
     1473            }
     1474            if (Virus_CheckForStealth())
    9081475                if (!Option_CID) {
    909                   printf("Sadly the virus also broke AiR-BOOT's backup. You will have to help yourself.\n");
    910                }
    911              }
    912           }
    913        }
    914     }
    915 
    916    // =============================================================
    917    //  MAIN-MENU
    918    // =============================================================
    919    if (!Option_CID) {
    920       printf("\n-> ...Please press... <-\n");
    921    }
    922 
    923    if (!Option_CID) {
    924       if (Install_IsCorrupt) printf(" <R> - Repair AiR-BOOT ");
    925        else if (Status_Code==STATUS_NOTINSTALLED) printf(" <A> - Add AiR-BOOT ");
    926        else printf(" <U> - Update/Change AiR-BOOT to ");
    927       printf("'v%x.%1d.%1d/", Bootcode_Version>>8, (Bootcode_Version & 0x0F0)>>4, Bootcode_Version & 0x0F);
    928       Language_PrintF(Bootcode_LanguageID);
    929       printf("' on current system\n");
    930 
    931       printf(" <D> - Delete AiR-BOOT from current system\n");
    932       printf(" <Q> - Quit without any change\n");
    933    }
    934 
    935    if (Option_Silent || Option_CID) {
    936       // Silent operation? Always add AiR-BOOT then
    937       UserKey = 'a';
    938     } else {
    939       do {
    940          UserKey = getch() | 0x20;
    941        } while (!((UserKey=='a') || (UserKey=='r') || (UserKey=='u') || (UserKey=='d') || (UserKey=='q')));
    942     }
    943 
    944    if (!Option_CID) {
    945       printf("\n\n\n-------------------------------------------------------------------------------\n");
    946    }
    947    switch (UserKey) {
    948     case 'a':
    949     case 'r':
    950     case 'u': {
    951       if (Install_Code || Install_Config) {
    952          if (!Option_CID) {
    953             printf("Add/Repair/Update AiR-BOOT in progress...\n");
    954          }
    955          #ifdef PLATFORM_OS2
    956             OS2_GetBootAutoDriveLetter();
    957          #endif
    958          if (Install_Code) {
     1476                    printf("Your system GOT infected by a stealth-virus (or your MBR got trashed).\n");
     1477                }
     1478            else
     1479                if (!Option_CID) {
     1480                    printf("Probably your system was infected by a virus.\n");
     1481                    printf("Repairing AiR-BOOT will normally squash the virus.\n");
     1482                    printf("But to be sure it's gone, you should check your harddisc using a virus-scanner.\n");
     1483                }
     1484
     1485            if (!Virus_CheckCurrentMBR()) {
     1486                // MBR squashed, so check backup and display message
     1487                if (!Option_CID) {
     1488                    printf("\n");
     1489                    printf("AiR-BOOT detected that the virus has broken your partition-table.\n");
     1490                }
     1491                if (Virus_CheckForBackUpMBR()) {
     1492                    if (!Option_CID) {
     1493                        printf("Good news: AiR-BOOT has found a (hopefully) functional backup.\n");
     1494                        printf("Shall I use this backup, instead of the current active one? (Y/N)\n");
     1495                    }
     1496                    // User selection, Y/N, if he wants to restore MBR
     1497                    //  *NOT* CID (silent) able
     1498                    do {
     1499                        UserKey = getch() | 0x20;
     1500                    } while (!((UserKey=='y') | (UserKey=='n')));
     1501                    if (UserKey=='y')
     1502                        Virus_CopyBackUpMBR();
     1503                }
     1504                else {
     1505                    if (!Option_CID) {
     1506                        printf("Sadly the virus also broke AiR-BOOT's backup. You will have to help yourself.\n");
     1507                    }
     1508                }
     1509            }
     1510        }
     1511    }
     1512
     1513
     1514
     1515    // =============================================================
     1516    //  MAIN-MENU
     1517    // =============================================================
     1518    if (!Option_CID) {
     1519        printf("\n-> ...Please press... <-\n");
     1520    }
     1521
     1522    if (!Option_CID) {
     1523        if (Install_IsCorrupt)
     1524            printf(" <R> - Repair AiR-BOOT ");
     1525        else
     1526            if (Status_Code==STATUS_NOTINSTALLED)
     1527                printf(" <A> - Add AiR-BOOT ");
     1528            else
     1529                printf(" <U> - Update/Change AiR-BOOT to ");
     1530
     1531        printf("'v%x.%1d.%1d/", Bootcode_Version>>8, (Bootcode_Version & 0x0F0)>>4, Bootcode_Version & 0x0F);
     1532        Language_PrintF(Bootcode_LanguageID);
     1533        printf("' on current system\n");
     1534
     1535        printf(" <D> - Delete AiR-BOOT from current system\n");
     1536        printf(" <Q> - Quit without any change\n");
     1537    }
     1538
     1539    if (Option_Silent || Option_CID) {
     1540        // Silent operation? Always add AiR-BOOT then
     1541        UserKey = 'a';
     1542    }
     1543    else {
     1544        do {
     1545            UserKey = getch() | 0x20;
     1546        } while (!((UserKey=='a') || (UserKey=='r') || (UserKey=='u') || (UserKey=='d') || (UserKey=='q')));
     1547    }
     1548
     1549    if (!Option_CID) {
     1550        printf("\n\n\n-------------------------------------------------------------------------------\n");
     1551    }
     1552
     1553    switch (UserKey) {
     1554        case 'a':
     1555        case 'r':
     1556        case 'u': {
     1557            if (Install_Code || Install_Config) {
     1558                if (!Option_CID) {
     1559                    printf("Add/Repair/Update AiR-BOOT in progress...\n");
     1560                }
     1561#ifdef PLATFORM_OS2
     1562                OS2_GetBootAutoDriveLetter();
     1563#endif
     1564                if (Install_Code) {
     1565                    if (!Option_CID) {
     1566                        printf(" þ Writing AiR-BOOT code...");
     1567                    }
     1568                    Install_WriteCode();
     1569                    if (!Option_CID) {
     1570                        printf("ok\n");
     1571                    }
     1572                }
     1573                if (Install_Config) {
     1574                    if (!Option_CID) {
     1575                        printf(" þ Writing AiR-BOOT configuration...");
     1576                    }
     1577                    Install_WriteConfig();
     1578                    if (!Option_CID) {
     1579                        printf("ok\n");
     1580                    }
     1581                }
     1582
     1583                if (!Track0Write()) {
     1584                    if (!Option_CID) {
     1585                        printf("SAVE ERROR!\n");
     1586                    }
     1587                    return 1;
     1588                }
     1589                if (!Option_CID) {
     1590                    printf("\n");
     1591                    printf("Your copy of AiR-BOOT is now fully functional.\n");
     1592                    if (!Option_Silent) {
     1593                        printf("Please hit ESC to exit AiR-BOOT installer or ENTER to reboot your system...\n");
     1594                    }
     1595                }
     1596                if (Option_Silent || Option_CID) {
     1597                    // Silent operation? Always reboot system (shall we do this really?)
     1598                    // No, otherwise installing from MiniLVM will reboot the system
     1599                    // which is not what the user would expect.
     1600                    //UserKey = 0x0D;
     1601                    UserKey = 0x1B;
     1602                }
     1603                else {
     1604                    do {
     1605                        UserKey = getch();             // React on ENTER or ESC
     1606                    } while (!((UserKey==0x0D) || (UserKey==0x1B)));
     1607                }
     1608                if (UserKey==0x0D) {              // ENTER reboots system... (if not in eCS install mode)
     1609
     1610                    /*
     1611                    // Rousseau: ## Disable Reboot when installing eComStation ##
     1612                    // In the install-environment, the MEMDRIVE env-var is defined.
     1613                    // So, only reboot if this env-var is not defined.
     1614                    */
     1615                    if (!getenv("MEMDRIVE")) {
     1616                        if (!Option_CID) {
     1617                            printf("Now rebooting system...\n");
     1618                        }
     1619                        RebootSystem();
     1620                    }
     1621                    ExitOnly = TRUE;
     1622                }
     1623            }
     1624            else {
     1625                if (!Option_CID) {
     1626                    printf(" þ All components of AiR-BOOT are intact and up-to-date. Nothing to do.\n");
     1627                }
     1628                ExitOnly = TRUE;
     1629            }
     1630            break;
     1631        }
     1632        case 'd': {
    9591633            if (!Option_CID) {
    960                printf(" þ Writing AiR-BOOT code...");
    961             }
    962             Install_WriteCode();
     1634                printf(" þ Removing AiR-BOOT automatically is not possible at this time.\n");
     1635            }
     1636#ifdef PLATFORM_OS2
    9631637            if (!Option_CID) {
    964                printf("ok\n");
    965             }
    966           }
    967          if (Install_Config) {
     1638                printf("    You may remove AiR-BOOT manually by entering \"FDISK /MBR\" or \"LVM /NEWMBR:1\"\n");
     1639                printf("    in commandline.\n");
     1640            }
     1641#endif
     1642#ifdef PLATFORM_WINNT
    9681643            if (!Option_CID) {
    969                printf(" þ Writing AiR-BOOT configuration...");
    970             }
    971             Install_WriteConfig();
    972             if (!Option_CID) {
    973                printf("ok\n");
    974             }
    975           }
    976 
    977          if (!Track0Write()) {
    978             if (!Option_CID) {
    979                printf("SAVE ERROR!\n");
    980             }
    981             return 1;
    982           }
    983          if (!Option_CID) {
    984             printf("\n");
    985             printf("Your copy of AiR-BOOT is now fully functional.\n");
    986             if (!Option_Silent) {
    987                 printf("Please hit ESC to exit AiR-BOOT installer or ENTER to reboot your system...\n");
    988             }
    989          }
    990          if (Option_Silent || Option_CID) {
    991             // Silent operation? Always reboot system (shall we do this really?)
    992             // No, otherwise installing from MiniLVM will reboot the system
    993             // which is not what the user would expect.
    994             //UserKey = 0x0D;
    995             UserKey = 0x1B;
    996           } else {
    997             do {
    998                UserKey = getch();             // React on ENTER or ESC
    999              } while (!((UserKey==0x0D) || (UserKey==0x1B)));
    1000           }
    1001          if (UserKey==0x0D) {              // ENTER reboots system... (if not in eCS install mode)
    1002 
    1003             /*
    1004             // Rousseau: ## Disable Reboot when installing eComStation ##
    1005             // In the install-environment, the MEMDRIVE env-var is defined.
    1006             // So, only reboot if this env-var is not defined.
    1007             */
    1008             if (!getenv("MEMDRIVE")) {
    1009                if (!Option_CID) {
    1010                   printf("Now rebooting system...\n");
    1011                }
    1012                RebootSystem();
    1013             }
     1644                printf("    You may remove AiR-BOOT manually by entering \"FDISK /MBR\" in commandline.\n");
     1645            }
     1646#endif
    10141647            ExitOnly = TRUE;
    1015           }
    1016        } else {
    1017          if (!Option_CID) {
    1018             printf(" þ All components of AiR-BOOT are intact and up-to-date. Nothing to do.\n");
    1019          }
    1020          ExitOnly = TRUE;
    1021         }
    1022        break;
    1023      }
    1024     case 'd': {
    1025       if (!Option_CID) {
    1026          printf(" þ Removing AiR-BOOT automatically is not possible at this time.\n");
    1027       }
    1028       #ifdef PLATFORM_OS2
    1029          if (!Option_CID) {
    1030             printf("    You may remove AiR-BOOT manually by entering \"FDISK /MBR\" or \"LVM /NEWMBR:1\"\n");
    1031             printf("    in commandline.\n");
    1032          }
    1033       #endif
    1034       #ifdef PLATFORM_WINNT
    1035          if (!Option_CID) {
    1036             printf("    You may remove AiR-BOOT manually by entering \"FDISK /MBR\" in commandline.\n");
    1037          }
    1038       #endif
    1039       ExitOnly = TRUE;
    1040       break;
    1041      }
    1042     default:
    1043      break;
     1648            break;
     1649        }
     1650        default:
     1651        break;
    10441652    }
    10451653
     
    10511659        }
    10521660    }
     1661
     1662    // Free the buffer memory.
     1663    if (Track0)     free(Track0);
     1664    if (Bootcode)   free(Bootcode);
     1665
    10531666   return 0;
    1054  }
     1667}
  • trunk/INSTALL/C/Makefile

    r45 r46  
    11###############################################################################
    2 # Makefile :: Builds FIXCODE program for several platforms.           [wmake] #
    3 ###############################################################################
    4 
    5 #
    6 # This Makefile builds the FIXCODE program for DOS, Windows, OS/2 and Linux.
    7 # FIXCODE is used to embed the anti-virus code into the AiR-BOOT image.
    8 # This anti-virus code protects the MBR and is installed as a TSR by the
    9 # loader. That's why it cannot be included at the source level.
     2# Makefile :: Builds the Installer for several platforms.             [wmake] #
     3###############################################################################
     4# rousseau@ecomstation.com
     5#
     6# Derived from the FIXCODE Makefile.
     7#
     8
     9#
     10# This Makefile builds the Installer for DOS, Windows, OS/2 and Linux.
     11# Like FIXCODE, each platform version has a letter appended it:
     12# 'D' for DOS, 'W' for Windows, '2' for OS/2 and 'L' for Linux.
    1013#
    1114
     
    2427# to influence source assembly / compilation.
    2528#
    26 DEBUG_LEVEL=0
     29RELEASE_CODE=0
    2730MAX_DEBUG_LEVEL=2
     31#DEBUG_LEVEL=1
     32#DEBUG_LEVEL=$(MAX_DEBUG_LEVEL)
     33DEBUG_LEVEL=$(RELEASE_CODE)
    2834
    2935#
     
    4147
    4248#
    43 # Base Name of Program to build.
     49# Base Name of Source Program to compile.
     50#
     51BASENAME=INSTALL
     52
     53#
     54# Base Name of Executable Module to build.
    4455# A letter is appended for each platform version:
    4556# D=DOS, W=Windows, 2=OS2, L=Linux.
    46 # The DOS COM-version has no suffix.
    47 #
    48 BASENAME=FIXCODE
     57#
     58MODULE=AIRBOOT
    4959
    5060#
    5161# This is a list of the Targets to be built.
    5262#
    53 TARGETS=$(BASENAME).COM $(BASENAME)D.EXE $(BASENAME)W.EXE $(BASENAME)2.EXE $(BASENAME)L.ELF
    54 #TARGETS=$(BASENAME)D.EXE
    55 #TARGETS=$(BASENAME).COM
     63TARGETS=$(MODULE)D.EXE $(MODULE)W.EXE $(MODULE)2.EXE $(MODULE)L.ELF
     64
    5665
    5766#
     
    92101ASM_FLAGS_D0=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ASSEMBLER=ALP -Mb +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
    93102ASM_FLAGS_D1=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ASSEMBLER=ALP -Mb +Od:MS16 +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
    94 ASM_FLAGS_D2=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ASSEMBLER=ALP
     103ASM_FLAGS_D2=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ASSEMBLER=ALP -Mb +Od:MS16 +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
    95104!else
    96105!error Unknown Assembler specified !
     
    101110# 16-bits C Compiler
    102111#
     112MM16=-mc
     113CPU=-2
    103114CC16=wcc
    104 CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -fo=$^.
    105 CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^.
    106 CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^.
     115CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(CPU) $(MM16) -w4 -e25 -zq -osexan -fo=$^. -fr=$^&.ERR
     116CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(CPU) $(MM16) -d2 -w4 -e25 -zq -on -fo=$^. -fr=$^&.ERR
     117CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(CPU) $(MM16) -d3 -w4 -e25 -zq -od -fo=$^. -fr=$^&.ERR
    107118CC16_FLAGS=$(CC16_FLAGS_D$(DEBUG_LEVEL))
    108119
     
    110121# 32-bits C Compiler
    111122#
     123MM32=-mf
    112124CC32=wcc386
    113 CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -6r -mf -fo=$^.
    114 CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
    115 CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
    116 CC32_FLAGS_R=-w4 -e25 -zq -od -6r -mf -fo=$^.
     125CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -w4 -e25 -zq -osexan -6r -fo=$^. -fr=$^&.ERR
     126CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d2 -w4 -e25 -zq -on -6r -fo=$^. -fr=$^&.ERR
     127CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d3 -w4 -e25 -zq -od -6r -fo=$^. -fr=$^&.ERR
    117128CC32_FLAGS=$(CC32_FLAGS_D$(DEBUG_LEVEL))
    118129
     
    121132#
    122133LNK=wlink
     134#
     135# DESCRIPTION does not work under WLink/Linux
     136# @ Cannot be escaped like with \x40 and it is still processed in quotes.
     137# WLink/2 can use the '\x40' variant.
     138#
     139#~ LNK_FLAGS_D0=op q op v op map=$^&.MAP op de '\x40\x23KIEWITZ:1.18\x23\x40\x41iR-BOOT Installer by Kiewitz'
    123140LNK_FLAGS_D0=op q op v op map=$^&.MAP
     141#~ LNK_FLAGS_D1=op q op v d all &
     142        #~ order clname CODE clname FAR_CONST clname FAR_DATA clnam BEGDATA clname DATA clname BSS clname STACK clname BLAP NOE &
     143        #~ op map=$^&.MAP
    124144LNK_FLAGS_D1=op q op v d all op map=$^&.MAP
    125145LNK_FLAGS_D2=op q op v d all op map=$^&.MAP
     
    172192        @echo.
    173193        @echo =====================================================================
    174         @echo = PROGRAM: FIXCODE Multi Platform      [DOS, Win32, OS/2 and Linux] =
     194        @echo = PROGRAM: INSTALL Multi Platform      [DOS, Win32, OS/2 and Linux] =
    175195        @echo =====================================================================
    176196#       @echo.
     
    233253
    234254###############################################################################
    235 # DOS 16-bits (COM)
    236 ###############################################################################
    237 $(BASENAME).COM:        $(BASENAME).OBJ
    238         $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
     255# DOS 16-bits (MZ)
     256###############################################################################
     257$(MODULE)D.EXE: $(MODULE)D.OBJ
     258        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos
     259        @wdump $^. > $^&.WDU
    239260        @if exist $^. @echo             $^. $(MSG_SUCCESS)
    240261        @echo.
    241 
    242 $(BASENAME).OBJ:        $(BASENAME).ASM
    243 #       @echo.
    244         @echo TARGET: $^&.COM   [DOS 16-bits COM-file]
    245         $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
    246         @wdis $^. > $^&.WDA
    247 
    248 
    249 ###############################################################################
    250 # DOS 16-bits (MZ)
    251 ###############################################################################
    252 $(BASENAME)D.EXE:       $(BASENAME)D.OBJ
    253         $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos
     262        #~ wstrip $^.
     263
     264$(MODULE)D.OBJ: $(BASENAME).C $(BASENAME).H
     265#       @echo.
     266        @echo TARGET: $^&.EXE   [DOS 16-bits Executable]
     267        $(CC16) $(CC16_FLAGS) -I$(%WATCOM)$(DS)h$(DS)os2 -bt=dos $(BASENAME).C
     268        @wdis -fi $^. > $^&.WDA
     269
     270
     271###############################################################################
     272# NT 32-bits (PE)
     273###############################################################################
     274$(MODULE)W.EXE: $(MODULE)W.OBJ
     275        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys nt
     276        @wdump $^. > $^&.WDU
    254277        @if exist $^. @echo             $^. $(MSG_SUCCESS)
    255278        @echo.
    256279
    257 $(BASENAME)D.OBJ:       $(BASENAME).C $(BASENAME).H
    258 #       @echo.
    259         @echo TARGET: $^&.EXE   [DOS 16-bits Executable]
    260         $(CC16) $(CC16_FLAGS) -bt=dos $(BASENAME).C
    261         @wdis $^. > $^&.WDA
    262 
    263 
    264 ###############################################################################
    265 # NT 32-bits (PE)
    266 ###############################################################################
    267 $(BASENAME)W.EXE:       $(BASENAME)W.OBJ
    268         $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys nt
    269         @if exist $^. @echo             $^. $(MSG_SUCCESS)
    270         @echo.
    271 
    272 $(BASENAME)W.OBJ:       $(BASENAME).C $(BASENAME).H
     280$(MODULE)W.OBJ: $(BASENAME).C $(BASENAME).H
    273281#       @echo.
    274282        @echo TARGET: $^&.EXE   [NT 32-bits Executable]
    275283        $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)nt -bt=nt $(BASENAME).C
    276         @wdis $^. > $^&.WDA
     284        @wdis -fi $^. > $^&.WDA
    277285
    278286
     
    280288# OS/2 32-bits (LX)
    281289###############################################################################
    282 $(BASENAME)2.EXE:       $(BASENAME)2.OBJ
     290$(MODULE)2.EXE: $(MODULE)2.OBJ
    283291        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys os2v2
     292        @wdump $^. > $^&.WDU
    284293        @if exist $^. @echo             $^. $(MSG_SUCCESS)
    285294        @echo.
    286 
    287 $(BASENAME)2.OBJ:       $(BASENAME).C $(BASENAME).H
     295        #~ wstrip $^.
     296
     297$(MODULE)2.OBJ: $(BASENAME).C $(BASENAME).H
    288298#       @echo.
    289299        @echo TARGET: $^&.EXE   [OS/2 32-bits Executable]
    290300        $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)os2 -bt=os2 $(BASENAME).C
    291         @wdis $^. > $^&.WDA
     301        @wdis -fi $^. > $^&.WDA
    292302
    293303
     
    295305# Linux 32-bits (ELF)
    296306###############################################################################
    297 $(BASENAME)L.ELF:       $(BASENAME)L.OBJ
     307$(MODULE)L.ELF: $(MODULE)L.OBJ
    298308        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^&.ELF sys linux
     309        @wdump $^. > $^&.WDU
    299310#       $(MV) $^&.ELF $^.
    300311        @if exist $^. @echo             $^. $(MSG_SUCCESS)
    301312        @echo.
    302313
    303 $(BASENAME)L.OBJ:       $(BASENAME).C $(BASENAME).H
     314$(MODULE)L.OBJ: $(BASENAME).C $(BASENAME).H
    304315#       @echo.
    305316        @echo TARGET: $^&.ELF   [Linux 32-bits Executable]
    306         $(CC32) $(CC32_FLAGS) -bt=linux $(BASENAME).C
    307         @wdis $^. > $^&.WDA
     317        $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)os2 -bt=linux $(BASENAME).C
     318        @wdis -fi $^. > $^&.WDA
    308319
    309320
     
    330341        @if exist *.OBJ $(RM) *.OBJ
    331342        @if exist *.WDA $(RM) *.WDA
     343        @if exist *.WDU $(RM) *.WDU
     344        @if exist *.NDA $(RM) *.NDA
    332345        @if exist *.MAP $(RM) *.MAP
    333346        @if exist *.LST $(RM) *.LST
  • trunk/INSTALL/C/_build.cmd

    r32 r46  
    1 /* REXX */
    2 
    3 /* -r use release flags, -d use debug flags */
    4 debug='-r';
    5 
    6 /* OS2 version */
    7 'ide2make '||debug||' -p OS2.WPJ';
    8 'wmake -h -f OS2.MK';
    9 
    10 /* WIN32 version */
    11 'ide2make '||debug||' -p WIN32.WPJ';
    12 'wmake -h -f WIN32.MK';
    13 
     1wmake clean
     2wmake
  • trunk/INSTALL/C/_clean.cmd

    r30 r46  
    1 /* REXX */
    2 
    3 /* Cleanup OS2 files */
    4 '@if exist OS2.MK del OS2.MK';
    5 '@if exist INST-OS2.EXE del INST-OS2.EXE';
    6 '@if exist INST-OS2.OBJ del INST-OS2.OBJ';
    7 '@if exist INST-OS2.MK1 del INST-OS2.MK1';
    8 '@if exist INST-OS2.LK1 del INST-OS2.LK1';
    9 '@if exist INST-OS2.MAP del INST-OS2.MAP';
    10 '@if exist *.err del *.err';
    11 '@if exist ..\..\RELEASE\OS2\AIRBOOT2.EXE del ..\..\RELEASE\OS2\AIRBOOT2.EXE';
    12 
    13 /* Cleanup WIN32 files */
    14 '@if exist WIN32.MK del WIN32.MK';
    15 '@if exist INST-WIN.EXE del INST-WIN.EXE';
    16 '@if exist INST-WIN.OBJ del INST-WIN.OBJ';
    17 '@if exist INST-WIN.MK1 del INST-WIN.MK1';
    18 '@if exist INST-WIN.LK1 del INST-WIN.LK1';
    19 '@if exist INST-WIN.MAP del INST-WIN.MAP';
    20 '@if exist *.err del *.err';
    21 '@if exist ..\..\RELEASE\WINNT\AIRBOOTW.EXE del ..\..\RELEASE\WINNT\AIRBOOTW.EXE';
     1@wmake clean
  • trunk/INSTALL/DOS/Makefile

    r45 r46  
    1 ###############################################################
    2 # Makefile :: Builds the MBR Protection Image.                #
    3 ###############################################################
     1###############################################################################
     2# Makefile :: Builds the MBR_PROT.BIN 16-bits RAW Protection Image.           #
     3###############################################################################
    44# rousseau@ecomstation.com
    55#
     
    4545# Source Level base-name of Target to build.
    4646#
    47 BASENAME=MBR_PROT
     47BASENAME=AIRBOOT
    4848
    4949#
     
    5656# For MBR_PROT there is only one real target: MBR_PROT.BIN.
    5757#
    58 TARGET=$(MODULE).BIN
     58TARGET=$(MODULE).COM
    5959
    6060#
     
    8181# -Cp   = case sensitive symbols
    8282# -zcw  = no _ prefix on symbols (C model)
    83 ASM_FLAGS_D0=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -nt='CODE_SEG' -nd='DATA_SEG' -Fo$^. -Fw$^&.ERR
    84 ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    85 ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     83ASM_FLAGS_D0=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     84ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     85ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DJWASM -q -Cp -zcw -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    8686!elseif "$(ASM)"=="masm"
    8787ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dMASM -zq -fo=$^. -fr=$^&.ERR
     
    9494!elseif "$(ASM)"=="tasm"
    9595# -ml   = case sensitive symbols
    96 ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -l
    97 ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -z -zi -c -la
    98 ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -m9 -z -zi -c -la
     96ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -l
     97ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -z -zi -c -la
     98ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dTASM -t -ml -m9 -z -zi -c -la
    9999!elseif "$(ASM)"=="alp"
    100100ASM_FLAGS_D0=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ALP -Mb +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
     
    133133
    134134#
    135 # This builds all the languages using normal dependency rules.
     135# This builds the target using normal dependency rules.
    136136# If this Makefile was modified, all targets are forcefully rebuilt.
    137 # At the end all intermediate files are deleted.
    138 # Use wmake dev to to development; this generated one image and leaves
    139 # the intermediate files intact.
    140 #
    141 all:    .SYMBOLIC Makefile.bu $(TARGET) footer
    142 #       @echo ALL !!
    143 #       @#MAKE $(BLD_LANGUAGES)
    144 #       @for %%i in ($(BLD_LANGUAGES)) do @%MAKE AB-%%i
    145 #       @echo $<
    146 #       @%MAKE clean
    147 
    148 
    149 #
    150 # Some targets have the .MULTIPLE directive defined.
    151 # This is because the iteration "calls" for the creation of other (meta)
    152 # targets. If .MULTIPLE would not be defined these (meta) targets would not
    153 # be "built" anymore because the are considered up-to-date.
    154 # With multiple this assumption is removed and the target is "rebuilt" for
    155 # every target that depends on it.
    156 # This mostly concerns meta operations like clean etc.,
    157 # but of course also the main building of the AIRBOOT.BIN module.
    158 #
     137#
     138all:    .SYMBOLIC Makefile.bu header $(TARGET) footer
     139
    159140
    160141#
    161142# Show the header.
    162143#
    163 header: .SYMBOLIC .MULTIPLE
     144header: .SYMBOLIC
    164145        @echo.
    165146        @echo =====================================================================
    166         @echo = MODULE: $(TARGET)    [$(%BLD_LANG)]           [16-bits Raw Binary Loader] =
     147        @echo = MODULE: $(TARGET)               [16-bits Raw Protection Image] =
    167148        @echo =====================================================================
    168149#       @echo.
     
    197178#
    198179
    199 ###############################################################################
    200 # 16-bits RAW :: MBR virus protection to be embedded in the AIRBOOT.BIN image.
    201 ###############################################################################
    202 $(TARGET):      .MULTIPLE $(BASENAME).COM
    203 #       $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
    204         $(CP) $(BASENAME).COM $(TARGET)
    205 #       @echo $(%BLD_LANG)>$^.
    206         @if exist $^. @echo             $^. $(MSG_SUCCESS) - [$(%BLD_LANG) version]
    207 #       $(RM) $(TARGET)
    208 #       @echo.
    209 
    210 
    211180
    212181###############################################################################
    213182# 16-bits COM :: Intermediate image without embedded MBR-prot. and code count.
    214183###############################################################################
    215 $(BASENAME).COM:        .MULTIPLE $(BASENAME).OBJ
     184$(BASENAME).COM:        $(BASENAME).OBJ
    216185        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
    217186#       $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. form raw
     
    219188#       @echo.
    220189
    221 $(BASENAME).OBJ:        .MULTIPLE $(BASENAME).ASM
     190$(BASENAME).OBJ:        $(BASENAME).ASM
    222191#       @echo.
    223192        @echo TARGET: $^.       [DOS 16-bits Raw Image]
    224193        $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
    225         @wdis $^. > $^&.WDA
     194        @wdis -fi $^. > $^&.WDA
    226195
    227196
     
    242211# Remove all generated files.
    243212#
    244 clean:  .SYMBOLIC .MULTIPLE
     213clean:  .SYMBOLIC
    245214#       @echo CLEANING UP
    246215#       @for %%i in ($(TARGET)) do @if exist %%i $(RM) %%i
    247216        @if exist *.COM $(RM) *.COM
     217        @if exist *.BIN $(RM) *.BIN
    248218        @if exist *.OBJ $(RM) *.OBJ
    249219        @if exist *.WDA $(RM) *.WDA
     220        @if exist *.NDA $(RM) *.NDA
    250221        @if exist *.MAP $(RM) *.MAP
    251222        @if exist *.LST $(RM) *.LST
  • trunk/INSTALL/INST_X86/INSTALL.INC

    r38 r46  
    146146                call    APIShowMessage
    147147                call    Init_CheckBackupMBR
    148                 jc      VirusNoBackUp
     148                jc      VirusNoBackup
    149149                mov     si, offset TXT_MBRfail_Strike
    150150                call    APIShowMessage
     
    220220                mov     si, offset TXT_AfterAdd
    221221                call    APIShowMessage
    222                 call    MenuWaitForENTER
     222                call    MenuWaitForEnter
    223223                call    APIAfterAdd
    224224
     
    230230                mov     si, offset TXT_AfterDelete
    231231                call    APIShowMessage
    232                 call    MenuWaitForENTER
     232                call    MenuWaitForEnter
    233233                call    APIAfterDelete
    234234
    235235MenuProcessQUIT:mov     si, offset TXT_AfterQuit
    236236                call    APIShowMessage
    237                 call    MenuWaitForENTER
     237                call    MenuWaitForEnter
    238238                call    APIAfterQuit
    239239
  • trunk/Makefile

    r37 r46  
    11###############################################################################
    2 # Makefile :: Builds AiR-BOOT for all supported Languages.                    #
     2# Makefile :: Builds complete AiR-BOOT; all supported Languages and Platforms #
    33###############################################################################
    4 
     4# rousseau@ecomstation.com
    55#
    6 # The default language for the loader code is EN.
    7 # Supported languages are: EN,DE,FR,SW,IT,NL,RU.
    8 # The 1.06 version used 'DT' for the Dutch language,
    9 # this has been changed to 'NL'.
    10 # To build all languages, set the LANGUAGE macro below to ALL.
     6
     7# This is the Master Makefile and it builds the whole AiR-BOOT she-bang:
     8# - The AiR-BOOT Loader Code for all supported languages.
     9# - The MBR Protection Image that get's embedded in the loader.
     10# - The FIXCODE program that embeds the MBR Protection Image.
     11# - The Installers for all supported platforms.
     12# - The SET(A)BOOT program for all supported platforms. (currently only OS/2)
     13
     14
     15# Note:
     16# AiR-BOOT and it's helpers are relatively small to build.
     17# So, although Makefiles are being used to build the lot, there is no explicit
     18# separation between assembling/compiling from source or just only linking.
     19# In fact, because of multiple languages for the Loader and cross-platform
     20# support for the Helpers, any target will almost always be built from source
     21# everytime.
     22
     23# Also:
     24# While WMake does it's job, running it on Linux requires a bit of extra effort
     25# with regard to case sensitivity, directory separators, escape characters
     26# and other platform differences.
     27# This is handled in MAKEFILE.MIF.
     28
     29
     30
     31#                                                       DEFINITIONS AND STUFF
     32# _____________________________________________________________________________
     33
     34# This one is defined in the Environment so that all 'called' WMake invocations
     35# can adjust their behavior when they are invoked from this Master.
     36# When invoked from this Master, it is assumed the user/developer
     37# 'just-wants-to-have-all-the-stuff-built', so some messages are suppressed and
     38# some stuff is overridden.
     39# Building from this Master is how AiR-BOOT is built when released.
     40# It will force JWasm as the assembler and force DEBUG_LEVEL to 0.
     41# Also, targets are distributed to the RELEASE directory.
     42# Usage of lower level Makefiles directly is considered 'development'.
     43%MASTER=TRUE
     44
     45# Include a Master Makefile with several cross-platform definitions and macros.
     46# This is used to compensate for the differences between the target platforms.
     47!include        INCLUDE/MAKEFILE.MIF
     48
     49
     50# These are the Build Directories (Components) that produce
     51# one or more targets. WMake is invoked from this Master Makefile in each of
     52# this directories to produce the corresponding component.
     53# Note that the %MASTER Environment variable above is passed
     54# to influence build behavior of the individual Makefiles.
     55# The order of these Build Directories matters !
    1156#
    12 LANGUAGE=EN
    13 
     57# - MBR-PROT            ; MBR Protection Image later to be embedded.
     58# - INTERNAL            ; FIXBOOT program to embed the Protection Image.
     59# - BOOTCODE            ; AiR-BOOT Boot Manager itself.
     60# - INSTALL/C           ; Installer for multiple platforms.
     61# - INSTALL/DOS         ; Old DOS installer -- will be removed when converted to C.
     62# - SETABOOT            ; SETABOOT Manager for OS/2 -- other platforms not yet.
    1463#
    15 # Used tools:
    16 # Open Watcom v1.9
    17 # Tasm v4.1 DOS (136018 bytes)
    18 # Tlink v4.0 DOS (72585 bytes)
    19 # Caldera EXE2BIN.EXE R1.01 (9845 bytes)
    20 #
    21 
    22 
    23 #
    24 # Build the loader code, the installers and SETABOOT.
    25 #
    26 all: .SYMBOLIC
    27 # AiR-BOOT loader code
    28         cd BOOTCODE
    29         call _clean.cmd
    30         call _build.cmd $(LANGUAGE)
    31         @cd ..
    32 
    33 # OS2 and WIN32 installer
    34         cd INSTALL\C
    35         call _clean.cmd
    36         call _build.cmd
    37         cd ..\..
    38 
    39 # OS2 SETABOOT
    40         cd TOOLS\OS2\SETABOOT
    41         call _clean.cmd
    42         call _build.cmd
    43         cd ..\..\..
    44 
    45 #
    46 # Cleanup.
    47 #
    48 clean: .SYMBOLIC
    49         cd BOOTCODE
    50         call _clean.cmd
    51         cd MBR-PROT
    52         call _clean.cmd
    53         cd ..
    54         cd ..
    55 
    56         cd INSTALL\C
    57         call _clean.cmd
    58         cd ..\..
    59 
    60         cd TOOLS\OS2\SETABOOT
    61         call _clean.cmd
    62         cd ..\..\..
    63 
    64         cd TOOLS\INTERNAL
    65         call _clean.cmd
    66         cd ..\..
     64COMPONENTS=&
     65        BOOTCODE$(DS)MBR-PROT&
     66        TOOLS$(DS)INTERNAL&
     67        BOOTCODE&
     68        INSTALL$(DS)C&
     69        INSTALL$(DS)DOS&
     70        TOOLS$(DS)OS2$(DS)SETABOOT&
     71
     72
     73
     74
     75#                                                               MAIN ACTIONS
     76# _____________________________________________________________________________
     77
     78
     79# -----------------------------------------------------------------------------
     80# MAIN :-)
     81# -----------------------------------------------------------------------------
     82# Unless another target is specified, a 'build' is the default action.
     83# Using wmake build would be equivalent.
     84# -----------------------------------------------------------------------------
     85all:    .SYMBOLIC Makefile.bu
     86        @%MAKE build
     87
     88
     89
     90# -----------------------------------------------------------------------------
     91# BUILD EVERYTHING
     92# -----------------------------------------------------------------------------
     93# Here we iterate over all AiR-BOOT components that have a Makefile.
     94# To be able to influence the 'action' we pass that using the Environment.
     95# In this case we are 'building'.
     96# Note that we don't use %ACTION=, because that would be evaluated by WMake
     97# when parsing the Makefile. It needs to be a command related to the target.
     98# -----------------------------------------------------------------------------
     99build:  .SYMBOLIC
     100        @SET ACTION=BUILD
     101        @for %%i in ($(COMPONENTS)) do @$(MAKE) -h %%i
     102        @echo.
     103        @echo ** Success !! **
     104        @echo All AiR-BOOT stuff has been built.
     105        @echo Look in the RELEASE directory for the distribution files
     106        @echo for each platform.
     107        @echo The PACKAGES directory contains packages for each supported
     108        @echo platform.
     109        @echo.
     110
     111
     112# -----------------------------------------------------------------------------
     113# CLEANUP EVERYTHING
     114# -----------------------------------------------------------------------------
     115# Here we iterate over all AiR-BOOT components that have a Makefile.
     116# To be able to influence the 'action' we pass that using the Environment.
     117# In this case we are 'cleaning'.
     118# Note that we don't use %ACTION=, because that would be evaluated by WMake
     119# when parsing the Makefile. It needs to be a command related to the target.
     120# -----------------------------------------------------------------------------
     121clean:  .SYMBOLIC
     122        @SET ACTION=CLEAN
     123        @for %%i in ($(COMPONENTS)) do @$(MAKE) -h %%i
     124        @echo.
     125        @echo Done.
     126        @echo.
     127
     128
     129# -----------------------------------------------------------------------------
     130# SHOW HELP ON USING THIS MAKEFILE
     131# -----------------------------------------------------------------------------
     132help:   .SYMBOLIC
     133        @echo.
     134        @echo           The following actions are available:
     135        @echo           wmake           to build all targets and all languages
     136        @echo           wmake dev       to build a develoopment target
     137        @echo           wmake [LANG]    to build EN,DE,NL,FR,IT or RU versions
     138        @echo           wmake list      to show the list of buildable targets
     139        @echo           wmake clean     to remove almost all generated files
     140        @echo           wmake rmbin     to remove all residual BIN files
     141        @echo           wmake rebuild   to rebuild all targets
     142        @echo           wmake dist      to populate the dist directories
     143        @echo           wmake help      for this information
     144        @echo.
     145
     146
     147
     148
     149
     150
     151
     152# -----------------------------------------------------------------------------
     153# CHECK FOR MAKEFILE CHANGES
     154# -----------------------------------------------------------------------------
     155# Create a backup of the Makefile when it is modified.
     156# This also forces a rebuild of all targets.
     157# -----------------------------------------------------------------------------
     158Makefile.bu:    Makefile
     159        @echo.
     160        @echo Makefile modified, forcing rebuild of all targets !
     161        @echo.
     162        @%MAKE clean
     163        @$(CP) Makefile Makefile.bu > $(NULDEV)
     164
     165
     166
     167#                                                               GENERIC HANDLERS
     168# _____________________________________________________________________________
     169
     170
     171# -----------------------------------------------------------------------------
     172# ACTION HANDLER FOR BUILD DIRECTORIES
     173# -----------------------------------------------------------------------------
     174# This is the generic handler.
     175# The action to undertake is set in the Environment.
     176# It functions like a "switch".
     177# -----------------------------------------------------------------------------
     178$(COMPONENTS):  .SYMBOLIC
     179        @echo.
     180        @echo.
     181        @echo.
     182!if "$(%ACTION)"=="BUILD"
     183        @echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     184        @echo @@ BUILDING $@
     185        @echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     186        @echo.
     187        @cd $@
     188        @$(MAKE) -h
     189!elseif "$(%ACTION)"=="CLEAN"
     190        @echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     191        @echo @@ CLEANING $@
     192        @echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     193        @echo.
     194        @cd $@
     195        @$(MAKE) -h clean
     196!else
     197        @echo.
     198        @echo !! Undefined Action !!
     199        @echo.
     200!endif
     201
     202
  • trunk/TOOLS/DOS/SETABOOT/SETABOOT.ASM

    r37 r46  
    2020
    2121Include ../../../INCLUDE/ASM.INC
    22 include ../../../INCLUDE/DOS/AIRBOOT.INC
     22;include ../../../INCLUDE/DOS/AIRBOOT.INC
    2323
    2424                .386p
     
    6060                        db ' detected.', 13, 10, 0
    6161
    62    Include ../../../INCLUDE/DOS/CONST.ASM
     62;   Include ../../../INCLUDE/DOS/CONST.ASM
    6363
    6464AiRBOOTdetected         db 0
  • trunk/TOOLS/INTERNAL/FIXCODE

    r43 r46  
    44# $airboot@ecomstation.com$
    55#
    6 # This is a hack until the Linux version of FIXCODE.C is finished.
     6# This is a quick-hack until the Linux version of FIXCODE.C is finished.
    77# Note that it does not search for the AiR-BOOT Protection Signature,
    88# but embeds it at the 'well known' location.
    9 # It the protection image is moved, this script will corrupt AIR-BOOT.COM
    10 # of which the final AIRBOOT.BIN is derived.
     9# If the protection image is moved, this script will produce a corrupted
     10# AIRBOOT.BIN.
    1111# Also, a code-size of 35h (max size) is always inserted.
    12 # Furthermore, it does no sanity checks whatsoever.
     12# Furthermore, it does not do any sanity checks whatsoever.
    1313#
    1414
    15 PROT_IMG="MBR-PROT/MBR_PROT.COM"
     15#
     16# This script is now obsolete.
     17#
     18exit 1;
     19
     20
     21PROT_IMG="MBR-PROT/MBR-PROT.BIN"
    1622AB_INTERIM_IMG="AIR-BOOT.COM"
     23AB_IMG="AIRBOOT.BIN"
    1724CODE_SIZE_OFFSET=16
    1825PROT_IMG_OFFSET=26624
    1926
    2027
     28function    echox() {
     29    echo -e $@;
     30}
     31
     32
    2133function        Header() {
    22         echo "Header";
     34    echox "\t## FIXCODE script for Linux ##";
    2335}
    2436
    2537function        CheckIfFileExists() {
    26         echo "CheckIfFileExists";
     38        echox "\tCheckIfFileExists";
    2739        if [ ! -f "${1}" ]; then
    28                 echo "ERROR: File ${1} could not be found !";
    29                 echo "       Aborting...";
     40                echox "\tERROR: File ${1} could not be found !";
     41                echox "\t       Aborting...";
    3042                exit 1;
    3143        else
    32                 echo "File ${1} found, OK.";
     44                echox "\tFile ${1} found, OK.";
    3345        fi;
    3446}
    3547
     48function    CreateImage() {
     49    echox "\tCreateImage";
     50    cp -a "${1}" "${2}";
     51}
     52
    3653function        EmbedCodeSize() {
    37         echo "EmbedCodeSize";
    38         echo -n "5" | dd of="${1}" bs=1 seek=${CODE_SIZE_OFFSET} conv=notrunc;
     54        echox "\tEmbedCodeSize";
     55    echo "${1}"
     56        echo -n "5" | dd of="${1}" bs=1 seek=${CODE_SIZE_OFFSET} conv=notrunc 2> /dev/null;
    3957}
    4058
    4159function        EmbedProtectionImage() {
    42         echo "EmbedProtectionImage";
    43         dd if="${1}" of="${2}" bs=1 seek=${PROT_IMG_OFFSET} conv=notrunc;
     60        echox "\tEmbedProtectionImage";
     61        dd if="${1}" of="${2}" bs=1 seek=${PROT_IMG_OFFSET} conv=notrunc 2> /dev/null;
    4462}
    4563
    4664function        VerifyImage() {
    47         echo "VerfyImage";
     65        echox "\tVerfyImage";
    4866}
    4967
    5068function        Footer() {
    51         echo "Footer";
     69        echox "\t## AiR-BOOT code fixed ##";
     70    echo "";
    5271}
    5372
     
    5877#
    5978function        Main() {
    60         echo "## Main ##";
     79    echo "";
    6180        Header;
    62         CheckIfFileExists "${PROT_IMG}"
    63         CheckIfFileExists "${AB_INTERIM_IMG}"
    64         EmbedCodeSize "${AB_INTERIM_IMG}";
    65         EmbedProtectionImage "${PROT_IMG}" "${AB_INTERIM_IMG}";
     81        CheckIfFileExists "${PROT_IMG}";
     82        CheckIfFileExists "${AB_INTERIM_IMG}";
     83    CreateImage "${AB_INTERIM_IMG}" "${AB_IMG}";
     84        EmbedProtectionImage "${PROT_IMG}" "${AB_IMG}";
     85    EmbedCodeSize "${AB_IMG}";
    6686        Footer;
    6787}
  • trunk/TOOLS/INTERNAL/FIXCODE.ASM

    r43 r46  
    4141COM_CodeName    db 'AIR-BOOT.COM', 0
    4242COM_LoadMBR     db ' - Loading MBR-protection from file...$'
    43 COM_MBRName     db 'MBR-PROT\MBR_PROT.COM', 0
     43COM_MBRName     db 'MBR-PROT\MBR-PROT.BIN', 0
    4444COM_MergeMBR    db ' - Merging MBR-protection into bootcode...$'
    4545COM_CountCode   db ' - Count code in bootcode-image...$'
     
    5151COM_FailedReadCode    db 'Read air-boot.com failed', 13, 10, '$'
    5252COM_FailedInvalidCode db 'Invalid air-boot.com', 13, 10, '$'
    53 COM_FailedOpenMBR     db 'mbr-prot\mbr_prot.com not found', 13, 10, '$'
    54 COM_FailedReadMBR     db 'Read mbr-prot\mbr_prot.com failed', 13, 10, '$'
    55 COM_FailedInvalidMBR  db 'Invalid mbr-prot\mbr_prot.com', 13, 10, '$'
     53COM_FailedOpenMBR     db 'mbr-prot\mbr-prot.bin not found', 13, 10, '$'
     54COM_FailedReadMBR     db 'Read mbr-prot\mbr-prot.bin failed', 13, 10, '$'
     55COM_FailedInvalidMBR  db 'Invalid mbr-prot\mbr-prot.bin', 13, 10, '$'
    5656COM_FailedWriteCode   db 'Write air-boot.com failed', 13, 10, '$'
    5757
     
    6565ShowMessage     EndP
    6666
    67 ShowError       Proc Near
    68    mov     ah, 09h
    69    int     21h              ; DOS: WRITE STRING DS:DX TO CONSOLE
    70    jmp     EndProgram
    71    ret
    72 ShowError       EndP
     67ShowError   Proc Near
     68        mov     ah, 09h
     69        int     21h             ; DOS: WRITE STRING DS:DX TO CONSOLE
     70        mov     al,1            ; Error code
     71        jmp     EndProgram
     72        ret
     73ShowError   EndP
    7374
    7475COM_Init:
     
    128129                call    ShowMessage
    129130
    130                 ; Open MBR_PROT.COM
     131                ; Open MBR_PROT.BIN
    131132                mov     dx, offset COM_LoadMBR
    132133                call    ShowMessage
     
    141142DoneOpenMBR:    mov     bx, ax           ; BX = Filehandle
    142143
    143                 ; Load MBR_PROT.COM
     144                ; Load MBR-PROT.BIN
    144145                mov     ah, 3Fh
    145146                mov     cx, 1024         ; Image size
     
    204205                mov     dx, offset COM_Failed
    205206                call    ShowMessage
     207                mov     al,2            ; Error code
    206208                jmp     EndProgram
    207209
     
    220222
    221223                mov     si, offset BootCode
    222                 add     si, 512*53
    223                 mov     cx, 256
    224                 mov     dx, 53
     224                add     si, 512*53  ; 6A00
     225                mov     cx, 256     ; 512 bytes
     226                mov     dx, 53      ; initial count
    225227COM_CodeEndLoop:push    cx
    226228                push    si
     
    277279                mov     dx, offset COM_Okay
    278280                call    ShowMessage
     281                xor     al,al           ; No Error
    279282                jmp     EndProgram
    280283
     
    282285EndProgram:
    283286   ; DOS: TERMINATE PROGRAM
    284    mov     ax, 4C00h
     287   mov     ah, 04Ch
    285288   int     21h
    286289
  • trunk/TOOLS/INTERNAL/FIXCODE.C

    r37 r46  
     1// AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
     2//
     3// This file is part of AiR-BOOT
     4//
     5// AiR-BOOT is free software: you can redistribute it and/or modify it under
     6//  the terms of the GNU General Public License as published by the Free
     7//  Software Foundation, either version 3 of the License, or (at your option)
     8//  any later version.
     9//
     10// AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
     11//  WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
     12//  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
     13//  details.
     14//
     15// You should have received a copy of the GNU General Public License along with
     16//  AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
     17//
     18
     19/*
     20// FIXCODE.C -- Fix the AiR-BOOT image; include the code-size and MBR prot-img.
     21//  This reads AIR-BOOT.COM, merges MBR-PROT.BIN and writes AIRBOOT.BIN.
     22//  It is a quick-and-dirty translation of the original DOS-only ASM file.
     23//  Of course it's not as small but it's much easier to maintain across
     24//  multiple platforms.
     25*/
     26
     27
    128#include    "FIXCODE.H"
    229
     
    1946
    2047
    21 #define     IN_FILE     "AIR-BOOT.COM"  // Target from assembly.
    22 #define     MERGE_FILE  "MBR_PROT.BIN"  // MBR protection TSR.
    23 #define     OUT_FILE    "AIRBOOT.BIN"   // Generated loader image.
    24 
    25 
    26 
     48/* File names */
     49#define     IN_FILE     "AIR-BOOT.COM"              // Target from assembly.
     50#ifdef      PLATFORM_LINUX
     51#define     MERGE_FILE  "MBR-PROT/MBR-PROT.BIN"     // MBR protection TSR.
     52#else
     53#define     MERGE_FILE  "MBR-PROT\\MBR-PROT.BIN"    // MBR protection TSR.
     54#endif
     55#define     OUT_FILE    "AIRBOOT.BIN"               // Generated loader image.
     56
     57
     58/* Copyright message */
     59char    Copyright[] = "AiR-BOOT Bootcode Image Fix\n"
     60                        " - (c) Copyright 2009-2012 by M. Kiewitz\n";
     61/* Progress messages */
     62char    LoadCode[]  = " - Loading bootcode from file...";
     63char    LoadMBR[]   = " - Loading MBR-protection from file...";
     64char    MergeMBR[]  = " - Merging MBR-protection into bootcode...";
     65char    CountCode[] = " - Count code in bootcode-image...";
     66char    WriteCode[] = " - Saving bootcode to file...";
     67char    Okay[]      = "ok\n";
     68char    Failed[]    = "failed\n";
     69
     70/* Error messages */
     71char    FailedOpenCode[]    = IN_FILE" not found\n";
     72char    FailedReadCode[]    = "Read "IN_FILE" failed\n";
     73char    FailedInvalidCode[] = "Invalid "IN_FILE"\n";
     74char    FailedOpenMBR[]     = MERGE_FILE" not found\n";
     75char    FailedReadMBR[]     = "Read "MERGE_FILE" failed\n";
     76char    FailedInvalidMBR[]  = "Invalid "MERGE_FILE"\n";
     77char    FailedWriteCode[]   = "Write "OUT_FILE" failed\n";
     78
     79/* The signature we search for in the AIR-BOOT.COM image */
     80char    MBRProtectionSignature[]    = "AiR-BOOT MBR-Protection Image";
     81
     82/* File buffers */
     83char    BootCode[IMAGE_SIZE];   // Buffer for boot-image
     84char    MBRProtection[1024];    // Buffer for protection-image
     85
     86
     87
     88
     89/*
     90// Main Entrypoint.
     91*/
    2792int     main(int argc, char* argv[]) {
    28     FILE*   ifile   = NULL;
    29     FILE*   mfile   = NULL;
    30     FILE*   ofile   = NULL;
    31 
     93    FILE*       ifile   = NULL;
     94    FILE*       mfile   = NULL;
     95    FILE*       ofile   = NULL;
     96    size_t      ibytes  = 0;
     97    size_t      mbytes  = 0;
     98    size_t      obytes  = 0;
     99    unsigned    i       = 0;
     100    unsigned    found   = 0;
     101
     102
     103#if DEBUG_LEVEL > 0
     104    printf("\n%s\n", welcome);
     105    printf("Debug level is: %d\n\n", DEBUG_LEVEL);
     106#endif
     107
     108    /*
     109    // Show copyright message.
     110    */
     111    printf("%s",Copyright);
     112
     113    /*
     114    // Load AIR-BOOT.COM
     115    */
     116    printf("%s",LoadCode);
    32117    ifile = fopen(IN_FILE, "rb");
     118    if (!ifile) {
     119        printf("%s",FailedOpenCode);
     120        exit(1);
     121    }
     122    ibytes = fread(BootCode, 1, IMAGE_SIZE, ifile);
     123    if (ferror(ifile)) {
     124        printf("%s",FailedReadCode);
     125        exit(1);
     126    }
     127    //printf("ibytes: %d\n", ibytes);
     128    fread(BootCode, 1, 1, ifile);
     129    if (ibytes != IMAGE_SIZE || !feof(ifile)) {
     130        printf("%s", FailedInvalidCode);
     131        exit(1);
     132    }
     133    printf("%s", Okay);
     134
     135
     136    /*
     137    // Load MBR-PROT.BIN
     138    */
     139    printf("%s",LoadMBR);
    33140    mfile = fopen(MERGE_FILE, "rb");
     141    if (!mfile) {
     142        printf("%s",FailedOpenMBR);
     143        exit(1);
     144    }
     145    mbytes = fread(MBRProtection, 1, MBRPROT_SIZE, mfile);
     146    if (ferror(mfile)) {
     147        printf("%s",FailedReadMBR);
     148        exit(1);
     149    }
     150    fread(MBRProtection, 1, 1, mfile);
     151    if (mbytes != MBRPROT_SIZE || !feof(mfile)) {
     152        printf("%s", FailedInvalidMBR);
     153        exit(1);
     154    }
     155    printf("%s", Okay);
     156
     157
     158    /*
     159    // Find Protection Image Signature.
     160    // Note that this signature must reside on a sector boundary.
     161    */
     162    for (i=0; i<55; i++) {
     163        if (!memcmp(MBRProtectionSignature, &BootCode[i*SECSIZE], strlen(MBRProtectionSignature))) {
     164            found = 1;
     165            break;
     166        }
     167    }
     168
     169    /*
     170    // Merge Protection Image.
     171    */
     172    printf("%s",MergeMBR);
     173    if (!found) {
     174        printf("%s",Failed);
     175        exit(2);
     176    }
     177    memcpy(&BootCode[i*SECSIZE], MBRProtection, MBRPROT_SIZE);
     178    printf("%s", Okay);
     179
     180
     181    /*
     182    // Count Code Sectors.
     183    // Obsolete now since the Protection Image has moved just below the
     184    // Configuration and the code is always max. size.
     185    // Overlap checking is done while assembling AIR-BOOT.ASM.
     186    */
     187    printf("%s", CountCode);
     188    BootCode[16] = 53;
     189    printf("%s", Okay);
     190
     191    /*
     192    // Write AIRBOOT.BIN
     193    */
     194    printf("%s", WriteCode);
    34195    ofile = fopen(OUT_FILE, "wb");
    35 
    36 
    37     printf("\n%s\n", welcome);
    38 
    39 #if DEBUG_LEVEL > 0
    40     printf("Debug level is: %d", DEBUG_LEVEL);
    41 #endif
    42 
    43 
     196    if (!ofile) {
     197        printf("%s", FailedWriteCode);
     198        exit(3);
     199    }
     200    obytes = fwrite(BootCode, 1, IMAGE_SIZE, ofile);
     201    if (obytes != IMAGE_SIZE || ferror(ofile)) {
     202        printf("%s", FailedWriteCode);
     203        exit(3);
     204    }
     205    printf("%s", Okay);
     206
     207
     208    /*
     209    // Close files.
     210    */
     211    if (ifile)
     212        fclose(ifile);
     213    if (mfile)
     214        fclose(mfile);
     215    if (ofile)
     216        fclose(ofile);
    44217
    45218
  • trunk/TOOLS/INTERNAL/FIXCODE.H

    r37 r46  
    66    #define PLATFORM_DOS
    77#elif defined(__OS2__) && !defined(OS2)
    8     #define INCL_NOPMAPI
    9     #define INCL_BASE
    10     #define INCL_DOS
    11     #define INCL_DOSDEVIOCTL
    12     #include <os2.h>
    138    #define PLATFORM_OS2
    149#elif defined(__NT__)
    15     #include <windows.h>
    1610    #define PLATFORM_WINNT
    1711#elif defined(__LINUX__)
     
    2115#endif
    2216
     17
    2318#include    <stdlib.h>
    2419#include    <stdio.h>
     
    2621
    2722
    28 
    29 
    30 
    31 
    32 
    33 
    34 
    35 
     23#define     IMAGE_SIZE      31744
     24#define     MBRPROT_SIZE    1024
     25#define     SECSIZE         512
    3626
    3727#endif
    38 
    39 
    40 
    41 
    42 
    43 
  • trunk/TOOLS/INTERNAL/Makefile

    r37 r46  
    102102#
    103103CC16=wcc
    104 CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -fo=$^.
    105 CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^.
    106 CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^.
     104MM16=-ml
     105CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -w4 -e25 -zq -otexan -fo=$^. -fr=$^&.ERR
     106CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -d2 -w4 -e25 -zq -od -fo=$^. -fr=$^&.ERR
     107CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -d2 -w4 -e25 -zq -od -fo=$^. -fr=$^&.ERR
    107108CC16_FLAGS=$(CC16_FLAGS_D$(DEBUG_LEVEL))
    108109
     
    110111# 32-bits C Compiler
    111112#
     113MM32=-mf
    112114CC32=wcc386
    113 CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -6r -mf -fo=$^.
    114 CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
    115 CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
     115CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -w4 -e25 -zq -otexan -6r -fo=$^. -fr=$^&.ERR
     116CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d2 -w4 -e25 -zq -od -6r -fo=$^. -fr=$^&.ERR
     117CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d2 -w4 -e25 -zq -od -6r -fo=$^. -fr=$^&.ERR
    116118CC32_FLAGS_R=-w4 -e25 -zq -od -6r -mf -fo=$^.
    117119CC32_FLAGS=$(CC32_FLAGS_D$(DEBUG_LEVEL))
     
    210212#
    211213
    212 #
    213 # While the DOS build-environment has been kept alive in this version,
    214 # it has several drawbacks:
    215 # - No support for long filenames
    216 # - Very limited memory
    217 # - JWasmR does not work because of memory limitations
    218 # - JWasmD does not work at all
    219 # - Batch scripting is very rudimentairy
    220 #
    221 # Therefore, the DOS build-environment will most probably disappear
    222 # in future versions.
    223 # This does not influence the building of DOS targets, which can be done
    224 # on OS/2, Windows or Linux.
    225 #
    226 
    227 
    228214
    229215
     
    244230        @echo TARGET: $^&.COM   [DOS 16-bits COM-file]
    245231        $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
    246         @wdis $^. > $^&.WDA
     232        @wdis -fi $^. > $^&.WDA
    247233
    248234
     
    259245        @echo TARGET: $^&.EXE   [DOS 16-bits Executable]
    260246        $(CC16) $(CC16_FLAGS) -bt=dos $(BASENAME).C
    261         @wdis $^. > $^&.WDA
     247        @wdis -fi $^. > $^&.WDA
    262248
    263249
     
    274260        @echo TARGET: $^&.EXE   [NT 32-bits Executable]
    275261        $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)nt -bt=nt $(BASENAME).C
    276         @wdis $^. > $^&.WDA
     262        @wdis -fi $^. > $^&.WDA
    277263
    278264
     
    289275        @echo TARGET: $^&.EXE   [OS/2 32-bits Executable]
    290276        $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)os2 -bt=os2 $(BASENAME).C
    291         @wdis $^. > $^&.WDA
     277        @wdis -fi $^. > $^&.WDA
    292278
    293279
     
    305291        @echo TARGET: $^&.ELF   [Linux 32-bits Executable]
    306292        $(CC32) $(CC32_FLAGS) -bt=linux $(BASENAME).C
    307         @wdis $^. > $^&.WDA
     293        @wdis -fi $^. > $^&.WDA
    308294
    309295
     
    330316        @if exist *.OBJ $(RM) *.OBJ
    331317        @if exist *.WDA $(RM) *.WDA
     318        @if exist *.NDA $(RM) *.NDA
    332319        @if exist *.MAP $(RM) *.MAP
    333320        @if exist *.LST $(RM) *.LST
  • trunk/TOOLS/OS2/SETABOOT/.build

    r45 r46  
    11#!/bin/bash
    22
    3 make clean
    43make
  • trunk/TOOLS/OS2/SETABOOT/.clean

    r45 r46  
    22
    33make clean
    4 make
  • trunk/TOOLS/OS2/SETABOOT/Makefile

    r45 r46  
    11###############################################################################
    2 # Makefile :: Builds FIXCODE program for several platforms.           [wmake] #
     2# Makefile :: Builds the SET(A)BOOT Helper for several platforms.     [wmake] #
    33###############################################################################
    4 
    5 #
    6 # This Makefile builds the FIXCODE program for DOS, Windows, OS/2 and Linux.
    7 # FIXCODE is used to embed the anti-virus code into the AiR-BOOT image.
    8 # This anti-virus code protects the MBR and is installed as a TSR by the
    9 # loader. That's why it cannot be included at the source level.
     4# rousseau@ecomstation.com
     5#
     6# Derived from the INSTALL Makefile.
     7#
     8
     9#
     10# This Makefile builds the SET(A)BOOT Helper for DOS, Windows, OS/2 and Linux.
     11# Like FIXCODE, each platform version has a letter appended it:
     12# 'D' for DOS, 'W' for Windows, '2' for OS/2 and 'L' for Linux.
    1013#
    1114
     
    1417# This is used to compensate for the differences between the target platforms.
    1518#
    16 !include        ../../INCLUDE/MAKEFILE.MIF
     19!include        ../../../INCLUDE/MAKEFILE.MIF
    1720
    1821
     
    4144
    4245#
    43 # Base Name of Program to build.
     46# Base Name of Source Program to compile.
     47#
     48BASENAME=SETABOOT
     49
     50#
     51# Base Name of Executable Module to build.
    4452# A letter is appended for each platform version:
    4553# D=DOS, W=Windows, 2=OS2, L=Linux.
    46 # The DOS COM-version has no suffix.
    47 #
    48 BASENAME=FIXCODE
     54#
     55MODULE=$(BASENAME)
    4956
    5057#
    5158# This is a list of the Targets to be built.
    5259#
    53 TARGETS=$(BASENAME).COM $(BASENAME)D.EXE $(BASENAME)W.EXE $(BASENAME)2.EXE $(BASENAME)L.ELF
    54 #TARGETS=$(BASENAME)D.EXE
    55 #TARGETS=$(BASENAME).COM
     60#TARGETS=$(MODULE)D.EXE $(MODULE)W.EXE $(MODULE)2.EXE $(MODULE)L.ELF
     61TARGETS=$(MODULE).EXE
    5662
    5763#
     
    7884# -zcw  = no _ prefix on symbols (C model)
    7985ASM_FLAGS_D0=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DASSEMBLER=JWASM -q -Cp -Fo$^. -Fl=$^&.LST -Fw$^&.ERR
    80 ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DASSEMBLER=JWASM -q -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    81 ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DASSEMBLER=JWASM -q -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     86ASM_FLAGS_D1=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DASSEMBLER=JWASM -q -Cp -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
     87ASM_FLAGS_D2=-DDEBUG_LEVEL=$(DEBUG_LEVEL) -DASSEMBLER=JWASM -q -Cp -Zd -Zi -Fo$^. -Sa -Fl=$^&.LST -Fw$^&.ERR
    8288!elseif "$(ASM)"=="wasm"
    8389ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dASSEMBLER=TASM -zq -fo=$^. -fr=$^&.ERR
     
    8692!elseif "$(ASM)"=="tasm"
    8793# -ml   = case sensitive symbols
    88 ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dASSEMBLER=TASM -t -l
    89 ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dASSEMBLER=TASM -t -z -zi -c -la
    90 ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dASSEMBLER=TASM -t -z -zi -c -la
     94ASM_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dASSEMBLER=TASM -t -ml -l
     95ASM_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dASSEMBLER=TASM -t -ml -z -zi -c -la
     96ASM_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -dASSEMBLER=TASM -t -ml -z -zi -c -la
    9197!elseif "$(ASM)"=="alp"
    9298ASM_FLAGS_D0=-D:DEBUG_LEVEL=$(DEBUG_LEVEL) -D:ASSEMBLER=ALP -Mb +Feo:OBJ +Fl +Fel:LST +Fm +Fem:ERR
     
    101107# 16-bits C Compiler
    102108#
     109MM16=-ml
    103110CC16=wcc
    104 CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -fo=$^.
    105 CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^.
    106 CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^.
     111CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -w4 -e25 -zq -otexan -fo=$^. -fr=$^&.ERR
     112CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -d2 -w4 -e25 -zq -od -fo=$^. -fr=$^&.ERR
     113CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -d3 -w4 -e25 -zq -od -fo=$^. -fr=$^&.ERR
    107114CC16_FLAGS=$(CC16_FLAGS_D$(DEBUG_LEVEL))
    108115
     
    110117# 32-bits C Compiler
    111118#
     119MM32=-mf
    112120CC32=wcc386
    113 CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -6r -mf -fo=$^.
    114 CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
    115 CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.
    116 CC32_FLAGS_R=-w4 -e25 -zq -od -6r -mf -fo=$^.
     121CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -w4 -e25 -zq -otexan -6r -fo=$^. -fr=$^&.ERR
     122CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d2 -w4 -e25 -zq -od -6r -fo=$^. -fr=$^&.ERR
     123CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d3 -w4 -e25 -zq -od -6r -fo=$^. -fr=$^&.ERR
    117124CC32_FLAGS=$(CC32_FLAGS_D$(DEBUG_LEVEL))
    118125
     
    121128#
    122129LNK=wlink
     130#
     131# DESCRIPTION does not work under WLink/Linux
     132# @ Cannot be escaped like with \x40 and it is still processed in quotes.
     133# WLink/2 can use the '\x40' variant.
     134#
     135#~ LNK_FLAGS_D0=op q op v op map=$^&.MAP op de '\x40\x23KIEWITZ:1.18\x23\x40\x41iR-BOOT Installer by Kiewitz'
    123136LNK_FLAGS_D0=op q op v op map=$^&.MAP
     137#~ LNK_FLAGS_D1=op q op v d all &
     138        #~ order clname CODE clname FAR_CONST clname FAR_DATA clnam BEGDATA clname DATA clname BSS clname STACK clname BLAP NOE &
     139        #~ op map=$^&.MAP
    124140LNK_FLAGS_D1=op q op v d all op map=$^&.MAP
    125141LNK_FLAGS_D2=op q op v d all op map=$^&.MAP
     
    172188        @echo.
    173189        @echo =====================================================================
    174         @echo = PROGRAM: FIXCODE Multi Platform      [DOS, Win32, OS/2 and Linux] =
     190        @echo = PROGRAM: SETABOOT Multi Platform   [DOS, Win32, OS/2 and Linux] =
    175191        @echo =====================================================================
    176192#       @echo.
     
    229245
    230246#
    231 # MAIN TARGETS
    232 #
    233 
    234 ###############################################################################
    235 # DOS 16-bits (COM)
    236 ###############################################################################
    237 $(BASENAME).COM:        $(BASENAME).OBJ
    238         $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos com
    239         @if exist $^. @echo             $^. $(MSG_SUCCESS)
    240         @echo.
    241 
    242 $(BASENAME).OBJ:        $(BASENAME).ASM
    243 #       @echo.
    244         @echo TARGET: $^&.COM   [DOS 16-bits COM-file]
    245         $(ASM) $(ASM_FLAGS) $(BASENAME).ASM
    246         @wdis $^. > $^&.WDA
    247 
    248 
    249 ###############################################################################
    250 # DOS 16-bits (MZ)
    251 ###############################################################################
    252 $(BASENAME)D.EXE:       $(BASENAME)D.OBJ
    253         $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys dos
    254         @if exist $^. @echo             $^. $(MSG_SUCCESS)
    255         @echo.
    256 
    257 $(BASENAME)D.OBJ:       $(BASENAME).C $(BASENAME).H
    258 #       @echo.
    259         @echo TARGET: $^&.EXE   [DOS 16-bits Executable]
    260         $(CC16) $(CC16_FLAGS) -bt=dos $(BASENAME).C
    261         @wdis $^. > $^&.WDA
    262 
    263 
    264 ###############################################################################
    265 # NT 32-bits (PE)
    266 ###############################################################################
    267 $(BASENAME)W.EXE:       $(BASENAME)W.OBJ
    268         $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys nt
    269         @if exist $^. @echo             $^. $(MSG_SUCCESS)
    270         @echo.
    271 
    272 $(BASENAME)W.OBJ:       $(BASENAME).C $(BASENAME).H
    273 #       @echo.
    274         @echo TARGET: $^&.EXE   [NT 32-bits Executable]
    275         $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)nt -bt=nt $(BASENAME).C
    276         @wdis $^. > $^&.WDA
    277 
     247# MAIN TARGET
     248#
    278249
    279250###############################################################################
    280251# OS/2 32-bits (LX)
    281252###############################################################################
    282 $(BASENAME)2.EXE:       $(BASENAME)2.OBJ
     253$(MODULE).EXE:  $(MODULE).OBJ
    283254        $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^. sys os2v2
    284255        @if exist $^. @echo             $^. $(MSG_SUCCESS)
    285256        @echo.
    286 
    287 $(BASENAME)2.OBJ:       $(BASENAME).C $(BASENAME).H
     257        #~ wstrip $^.
     258
     259$(MODULE).OBJ:  $(BASENAME).C $(BASENAME).H
    288260#       @echo.
    289261        @echo TARGET: $^&.EXE   [OS/2 32-bits Executable]
    290262        $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)os2 -bt=os2 $(BASENAME).C
    291         @wdis $^. > $^&.WDA
    292 
    293 
    294 ###############################################################################
    295 # Linux 32-bits (ELF)
    296 ###############################################################################
    297 $(BASENAME)L.ELF:       $(BASENAME)L.OBJ
    298         $(LNK) $(LNK_FLAGS) file $^&.OBJ name $^&.ELF sys linux
    299 #       $(MV) $^&.ELF $^.
    300         @if exist $^. @echo             $^. $(MSG_SUCCESS)
    301         @echo.
    302 
    303 $(BASENAME)L.OBJ:       $(BASENAME).C $(BASENAME).H
    304 #       @echo.
    305         @echo TARGET: $^&.ELF   [Linux 32-bits Executable]
    306         $(CC32) $(CC32_FLAGS) -bt=linux $(BASENAME).C
    307         @wdis $^. > $^&.WDA
    308 
    309 
    310 
     263        @wdis -fi $^. > $^&.WDA
    311264
    312265
     
    330283        @if exist *.OBJ $(RM) *.OBJ
    331284        @if exist *.WDA $(RM) *.WDA
     285        @if exist *.NDA $(RM) *.NDA
    332286        @if exist *.MAP $(RM) *.MAP
    333287        @if exist *.LST $(RM) *.LST
  • trunk/TOOLS/OS2/SETABOOT/SETABOOT.C

    r35 r46  
    2424
    2525
     26#include    "SETABOOT.H"
     27
     28
    2629#define INCL_BASE
    2730#define INCL_WINSHELLDATA
     
    3740#include <string.h>
    3841
    39 #include "msghelp.c"
     42#include "MSGHELP.C"
    4043
    4144// Msg-IDs from OSO001.msg
  • trunk/TOOLS/OS2/SETABOOT/_build.cmd

    r32 r46  
    1 /* REXX */
    2 
    3 /* -r use release flags, -d use debug flags */
    4 debug='-d';
    5 
    6 'ide2make '||debug||' -p SETABOOT.WPJ';
    7 'wmake -h -f SETABOOT.MK';
     1@wmake
  • trunk/TOOLS/OS2/SETABOOT/_clean.cmd

    r30 r46  
    1 /* REXX */
    2 
    3 '@if exist SETABOOT.MK del SETABOOT.MK';
    4 '@if exist SETABOOT.EXE del SETABOOT.EXE';
    5 '@if exist SETABOOT.OBJ del SETABOOT.OBJ';
    6 '@if exist SETABOOT.MK1 del SETABOOT.MK1';
    7 '@if exist SETABOOT.LK1 del SETABOOT.LK1';
    8 '@if exist SETABOOT.MAP del SETABOOT.MAP';
    9 '@if exist *.err del *.err';
    10 '@if exist ..\..\..\RELEASE\OS2\SETABOOT.EXE del ..\..\..\RELEASE\OS2\SETABOOT.EXE';
     1@wmake clean
Note: See TracChangeset for help on using the changeset viewer.