Changeset 43 for trunk


Ignore:
Timestamp:
Apr 11, 2014, 11:48:01 PM (11 years ago)
Author:
Ben Rietbroek
Message:

BSS Corruption Problem located (auxdebug on) [2012-02-21]

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!!

Problem

o Function with Xrefs goes out-of-bounds because hideparttable is too small

Has only 30 entries and should be 45.
Lost partition checker initializes out-of-bounds.

Info

o About the hideparttable

For each partition it can be specified which other partitions need to
be hidden when that partition is booted. This is useful for legacy DOS
but also braindead Windows that presents HPFS/JFS partitions as
unformatted and tries to persuade the user to format them.
With v1.07 the numer of partitions that can be handled was expanded from
30 to 45, but the size of the hideparttable was overseen.

o The need to compress the hideparttable

The old size was 30x30=900 bytes while the required size is 45x45=2045 bytes.
This amount of space is not available in the image.
Since 6 bits are enough to identify the partition number to be hidden,
the solution is to devide the table into bitfields. This will result
in a table of (45*45*6)/8=1519 bytes, which can be fitted.

Changes

Revamped the sources quite a bit and moved the history to a separate
file. (AIR-BOOT.HIS)

New

o FIXCODE script for Linux

Just until the C version is ready...

Location:
trunk
Files:
3 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/BOOTCODE/AIR-BOOT.ASM

    r42 r43  
    11;
    2 ; BSS moet op A000 liggen
    3 ; Segmented werkt niet
    4 ; Moet met Tasm/DOS assembleren
    5 ; Wat we dus *niet* willen !!
    6 ;
    7 
    8 
    9 
    102; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
    113;
     
    2517;  AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
    2618;
    27 
    28 
    29 ;IFDEF   JWASM
    30 ;    db  'JWASM'
    31 ;ENDIF
    32 ;IFDEF   TASM
    33 ;    db  'TASM'
    34 ;ENDIF
    35 
    36 
    37 
    38 ;IF  DEBUG_LEVEL EQ  0
    39 ;    db  'L0'
    40 ;ELSE
    41 ;    db  'Lx'
    42 ;ENDIF
    43 
    44 
    45 ; ---------------------------------
    46 ; Rousseau: Fixes and Enhancements
    47 ; ---------------------------------
    48 ;
    49 ; v1.0.8-rc2-bld20120213
    50 ;-----------------------
    51 ; # Removed requirement for LVM P and V name to be the same to edit #
    52 ;   However, when both are the same before the edit, the V name will be
    53 ;   synved to the P name to have them both the same again after the edit.
    54 ;   If they differ, only the V name is updated.
    55 ;
    56 ; # Trying to edit the label of a type 0x35 partition now shows a popup #
    57 ;   The user is informed that type 0x35 labels cannot be edited.
    58 ;
    59 ; # Type 0x35 partitions cannot be added to the AB-menu anymore #
    60 ;   They are not bootable anyway. The user is informed by a popup.
    61 ;
    62 ; # De-tasemized the Assembler sources for JWasm compatibility #
    63 ;   AiR-BOOT can now be built using JWasm, which is now the preferred
    64 ;   assembler.
    65 ;
    66 ; # Completely reworked the build-system #
    67 ;   Everything is now done with Makefiles using WMake, Wlink and the
    68 ;   C/C++ Compilers from the Open Watcom development tools together with JWasm.
    69 ;   This obsoletes tasm, tlink and exe2bin.
    70 ;
    71 ; # Cross-Platform support #
    72 ;   AiR-BOOT and it's helpers can now be built on: DOS, Win32, OS/2 and Linux.
    73 ;
    74 ; # Rewrote FIXCODE.ASM in C so the tool-chain is not dependent on a DOS .COM
    75 ;   program for embedding the MBR-protection. DOS,Win32,OS/2 and Linux
    76 ;   versions of FIXCODE are now used. (EXE[MZ|PE|LX] and ELF)
    77 ;
    78 ; v1.0.8-rc1-bld20120124
    79 ; ----------------------
    80 ; # Changed version format to be more WarpIN compatible #
    81 ;   This is a cosmetic change only, the internal format has not changed.
    82 ;
    83 ; # Show LVM VolumeName instead of LVM PartitionName #
    84 ;   Previous versions of AiR-BOOT used the LVM PartitionName as the Label
    85 ;   if LVM-info was present for the partition.
    86 ;   This is inconsistent with MiniLVM which shows the LVM VolumeName.
    87 ;   Starting with v1.0.8 the LVM VolumeName is displayed.
    88 ;
    89 ; # LVM Partition and Volume name Synchronization #
    90 ;   Changing the Label of a partition with LVM-info now synchronizes
    91 ;   the LVM Partition Name with the LVM Volume Name.
    92 ;   This is the same behavior as MiniLVM.
    93 ;   Note however that the Label can only be changed when both the
    94 ;   LVM PartitionName and LVM VolumeName are the same.
    95 ;   See protected editing below.
    96 ;
    97 ; # Protected editing of the Label when LVM-info is present #
    98 ;   When the LVM VolumeName differs from the LVM PartitionName, the user can
    99 ;   edit the label but it will not be saved to the LVM record on disk.
    100 ;   This is to protect configurations created with the classic LVM tool.
    101 ;   Since MiniLVM assigns the same name to both the Partition and the Volume,
    102 ;   the Label can be edited and will be saved for such partitions.
    103 ;   To further protect a given configuration, LVM volumes with type 0x35
    104 ;   cannot be edited at all. This is to ensure that the LVM PartitionNames
    105 ;   remain unique when Spanning Volumes are used.
    106 ;
    107 ; # Editing the Label appended spaces #
    108 ;   When editing and changing the Label of a System using SETUP,
    109 ;   trailing spaces were stored in the LVM Volume and Partition names.
    110 ;   These labels need to be padded with zero's.
    111 ;   This has been fixed.
    112 ;   This bug is also present in v1.06.
    113 ;
    114 ; # Reworked Primary Partition <-> LVM-info association #
    115 ;   The previous way was to use a 1:1 correspondence between the PT-index
    116 ;   and the LVM-index. However, when the PT is cross-linked, lower entries
    117 ;   pointing to higher locations on the disk, or vice-versa, incorrect
    118 ;   LVM-info was associated. Such a cross-linked PT is sometimes generated
    119 ;   by the LVM engine when creating or deleting multiple partitions at once.
    120 ;   Best is to intermediately save after creating or deleting a partition
    121 ;   with (Mini)LVM.
    122 ;   The new way is to search the LVM-entries for the partition requested.
    123 ;
    124 ; # Reworked MBR-code to provide two I13X signatures #
    125 ;   The normal LVM MBR-code uses a special setup to indicate Int13X capability.
    126 ;   It contains the instruction, MOV EAX,'X31I', and some software checks
    127 ;   for the presence of the 'I13X' string in the MBR.
    128 ;   However, the location of this instruction differs between eCS 1.x and
    129 ;   eCS 2.x LVM MBR-code.
    130 ;   For compatibility, the v1.0.8 MBR has the 'I13X' string at both locations.
    131 ;
    132 ; # Fixed booting older eCS installations on HPFS #
    133 ;   When restoring systems from archive or otherwise generated systems,
    134 ;   the HPFS BPB sometimes lacked information that AiR-BOOT did not fill in.
    135 ;   The result was that a wrong partition was booted or that booting
    136 ;   stalled with the "unable to operate harddisk" message.
    137 ;   This has been fixed.
    138 ;
    139 ; # Fixed booting Windows from a logical partition with loader on FAT32 #
    140 ;   Depending on the configuration, sometimes the NTLDR could not be found.
    141 ;   This has been fixed.
    142 ;
    143 ; # Fixed drive-letter feature which was broken in v1.07 #
    144 ;   a)  v1.07 did remember the drive-letter feature was active for a partition,
    145 ;       but it failed to store the drive-letter because too few configuration
    146 ;       sectors were saved. This resulted in arbitrary values to be assigned
    147 ;       to the drive-letter for the partition.
    148 ;   b)  The JFS PBR-code does not use the in-memory BPB but uses the one
    149 ;       that is on disk. This prevented AiR-BOOT from passing the user assigned
    150 ;       drive-letter. AiR-BOOT now inserts the drive-letter in the BPB on disk,
    151 ;       but only if the partition is JFS.
    152 ;       AB v1.06 is also unable to use the drive-letter feature on JFS.
    153 ;   As a convenience, a drive-letter in the dl-feature pop-up can now be set
    154 ;   to "Disabled" by pressing backspace.
    155 ;   (As opposed to arrowing up/down to get to the "Disabled" entry)
    156 ;
    157 ; # Fixed stuck phase1 indicator when wrong name entered #
    158 ;   When using SET(A)BOOT /4:NAME with the MEMDRIVE env-var set,
    159 ;   and NAME being a non-existing partition, the phase1 indicator
    160 ;   would stay stuck between reboots.
    161 ;   This has been fixed.
    162 ;
    163 ; # Fixed DOS installer (AIRBOOT.COM) #
    164 ;   Behavior should now be the same as the eCS and WIN installers.
    165 ;   This re-enables the use of a bootable floppy or usb-stick
    166 ;   to install AiR-BOOT.
    167 ;
    168 ; # Fixed booting from FloppyDrive #
    169 ;   This is actually also broken in v1.06 when Int13X is forced on.
    170 ;   Now regular BIOS calls are used when booting from floppydrive.
    171 ;   A fresh AiR-BOOT installation now includes the floppydrive menu entry.
    172 ;
    173 ; # Fixed chainloading IBM Boot Manager #
    174 ;   AiR-BOOT v1.06 could chainload IBM-BM but only when it resided on
    175 ;   the first disk and was located below the 1024 cylinder and forced Int13X
    176 ;   extensions were disabled.
    177 ;   AiR-BOOT v1.0.8 can now chainload IBM-BM with forced Int13X extensions
    178 ;   enabled (the default) and if IBM-BM resides above the 1024 cylinder limit.
    179 ;   Also, chainloading IBM-BM from the second disk is supported.
    180 ;   Do not use chainloading IBM-BM unless you really have a need to.
    181 ;   See the AiR-BOOT Manual for "gotcha's" when using both AiR-BOOT and IBM-BM.
    182 ;
    183 ; # Corrected contact links #
    184 ;   Version 1.07 still presented the old contact links to the sourceforge
    185 ;   repository and the original author.
    186 ;   This caused confusion with regard to issues with v1.07.
    187 ;   This has been corrected.
    188 ;
    189 ; NOTE:
    190 ;   AB v1.07 had a bug with saving and loading the correct size of the
    191 ;   configuration. This broke the drive-letter feature.
    192 ;   As a result, the CRC over the config was also calculated wrongly.
    193 ;   While AB v1.0.8 fixes this, it has to use the v1.07 way of CRC calculation.
    194 ;   Otherwise SET(A)BOOT from the eCS v2.1 would break on AB v1.0.8 because it
    195 ;   sees a corrupt AiR-BOOT configuration.
    196 ;   This means that the CRC over the AB config is calculated over 5 sectors
    197 ;   instead of 7, just like in v1.07.
    198 ;
    199 ; NOTE:
    200 ;   Because of space constraints most of the debug code has been commented
    201 ;   out in this version.
    202 ;   Possibly it will be re-enabled after code cleanup and changing to JWasm.
    203 ;
    204 ;
    205 ; v1.07
    206 ; -----
    207 ; # Huge Drives and LVM #
    208 ;   When using disks >512GB under eComStation, the drive geometry changes to
    209 ;   127 or 255 sectors per track. Since LVM-info is written at the last sector
    210 ;   of a track, and AiR-BOOT uses the geometry of the MBR, it cannot find the
    211 ;   LVM-info and the eCS partition / volume bootsector.
    212 ;   This has been fixed.
    213 ;   Now, when an eCS-partition is discovered and the drive is >512GB, AiR-BOOT
    214 ;   will use the eCS geometry to locate the LVM-info and the bootsector.
    215 ;
    216 ; # Special loader handling #
    217 ;   The special handling of partition boot-loaders has been enhanced to
    218 ;   enable booting of legacy systems on huge drives with or without OS/2
    219 ;   extended geometry.
    220 ;
    221 ; # eComStation boot-through after phase 1 #
    222 ;   Special functionality is implemented to directly boot a newly
    223 ;   installed eCS system after completing phase 1 of the installation.
    224 ;   This works in conjuntion with the OS/2 specific SET(A)BOOT.EXE program,
    225 ;   also part of the AiR-BOOT package.
    226 ;
    227 ; # Math, Debug, Conv and Aux modules #
    228 ;   These are used for 32-bit arithmatic on 16-bit code,
    229 ;   debug the booting process, converting between data-types
    230 ;   and outputting log-data to the com-port.
    231 ;
    232 ;
    233 ; v1.06
    234 ; -----
    235 ; This is the last version developed by Martin Kiewitz.
    236 ; It serves as the base for the versions above.
    237 ; Please do not post your feedback on sourceforge or bother Martin with
    238 ; regard to issues with the above versions.
    239 ; Use the eCS bug-tracker or the Trac project-page at netlabs and see the
    240 ; documentation of this newer versions for the relevant contact information.
    24119
    24220
     
    26240; instructions, to allow for automatic recoding by TASM.
    26341; This seems to be a TASM bug. (v2,v3,v4, dunno v5)
    264 ;
    265 ;JUMPS
    266 ;
     42IFDEF   TASM
     43    ;~ JUMPS
     44ENDIF
    26745
    26846;
     
    27250;
    27351;ModuleNames             equ     1
    274 
    275 
    276 
    277 
    278 
    279 ;
    280 ; An ORG directive resets the location counter where code and data is
    281 ; generated. If the location counter is reset back to a point where
    282 ; code or data already has been generated, this will be overwritten
    283 ; without warning.
    284 ; This macro is run at every ORG directive to check for this condition,
    285 ; and when it occurs further assembly is terminated.
    286 ; FIXME: Get JWasm and Tasm use some common ECHO/%OUT method.
    287 ;        (Tasm only pases first word of non-quoted string to a macro)
    288 ;
    289 check_overlap   MACRO   loc
    290 
    291     ; Exit macro immediately if no overlap.
    292     ; We don't want to assign values to z_last_... if there is no
    293     ; overlap because they would then hold the values the last time this
    294     ; macro was called and not those of the last overlap.
    295     IF (loc - $) LE 0
    296         EXITM
    297     ENDIF
    298 
    299     ; Calculate the overlap.
    300     z_last_overlap_location = loc
    301     z_last_overlap_size = (loc - $)
    302 
    303     IFDEF   JWASM
    304         ; Output message.
    305         ECHO
    306         ECHO ** ERROR: LOCATION OVERLAP DETECTED [JWASM] ! **
    307         ECHO .         THIS IS MOST LIKELY CAUSED BY CODE / DATA
    308         ECHO .         EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
    309         ECHO .         LOOK AT 'z_last_overlap_location' TO SEE WHERE.
    310         ECHO .         LOOK AT 'z_last_overlap_size' TO SEE SIZE.
    311         ECHO .         FORCING ERROR...
    312         ECHO
    313     ENDIF
    314     IFDEF   TASM
    315         IF2
    316             ; Output message (only on pass2).
    317             %OUT
    318             %OUT ** ERROR: LOCATION OVERLAP DETECTED [TASM] ! **
    319             %OUT .         THIS IS MOST LIKELY CAUSED BY CODE / DATA
    320             %OUT .         EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
    321             %OUT .         LOOK AT 'z_last_overlap_location' TO WHERE.
    322             %OUT .         LOOK AT 'z_last_overlap_size' TO SEE SIZE.
    323             %OUT .         FORCING ERROR...
    324             %OUT
    325         ENDIF
    326     ENDIF
    327 
    328     ; Terminate assembly by forcing an error.
    329     .ERR
    330 
    331 ENDM
    332 
    333 
    33452
    33553
     
    34260MaxDisks                equ     64
    34361
    344 ;
    345 ; If defined then include DEBUG.ASM and output debug-info to serial-port.
    346 ;
    347 ;AuxDebug                equ     1
    348 
    349 ; Com-port for debugging, 0 is disabled
    350 BiosComPort             equ     0
     62; Only when assembled with JWasm because Tasm generates too large code.
     63IFDEF   JWASM
     64    ; If defined then include DEBUG.ASM and output debug-info to serial-port.
     65    AUX_DEBUG       EQU
     66ELSE
     67    ;~ AUX_DEBUG       EQU
     68ENDIF
    35169
    35270
     
    36381
    36482; 9600 bps, no parity, 1 stop-bit, 8 bits per char
    365 AuxInitParms            equ     11100011b
     83AUX_INIT_PARMS          EQU     11100011b
     84
     85; Com-port for debugging, 0 is disabled
     86BIOS_COM_PORT           EQU     1
    36687
    36788; Default word value for BIOS_AuxParms variable
    36889; Note that is has moved since v1.07
    369 BIOS_AuxParmsDefault    equ     (AuxInitParms SHL 8) OR BiosComPort
     90BIOS_AUXPARMS_DEFAULT   EQU     (AUX_INIT_PARMS SHL 8) OR BIOS_COM_PORT
     91
     92
     93
    37094
    37195;
     
    37397;
    37498ReleaseCode             equ     -1
    375 
    376 
    377 
    37899
    379100
     
    542263
    543264
    544                 ; ------------------------------------------
    545                 ; Rousseau: # Changed this from .386 to .286
    546                 ; ------------------------------------------
    547                 ; Because of the TASM-bug the processor had to be changed to turn JUMPS
    548                 ; off. Existing movzx instructions were replaced with 286 equivalent code.
    549                 ; Out of range relative jumps have been recoded.
    550                 ; TASM still generates an extra NOP after test [mem],1
    551                 ; instructions.
    552                 ; JWasm produces tighter code.
    553                 ; JWasm:
    554                 ; With segment overrides, the address is expanded to the bit-width.
    555                 ; So, .386 will generate a 32-bit address, even in a USE16 segment.
    556                 .286
    557 
    558                 ; This influences the uses directive and other stuff,
    559                 ; like calling-style and local variables.
    560                 ; The model itself,large, has no effect because we generate
    561                 ; a binairy image and not a segmented executable.
    562 
    563                 ; Tasm needs a memory model for USES on PROC to work.
    564                 IFDEF   TASM
    565                 ;.model large, basic
    566                 .model  tiny,c
    567                 ENDIF
     265; ------------------------------------------
     266; Rousseau: # Changed this from .386 to .286
     267; ------------------------------------------
     268; Because of the TASM-bug the processor had to be changed to turn JUMPS
     269; off. Existing movzx instructions were replaced with 286 equivalent code.
     270; Out of range relative jumps have been recoded.
     271; TASM still generates an extra NOP after test [mem],1
     272; instructions.
     273; JWasm produces tighter code.
     274; JWasm:
     275; With segment overrides, the address is expanded to the bit-width.
     276; So, .386 will generate a 32-bit address, even in a USE16 segment.
     277.286
     278
     279; This influences the uses directive and other stuff,
     280; like calling-style and local variables.
     281; The model itself,large, has no effect because we generate
     282; a binairy image and not a segmented executable.
     283
     284; Tasm needs a memory model for USES on PROC to work.
     285IFDEF   TASM
     286    ;.model large, basic
     287    .model  tiny,c
     288ENDIF
    568289
    569290;
     
    580301; time.
    581302;
    582 SEGMENTED   EQU 1
     303SEGMENTED   EQU
    583304
    584305IFDEF   SEGMENTED
    585             AIRBOOT     GROUP   IMAGE,VOLATILE
     306    AIRBOOT     GROUP   LDRIMAGE,VOLATILE
    586307ENDIF
    587308
    588309; Our code-segment starts here.
    589 IMAGE       SEGMENT     USE16   PUBLIC  'MIXED'
     310LDRIMAGE    SEGMENT     USE16   PUBLIC  'MIXED'
    590311
    591312IFDEF   SEGMENTED
    592             ASSUME      CS:AIRBOOT, DS:AIRBOOT, ES:nothing, SS:nothing
     313    ASSUME  CS:AIRBOOT, DS:AIRBOOT, ES:nothing, SS:nothing
    593314ELSE
    594             ASSUME      CS:IMAGE,   DS:IMAGE,   ES:nothing, SS:nothing
     315    ASSUME  CS:LDRIMAGE,DS:LDRIMAGE,ES:nothing, SS:nothing
    595316ENDIF
    596 
    597317
    598318;==============================================================================
     
    638358
    639359                ; ID String, Date (DD,MM,CC,YY), Version Number, Language ID
    640                 db      'AiRBOOT', 16h, 02h, 20h, 12h, 01h, 08h, TXT_LanguageID
     360                db      'AiRBOOT', 20h, 02h, 20h, 12h, 01h, 08h, TXT_LanguageID
    641361
    642362                ; Total Sectors Count.
     
    709429
    710430
    711 
    712431; Comport settings
    713432; It had to be moved to create room for the double I13X
    714433; signature.
    715434; It cannot be in the config-area (sector 55)
    716 ; because that area
    717 ; is crc-protected.
    718 BIOS_AuxParms   dw      BIOS_AuxParmsDefault
    719 
    720 ;
    721 ; Reserved space
    722 ; Should check overflow here, later...
    723 ;
     435; because that area is crc-protected and would not allow 'poking'.
     436here = $
     437                org     0003Ch
     438                check_overlap   here
     439BIOS_AuxParms   dw      BIOS_AUXPARMS_DEFAULT
     440
    724441reserved        db      6   dup('X')
    725 
    726442
    727443                ;
     
    733449                ; want to change the AiR-BOOT signature
    734450                ; because of Microsoft inventions...
    735 
    736 
    737 
    738 
    739 
    740451here = $
    741452                org     044h
     
    832543                mov     ds, ax          ; Set DS==ES to Code Segment
    833544
     545
    834546            ; If we are in debug-mode, all code is moved already,
    835547            ; so we can directly jump to it.
     
    966678                dw      '$$'
    967679
     680
     681here = $
     682                org     001beh
     683                check_overlap   here
    968684
    969685                ; Partition Table
     
    1057773
    1058774
    1059 
    1060 
    1061 
    1062 
    1063 
    1064 
    1065 
    1066 
    1067 
    1068 
    1069 
    1070 
    1071 
    1072775                ; ##############################################
    1073776                ; ## ENTRY-POINT AFTER ALL THE INITIAL HASSLE ##
    1074777                ; ##############################################
     778
    1075779
    1076780
     
    1107811
    1108812
     813                mov     ax, offset sobss
     814                mov     ax,offset BeginOfVariables
     815                mov     ax,offset [TrueSecs]
     816                lea     ax, [TrueSecs]
     817                mov     ax,word ptr [TrueSecs]
     818                mov     ax,offset EndOfVariables
     819                mov     ax, offset eobss
     820                nop
     821                ;~ mov     ax, offset qqqq
     822
    1109823
    1110824                ;jmp skip
     
    1267981
    1268982
    1269 skip:
     983    skip:
    1270984
    1271985
     
    14411155size_driveio = $-b_driveio
    14421156
     1157b_lvm:
     1158Include SPECIAL/LVM.ASM         ; LVM-specific code
     1159size_lvm = $-b_lvm
     1160
    14431161b_videoio:
    14441162Include REGULAR/VIDEOIO.ASM     ; Video I/O
     
    14691187size_other = $-b_other
    14701188
    1471 ; Rousseau: Special modules moved upwards.
    14721189b_main:
    14731190Include SETUP/MAIN.ASM          ; The whole AiR-BOOT SETUP
    14741191size_main = $-b_main
     1192
    14751193
    14761194
     
    14811199ENDIF
    14821200
     1201
    14831202b_math:
    14841203Include REGULAR/MATH.ASM        ; Math functions (like 32-bit multiply)
     
    14871206
    14881207
    1489 IFDEF AuxDebug
     1208
     1209; Various debugging routines, uses AUXIO and CONV
     1210IFDEF AUX_DEBUG
    14901211b_debug:
    1491 ;   Include REGULAR/DEBUG.ASM     ; Various debugging routines,
    1492                                 ; uses AUXIO and CONV
     1212Include REGULAR/DEBUG.ASM
    14931213size_debug = $-b_debug
     1214b_auxio:
     1215Include REGULAR/AUXIO.ASM       ; Com-port support for debugging
     1216size_auxio = $-b_auxio
    14941217ENDIF
    1495 
    1496 b_auxio:
    1497 ;Include REGULAR/AUXIO.ASM       ; Com-port support for debugging
    1498 size_auxio = $-b_auxio
    1499 
    1500 ; Rousseau: moved upwards
    1501 ;IFDEF TXT_IncludeCyrillic
    1502 ;   Include SPECIAL/CHARSET.ASM  ; Charset Support (e.g. Cyrillic)
    1503 ;ENDIF
    1504 
    1505 b_lvm:
    1506 Include SPECIAL/LVM.ASM         ; LVM-specific code
    1507 size_lvm = $-b_lvm
    15081218
    15091219
     
    16031313
    16041314
    1605 
    1606 CODE_END:
    1607 
    1608                 ;org     06A00h - 4
     1315                ;
     1316                ; End of code marker.
     1317                ;
    16091318                db      'BABE'
    1610 
    1611                 ;org     06A00h
    16121319                db      'FACE'
    16131320
     1321code_end:
     1322
     1323
     1324
     1325here = $
     1326                org     06800h
     1327                ; For some reason, this overlap check does not work !!
     1328                ; I gues it's because 'here' has no definitive value yet
     1329                ; and since JWasm is a single pass assembler, it won't
     1330                ; change anymore. it is off by 1dh bytes.
     1331                ; (Changing the ORG to 6700h produces an overlap of 11dh.
     1332                ; This 1dh is by sheer coincidence the same length as the
     1333                ; MBR_Prot signature on my system, but it's not related.
     1334                check_overlap   here
     1335
    16141336                ;
    16151337                ; This is the AiR-BOOT MBR-Protection Image.
    1616                 ; 04600 / 200h = 34h = 52d sectors are before this point.
     1338                ; 06800 / 200h = 34h = 52d sectors are before this point.
    16171339                ; The stuff generated here gets overwritten when the MBR_PROT.ASM
    16181340                ; module, which is assembled separately, gets merged.
    16191341                ; So you won't find the string below in the generated binary.
    16201342                ;
    1621 here = $
    1622                 org     06800h
    1623                 check_overlap   here
    1624 
     1343; Hardcoded to 1k (1024 bytes) (MBR_PROT.ASM)
    16251344MBR_Protection  db 'AiR-BOOT MBR-Protection Image'
    1626 ; Hardcoded to 1k (1024 bytes)
    1627                 db  1024-($-MBR_Protection)  dup(0)
    1628 
    1629 
    1630 ;CODE_SEG        ENDS
    1631 
     1345
     1346                ; Just fill.
     1347                db  1024-($-MBR_Protection)  dup('M')
     1348
     1349;LDRIMAGE        ENDS
    16321350;DATA_SEG        SEGMENT     USE16   PUBLIC  'CODE'
     1351
     1352
     1353
     1354;~ MYDATA  SEGMENT     COMMON    'MIXED'
     1355;~ qqqq     dw  'QQ'
     1356;~ MYDATA  ENDS
    16331357
    16341358;==============================================================================
     
    19791703;
    19801704
    1981 IMAGE           ENDS
    1982 
    1983 ;DATA_SEG        ENDS
     1705LDRIMAGE    ENDS
     1706
     1707;DATA_SEG    ENDS
    19841708
    19851709;
     
    20001724                            ;
    20011725                            org 02400h                         ; Uninitialized
    2002 
     1726                            ;~ org 00200h                         ; 200h geeft 3 floppies !
    20031727
    20041728; This space actually gets initialized in PreCrap to NUL (till EndOfVariables)
     
    20101734
    20111735; Everything used to build a new IPT and reference it to the old one
     1736; IETS OVERSCHRIJFT DIT !!
    20121737NewPartTable                db  1536 dup (?)                    ; New Partition Table
     1738
    20131739NewHidePartTable            db  partition_count * LocHPT_LenOfHPT dup (?)    ; New Hide-Partition Table
    20141740NewDriveLetters             db  partition_count dup (?)         ; Logical Drive-Letters
     
    21671893VOLATILE    ENDS
    21681894ELSE
    2169 IMAGE       ENDS
     1895LDRIMAGE    ENDS
    21701896ENDIF
     1897
    21711898            END     AIR_BOOT
    21721899
    2173 
    2174 
  • trunk/BOOTCODE/BLDDATE.ASM

    r42 r43  
    11IFDEF   JWASM
    2     BUILD_DATE db 'Build Date: 16 Feb 2012 at 03:00:00                                 [JWasm]',0
     2    BUILD_DATE db 'Build Date: 20 Feb 2012 at 19:30:00                                 [JWasm]',0
    33ENDIF
    44IFDEF   TASM
    5     BUILD_DATE db 'Build Date: 16 Feb 2012 at 03:00:00                                  [Tasm]',0
     5    BUILD_DATE db 'Build Date: 20 Feb 2012 at 19:30:00                                  [Tasm]',0
    66ENDIF
  • trunk/BOOTCODE/Makefile

    r42 r43  
    130130#ASM=masm
    131131#ASM=alp
    132 #ASM=tasm
     132ASM=tasm
    133133#ASM=wasm
    134 ASM=jwasm
     134#ASM=jwasm
    135135
    136136#
  • trunk/BOOTCODE/REGULAR/AUXIO.ASM

    r31 r43  
    3434
    3535; Initialize the com-port, but only when logging is enabled.
    36 ; It get's it's parameters from offset 1B0h in the MBR.
     36; It get's it's parameters from the value in the MBR.
    3737; Out:         AX - line status
    38 AuxIO_Init              Proc  Near  Uses dx si
    39       ; bits 7-5 = datarate   (000=110,001=150,010=300,011=600,100=1200,101=2400,110=4800,111=9600 bps)
    40       ; bits 4-3 = parity     (00 or 10 = none, 01 = odd, 11 = even)
    41       ; bit  2   = stop-bits  (set = 2 stop-bits, clear = 1 stop-bit)
    42       ; bits 1-0 = data-bits  (00 = 5, 01 = 6, 10 = 7, 11 = 8)
    43      ; mov      [BIOS_AuxParms],ax             ; save initialization and port
    44       mov      dx,[BIOS_AuxParms]            ; DL=port, 0=disabled, 1=com1; DH=config-parms
    45       test     dl,dl                         ; see if logging is enabled, if not, skip initialization
    46       jz       AuxIO_Init_NoLogging
    47 
    48       dec      dl                            ; adjust port-number
    49       and      dl,03h                        ; 3 is max value
    50 
    51       ; Initialization message
    52       mov      si,offset AuxInitMsg
    53       call     MBR_Teletype
    54 
    55       ; Port number
    56       call     VideoIO_SyncPos
    57       mov      al,dl
    58       inc      al
    59       call     VideoIO_PrintByteDynamicNumber
    60       xor      si,si
    61       call     MBR_TeletypeNL
    62 
    63       ; Do the initialization
    64       mov      al,dh                         ; initialization parameters to al
    65       mov      dh,0                          ; DX now contains port-number
    66       mov      ah,0
    67       int      14h                           ; intialize com-port
    68    AuxIO_Init_NoLogging:
    69       ret
    70 AuxIO_Init              EndP
     38AuxIO_Init      Proc  Near  Uses dx si
     39        ; bits 7-5 = datarate   (000=110,001=150,010=300,011=600,100=1200,101=2400,110=4800,111=9600 bps)
     40        ; bits 4-3 = parity     (00 or 10 = none, 01 = odd, 11 = even)
     41        ; bit  2   = stop-bits  (set = 2 stop-bits, clear = 1 stop-bit)
     42        ; bits 1-0 = data-bits  (00 = 5, 01 = 6, 10 = 7, 11 = 8)
     43        ; mov      [BIOS_AuxParms],ax             ; save initialization and port
     44        mov     dx,[BIOS_AuxParms]            ; DL=port, 0=disabled, 1=com1; DH=config-parms
     45        test    dl,dl                         ; see if logging is enabled, if not, skip initialization
     46        jz      AuxIO_Init_NoLogging
     47
     48        dec     dl                            ; adjust port-number
     49        and     dl,03h                        ; 3 is max value
     50
     51        ; Initialization message
     52        mov     si,offset AuxInitMsg
     53        call    MBR_Teletype
     54
     55        ; Port number
     56        call    VideoIO_SyncPos
     57        mov     al,dl
     58        inc     al
     59        call    VideoIO_PrintByteDynamicNumber
     60        xor     si,si
     61        call    MBR_TeletypeNL
     62
     63        ; Do the initialization
     64        mov     al,dh                         ; initialization parameters to al
     65        mov     dh,0                          ; DX now contains port-number
     66        mov     ah,0
     67        int     14h                           ; intialize com-port
     68    AuxIO_Init_NoLogging:
     69        ret
     70AuxIO_Init      EndP
    7171
    7272
     
    7575; Destroyed: None
    7676AuxIO_PrintSingleChar   Proc  Near  Uses ax es di
    77    nop
     77        nop
    7878AuxIO_PrintSingleChar   EndP
    7979
    8080
    8181; Print char to com-port (teletype style)
    82 AuxIO_Teletype          Proc     Near  Uses  ax dx
    83       mov      dx,[BIOS_AuxParms]            ; get port and parameters
    84       xor      dh,dh                         ; we don't need the parameters
    85       test     dl,dl                         ; test if logging is enabled
    86       jz       AuxIO_Teletype_NoLogging      ; nope, return immediately
    87       dec      dl                            ; adjust port-number
    88       and      dl,03h                        ; 3 is max value
    89       mov      ah,01h
    90       int      14h                           ; send char to com-port
    91    AuxIO_Teletype_NoLogging:
    92       ret
    93 AuxIO_TeleType          EndP
     82AuxIO_Teletype  Proc     Near  Uses  ax dx
     83        mov     dx,[BIOS_AuxParms]            ; get port and parameters
     84        xor     dh,dh                         ; we don't need the parameters
     85        test    dl,dl                         ; test if logging is enabled
     86        jz      AuxIO_Teletype_NoLogging      ; nope, return immediately
     87        dec     dl                            ; adjust port-number
     88        and     dl,03h                        ; 3 is max value
     89        mov     ah,01h
     90        int     14h                           ; send char to com-port
     91    AuxIO_Teletype_NoLogging:
     92        ret
     93AuxIO_TeleType  EndP
    9494
    9595
    9696; Print newline char (unix) to com-port (teletype style)
    97 AuxIO_TeletypeNL        Proc     Near  Uses  ax
    98       mov      al,10
    99       call     AuxIO_Teletype
    100       ret
    101 AuxIO_TeleTypeNL        EndP
     97AuxIO_TeletypeNL    Proc     Near  Uses  ax
     98        mov     al,10
     99        call    AuxIO_Teletype
     100        ret
     101AuxIO_TeleTypeNL    EndP
    102102
    103103
     
    108108; Destroyed:   None
    109109AuxIO_TeletypeHexByte   Proc     Near  Uses  ax
    110       call     CONV_BinToAsc              ; Returns high hex-nibble in AH, low hex-nibble in AL
    111       xchg     al,ah                      ; High hex-nibble first
    112       call     AuxIO_Teletype             ; Output to com-port
    113       xchg     al,ah                      ; Low hex-nibble next
    114       call     AuxIO_Teletype             ; Output to com-port
    115       ret
     110        call    CONV_BinToAsc              ; Returns high hex-nibble in AH, low hex-nibble in AL
     111        xchg    al,ah                      ; High hex-nibble first
     112        call    AuxIO_Teletype             ; Output to com-port
     113        xchg    al,ah                      ; Low hex-nibble next
     114        call    AuxIO_Teletype             ; Output to com-port
     115        ret
    116116AuxIO_TeleTypeHexByte   EndP
    117117
     
    122122; Destroyed:   None
    123123AuxIO_TeletypeHexWord   Proc     Near
    124       xchg     al,ah                      ; High byte first
    125       call     AuxIO_TeletypeHexByte      ; Output to com-port
    126       xchg     al,ah                      ; low byte next
    127       call     AuxIO_TeletypeHexByte      ; Output to com-port
    128       ret
     124        xchg    al,ah                      ; High byte first
     125        call    AuxIO_TeletypeHexByte      ; Output to com-port
     126        xchg    al,ah                      ; low byte next
     127        call    AuxIO_TeletypeHexByte      ; Output to com-port
     128        ret
    129129AuxIO_TeleTypeHexWord   EndP
    130130
     
    136136; Destroyed:   None
    137137AuxIO_TeletypeHexDWord  Proc     Near
    138       xchg     ax,dx
    139       call     AuxIO_TeletypeHexWord      ; High word first
    140       xchg     ax,dx
    141       call     AuxIO_TeletypeHexWord      ; Low word next
    142       ret
     138        xchg    ax,dx
     139        call    AuxIO_TeletypeHexWord      ; High word first
     140        xchg    ax,dx
     141        call    AuxIO_TeletypeHexWord      ; Low word next
     142        ret
    143143AuxIO_TeleTypeHexDWord  EndP
    144144
     
    150150; Destroyed:   None
    151151AuxIO_TeletypeHexQWord  Proc     Near
    152       xchg     dx,bx
    153       xchg     ax,cx
    154       call     AuxIO_TeletypeHexDWord     ; High dword first
    155       xchg     dx,bx
    156       xchg     ax,cx
    157       call     AuxIO_TeletypeHexDWord     ; Low dword next
    158       ret
     152        xchg    dx,bx
     153        xchg    ax,cx
     154        call    AuxIO_TeletypeHexDWord     ; High dword first
     155        xchg    dx,bx
     156        xchg    ax,cx
     157        call    AuxIO_TeletypeHexDWord     ; Low dword next
     158        ret
    159159AuxIO_TeleTypeHexQWord  EndP
    160160
    161161
    162162
    163 
    164 
    165 
    166163; Print 0-terminated string to com-port
    167 AuxIO_Print    Proc     Near  Uses  ax bx cx dx
    168    AuxIO_PrintNext:
    169       lodsb
    170       test     al,al
    171       jz       AuxIO_PrintEOS
    172       call     AuxIO_Teletype
    173       jmp      AuxIO_PrintNext
    174    AuxIO_PrintEOS:
    175       ret
    176 AuxIO_Print    EndP
     164AuxIO_Print     Proc     Near  Uses  ax bx cx dx
     165    AuxIO_PrintNext:
     166        lodsb
     167        test    al,al
     168        jz      AuxIO_PrintEOS
     169        call    AuxIO_Teletype
     170        jmp     AuxIO_PrintNext
     171    AuxIO_PrintEOS:
     172        ret
     173AuxIO_Print     EndP
    177174
    178175
     
    182179AuxIO_DumpParagraph     Proc  Near  Uses  ax cx dx si
    183180
    184       ; Dump the index dword
    185       xor      dx,dx
    186       mov      ax,si
    187       call     AuxIO_TeletypeHexDWord
    188 
    189       ; Separate it from the dump
    190       mov      al,' '
    191       call     AuxIO_Teletype
    192       mov      al,' '
    193       call     AuxIO_Teletype
    194       mov      al,'|'
    195       call     AuxIO_Teletype
    196       mov      al,' '
    197       call     AuxIO_Teletype
    198 
    199       ; Save si for later
    200       push     si
    201 
    202       ; Four groups of 4 bytes
    203       mov      cx,4
    204 
    205 
    206    AuxIO_DumpParagraph_Next_1:
    207 
    208       ; byte at offset 0
    209       lodsb
    210       call     AuxIO_TeletypeHexByte
    211 
    212       ; space separator
    213       mov      al,' '
    214       call     AuxIO_Teletype
    215 
    216       ; byte at offset 1
    217       lodsb
    218       call     AuxIO_TeletypeHexByte
    219 
    220       ; space separator
    221       mov      al,' '
    222       call     AuxIO_Teletype
    223 
    224       ; byte at offset 2
    225       lodsb
    226       call     AuxIO_TeletypeHexByte
    227 
    228       ; space separator
    229       mov      al,' '
    230       call     AuxIO_Teletype
    231 
    232       ; byte at offset 3
    233       lodsb
    234       call     AuxIO_TeletypeHexByte
    235 
    236       ; space separator
    237       mov      al,' '
    238       call     AuxIO_Teletype
    239 
    240       ; separator
    241       mov      al,'|'
    242       call     AuxIO_Teletype
    243 
    244       ; space separator
    245       mov      al,' '
    246       call     AuxIO_Teletype
    247 
    248       loop     AuxIO_DumpParagraph_Next_1
    249 
    250       ; space separator
    251       mov      al,' '
    252       call     AuxIO_Teletype
    253 
    254       ; recall pointer
    255       pop      si
    256 
    257       ; 16 ascii bytes to print
    258       mov      cx,16
    259 
    260    AuxIO_DumpParagraph_Next_2:
    261       mov      ah,'.'                              ; char to use ufnot printable
    262       lodsb                                        ; load byte
    263       call     CONV_ConvertToPrintable             ; use dot's if not printable
    264       call     AuxIO_Teletype                      ; print it
    265       loop     AuxIO_DumpParagraph_Next_2
    266       ret
    267 AuxIO_DumpParagraph    EndP
    268 
    269 
    270 
    271 AuxIO_DumpSector  Proc  Near  Uses  cx si
    272       mov      cx,32                      ; Number of paragraphs in a sector
    273    AuxIO_DumpSector_Next:
    274       call     AuxIO_DumpParagraph        ; Dump te paragraph
    275       add      si,16                      ; Advance pointer
    276       call     AuxIO_TeletypeNL
    277       loop     AuxIO_DumpSector_Next
    278       ret
    279 AuxIO_DumpSector  EndP
    280 
    281 
    282 AuxIOHello: db 'AiR-BOOT com-port debugging',10,0
    283 
    284 
    285 
     181        ; Dump the index dword
     182        xor     dx,dx
     183        mov     ax,si
     184        call    AuxIO_TeletypeHexDWord
     185
     186        ; Separate it from the dump
     187        mov     al,' '
     188        call    AuxIO_Teletype
     189        mov     al,' '
     190        call    AuxIO_Teletype
     191        mov     al,'|'
     192        call    AuxIO_Teletype
     193        mov     al,' '
     194        call    AuxIO_Teletype
     195
     196        ; Save si for later
     197        push    si
     198
     199        ; Four groups of 4 bytes
     200        mov     cx,4
     201
     202
     203    AuxIO_DumpParagraph_Next_1:
     204
     205        ; byte at offset 0
     206        lodsb
     207        call    AuxIO_TeletypeHexByte
     208
     209        ; space separator
     210        mov     al,' '
     211        call    AuxIO_Teletype
     212
     213        ; byte at offset 1
     214        lodsb
     215        call    AuxIO_TeletypeHexByte
     216
     217        ; space separator
     218        mov     al,' '
     219        call    AuxIO_Teletype
     220
     221        ; byte at offset 2
     222        lodsb
     223        call    AuxIO_TeletypeHexByte
     224
     225        ; space separator
     226        mov      al,' '
     227        call    AuxIO_Teletype
     228
     229        ; byte at offset 3
     230        lodsb
     231        call    AuxIO_TeletypeHexByte
     232
     233        ; space separator
     234        mov      al,' '
     235        call    AuxIO_Teletype
     236
     237        ; separator
     238        mov      al,'|'
     239        call    AuxIO_Teletype
     240
     241        ; space separator
     242        mov      al,' '
     243        call    AuxIO_Teletype
     244
     245        loop    AuxIO_DumpParagraph_Next_1
     246
     247        ; space separator
     248        mov      al,' '
     249        call    AuxIO_Teletype
     250
     251        ; recall pointer
     252        pop     si
     253
     254        ; 16 ascii bytes to print
     255        mov     cx,16
     256
     257    AuxIO_DumpParagraph_Next_2:
     258        mov     ah,'.'                              ; char to use ufnot printable
     259        lodsb                                        ; load byte
     260        call    CONV_ConvertToPrintable             ; use dot's if not printable
     261        call    AuxIO_Teletype                      ; print it
     262        loop    AuxIO_DumpParagraph_Next_2
     263        ret
     264AuxIO_DumpParagraph     EndP
     265
     266
     267
     268AuxIO_DumpSector    Proc  Near  Uses  cx si
     269        mov     cx,32                      ; Number of paragraphs in a sector
     270    AuxIO_DumpSector_Next:
     271        call    AuxIO_DumpParagraph        ; Dump te paragraph
     272        add     si,16                      ; Advance pointer
     273        call    AuxIO_TeletypeNL
     274        loop    AuxIO_DumpSector_Next
     275        ret
     276AuxIO_DumpSector    EndP
     277
     278
     279AuxIOHello  db 'AiR-BOOT com-port debugging',10,0
     280
     281
     282
  • trunk/BOOTCODE/REGULAR/BOOTMENU.ASM

    r40 r43  
    598598;        In: CL - Color, DL - Partition
    599599; Destroyed: None, but Locate-Pointer gets set
    600 BOOTMENU_ReColorPart            Proc Near   Uses bx cx es di
    601 
    602   ; call  SOUND_Beep
    603 
    604    mov     bh, cl     ; Color to BH
    605    ; First calculate location of bar
    606    cmp     Menu_UpperPart, dl
    607    ja      BMRCP_NotInWindowView
    608    mov     ch, dl
    609    sub     ch, Menu_UpperPart            ; CH - Position relative to UpperPart
    610    cmp     ch, 14                        ; 14 - Maximum Total in Window
    611    ja      BMRCP_NotInWindowView
    612    add     ch, 5                         ; Y-Position add-on fixed 5
    613    mov     cl, 2                         ; X-Position is always 2
    614    call    VideoIO_Locate                ; geht zu CX
    615    call    VideoIO_Internal_SetRegs
    616    inc     di                            ; DI - Destination+1 -> Color-Byte
    617    mov     cl, 78                        ; Length of Bar is always 78
    618   BMRCP_ClearLoop:
    619       mov     al, es:[di]
    620       and     al, 0Fh
    621       or      al, bh                     ; Adds background color (from BH)
    622 
    623       ;mov      al,97h
    624 
    625       mov     es:[di], al
    626       add     di, 2
    627    dec     cl
    628    jnz     BMRCP_ClearLoop
    629   BMRCP_NotInWindowView:
    630    ret
    631 BOOTMENU_ReColorPart            EndP
     600BOOTMENU_ReColorPart    Proc Near   Uses bx cx es di
     601
     602        ; call  SOUND_Beep
     603
     604        mov     bh, cl     ; Color to BH
     605        ; First calculate location of bar
     606        cmp     Menu_UpperPart, dl
     607        ja      BMRCP_NotInWindowView
     608        mov     ch, dl
     609        sub     ch, Menu_UpperPart          ; CH - Position relative to UpperPart
     610        cmp     ch, 14                      ; 14 - Maximum Total in Window
     611        ja      BMRCP_NotInWindowView
     612        add     ch, 5                       ; Y-Position add-on fixed 5
     613        mov     cl, 2                       ; X-Position is always 2
     614        call    VideoIO_Locate              ; geht zu CX
     615        call    VideoIO_Internal_SetRegs
     616        inc     di                          ; DI - Destination+1 -> Color-Byte
     617        mov     cl, 78                      ; Length of Bar is always 78
     618    BMRCP_ClearLoop:
     619        mov     al, es:[di]
     620        and     al, 0Fh
     621        or      al, bh                      ; Adds background color (from BH)
     622
     623        ;mov      al,97h
     624
     625        mov     es:[di], al
     626        add     di, 2
     627        dec     cl
     628        jnz     BMRCP_ClearLoop
     629    BMRCP_NotInWindowView:
     630        ret
     631BOOTMENU_ReColorPart    EndP
    632632
    633633
    634634; Calculate Menu-Variables for Boot-Menu, these use the filtered Part-Pointers
    635 BOOTMENU_ResetMenuVars          Proc Near   Uses dx
    636    xor     dl, dl                        ; Partition at Pos 0 == 1st
    637    mov     Menu_UpperPart, dl
    638 
    639    ; = TIMED BOOTING =
    640    mov     dl, CFG_TimedBoot
    641    mov     TimedBootEnable, dl
    642    mov     al, CFG_TimedSecs
    643    mov     TimedSecondLeft, al
    644    call    TIMER_TranslateSecToTic
    645    add     ax, 16                        ; So that the required ammount will
    646    mov     CFG_TimedDelay, ax            ; be shown and not Timer-1.
    647    call    BOOTMENU_ResetTimedBoot
    648    ; = FLOPPY-GET-NAME TIMER =
    649    call    BOOTMENU_ResetGetFloppy
    650 
    651    ; Resettet die Base-Variablen...
    652    mov     dl, PartitionPointerCount
    653    mov     Menu_TotalParts, dl
    654 
    655    ; Copy device-name to the ContBIOSbootSeq-IPT entry
    656    ;  Normally this does not need to get done here, but is done for safety
    657    ;  reasons if e.g. IPT got changed by SETUP, but that setup was discarded.
    658    call    PART_UpdateResumeBIOSName
    659 
    660    ; Default-Partition -> Filtered View -> Menu_EntryDefault
    661    mov     dl, CFG_PartDefault
    662    call    PART_ConvertFromStraight
    663    mov     Menu_EntryDefault, dl
    664 
    665    ; Last-Booted-Partition -> Filtered View -> Menu_EntryLast
    666    mov     dl, CFG_PartLast
    667    call    PART_ConvertFromStraight
    668    mov     Menu_EntryLast, dl
    669 
    670    ; Automatic-Partition -> Filtered View -> Menu_EntryAutomatic
    671    mov     dl, CFG_PartAutomatic
    672    call    PART_ConvertFromStraight
    673    mov     Menu_EntryAutomatic, dl
    674 
    675 ; [Linux support removed since v1.02]
    676  ; Okay, now we check if Default/Last Kernel Partition Name is available...
    677  ;  if so, simply set Menu_EntryDefault/Menu_EntryLast.
    678  mov     si, offset CFG_LinuxDefaultKernel
    679  call    LINUX_SearchKernelName        ; DL - Filtered Entry No
    680  cmp     dl, 0FFh
    681  je      BMRMV_DefaultKernelNF
    682  mov     Menu_EntryDefault, dl
    683 ; BMRMV_DefaultKernelNF:
    684  mov     si, offset CFG_LinuxLastKernel
    685  call    LINUX_SearchKernelName        ; DL - Filtered Entry No
    686  cmp     dl, 0FFh
    687  je      BMRMV_LastKernelNF
    688  mov     Menu_EntryLast, dl
    689 ; BMRMV_LastKernelNF:
    690 
    691    ; restlichen Variablen berechnen...
    692    mov     dl, Menu_TotalParts
    693    cmp     Menu_TotalParts, 14
    694    jbe     BMRMV_NotMoreThan14
    695    mov     dl, 14
    696   BMRMV_NotMoreThan14:
    697    mov     Menu_TotalLines, dl
    698 
    699    ; Now copy the name of the Timed-Booted Partition to TimedBoot-Field
    700    mov     dl, Menu_EntryDefault
    701    test    CFG_TimedBootLast, 1
    702    jz      BMRMV_TimedBootDefault
    703    mov     dl, Menu_EntryLast
    704   BMRMV_TimedBootDefault:
    705    call    PART_GetPartitionPointer      ; Holt SI fr Partition DL
    706    add     si, LocIPT_Name
    707    mov     cx, 11
    708    call    GetLenOfName
    709    mov     di, offset TXT_TimedBootEntryName
    710    jz      BMRMV_NoName
    711    rep     movsb
    712   BMRMV_NoName:
    713    xor     al, al
    714    stosb              ; Ending Zero
    715    ret
    716 BOOTMENU_ResetMenuVars          EndP
     635BOOTMENU_ResetMenuVars      Proc Near   Uses dx
     636        xor     dl, dl                        ; Partition at Pos 0 == 1st
     637        mov     Menu_UpperPart, dl
     638
     639        ; = TIMED BOOTING =
     640        mov     dl, CFG_TimedBoot
     641        mov     TimedBootEnable, dl
     642        mov     al, CFG_TimedSecs
     643        mov     TimedSecondLeft, al
     644        call    TIMER_TranslateSecToTic
     645        add     ax, 16                        ; So that the required ammount will
     646        mov     CFG_TimedDelay, ax            ; be shown and not Timer-1.
     647        call    BOOTMENU_ResetTimedBoot
     648        ; = FLOPPY-GET-NAME TIMER =
     649        call    BOOTMENU_ResetGetFloppy
     650
     651        ; Resettet die Base-Variablen...
     652        mov     dl, PartitionPointerCount
     653        mov     Menu_TotalParts, dl
     654
     655        ; Copy device-name to the ContBIOSbootSeq-IPT entry
     656        ;  Normally this does not need to get done here, but is done for safety
     657        ;  reasons if e.g. IPT got changed by SETUP, but that setup was discarded.
     658        call    PART_UpdateResumeBIOSName
     659
     660        ; Default-Partition -> Filtered View -> Menu_EntryDefault
     661        mov     dl, CFG_PartDefault
     662        call    PART_ConvertFromStraight
     663        mov     Menu_EntryDefault, dl
     664
     665        ; Last-Booted-Partition -> Filtered View -> Menu_EntryLast
     666        mov     dl, CFG_PartLast
     667        call    PART_ConvertFromStraight
     668        mov     Menu_EntryLast, dl
     669
     670        ; Automatic-Partition -> Filtered View -> Menu_EntryAutomatic
     671        mov     dl, CFG_PartAutomatic
     672        call    PART_ConvertFromStraight
     673        mov     Menu_EntryAutomatic, dl
     674
     675        ;~ ; [Linux support removed since v1.02]
     676        ;~ ; Okay, now we check if Default/Last Kernel Partition Name is available...
     677        ;~ ;  if so, simply set Menu_EntryDefault/Menu_EntryLast.
     678        ;~ mov     si, offset CFG_LinuxDefaultKernel
     679        ;~ call    LINUX_SearchKernelName        ; DL - Filtered Entry No
     680        ;~ cmp     dl, 0FFh
     681        ;~ je      BMRMV_DefaultKernelNF
     682        ;~ mov     Menu_EntryDefault, dl
     683    ;~ BMRMV_DefaultKernelNF:
     684        ;~ mov     si, offset CFG_LinuxLastKernel
     685        ;~ call    LINUX_SearchKernelName        ; DL - Filtered Entry No
     686        ;~ cmp     dl, 0FFh
     687        ;~ je      BMRMV_LastKernelNF
     688        ;~ mov     Menu_EntryLast, dl
     689    ;~ BMRMV_LastKernelNF:
     690
     691        ; restlichen Variablen berechnen...
     692        mov     dl, Menu_TotalParts
     693        cmp     Menu_TotalParts, 14
     694        jbe     BMRMV_NotMoreThan14
     695        mov     dl, 14
     696    BMRMV_NotMoreThan14:
     697        mov     Menu_TotalLines, dl
     698
     699        ; Now copy the name of the Timed-Booted Partition to TimedBoot-Field
     700        mov     dl, Menu_EntryDefault
     701        test    CFG_TimedBootLast, 1
     702        jz      BMRMV_TimedBootDefault
     703        mov     dl, Menu_EntryLast
     704    BMRMV_TimedBootDefault:
     705        call    PART_GetPartitionPointer      ; Holt SI fr Partition DL
     706        add     si, LocIPT_Name
     707        mov     cx, 11
     708        call    GetLenOfName
     709        mov     di, offset TXT_TimedBootEntryName
     710        jz      BMRMV_NoName
     711        rep     movsb
     712    BMRMV_NoName:
     713        xor     al, al
     714        stosb              ; Ending Zero
     715        ret
     716BOOTMENU_ResetMenuVars      EndP
    717717
    718718; Will Set some Vars after user selected entry to boot...
    719719;  ...don't select Straight View !
    720 BOOTMENU_SetVarsAfterMenu Proc Near
    721    ; No Straight View in here...we got filtered view since BootMenu-Startup...
    722    mov     al, CFG_RememberTimed
    723    test    TimedBootUsed, 1
    724    jnz     BMSVAM_TimedBootUsed
    725    mov     al, CFG_RememberBoot
    726   BMSVAM_TimedBootUsed:
    727    or      al, al
    728    jz      BMSVAM_DontRememberBoot
    729    mov     dl, Menu_EntrySelected
    730    call    PART_ConvertToStraight        ; CFG_PartLast is non-filtered
    731 ;   mov     di, offset CFG_LinuxLastKernel
    732 ;   mov     cx, 11
    733    cmp     dl, 0FDh                      ; Dont Remember on Floppy/CD-ROM/etc.
    734    ja      BMSVAM_DontRememberBoot
    735 ;   je      BMSVAM_RememberKernelBoot     ; but remember Kernel-Bootings...
    736    mov     CFG_PartLast, dl              ; Remember partition in CFG_PartLast
    737 ;   mov     al, ' '
    738 ;   rep     stosb                         ; SPACE out CFG_LinuxLastKernel
    739   BMSVAM_DontRememberBoot:
    740    ret
    741 ;
    742 ;  BMSVAM_RememberKernelBoot:
    743 ;   mov     dl, Menu_EntrySelected
    744 ;   call    PART_GetPartitionPointer      ; SI - Pointer to Kernel Entry...
    745 ;   add     si, LocIPT_Name
    746 ;   rep     movsb                         ; Copy KernelName 2 CFG_LinuxLastKernel
    747 ;   ret
    748 BOOTMENU_SetVarsAfterMenu       EndP
     720BOOTMENU_SetVarsAfterMenu   Proc Near
     721        ; No Straight View in here...we got filtered view since BootMenu-Startup...
     722        mov     al, CFG_RememberTimed
     723        test    TimedBootUsed, 1
     724        jnz     BMSVAM_TimedBootUsed
     725        mov     al, CFG_RememberBoot
     726    BMSVAM_TimedBootUsed:
     727        or      al, al
     728        jz      BMSVAM_DontRememberBoot
     729        mov     dl, Menu_EntrySelected
     730        call    PART_ConvertToStraight        ; CFG_PartLast is non-filtered
     731        ;~ mov     di, offset CFG_LinuxLastKernel
     732        ;~ mov     cx, 11
     733        cmp     dl, 0FDh                      ; Dont Remember on Floppy/CD-ROM/etc.
     734        ja      BMSVAM_DontRememberBoot
     735        ;   je      BMSVAM_RememberKernelBoot     ; but remember Kernel-Bootings...
     736        mov     CFG_PartLast, dl              ; Remember partition in CFG_PartLast
     737        ;~ mov     al, ' '
     738        ;~ rep     stosb                         ; SPACE out CFG_LinuxLastKernel
     739    BMSVAM_DontRememberBoot:
     740        ret
     741
     742    ;~ BMSVAM_RememberKernelBoot:
     743        ;~ mov     dl, Menu_EntrySelected
     744        ;~ call    PART_GetPartitionPointer      ; SI - Pointer to Kernel Entry...
     745        ;~ add     si, LocIPT_Name
     746        ;~ rep     movsb                         ; Copy KernelName 2 CFG_LinuxLastKernel
     747        ;~ ret
     748BOOTMENU_SetVarsAfterMenu   EndP
     749
     750
     751
    749752
    750753; Actually does the Boot-Menu Interaction
    751754; Sets Carry-flag, if Setup is to be entered, otherwise system shall get booted
    752755; On boot: Fills out some variables (like Menu_EntrySelected), when Booting
    753 BOOTMENU_Execute                Proc Near   Uses es di
    754    ; Finds out, where to place the bar at first...
    755    mov     dl, Menu_EntryDefault
    756    test    CFG_RememberBoot, 1
    757    jnz     BME_RememberMode
    758    test    CFG_RememberTimed, 1
    759    jz      BME_ForgetMode
    760   BME_RememberMode:
    761    mov     dl, Menu_EntryLast
    762   BME_ForgetMode:
    763    ; Got it, so display bar...
    764    mov     dh, dl
    765 
    766    ;call  SOUND_Beep
    767 
    768    call    BOOTMENU_BuildChoiceBar       ; DH - Active, DL - Last Active
    769 
    770    ;call  SOUND_Beep
    771 
    772    call    SOUND_PreBootMenu
    773 
    774 
    775   BME_MainLoop:
    776 
    777      ;call    VideoIO_DBG_WriteString2    ; Rousseau
    778 
    779    test    TimedBootEnable, 1
    780    jz      BME_NoTimedBoot
    781       ; ------------------------------------------------ TIMED BOOT
    782       push    ax
    783       push    dx
    784          call    TIMER_GetTicCount
    785          mov     dx, word ptr [TimedTimeOut]
    786          sub     dx, ax
    787          mov     ax, dx
    788          call    TIMER_TranslateTicToSec ; DX - Timertics till ByeBye
    789          cmp     al, TimedSecondLeft     ; -> AL - Seconds till ByeBye
    790          je      BME_NoFixSecond
    791          mov     TimedSecondLeft, al
    792          call    BOOTMENU_BuildTimedBootText ; Display Timed-Boot-Text
    793         BME_NoFixSecond:
    794          cmp     al, 0
    795          jne     BME_NoTimeOut
    796       pop     dx
    797       pop     ax
    798       mov     dl, Menu_EntryDefault
    799       and     CFG_TimedBootLast, 1
    800       jz      BME_TimedBootDefault
    801       mov     dl, Menu_EntryLast
    802      BME_TimedBootDefault:
    803       mov     Menu_EntrySelected, dl        ; Just boot default partition
    804       mov     TimedBootUsed, 1           ; set flag...
    805       clc                                ; Boot-Now!
    806       ret
    807 
    808      BME_NoTimeOut:
    809       pop     dx
    810       pop     ax
    811   BME_NoTimedBoot:
    812    ; ------------------------------------------------ FLOPPY-NAME TIMER
    813    test    CFG_FloppyBootGetTimer, 1
    814    jz      BME_NoFloppyNameTimer
    815       ; Wait 2 Seconds everytime
    816       push    ax
    817       push    dx
    818          call    TIMER_GetTicCount
    819          cmp     dx, wptr [FloppyGetNameTimer+2]
    820          ja      BME_ExpiredGetFloppy
    821          cmp     ax, wptr [FloppyGetNameTimer+0]
    822          jb      BME_NoFloppyNameExpired
    823         BME_ExpiredGetFloppy:
    824          call    BOOTMENU_ResetGetFloppy
    825       pop     dx
    826       pop     ax
    827       jmp     BME_RefreshFloppyName
    828         BME_NoFloppyNameExpired:
    829       pop     dx
    830       pop     ax
    831   BME_NoFloppyNameTimer:
    832    ; ------------------------------------------------ KEYBOARD
    833    push    dx
    834       mov     ah, 1
    835       int     16h
    836    pop     dx
    837    jnz     BME_KeyAvailable
    838    jmp     BME_MainLoop
    839 
    840   BME_RefreshFloppyName:
    841    test    CFG_IncludeFloppy, 1
    842    jz      BME_NoRefreshFloppyName
    843       test    CFG_FloppyBootGetName, 1
    844       jz      BME_NoRefreshFloppyName
    845          call    DriveIO_UpdateFloppyName
    846          call    BOOTMENU_RefreshPartitionText
    847          call    BOOTMENU_BuildChoiceBar ; Redisplay the selection-bar
    848   BME_NoRefreshFloppyName:
    849    jmp     BME_MainLoop
    850 
    851   BME_KeyAvailable:
    852    push    dx
    853       mov     ah, 0
    854       int     16h
    855    pop     dx
    856    cmp     ah, Keys_ENTER
    857    je      BME_KeyEnter
    858    cmp     ah, Keys_F10
    859    je      BME_KeyF10
    860    cmp     ah, Keys_Delete
    861    je      BME_KeyDelete
    862    cmp     ah, Keys_ESC
    863    je      BME_KeyESC
    864    ; Upper Keys do not fall under Timed Boot Key Handling
    865    test    TimedBootEnable, 1
    866    je      BME_NoTimedKeyHandling
    867       cmp     CFG_TimedKeyHandling, 1
    868       jb      BME_NoTimedKeyHandling     ; = 0
    869       je      BME_ResetTimedBoot         ; = 1
    870       mov     al, TimedBootEnable        ; = 2
    871       xor     al, 1                      ; Flip Flop Switch :]
    872       mov     TimedBootEnable, al
    873      BME_ResetTimedBoot:
    874       push    dx
    875          call    BOOTMENU_ResetTimedBoot     ; Reset Timer
    876          call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
    877       pop     dx
    878   BME_NoTimedKeyHandling:
    879    cmp     ah, Keys_TAB
    880    je      BME_KeyTAB
    881    cmp     ah, Keys_Up
    882    je      BME_KeyUp
    883    cmp     ah, Keys_Down
    884    je      BME_KeyDown
    885    jmp     BME_MainLoop
    886 
    887   BME_KeyUp:
    888    dec     dh
    889    call    BOOTMENU_BuildChoiceBar       ; DH - Active, DL - Last Active
    890    jmp     BME_MainLoop
    891 
    892   BME_KeyDown:
    893    inc     dh
    894    call    BOOTMENU_BuildChoiceBar       ; DH - Active, DL - Last Active
    895    jmp     BME_MainLoop
    896 
    897   BME_KeyEnter:
    898    mov     Menu_EntrySelected, dl
    899    mov     TimedBootUsed, 0              ; reset flag...
    900    clc                                   ; Boot-Now!
    901    ret
    902 
    903   BME_KeyF10:
    904    mov     al, Keys_Flags_EnterSetup
    905    mov     SETUP_KeysOnEntry, al         ; Simulate user wants to enter setup
    906    stc                                   ; Go Re-Enter Setup
    907    ret
    908 
    909   BME_KeyDelete:
    910    call    SOUND_ExecuteBoot
    911    call    APM_TurnOffComputer
    912    jmp     BME_MainLoop
    913 
    914   BME_KeyESC:
    915    mov     al, TimedBootEnable
    916    xor     al, 1                         ; Flip Flop Switch :]
    917    mov     TimedBootEnable, al
    918    push    dx
    919       call    BOOTMENU_ResetTimedBoot     ; Reset Timer
    920       call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
    921    pop     dx
    922    jmp     BME_MainLoop
    923 
    924   BME_KeyTAB:
    925    push    dx
    926       test    CFG_CooperBars, 1
    927       jnz     BME_KeyTAB_ShowFX
    928       mov     ax, 0501h                  ; Go To Page 1 -> BIOS POST crap
    929       int     10h
    930       mov     ah, 0
    931       int     16h                        ; Wait for any key
    932       call    BOOTMENU_ResetTimedBoot     ; Reset Timer
    933       call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
    934       mov     ax, 0500h                  ; Go Back to Page 0
    935       int     10h
    936    pop     dx
    937    jmp     BME_MainLoop
    938      BME_KeyTAB_ShowFX:
    939       pusha
    940          mov     ax, VideoIO_Page1
    941          mov     bx, VideoIO_Page0
    942          mov     dx, 160
    943          xor     di, di
    944          call    FX_InterleaveCopy
    945          call    FX_ScrollScreenLeft
    946          mov     ah, 0
    947          int     16h                        ; Wait for any key
    948          call    BOOTMENU_ResetTimedBoot     ; Reset Timer
    949          call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
    950          call    FX_ScrollScreenRight
    951          call    FX_EndScreenInternalCleanUp
    952          call    BOOTMENU_ResetTimedBoot    ; Reset Timer again...
    953       popa
    954    pop     dx
    955    jmp     BME_MainLoop
     756BOOTMENU_Execute    Proc Near   Uses es di
     757        ; Finds out, where to place the bar at first...
     758        mov     dl, Menu_EntryDefault
     759        test    CFG_RememberBoot, 1
     760        jnz     BME_RememberMode
     761        test    CFG_RememberTimed, 1
     762        jz      BME_ForgetMode
     763    BME_RememberMode:
     764        mov     dl, Menu_EntryLast
     765    BME_ForgetMode:
     766        ; Got it, so display bar...
     767        mov     dh, dl
     768
     769        ;~ call    SOUND_Beep
     770
     771        call    BOOTMENU_BuildChoiceBar       ; DH - Active, DL - Last Active
     772
     773        ;~ call    SOUND_Beep
     774
     775        call    SOUND_PreBootMenu
     776
     777
     778    BME_MainLoop:
     779
     780        ;call    VideoIO_DBG_WriteString2    ; Rousseau
     781
     782        test    TimedBootEnable, 1
     783        jz      BME_NoTimedBoot
     784        ; ------------------------------------------------ TIMED BOOT
     785        push    ax
     786        push    dx
     787        call    TIMER_GetTicCount
     788        mov     dx, word ptr [TimedTimeOut]
     789        sub     dx, ax
     790        mov     ax, dx
     791        call    TIMER_TranslateTicToSec ; DX - Timertics till ByeBye
     792        cmp     al, TimedSecondLeft     ; -> AL - Seconds till ByeBye
     793        je      BME_NoFixSecond
     794        mov     TimedSecondLeft, al
     795        call    BOOTMENU_BuildTimedBootText ; Display Timed-Boot-Text
     796    BME_NoFixSecond:
     797        cmp     al, 0
     798        jne     BME_NoTimeOut
     799        pop     dx
     800        pop     ax
     801        mov     dl, Menu_EntryDefault
     802        and     CFG_TimedBootLast, 1
     803        jz      BME_TimedBootDefault
     804        mov     dl, Menu_EntryLast
     805    BME_TimedBootDefault:
     806        mov     Menu_EntrySelected, dl        ; Just boot default partition
     807        mov     TimedBootUsed, 1           ; set flag...
     808        clc                                ; Boot-Now!
     809        ret
     810
     811    BME_NoTimeOut:
     812        pop     dx
     813        pop     ax
     814    BME_NoTimedBoot:
     815        ; ------------------------------------------------ FLOPPY-NAME TIMER
     816        test    CFG_FloppyBootGetTimer, 1
     817        jz      BME_NoFloppyNameTimer
     818        ; Wait 2 Seconds everytime
     819        push    ax
     820        push    dx
     821        call    TIMER_GetTicCount
     822        cmp     dx, wptr [FloppyGetNameTimer+2]
     823        ja      BME_ExpiredGetFloppy
     824        cmp     ax, wptr [FloppyGetNameTimer+0]
     825        jb      BME_NoFloppyNameExpired
     826    BME_ExpiredGetFloppy:
     827        call    BOOTMENU_ResetGetFloppy
     828        pop     dx
     829        pop     ax
     830        jmp     BME_RefreshFloppyName
     831    BME_NoFloppyNameExpired:
     832        pop     dx
     833        pop     ax
     834    BME_NoFloppyNameTimer:
     835        ; ------------------------------------------------ KEYBOARD
     836        push    dx
     837        mov     ah, 1
     838        int     16h
     839        pop     dx
     840        jnz     BME_KeyAvailable
     841        jmp     BME_MainLoop
     842
     843    BME_RefreshFloppyName:
     844        test    CFG_IncludeFloppy, 1
     845        jz      BME_NoRefreshFloppyName
     846        test    CFG_FloppyBootGetName, 1
     847        jz      BME_NoRefreshFloppyName
     848        call    DriveIO_UpdateFloppyName
     849        call    BOOTMENU_RefreshPartitionText
     850        call    BOOTMENU_BuildChoiceBar ; Redisplay the selection-bar
     851    BME_NoRefreshFloppyName:
     852        jmp     BME_MainLoop
     853
     854        BME_KeyAvailable:
     855        push    dx
     856        mov     ah, 0
     857        int     16h
     858        pop     dx
     859        cmp     ah, Keys_ENTER
     860        je      BME_KeyEnter
     861        cmp     ah, Keys_F10
     862        je      BME_KeyF10
     863        cmp     ah, Keys_Delete
     864        je      BME_KeyDelete
     865        cmp     ah, Keys_ESC
     866        je      BME_KeyESC
     867        ; Upper Keys do not fall under Timed Boot Key Handling
     868        test    TimedBootEnable, 1
     869        je      BME_NoTimedKeyHandling
     870        cmp     CFG_TimedKeyHandling, 1
     871        jb      BME_NoTimedKeyHandling     ; = 0
     872        je      BME_ResetTimedBoot         ; = 1
     873        mov     al, TimedBootEnable        ; = 2
     874        xor     al, 1                      ; Flip Flop Switch :]
     875        mov     TimedBootEnable, al
     876    BME_ResetTimedBoot:
     877        push    dx
     878        call    BOOTMENU_ResetTimedBoot     ; Reset Timer
     879        call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
     880        pop     dx
     881    BME_NoTimedKeyHandling:
     882        cmp     ah, Keys_TAB
     883        je      BME_KeyTAB
     884        cmp     ah, Keys_Up
     885        je      BME_KeyUp
     886        cmp     ah, Keys_Down
     887        je      BME_KeyDown
     888        jmp     BME_MainLoop
     889
     890    BME_KeyUp:
     891        dec     dh
     892        call    BOOTMENU_BuildChoiceBar       ; DH - Active, DL - Last Active
     893        jmp     BME_MainLoop
     894
     895    BME_KeyDown:
     896        inc     dh
     897        call    BOOTMENU_BuildChoiceBar       ; DH - Active, DL - Last Active
     898        jmp     BME_MainLoop
     899
     900    BME_KeyEnter:
     901        mov     Menu_EntrySelected, dl
     902        mov     TimedBootUsed, 0              ; reset flag...
     903        clc                                   ; Boot-Now!
     904        ret
     905
     906    BME_KeyF10:
     907        mov     al, Keys_Flags_EnterSetup
     908        mov     SETUP_KeysOnEntry, al         ; Simulate user wants to enter setup
     909        stc                                   ; Go Re-Enter Setup
     910        ret
     911
     912    BME_KeyDelete:
     913        call    SOUND_ExecuteBoot
     914        call    APM_TurnOffComputer
     915        jmp     BME_MainLoop
     916
     917    BME_KeyESC:
     918        mov     al, TimedBootEnable
     919        xor     al, 1                         ; Flip Flop Switch :]
     920        mov     TimedBootEnable, al
     921        push    dx
     922        call    BOOTMENU_ResetTimedBoot     ; Reset Timer
     923        call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
     924        pop     dx
     925        jmp     BME_MainLoop
     926
     927    BME_KeyTAB:
     928        push    dx
     929        test    CFG_CooperBars, 1
     930        jnz     BME_KeyTAB_ShowFX
     931        mov     ax, 0501h                  ; Go To Page 1 -> BIOS POST crap
     932        int     10h
     933        mov     ah, 0
     934        int     16h                        ; Wait for any key
     935        call    BOOTMENU_ResetTimedBoot     ; Reset Timer
     936        call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
     937        mov     ax, 0500h                  ; Go Back to Page 0
     938        int     10h
     939        pop     dx
     940        jmp     BME_MainLoop
     941    BME_KeyTAB_ShowFX:
     942        pusha
     943        mov     ax, VideoIO_Page1
     944        mov     bx, VideoIO_Page0
     945        mov     dx, 160
     946        xor     di, di
     947        call    FX_InterleaveCopy
     948        call    FX_ScrollScreenLeft
     949        mov     ah, 0
     950        int     16h                        ; Wait for any key
     951        call    BOOTMENU_ResetTimedBoot     ; Reset Timer
     952        call    BOOTMENU_BuildTimedBootText ; Refresh TimedBootText
     953        call    FX_ScrollScreenRight
     954        call    FX_EndScreenInternalCleanUp
     955        call    BOOTMENU_ResetTimedBoot    ; Reset Timer again...
     956        popa
     957        pop     dx
     958        jmp     BME_MainLoop
    956959BOOTMENU_Execute                EndP
    957960
    958961; Resettet den TimedBoot Timer...
    959 BOOTMENU_ResetTimedBoot         Proc Near   Uses ax
    960    call    TIMER_GetTicCount
    961    add     ax, CFG_TimedDelay
    962    adc     dx, 0
    963    mov     wptr [TimedTimeOut], ax
    964    mov     wptr [TimedTimeOut+2], dx
    965    ret
    966 BOOTMENU_ResetTimedBoot         EndP
     962BOOTMENU_ResetTimedBoot     Proc Near   Uses ax
     963        call    TIMER_GetTicCount
     964        add     ax, CFG_TimedDelay
     965        adc     dx, 0
     966        mov     wptr [TimedTimeOut], ax
     967        mov     wptr [TimedTimeOut+2], dx
     968        ret
     969BOOTMENU_ResetTimedBoot     EndP
    967970
    968971; Resettet den Floppy-Get-Name Timer...
    969 BOOTMENU_ResetGetFloppy         Proc Near   Uses ax
    970    call    TIMER_GetTicCount
    971    add     ax, 36                      ; 18*2 -> 2 seconds
    972    adc     dx, 0
    973    mov     word ptr [FloppyGetNameTimer], ax
    974    mov     word ptr [FloppyGetNameTimer+2], dx
    975    ret
    976 BOOTMENU_ResetGetFloppy         EndP
     972BOOTMENU_ResetGetFloppy     Proc Near   Uses ax
     973        call    TIMER_GetTicCount
     974        add     ax, 36                      ; 18*2 -> 2 seconds
     975        adc     dx, 0
     976        mov     word ptr [FloppyGetNameTimer], ax
     977        mov     word ptr [FloppyGetNameTimer+2], dx
     978        ret
     979BOOTMENU_ResetGetFloppy     EndP
  • trunk/BOOTCODE/REGULAR/CONV.ASM

    r30 r43  
    3636; Out:         AX - two (Hex) Ascii digits
    3737; Destroyed:   none
    38 CONV_BinToAsc  Proc  Near
    39       mov      ah,al                      ; Save value to process high nibble later
    40       and      al,0fh                     ; Mask low nibble
    41       add      al,'0'                     ; Convert to ASCII
    42       cmp      al,'9'                     ; Is it in the range of '0' - '9' ?
    43       jbe      CONV_BinToAsc_DecDigit_1   ; Yep, done
    44       add      al,7                       ; Nope, adjust to Hex Ascii
    45    CONV_BinToAsc_DecDigit_1:
    46       xchg     al,ah                      ; Exchange with saved value to process high nibble
    47       shr      al,4                         ; Move high nibble to low nibble (80186+)
    48       ;shr      al
    49       ;shr      al
    50       ;shr      al
    51       add      al,'0'                     ; Convert to ASCII
    52       cmp      al,'9'                     ; Is it in the range of '0' - '9' ?
    53       jbe      CONV_BinToAsc_DecDigit_2
    54       add      al,7                       ; Nope, adjust to Hex Ascii
    55    CONV_BinToAsc_DecDigit_2:
    56       xchg     al,ah                      ; Correct order, AX now contains the two (hex) digits
    57       ret
    58 CONV_BinToAsc  Endp
     38CONV_BinToAsc   Proc  Near
     39        mov     ah,al                      ; Save value to process high nibble later
     40        and     al,0fh                     ; Mask low nibble
     41        add     al,'0'                     ; Convert to ASCII
     42        cmp     al,'9'                     ; Is it in the range of '0' - '9' ?
     43        jbe     CONV_BinToAsc_DecDigit_1   ; Yep, done
     44        add     al,7                       ; Nope, adjust to Hex Ascii
     45    CONV_BinToAsc_DecDigit_1:
     46        xchg    al,ah                      ; Exchange with saved value to process high nibble
     47        shr     al,4                       ; Move high nibble to low nibble (80186+)
     48        ;shr     al
     49        ;shr     al
     50        ;shr     al
     51        add     al,'0'                     ; Convert to ASCII
     52        cmp     al,'9'                     ; Is it in the range of '0' - '9' ?
     53        jbe     CONV_BinToAsc_DecDigit_2
     54        add     al,7                       ; Nope, adjust to Hex Ascii
     55    CONV_BinToAsc_DecDigit_2:
     56        xchg    al,ah                      ; Correct order, AX now contains the two (hex) digits
     57        ret
     58CONV_BinToAsc   Endp
    5959
    6060
     
    6666; Out:         AL - char printed (could be dot)
    6767; Destroyed:   none
    68 CONV_ConvertToPrintable    Proc  Near
    69       cmp      al,20h
    70       jb       CONV_ConvertToPrintable_NP       ; Below space, so not printable
    71       cmp      al,7eh                           ; Above tilde, so not printable
    72       ja       CONV_ConvertToPrintable_NP
    73       jmp      CONV_ConvertToPrintable_End   ; Go output it
    74    CONV_ConvertToPrintable_NP:
    75       mov      al,ah                            ; Use the replacement character
    76    CONV_ConvertToPrintable_End:
    77       ret
    78 CONV_ConvertToPrintable    EndP
     68CONV_ConvertToPrintable     Proc  Near
     69        cmp     al,20h
     70        jb      CONV_ConvertToPrintable_NP       ; Below space, so not printable
     71        cmp     al,7eh                           ; Above tilde, so not printable
     72        ja      CONV_ConvertToPrintable_NP
     73        jmp     CONV_ConvertToPrintable_End   ; Go output it
     74    CONV_ConvertToPrintable_NP:
     75        mov     al,ah                            ; Use the replacement character
     76    CONV_ConvertToPrintable_End:
     77        ret
     78CONV_ConvertToPrintable     EndP
    7979
    8080
     
    9090;              ZF=1 if upper 32-bits are zero (LBA32)
    9191; Destroyed:   none
    92 CONV_CHS2LBA   Proc  Near
    93       local    req_cyl:dword
    94       local    req_head:word
    95       local    req_sec:word
    96       local    lba:qword
     92CONV_CHS2LBA    Proc  Near
     93        local   req_cyl:dword
     94        local   req_head:word
     95        local   req_sec:word
     96        local   lba:qword
    9797
    98       ; Save parameters
    99       mov      word ptr [req_cyl],ax      ; save low cyl
    100       mov      word ptr [req_cyl+2],dx    ; save high cyl
    101       mov      [req_head],bx              ; save head
    102       test     cx,cx
    103       jnz      CONV_CHS2LBA_sec_ok
    104       mov      cx,1                       ; cannot have sector 0, so change to 1
    105    CONV_CHS2LBA_sec_ok:
    106       dec      cx                         ; prepare for calculation later
    107       mov      [req_sec],cx               ; save sec
     98        ; Save parameters
     99        mov     word ptr [req_cyl],ax      ; save low cyl
     100        mov     word ptr [req_cyl+2],dx    ; save high cyl
     101        mov     [req_head],bx              ; save head
     102        test    cx,cx
     103        jnz     CONV_CHS2LBA_sec_ok
     104        mov     cx,1                       ; cannot have sector 0, so change to 1
     105    CONV_CHS2LBA_sec_ok:
     106        dec     cx                         ; prepare for calculation later
     107        mov     [req_sec],cx               ; save sec
    108108
    109       ; Clear return value
    110       xor      ax,ax
    111       mov      word ptr [lba+6],ax
    112       mov      word ptr [lba+4],ax
    113       mov      word ptr [lba+2],ax
    114       mov      word ptr [lba+0],ax
     109        ; Clear return value
     110        xor     ax,ax
     111        mov     word ptr [lba+6],ax
     112        mov     word ptr [lba+4],ax
     113        mov     word ptr [lba+2],ax
     114        mov     word ptr [lba+0],ax
    115115
    116       ; Cyls * Heads
    117       mov      dx,word ptr [req_cyl+2]    ; high word of requested cylinder
    118       mov      ax,word ptr [req_cyl+0]    ; low word of requested cylinder
    119       xor      bx,bx                      ; zero for 32-bit math
    120       mov      cx,word ptr [BIOS_Heads]   ; number of heads
    121       call     MATH_Mul32
     116        ; Cyls * Heads
     117        mov     dx,word ptr [req_cyl+2]    ; high word of requested cylinder
     118        mov     ax,word ptr [req_cyl+0]    ; low word of requested cylinder
     119        xor     bx,bx                      ; zero for 32-bit math
     120        mov     cx,word ptr [BIOS_Heads]   ; number of heads
     121        call    MATH_Mul32
    122122
    123       ; WE DISCARD HIGH 32-BITS HERE BECAUSE CALCULATION
    124       ; WOULD REQUIRE 64-bits MATH.
    125       ; THIS WILL BE FIXED LATER.
    126       ; THIS MEANS LBA >2TiB IS NOT SUPPORTED YET.
     123        ; WE DISCARD HIGH 32-BITS HERE BECAUSE CALCULATION
     124        ; WOULD REQUIRE 64-bits MATH.
     125        ; THIS WILL BE FIXED LATER.
     126        ; THIS MEANS LBA >2TiB IS NOT SUPPORTED YET.
    127127
    128       ; Add requested head
    129       add      ax,[req_head]
    130       adc      dx,0
    131       ;adc      cx,0
    132       ;adc      bx,0
     128        ; Add requested head
     129        add     ax,[req_head]
     130        adc     dx,0
     131        ;adc     cx,0
     132        ;adc     bx,0
    133133
    134       ; * Secs
    135       xor      bx,bx
    136       mov      cx,word ptr [TrueSecs]
    137       call     MATH_Mul32
     134        ; * Secs
     135        xor     bx,bx
     136        mov     cx,word ptr [TrueSecs]       ; Implicitly address disk 80h
     137        call    MATH_Mul32
    138138
    139       ; Add requested sec
    140       add      ax,[req_sec]
    141       adc      dx,0
    142       ;adc      cx,0
    143       ;adc      bx,0
     139        ; Add requested sec
     140        add     ax,[req_sec]
     141        adc     dx,0
     142        ;adc     cx,0
     143        ;adc     bx,0
    144144
    145       xor      bx,bx
    146       xor      cx,cx
     145        xor     bx,bx
     146        xor     cx,cx
    147147
    148       ; Set ZF if high upper 32-bits are zero
    149       or       bx,cx
     148        ; Set ZF if high upper 32-bits are zero
     149        or      bx,cx
    150150
    151151      ret
    152 CONV_CHS2LBA   EndP
     152CONV_CHS2LBA    EndP
    153153
    154154
    155 CONV_LBA2CYLS  Proc  Near
     155CONV_LBA2CYLS   Proc  Near
     156        ret
     157CONV_LBA2CYLS   Endp
    156158
    157159
    158       ret
    159 CONV_LBA2CYLS  Endp
    160 
    161160; Convert a character to upper-case
    162 CONV_ToUpper   Proc  Near
    163       cmp      al,'a'
    164       jb       CONV_ToUpperSkip1
    165       cmp      al,'z'
    166       ja       CONV_ToUpperSkip1
    167       sub      al,20h
    168    CONV_ToUpperSkip1:
    169       ret
     161CONV_ToUpper    Proc  Near
     162        cmp     al,'a'
     163        jb      CONV_ToUpperSkip1
     164        cmp     al,'z'
     165        ja      CONV_ToUpperSkip1
     166        sub     al,20h
     167    CONV_ToUpperSkip1:
     168        ret
    170169CONV_ToUpper   EndP
  • trunk/BOOTCODE/REGULAR/DEBUG.ASM

    r30 r43  
    3636ENDIF
    3737
    38 
    39 
    40 ; Initialize the com-port
    41 ; In:          AL - com-port, 0=disable com-port logging, 1=com1 etc. (max 4)
    42 ;              AH - initialization parameters (see below)
    43 ; Out:         AX - line status
    44 DEBUG_Dump1             Proc  Near
    45       pushf
    46       pusha
    47 
    48       ; Hello message
    49       mov      si, offset AuxIOHello
    50       call     AuxIO_Print
    51 
    52       ; Build Date
    53       mov      si, offset BUILD_DATE
    54       call     AuxIO_Print
    55 
    56       ; Start new line
    57       call     AuxIO_TeletypeNL
    58       Call     AuxIO_TeletypeNL
    59 
    60       ; Msg check math-module
    61       mov      si,offset db_checkmath
    62       call     AuxIO_Print
    63 
    64       ; Output hex-word
    65       mov      ax,0BABEh
    66       call     AuxIO_TeletypeHexWord
    67 
    68       mov      al,' '
    69       call     AuxIO_Teletype
    70       mov      al,'*'
    71       call     AuxIO_Teletype
    72       mov      al,' '
    73       call     AuxIO_Teletype
    74 
    75       ; Output hex-word
    76       mov      ax,0BABEh
    77       call     AuxIO_TeletypeHexWord
    78 
    79       mov      al,' '
    80       call     AuxIO_Teletype
    81       mov      al,'='
    82       call     AuxIO_Teletype
    83       mov      al,' '
    84       call     AuxIO_Teletype
    85 
    86       mov      ax,0BABEh
    87       mul      ax
    88       call     AuxIO_TeletypeHexDWord
    89 
    90       ; Start new line
    91       call     AuxIO_TeletypeNL
    92 
    93 
    94       ; Output hex-dword
    95       mov      dx,0DEADh
    96       mov      ax,0FACEh
    97       call     AuxIO_TeletypeHexDWord
    98 
    99       mov      al,' '
    100       call     AuxIO_Teletype
    101       mov      al,'*'
    102       call     AuxIO_Teletype
    103       mov      al,' '
    104       call     AuxIO_Teletype
    105 
    106       ; Output hex-dword
    107       mov      dx,0DEADh
    108       mov      ax,0FACEh
    109       call     AuxIO_TeletypeHexDWord
    110 
    111       mov      al,' '
    112       call     AuxIO_Teletype
    113       mov      al,'='
    114       call     AuxIO_Teletype
    115       mov      al,' '
    116       call     AuxIO_Teletype
    117 
    118 
    119 
    120       mov      bx,0DEADh
    121       mov      cx,0FACEh
    122       mov      dx,0DEADh
    123       mov      ax,0FACEh
    124       call     MATH_Mul32
    125       call     AuxIO_TeletypeHexQWord
    126 
    127 
    128       ; Start new line
    129       call     AuxIO_TeletypeNL
    130 
    131 
    132       ; Start new line
    133       call     AuxIO_TeletypeNL
    134 
    135 
    136       ; BIOS cyls
    137 ;      mov      dx,word ptr [BIOS_Cyls+02]
    138 ;      mov      ax,word ptr [BIOS_Cyls+00]
    139 ;      call     AuxIO_TeletypeHexDWord
    140 ;      call     AuxIO_TeletypeNL
    141 
    142       ; BIOS heads
    143 ;      mov      dx,word ptr [BIOS_Heads+02]
    144 ;      mov      ax,word ptr [BIOS_Heads+00]
    145 ;      call     AuxIO_TeletypeHexDWord
    146 ;      call     AuxIO_TeletypeNL
    147 
    148       ; BIOS secs
    149 ;      mov      dx,word ptr [BIOS_Secs+02]
    150 ;      mov      ax,word ptr [BIOS_Secs+00]
    151 ;      call     AuxIO_TeletypeHexDWord
    152 ;      call     AuxIO_TeletypeNL
    153 
    154       ; Bytes per sector
    155 ;      mov      ax,[BIOS_Bytes]
    156 ;      call     AuxIO_TeletypeHexWord
    157 ;      call     AuxIO_TeletypeNL
    158 
    159       ; Total secs
    160 ;      mov      bx, word ptr [BIOS_TotalSecs+06]
    161 ;      mov      cx, word ptr [BIOS_TotalSecs+04]
    162 ;      mov      dx, word ptr [BIOS_TotalSecs+02]
    163 ;      mov      ax, word ptr [BIOS_TotalSecs+00]
    164 ;      call     AuxIO_TeletypeHexDWord
    165 ;      call     AuxIO_TeletypeNL
    166 
    167       ; CHS to LBA
    168 ;      mov      dx,1
    169 ;      mov      ax,29e5h
    170 ;      mov      bx,23h
    171 ;      mov      cx,9h
    172 ;      call     CONV_CHS2LBA
    173 ;      call     AuxIO_TeletypeHexDWord
    174 ;      call     AuxIO_TeletypeNL
    175 
    176 
    177       popa
    178       popf
    179       ret
    180 DEBUG_Dump1             EndP
    181 
    182 
    183 
    184 ;DEBUG_Dump2             Proc  Near
    185 ;      pushf
    186 ;      pusha
    187 
    188 
    189 ;      call     AuxIO_TeletypeNL
    190 ;      call     AuxIO_TeletypeNL
    191 
    192 
    193 ;      mov      si,offset db_config
    194 ;      call     AuxIO_Print
    195 
    196 ;      mov      si,offset db_cfgparts
    197 ;      call     AuxIO_Print
    198 ;      mov      al,[CFG_Partitions]
    199 ;      call     AuxIO_TeletypeHexByte
    200 ;      call     AuxIO_TeletypeNL
    201 
    202 ;      mov      si,offset db_cfgpartdef
    203 ;      call     AuxIO_Print
    204 ;      mov      al,[CFG_PartDefault]
    205 ;      call     AuxIO_TeletypeHexByte
    206 ;      call     AuxIO_TeletypeNL
    207 
    208 ;      mov      si,offset db_cfgpartlast
    209 ;      call     AuxIO_Print
    210 ;      mov      al,[CFG_PartLast]
    211 ;      call     AuxIO_TeletypeHexByte
    212 ;      call     AuxIO_TeletypeNL
    213 ;      call     AuxIO_TeletypeNL
    214 
    215 
    216 
    217 ;      mov      si,offset db_vars
    218 ;      call     AuxIO_Print
    219 
    220 ;      mov      si,offset db_newpart
    221 ;      call     AuxIO_Print
    222 ;      mov      si,offset NewPartTable
    223 ;      call     AuxIO_DumpSector
    224 ;      call     AuxIO_TeletypeNL
    225 ;      add      si,512
    226 ;      call     AuxIO_DumpSector
    227 ;      call     AuxIO_TeletypeNL
    228 ;      call     AuxIO_TeletypeNL
    229 
    230 ;      mov      si,offset db_newhide
    231 ;      call     AuxIO_Print
    232 ;      mov      si,offset NewHidePartTable
    233 ;      call     AuxIO_DumpSector
    234 ;      call     AuxIO_TeletypeNL
    235 ;      add      si,512
    236 ;      call     AuxIO_DumpSector
    237 ;      call     AuxIO_TeletypeNL
    238 ;      call     AuxIO_TeletypeNL
    239 
    240 ;      mov      si,offset db_dletters
    241 ;      call     AuxIO_Print
    242 ;      mov      si,offset NewDriveLetters
    243 ;      call     AuxIO_DumpParagraph
    244 ;      call     AuxIO_TeletypeNL
    245 ;      add      si,16
    246 ;      call     AuxIO_DumpParagraph
    247 ;      call     AuxIO_TeletypeNL
    248 ;      call     AuxIO_TeletypeNL
    249 
    250 ;      mov      si,offset db_tmpec
    251 ;      call     AuxIO_Print
    252 ;      mov      si,offset TmpSector
    253 ;      call     AuxIO_DumpSector
    254 ;      call     AuxIO_TeletypeNL
    255 ;      call     AuxIO_TeletypeNL
    256 
    257 ;      mov      si,offset db_partsec
    258 ;      call     AuxIO_Print
    259 ;      mov      si,offset PartitionSector
    260 ;      call     AuxIO_DumpSector
    261 ;      call     AuxIO_TeletypeNL
    262 ;      call     AuxIO_TeletypeNL
    263 
    264 ;      popa
    265 ;      popf
    266 ;      ret
    267 ;DEBUG_Dump2             EndP
    268 
    269 
    270 
    271 db_mbr:           db "## MBR ##",10,0
    272 db_masterlvm:     db "## MLVMR ##",10,0
    273 
    274 db_checkmath:     db "## CHK MATH ##",10,0
    275 
    276 
    277 db_config:        db '## CFG (DMP2) ##',10,0
    278 db_cfgparts:      db 'CFG_Partitions:',0
    279 db_cfgpartdef:    db 'CFG_PartDefault:',0
    280 db_cfgpartlast:   db 'CFG_PartLast:',0
    281 
    282 
    283 db_vars:          db '## VARS ##',10,0
    284 db_partsec:       db 'PartitionSector:',10,0
    285 ;db_lvmsec:        db 'LVMSector :',10,0
    286 db_tmpec:         db 'TmpSector :',10,0
    287 
    288 db_newpart:       db 'NewPartTable :',10,0
    289 db_newhide:       db 'NewHideTable:',10,0
    290 db_dletters:      db 'NewDriveLetters:',10,0
    291 
    292 ;db_partsize:      db 'PartitionSizeTable:',10,0
    293 ;db_partpoint:     db 'PartitionPointers:',10,0
    294 ;db_partpointcnt:  db 'PartitionPointerCount:',0
    295 ;db_partxref:      db 'PartitionXref:',10,0
    296 ;db_partvoldl:     db 'PartitionVolumeLetters:',10,0
    297 
    298 ;db_totaldisks:    db 'TotalHarddiscs:',0
    299 ;db_lbaswitchtab:  db 'LBASwitchTable:',10,0
    300 ;db_newparts:      db 'NewPartitions:',0
    301 
    302 ;db_exabspos:      db 'ExtendedAbsPos:',0
    303 ;db_exabsposset:   db 'ExtendedAbsPosSet:',0
    304 
    305 db_curpartloc:    db 'CurPartition_Location:',0
    306 ;db_curiox:        db 'CurIO_UseExtension:',0
    307 
    308 db_curlvmsec:     db 'Current LVM Sector:',0
     38DEBUG_CheckMath Proc    Near
     39        pushf
     40        pusha
     41
     42        ; Msg check math-module
     43        mov     si,offset db_checkmath
     44        call    AuxIO_Print
     45
     46        ; Output hex-word
     47        mov     ax,0BABEh
     48        call    AuxIO_TeletypeHexWord
     49
     50        mov     al,' '
     51        call    AuxIO_Teletype
     52        mov     al,'*'
     53        call    AuxIO_Teletype
     54        mov     al,' '
     55        call    AuxIO_Teletype
     56
     57        ; Output hex-word
     58        mov     ax,0BABEh
     59        call    AuxIO_TeletypeHexWord
     60
     61        mov     al,' '
     62        call    AuxIO_Teletype
     63        mov     al,'='
     64        call    AuxIO_Teletype
     65        mov     al,' '
     66        call    AuxIO_Teletype
     67
     68        mov     ax,0BABEh
     69        mul     ax
     70        call    AuxIO_TeletypeHexDWord
     71
     72        ; Start new line
     73        call    AuxIO_TeletypeNL
     74
     75        ; Output hex-dword
     76        mov     dx,0DEADh
     77        mov     ax,0FACEh
     78        call    AuxIO_TeletypeHexDWord
     79
     80        mov     al,' '
     81        call    AuxIO_Teletype
     82        mov     al,'*'
     83        call    AuxIO_Teletype
     84        mov     al,' '
     85        call     AuxIO_Teletype
     86
     87        ; Output hex-dword
     88        mov     dx,0DEADh
     89        mov     ax,0FACEh
     90        call    AuxIO_TeletypeHexDWord
     91
     92        mov     al,' '
     93        call    AuxIO_Teletype
     94        mov     al,'='
     95        call    AuxIO_Teletype
     96        mov     al,' '
     97        call    AuxIO_Teletype
     98
     99        mov     bx,0DEADh
     100        mov     cx,0FACEh
     101        mov     dx,0DEADh
     102        mov     ax,0FACEh
     103        call    MATH_Mul32
     104        call    AuxIO_TeletypeHexQWord
     105
     106        ; Start new line
     107        call    AuxIO_TeletypeNL
     108
     109        ;~ ; Start new line
     110        call    AuxIO_TeletypeNL
     111
     112        popa
     113        popf
     114
     115        ret
     116DEBUG_CheckMath EndP
     117
     118
     119DEBUG_DumpGeo   Proc
     120        pushf
     121        pusha
     122
     123        ; BIOS cyls
     124        mov     dx,word ptr [BIOS_Cyls+02]
     125        mov     ax,word ptr [BIOS_Cyls+00]
     126        call    AuxIO_TeletypeHexDWord
     127        call    AuxIO_TeletypeNL
     128
     129        ; BIOS heads
     130        mov     dx,word ptr [BIOS_Heads+02]
     131        mov     ax,word ptr [BIOS_Heads+00]
     132        call    AuxIO_TeletypeHexDWord
     133        call    AuxIO_TeletypeNL
     134
     135        ; BIOS secs
     136        mov     dx,word ptr [BIOS_Secs+02]
     137        mov     ax,word ptr [BIOS_Secs+00]
     138        call    AuxIO_TeletypeHexDWord
     139        call    AuxIO_TeletypeNL
     140
     141        ; Bytes per sector
     142        mov     ax,[BIOS_Bytes]
     143        call    AuxIO_TeletypeHexWord
     144        call    AuxIO_TeletypeNL
     145
     146        ; Total secs
     147        mov     bx, word ptr [BIOS_TotalSecs+06]
     148        mov     cx, word ptr [BIOS_TotalSecs+04]
     149        mov     dx, word ptr [BIOS_TotalSecs+02]
     150        mov     ax, word ptr [BIOS_TotalSecs+00]
     151        call    AuxIO_TeletypeHexDWord
     152        call    AuxIO_TeletypeNL
     153
     154        ; CHS to LBA
     155        mov     dx,1
     156        mov     ax,29e5h
     157        mov     bx,23h
     158        mov     cx,9h
     159        call    CONV_CHS2LBA
     160        call     AuxIO_TeletypeHexDWord
     161        call     AuxIO_TeletypeNL
     162
     163        popa
     164        popf
     165
     166        ret
     167DEBUG_DumpGeo   Endp
     168
     169;
     170; Dump information before the menu is displayed.
     171;
     172DEBUG_Dump1     Proc  Near
     173        pushf
     174        pusha
     175
     176        ; Hello message
     177        mov     si, offset AuxIOHello
     178        call    AuxIO_Print
     179
     180        ; Build Date
     181        mov     si, offset BUILD_DATE
     182        call    AuxIO_Print
     183
     184        ; Start new line
     185        call    AuxIO_TeletypeNL
     186        call    AuxIO_TeletypeNL
     187
     188        ;~ call    DEBUG_CheckMath
     189
     190        ;~ call    DEBUG_DumpGeo
     191
     192
     193
     194        popa
     195        popf
     196        ret
     197DEBUG_Dump1     EndP
     198
     199
     200DEBUG_DumpBSSSectors    Proc    Near
     201        pushf
     202        pusha
     203
     204        mov     si, offset [PartitionSector]
     205        call    AuxIO_DumpSector
     206        call    AuxIO_TeletypeNL
     207
     208        mov     si, offset [JfsPBR]
     209        call    AuxIO_DumpSector
     210        call    AuxIO_TeletypeNL
     211
     212        mov     si, offset [LVMSector]
     213        call    AuxIO_DumpSector
     214        call    AuxIO_TeletypeNL
     215
     216        mov     si, offset [TmpSector]
     217        call    AuxIO_DumpSector
     218        call    AuxIO_TeletypeNL
     219
     220        mov     si, offset [NewPartTable]
     221        call    AuxIO_DumpSector
     222        call    AuxIO_TeletypeNL
     223        call    AuxIO_TeletypeNL
     224
     225        popa
     226        popf
     227        ret
     228
     229
     230DEBUG_DumpBSSSectors    EndP
     231
     232
     233
     234
     235;
     236; Dump information before the partition is booted.
     237;
     238DEBUG_Dump2     Proc  Near
     239        pushf
     240        pusha
     241
     242
     243        call    AuxIO_TeletypeNL
     244        call    AuxIO_TeletypeNL
     245
     246
     247        mov     si,offset db_config
     248        call    AuxIO_Print
     249
     250        mov     si,offset db_cfgparts
     251        call    AuxIO_Print
     252        mov     al,[CFG_Partitions]
     253        call    AuxIO_TeletypeHexByte
     254        call    AuxIO_TeletypeNL
     255
     256        mov     si,offset db_cfgpartdef
     257        call    AuxIO_Print
     258        mov     al,[CFG_PartDefault]
     259        call    AuxIO_TeletypeHexByte
     260        call    AuxIO_TeletypeNL
     261
     262        mov     si,offset db_cfgpartlast
     263        call    AuxIO_Print
     264        mov     al,[CFG_PartLast]
     265        call    AuxIO_TeletypeHexByte
     266        call    AuxIO_TeletypeNL
     267        call    AuxIO_TeletypeNL
     268
     269
     270
     271        mov     si,offset db_vars
     272        call    AuxIO_Print
     273
     274        mov     si,offset db_newpart
     275        call    AuxIO_Print
     276        mov     si,offset NewPartTable
     277        call    AuxIO_DumpSector
     278        call    AuxIO_TeletypeNL
     279        add     si,512
     280        call    AuxIO_DumpSector
     281        call    AuxIO_TeletypeNL
     282        call    AuxIO_TeletypeNL
     283
     284        mov     si,offset db_newhide
     285        call    AuxIO_Print
     286        mov     si,offset NewHidePartTable
     287        call    AuxIO_DumpSector
     288        call    AuxIO_TeletypeNL
     289        add     si,512
     290        call    AuxIO_DumpSector
     291        call    AuxIO_TeletypeNL
     292        call    AuxIO_TeletypeNL
     293
     294        mov     si,offset db_dletters
     295        call    AuxIO_Print
     296        mov     si,offset NewDriveLetters
     297        call    AuxIO_DumpParagraph
     298        call    AuxIO_TeletypeNL
     299        add     si,16
     300        call    AuxIO_DumpParagraph
     301        call    AuxIO_TeletypeNL
     302        call    AuxIO_TeletypeNL
     303
     304        mov     si,offset db_tmpec
     305        call    AuxIO_Print
     306        mov     si,offset TmpSector
     307        call    AuxIO_DumpSector
     308        call    AuxIO_TeletypeNL
     309        call    AuxIO_TeletypeNL
     310
     311        mov     si,offset db_partsec
     312        call    AuxIO_Print
     313        mov     si,offset PartitionSector
     314        call    AuxIO_DumpSector
     315        call    AuxIO_TeletypeNL
     316        call    AuxIO_TeletypeNL
     317
     318        popa
     319        popf
     320        ret
     321DEBUG_Dump2     EndP
     322
     323
     324
     325db_mbr              db "## MBR ##",10,0
     326db_masterlvm        db "## MLVMR ##",10,0
     327
     328db_checkmath        db "## CHK MATH ##",10,0
     329
     330
     331db_config           db '## CFG (DMP2) ##',10,0
     332db_cfgparts         db 'CFG_Partitions:',0
     333db_cfgpartdef       db 'CFG_PartDefault:',0
     334db_cfgpartlast      db 'CFG_PartLast:',0
     335
     336
     337db_vars             db '## VARS ##',10,0
     338db_partsec          db 'PartitionSector:',10,0
     339;db_lvmsec           db 'LVMSector :',10,0
     340db_tmpec            db 'TmpSector :',10,0
     341
     342db_newpart          db 'NewPartTable :',10,0
     343db_newhide          db 'NewHideTable:',10,0
     344db_dletters         db 'NewDriveLetters:',10,0
     345
     346;db_partsize         db 'PartitionSizeTable:',10,0
     347;db_partpoint        db 'PartitionPointers:',10,0
     348;db_partpointcnt     db 'PartitionPointerCount:',0
     349;db_partxref         db 'PartitionXref:',10,0
     350;db_partvoldl        db 'PartitionVolumeLetters:',10,0
     351
     352;db_totaldisks       db 'TotalHarddiscs:',0
     353;db_lbaswitchtab     db 'LBASwitchTable:',10,0
     354;db_newparts         db 'NewPartitions:',0
     355
     356;db_exabspos         db 'ExtendedAbsPos:',0
     357;db_exabsposset      db 'ExtendedAbsPosSet:',0
     358
     359db_curpartloc       db 'CurPartition_Location:',0
     360;db_curiox           db 'CurIO_UseExtension:',0
     361
     362db_curlvmsec        db 'Current LVM Sector:',0
     363
  • trunk/BOOTCODE/REGULAR/DRIVEIO.ASM

    r40 r43  
    3535; Will only load base-configuration, will NOT load IPT nor Hide-Config
    3636;  Those are originally loaded on startup and will NOT get reloaded.
    37 DriveIO_LoadConfiguration       Proc Near   Uses ax bx cx dx es
    38    mov     ax, cs
    39    mov     es, ax
    40    mov     bx, offset Configuration
    41    mov     dx, 0080h                     ; First harddrive, Sector 55...
    42    mov     cx, 0037h
    43    mov     ax, 0201h                     ; Function 02, read 1 sector...
    44    int     13h
    45    jnc     DIOLC_NoError
    46    call    MBR_LoadError                 ; Will Abort BootUp
    47   DIOLC_NoError:
    48    ret
    49 DriveIO_LoadConfiguration       EndP
    50 
    51 DriveIO_SaveConfiguration       Proc Near   Uses ax bx cx dx ds es si
    52    mov     ax, cs
    53    mov     ds, ax
    54    mov     es, ax                        ; Safety first (CS==DS==ES)
    55    ; --- Overwrite Floppy-Name with "FloppyDrive"
    56    mov     si, offset TXT_Floppy_Drive
    57    mov     di, offset PartitionTable
    58    sub     di, 30                        ; Adjust to Floppy-Name
    59    mov     cx, 11
    60    rep     movsb
    61    mov     si, offset Configuration      ; Calculate new checksum
    62    xor     bx, bx
    63 
    64    ; Changed from 5 to calculated value (not here, see compat. issue below)
    65    ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
    66    ; Size of the ab-configuration in 512 byte sectors
    67    ;mov     cx, (MBR_BackUpMBR - Configuration) / 200h
    68 
    69    ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
    70    ; AB v1.0.8 *should* stores a 7 sector configuration with a
    71    ; 7 sector checksum.
    72    ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8
    73    ; config as corrupted, while this is not the case.
    74    ; So, for compatibility reasons, in v1.0.8, the checksum stored is over
    75    ; 5 sectors, to be compatible with v1.07.
    76    ; This may change (be corrected) in future versions !
    77    mov     cx,5
    78 
    79    mov     dx, [CFG_CheckConfig]
    80    mov     [CFG_CheckConfig], bx
    81   DIOSC_Loop:
    82       call    MBR_GetCheckOfSector
    83    loop    DIOSC_Loop
    84    mov     [CFG_CheckConfig], bx
    85    ; --------------------------------------------------------------------
    86    ; ES == CS
    87    mov     bx, offset Configuration
    88    mov     dx, 0080h                     ; First harddrive, Sector 55...
    89    mov     cx, 0037h
    90 
    91    ; Changed from 5 to calculated value
    92    ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
    93    ; Size of the ab-configuration in 512 byte sectors
    94    mov     al, (MBR_BackUpMBR - Configuration) / 200h
    95    mov     ah,03h
    96 
    97    int     13h
    98    jnc     DIOSC_NoError
    99    call    MBR_SaveError                 ; Will Abort BootUp
    100   DIOSC_NoError:
    101    ret
    102 DriveIO_SaveConfiguration       EndP
    103 
    104 DriveIO_UpdateFloppyName        Proc Near   Uses bx cx dx ds si es di
    105    mov     ax, cs
    106    mov     ds, ax
    107    mov     es, ax
    108 
    109    mov     ah, 00h                        ; Function 2 - Reset Drive
    110    xor     dl, dl
    111    int     13h
    112    xor     dx, dx                         ; Cylinder=0, Head=0
    113    mov     cx,  1                         ; Sector=1, Drive=0
    114    mov     bx, offset TmpSector           ; ES:BX - TmpSector
    115    mov     ax, 0201h                      ; Function 2 - Load Sector
    116    int     13h
    117    jnc     DIOUFN_AllFine
    118 
    119    ; --- Overwrite Floppy-Name with "No Disc"
    120    mov     si, offset TXT_Floppy_NoDisc
    121    xor     ax, ax
    122   DIOUFN_WriteFloppyName:
    123    mov     di, offset PartitionTable
    124    sub     di, 30                         ; Adjust to Floppy-Name
    125    mov     cl, 11
    126    rep     movsb
    127    ret     ; AX=-1 -> GotDisc, =0 -> NoDisc
    128 
    129    ; --- Floppy found and read, data in TempSector
    130   DIOUFN_AllFine:
    131    mov     ax, -1
    132    mov     si, offset TXT_Floppy_NoName
    133    cmp     wptr es:[bx+54], 'AF'
    134    jne     DIOUFN_WriteFloppyName
    135    cmp     wptr es:[bx+56], '1T'
    136    jne     DIOUFN_WriteFloppyName
    137    cmp     bptr es:[bx+58], '2'
    138    jne     DIOUFN_WriteFloppyName
    139    mov     si, bx
    140    add     si, 43                         ; FAT12 - Volume Label Location
    141    jmp     DIOUFN_WriteFloppyName
    142 DriveIO_UpdateFloppyName        EndP
     37DriveIO_LoadConfiguration   Proc Near   Uses ax bx cx dx es
     38        mov     ax, cs
     39        mov     es, ax
     40        mov     bx, offset Configuration
     41        mov     dx, 0080h                     ; First harddrive, Sector 55...
     42        mov     cx, 0037h
     43        mov     ax, 0201h                     ; Function 02, read 1 sector...
     44        int     13h
     45        jnc     DIOLC_NoError
     46        call    MBR_LoadError                 ; Will Abort BootUp
     47    DIOLC_NoError:
     48        ret
     49DriveIO_LoadConfiguration   EndP
     50
     51DriveIO_SaveConfiguration   Proc Near   Uses ax bx cx dx ds es si
     52        mov     ax, cs
     53        mov     ds, ax
     54        mov     es, ax                        ; Safety first (CS==DS==ES)
     55        ; --- Overwrite Floppy-Name with "FloppyDrive"
     56        mov     si, offset TXT_Floppy_Drive
     57        mov     di, offset PartitionTable
     58        sub     di, 30                        ; Adjust to Floppy-Name
     59        mov     cx, 11
     60        rep     movsb
     61        mov     si, offset Configuration      ; Calculate new checksum
     62        xor     bx, bx
     63
     64        ; Changed from 5 to calculated value (not here, see compat. issue below)
     65        ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
     66        ; Size of the ab-configuration in 512 byte sectors
     67        ;mov     cx, (MBR_BackUpMBR - Configuration) / 200h
     68
     69        ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
     70        ; AB v1.0.8 *should* stores a 7 sector configuration with a
     71        ; 7 sector checksum.
     72        ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8
     73        ; config as corrupted, while this is not the case.
     74        ; So, for compatibility reasons, in v1.0.8, the checksum stored is over
     75        ; 5 sectors, to be compatible with v1.07.
     76        ; This may change (be corrected) in future versions !
     77        mov     cx,5
     78
     79        mov     dx, [CFG_CheckConfig]
     80        mov     [CFG_CheckConfig], bx
     81    DIOSC_Loop:
     82        call    MBR_GetCheckOfSector
     83        loop    DIOSC_Loop
     84        mov     [CFG_CheckConfig], bx
     85        ; --------------------------------------------------------------------
     86        ; ES == CS
     87        mov     bx, offset Configuration
     88        mov     dx, 0080h                     ; First harddrive, Sector 55...
     89        mov     cx, 0037h
     90
     91        ; Changed from 5 to calculated value
     92        ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
     93        ; Size of the ab-configuration in 512 byte sectors
     94        mov     al, (MBR_BackUpMBR - Configuration) / 200h
     95        mov     ah,03h
     96
     97        int     13h
     98        jnc     DIOSC_NoError
     99        call    MBR_SaveError                 ; Will Abort BootUp
     100    DIOSC_NoError:
     101        ret
     102DriveIO_SaveConfiguration   EndP
     103
     104DriveIO_UpdateFloppyName    Proc Near   Uses bx cx dx ds si es di
     105        mov     ax, cs
     106        mov     ds, ax
     107        mov     es, ax
     108
     109        mov     ah, 00h                        ; Function 2 - Reset Drive
     110        xor     dl, dl
     111        int     13h
     112        xor     dx, dx                         ; Cylinder=0, Head=0
     113        mov     cx,  1                         ; Sector=1, Drive=0
     114        mov     bx, offset TmpSector           ; ES:BX - TmpSector
     115        mov     ax, 0201h                      ; Function 2 - Load Sector
     116        int     13h
     117        jnc     DIOUFN_AllFine
     118
     119        ; --- Overwrite Floppy-Name with "No Disc"
     120        mov     si, offset TXT_Floppy_NoDisc
     121        xor     ax, ax
     122    DIOUFN_WriteFloppyName:
     123        mov     di, offset PartitionTable
     124        sub     di, 30                         ; Adjust to Floppy-Name
     125        mov     cl, 11
     126        rep     movsb
     127        ret     ; AX=-1 -> GotDisc, =0 -> NoDisc
     128
     129        ; --- Floppy found and read, data in TempSector
     130    DIOUFN_AllFine:
     131        mov     ax, -1
     132        mov     si, offset TXT_Floppy_NoName
     133        cmp     wptr es:[bx+54], 'AF'
     134        jne     DIOUFN_WriteFloppyName
     135        cmp     wptr es:[bx+56], '1T'
     136        jne     DIOUFN_WriteFloppyName
     137        cmp     bptr es:[bx+58], '2'
     138        jne     DIOUFN_WriteFloppyName
     139        mov     si, bx
     140        add     si, 43                         ; FAT12 - Volume Label Location
     141        jmp     DIOUFN_WriteFloppyName
     142DriveIO_UpdateFloppyName    EndP
    143143
    144144; =============================================================================
     
    152152;  Internal access (to AiR-BOOT) is always done via INT 13h/CHS.
    153153
    154 DriveIO_GetHardDriveCount       Proc Near   Uses ds si
    155    push    ds
    156    push    si
    157       push    0040h
    158       pop     ds
    159       mov     si, 0075h
    160       mov     dh, ds:[si]                ; 40:75 -> POST: Total Harddiscs == DL
    161    pop     si
    162    pop     ds
    163    mov     TotalHarddiscs, dh
    164    ret
    165 DriveIO_GetHardDriveCount       EndP
     154DriveIO_GetHardDriveCount   Proc Near   Uses ds si
     155        push    ds
     156        push    si
     157        push    0040h
     158        pop     ds
     159        mov     si, 0075h
     160        mov     dh, ds:[si]                ; 40:75 -> POST: Total Harddiscs == DL
     161        pop     si
     162        pop     ds
     163        mov     TotalHarddiscs, dh
     164        ret
     165DriveIO_GetHardDriveCount   EndP
    166166
    167167
     
    170170;  This is calculated by Sector*Heads. Comparing will get done with Bit 25-10
    171171;  on LBA sectors, so we actually divide sector number by 1024.
    172 DriveIO_InitLBASwitchTable      Proc Near   Uses es di
    173    mov     di, offset LBASwitchTable
    174    mov     dh, TotalHarddiscs
    175    mov     dl, 80h
    176   DIOILUT_DriveLoop:
    177       push    dx
    178       push    di
    179          mov     ah, 08h
    180          int     13h            ; DISK - GET DRIVE PARAMETERS
    181          mov     ah, 0FBh       ; Assume 255 heads/63 sectors, if error
    182          jc      DIOILUT_Error
    183          and     cl, 111111b    ; Isolate lower 6 bits of CL -> sector count
    184 
    185          ;movzx   ax, cl
    186          mov   al,cl
    187          mov   ah,0
    188 
    189          mov     bl, dh         ; DH -> max head number
    190          mul     bl             ; AX = Sectors*Heads
    191          shl     ah, 1
    192          shl     ah, 1          ; Shift 2 bits, so we are able to compare to
    193                                 ;  bit 16-23 of the LBA address
    194         DIOILUT_Error:
    195       pop     di
    196       pop     dx
    197       mov     bptr ds:[di], ah  ; Save that value
    198       inc     di                ; Go to next BYTE
    199       inc     dl
    200    dec     dh
    201    jnz     DIOILUT_DriveLoop
    202    ret
    203 DriveIO_InitLBASwitchTable      EndP
     172DriveIO_InitLBASwitchTable  Proc Near   Uses es di
     173        mov     di, offset LBASwitchTable
     174        mov     dh, TotalHarddiscs
     175        mov     dl, 80h
     176    DIOILUT_DriveLoop:
     177        push    dx
     178        push    di
     179        mov     ah, 08h
     180        int     13h            ; DISK - GET DRIVE PARAMETERS
     181        mov     ah, 0FBh       ; Assume 255 heads/63 sectors, if error
     182        jc      DIOILUT_Error
     183        and     cl, 111111b    ; Isolate lower 6 bits of CL -> sector count
     184
     185        ;movzx   ax, cl
     186        mov   al,cl
     187        mov   ah,0
     188
     189        mov     bl, dh         ; DH -> max head number
     190        mul     bl             ; AX = Sectors*Heads
     191        shl     ah, 1
     192        shl     ah, 1          ; Shift 2 bits, so we are able to compare to
     193                ;  bit 16-23 of the LBA address
     194    DIOILUT_Error:
     195        pop     di
     196        pop     dx
     197        mov     bptr ds:[di], ah  ; Save that value
     198        inc     di                ; Go to next BYTE
     199        inc     dl
     200        dec     dh
     201        jnz     DIOILUT_DriveLoop
     202        ret
     203DriveIO_InitLBASwitchTable  EndP
    204204
    205205
     
    212212DriveIO_LVMAdjustToInfoSector   Proc Near
    213213
    214 
    215 
    216 ;      pusha
    217 ;      call     AuxIO_TeletypeNL
    218 
    219       ; LBA
    220 ;      xchg     dx,bx
    221 ;      call     AuxIO_TeletypeHexDWord
    222 ;      call     AuxIO_TeletypeNL
    223 ;      xchg     bx,dx
    224 
    225       ; CYL
    226 ;      mov      al,ch
    227 ;      call     AuxIO_TeletypeHexByte
    228 ;      call     AuxIO_TeletypeNL
    229 
    230       ; HEAD
    231 ;      mov      al,dh
    232 ;      call     AuxIO_TeletypeHexByte
    233 ;      call     AuxIO_TeletypeNL
    234 
    235       ; SEC
    236 ;      mov      al,cl
    237 ;      call     AuxIO_TeletypeHexByte
    238 ;      call     AuxIO_TeletypeNL
    239 
    240       ; DRIVE
    241 ;      mov      al,dl
    242 ;      call     AuxIO_TeletypeHexByte
    243 ;      call     AuxIO_TeletypeNL
    244 
    245 ;      popa
    246 
    247 
    248       ;local ts:word
    249       ;local ts2:word
    250 
    251       pusha
    252 
    253          ; Dump drive
    254          mov      si,offset drive
    255 ;         call     AuxIO_Print
    256          xchg     al,dl
    257 ;         call     AuxIO_TeletypeHexByte
    258 ;         call     AuxIO_TeletypeNL
    259          xchg     dl,al
    260 
    261          ; Dump SPT
    262          mov      si,offset spt_used
    263 ;         call     AuxIO_Print
    264          push     dx
    265          push     bx
     214        ;~ pusha
     215        ;~ call    AuxIO_TeletypeNL
     216;~
     217        ;~ ; LBA
     218        ;~ xchg    dx,bx
     219        ;~ call    AuxIO_TeletypeHexDWord
     220        ;~ call    AuxIO_TeletypeNL
     221        ;~ xchg    bx,dx
     222;~
     223        ;~ ; CYL
     224        ;~ mov     al,ch
     225        ;~ call    AuxIO_TeletypeHexByte
     226        ;~ call    AuxIO_TeletypeNL
     227;~
     228        ;~ ; HEAD
     229        ;~ mov     al,dh
     230        ;~ call    AuxIO_TeletypeHexByte
     231        ;~ call    AuxIO_TeletypeNL
     232;~
     233        ;~ ; SEC
     234        ;~ mov     al,cl
     235        ;~ call    AuxIO_TeletypeHexByte
     236        ;~ call    AuxIO_TeletypeNL
     237;~
     238        ;~ ; DRIVE
     239        ;~ mov     al,dl
     240        ;~ call    AuxIO_TeletypeHexByte
     241        ;~ call    AuxIO_TeletypeNL
     242        ;~ popa
     243;~
     244        ;~ ;local   ts:word
     245        ;~ ;local   ts2:word
     246
     247        pusha
     248
     249            ; Dump drive
     250            mov      si,offset drive
     251            ;call     AuxIO_Print
     252            xchg     al,dl
     253            ;call     AuxIO_TeletypeHexByte
     254            ;call     AuxIO_TeletypeNL
     255            xchg     dl,al
     256
     257            ; Dump SPT
     258            mov      si,offset spt_used
     259            ;call     AuxIO_Print
     260            push     dx
     261            push     bx
     262                xor      dh,dh
     263                and      dl,01111111b
     264                shl      dx,1
     265                shl      dx,1
     266                mov      bx, offset TrueSecs
     267                add      bx,dx
     268                mov      ax,word ptr [bx]
     269                ;mov      [ts],ax
     270                ;call     AuxIO_TeletypeHexWord
     271                ;call     AuxIO_TeletypeNL
     272            pop      bx
     273            pop      dx
     274
     275            pusha
     276                push    dx
     277                ; Location of extended position
     278                mov     dx,word ptr [ExtendedAbsPos+02]
     279                mov     ax,word ptr [ExtendedAbsPos+00]
     280                ;call    AuxIO_TeletypeHexDWord
     281                ;call    AuxIO_TeletypeNL
     282                pop     dx
     283
     284                xor     dh,dh
     285                and     dl,01111111b
     286                shl     dx,1
     287                shl     dx,1
     288                mov     bx, offset TrueSecs
     289                add     bx,dx
     290
     291                mov     ax, word ptr[bx]
     292                ;call    AuxIO_TeletypeHexWord
     293                ;call    AuxIO_TeletypeNL
     294                mov     al,[ExtendedAbsPosSet]           ; if true -> 1st sector of extpart (EBR), not logpart(BPB)
     295                ;call    AuxIO_TeletypeHexByte
     296                ;call    AuxIO_TeletypeNL
     297                ;mov     si,offset PartitionSector
     298                ;call    AuxIO_DumpSector
     299            popa
     300
     301            ; LBA
     302            mov     si,offset before_lvm_adjust
     303            ;call    AuxIO_Print
     304
     305            xchg    dx,bx
     306            ;call    AuxIO_TeletypeHexDWord
     307            ;call    AuxIO_TeletypeNL
     308            xchg    bx,dx
     309        popa
     310
     311
     312      ;or       bx,ax
     313      test     [ExtendedAbsPosSet],1
     314      jz       pri
     315
     316
     317
     318
     319        pusha
     320            mov      si,offset before_lvm_adjust_log
     321            ;call     AuxIO_Print
     322            ; LBA
     323            xchg     dx,bx
     324            ;call     AuxIO_TeletypeHexDWord
     325            ;call     AuxIO_TeletypeNL
     326            xchg     bx,dx
     327        popa
     328
     329
     330        push     dx
     331        push     bx
     332
    266333            xor      dh,dh
    267334            and      dl,01111111b
    268335            shl      dx,1
    269336            shl      dx,1
    270             mov      bx, offset TrueSecs
     337            mov      bx,offset TrueSecs
    271338            add      bx,dx
    272             mov      ax,word ptr [bx]
    273 
    274             ;mov      [ts],ax
    275 
    276 ;            call     AuxIO_TeletypeHexWord
    277 ;            call     AuxIO_TeletypeNL
    278          pop      bx
    279          pop      dx
    280 
    281          pusha
    282             push     dx
    283                ; Location of extended position
    284                mov      dx,word ptr [ExtendedAbsPos+02]
    285                mov      ax,word ptr [ExtendedAbsPos+00]
    286 ;               call     AuxIO_TeletypeHexDWord
    287 ;               call     AuxIO_TeletypeNL
    288             pop      dx
    289 
    290             xor      dh,dh
    291             and      dl,01111111b
    292             shl      dx,1
    293             shl      dx,1
    294             mov      bx, offset TrueSecs
    295             add      bx,dx
    296 
    297             mov      ax, word ptr[bx]
    298 ;            call     AuxIO_TeletypeHexWord
    299 ;            call     AuxIO_TeletypeNL
    300             mov      al,[ExtendedAbsPosSet]           ; if true -> 1st sector of extpart (EBR), not logpart(BPB)
    301 ;            call     AuxIO_TeletypeHexByte
    302 ;            call     AuxIO_TeletypeNL
    303       ;      mov      si,offset PartitionSector
    304       ;      call     AuxIO_DumpSector
    305          popa
    306 
    307          ; LBA
    308          mov      si,offset before_lvm_adjust
    309 ;         call     AuxIO_Print
    310 
    311          xchg     dx,bx
    312 ;         call     AuxIO_TeletypeHexDWord
    313 ;         call     AuxIO_TeletypeNL
    314          xchg     bx,dx
    315       popa
    316 
    317 
    318       ;or       bx,ax
    319       test     [ExtendedAbsPosSet],1
    320       jz       pri
    321 
    322 
    323 
    324 
    325       pusha
    326          mov      si,offset before_lvm_adjust_log
    327 ;         call     AuxIO_Print
    328          ; LBA
    329          xchg     dx,bx
    330 ;         call     AuxIO_TeletypeHexDWord
    331 ;         call     AuxIO_TeletypeNL
    332          xchg     bx,dx
    333       popa
    334 
    335 
    336       push     dx
    337       push     bx
    338          xor      dh,dh
    339          and      dl,01111111b
    340          shl      dx,1
    341          shl      dx,1
    342          mov      bx,offset TrueSecs
    343          add      bx,dx
    344          mov      dx,[bx]
    345          dec      dx
    346          add      ax,dx
    347       pop      bx
    348       pop      dx
    349       adc      bx,0
    350 
    351 
    352       pusha
    353          mov      si,offset after_lvm_adjust_log
    354 ;         call     AuxIO_Print
    355          ; LBA
    356          xchg     dx,bx
    357 ;         call     AuxIO_TeletypeHexDWord
    358 ;         call     AuxIO_TeletypeNL
    359          xchg     bx,dx
    360       popa
    361 
    362       jmp      done
    363 
    364 
    365 
    366 
    367 pri:
    368 
    369 
    370       push     ax
    371       push     cx
    372          xor      ch, ch                           ; Zero out upper-byte
    373 
    374          push     dx
    375             xor      dh,dh
    376             and      dl,01111111b
    377             shl      dx,1
    378             shl      dx,1
    379             push     bx
    380                mov      bx,offset TrueSecs
    381                add      bx,dx
    382                mov      ax,[bx]
    383                ;mov      [ts2],ax
    384             pop      bx
    385          pop      dx
    386 
    387 
    388 
    389          ;mov      al, 63
    390          ;call VideoIO_PrintByteDynamicNumber
    391          ;self: jmp self
    392 
    393 
    394 
    395          ; DEZE WERKT SOMS NIET GOED
    396          ; ROMMELT MET CYLINDERS
    397          ; ALLEEN TOEPASSEN ALS INT13X NIET ACTIEF !
    398 
    399          and      cl, al                           ; Isolate lower bits, because upper
    400          mov      ah, 0
    401          mov      si, ax                           ;  ones may be used for cylinder
    402          sub      si, cx
    403 
    404       pop      cx
    405       pop      ax
    406 
    407       or       cl, al                           ; Set sector to last sector
    408 
    409       add      ax, si                           ; Adjust lower LBA
    410       adc      bx, 0                            ; Adjust LBA Sector (BX:AX)
    411 
    412 
    413 
    414       ;push     ax
    415       ;call     AuxIO_TeletypeHexWord
    416       ;call     AuxIO_TeletypeNL
    417       ;mov      ax,[ts]
    418       ;call     AuxIO_TeletypeHexWord
    419       ;call     AuxIO_TeletypeNL
    420       ;mov      ax,[ts2]
    421       ;call     AuxIO_TeletypeHexWord
    422       ;call     AuxIO_TeletypeNL
    423       ;pop      ax
    424 
    425       ;and      ax,[ts]
     339            mov      dx,[bx]
     340            dec      dx
     341            add      ax,dx
     342
     343        pop      bx
     344        pop      dx
     345        adc      bx,0
     346
     347
     348        pusha
     349            mov     si,offset after_lvm_adjust_log
     350            ;call    AuxIO_Print
     351            ; LBA
     352            xchg    dx,bx
     353            ;call    AuxIO_TeletypeHexDWord
     354            ;call    AuxIO_TeletypeNL
     355            xchg    bx,dx
     356        popa
     357
     358        jmp      done
     359
     360
     361
     362
     363    pri:
     364
     365
     366        push    ax
     367        push    cx
     368            xor     ch, ch                           ; Zero out upper-byte
     369
     370            push    dx
     371                xor     dh,dh
     372                and     dl,01111111b
     373                shl     dx,1
     374                shl     dx,1
     375
     376                push    bx
     377                    mov     bx,offset TrueSecs
     378                    add     bx,dx
     379                    mov     ax,[bx]
     380                    ;mov     [ts2],ax
     381                pop     bx
     382            pop     dx
     383
     384
     385
     386            ;~ mov     al, 63
     387            ;~ call    VideoIO_PrintByteDynamicNumber
     388            ;~ self:   jmp self
     389
     390
     391
     392            ; DEZE WERKT SOMS NIET GOED
     393            ; ROMMELT MET CYLINDERS
     394            ; ALLEEN TOEPASSEN ALS INT13X NIET ACTIEF !
     395
     396            and     cl, al                           ; Isolate lower bits, because upper
     397            mov     ah, 0
     398            mov     si, ax                           ;  ones may be used for cylinder
     399            sub     si, cx
     400
     401        pop     cx
     402        pop     ax
     403
     404        or      cl, al                           ; Set sector to last sector
     405        add     ax, si                           ; Adjust lower LBA
     406        adc     bx, 0                            ; Adjust LBA Sector (BX:AX)
     407
     408
     409
     410        ;~ push    ax
     411        ;~ call    AuxIO_TeletypeHexWord
     412        ;~ call    AuxIO_TeletypeNL
     413        ;~ mov     ax,[ts]
     414        ;~ call    AuxIO_TeletypeHexWord
     415        ;~ call    AuxIO_TeletypeNL
     416        ;~ mov     ax,[ts2]
     417        ;~ call    AuxIO_TeletypeHexWord
     418        ;~ call    AuxIO_TeletypeNL
     419        ;~ pop     ax
     420
     421        ;~ and      ax,[ts]
    426422
    427423      jmp done
     
    429425
    430426
    431 done:
    432 
    433 
    434 
    435       pusha
    436          mov      si,offset after_lvm_adjust
    437 ;         call     AuxIO_Print
    438          ; LBA
    439          xchg     dx,bx
    440 ;         call     AuxIO_TeletypeHexDWord
    441 ;         call     AuxIO_TeletypeNL
    442          xchg     bx,dx
    443       popa
    444 
    445 
    446 
    447 ;      pusha
    448 ;      call     AuxIO_TeletypeNL
    449 
    450       ; CYL
    451 ;      mov      al,ch
    452 ;      call     AuxIO_TeletypeHexByte
    453 ;      call     AuxIO_TeletypeNL
    454 
    455       ; HEAD
    456 ;      mov      al,dh
    457 ;      call     AuxIO_TeletypeHexByte
    458 ;      call     AuxIO_TeletypeNL
    459 
    460       ; SEC
    461 ;      mov      al,cl
    462 ;      call     AuxIO_TeletypeHexByte
    463 ;      call     AuxIO_TeletypeNL
    464 
    465       ; DRIVE
    466 ;      mov      al,dl
    467 ;      call     AuxIO_TeletypeHexByte
    468 ;      call     AuxIO_TeletypeNL
    469 
    470 ;      popa
    471 
    472 
     427    done:
     428
     429        pusha
     430            mov     si,offset after_lvm_adjust
     431            ;~ call    AuxIO_Print
     432            ; LBA
     433            xchg    dx,bx
     434            ;~ call    AuxIO_TeletypeHexDWord
     435            ;~ call    AuxIO_TeletypeNL
     436            xchg    bx,dx
     437        popa
     438
     439        ;~ pusha
     440        ;~ call    AuxIO_TeletypeNL
     441;~
     442        ;~ ; CYL
     443        ;~ mov     al,ch
     444        ;~ call    AuxIO_TeletypeHexByte
     445        ;~ call    AuxIO_TeletypeNL
     446;~
     447        ;~ ; HEAD
     448        ;~ mov     al,dh
     449        ;~ call    AuxIO_TeletypeHexByte
     450        ;~ call    AuxIO_TeletypeNL
     451;~
     452        ;~ ; SEC
     453        ;~ mov     al,cl
     454        ;~ call    AuxIO_TeletypeHexByte
     455        ;~ call    AuxIO_TeletypeNL
     456;~
     457        ;~ ; DRIVE
     458        ;~ mov     al,dl
     459        ;~ call    AuxIO_TeletypeHexByte
     460        ;~ call    AuxIO_TeletypeNL
     461        ;~ popa
    473462
    474463      ret
    475464DriveIO_LVMAdjustToInfoSector   EndP
     465
     466
    476467
    477468drive                   db 'drive                    : ',0
     
    492483; Preserve: all registers
    493484; #########################################################################
    494 DriveIO_LoadPartition           Proc Near  Uses si
    495    mov     wptr cs:[CurPartition_Location+0], ax
    496    mov     wptr cs:[CurPartition_Location+2], bx
    497    mov     wptr cs:[CurPartition_Location+4], dx
    498    mov     wptr cs:[CurPartition_Location+6], cx ; Saves the location
    499    mov     si, offset PartitionSector    ; DS:SI - ExecBase
    500    call    DriveIO_LoadSector
    501    clc
    502    cmp     wptr [si+LocBR_Magic], 0AA55h
    503    je      DIOLP_Success
    504    ; We check, if we are scanning partitions. In that case, if CHS is not 0/0/1
    505    ;  we will display a "bad partition table" message and halt the system.
    506    cmp     cx, 0001h
    507    jne     DIOLP_Failed
    508    or      dh, dh
    509    jnz     DIOLP_Failed
    510    stc                                   ; Set carry, so no partition table
    511   DIOLP_Success:
    512 
    513 IFDEF AuxDebug
    514    ; show current partition location
    515    pushf
    516    pusha
    517       call     AuxIO_TeletypeNL
    518       mov      si,offset db_curpartloc
    519       call     AuxIO_Print
    520       mov      dx,word ptr [CurPartition_Location+02]
    521       mov      ax,word ptr [CurPartition_Location+00]
    522       call     AuxIO_TeletypeHexDWord
    523       call     AuxIO_TeletypeNL
    524       mov      si,offset PartitionSector
    525       call     AuxIO_DumpSector
    526       call     AuxIO_TeletypeNL
    527    popa
    528    popf
    529 ENDIF
    530 
    531    ret
    532   DIOLP_Failed:
    533    jmp     DriveIO_GotLoadError
    534 DriveIO_LoadPartition           EndP
     485DriveIO_LoadPartition   Proc Near  Uses si
     486        mov     wptr cs:[CurPartition_Location+0], ax
     487        mov     wptr cs:[CurPartition_Location+2], bx
     488        mov     wptr cs:[CurPartition_Location+4], dx
     489        mov     wptr cs:[CurPartition_Location+6], cx ; Saves the location
     490        mov     si, offset PartitionSector    ; DS:SI - ExecBase
     491        call    DriveIO_LoadSector
     492        clc
     493        cmp     wptr [si+LocBR_Magic], 0AA55h
     494        je      DIOLP_Success
     495        ; We check, if we are scanning partitions. In that case, if CHS is not 0/0/1
     496        ;  we will display a "bad partition table" message and halt the system.
     497        cmp     cx, 0001h
     498        jne     DIOLP_Failed
     499        or      dh, dh
     500        jnz     DIOLP_Failed
     501        stc                                   ; Set carry, so no partition table
     502    DIOLP_Success:
     503
     504    IFDEF AUX_DEBUG
     505        ; show current partition location
     506        ;~ pushf
     507        ;~ pusha
     508        ;~ call     AuxIO_TeletypeNL
     509        ;~ mov      si,offset db_curpartloc
     510        ;~ call     AuxIO_Print
     511        ;~ mov      dx,word ptr [CurPartition_Location+02]
     512        ;~ mov      ax,word ptr [CurPartition_Location+00]
     513        ;~ call     AuxIO_TeletypeHexDWord
     514        ;~ call     AuxIO_TeletypeNL
     515        ;~ mov      si,offset PartitionSector
     516        ;~ call     AuxIO_DumpSector
     517        ;~ call     AuxIO_TeletypeNL
     518        ;~ popa
     519        ;~ popf
     520    ENDIF
     521
     522        ret
     523    DIOLP_Failed:
     524        jmp     DriveIO_GotLoadError
     525DriveIO_LoadPartition   EndP
    535526
    536527; #########################################################################
     
    541532; Preserve: all registers
    542533; #########################################################################
    543 DriveIO_SavePartition           Proc Near  Uses ax bx cx dx si
    544    mov     ax, wptr cs:[CurPartition_Location+0]
    545    mov     bx, wptr cs:[CurPartition_Location+2]
    546    mov     dx, wptr cs:[CurPartition_Location+4]
    547    mov     cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location
    548    mov     si, offset PartitionSector    ; DS:SI - ExecBase
    549    cmp     wptr [si+LocBR_Magic], 0AA55h ; Checks for signature, if not found
    550    jne     DIOSP_SevereError             ;  we assume a really bad error
    551    call    DriveIO_SaveSector
    552   DIOSP_SevereError:
    553    ret
    554 DriveIO_SavePartition           EndP
     534DriveIO_SavePartition   Proc Near  Uses ax bx cx dx si
     535        mov     ax, wptr cs:[CurPartition_Location+0]
     536        mov     bx, wptr cs:[CurPartition_Location+2]
     537        mov     dx, wptr cs:[CurPartition_Location+4]
     538        mov     cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location
     539        mov     si, offset PartitionSector    ; DS:SI - ExecBase
     540        cmp     wptr [si+LocBR_Magic], 0AA55h ; Checks for signature, if not found
     541        jne     DIOSP_SevereError             ;  we assume a really bad error
     542        call    DriveIO_SaveSector
     543    DIOSP_SevereError:
     544        ret
     545DriveIO_SavePartition   EndP
    555546
    556547; Keeps DS:SI for caller
    557 DriveIO_LoadTmpSector           Proc Near
    558    mov     si, offset TmpSector
    559    call    DriveIO_LoadSector                                                    ; Uses INT13X if needed
    560    ret
    561 DriveIO_LoadTmpSector           EndP
     548DriveIO_LoadTmpSector   Proc Near
     549        mov     si, offset TmpSector
     550        call    DriveIO_LoadSector
     551        ret
     552DriveIO_LoadTmpSector   EndP
    562553
    563554; Keeps DS:SI for caller
    564 DriveIO_SaveTmpSector           Proc Near
    565    mov     si, offset TmpSector
    566    call    DriveIO_SaveSector
    567    ret
    568 DriveIO_SaveTmpSector           EndP
     555DriveIO_SaveTmpSector   Proc Near
     556        mov     si, offset TmpSector
     557        call    DriveIO_SaveSector
     558        ret
     559DriveIO_SaveTmpSector   EndP
    569560
    570561; Keeps DS:SI for caller, sets carry if valid LVM sector encountered
    571 DriveIO_LoadLVMSector           Proc Near  Uses ax bx cx dx
    572    test    [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
    573    jnz     DIOLLVMS_NoLVMSector          ;  don't load but declare as bad!
    574    mov     ax, wptr cs:[CurPartition_Location+0]
    575    mov     bx, wptr cs:[CurPartition_Location+2]
    576    mov     dx, wptr cs:[CurPartition_Location+4]
    577    mov     cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location
    578 
    579    call    DriveIO_LVMAdjustToInfoSector
    580 
    581    mov     si, offset LVMSector
    582    call    DriveIO_LoadSector
    583 
    584 IFDEF AuxDebug
    585    ; show current partition location
    586    pushf
    587    pusha
    588 ;      call     AuxIO_TeletypeNL
    589       mov      si,offset db_curlvmsec
    590 ;      call     AuxIO_Print
    591       mov      dx,bx
    592 ;      call     AuxIO_TeletypeHexDWord
    593 ;      call     AuxIO_TeletypeNL
    594       mov      si,offset LVMSector
    595 ;      call     AuxIO_DumpSector
    596 ;      call     AuxIO_TeletypeNL
    597    popa
    598    popf
    599 ENDIF
    600 
    601    call    LVM_CheckSectorSignature
    602    jnc     DIOLLVMS_NoLVMSector
    603    call    LVM_CheckSectorCRC
    604    jnc     DIOLLVMS_NoLVMSector
    605    ret
    606    ; This here is called, if an invalid (or no) LVM information sector is found
    607    ;  It will truncate the first byte of the sector, so all other routines
    608    ;  will notice it easily by just comparing the first byte.
    609   DIOLLVMS_NoLVMSector:
    610    mov     bptr [si+LocLVM_SignatureStart], 0
    611    ret
    612 DriveIO_LoadLVMSector           EndP
     562DriveIO_LoadLVMSector   Proc Near  Uses ax bx cx dx
     563        test    [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
     564        jnz     DIOLLVMS_NoLVMSector          ;  don't load but declare as bad!
     565        mov     ax, wptr cs:[CurPartition_Location+0]
     566        mov     bx, wptr cs:[CurPartition_Location+2]
     567        mov     dx, wptr cs:[CurPartition_Location+4]
     568        mov     cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location
     569
     570        call    DriveIO_LVMAdjustToInfoSector
     571
     572        mov     si, offset LVMSector
     573        call    DriveIO_LoadSector
     574
     575    IFDEF AUX_DEBUG
     576        ; show current partition location
     577        pushf
     578        pusha
     579        ;~ call    AuxIO_TeletypeNL
     580        ;~ mov     si,offset db_curlvmsec
     581        ;~ call    AuxIO_Print
     582        mov     dx,bx
     583        ;~ call    AuxIO_TeletypeHexDWord
     584        ;~ call    AuxIO_TeletypeNL
     585        mov     si,offset LVMSector
     586        ;~ call    AuxIO_DumpSector
     587        ;~ call    AuxIO_TeletypeNL
     588        popa
     589        popf
     590    ENDIF
     591
     592        call    LVM_CheckSectorSignature
     593        jnc     DIOLLVMS_NoLVMSector
     594        call    LVM_CheckSectorCRC
     595        jnc     DIOLLVMS_NoLVMSector
     596        ret
     597        ; This here is called, if an invalid (or no) LVM information sector is found
     598        ;  It will truncate the first byte of the sector, so all other routines
     599        ;  will notice it easily by just comparing the first byte.
     600    DIOLLVMS_NoLVMSector:
     601        mov     bptr [si+LocLVM_SignatureStart], 0
     602        ret
     603DriveIO_LoadLVMSector   EndP
    613604
    614605; Keeps DS:SI for caller, saves at anytime w/o checks (!)
    615 DriveIO_SaveLVMSector           Proc Near  Uses ax bx cx dx
    616    test    [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
    617    jnz     DIOSLVMS_SevereError          ;  don't save at anytime (security!)
    618    mov     ax, wptr cs:[CurPartition_Location+0]
    619    mov     bx, wptr cs:[CurPartition_Location+2]
    620    mov     dx, wptr cs:[CurPartition_Location+4]
    621    mov     cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location
    622    call    LVM_CheckSectorSignature
    623    jnc     DIOSLVMS_SevereError                  ; LVM Signature must be there
    624    call    DriveIO_LVMAdjustToInfoSector
    625    mov     si, offset LVMSector
    626    call    DriveIO_SaveSector
    627   DIOSLVMS_SevereError:
    628    ret
    629 DriveIO_SaveLVMSector           EndP
     606DriveIO_SaveLVMSector   Proc Near  Uses ax bx cx dx
     607        test    [CFG_IgnoreLVM], 1            ; We are supposed to ignore LVM, so
     608        jnz     DIOSLVMS_SevereError          ;  don't save at anytime (security!)
     609        mov     ax, wptr cs:[CurPartition_Location+0]
     610        mov     bx, wptr cs:[CurPartition_Location+2]
     611        mov     dx, wptr cs:[CurPartition_Location+4]
     612        mov     cx, wptr cs:[CurPartition_Location+6] ; Gets cur. partition location
     613        call    LVM_CheckSectorSignature
     614        jnc     DIOSLVMS_SevereError                  ; LVM Signature must be there
     615        call    DriveIO_LVMAdjustToInfoSector
     616        mov     si, offset LVMSector
     617        call    DriveIO_SaveSector
     618    DIOSLVMS_SevereError:
     619        ret
     620DriveIO_SaveLVMSector   EndP
     621
     622; Rousseau: Move this to BSS and merge with int13xbuf there.
    630623
    631624; Memory-Block that holds information for LBA-access via INT 13h
    632 DriveIO_DAP                db       10h ; Size of paket
    633                            db        0   ; Reserved
    634 DriveIO_DAP_NumBlocks      dw        0   ; Number of blocks
    635 DriveIO_DAP_Transfer       dd        0   ; Transfer Adress
    636 DriveIO_DAP_Absolute       dd        0   ; Absolute Sector
    637                            dd        0   ; Second Part of QWORD
     625DriveIO_DAP                 db      10h ; Size of paket
     626                            db      0   ; Reserved
     627DriveIO_DAP_NumBlocks       dw      0   ; Number of blocks
     628DriveIO_DAP_Transfer        dd      0   ; Transfer Adress
     629DriveIO_DAP_Absolute        dd      0   ; Absolute Sector
     630                            dd      0   ; Second Part of QWORD
    638631
    639632; Special error message instead of "LOAD ERROR" during partition scanning,
    640633;  so users will notice that something is bad with their partition table(s)
    641 DriveIO_GotLoadError            Proc Near
    642    test    cs:CurIO_Scanning, 1          ; Must be CS:, cause DS!=CS maybe here
    643    jnz     InScanMode
    644    jmp     MBR_LoadError
    645   InScanMode:
    646    mov     si, offset TXT_BrokenPartitionTable
    647    push    cs
    648    pop     ds
    649    call    MBR_Teletype
    650    mov     si, offset BrokenHDD
    651    sub     dl, 50h                       ; 80h -> '0'
    652    cmp     dl, 39h
    653    jbe     DIOGLE_BelowA
    654    add     dl, 7                         ; 3Ah -> 'A'
    655   DIOGLE_BelowA:
    656    mov     bptr [si+5], dl
    657    call    MBR_Teletype
    658 
    659    ; JWasm: cannot jump to local label in procedure.
    660    ; Changed to halt here.
    661    ;jmp     MBRLE_Halt
    662   DriveIO_GotLoadError_halt:
    663    jmp     DriveIO_GotLoadError_halt
    664 DriveIO_GotLoadError            EndP
     634DriveIO_GotLoadError    Proc Near
     635        test    cs:CurIO_Scanning, 1          ; Must be CS:, cause DS!=CS maybe here
     636        jnz     InScanMode
     637        jmp     MBR_LoadError
     638    InScanMode:
     639        mov     si, offset TXT_BrokenPartitionTable
     640        push    cs
     641        pop     ds
     642        call    MBR_Teletype
     643        mov     si, offset BrokenHDD
     644        sub     dl, 50h                       ; 80h -> '0'
     645        cmp     dl, 39h
     646        jbe     DIOGLE_BelowA
     647        add     dl, 7                         ; 3Ah -> 'A'
     648    DIOGLE_BelowA:
     649        mov     bptr [si+5], dl
     650        call    MBR_Teletype
     651
     652        ; JWasm: cannot jump to local label in other procedure.
     653        ; Changed to halt here.
     654        ;jmp     MBRLE_Halt
     655    DriveIO_GotLoadError_halt:
     656        jmp     DriveIO_GotLoadError_halt
     657DriveIO_GotLoadError    EndP
    665658
    666659; #########################################################################
     
    673666; Preserve: all registers
    674667; #########################################################################
    675 DriveIO_LoadSector              Proc Near  Uses ax bx ds si es di
    676    ; Is the drive not a harddrive?
    677    cmp      dl, 80h
    678    jb       DIOLS_UseNormal
    679 
    680    test     cs:[CurIO_UseExtension], 1
    681    jz       DIOLS_UseNormal
    682    ; Are we forced do use LBA via Setting?
    683    jnz      DIOLS_UseExtension
    684 
    685    ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)
    686    or       bh, bh
    687    jnz      DIOLS_UseExtension
    688    ; Compare Switch-Table value to bit 16-23 of LBA-address
    689    mov      di, dx
    690    and      di, 007Fh
    691    cmp      bptr cs:[LBASwitchTable+di], bl
    692    jbe      DIOLS_UseExtension
    693   DIOLS_UseNormal:
    694       mov      di, 3
    695      DIOLS_ErrorLoop:
    696          push     ds
    697          pop      es
    698          mov      bx, si                     ; ES:BX - Destination
    699          mov      ax, 0201h                  ; Function 2 - Load Sector
    700          int      13h
    701          jnc      DIOLS_Success
    702       dec      di
    703       jnz      DIOLS_ErrorLoop
    704       ; Sector load failed...
    705       jmp      DriveIO_GotLoadError
    706 
    707   DIOLS_UseExtension:
    708    push    cx
    709       mov     cs:[DriveIO_DAP_NumBlocks], 1         ; Copy ONE sector
    710       mov     wptr cs:[DriveIO_DAP_Transfer+0], si
    711       mov     cx, ds
    712       mov     wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
    713       mov     wptr cs:[DriveIO_DAP_Absolute+0], ax
    714       mov     wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
    715       push    cs
    716       pop     ds
    717       mov     si, offset DriveIO_DAP
    718       mov     ah, 42h                        ; Extended Read
    719       int     13h
    720    pop     cx
    721    jnc     DIOLS_Success
    722    ; Sector load failed...
    723    jmp     DriveIO_GotLoadError
    724 
    725   DIOLS_Success:
    726    ret
    727 DriveIO_LoadSector              EndP
     668DriveIO_LoadSector      Proc Near  Uses ax bx ds si es di
     669        ; Is the drive not a harddrive?
     670        cmp     dl, 80h
     671        jb      DIOLS_UseNormal
     672
     673        test    cs:[CurIO_UseExtension], 1
     674        jz      DIOLS_UseNormal
     675        ; Are we forced do use LBA via Setting?
     676        jnz     DIOLS_UseExtension
     677
     678        ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)
     679        or      bh, bh
     680        jnz     DIOLS_UseExtension
     681        ; Compare Switch-Table value to bit 16-23 of LBA-address
     682        mov     di, dx
     683        and     di, 007Fh
     684        cmp     bptr cs:[LBASwitchTable+di], bl
     685        jbe     DIOLS_UseExtension
     686    DIOLS_UseNormal:
     687        mov     di, 3
     688    DIOLS_ErrorLoop:
     689        push    ds
     690        pop     es
     691        mov     bx, si                     ; ES:BX - Destination
     692        mov     ax, 0201h                  ; Function 2 - Load Sector
     693        int     13h
     694        jnc     DIOLS_Success
     695        dec     di
     696        jnz     DIOLS_ErrorLoop
     697        ; Sector load failed...
     698        jmp     DriveIO_GotLoadError
     699
     700    DIOLS_UseExtension:
     701        push    cx
     702        mov     cs:[DriveIO_DAP_NumBlocks], 1         ; Copy ONE sector
     703        mov     wptr cs:[DriveIO_DAP_Transfer+0], si
     704        mov     cx, ds
     705        mov     wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
     706        mov     wptr cs:[DriveIO_DAP_Absolute+0], ax
     707        mov     wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
     708        push    cs
     709        pop     ds
     710        mov     si, offset DriveIO_DAP
     711        mov     ah, 42h                        ; Extended Read
     712        int     13h
     713        pop     cx
     714        jnc     DIOLS_Success
     715        ; Sector load failed...
     716        jmp     DriveIO_GotLoadError
     717
     718    DIOLS_Success:
     719        ret
     720DriveIO_LoadSector      EndP
    728721
    729722
     
    744737; AX     = Error code
    745738;
    746 DriveIO_LoadSectorLBA           Proc Near  Uses bx cx dx si di ds es
    747       ; Get one sector
    748       mov     cs:[DriveIO_DAP_NumBlocks], 1
    749 
    750       ; Setup buffer address
    751       mov     wptr cs:[DriveIO_DAP_Transfer+0], si
    752       mov     wptr cs:[DriveIO_DAP_Transfer+2], di
    753 
    754       ; Setup LBA address of requested sector
    755       mov     wptr cs:[DriveIO_DAP_Absolute+0], cx
    756       mov     wptr cs:[DriveIO_DAP_Absolute+2], bx
    757       mov     wptr cs:[DriveIO_DAP_Absolute+4], 0
    758       mov     wptr cs:[DriveIO_DAP_Absolute+6], 0
    759 
    760       ; Address of packet
    761       mov     si, offset DriveIO_DAP
    762 
    763       ; Do the extended read
    764       mov     ah, 42h
    765       int     13h
    766 
    767       ; Looking good so far
    768       jnc     DriveIO_LoadSectorLBA_succes1
    769 
    770       ; AH should not be zero, if it is then set to undefined and set carry
    771       test    ah,ah
    772       jnz     DriveIO_LoadSectorLBA_error1
    773       mov     ah, 0bbh        ; Undefined error
    774    DriveIO_LoadSectorLBA_error1:
    775       stc
    776       jmp     DriveIO_LoadSectorLBA_exit
    777 
    778       ; AL should be zero, if not then set to undefined and set carry
    779    DriveIO_LoadSectorLBA_succes1:
    780       test    ah,ah
    781       jz      DriveIO_LoadSectorLBA_exit
    782       stc
    783       jmp     DriveIO_LoadSectorLBA_exit
    784 
    785       ; Return to caller
    786    DriveIO_LoadSectorLBA_exit:
    787       ret
    788 DriveIO_LoadSectorLBA           EndP
     739DriveIO_LoadSectorLBA       Proc Near  Uses bx cx dx si di ds es
     740        ; Get one sector
     741        mov     cs:[DriveIO_DAP_NumBlocks], 1
     742
     743        ; Setup buffer address
     744        mov     wptr cs:[DriveIO_DAP_Transfer+0], si
     745        mov     wptr cs:[DriveIO_DAP_Transfer+2], di
     746
     747        ; Setup LBA address of requested sector
     748        mov     wptr cs:[DriveIO_DAP_Absolute+0], cx
     749        mov     wptr cs:[DriveIO_DAP_Absolute+2], bx
     750        mov     wptr cs:[DriveIO_DAP_Absolute+4], 0
     751        mov     wptr cs:[DriveIO_DAP_Absolute+6], 0
     752
     753        ; Address of packet
     754        mov     si, offset DriveIO_DAP
     755
     756        ; Do the extended read
     757        mov     ah, 42h
     758        int     13h
     759
     760        ; Looking good so far
     761        jnc     DriveIO_LoadSectorLBA_succes1
     762
     763        ; AH should not be zero, if it is then set to undefined and set carry
     764        test    ah,ah
     765        jnz     DriveIO_LoadSectorLBA_error1
     766        mov     ah, 0bbh        ; Undefined error
     767    DriveIO_LoadSectorLBA_error1:
     768        stc
     769        jmp     DriveIO_LoadSectorLBA_exit
     770
     771        ; AL should be zero, if not then set to undefined and set carry
     772    DriveIO_LoadSectorLBA_succes1:
     773        test    ah,ah
     774        jz      DriveIO_LoadSectorLBA_exit
     775        stc
     776        jmp     DriveIO_LoadSectorLBA_exit
     777
     778        ; Return to caller
     779    DriveIO_LoadSectorLBA_exit:
     780        ret
     781DriveIO_LoadSectorLBA       EndP
    789782
    790783
     
    801794; #########################################################################
    802795DriveIO_SaveSector              Proc Near  Uses ax bx cx ds si es di
    803    test     cs:[CurIO_UseExtension], 1
    804    jz       DIOSS_UseNormal
    805    ; Are we forced do use LBA via Setting?
    806    test     cs:[CFG_ForceLBAUsage], 1
    807    jnz      DIOSS_UseExtension
    808    ; Is the drive not a harddrive?
    809    cmp      dl, 80h
    810    jb       DIOSS_UseNormal
    811    ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)
    812    or       bh, bh
    813    jnz      DIOSS_UseExtension
    814    ; Compare Switch-Table value to bit 16-23 of LBA-address
    815    mov      di, dx
    816    and      di, 007Fh
    817    cmp      bptr cs:[LBASwitchTable+di], bl
    818    jbe      DIOSS_UseExtension
    819   DIOSS_UseNormal:
    820       mov      di, 3
    821      DIOSS_ErrorLoop:
    822          push     ds
    823          pop      es
    824          mov      bx, si                     ; ES:BX - Destination
    825          mov      ax, 0301h                  ; Function 3 - Write Sector
    826          int      13h
    827          jnc      DIOSS_Success
    828       dec      di
    829       jnz      DIOSS_ErrorLoop
    830       call     MBR_SaveError
    831 
    832   DIOSS_UseExtension:
    833    push    cx
    834       mov     cs:[DriveIO_DAP_NumBlocks], 1        ; Copy ONE sector
    835       mov     wptr cs:[DriveIO_DAP_Transfer+0], si
    836       mov     cx, ds
    837       mov     wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
    838       mov     wptr cs:[DriveIO_DAP_Absolute+0], ax
    839       mov     wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
    840       push    cs
    841       pop     ds
    842       mov     si, offset DriveIO_DAP
    843       mov     ax, 4300h                  ; Extended Write (No Verify)
    844       int     13h
    845    pop     cx
    846    jnc     DIOSS_Success
    847    call    MBR_SaveError
    848 
    849   DIOSS_Success:
    850    ret
     796        test    cs:[CurIO_UseExtension], 1
     797        jz      DIOSS_UseNormal
     798        ; Are we forced do use LBA via Setting?
     799        test    cs:[CFG_ForceLBAUsage], 1
     800        jnz     DIOSS_UseExtension
     801        ; Is the drive not a harddrive?
     802        cmp     dl, 80h
     803        jb      DIOSS_UseNormal
     804        ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)
     805        or      bh, bh
     806        jnz     DIOSS_UseExtension
     807        ; Compare Switch-Table value to bit 16-23 of LBA-address
     808        mov     di, dx
     809        and     di, 007Fh
     810        cmp     bptr cs:[LBASwitchTable+di], bl
     811        jbe     DIOSS_UseExtension
     812    DIOSS_UseNormal:
     813        mov     di, 3
     814    DIOSS_ErrorLoop:
     815        push    ds
     816        pop     es
     817        mov     bx, si                     ; ES:BX - Destination
     818        mov     ax, 0301h                  ; Function 3 - Write Sector
     819        int     13h
     820        jnc     DIOSS_Success
     821        dec     di
     822        jnz     DIOSS_ErrorLoop
     823        call    MBR_SaveError
     824
     825    DIOSS_UseExtension:
     826        push    cx
     827        mov     cs:[DriveIO_DAP_NumBlocks], 1        ; Copy ONE sector
     828        mov     wptr cs:[DriveIO_DAP_Transfer+0], si
     829        mov     cx, ds
     830        mov     wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
     831        mov     wptr cs:[DriveIO_DAP_Absolute+0], ax
     832        mov     wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
     833        push    cs
     834        pop     ds
     835        mov     si, offset DriveIO_DAP
     836        mov     ax, 4300h                  ; Extended Write (No Verify)
     837        int     13h
     838        pop     cx
     839        jnc     DIOSS_Success
     840        call    MBR_SaveError
     841
     842    DIOSS_Success:
     843        ret
    851844DriveIO_SaveSector              EndP
    852845
     
    858851        pusha
    859852
    860         call     LVM_CheckSectorSignature
     853        call    LVM_CheckSectorSignature
    861854        ; NC if no signature found
    862         jnc       DriveIO_LVMSectorValid_End
    863 
    864         call     LVM_CheckSectorCRC
     855        jnc     DriveIO_LVMSectorValid_End
     856
     857        call    LVM_CheckSectorCRC
    865858        ; Force valid !!!
    866859        stc
     
    889882; Return CF when valid master LVM sector found, NC if not.
    890883; Loads sector at [LVMSector] !
    891 DriveIO_LoadMasterLVMSector      Proc  Near
     884DriveIO_LoadMasterLVMSector     Proc  Near
    892885        pusha
    893886
    894         ;mov      si,offset db_lmlvm
    895         ;call     AuxIO_Print
    896 
    897         ; Physical disk
    898 ;        mov     al,'<'
    899 ;        call    VideoIO_PrintSingleChar
    900 ;        mov     al,dl
    901 ;        call    VideoIO_PrintHexByte
    902 ;        mov     al,'>'
    903 ;        call    VideoIO_PrintSingleChar
    904 
    905         ;call     AuxIO_TeletypeHexByte
    906         ;call     AuxIO_TeletypeNL
     887        ;~ mov      si,offset db_lmlvm
     888        ;~ call     AuxIO_Print
     889
     890        ;~ ; Physical disk
     891        ;~ mov     al,'<'
     892        ;~ call    VideoIO_PrintSingleChar
     893        ;~ mov     al,dl
     894        ;~ call    VideoIO_PrintHexByte
     895        ;~ mov     al,'>'
     896        ;~ call    VideoIO_PrintSingleChar
     897;~
     898        ;~ call    AuxIO_TeletypeHexByte
     899        ;~ call    AuxIO_TeletypeNL
    907900
    908901
    909902        ; Loop over the sector-translation table,
    910903        ; process the first three values from high (255) to low (bios spt, most likely 63)
    911         mov      cx,3
     904        mov     cx,3
    912905    DriveIO_LoadMasterLVMSector_NextTry:
    913906        ; Number of sectors to read
     
    934927        ;
    935928
    936 ;        push    ax
    937 ;        push    ax
    938 ;        mov     al,'$'
    939 ;        call    VideoIO_PrintSingleChar
    940 ;        pop     ax
    941 ;        call    VideoIO_PrintHexByte
    942 ;        mov     al,'$'
    943 ;        call    VideoIO_PrintSingleChar
    944 ;        pop     ax
    945 
    946 IFDEF AuxDebug
     929        ;~ push    ax
     930        ;~ push    ax
     931        ;~ mov     al,'$'
     932        ;~ call    VideoIO_PrintSingleChar
     933        ;~ pop     ax
     934        ;~ call    VideoIO_PrintHexByte
     935        ;~ mov     al,'$'
     936        ;~ call    VideoIO_PrintSingleChar
     937        ;~ pop     ax
     938
     939IFDEF AUX_DEBUG
    947940      ; Dump the value
    948941      ;call     AuxIO_TeletypeHexByte
     
    963956
    964957        ; See if this is a valid LVM-sector
    965         call     DriveIO_LVMSectorValid
     958        call    DriveIO_LVMSectorValid
    966959
    967960;        pushf
     
    980973        jc      DriveIO_LoadMasterLVMSector_Found
    981974        ; Try next location
    982         loop     DriveIO_LoadMasterLVMSector_NextTry
     975        loop    DriveIO_LoadMasterLVMSector_NextTry
    983976
    984977        ; No master LVM-sector found, set CF=false
     
    10831076; DL contains BIOS disk-number; 80h for first, 81h for second, etc.
    10841077DriveIO_GatherDiskInfo  Proc Near
    1085       pushf
    1086       push    bx
    1087       push    cx
    1088       push    dx
    1089       push    si
    1090       push    di
    1091       push    es
    1092 
    1093       ; Set ES to CS for buffer clearing
    1094       push    cs
    1095       pop     es
    1096 
    1097       ; Clear the buffer
    1098       ; Don't overwrite the word of the buffersize at index 0 !
    1099       ; Old Phoenix BIOSses require word (flags) at 02 to be zero,
    1100       ; so we clear the whole buffer to be sure.
    1101       mov     cx, i13xbuf_size
    1102       mov     di, offset i13xbuf
    1103       mov     [di],cx
    1104       inc     di
    1105       inc     di
    1106       xor     ah,ah
    1107       cld
    1108       rep stosb
    1109 
    1110       ; Get the drive parameters
    1111       mov     ah, 48h                                 ; Get Drive Parameters (extended version)
    1112       ;mov     dl, 80h                                ; Drive number
    1113       mov     si, offset i13xbuf                      ; Buffer for result-info
    1114       push    dx
    1115       int     13h                                     ; Call the BIOS-function
    1116       pop     dx
    1117 
    1118       ; Do some error-checking
    1119       or      ah,ah                                   ; AH is zero if no error (ZF=1 if no error)
    1120       mov     ax,0                                    ; Setup code for non-huge drive (does not influence ZF)
    1121       jz      DriveIO_GatherDiskInfo_ok               ; Return if error (AL<>0 thus ZF=0) but CY not set, assuming non-huge drive
    1122       jnc     DriveIO_GatherDiskInfo_ok               ; Return if error (CY=1), assuming non-huge drive
    1123       jmp     DriveIO_GatherDiskInfo_ret
    1124 
    1125 
    1126    DriveIO_GatherDiskInfo_ok:
    1127 
    1128       ;
    1129       ; Store the drive geometry
    1130       ;
    1131 
    1132       mov      si, offset i13xbuf
    1133 
    1134       xor      dh,dh
    1135       and      dl,01111111b
    1136       shl      dx,1
    1137       shl      dx,1
    1138 
    1139       ; Store number of cylinders on disk
    1140       mov      bx, offset BIOS_Cyls
    1141       add      bx,dx
    1142       mov      ax,[si+04h]
    1143 
    1144       mov      word ptr [bx+00],ax
    1145       mov      ax,[si+06]
    1146       mov      word ptr [bx+02],ax
    1147 
    1148       ; Store number of heads per cylinder
    1149       mov      bx, offset BIOS_Heads
    1150       add      bx,dx
    1151       mov      ax,[si+08h]
    1152       mov      word ptr [bx+00],ax
    1153       mov      ax,[si+0ah]
    1154       mov      word ptr [bx+02],ax
    1155 
    1156       ; Store number of sectors per track
    1157       mov      bx, offset BIOS_Secs
    1158       add      bx,dx
    1159       mov      ax,[si+0ch]
    1160       mov      word ptr [bx+00],ax
    1161 
    1162       ; Update first byte of translation-table to conform to BIOS SPT
    1163       mov      byte ptr [secs_per_track_table], al
    1164 
    1165       mov      ax,[si+0eh]
    1166       mov      word ptr [bx+02],ax
    1167 
    1168       ; Store total secs
    1169       mov      bx, offset BIOS_TotalSecs
    1170       add      bx,dx
    1171       add      bx,dx
    1172       mov      ax,[si+10h]
    1173 
    1174       mov      word ptr [bx+00],ax
    1175       mov      ax,[si+12h]
    1176       mov      word ptr [bx+02],ax
    1177       mov      ax,[si+14h]
    1178       mov      word ptr [bx+04],ax
    1179       mov      ax,[si+18h]
    1180       mov      word ptr [bx+06],ax
    1181 
    1182       ; Store number of bytes per sector
    1183       mov      bx, offset BIOS_Bytes
    1184       add      bx,dx
    1185       mov      ax,[si+18h]
    1186       mov      [bx],ax
    1187 
    1188 
    1189       ;
    1190       ; See of it's a huge drive of not
    1191       ;
    1192 
    1193       ; Drive is larger than 2TiB
    1194       mov     ax,5                                    ; Drive code (5)
    1195       mov     bx, [si+14h]                            ; Low word of high dword of sector-count
    1196       or      bx, [si+16h]                            ; High word of high dword of sector-count
    1197       jnz     DriveIO_GatherDiskInfo_ret              ; If non-zero we have a drive with >2^32 sectors and thus LBA48 addressing
    1198 
    1199       ; Drive is larger than max OS/2 capacity
    1200       dec     ax                                      ; Drive code (4)
    1201       mov     bx, [si+12h]                            ; High word of low dword of sector-count
    1202       cmp     bx, 0fe01h                              ; Boundary
    1203       jae     DriveIO_GatherDiskInfo_ret              ; If above or equal to boundary,
    1204                                                       ; we have a drive larger than to 65536*255*255 = FE010000 sectors
    1205 
    1206       ; Drive can be completely utilized by OS/2
    1207       dec     ax                                      ; Drive code (3)
    1208       cmp     bx, 8000h                               ; Boundary
    1209       jae     DriveIO_GatherDiskInfo_ret              ; If above or equal to boundary,
    1210                                                       ; we have a drive larger than 2^31 sectors but smaller than 65536*255*255
    1211 
    1212       ; This is the small area between DANI 1TiB and LBA 1TiB
    1213       dec     ax                                      ; Drive code (2)
    1214       cmp     bx, 7e81h                               ; Boundary
    1215       jae     DriveIO_GatherDiskInfo_ret              ; If above or equal to boundary,
    1216                                                       ; we have a drive larger than 65536*255*127 but <65536*255*255
    1217                                                       ; DANIS506.ADD will use 255/255 extended geometry
    1218 
    1219       ; DANI will use 255/127 in this area, this could impact the location of LVM-sectors ! (last sec on track)
    1220       dec     ax                                      ; Drive code (1)
    1221       cmp     bx, 3ec1h                               ; Boundary
    1222       jae     DriveIO_GatherDiskInfo_ret              ; If above or equal to boundary,
    1223                                                       ; we have a drive larger than 65536*255*63 sectors (OS/2 502GiB Limit!)
    1224                                                       ; DANIS506.ADD will use 255/127 extended geometry !
    1225                                                       ; IBM1S506.ADD will use 255/255 extended geometry !
    1226 
    1227       ; We have a drive that can be addressed using standard 255/63 geometry
    1228       dec     ax                                      ; Drive code (0)
    1229                                                       ; We have a drive smaller than 65536*255*63 = 3EC10000 sectors
    1230 
    1231    DriveIO_GatherDiskInfo_ret:
    1232       pop     es
    1233       pop     di
    1234       pop     si
    1235       pop     dx
    1236       pop     cx
    1237       pop     bx
    1238 
    1239       mov      [CurIO_UseExtension],1
    1240 
    1241       popf
    1242       ret
     1078        pushf
     1079        push    bx
     1080        push    cx
     1081        push    dx
     1082        push    si
     1083        push    di
     1084        push    es
     1085
     1086        ; Set ES to CS for buffer clearing
     1087        push    cs
     1088        pop     es
     1089
     1090        ; Clear the buffer
     1091        ; Also setup the buffer size.
     1092        ; Old Phoenix BIOSses require word (flags) at 02 to be zero,
     1093        ; so we clear the whole buffer to be sure.
     1094        mov     cx, i13xbuf_size        ; Dynamically calculated by assembler.
     1095        mov     di, offset i13xbuf      ; Points to size field.
     1096        mov     [di],cx                 ; Setup buffer-size.
     1097        inc     di
     1098        inc     di                      ; Now pointing at actual buffer.
     1099        xor     ah,ah                   ; Fill value.
     1100        cld                             ; Direction up.
     1101        rep stosb                       ; Clear buffer.
     1102
     1103        ; Get the drive parameters
     1104        mov     ah, 48h                 ; Get Drive Parameters (extended version)
     1105        ;mov     dl, 80h                ; Drive number
     1106        mov     si, offset i13xbuf      ; Buffer for result-info
     1107        push    dx
     1108        int     13h                     ; Call the BIOS-function
     1109        pop     dx
     1110
     1111        ; Do some error-checking
     1112        or      ah,ah                       ; AH is zero if no error (ZF=1 if no error)
     1113        mov     ax,0                        ; Setup code for non-huge drive (does not influence ZF)
     1114        jz      DriveIO_GatherDiskInfo_ok   ; Return if error (AL<>0 thus ZF=0) but CY not set, assuming non-huge drive
     1115        jnc     DriveIO_GatherDiskInfo_ok   ; Return if error (CY=1), assuming non-huge drive
     1116        jmp     DriveIO_GatherDiskInfo_ret
     1117
     1118
     1119    DriveIO_GatherDiskInfo_ok:
     1120
     1121        ;
     1122        ; Store the drive geometry
     1123        ;
     1124
     1125        mov      si, offset i13xbuf
     1126
     1127        xor      dh,dh
     1128        and      dl,01111111b
     1129        shl      dx,1
     1130        shl      dx,1
     1131
     1132        ; Store number of cylinders on disk
     1133        mov      bx, offset BIOS_Cyls
     1134        add      bx,dx
     1135        mov      ax,[si+04h]
     1136
     1137        mov      word ptr [bx+00],ax
     1138        mov      ax,[si+06]
     1139        mov      word ptr [bx+02],ax
     1140
     1141        ; Store number of heads per cylinder
     1142        mov      bx, offset BIOS_Heads
     1143        add      bx,dx
     1144        mov      ax,[si+08h]
     1145        mov      word ptr [bx+00],ax
     1146        mov      ax,[si+0ah]
     1147        mov      word ptr [bx+02],ax
     1148
     1149        ; Store number of sectors per track
     1150        mov      bx, offset BIOS_Secs
     1151        add      bx,dx
     1152        mov      ax,[si+0ch]
     1153        mov      word ptr [bx+00],ax
     1154
     1155        ; Update first byte of translation-table to conform to BIOS SPT
     1156        mov      byte ptr [secs_per_track_table], al
     1157
     1158        mov      ax,[si+0eh]
     1159        mov      word ptr [bx+02],ax
     1160
     1161        ; Store total secs
     1162        mov      bx, offset BIOS_TotalSecs
     1163        add      bx,dx
     1164        add      bx,dx
     1165        mov      ax,[si+10h]
     1166
     1167        mov      word ptr [bx+00],ax
     1168        mov      ax,[si+12h]
     1169        mov      word ptr [bx+02],ax
     1170        mov      ax,[si+14h]
     1171        mov      word ptr [bx+04],ax
     1172        mov      ax,[si+18h]
     1173        mov      word ptr [bx+06],ax
     1174
     1175        ; Store number of bytes per sector
     1176        mov      bx, offset BIOS_Bytes
     1177        add      bx,dx
     1178        mov      ax,[si+18h]
     1179        mov      [bx],ax
     1180
     1181
     1182        ;
     1183        ; See of it's a huge drive of not
     1184        ;
     1185
     1186        ; Drive is larger than 2TiB
     1187        mov     ax,5                        ; Drive code (5)
     1188        mov     bx, [si+14h]                ; Low word of high dword of sector-count
     1189        or      bx, [si+16h]                ; High word of high dword of sector-count
     1190        jnz     DriveIO_GatherDiskInfo_ret  ; If non-zero we have a drive with >2^32 sectors and thus LBA48 addressing
     1191
     1192        ; Drive is larger than max OS/2 capacity
     1193        dec     ax                          ; Drive code (4)
     1194        mov     bx, [si+12h]                ; High word of low dword of sector-count
     1195        cmp     bx, 0fe01h                  ; Boundary
     1196        jae     DriveIO_GatherDiskInfo_ret  ; If above or equal to boundary,
     1197                                            ; we have a drive larger than to 65536*255*255 = FE010000 sectors
     1198
     1199        ; Drive can be completely utilized by OS/2
     1200        dec     ax                          ; Drive code (3)
     1201        cmp     bx, 8000h                   ; Boundary
     1202        jae     DriveIO_GatherDiskInfo_ret  ; If above or equal to boundary,
     1203                                            ; we have a drive larger than 2^31 sectors but smaller than 65536*255*255
     1204
     1205        ; This is the small area between DANI 1TiB and LBA 1TiB
     1206        dec     ax                          ; Drive code (2)
     1207        cmp     bx, 7e81h                   ; Boundary
     1208        jae     DriveIO_GatherDiskInfo_ret  ; If above or equal to boundary,
     1209                                            ; we have a drive larger than 65536*255*127 but <65536*255*255
     1210                                            ; DANIS506.ADD will use 255/255 extended geometry
     1211
     1212        ; DANI will use 255/127 in this area, this could impact the location of LVM-sectors ! (last sec on track)
     1213        dec     ax                          ; Drive code (1)
     1214        cmp     bx, 3ec1h                   ; Boundary
     1215        jae     DriveIO_GatherDiskInfo_ret  ; If above or equal to boundary,
     1216                                            ; we have a drive larger than 65536*255*63 sectors (OS/2 502GiB Limit!)
     1217                                            ; DANIS506.ADD will use 255/127 extended geometry !
     1218                                            ; IBM1S506.ADD will use 255/255 extended geometry !
     1219
     1220        ; We have a drive that can be addressed using standard 255/63 geometry
     1221        dec     ax                                      ; Drive code (0)
     1222                                            ; We have a drive smaller than 65536*255*63 = 3EC10000 sectors
     1223
     1224    DriveIO_GatherDiskInfo_ret:
     1225        pop     es
     1226        pop     di
     1227        pop     si
     1228        pop     dx
     1229        pop     cx
     1230        pop     bx
     1231
     1232        mov      [CurIO_UseExtension],1
     1233
     1234        popf
     1235        ret
    12431236DriveIO_GatherDiskInfo  EndP
    12441237
  • trunk/BOOTCODE/REGULAR/OTHER.ASM

    r40 r43  
    2929;            Zero Flag set if nul string
    3030; Destroyed: None
    31 GetLenOfName                    Proc Near   Uses ax si
    32    add     si, cx
    33    dec     si
    34   GLON_NameLoop:
    35       mov     al, ds:[si]
    36       dec     si
    37       cmp     al, 32
    38       ja      GLON_EndLoop
    39       dec     cx
    40       jnz     GLON_NameLoop
    41   GLON_EndLoop:
    42    or      cx, cx
    43    ret                                   ; return supposed len
    44 GetLenOfName                    EndP
     31GetLenOfName        Proc Near   Uses ax si
     32        add     si, cx
     33        dec     si
     34    GLON_NameLoop:
     35        mov     al, ds:[si]
     36        dec     si
     37        cmp     al, 32
     38        ja      GLON_EndLoop
     39        dec     cx
     40        jnz     GLON_NameLoop
     41    GLON_EndLoop:
     42        or      cx, cx
     43        ret                                   ; return supposed len
     44GetLenOfName        EndP
    4545
    4646;        In: DS:SI - Pointer to NUL-terminated string
     
    4848;            Zero Flag set if nul string
    4949; Destroyed: None
    50 GetLenOfString                 Proc Near   Uses ax si
    51    xor     cx, cx
    52   GLOS_StringLoop:
    53       lodsb
    54       or      al, al
    55       jz      GLOS_EndOfString
    56       inc     cx
    57       jmp     GLOS_StringLoop
    58 
    59   GLOS_EndOfString:
    60    or      cx, cx
    61    ret
    62 GetLenOfString                 EndP
     50GetLenOfString      Proc Near   Uses ax si
     51        xor     cx, cx
     52    GLOS_StringLoop:
     53        lodsb
     54        or      al, al
     55        jz      GLOS_EndOfString
     56        inc     cx
     57        jmp     GLOS_StringLoop
     58
     59    GLOS_EndOfString:
     60        or      cx, cx
     61        ret
     62GetLenOfString      EndP
    6363
    6464;        In: DS:SI - Pointer to NUL-terminated strings
     
    6666;       Out: CX - Length of strings
    6767; Destroyed: None
    68 GetLenOfStrings                Proc Near   Uses bx dx si
    69    mov     dh, cl
    70    xor     dl, dl
    71   GLOSS_StringsLoop:
    72       call    GetLenOfString
    73       add     dl, cl
    74       add     si, cx
    75       inc     si
    76    dec     dh
    77    jnz     GLOSS_StringsLoop
    78    ;movzx   cx, dl
    79    mov   cl,dl
    80    mov   ch,0
    81 
    82    ret
    83 GetLenOfStrings                EndP
    84 
    85 PRECRAP_Main                    Proc Near
    86    ; First initialize Variable-Area (everything with NUL)
    87    mov     di, offset BeginOfVariables
    88    mov     cx, offset EndOfVariables-offset BeginOfVariables
    89    xor     ax, ax
    90    shr     cx, 1
    91    inc     cx
    92    rep     stosw
    93 
    94    mov     VideoIO_Segment, VideoIO_Page0
    95 
    96    ; Don't use blinking attribute
    97    call     VideoIO_NoBlinking
    98 
    99    ; Get HardDriveCount
    100    call    DriveIO_GetHardDriveCount
    101 
    102 
    103                ; Rousseau: added
    104                call    VideoIO_ClearScreen
    105 
    106                ; Cursor to upper-left
    107                mov     TextPosX, 0
    108                mov     TextPosY, 0
    109                call    VideoIO_CursorSet
    110 
    111                ;mov     ax, VideoIO_Page1
    112                ;call    VideoIO_BackUpTo   ; Copy BIOS POST to Second Page
    113 
    114                ; Copyright
    115                mov     si, offset Copyright
    116                call    MBR_Teletype
    117                xor     si,si
    118                call    MBR_TeletypeNL
    119 
    120 
    121                ;call    SOUND_Beep
    122 
    123                ; Build Date
    124                mov     si, offset BUILD_DATE
    125                call    MBR_TeletypeNL
    126 
    127                ; Initialize the com-port for debugging
    128 ;               call     AuxIO_Init
    129 
    130                xor     si,si
    131                call    MBR_TeletypeNL
    132 
    133                xor      cx,cx
    134             PRECRAP_Main_next_disk:
    135 
    136                mov      dl,cl
    137                or       dl,80h
    138 
    139                call     DriveIO_GatherDiskInfo              ; Also used to fill the geo, should be separate function
    140 
    141                mov      bx,offset HugeDisk
    142                add      bx,cx
    143                mov      [bx], al
    144 
    145                call     DriveIO_LoadMasterLVMSector         ; returns NC if no valid LVM record found
    146 
    147                pushf
    148 
    149 ;                mov     al,'#'
    150 ;                pushf
    151 ;                call    VideoIO_PrintSingleChar
    152 ;                popf
    153 ;                mov     al,0
    154 ;                rcl     al,1
    155 ;                call    VideoIO_PrintHexByte
    156 ;                mov     al,'#'
    157 ;                call    VideoIO_PrintSingleChar
    158 
    159                mov      bx, offset TrueSecs
    160                add      bx,cx
    161                add      bx,cx
    162                add      bx,cx
    163                add      bx,cx
    164                popf
    165 
    166                ; bx now contains pointer to truesecs for this drive
    167 
    168                jnc      NoValidMasterLVM
    169 
    170                 ; ?? 3f bij disk 80h maar 0 bij disk 81h
    171                mov      si,offset LVMSector
    172                mov      ax,[si+LocLVM_Secs]
    173 
    174 ;                pusha
    175 ;                mov     dx,ax
    176 ;                mov     al,'%'
    177 ;                call    VideoIO_PrintSingleChar
    178 ;                mov     ax,dx
    179 ;                call    VideoIO_PrintHexWord
    180 ;                mov     al,'%'
    181 ;                call    VideoIO_PrintSingleChar
    182 ;                popa
    183 
    184                mov      word ptr [bx],ax
    185                jmp      SkipUseBiosSecs
    186 
    187 
    188             NoValidMasterLVM:
    189                push     bx                   ; push truesecs pointer
    190                mov      bx, offset BIOS_Secs
    191                add      bx,cx
    192                add      bx,cx
    193                add      bx,cx
    194                add      bx,cx
    195 
    196                mov      ax,[bx]              ; get biossecs
    197                pop      bx
    198                mov      word ptr [bx],ax     ; store bios secs in truesecs
    199 
    200 
    201             SkipUseBiosSecs:
    202                inc      cx
    203                cmp      cl,[TotalHarddiscs]
    204                jb       PRECRAP_Main_next_disk
    205 
    206 
    207 
    208 IFDEF AuxDebug
    209                ; Write some debug-info to the com-port
    210                call     DEBUG_Dump1
    211 ENDIF
    212 
    213               ; jz       NoValidMasterLVM
    214 
    215 
    216                ; A valid Master LVM has been found.
    217                ; We use the values in here to determine the number of sectors per track,
    218                ; since this could be OS/2 extended geometry.
    219 
    220               ; jmp      Continue1
    221 
    222 
    223                ;mov      word ptr [LOG_Secs],63
     68GetLenOfStrings     Proc Near   Uses bx dx si
     69        mov     dh, cl
     70        xor     dl, dl
     71    GLOSS_StringsLoop:
     72        call    GetLenOfString
     73        add     dl, cl
     74        add     si, cx
     75        inc     si
     76        dec     dh
     77        jnz     GLOSS_StringsLoop
     78        ;movzx   cx, dl
     79        mov   cl,dl
     80        mov   ch,0
     81        ret
     82GetLenOfStrings     EndP
     83
     84PRECRAP_Main    Proc Near
     85        ; First initialize Variable-Area (everything with NUL)
     86        ; We use the start instead of the variables because they could be 'orged'
     87        ; to an offset. We want everything after the code to be nullified.
     88        mov     di, offset sobss
     89        mov     cx, offset EndOfVariables-offset BeginOfVariables
     90        xor     ax, ax
     91        shr     cx, 1
     92        inc     cx
     93        rep     stosw
     94
     95        mov     VideoIO_Segment, VideoIO_Page0
     96
     97        ; Don't use blinking attribute
     98        call    VideoIO_NoBlinking
     99
     100        ; Get HardDriveCount
     101        call    DriveIO_GetHardDriveCount
     102
     103
     104        ; Rousseau: added
     105        call    VideoIO_ClearScreen
     106
     107        ; Cursor to upper-left
     108        mov     TextPosX, 0
     109        mov     TextPosY, 0
     110        call    VideoIO_CursorSet
     111
     112        ;~ mov     ax, VideoIO_Page1
     113        ;~ call    VideoIO_BackUpTo   ; Copy BIOS POST to Second Page
     114
     115        ; Copyright
     116        mov     si, offset Copyright
     117        call    MBR_Teletype
     118        xor     si,si
     119        call    MBR_TeletypeNL
     120
     121
     122        ;call    SOUND_Beep
     123
     124        ; Build Date
     125        mov     si, offset BUILD_DATE
     126        call    MBR_TeletypeNL
     127
     128    IFDEF   AUX_DEBUG
     129        ; Initialize the com-port for debugging
     130        call     AuxIO_Init
     131    ENDIF
     132
     133        xor     si,si
     134        call    MBR_TeletypeNL
     135
     136        xor     cx,cx
     137    PRECRAP_Main_next_disk:
     138
     139        mov     dl,cl
     140        or      dl,80h
     141
     142        ;
     143        ; This also setup the size of the i13xbuf.
     144        ;
     145        call     DriveIO_GatherDiskInfo              ; Also used to fill the geo, should be separate function
     146
     147        mov      bx,offset HugeDisk
     148        add      bx,cx
     149        mov      [bx], al
     150
     151        call     DriveIO_LoadMasterLVMSector         ; returns NC if no valid LVM record found
     152
     153        pushf
     154
     155        ;~ mov     al,'#'
     156        ;~ pushf
     157        ;~ call    VideoIO_PrintSingleChar
     158        ;~ popf
     159        ;~ mov     al,0
     160        ;~ rcl     al,1
     161        ;~ call    VideoIO_PrintHexByte
     162        ;~ mov     al,'#'
     163        ;~ call    VideoIO_PrintSingleChar
     164
     165        mov      bx, offset TrueSecs
     166        add      bx,cx
     167        add      bx,cx
     168        add      bx,cx
     169        add      bx,cx
     170        popf
     171
     172        ; bx now contains pointer to truesecs for this drive
     173
     174        jnc      NoValidMasterLVM
     175
     176        ; ?? 3f bij disk 80h maar 0 bij disk 81h
     177        mov     si,offset LVMSector
     178        mov     ax,[si+LocLVM_Secs]
     179
     180        ;~ pusha
     181        ;~ mov     dx,ax
     182        ;~ mov     al,'%'
     183        ;~ call    VideoIO_PrintSingleChar
     184        ;~ mov     ax,dx
     185        ;~ call    VideoIO_PrintHexWord
     186        ;~ mov     al,'%'
     187        ;~ call    VideoIO_PrintSingleChar
     188        ;~ popa
     189
     190        mov      word ptr [bx],ax
     191        jmp      SkipUseBiosSecs
     192
     193
     194    NoValidMasterLVM:
     195        push    bx                   ; push truesecs pointer
     196        mov     bx, offset BIOS_Secs
     197        add     bx,cx
     198        add     bx,cx
     199        add     bx,cx
     200        add     bx,cx
     201
     202        mov     ax,[bx]              ; get biossecs
     203        pop     bx
     204        mov     word ptr [bx],ax     ; store bios secs in truesecs
     205
     206
     207    SkipUseBiosSecs:
     208        inc     cx
     209        cmp     cl,[TotalHarddiscs]
     210        jb      PRECRAP_Main_next_disk
     211
     212
     213
     214    IFDEF AUX_DEBUG
     215        ; Write some debug-info to the com-port
     216        call     DEBUG_Dump1
     217    ENDIF
     218
     219        ;~ jz      NoValidMasterLVM
     220;~
     221        ;~ ; A valid Master LVM has been found.
     222        ;~ ; We use the values in here to determine the number of sectors per track,
     223        ;~ ; since this could be OS/2 extended geometry.
     224;~
     225        ;~ jmp     Continue1
     226        ;~
     227        ;~ mov     word ptr [LOG_Secs],63
    224228
    225229;               mov      al,[HugeDisk]           ;; fout, moet nog index bij
     
    233237
    234238
    235                  ; Huge Disk indicator
    236                  mov     si, offset HugeBootDisk
    237                  call    MBR_Teletype
    238                  mov     al,[HugeDisk]
    239                  mov     si, offset No
    240                  test    al,al
    241                  jz      MBR_HugeDriveIndicator
    242                  mov     si, offset Yes
    243 
    244                MBR_HugeDriveIndicator:
    245                  call    MBR_Teletype
    246                  xor     si,si
    247                  call    MBR_TeletypeNL
    248 
    249 
    250 
    251 
    252 
    253                  ;
    254                  ; Phase 1 Indicator
    255                  ;
    256                  mov     si, offset Phase1
    257                  call    MBR_Teletype
    258 
    259                  mov     si, offset eCS_InstallVolume
    260                  mov     al, [si]
    261                  test    al,al                                 ; See if phase 1 is active
    262                  jnz     MBR_Main_BootThrough
    263                  mov     si, offset NotActive
    264 
    265                MBR_Main_BootThrough:
    266                  call    MBR_Teletype
    267                  xor     si,si
    268                  call    MBR_TeletypeNL
    269 
    270 
    271    ; Calculate Cooper-Bar Tables
    272    call    FX_CalculateTables
    273 
    274    ; Calculate LVM-CRC-Table
    275    call    LVM_InitCRCTable
    276 
    277    ; Get HardDriveCount
    278    call    DriveIO_GetHardDriveCount
    279 
    280    ; Calculate CHS/LBA Switch Table
    281    call    DriveIO_InitLBASwitchTable
    282 
    283    ; Setup PartitionPointers-Table
    284    call    PART_CalculateStraightPartPointers
    285 
    286    ; Setup Cyrillic Charset, if needed
    287    ifdef TXT_IncludeCyrillic
    288       call    CHARSET_IncludeCyrillic
    289    endif
    290 
    291 
    292     ; This sets [CurIO_UseExtension] flag.
    293     call    PRECRAP_CheckFor13extensions
    294 
    295 
    296 
    297    IFNDEF ReleaseCode
    298       ret
    299    ENDIF
    300 
    301 
    302    call    PRECRAP_CheckConfiguration
    303 
    304 
    305    ; =======================================
    306    ; Checks for MBR Virii :) I love that job
    307    ; =======================================
    308    test    CFG_DetectStealth, 1
    309    jz      PCM_NoStealthDetection
    310       call    VIRUS_CheckForStealth
    311   PCM_NoStealthDetection:
    312    test    CFG_DetectVirus, 1
    313    jz      PCM_NoVirusDetection
    314       call    VIRUS_CheckForVirus
    315   PCM_NoVirusDetection:
    316 
    317 
    318    ; ============================================
    319    ;  Delay for some time and get Strg/Alt State
    320    ; ============================================
    321    test    CFG_CooperBars, 1
    322    jnz     PCM_ShortDelay
    323    mov     al, 27                        ; About 1.5 seconds
    324    test    CFG_FloppyBootGetName, 1
    325    jz      PCM_LongDelay
    326   PCM_ShortDelay:
    327 
    328    mov     al, 13                        ; shorten delay,if floppy gets accessed
    329   PCM_LongDelay:
    330 
    331    call    TIMER_WaitTicCount
    332 
    333    ; First check, if any normal key got pressed...
    334    mov     ah, 1
    335    int     16h
    336    jz      PCM_NoNormalKeyPressed
    337    ; User doesn't know what to do...or he is crazy <g> so display message
    338    mov     si, offset TXT_HowEnterSetup
    339    call    MBR_Teletype
    340    mov     al, 54                        ; about 3 seconds, delay again
    341 
    342    call    TIMER_WaitTicCount
    343 
    344   PCM_NoNormalKeyPressed:
    345    ; Now get keyboard Strg/Alt State
    346    mov     ah, 02h
    347    int     16h
    348    mov     SETUP_KeysOnEntry, al
    349 
    350    ; Copy device-name to the ContBIOSbootSeq-IPT entry
    351    ;  We may not do this before PRECRAP_CheckConfiguration, because otherwise
    352    ;  this check will fail.
    353    call    PART_UpdateResumeBIOSName
    354    ret
    355 PRECRAP_Main                    EndP
    356 
    357 
    358 
    359 AFTERCRAP_Main                  Proc Near
    360    ; ===================================================
    361    ;  Now get volume label of FloppyDrive, if wanted...
    362    ; ===================================================
    363    test    CFG_FloppyBootGetName, 1
    364    jz      ACM_NoFloppyGetName
    365       call    DriveIO_UpdateFloppyName
    366       or      ax, ax
    367       jnz     ACM_NoFloppyGetName
    368       ; Try a second time, if it failed to detect the Floppy
    369       call    DriveIO_UpdateFloppyName
    370   ACM_NoFloppyGetName:
    371    ret
    372 AFTERCRAP_Main                  EndP
     239        ; Huge Disk indicator
     240        mov     si, offset HugeBootDisk
     241        call    MBR_Teletype
     242        mov     al,[HugeDisk]
     243        mov     si, offset No
     244        test    al,al
     245        jz      MBR_HugeDriveIndicator
     246        mov     si, offset Yes
     247
     248    MBR_HugeDriveIndicator:
     249        call    MBR_Teletype
     250        xor     si,si
     251        call    MBR_TeletypeNL
     252
     253
     254        ;
     255        ; Phase 1 Indicator
     256        ;
     257        mov     si, offset Phase1
     258        call    MBR_Teletype
     259
     260        mov     si, offset eCS_InstallVolume
     261        mov     al, [si]
     262        test    al,al                                 ; See if phase 1 is active
     263        jnz     MBR_Main_BootThrough
     264        mov     si, offset NotActive
     265
     266    MBR_Main_BootThrough:
     267        call    MBR_Teletype
     268        xor     si,si
     269        call    MBR_TeletypeNL
     270
     271
     272        ; Calculate Cooper-Bar Tables
     273        call    FX_CalculateTables
     274
     275        ; Calculate LVM-CRC-Table
     276        call    LVM_InitCRCTable
     277
     278        ; Get HardDriveCount
     279        call    DriveIO_GetHardDriveCount
     280
     281        ; Calculate CHS/LBA Switch Table
     282        call    DriveIO_InitLBASwitchTable
     283
     284        ; Setup PartitionPointers-Table
     285        call    PART_CalculateStraightPartPointers
     286
     287        ; Setup Cyrillic Charset, if needed
     288    IFDEF TXT_IncludeCyrillic
     289        call    CHARSET_IncludeCyrillic
     290    ENDIF
     291
     292
     293        ; This sets [CurIO_UseExtension] flag.
     294        call    PRECRAP_CheckFor13extensions
     295
     296    IFNDEF ReleaseCode
     297        ret
     298    ENDIF
     299
     300
     301    call    PRECRAP_CheckConfiguration
     302
     303
     304        ; =======================================
     305        ; Checks for MBR Virii :) I love that job
     306        ; =======================================
     307        test    CFG_DetectStealth, 1
     308        jz      PCM_NoStealthDetection
     309        call    VIRUS_CheckForStealth
     310    PCM_NoStealthDetection:
     311        test    CFG_DetectVirus, 1
     312        jz      PCM_NoVirusDetection
     313        call    VIRUS_CheckForVirus
     314    PCM_NoVirusDetection:
     315
     316
     317        ; ============================================
     318        ;  Delay for some time and get Strg/Alt State
     319        ; ============================================
     320        test    CFG_CooperBars, 1
     321        jnz     PCM_ShortDelay
     322        mov     al, 27                        ; About 1.5 seconds
     323        test    CFG_FloppyBootGetName, 1
     324        jz      PCM_LongDelay
     325    PCM_ShortDelay:
     326
     327        mov     al, 13                        ; shorten delay,if floppy gets accessed
     328    PCM_LongDelay:
     329
     330        call    TIMER_WaitTicCount
     331
     332        ; First check, if any normal key got pressed...
     333        mov     ah, 1
     334        int     16h
     335        jz      PCM_NoNormalKeyPressed
     336        ; User doesn't know what to do...or he is crazy <g> so display message
     337        mov     si, offset TXT_HowEnterSetup
     338        call    MBR_Teletype
     339        mov     al, 54                        ; about 3 seconds, delay again
     340
     341        call    TIMER_WaitTicCount
     342
     343    PCM_NoNormalKeyPressed:
     344        ; Now get keyboard Strg/Alt State
     345        mov     ah, 02h
     346        int     16h
     347        mov     SETUP_KeysOnEntry, al
     348
     349        ; Copy device-name to the ContBIOSbootSeq-IPT entry
     350        ; We may not do this before PRECRAP_CheckConfiguration, because otherwise
     351        ; this check will fail.
     352        call    PART_UpdateResumeBIOSName
     353        ret
     354PRECRAP_Main    EndP
     355
     356AFTERCRAP_Main  Proc Near
     357        ; ===================================================
     358        ;  Now get volume label of FloppyDrive, if wanted...
     359        ; ===================================================
     360        test    CFG_FloppyBootGetName, 1
     361        jz      ACM_NoFloppyGetName
     362        call    DriveIO_UpdateFloppyName
     363        or      ax, ax
     364        jnz     ACM_NoFloppyGetName
     365        ; Try a second time, if it failed to detect the Floppy
     366        call    DriveIO_UpdateFloppyName
     367    ACM_NoFloppyGetName:
     368        ret
     369AFTERCRAP_Main  EndP
    373370
    374371PRECRAP_CheckFor13extensions    Proc Near
    375    mov     ah, 41h
    376    mov     bx, 55AAh
    377    mov     dl, 80h
    378    int     13h
    379    cmp     bx, 0AA55h
    380    je      PCCF13E_Found
    381   PCCF13E_NotFound:
    382    ret
    383   PCCF13E_Found:
    384    and     cx, 1
    385    jz      PCCF13E_NotFound
    386    mov     CurIO_UseExtension, 1
    387    ret
     372        mov     ah, 41h
     373        mov     bx, 55AAh
     374        mov     dl, 80h
     375        int     13h
     376        cmp     bx, 0AA55h
     377        je      PCCF13E_Found
     378    PCCF13E_NotFound:
     379        ret
     380    PCCF13E_Found:
     381        and     cx, 1
     382        jz      PCCF13E_NotFound
     383        mov     CurIO_UseExtension, 1
     384        ret
    388385PRECRAP_CheckFor13extensions    EndP
     386
    389387
    390388; Checks Configuration CheckSum...Displays message, if failed.
    391389PRECRAP_CheckConfiguration      Proc Near  Uses ds si es di
    392    mov     si, offset Configuration
    393    xor     bx, bx
    394 
    395    ; Changed from 5 to calculated value (not here, see compat. issue below)
    396    ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
    397    ; Size of the ab-configuration in 512 byte sectors
    398    ;mov     cx, (MBR_BackUpMBR - Configuration) / 200h
    399 
    400    ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
    401    ; AB v1.0.8 *should* stores a 7 sector configuration with a
    402    ; 7 sector checksum.
    403    ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8
    404    ; config as corrupted, while this is not the case.
    405    ; So, for compatibility reasons, in v1.0.8, the checksum stored is over
    406    ; 5 sectors, to be compatible with v1.07.
    407    ; This may change (be corrected) in future versions !
    408    mov      cx,5
    409 
    410    mov     dx, CFG_CheckConfig
    411    mov     CFG_CheckConfig, bx
    412   PCCC_Loop:
    413       call    MBR_GetCheckOfSector
    414    loop    PCCC_Loop
    415    cmp     bx, dx
    416    jne     PCCC_Failed
    417    mov     CFG_CheckConfig, dx
    418    ret
    419   PCCC_Failed:
    420    mov     si, offset TXT_ERROR_CheckConfig
    421    call    MBR_Teletype
    422    mov     si, offset TXT_ERROR_CheckFailed
    423    call    MBR_Teletype
    424    jmp     MBR_HaltSystem
     390        mov     si, offset Configuration
     391        xor     bx, bx
     392
     393        ; Changed from 5 to calculated value (not here, see compat. issue below)
     394        ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
     395        ; Size of the ab-configuration in 512 byte sectors
     396        ; mov     cx, (MBR_BackUpMBR - Configuration) / 200h
     397
     398        ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
     399        ; AB v1.0.8 *should* stores a 7 sector configuration with a
     400        ; 7 sector checksum.
     401        ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8
     402        ; config as corrupted, while this is not the case.
     403        ; So, for compatibility reasons, in v1.0.8, the checksum stored is over
     404        ; 5 sectors, to be compatible with v1.07.
     405        ; This may change (be corrected) in future versions !
     406        mov      cx,5
     407
     408        mov     dx, CFG_CheckConfig
     409        mov     CFG_CheckConfig, bx
     410    PCCC_Loop:
     411        call    MBR_GetCheckOfSector
     412        loop    PCCC_Loop
     413        cmp     bx, dx
     414        jne     PCCC_Failed
     415        mov     CFG_CheckConfig, dx
     416        ret
     417    PCCC_Failed:
     418        mov     si, offset TXT_ERROR_CheckConfig
     419        call    MBR_Teletype
     420        mov     si, offset TXT_ERROR_CheckFailed
     421        call    MBR_Teletype
     422        jmp     MBR_HaltSystem
    425423PRECRAP_CheckConfiguration      EndP
    426424
     
    430428; Destroyed: SI
    431429; Fixme: Uses double writes to use attribute with teletype-function.
    432 MBR_TeletypeBold                Proc Near   Uses ax bx cx
    433   MBRT_LoopBold:
    434    lodsb
    435    or      al, al
    436    jz      MBRT_EndBold
    437    push    ax
    438    mov     ah,09h
    439    mov     bx,15
    440    mov     cx,1
    441    int     10h
    442    pop     ax
    443    mov     ah,0eh
    444    mov     bx,7            ; Does not do anything in text-modus
    445    mov     cx,1
    446    int     10h
    447    jmp     MBRT_LoopBold
    448   MBRT_EndBold:
    449    ret
    450 MBR_TeletypeBold                EndP
     430MBR_TeletypeBold    Proc Near   Uses ax bx cx
     431    MBRT_LoopBold:
     432        lodsb
     433        or      al, al
     434        jz      MBRT_EndBold
     435        push    ax
     436        mov     ah,09h
     437        mov     bx,15
     438        mov     cx,1
     439        int     10h
     440        pop     ax
     441        mov     ah,0eh
     442        mov     bx,7            ; Does not do anything in text-modus
     443        mov     cx,1
     444        int     10h
     445        jmp     MBRT_LoopBold
     446    MBRT_EndBold:
     447        ret
     448MBR_TeletypeBold    EndP
     449
    451450
    452451;        In: SI - Pointer to begin of string (EOS is 0)
    453452; Destroyed: SI
    454453; Fixme: Uses double writes to use attribute with teletype-function.
    455 MBR_TeletypeVolName             Proc Near   Uses ax bx cx
    456    mov     cx, 11
    457   MBRT_LoopVolName:
    458    mov     dx,cx           ; Backup counter
    459    lodsb
    460    or      al, al
    461    jz      MBRT_EndVolName
    462    push    ax
    463    mov     ah,09h
    464    mov     bx,15
    465    mov     cx,1
    466    int     10h             ; DX is preserved
    467    pop     ax
    468    mov     ah,0eh
    469    mov     bx,7            ; Does not do anything in text-modus
    470    mov     cx,1
    471    int     10h             ; DX is preserved
    472    mov     cx,dx           ; Restore counter
    473    loop    MBRT_LoopVolName
    474   MBRT_EndVolName:
    475    ret
    476 MBR_TeletypeVolName             EndP
     454MBR_TeletypeVolName     Proc Near   Uses ax bx cx
     455        mov     cx, 11
     456    MBRT_LoopVolName:
     457        mov     dx,cx           ; Backup counter
     458        lodsb
     459        or      al, al
     460        jz      MBRT_EndVolName
     461        push    ax
     462        mov     ah,09h
     463        mov     bx,15
     464        mov     cx,1
     465        int     10h             ; DX is preserved
     466        pop     ax
     467        mov     ah,0eh
     468        mov     bx,7            ; Does not do anything in text-modus
     469        mov     cx,1
     470        int     10h             ; DX is preserved
     471        mov     cx,dx           ; Restore counter
     472        loop    MBRT_LoopVolName
     473    MBRT_EndVolName:
     474        ret
     475MBR_TeletypeVolName     EndP
    477476
    478477; Rousseau: added
    479478; Move cursor to next line
    480479; Just do a new-line if SI==0
    481 MBR_TeletypeNL                  Proc Near   Uses ax bx cx
    482    test    si,si
    483    jz      MBR_TeletypeNL_NL
    484    call    MBR_Teletype
    485   MBR_TeletypeNL_NL:
    486    push    si
    487    mov     si, offset NL
    488    call    MBR_Teletype
    489    pop     si
    490    ret
    491 MBR_TeletypeNL                  EndP
     480MBR_TeletypeNL      Proc Near   Uses ax bx cx
     481        test    si,si
     482        jz      MBR_TeletypeNL_NL
     483        call    MBR_Teletype
     484    MBR_TeletypeNL_NL:
     485        push    si
     486        mov     si, offset NL
     487        call    MBR_Teletype
     488        pop     si
     489        ret
     490MBR_TeletypeNL      EndP
    492491
    493492; Sync teletype position to VideoIO
    494493MBR_TeletypeSyncPos     Proc Near   Uses ax bx cx dx
    495    pushf
    496    mov   bh, 0
    497    mov   ah, 02h
    498    mov   dh,[TextPosY]
    499    mov   dl,[TextPosX]
    500    int   10h
    501    popf
    502    ret
     494        pushf
     495        mov     bh, 0
     496        mov     ah, 02h
     497        mov     dh,[TextPosY]
     498        mov     dl,[TextPosX]
     499        int     10h
     500        popf
     501        ret
    503502MBR_TeletypeSyncPos     EndP
  • trunk/BOOTCODE/REGULAR/PARTMAIN.ASM

    r40 r43  
    16201620
    16211621
    1622 IFDEF AuxDebug
    1623 ;   call     DEBUG_Dump2
     1622IFDEF AUX_DEBUG
     1623   call     DEBUG_Dump2
     1624   call     DEBUG_DumpBSSSectors
    16241625ENDIF
    16251626
  • trunk/BOOTCODE/REGULAR/PARTSCAN.ASM

    r40 r43  
    2929
    3030PARTSCAN_ScanForPartitions      Proc Near
    31    ; Reset X-Reference
    32    call    PARTSCAN_ResetXref
    33 
    34    mov     dh, TotalHarddiscs
    35    xor     al, al
    36    mov     NewPartitions, al
    37 
    38    mov     CurIO_Scanning, 1             ; Set flag due scanning partitions
    39    mov     dl, 80h                       ; is first harddisc
    40   PSSFP_HarddiscLoop:
    41       push    dx
    42          call    PARTSCAN_ScanDriveForPartitions
    43       pop     dx
    44       inc     dl
    45    dec     dh
    46    jnz     PSSFP_HarddiscLoop
    47    mov     CurIO_Scanning, 0             ; Reset flag due scanning complete
    48 
    49    ; Use X-Reference to sync NewPartitionTable with Hide-Config
    50    call    PARTSCAN_SyncHideConfigWithXref
    51 
    52    ; Now we copy the new IPT over the old one...
    53    mov     si, offset NewPartTable
    54    mov     di, offset PartitionTable
    55    ;movzx   ax, NewPartitions
    56    mov   al,NewPartitions
    57    mov   ah,0
    58 
    59    mov     CFG_Partitions, al
    60    mov     bl, LocIPT_LenOfIPT
    61    mul     bl
    62    mov     cx, ax
    63    rep     movsb
    64 
    65    ; and the New Logical Drive Letter table as well...
    66    mov     si, offset NewDriveLetters
    67    mov     di, offset DriveLetters
    68    mov     cx, LocIPT_MaxPartitions
    69    rep     movsb
     31        ; Reset X-Reference
     32        call    PARTSCAN_ResetXref
     33
     34        mov     dh, TotalHarddiscs
     35        xor     al, al
     36        mov     NewPartitions, al
     37
     38        mov     CurIO_Scanning, 1             ; Set flag due scanning partitions
     39        mov     dl, 80h                       ; is first harddisc
     40    PSSFP_HarddiscLoop:
     41
     42        push    dx
     43        call    PARTSCAN_ScanDriveForPartitions
     44        pop     dx
     45        inc     dl
     46        dec     dh
     47        jnz     PSSFP_HarddiscLoop
     48        mov     CurIO_Scanning, 0             ; Reset flag due scanning complete
     49
     50        ; Use X-Reference to sync NewPartitionTable with Hide-Config
     51        call    PARTSCAN_SyncHideConfigWithXref
     52
     53        ; Now we copy the new IPT over the old one...
     54        mov     si, offset NewPartTable
     55        mov     di, offset PartitionTable
     56        ;movzx   ax, NewPartitions
     57        mov   al,NewPartitions
     58        mov   ah,0
     59
     60        mov     CFG_Partitions, al
     61        mov     bl, LocIPT_LenOfIPT
     62        mul     bl
     63        mov     cx, ax
     64        rep     movsb
     65
     66        ; and the New Logical Drive Letter table as well...
     67        mov     si, offset NewDriveLetters
     68        mov     di, offset DriveLetters
     69        mov     cx, LocIPT_MaxPartitions
     70        rep     movsb
    7071
    7172; [Linux support removed since v1.02]
     
    8687;   mov     GotLinux, dl                  ; Set Flag
    8788
    88    ; ...and finally check, if we need to set a Drive-Letter
    89    mov     dl, AutoDrvLetter
    90    or      dl, dl
    91    jz      PSSFP_NoAutoDriveLetter
    92    ;movzx   cx, CFG_Partitions
    93    mov   cl,CFG_Partitions
    94    mov   ch,0
    95 
    96    or      cx, cx
    97    jz      PSSFP_NoAutoDriveLetter
    98    mov     si, offset PartitionTable
    99    mov     di, offset DriveLetters
    100    mov     ax, wptr [AutoDrvLetterSerial]
    101    mov     bx, wptr [AutoDrvLetterSerial+2]
    102   PSSFP_AutoDrvLetterLoop:
    103       cmp     ax, [si+LocIPT_Serial]
    104       jne     PSSFP_AutoDrvLetterNoMatch
    105       cmp     bx, [si+LocIPT_Serial+2]
    106       jne     PSSFP_AutoDrvLetterNoMatch
    107       ; We got a match, so set Drive-Letter in DL
    108       or      bptr [si+LocIPT_Flags], Flags_DriveLetter
    109       mov     [di], dl
    110      PSSFP_AutoDrvLetterNoMatch:
    111       add     si, LocIPT_LenOfIPT
    112       inc     di
    113    loop    PSSFP_AutoDrvLetterLoop
    114    mov     AutoDrvLetter, 0              ; Disable after processing...
    115   PSSFP_NoAutoDriveLetter:
    116    ret
     89        ; ...and finally check, if we need to set a Drive-Letter
     90        mov     dl, AutoDrvLetter
     91        or      dl, dl
     92        jz      PSSFP_NoAutoDriveLetter
     93        ;movzx   cx, CFG_Partitions
     94        mov   cl,CFG_Partitions
     95        mov   ch,0
     96
     97        or      cx, cx
     98        jz      PSSFP_NoAutoDriveLetter
     99        mov     si, offset PartitionTable
     100        mov     di, offset DriveLetters
     101        mov     ax, wptr [AutoDrvLetterSerial]
     102        mov     bx, wptr [AutoDrvLetterSerial+2]
     103    PSSFP_AutoDrvLetterLoop:
     104        cmp     ax, [si+LocIPT_Serial]
     105        jne     PSSFP_AutoDrvLetterNoMatch
     106        cmp     bx, [si+LocIPT_Serial+2]
     107        jne     PSSFP_AutoDrvLetterNoMatch
     108        ; We got a match, so set Drive-Letter in DL
     109        or      bptr [si+LocIPT_Flags], Flags_DriveLetter
     110        mov     [di], dl
     111    PSSFP_AutoDrvLetterNoMatch:
     112        add     si, LocIPT_LenOfIPT
     113        inc     di
     114        loop    PSSFP_AutoDrvLetterLoop
     115        mov     AutoDrvLetter, 0              ; Disable after processing...
     116    PSSFP_NoAutoDriveLetter:
     117        ret
    117118PARTSCAN_ScanForPartitions      EndP
    118119
     
    121122; falls eine Extended Partition (DOS) gefunden wird, wird erneut gescannt.
    122123PARTSCAN_ScanDriveForPartitions Proc Near
    123    xor     ax, ax
    124    xor     bx, bx     ; Location Absoluter Sektor 0
    125    mov     cx, 0001h
    126    xor     dh, dh     ; Location Zylinder 0, Side 0, Sektor 1 MBR
    127    mov     [ExtendedAbsPosSet], al
    128    mov     wptr [ExtendedAbsPos+0], ax
    129    mov     wptr [ExtendedAbsPos+2], ax
    130   PSSDFP_LoadThisPartition:
    131 
    132    call    DriveIO_LoadPartition                ; Load a partition record
    133 
    134    jc      PSSDFP_InvalidPartition
    135 
    136    ; LVM Support - Reads LVM Information Sector
    137    call    DriveIO_LoadLVMSector                ; Load LVM sector
    138 
    139    call    PARTSCAN_ScanPartition
    140    IFDEF ReleaseCode
    141       call    DriveIO_SavePartition
    142    ENDIF
    143    call    PARTSCAN_ScanPartitionForExtended
    144    jc      PSSDFP_LoadThisPartition
    145   PSSDFP_InvalidPartition:
    146    ret
     124        xor     ax, ax
     125        xor     bx, bx     ; Location Absoluter Sektor 0
     126        mov     cx, 0001h
     127        xor     dh, dh     ; Location Zylinder 0, Side 0, Sektor 1 MBR
     128        mov     [ExtendedAbsPosSet], al
     129        mov     wptr [ExtendedAbsPos+0], ax
     130        mov     wptr [ExtendedAbsPos+2], ax
     131    PSSDFP_LoadThisPartition:
     132
     133        call    DriveIO_LoadPartition                ; Load a partition record
     134
     135        jc      PSSDFP_InvalidPartition
     136
     137        ; LVM Support - Reads LVM Information Sector
     138        call    DriveIO_LoadLVMSector                ; Load LVM sector
     139
     140        call    PARTSCAN_ScanPartition
     141    IFDEF ReleaseCode
     142        call    DriveIO_SavePartition
     143    ENDIF
     144        call    PARTSCAN_ScanPartitionForExtended
     145        jc      PSSDFP_LoadThisPartition
     146    PSSDFP_InvalidPartition:
     147        ret
    147148PARTSCAN_ScanDriveForPartitions EndP
    148149
     
    150151; be set to this location and Carry will be set
    151152PARTSCAN_ScanPartitionForExtended Proc Near  Uses si
    152    mov     si, offset PartitionSector+446 ; DS:SI - 1st partition entry
    153    xor     ax, ax
    154   PSSPFE_ScanLoop:
    155       mov     al, [si+LocBRPT_SystemID]
    156       cmp     al, 5                      ; Is Partition EXTENDED ?
    157       je      PSSPFE_ExtendedPartition
    158       cmp     al, 0Fh                    ; Is Partition EXTENDED (M$) ?
    159       je      PSSPFE_ExtendedPartition
    160       jmp     PSSPFE_IgnorePartition
    161      PSSPFE_ExtendedPartition:
    162       mov     ax, wptr [si+LocBRPT_RelativeBegin]
    163       mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
    164       add     ax, wptr [ExtendedAbsPos+0] ; Adjust...
    165       adc     bx, wptr [ExtendedAbsPos+2] ; (Shit Design!)
    166       test    [ExtendedAbsPosSet], 1
    167       jnz     PSSPFE_ExtendedMainKnown
    168       mov     wptr [ExtendedAbsPos+0], ax
    169       mov     wptr [ExtendedAbsPos+2], bx
    170       mov     [ExtendedAbsPosSet], 1
    171      PSSPFE_ExtendedMainKnown:
    172       mov     cx, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
    173       mov     dh, bptr [si+LocBRPT_BeginHead]   ; Head
    174       mov     dl, bptr [CurPartition_Location+4] ; Drive
    175       stc
    176       jmp     PSSPFE_EndOfSearch
    177      PSSPFE_IgnorePartition:
    178       add     si, LocBRPT_LenOfEntry
    179    cmp     si, 500+offset PartitionSector
    180    jb      PSSPFE_ScanLoop
    181    clc
    182   PSSPFE_EndOfSearch:
    183    ret
     153        mov     si, offset PartitionSector+446 ; DS:SI - 1st partition entry
     154        xor     ax, ax
     155    PSSPFE_ScanLoop:
     156            mov     al, [si+LocBRPT_SystemID]
     157            cmp     al, 5                      ; Is Partition EXTENDED ?
     158            je      PSSPFE_ExtendedPartition
     159            cmp     al, 0Fh                    ; Is Partition EXTENDED (M$) ?
     160            je      PSSPFE_ExtendedPartition
     161            jmp     PSSPFE_IgnorePartition
     162        PSSPFE_ExtendedPartition:
     163            mov     ax, wptr [si+LocBRPT_RelativeBegin]
     164            mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
     165            add     ax, wptr [ExtendedAbsPos+0] ; Adjust...
     166            adc     bx, wptr [ExtendedAbsPos+2] ; (Shit Design!)
     167            test    [ExtendedAbsPosSet], 1
     168            jnz     PSSPFE_ExtendedMainKnown
     169            mov     wptr [ExtendedAbsPos+0], ax
     170            mov     wptr [ExtendedAbsPos+2], bx
     171            mov     [ExtendedAbsPosSet], 1
     172        PSSPFE_ExtendedMainKnown:
     173            mov     cx, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
     174            mov     dh, bptr [si+LocBRPT_BeginHead]   ; Head
     175            mov     dl, bptr [CurPartition_Location+4] ; Drive
     176            stc
     177            jmp     PSSPFE_EndOfSearch
     178        PSSPFE_IgnorePartition:
     179            add     si, LocBRPT_LenOfEntry
     180            cmp     si, 500+offset PartitionSector
     181        jb      PSSPFE_ScanLoop
     182        clc
     183    PSSPFE_EndOfSearch:
     184        ret
    184185PARTSCAN_ScanPartitionForExtended EndP
    185186
    186187; The following routines have NOT *DS* set to CS, so we must address via ES
    187188PARTSCAN_ScanPartition          Proc Near  Uses ax si
    188    mov     si, offset PartitionSector+446 ; DS:SI - 1st Partition-Entry
    189   PSSP_ScanLoop:
    190       mov     al, bptr [si+LocBRPT_SystemID]
    191       cmp     al, 5                      ; Is Partition EXTENDED ?
    192       je      PSSP_IgnorePartition
    193       cmp     al, 0Fh                    ; Is Partition EXTENDED (M$-DOS7) ?
    194       je      PSSP_IgnorePartition
    195       cmp     al, 0                      ; Is Partition EMPTY ?
    196       je      PSSP_IgnorePartition
    197       ; Ignore these partitions, because there are no real Partitions
    198       call    PARTSCAN_CheckThisPartition
    199      PSSP_IgnorePartition:
    200       ; L”scht das Boot-Able Flag...
    201       and     byte ptr [si+LocBRPT_Flags], 7Fh ; Reset the Active-Flag
    202       add     si, LocBRPT_LenOfEntry     ; 16 Bytes per partition entry
    203    cmp     si, 500+offset PartitionSector
    204    jb      PSSP_ScanLoop
    205    ; If we are on first HDD and in primary partition table -> mark primary
    206    cmp     bptr [CurPartition_Location+4], 80h ; Drive
    207    jne     PSSP_NoMarkPrimary
    208    cmp     wptr [CurPartition_Location+0], 0
    209    jne     PSSP_NoMarkPrimary
    210    cmp     wptr [CurPartition_Location+2], 0 ; Absolute Location
    211    jne     PSSP_NoMarkPrimary
    212    call    PART_MarkFirstGoodPrimary
    213   PSSP_NoMarkPrimary:
    214    ret
     189        mov     si, offset PartitionSector+446 ; DS:SI - 1st Partition-Entry
     190    PSSP_ScanLoop:
     191        mov     al, bptr [si+LocBRPT_SystemID]
     192        cmp     al, 5                      ; Is Partition EXTENDED ?
     193        je      PSSP_IgnorePartition
     194        cmp     al, 0Fh                    ; Is Partition EXTENDED (M$-DOS7) ?
     195        je      PSSP_IgnorePartition
     196        cmp     al, 0                      ; Is Partition EMPTY ?
     197        je      PSSP_IgnorePartition
     198        ; Ignore these partitions, because there are no real Partitions
     199                call    DEBUG_DumpBSSSectors
     200        call    PARTSCAN_CheckThisPartition
     201                call    DEBUG_DumpBSSSectors
     202    PSSP_IgnorePartition:
     203        ; L”scht das Boot-Able Flag...
     204        and     byte ptr [si+LocBRPT_Flags], 7Fh ; Reset the Active-Flag
     205        add     si, LocBRPT_LenOfEntry     ; 16 Bytes per partition entry
     206        cmp     si, 500+offset PartitionSector
     207        jb      PSSP_ScanLoop
     208        ; If we are on first HDD and in primary partition table -> mark primary
     209        cmp     bptr [CurPartition_Location+4], 80h ; Drive
     210        jne     PSSP_NoMarkPrimary
     211        cmp     wptr [CurPartition_Location+0], 0
     212        jne     PSSP_NoMarkPrimary
     213        cmp     wptr [CurPartition_Location+2], 0 ; Absolute Location
     214        jne     PSSP_NoMarkPrimary
     215        call    PART_MarkFirstGoodPrimary
     216    PSSP_NoMarkPrimary:
     217        ret
    215218PARTSCAN_ScanPartition          EndP
    216219
     
    223226;        In: SI - Points to Partition-Entry (16-Bytes)
    224227PARTSCAN_CheckThisPartition     Proc Near  Uses di si
    225    local   PartSystemID:byte, PartTypeFlags:byte
    226    local   PartCRC:word, PartPtr:word
    227 
    228    mov     wptr [PartPtr], si          ; Save Pointer to PartitionEntry
    229 
    230    mov     al, bptr [si+LocBRPT_SystemID]
    231    mov     PartSystemID, al
    232 
    233    mov     cx, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
    234    mov     dh, bptr [si+LocBRPT_BeginHead] ; Head
    235    mov     dl, bptr [CurPartition_Location+4] ; Drive
    236    mov     ax, wptr [si+LocBRPT_RelativeBegin] ; Absolute Sector
    237    mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
    238    add     ax, wptr [CurPartition_Location+0] ; +Partition-Absolute
    239    adc     bx, wptr [CurPartition_Location+2] ;  sectors
    240    call    DriveIO_LoadTmpSector         ; Loads Boot record                     ; Rousseau: LOAD PARTITION BOOT RECORD !!
    241    ; Sets up DS:SI - TmpSector
    242 
    243    push    si
    244       mov     bx, 4B4Dh                  ; Magic 'MK' :)
    245       call    MBR_GetCheckOfSector
    246       mov     PartCRC, bx                ; Save Partition's-CRC
    247 
    248       ; ------------------------------ Gets internal infos of partition type
    249       mov     al, PartSystemID
    250       call    PART_SearchFileSysName
    251       ; Replies AH - FileSysFlags, AL - UnhiddenID, SI - FileSystemNamePtr
    252       mov     di, si
    253       mov     PartTypeFlags, ah
    254       mov     PartSystemID, al           ; Use Unhidden-ID
    255    pop     si
    256 
    257    ;================================
    258    ; AL - File System ID (Unhidden)
    259    ; AH - File System Flags
    260    ; SI - Boot-Record of Partition
    261    ; DI - File System Name
    262    ;================================
    263 
    264    cmp     PartSystemID, 07h          ; We got IFS here?
    265    jne     PCCTP_IFSdone
    266    ; Check, if 'JFS ' is at DWORD offset 36h                                     ; Rousseau: JFS check (LVM / IPT?)
    267    cmp     wptr [si+36h], 'FJ'
    268    jne     PCCTP_IFSnoJFS
    269    cmp     wptr [si+38h], ' S'
    270    jne     PCCTP_IFSnoJFS
    271    mov     PartSystemID, 0FCh         ; FC is JFS internally
    272    jmp     PCCTP_IFSdone
    273   PCCTP_IFSnoJFS:
    274    ; Check, if 'HPFS' is at DWORD offset 36h
    275    cmp     wptr [si+36h], 'PH'
    276    jne     PCCTP_ProbablyNTFS
    277    cmp     wptr [si+38h], 'SF'
    278    je      PCCTP_IFSdone              ; 07 is HPFS internally
    279   PCCTP_ProbablyNTFS:
    280    inc     PartSystemID               ; 08 is NTFS instead of 07
    281   PCCTP_IFSdone:
    282 
    283    ; First check, if LVM Information Sector is available and this partition
    284    ;  is supported.
    285    push    ax
    286    push    dx
    287    push    si
    288    push    di
    289       mov     si, wptr [PartPtr]
    290       mov     ax, wptr [si+LocBRPT_RelativeBegin] ; Absolute Sector
    291       mov     dx, wptr [si+LocBRPT_RelativeBegin+2]
    292       add     ax, wptr [CurPartition_Location+0] ; +Partition-Absolute
    293       adc     dx, wptr [CurPartition_Location+2] ;  sectors
    294       mov     si, offset LVMSector
    295       call    LVM_SearchForPartition     ; Search for DX:AX partition
    296       jnc     PCCTP_CheckBootRecord
    297       ; Check, if volume has driveletter assigned and remember it for later
    298       mov     al, [si+LocLVM_VolumeLetter]
    299       or      al, al
    300       jnz     PCCTP_HasVolumeLetter
    301       mov     al, 1                      ; 0 would mean "not LVM supported"
    302      PCCTP_HasVolumeLetter:
    303       ; Save VolumeLetter in separate table
    304       ;movzx   bx, NewPartitions          ; NewPartitions is one behind here, so
    305       mov   bl,NewPartitions          ; NewPartitions is one behind here, so
    306       mov   bh,0
    307 
    308       mov     [PartitionVolumeLetters+bx], al ; it's already a zero-based offset
    309       ; Now copy VolumeID and VolumeName to temporary space
    310       mov     di, offset MBR_NoName_Patched
    311       mov     ax, [si+LocLVM_PartitionID]
    312       stosw
    313       mov     ax, [si+LocLVM_PartitionID+2]
    314       stosw
    315                               ; Set Serial-Field to LVM-VolumeID
    316 
    317       push     di
    318       add     si, LocLVM_VolumeName     ; Use LVM VolumeName
    319       ;add     si, LocLVM_PartitionName  ; Use LVM PartitionName
    320       mov     cx, 5
    321       rep     movsw                      ; Copy LVM-PartitionName to Temp Space
    322       movsb                               ;  (11 bytes in total)
    323       pop   di
    324 
    325 
    326       ; Check if this is an IBM-BM partition
    327       cmp   PartSystemID, 0ah
    328       jne   PCCTP_NoIbmBm
    329 
    330       ; It is, so override the name given by IBM-BM by one that
    331       ; fits in 11 chars.
    332       mov   si, offset ibm_bm_name
    333       mov   cx,5
    334       rep   movsw
    335       movsb
    336 
    337 
    338 
    339    PCCTP_NoIbmBm:
    340    pop     di
    341    pop     si
    342    pop     dx
    343    pop     ax
    344    mov     si, offset MBR_NoName_Patched
    345    xor     ah, ah                        ; no Flags_NoPartName
    346    jmp     PCCTP_NameSearchInIPT
    347 
    348      PCCTP_CheckBootRecord:
    349    pop     di
    350    pop     si
    351    pop     dx
    352    pop     ax
    353    test    ah, FileSysFlags_NoName       ; No-Name-Flag ? -> No Partition Name
    354 
    355    jz      PCCTP_ThereIsAName
    356    jmp     PCCTP_ThereIsNoName           ;                    available
    357 
    358    PCCTP_ThereIsAName:
    359 
    360       ; We check for NTFS (got detected a little bit earlier in this routine)
    361       cmp     PartSystemID, 08h          ; We got IFS/NTFS here?
    362       jne     PCCTP_IsNoNTFS
    363       jmp     PCCTP_ThereIsNoName        ; NTFS has no volume label
    364      PCCTP_IsNoNTFS:
    365       add     si, 2Bh                    ; DS:SI - Partition-Name
    366       test    ah, FileSysFlags_FAT32     ; FAT32 specific name getting ?
    367 
    368       jz      PCCTP_ResumeNormal
    369 
    370       add     si, 1Ch                    ; Fix for FAT 32, shiat
    371      PCCTP_ResumeNormal:
    372       mov     cx, 11                     ;         11 bytes length
    373       call    PART_CheckForValidPartName
    374       jc    PCCTP_ThereIsAName2
    375 
    376       jmp     PCCTP_ThereIsNoName
    377 
    378    PCCTP_ThereIsAName2:
     228        local   PartSystemID:byte, PartTypeFlags:byte
     229        local   PartCRC:word, PartPtr:word
     230
     231        mov     wptr [PartPtr], si          ; Save Pointer to PartitionEntry
     232
     233        mov     al, bptr [si+LocBRPT_SystemID]
     234        mov     PartSystemID, al
     235
     236        mov     cx, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
     237        mov     dh, bptr [si+LocBRPT_BeginHead] ; Head
     238        mov     dl, bptr [CurPartition_Location+4] ; Drive
     239        mov     ax, wptr [si+LocBRPT_RelativeBegin] ; Absolute Sector
     240        mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
     241        add     ax, wptr [CurPartition_Location+0] ; +Partition-Absolute
     242        adc     bx, wptr [CurPartition_Location+2] ;  sectors
     243
     244        ; Sets up DS:SI - TmpSector
     245        call    DriveIO_LoadTmpSector         ; Loads Boot record                     ; Rousseau: LOAD PARTITION BOOT RECORD !!
     246
     247
     248
     249        push    si
     250            mov     bx, 4B4Dh                  ; Magic 'MK' :)
     251            call    MBR_GetCheckOfSector
     252            mov     PartCRC, bx                ; Save Partition's-CRC
     253
     254            ; ------------------------------ Gets internal infos of partition type
     255            mov     al, PartSystemID
     256            call    PART_SearchFileSysName
     257            ; Replies AH - FileSysFlags, AL - UnhiddenID, SI - FileSystemNamePtr
     258            mov     di, si
     259            mov     PartTypeFlags, ah
     260            mov     PartSystemID, al           ; Use Unhidden-ID
     261        pop     si
     262
     263        ;================================
     264        ; AL - File System ID (Unhidden)
     265        ; AH - File System Flags
     266        ; SI - Boot-Record of Partition
     267        ; DI - File System Name
     268        ;================================
     269
     270        cmp     PartSystemID, 07h          ; We got IFS here?
     271        jne     PCCTP_IFSdone
     272        ; Check, if 'JFS ' is at DWORD offset 36h                                     ; Rousseau: JFS check (LVM / IPT?)
     273        cmp     wptr [si+36h], 'FJ'
     274        jne     PCCTP_IFSnoJFS
     275        cmp     wptr [si+38h], ' S'
     276        jne     PCCTP_IFSnoJFS
     277        mov     PartSystemID, 0FCh         ; FC is JFS internally
     278        jmp     PCCTP_IFSdone
     279    PCCTP_IFSnoJFS:
     280        ; Check, if 'HPFS' is at DWORD offset 36h
     281        cmp     wptr [si+36h], 'PH'
     282        jne     PCCTP_ProbablyNTFS
     283        cmp     wptr [si+38h], 'SF'
     284        je      PCCTP_IFSdone              ; 07 is HPFS internally
     285    PCCTP_ProbablyNTFS:
     286        inc     PartSystemID               ; 08 is NTFS instead of 07
     287    PCCTP_IFSdone:
     288
     289
     290        ; First check, if LVM Information Sector is available and this partition
     291        ;  is supported.
     292        push    ax
     293        push    dx
     294        push    si
     295        push    di
     296        mov     si, wptr [PartPtr]
     297        mov     ax, wptr [si+LocBRPT_RelativeBegin] ; Absolute Sector
     298        mov     dx, wptr [si+LocBRPT_RelativeBegin+2]
     299        add     ax, wptr [CurPartition_Location+0] ; +Partition-Absolute
     300        adc     dx, wptr [CurPartition_Location+2] ;  sectors
     301        mov     si, offset LVMSector
     302        call    LVM_SearchForPartition     ; Search for DX:AX partition
     303        jnc     PCCTP_CheckBootRecord
     304        ; Check, if volume has driveletter assigned and remember it for later
     305        mov     al, [si+LocLVM_VolumeLetter]
     306        or      al, al
     307        jnz     PCCTP_HasVolumeLetter
     308        mov     al, 1                      ; 0 would mean "not LVM supported"
     309    PCCTP_HasVolumeLetter:
     310        ; Save VolumeLetter in separate table
     311        ;movzx   bx, NewPartitions          ; NewPartitions is one behind here, so
     312        mov   bl,NewPartitions          ; NewPartitions is one behind here, so
     313        mov   bh,0
     314
     315        mov     [PartitionVolumeLetters+bx], al ; it's already a zero-based offset
     316        ; Now copy VolumeID and VolumeName to temporary space
     317        mov     di, offset MBR_NoName_Patched
     318        mov     ax, [si+LocLVM_PartitionID]
     319        stosw
     320        mov     ax, [si+LocLVM_PartitionID+2]
     321        stosw
     322                  ; Set Serial-Field to LVM-VolumeID
     323
     324        push     di
     325        add     si, LocLVM_VolumeName     ; Use LVM VolumeName
     326        ;add     si, LocLVM_PartitionName  ; Use LVM PartitionName
     327        mov     cx, 5
     328        rep     movsw                      ; Copy LVM-PartitionName to Temp Space
     329        movsb                               ;  (11 bytes in total)
     330        pop   di
     331
     332
     333        ; Check if this is an IBM-BM partition
     334        cmp   PartSystemID, 0ah
     335        jne   PCCTP_NoIbmBm
     336
     337        ; It is, so override the name given by IBM-BM by one that
     338        ; fits in 11 chars.
     339        mov   si, offset ibm_bm_name
     340        mov   cx,5
     341        rep   movsw
     342        movsb
     343
     344
     345
     346    PCCTP_NoIbmBm:
     347        pop     di
     348        pop     si
     349        pop     dx
     350        pop     ax
     351        mov     si, offset MBR_NoName_Patched
     352        xor     ah, ah                        ; no Flags_NoPartName
     353        jmp     PCCTP_NameSearchInIPT
     354
     355    PCCTP_CheckBootRecord:
     356        pop     di
     357        pop     si
     358        pop     dx
     359        pop     ax
     360
     361        test    ah, FileSysFlags_NoName       ; No-Name-Flag ? -> No Partition Name
     362
     363        jz      PCCTP_ThereIsAName
     364        jmp     PCCTP_ThereIsNoName           ;                    available
     365
     366    PCCTP_ThereIsAName:
     367
     368        ; We check for NTFS (got detected a little bit earlier in this routine)
     369        cmp     PartSystemID, 08h          ; We got IFS/NTFS here?
     370        jne     PCCTP_IsNoNTFS
     371        jmp     PCCTP_ThereIsNoName        ; NTFS has no volume label
     372    PCCTP_IsNoNTFS:
     373        add     si, 2Bh                    ; DS:SI - Partition-Name
     374        test    ah, FileSysFlags_FAT32     ; FAT32 specific name getting ?
     375
     376        jz      PCCTP_ResumeNormal
     377
     378        add     si, 1Ch                    ; Fix for FAT 32, shiat
     379    PCCTP_ResumeNormal:
     380        mov     cx, 11                     ;         11 bytes length
     381        call    PART_CheckForValidPartName
     382        jc    PCCTP_ThereIsAName2
     383
     384        jmp     PCCTP_ThereIsNoName
     385
     386    PCCTP_ThereIsAName2:
    379387
    380388      sub     si, 4                      ; DS:SI -> Serial&Name (15-Bytes)
     
    382390;      jmp     PCCTP_NameSearchInIPT
    383391
    384       ;=======================================================
    385       ; NAME SEARCH in IPT-Table
    386       ; DS:SI - Serial&Name of Current Partition (15-Bytes)
    387       ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
    388       ;=======================================================
    389      PCCTP_NameSearchInIPT:
    390       xor     ah, ah                     ; no Flags_NoPartName cause PartName valid
    391       mov     di, offset PartitionTable  ; ES:DI - IPT-Start
    392       mov     dl, CFG_Partitions
    393       or      dl, dl
    394       jnz     PCCTP_SerialNameCompLoop
    395       jmp     PCCTP_CompareFailed
    396      PCCTP_SerialNameCompLoop:
    397          mov     al, [di+LocIPT_Flags]
    398          test    al, Flags_NowFound
    399          jnz     PCCTP_SerialNameAlreadyFound
    400          ; Now compare IPT with current Partition
    401          mov     cx, 15                  ; Serial&Name (15-Bytes)
    402          push    si
    403          push    di
    404             repz    cmpsb
    405          pop     di
    406          pop     si
    407 
    408          jne   PCCTP_NoMatchYet
    409 
    410          jmp      PCCTP_Match
    411 
    412       PCCTP_NoMatchYet:
    413 
    414         PCCTP_SerialNameAlreadyFound:
    415          add     di, LocIPT_LenOfIPT
    416       dec     dl
    417       jnz     PCCTP_SerialNameCompLoop
    418 
    419       ; if we didn't find Serial&Name, let's try Name-only without Serial
    420       mov     di, offset PartitionTable  ; ES:DI - IPT-Start
    421       mov     dl, CFG_Partitions
    422      PCCTP_NameCompLoop:
    423          mov     al, [di+LocIPT_Flags]
    424          test    al, Flags_NowFound
    425          jnz     PCCTP_NameAlreadyFound
    426          ; Now compare IPT with current Partition
    427          mov     cx, 11                  ; Name only (11-Bytes)
    428          push    si
    429          push    di
    430             add     si, 4
    431             add     di, 4                ; Skip over Serial-Field
    432             repz    cmpsb
    433          pop     di
    434          pop     si
    435          jne     PCCTP_NameNoMatch
    436          mov     cx, [si+0]           ; Get Serial
    437          mov     [di+0], cx
    438          mov     cx, [si+2]
    439          mov     [di+2], cx           ; ...and put it into IPT
    440          jmp     PCCTP_Match
    441         PCCTP_NameNoMatch:
    442         PCCTP_NameAlreadyFound:
    443          add     di, LocIPT_LenOfIPT
    444       dec     dl
    445       jnz     PCCTP_NameCompLoop
    446      PCCTP_NameCompFailed:
    447 
    448       ; So finally we search for Location and PartitionID
    449       push    si
    450          ; Initialize some stuff for Location-Search
    451          mov     dh, PartSystemID
    452          mov     si, [PartPtr]           ; DS:SI - Cur Partition Table
    453          ; Relative Sector to MBR/EPR
    454          mov     cx, wptr [si+LocBRPT_RelativeBegin]
    455          mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
    456          add     cx, [CurPartition_Location+0]
    457          add     bx, [CurPartition_Location+2]
    458          ; BX:CX - Absolute First Sector of Partition on HDD
    459       pop     si
    460       mov     di, offset PartitionTable  ; ES:DI - IPT-Start
    461       mov     dl, CFG_Partitions
    462      PCCTP_NameLocCompLoop:
    463          mov     al, [di+LocIPT_Flags]
    464          test    al, Flags_NowFound
    465          jnz     PCCTP_NameLocAlreadyFound
    466          ; Now compare IPT with current Partition
    467          cmp     dh, [di+LocIPT_SystemID]
    468          jne     PCCTP_NameLocMismatch
    469          cmp     cx, [di+LocIPT_AbsoluteBegin]
    470          jne     PCCTP_NameLocMismatch
    471          cmp     bx, [di+LocIPT_AbsoluteBegin+2]
    472          jne     PCCTP_NameLocMismatch
    473          ; We matched location, now copy the current PartitionID and Name to
    474          ;  the old IPT.
    475          push    di
    476             add     di, LocIPT_Serial    ; DS:SI - LocIPT-Serial&Name
    477             mov     cx, 15
    478             rep     movsb                ; Copy 15 bytes
    479          pop     di
    480          jmp     PCCTP_Match
    481         PCCTP_NameLocMismatch:
    482         PCCTP_NameLocAlreadyFound:
    483          add     di, LocIPT_LenOfIPT
    484       dec     dl
    485       jnz     PCCTP_NameLocCompLoop
    486       ; None of the searches worked, so forget it...
    487       jmp     PCCTP_CompareFailed
    488 
    489   PCCTP_ThereIsNoName:
    490       ; Try to find this partition by comparing location and PartitionID
    491       ;  aka LocIPT_AbsoluteBegin:dword and LocIPT_SystemID
    492       ; If found, simply go to the normal match-routine, otherwise use the
    493       ;  File-System-Name to build the Volume-Label for the New IPT Entry.
    494       mov     dh, PartSystemID
    495       mov     si, [PartPtr]           ; DS:SI - Cur Partition Table
    496       ; Relative Sector to MBR/EPR
    497       mov     cx, wptr [si+LocBRPT_RelativeBegin]
    498       mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
    499       add     cx, [CurPartition_Location+0]
    500       add     bx, [CurPartition_Location+2]
    501       ; Build a standard-Volume Label from FileSystemNamePtr
    502       ;  We have to call SearchFileSysName again because of NTFS
    503       push    ax
    504       push    cx
    505          mov     al, dh
    506          call    PART_SearchFileSysName   ; We want SI here <- FileSystemNamePtr
    507          mov     di, offset MBR_NoName_Patched
    508          xor     ax, ax
    509          stosw
    510          stosw                           ; Set Serial-Field to "NUL"
    511          mov     cx, 4
    512          rep     movsw                   ; Copy FileSystemName to Temp Space
    513          xor     ax, ax
    514          stosw
    515          stosb                           ; Fill last 3 bytes with "NUL"
    516          mov     si, offset MBR_NoName_Patched
    517       pop     cx
    518       pop     ax
    519       ;=======================================================
    520       ; LOCATION SEARCH in IPT-Table
    521       ;    DH - PartitionID of Current Partition
    522       ; BX:CX - AbsoluteBegin of Current Partition
    523       ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
    524       ; DS:SI - Serial&Name of Current Partition (15-Bytes)
    525       ;=======================================================
    526      PCCTP_LocSearchInIPT:
    527       mov     ah, Flags_NoPartName       ;set Flags_NoPartName, PartName invalid
    528       mov     di, offset PartitionTable  ; ES:DI - IPT-Start
    529       mov     dl, CFG_Partitions
    530       or      dl, dl
    531       jz      PCCTP_LocCompFailed
    532      PCCTP_LocCompLoop:
    533          mov     al, [di+LocIPT_Flags]
    534          test    al, Flags_NowFound
    535          jnz     PCCTP_LocAlreadyFound
    536          ; Now compare IPT with current Partition
    537          cmp     dh, [di+LocIPT_SystemID]
    538          jne     PCCTP_LocMismatch
    539          cmp     cx, [di+LocIPT_AbsoluteBegin]
    540          jne     PCCTP_LocMismatch
    541          cmp     bx, [di+LocIPT_AbsoluteBegin+2]
    542          jne     PCCTP_LocMismatch
    543          jmp     PCCTP_Match
    544         PCCTP_LocMismatch:
    545         PCCTP_LocAlreadyFound:
    546          add     di, LocIPT_LenOfIPT
    547       dec     dl
    548       jnz     PCCTP_LocCompLoop
    549      PCCTP_LocCompFailed:
    550       jmp     PCCTP_CompareFailed
    551 
    552    ; ==================================
    553    ; =MATCH=, found partition in IPT...
    554    ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
    555    ;    DL - IPT Partition Number from Loop (inverted)
    556    ; ES:DI - LocIPT-Pointer to found IPT-entry
    557    ; ==================================
    558   PCCTP_Match:
    559    mov     ch, ah
    560    ; Save the new location of this partition in the Xref-Table
    561    ;  for converting HideConfig.
    562    mov     dh, dl
    563    mov     dl, CFG_Partitions
    564    sub     dl, dh
    565    mov     dh, NewPartitions             ; is actually a counter
    566    call    PARTSCAN_DefXref              ; DL-IPT-Partition, DH-NewPartition
    567 
    568    ; Get Saved-Flags...
    569    mov     cl, bptr [di+LocIPT_Flags]    ; Use saved Flags
    570 
    571    ; ...and Saved-CRC if available...
    572    mov     ax, wptr [di+LocIPT_BootRecordCRC]
    573    or      ax, ax
    574    jz      PCCTP_UseNewComputedCRC
    575    mov     PartCRC, ax                   ; Use saved IPT-CRC
    576   PCCTP_UseNewComputedCRC:
    577    ; ...and mark partition in IPT as already found
    578    or      bptr [di+LocIPT_Flags], Flags_NowFound
    579    ; ...get Serial&Name from IPT-table...
    580    mov     si, di
    581    add     si, LocIPT_Serial             ; DS:SI - LocIPT-Serial&Name
    582    jmp     PCCTP_AddToNew
    583 
    584    ; =================================
    585    ; =FAILED= search, not found in IPT
    586    ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
    587    ; DS:SI - Serial&Name of Current Partition (15-Bytes)
    588    ; =================================
    589   PCCTP_CompareFailed:
    590    mov     ch, ah
    591    ; Default Flags hinzufgen...
    592    mov     cl, LocIPT_DefaultFlags
    593 
    594    mov     al, PartTypeFlags
    595    ; May I auto-add partitions ?
    596    test    CFG_PartitionsDetect, 1
    597    jz      PCCTP_MayNotAddAny ; add, but non-bootable
    598    test    al, FileSysFlags_BootAble     ; AH kam von SearchFileSysName
    599    jnz     PCCTP_PerhapsBootAble
    600   PCCTP_MayNotAddAny:
    601    mov     cl, LocIPT_DefaultNonBootFlags
    602   PCCTP_PerhapsBootAble:
    603 
    604    ; On FAT32-partitions, default to P-Flag (which means using M$-hack)
    605    ;  Anyway, this hack has to be globaly activated by the user manually...
    606    cmp     PartSystemID, 09h             ; Hardcoded: FAT32
    607    je      PCCTP_NeedsExtMShack
    608    cmp     PartSystemID, 0Bh
    609    je      PCCTP_NeedsExtMShack
    610    cmp     PartSystemID, 0Ch
    611    je      PCCTP_NeedsExtMShack
    612    cmp     PartSystemID, 0Eh             ; FAT16 above 8 GB
    613    jne     PCCTP_NoExtMShack
    614    ; We only get here, when the SystemID seems to be an M$ "invention"...
    615      PCCTP_NeedsExtMShack:
    616       or      cl, Flags_ExtPartMShack
    617   PCCTP_NoExtMShack:
    618 
    619    ;================================================
    620    ; CL - IPT-Partition-Flags, CH - NoPartName-Flag
    621    ; DS:SI - PartSerial&Name (15-Bytes)
    622    ;================================================
    623   PCCTP_AddToNew:
    624    mov     al, Flags_NoPartName          ; Unset NoPartName
    625    not     al
    626    and     cl, al
    627    or      cl, ch                        ; CL = Both CL and CH merged
    628 
    629    ; Calculate Pointer to IPT
    630    mov     di, offset NewPartTable       ; ES:DI - NewPartTable
    631    ;movzx   ax, NewPartitions
    632    mov   al,NewPartitions
    633    mov   ah,0
    634 
    635    mov     bl, LocIPT_LenOfIPT
    636    mul     bl
    637    add     di, ax                        ; ES:DI - Last+1 Entry of NewPartTable
    638 
    639    ; Now finally write this partition to our IPT
    640    ;=============================================
    641    push    cx
    642       mov     cx, 15                     ; Copy Serial&Name...
    643       rep     movsb
    644    pop     cx
    645 
    646    mov     si, [PartPtr]                 ; DS:SI - Cur Partition Entry
    647    mov     al, bptr [CurPartition_Location+4] ; Drive
    648    stosb
    649    mov     al, PartSystemID              ; Unhidden SystemID
    650    stosb
    651    mov     al, cl                        ; Partition-Flags from register...
    652    stosb
    653    mov     ax, PartCRC                   ; BootRecordCRC...
    654    stosw
    655    mov     al, bptr [si+LocBRPT_BeginHead]
    656    stosb
    657    mov     ax, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
    658    stosw
    659    mov     al, bptr [CurPartition_Location+5] ; Head of Part-Table
    660    stosb
    661    mov     ax, wptr [CurPartition_Location+6] ; Cylinder/Sector
    662    stosw
    663    mov     ax, wptr [si+LocBRPT_RelativeBegin]
    664    mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
    665    mov     cx, wptr [CurPartition_Location+0] ; +Partition-Absolute
    666    mov     dx, wptr [CurPartition_Location+2] ;  sectors
    667    add     ax, cx
    668    adc     bx, dx
    669    stosw
    670    mov     ax, bx
    671    stosw
    672    mov     ax, cx                        ; Absolute sector of partition table
    673    stosw
    674    mov     ax, dx
    675    stosw
    676    inc     NewPartitions                 ; NEW IPT Entry DONE
    677 
    678    cmp     NewPartitions, LocIPT_MaxPartitions
    679    jbe     PCCTP_NotTooManyPartitions
    680 
    681    mov     si, offset TXT_TooManyPartitions
    682    call    MBR_Teletype
    683    jmp     MBR_HaltSystem
    684 
    685 
    686   PCCTP_NotTooManyPartitions:
    687    ; UNHIDE PARTITION, if it was hidden previously
    688    mov     al, PartSystemID
    689    cmp     al, 08h                       ; internally IFS/NTFS?
    690    je      PCCTP_GotInternalIFS
    691    cmp     al, 0FCh                      ; internally IFS/JFS?
    692    jne     PCCTP_NoInternalIFS
    693   PCCTP_GotInternalIFS:
    694    mov     al, 07h
    695   PCCTP_NoInternalIFS:
    696    mov     bptr [si+LocBRPT_SystemID], al
    697 
    698    ; Calculate Size of this partition and put it into separate table...
    699    ;movzx   ax, NewPartitions
    700    mov   al,NewPartitions
    701    mov   ah,0
    702 
    703    dec     ax
    704    mov     bx, ax
    705    shl     ax, 1
    706    shl     bx, 2
    707    add     ax, bx                        ; My way [tm] of multiplying with 6
    708    mov     di, offset PartitionSizeTable
    709    add     di, ax                        ; DI - Partition Size-Element
    710    mov     ax, wptr [si+LocBRPT_AbsoluteLength] ; Sector-Size
    711    mov     bx, wptr [si+LocBRPT_AbsoluteLength+2]
    712    call    PART_FillOutSizeElement
    713    ret
     392        ;=======================================================
     393        ; NAME SEARCH in IPT-Table
     394        ; DS:SI - Serial&Name of Current Partition (15-Bytes)
     395        ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
     396        ;=======================================================
     397    PCCTP_NameSearchInIPT:
     398        xor     ah, ah                     ; no Flags_NoPartName cause PartName valid
     399        mov     di, offset PartitionTable  ; ES:DI - IPT-Start
     400        mov     dl, CFG_Partitions
     401        or      dl, dl
     402        jnz     PCCTP_SerialNameCompLoop
     403        jmp     PCCTP_CompareFailed
     404    PCCTP_SerialNameCompLoop:
     405        mov     al, [di+LocIPT_Flags]
     406        test    al, Flags_NowFound
     407        jnz     PCCTP_SerialNameAlreadyFound
     408        ; Now compare IPT with current Partition
     409        mov     cx, 15                  ; Serial&Name (15-Bytes)
     410        push    si
     411        push    di
     412        repz    cmpsb
     413        pop     di
     414        pop     si
     415
     416        jne   PCCTP_NoMatchYet
     417
     418        jmp      PCCTP_Match
     419
     420    PCCTP_NoMatchYet:
     421
     422    PCCTP_SerialNameAlreadyFound:
     423        add     di, LocIPT_LenOfIPT
     424        dec     dl
     425        jnz     PCCTP_SerialNameCompLoop
     426
     427        ; if we didn't find Serial&Name, let's try Name-only without Serial
     428        mov     di, offset PartitionTable  ; ES:DI - IPT-Start
     429        mov     dl, CFG_Partitions
     430    PCCTP_NameCompLoop:
     431        mov     al, [di+LocIPT_Flags]
     432        test    al, Flags_NowFound
     433        jnz     PCCTP_NameAlreadyFound
     434        ; Now compare IPT with current Partition
     435        mov     cx, 11                  ; Name only (11-Bytes)
     436        push    si
     437        push    di
     438        add     si, 4
     439        add     di, 4                ; Skip over Serial-Field
     440        repz    cmpsb
     441        pop     di
     442        pop     si
     443        jne     PCCTP_NameNoMatch
     444        mov     cx, [si+0]           ; Get Serial
     445        mov     [di+0], cx
     446        mov     cx, [si+2]
     447        mov     [di+2], cx           ; ...and put it into IPT
     448        jmp     PCCTP_Match
     449    PCCTP_NameNoMatch:
     450    PCCTP_NameAlreadyFound:
     451        add     di, LocIPT_LenOfIPT
     452        dec     dl
     453        jnz     PCCTP_NameCompLoop
     454    PCCTP_NameCompFailed:
     455
     456        ; So finally we search for Location and PartitionID
     457        push    si
     458        ; Initialize some stuff for Location-Search
     459        mov     dh, PartSystemID
     460        mov     si, [PartPtr]           ; DS:SI - Cur Partition Table
     461        ; Relative Sector to MBR/EPR
     462        mov     cx, wptr [si+LocBRPT_RelativeBegin]
     463        mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
     464        add     cx, [CurPartition_Location+0]
     465        add     bx, [CurPartition_Location+2]
     466        ; BX:CX - Absolute First Sector of Partition on HDD
     467        pop     si
     468        mov     di, offset PartitionTable  ; ES:DI - IPT-Start
     469        mov     dl, CFG_Partitions
     470    PCCTP_NameLocCompLoop:
     471        mov     al, [di+LocIPT_Flags]
     472        test    al, Flags_NowFound
     473        jnz     PCCTP_NameLocAlreadyFound
     474        ; Now compare IPT with current Partition
     475        cmp     dh, [di+LocIPT_SystemID]
     476        jne     PCCTP_NameLocMismatch
     477        cmp     cx, [di+LocIPT_AbsoluteBegin]
     478        jne     PCCTP_NameLocMismatch
     479        cmp     bx, [di+LocIPT_AbsoluteBegin+2]
     480        jne     PCCTP_NameLocMismatch
     481        ; We matched location, now copy the current PartitionID and Name to
     482        ;  the old IPT.
     483        push    di
     484        add     di, LocIPT_Serial    ; DS:SI - LocIPT-Serial&Name
     485        mov     cx, 15
     486        rep     movsb                ; Copy 15 bytes
     487        pop     di
     488        jmp     PCCTP_Match
     489    PCCTP_NameLocMismatch:
     490    PCCTP_NameLocAlreadyFound:
     491        add     di, LocIPT_LenOfIPT
     492        dec     dl
     493        jnz     PCCTP_NameLocCompLoop
     494        ; None of the searches worked, so forget it...
     495        jmp     PCCTP_CompareFailed
     496
     497    PCCTP_ThereIsNoName:
     498        ; Try to find this partition by comparing location and PartitionID
     499        ;  aka LocIPT_AbsoluteBegin:dword and LocIPT_SystemID
     500        ; If found, simply go to the normal match-routine, otherwise use the
     501        ;  File-System-Name to build the Volume-Label for the New IPT Entry.
     502        mov     dh, PartSystemID
     503        mov     si, [PartPtr]           ; DS:SI - Cur Partition Table
     504        ; Relative Sector to MBR/EPR
     505        mov     cx, wptr [si+LocBRPT_RelativeBegin]
     506        mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
     507        add     cx, [CurPartition_Location+0]
     508        add     bx, [CurPartition_Location+2]
     509        ; Build a standard-Volume Label from FileSystemNamePtr
     510        ;  We have to call SearchFileSysName again because of NTFS
     511        push    ax
     512        push    cx
     513        mov     al, dh
     514        call    PART_SearchFileSysName   ; We want SI here <- FileSystemNamePtr
     515        mov     di, offset MBR_NoName_Patched
     516        xor     ax, ax
     517        stosw
     518        stosw                           ; Set Serial-Field to "NUL"
     519        mov     cx, 4
     520        rep     movsw                   ; Copy FileSystemName to Temp Space
     521        xor     ax, ax
     522        stosw
     523        stosb                           ; Fill last 3 bytes with "NUL"
     524        mov     si, offset MBR_NoName_Patched
     525        pop     cx
     526        pop     ax
     527        ;=======================================================
     528        ; LOCATION SEARCH in IPT-Table
     529        ;    DH - PartitionID of Current Partition
     530        ; BX:CX - AbsoluteBegin of Current Partition
     531        ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
     532        ; DS:SI - Serial&Name of Current Partition (15-Bytes)
     533        ;=======================================================
     534    PCCTP_LocSearchInIPT:
     535        mov     ah, Flags_NoPartName       ;set Flags_NoPartName, PartName invalid
     536        mov     di, offset PartitionTable  ; ES:DI - IPT-Start
     537        mov     dl, CFG_Partitions
     538        or      dl, dl
     539        jz      PCCTP_LocCompFailed
     540    PCCTP_LocCompLoop:
     541        mov     al, [di+LocIPT_Flags]
     542        test    al, Flags_NowFound
     543        jnz     PCCTP_LocAlreadyFound
     544        ; Now compare IPT with current Partition
     545        cmp     dh, [di+LocIPT_SystemID]
     546        jne     PCCTP_LocMismatch
     547        cmp     cx, [di+LocIPT_AbsoluteBegin]
     548        jne     PCCTP_LocMismatch
     549        cmp     bx, [di+LocIPT_AbsoluteBegin+2]
     550        jne     PCCTP_LocMismatch
     551        jmp     PCCTP_Match
     552    PCCTP_LocMismatch:
     553    PCCTP_LocAlreadyFound:
     554        add     di, LocIPT_LenOfIPT
     555        dec     dl
     556        jnz     PCCTP_LocCompLoop
     557    PCCTP_LocCompFailed:
     558        jmp     PCCTP_CompareFailed
     559
     560        ; ==================================
     561        ; =MATCH=, found partition in IPT...
     562        ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
     563        ;    DL - IPT Partition Number from Loop (inverted)
     564        ; ES:DI - LocIPT-Pointer to found IPT-entry
     565        ; ==================================
     566    PCCTP_Match:
     567        mov     ch, ah
     568        ; Save the new location of this partition in the Xref-Table
     569        ;  for converting HideConfig.
     570        mov     dh, dl
     571        mov     dl, CFG_Partitions
     572        sub     dl, dh
     573        mov     dh, NewPartitions             ; is actually a counter
     574        call    PARTSCAN_DefXref              ; DL-IPT-Partition, DH-NewPartition
     575
     576        ; Get Saved-Flags...
     577        mov     cl, bptr [di+LocIPT_Flags]    ; Use saved Flags
     578
     579        ; ...and Saved-CRC if available...
     580        mov     ax, wptr [di+LocIPT_BootRecordCRC]
     581        or      ax, ax
     582        jz      PCCTP_UseNewComputedCRC
     583        mov     PartCRC, ax                   ; Use saved IPT-CRC
     584    PCCTP_UseNewComputedCRC:
     585        ; ...and mark partition in IPT as already found
     586        or      bptr [di+LocIPT_Flags], Flags_NowFound
     587        ; ...get Serial&Name from IPT-table...
     588        mov     si, di
     589        add     si, LocIPT_Serial             ; DS:SI - LocIPT-Serial&Name
     590        jmp     PCCTP_AddToNew
     591
     592        ; =================================
     593        ; =FAILED= search, not found in IPT
     594        ;    AH - NoPartName-Flag (!MUST! be merged with Flags)
     595        ; DS:SI - Serial&Name of Current Partition (15-Bytes)
     596        ; =================================
     597    PCCTP_CompareFailed:
     598        mov     ch, ah
     599        ; Default Flags hinzufgen...
     600        mov     cl, LocIPT_DefaultFlags
     601
     602        mov     al, PartTypeFlags
     603        ; May I auto-add partitions ?
     604        test    CFG_PartitionsDetect, 1
     605        jz      PCCTP_MayNotAddAny ; add, but non-bootable
     606        test    al, FileSysFlags_BootAble     ; AH kam von SearchFileSysName
     607        jnz     PCCTP_PerhapsBootAble
     608    PCCTP_MayNotAddAny:
     609        mov     cl, LocIPT_DefaultNonBootFlags
     610    PCCTP_PerhapsBootAble:
     611
     612        ; On FAT32-partitions, default to P-Flag (which means using M$-hack)
     613        ;  Anyway, this hack has to be globaly activated by the user manually...
     614        cmp     PartSystemID, 09h             ; Hardcoded: FAT32
     615        je      PCCTP_NeedsExtMShack
     616        cmp     PartSystemID, 0Bh
     617        je      PCCTP_NeedsExtMShack
     618        cmp     PartSystemID, 0Ch
     619        je      PCCTP_NeedsExtMShack
     620        cmp     PartSystemID, 0Eh             ; FAT16 above 8 GB
     621        jne     PCCTP_NoExtMShack
     622        ; We only get here, when the SystemID seems to be an M$ "invention"...
     623    PCCTP_NeedsExtMShack:
     624        or      cl, Flags_ExtPartMShack
     625    PCCTP_NoExtMShack:
     626
     627        ;================================================
     628        ; CL - IPT-Partition-Flags, CH - NoPartName-Flag
     629        ; DS:SI - PartSerial&Name (15-Bytes)
     630        ;================================================
     631    PCCTP_AddToNew:
     632        mov     al, Flags_NoPartName          ; Unset NoPartName
     633        not     al
     634        and     cl, al
     635        or      cl, ch                        ; CL = Both CL and CH merged
     636
     637        ; Calculate Pointer to IPT
     638        mov     di, offset NewPartTable       ; ES:DI - NewPartTable
     639        ;movzx   ax, NewPartitions
     640        mov   al,NewPartitions
     641        mov   ah,0
     642
     643        mov     bl, LocIPT_LenOfIPT
     644        mul     bl
     645        add     di, ax                        ; ES:DI - Last+1 Entry of NewPartTable
     646
     647        ; Now finally write this partition to our IPT
     648        ;=============================================
     649        push    cx
     650        mov     cx, 15                     ; Copy Serial&Name...
     651        rep     movsb
     652        pop     cx
     653
     654        mov     si, [PartPtr]                 ; DS:SI - Cur Partition Entry
     655        mov     al, bptr [CurPartition_Location+4] ; Drive
     656        stosb
     657        mov     al, PartSystemID              ; Unhidden SystemID
     658        stosb
     659        mov     al, cl                        ; Partition-Flags from register...
     660        stosb
     661        mov     ax, PartCRC                   ; BootRecordCRC...
     662        stosw
     663        mov     al, bptr [si+LocBRPT_BeginHead]
     664        stosb
     665        mov     ax, wptr [si+LocBRPT_BeginSector] ; Cylinder/Sector
     666        stosw
     667        mov     al, bptr [CurPartition_Location+5] ; Head of Part-Table
     668        stosb
     669        mov     ax, wptr [CurPartition_Location+6] ; Cylinder/Sector
     670        stosw
     671        mov     ax, wptr [si+LocBRPT_RelativeBegin]
     672        mov     bx, wptr [si+LocBRPT_RelativeBegin+2]
     673        mov     cx, wptr [CurPartition_Location+0] ; +Partition-Absolute
     674        mov     dx, wptr [CurPartition_Location+2] ;  sectors
     675        add     ax, cx
     676        adc     bx, dx
     677        stosw
     678        mov     ax, bx
     679        stosw
     680        mov     ax, cx                        ; Absolute sector of partition table
     681        stosw
     682        mov     ax, dx
     683        stosw
     684        inc     NewPartitions                 ; NEW IPT Entry DONE
     685
     686        cmp     NewPartitions, LocIPT_MaxPartitions
     687        jbe     PCCTP_NotTooManyPartitions
     688
     689        mov     si, offset TXT_TooManyPartitions
     690        call    MBR_Teletype
     691        jmp     MBR_HaltSystem
     692
     693
     694    PCCTP_NotTooManyPartitions:
     695        ; UNHIDE PARTITION, if it was hidden previously
     696        mov     al, PartSystemID
     697        cmp     al, 08h                       ; internally IFS/NTFS?
     698        je      PCCTP_GotInternalIFS
     699        cmp     al, 0FCh                      ; internally IFS/JFS?
     700        jne     PCCTP_NoInternalIFS
     701    PCCTP_GotInternalIFS:
     702        mov     al, 07h
     703    PCCTP_NoInternalIFS:
     704        mov     bptr [si+LocBRPT_SystemID], al
     705
     706        ; Calculate Size of this partition and put it into separate table...
     707        ;movzx   ax, NewPartitions
     708        mov   al,NewPartitions
     709        mov   ah,0
     710
     711        dec     ax
     712        mov     bx, ax
     713        shl     ax, 1
     714        shl     bx, 2
     715        add     ax, bx                        ; My way [tm] of multiplying with 6
     716        mov     di, offset PartitionSizeTable
     717        add     di, ax                        ; DI - Partition Size-Element
     718        mov     ax, wptr [si+LocBRPT_AbsoluteLength] ; Sector-Size
     719        mov     bx, wptr [si+LocBRPT_AbsoluteLength+2]
     720        call    PART_FillOutSizeElement
     721        ret
    714722PARTSCAN_CheckThisPartition     EndP
    715723
     
    721729
    722730; Reset X-Reference
    723 PARTSCAN_ResetXref              Proc Near   Uses ax cx di
    724    mov     di, offset PartitionXref      ; X-Reference for later syncing
    725    mov     cx, LocIPT_MaxPartitions
    726    mov     ax, 0FFFFh                    ; Fill up with FFh
    727    rep     stosb
    728    mov     di, offset NewHidePartTable   ; Temporary Hide-Config Table
    729    mov     cx, LocIPT_MaxPartitions * LocIPT_LenOfIPT
    730    rep     stosb                         ; Fill up with FFFFh
    731    mov     di, offset NewDriveLetters
    732    mov     cx, LocIPT_MaxPartitions                        ; Temporary Logical-Drive Letter Table
    733    xor     ax, ax
    734    rep     stosb                         ; Fill up with 0000h
    735    ret
    736 PARTSCAN_ResetXref              EndP
     731PARTSCAN_ResetXref  Proc Near   Uses ax cx di
     732        mov     di, offset PartitionXref      ; X-Reference for later syncing
     733        mov     cx, LocIPT_MaxPartitions
     734        mov     ax, 0FFFFh                                                  ; Fill up with FFh -- Influences OVERWRITE BUG !
     735        rep     stosb
     736        mov     di, offset NewHidePartTable   ; Temporary Hide-Config Table
     737        ;~ mov     cx, LocIPT_MaxPartitions * LocIPT_LenOfIPT
     738        mov     cx, LocIPT_MaxPartitions * LocHPT_LenOfHPT                  ; Checken !!!
     739        rep     stosb                         ; Fill up with FFFFh
     740        mov     di, offset NewDriveLetters
     741        mov     cx, LocIPT_MaxPartitions                        ; Temporary Logical-Drive Letter Table
     742        xor     ax, ax
     743        rep     stosb                         ; Fill up with 0000h
     744        ret
     745PARTSCAN_ResetXref  EndP
     746
     747
    737748
    738749;        In: DL - Partition Number in IPT
    739750;            DH - Partition Number in NewPartitionTable
    740751; Destroyed: None
    741 PARTSCAN_DefXref                Proc Near   Uses ax bx cx dx si di
    742    ;movzx   bx, dl
    743    mov   bl,dl
    744    mov   bh,0
    745 
    746    mov     bptr [PartitionXref+bx], dh      ; X-Reference
    747    ; Copy Hide-Config of IPT partition to new location in new table
    748    mov     si, offset HidePartitionTable
    749    mov     di, offset NewHidePartTable
    750    mov     bl, LocIPT_MaxPartitions
    751    mov     al, dl
    752    mul     bl
    753    add     si, ax
    754    mov     al, dh
    755    mul     bl
    756    add     di, ax
    757    mov     cx, LocIPT_MaxPartitions
    758    rep     movsb                            ; Copy Hide-Config to NewHideTable
    759    ; Process Logical-Drive-Letter table as well...
    760    ;movzx   bx, dl
    761    mov   bl,dl
    762    mov   bh,0
    763 
    764    mov     al, bptr [DriveLetters+bx]       ; Get Drv-Letter from org. pos
    765    ;movzx   bx, dh
    766    mov   bl,dl
    767    mov   bh,0
    768 
    769    mov     bptr [NewDriveLetters+bx], al    ; Put Drv-Letter to new pos
    770    ret
    771 PARTSCAN_DefXref                EndP
     752PARTSCAN_DefXref    Proc Near   Uses ax bx cx dx si di
     753        ;movzx   bx, dl
     754        mov   bl,dl
     755        mov   bh,0
     756
     757        mov     bptr [PartitionXref+bx], dh      ; X-Reference
     758        ; Copy Hide-Config of IPT partition to new location in new table
     759        mov     si, offset HidePartitionTable
     760        mov     di, offset NewHidePartTable
     761        mov     bl, LocIPT_MaxPartitions
     762        mov     al, dl
     763        mul     bl
     764        add     si, ax
     765        mov     al, dh
     766        mul     bl
     767        add     di, ax
     768        mov     cx, LocIPT_MaxPartitions
     769        rep     movsb                            ; Copy Hide-Config to NewHideTable
     770        ; Process Logical-Drive-Letter table as well...
     771        ;movzx   bx, dl
     772        mov   bl,dl
     773        mov   bh,0
     774
     775        mov     al, bptr [DriveLetters+bx]       ; Get Drv-Letter from org. pos
     776        ;movzx   bx, dh
     777        mov   bl,dl
     778        mov   bh,0
     779
     780        mov     bptr [NewDriveLetters+bx], al    ; Put Drv-Letter to new pos
     781        ret
     782PARTSCAN_DefXref    EndP
     783
     784
    772785
    773786;        In: DL - Partition Number in previous IPT
    774787;       Out: DH - Partition Number in NewPartitionTable
    775788; Destroyed: None
    776 PARTSCAN_GetXref                Proc Near   Uses bx
    777    ;movzx   bx, dl
    778    mov   bl,dl
    779    mov   bh,0
    780 
    781    mov     dh, bptr [PartitionXref+bx]      ; X-Reference
    782    ret
    783 PARTSCAN_GetXref                EndP
     789PARTSCAN_GetXref    Proc Near   Uses bx
     790        ;movzx   bx, dl
     791        mov   bl,dl
     792        mov   bh,0
     793
     794        mov     dh, bptr [PartitionXref+bx]      ; X-Reference
     795        ret
     796PARTSCAN_GetXref    EndP
     797
     798
    784799
    785800; This here updates the contents of the Hide-Configuration to the current IPT
    786801;  table.
    787802PARTSCAN_SyncHideConfigWithXref Proc Near Uses ax bx cx dx si di
    788    mov     si, offset NewHidePartTable
    789    mov     di, offset HidePartitionTable
    790    mov     ch, LocIPT_MaxPartitions
    791   PSSHCWX_SyncPartLoop:
    792       mov     cl, LocIPT_MaxPartitions
    793       xor     dl, dl                        ; Partition Lost Counter
    794      PSSHCWX_SyncLoop:
    795          lodsb                              ; Get Part-Pointer from Hide-Cfg
    796          cmp     al, 0FFh
    797          je      PSSHCWX_SyncEmpty
    798          ;movzx   bx, al
    799          mov   bl,al
    800          mov   bh,0
    801 
    802          mov     al, [PartitionXref+bx]     ; Translate it
    803          cmp     al, 0FFh
    804          je      PSSHCWX_PartLost
    805         PSSHCWX_SyncEmpty:
    806          stosb                              ; Put translated pointer to new table
    807       dec     cl
    808       jnz     PSSHCWX_SyncLoop
    809       jmp     PSSHCWX_SyncLoopEnd
    810         PSSHCWX_PartLost:
    811          inc     dl                         ; One partition got lost...
    812       dec     cl
    813       jnz     PSSHCWX_SyncLoop
    814 
    815      PSSHCWX_SyncLoopEnd:
    816       or      dl, dl
    817       jz      PSSHCWX_NothingLost
    818       mov     al, 0FFh
    819      PSSHCWX_LostFillLoop:
    820          stosb
    821       dec     cl
    822       jnz     PSSHCWX_LostFillLoop
    823      PSSHCWX_NothingLost:
    824    dec     ch
    825    jnz     PSSHCWX_SyncPartLoop
    826    ret
     803        mov     si, offset NewHidePartTable
     804        mov     di, offset HidePartitionTable
     805        mov     ch, LocIPT_MaxPartitions
     806    PSSHCWX_SyncPartLoop:
     807        mov     cl, LocIPT_MaxPartitions
     808        xor     dl, dl                        ; Partition Lost Counter
     809    PSSHCWX_SyncLoop:
     810        lodsb                              ; Get Part-Pointer from Hide-Cfg
     811        cmp     al, 0FFh
     812        je      PSSHCWX_SyncEmpty
     813        ;movzx   bx, al
     814        mov   bl,al
     815        mov   bh,0
     816
     817        mov     al, [PartitionXref+bx]     ; Translate it
     818        cmp     al, 0FFh
     819        je      PSSHCWX_PartLost
     820    PSSHCWX_SyncEmpty:
     821        stosb                              ; Put translated pointer to new table
     822        dec     cl
     823        jnz     PSSHCWX_SyncLoop
     824        jmp     PSSHCWX_SyncLoopEnd
     825    PSSHCWX_PartLost:
     826        inc     dl                         ; One partition got lost...
     827        dec     cl
     828        jnz     PSSHCWX_SyncLoop
     829
     830    PSSHCWX_SyncLoopEnd:
     831        or      dl, dl
     832        jz      PSSHCWX_NothingLost
     833        mov     al, 0FFh                                                    ; Influences OVERWRITE BUG ! (OUT OF BOUNDS !!)
     834    PSSHCWX_LostFillLoop:
     835        stosb
     836        dec     cl
     837        jnz     PSSHCWX_LostFillLoop
     838
     839                                        ; debug code
     840                                        mov     ax,di
     841                                        call    AuxIO_TeletypeHexWord
     842                                        call    AuxIO_TeletypeNL
     843
     844    PSSHCWX_NothingLost:
     845        dec     ch
     846        jnz     PSSHCWX_SyncPartLoop
     847        ret
    827848PARTSCAN_SyncHideConfigWithXref EndP
    828849
  • trunk/BOOTCODE/REGULAR/STD_TEXT.ASM

    r42 r43  
    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: 20120214)', 0
    44 Copyright             db ' AiR-BOOT v1.0.8 - (c) 2012 M. Kiewitz  <<Internal Release 2c>> (bld: 20120216)', 0
     44Copyright             db ' AiR-BOOT v1.0.8 - (c) 2012 M. Kiewitz  <<Internal Release 2f>> (bld: 20120220)', 0
    4545;Copyright             db ' AiR-BOOT v1.0.8 - (c) 1998-2012 M. Kiewitz, Dedicated to Gerd Kiewitz', 0
    4646
  • trunk/BOOTCODE/SETUP/PART_SET.ASM

    r40 r43  
    13061306;        In: DL - Partition, where to save Hide-Config
    13071307; Destroyed: None, but Locate-Pointer
    1308 PARTHIDESETUP_CollectHideConfigAndPutToTable Proc Near Uses ax si es di
     1308PARTHIDESETUP_CollectHideConfigAndPutToTable Proc Near Uses ax si es di         ; checken !
    13091309   ; First calculate, where to put Hide-Config
    13101310   mov     ax, LocIPT_MaxPartitions
  • trunk/BOOTCODE/TEXT/FR/MBR.ASM

    r29 r43  
    2929TXT_ERROR_CheckCode            db ' - Le code', 0
    3030TXT_ERROR_CheckFailed          db ' de AiR-BOOT a ‚t‚ alt‚r‚.', 13, 10
    31                                db '   Veuillez red‚marrer avec la disquette AiR-BOOT afin de le restaurer.', 13, 10
    32                                db '   SystŠme arrˆt‚. Veuillez appuyez sur RESET.', 0
     31                               ;~ db '   Veuillez red‚marrer avec la disquette AiR-BOOT afin de le restaurer.', 13, 10
     32                               ;~ db '   SystŠme arrˆt‚. Veuillez appuyez sur RESET.', 0
     33
     34                                ; Had to shorten this to prevent overlap with double 'I13X' signature in MBR.
     35                                ; Hope it still makes sense...
     36                                db '   Veuillez red‚marrer avec la disq AiR-BOOT pour restaurer.', 13, 10
     37                                db '   SystŠme arrˆt‚. Veuillez appuyez RESET.', 0
  • trunk/BOOTCODE/TEXT/TXTMBR.ASM

    r41 r43  
    1 Include TEXT/EN/MBR.ASM                 
     1Include TEXT/EN/MBR.ASM
  • trunk/BOOTCODE/TEXT/TXTMENUS.ASM

    r41 r43  
    1 Include TEXT/EN/MENUS.ASM               
     1Include TEXT/EN/MENUS.ASM
  • trunk/BOOTCODE/TEXT/TXTOTHER.ASM

    r41 r43  
    1 Include TEXT/EN/OTHER.ASM       
     1Include TEXT/EN/OTHER.ASM
  • trunk/INCLUDE/ASM.INC

    r30 r43  
    3535EndM
    3636
     37
     38;
     39; An ORG directive resets the location counter where code and data is
     40; generated. If the location counter is reset back to a point where
     41; code or data already has been generated, this will be overwritten
     42; without warning.
     43; This macro can be used with every ORG directive to check for this condition,
     44; and when it occurs further assembly is terminated.
     45
     46; NOTE:  Overlapchecking in JWasm is not as reliable as in Tasm.
     47;        Because it's a single pass assembler, the current location can be
     48;        incorrect. Tasm with multiple passes works correct.
     49; FIXME: Get JWasm and Tasm use some common ECHO/%OUT method.
     50;        (Tasm only pases first word of non-quoted string to a macro)
     51check_overlap   MACRO   loc
     52
     53    ; Exit macro immediately if no overlap.
     54    ; We don't want to assign values to z_last_... if there is no
     55    ; overlap because they would then hold the values the last time this
     56    ; macro was called and not those of the last overlap.
     57    IF (loc - $) LE 0
     58    ;~ IF ($ - loc) GE 0
     59        EXITM
     60    ENDIF
     61
     62    ; Calculate the overlap.
     63    z_last_overlap_size = (loc - $)
     64    z_last_overlap_location = loc - z_last_overlap_size
     65
     66    IFDEF   JWASM
     67        ; Output message.
     68        ECHO
     69        ECHO ** ERROR: LOCATION OVERLAP DETECTED [JWASM] ! **
     70        ECHO .         THIS IS MOST LIKELY CAUSED BY CODE / DATA
     71        ECHO .         EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
     72        ECHO .         LOOK AT 'z_last_overlap_location' TO SEE WHERE.
     73        ECHO .         LOOK AT 'z_last_overlap_size' TO SEE SIZE.
     74        ECHO .         FORCING ERROR...
     75        ECHO
     76    ENDIF
     77    IFDEF   TASM
     78        IF2
     79            ; Output message (only on pass2).
     80            %OUT
     81            %OUT ** ERROR: LOCATION OVERLAP DETECTED [TASM] ! **
     82            %OUT .         THIS IS MOST LIKELY CAUSED BY CODE / DATA
     83            %OUT .         EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
     84            %OUT .         LOOK AT 'z_last_overlap_location' TO WHERE.
     85            %OUT .         LOOK AT 'z_last_overlap_size' TO SEE SIZE.
     86            %OUT .         FORCING ERROR...
     87            %OUT
     88        ENDIF
     89    ENDIF
     90
     91    ; Terminate assembly by forcing an error.
     92    .ERR
     93
     94ENDM
     95
     96
    3797; Shortcuts for pointer-types
    3898bptr                             equ   byte ptr
  • trunk/TOOLS/INTERNAL/FIXCODE.ASM

    r37 r43  
    3939                db ' - (c) Copyright 2009 by M. Kiewitz', 13, 10, '$'
    4040COM_LoadCode    db ' - Loading bootcode from file...$'
    41 COM_CodeName    db 'air-boot.com', 0
     41COM_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.COM', 0
    4444COM_MergeMBR    db ' - Merging MBR-protection into bootcode...$'
    4545COM_CountCode   db ' - Count code in bootcode-image...$'
Note: See TracChangeset for help on using the changeset viewer.