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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.