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