Ignore:
Timestamp:
Nov 21, 2021, 2:15:32 PM (2 years ago)
Author:
krille_n_
Message:

Changes:

  • Fixed three different bugs all causing the boot menu to show drives using IRQs even though the BIOS had been built without MODULE_IRQ.
  • Fixed two bugs in XTIDECFG where loading a BIOS from file and then loading the old settings from EEPROM would
    • overwrite ROMVARS.wFlags in the loaded BIOS file (in RAM). The possibly resulting mismatch of module flags could make it impossible to change settings for modules included in the BIOS or allow changing settings for modules not included in the BIOS.
    • not copy the color theme over to the loaded BIOS.
  • Also fixed two very minor bugs in XTIDECFG in BiosFile_LoadFileFromDSSItoRamBuffer and BiosFile_SaveRamBufferToFileInDSSI where the error handling in these routines would close whatever file handle that happened to match the error code returned by DOS in AX.
  • Made significant changes to the new flash ROM programming routines to reduce the size. Also fixed a minor bug that would cause the second verification to be skipped and return success when programming a 64 KB block of data.
  • Changed the custom BIOS build file names to the 8.3 format.
  • Changed some help strings in XTIDECFG to clarify things.
  • Other minor optimizations and fixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/FlashSST.asm

    r620 r621  
    33
    44;
    5 ; Created by Jayeson Lee-Steere
    6 ; Hereby placed into the public domain.
     5; XTIDE Universal BIOS and Associated Tools
     6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2021 by XTIDE Universal BIOS Team.
     7;
     8; This program is free software; you can redistribute it and/or modify
     9; it under the terms of the GNU General Public License as published by
     10; the Free Software Foundation; either version 2 of the License, or
     11; (at your option) any later version.
     12;
     13; This program is distributed in the hope that it will be useful,
     14; but WITHOUT ANY WARRANTY; without even the implied warranty of
     15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16; GNU General Public License for more details.
     17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    718;
    819
     
    2738    push    si
    2839    push    bp
    29     mov     bp, bx                  ; Flashvars now in SS:BP.
     40    mov     bp, bx                  ; Flashvars now in SS:BP (Assumes SS=DS)
    3041
    3142    mov     BYTE [bp+FLASHVARS.flashResult], FLASH_RESULT.DeviceNotDetected
     
    3445
    3546    call    CalibrateSstTimeout
    36    
     47
    3748    mov     BYTE [bp+FLASHVARS.flashResult], FLASH_RESULT.PollingTimeoutError
    3849    mov     cx, [bp+FLASHVARS.wPagesToFlash]
    39     lds     si, [bp+FLASHVARS.fpNextSourcePage]
    40     les     di, [bp+FLASHVARS.fpNextDestinationPage]
     50    mov     dx, [bp+FLASHVARS.wEepromPageSize]
     51    les     di, [bp+FLASHVARS.fpNextSourcePage]
     52    lds     si, [bp+FLASHVARS.fpNextDestinationPage]
    4153%ifdef CLD_NEEDED
    4254    cld
     
    4961    push    di
    5062    push    cx
    51     mov     cx, [bp+FLASHVARS.wEepromPageSize]
    52     mov     bx, cx
     63    mov     cx, dx
    5364    repe cmpsb
    5465    pop     cx
    5566    pop     di
    5667    pop     si
    57     jnz     SHORT .FlashThisPage
    58     add     si, bx
    59     add     di, bx
     68    jne     SHORT .FlashThisPage
     69    add     si, dx
     70    add     di, dx
    6071    jmp     SHORT .ContinueLoop
    6172
     
    6980
    7081    ; The write process has already confirmed the results one byte at a time.
    71     ; Here we do an additional verify check just in case there was some 
     82    ; Here we do an additional verify check just in case there was some
    7283    ; kind of oddity with pages / addresses.
    7384    mov     BYTE [bp+FLASHVARS.flashResult], FLASH_RESULT.DataVerifyError
     85%ifndef USE_186
    7486    mov     ax, [bp+FLASHVARS.wPagesToFlash]
    75     mov     cl, SST_PAGE_SIZE_SHIFT
     87    mov     cl, SST_PAGE_SIZE_SHIFT - 1     ; -1 because we compare WORDs (verifying 64 KB won't work otherwise)
    7688    shl     ax, cl
    77     mov     cx, ax
     89    xchg    cx, ax
     90%else
     91    mov     cx, [bp+FLASHVARS.wPagesToFlash]
     92    shl     cx, SST_PAGE_SIZE_SHIFT - 1
     93%endif
    7894    lds     si, [bp+FLASHVARS.fpNextSourcePage]
    7995    les     di, [bp+FLASHVARS.fpNextDestinationPage]
    80     repe cmpsb
    81     jnz     SHORT .ExitOnError
     96    repe cmpsw
     97    jne     SHORT .ExitOnError
    8298
    8399%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
     
    106122;           Set if supported SST device not found
    107123;   Corrupts registers:
    108 ;       AX, DI, ES
     124;       AX, BX, SI, DS
    109125;--------------------------------------------------------------------
    110126ALIGN JUMP_ALIGN
    111127DetectSstDevice:
    112     les     di, [bp+FLASHVARS.fpNextDestinationPage]
     128    lds     si, [bp+FLASHVARS.fpNextDestinationPage]
     129    mov     bx, 5555h
    113130
    114131    cli
    115     mov     BYTE [es:05555h], 0AAh  ; Enter software ID sequence.
    116     mov     BYTE [es:02AAAh], 055h
    117     mov     BYTE [es:05555h], 090h
    118     mov     al, [es:di]             ; Extra reads to be sure device
    119     mov     al, [es:di]             ; has time to respond.
    120     mov     al, [es:di]
    121     mov     ah, [es:di]             ; Vendor ID in AH.
    122     mov     al, [es:di + 1]         ; Device ID in AL.
    123     mov     BYTE [es:05555h], 0F0h  ; Exit software ID.
     132    mov     BYTE [bx], 0AAh         ; Enter software ID sequence.
     133    shr     bx, 1                   ; BX=2AAAh, CF=1
     134    mov     BYTE [bx], 55h
     135    eRCL_IM bx, 1                   ; BX=5555h
     136    mov     BYTE [bx], 90h
     137    mov     al, [si]                ; Extra reads to be sure device
     138    mov     al, [si]                ; has time to respond.
     139    mov     al, [si]
     140    mov     ah, [si]                ; Vendor ID in AH.
     141    mov     al, [si+1]              ; Device ID in AL.
     142    mov     BYTE [bx], 0F0h         ; Exit software ID.
    124143    sti
    125144
    126     cmp     al, 0B4h
     145    cmp     ax, 0BFB4h
    127146    jb      SHORT .NotValidDevice
    128     cmp     al, 0B7h
    129     ja      SHORT .NotValidDevice
    130     cmp     ah, 0BFh
    131     jne     SHORT .NotValidDevice
    132     ret
    133 
     147    cmp     ax, 0BFB7h+1
     148    cmc
    134149.NotValidDevice:
    135     stc
    136     ret
    137    
     150    ret
     151
    138152;--------------------------------------------------------------------
    139153; CalibrateSstTimeout
     
    147161ALIGN JUMP_ALIGN
    148162CalibrateSstTimeout:
    149     LOAD_BDA_SEGMENT_TO ds, ax
    150     les     di, [bp+FLASHVARS.fpNextDestinationPage]
    151     xor     cx, cx
     163    LOAD_BDA_SEGMENT_TO es, cx, !
     164    mov     ds, [bp+FLASHVARS.fpNextDestinationPage+2]
     165    mov     bx, BDA.dwTimerTicks
    152166    mov     si, cx
    153167    mov     di, cx
    154     mov     al, [es:di]
    155     not     al                          ; Forces poll to fail.
    156 
    157     mov     bx, [BDA.dwTimerTicks]      ; Read low word only.
    158     inc     bx
     168    mov     al, [di]
     169    inc     ax                      ; Forces poll to fail
     170
     171    mov     ah, [es:bx]             ; Read low byte only
     172    inc     ah
    159173.WaitForFirstIncrement:
    160     cmp     bx, [BDA.dwTimerTicks]
    161     jnz     SHORT .WaitForFirstIncrement
    162 
    163     inc     bx
     174    cmp     ah, [es:bx]
     175    jne     SHORT .WaitForFirstIncrement
     176
     177    inc     ah
    164178
    165179.WaitForSecondIncrement:
    166     inc     ch                          ; cx now 0x0100
    167 .PollLoop:                              ; Identical to poll loop used
    168     cmp     [es:di], al                 ; during programming
    169     jz      SHORT .PollComplete         ; Will never branch in this case
    170     loop    .PollLoop
    171 .PollComplete:
    172     add     si, 1                       ; number of poll loops completed
    173     jc      SHORT .countOverflow
    174     cmp     bx, [BDA.dwTimerTicks]
    175     jnz     SHORT .WaitForSecondIncrement
    176 
    177 .CalComplete:
    178     ; SI ~= number of polling loops in 215us.
    179     mov     [bp+FLASHVARS.wTimeoutCounter], si
    180     ret
    181        
    182 .countOverflow:
     180    inc     ch                      ; CX now 0x0100
     181.PollLoop:                          ; Identical to poll loop used
     182    cmp     [di], al                ; during programming
     183    loopne  .PollLoop               ; Will never be equal in this case
     184    inc     si                      ; Number of poll loops completed
     185    jz      SHORT .CountOverflow
     186    cmp     ah, [es:bx]
     187    jne     SHORT .WaitForSecondIncrement
     188    SKIP1B  al
     189.CountOverflow:
    183190    ; Clamp on overflow, although it should not be possible on
    184191    ; real hardware. In principle SI could overflow on a very
     
    187194    ; the device, SI can not overflow.
    188195    dec     si
    189     jmp     SHORT .CalComplete
     196
     197    ; SI ~= number of polling loops in 215us.
     198    mov     [bp+FLASHVARS.wTimeoutCounter], si
     199    ret
    190200
    191201;--------------------------------------------------------------------
    192202; EraseSstPage
    193203;   Parameters:
    194 ;       ES:DI:  Destination ptr.
     204;       DS:SI:  Destination ptr
    195205;   Returns:
    196206;       CF:     Set on error.
    197207;   Corrupts registers:
    198 ;       AX
     208;       AX, BX
    199209;--------------------------------------------------------------------
    200210ALIGN JUMP_ALIGN
     
    202212    push    cx
    203213
    204     mov     BYTE [es:05555h], 0AAh  ; Sector erase sequence.
    205     mov     BYTE [es:02AAAh], 055h
    206     mov     BYTE [es:05555h], 080h
    207     mov     BYTE [es:05555h], 0AAh
    208     mov     BYTE [es:02AAAh], 055h
    209     mov     BYTE [es:di], 030h
    210 
     214    mov     bx, 5555h
     215    mov     ax, 2AAAh
     216
     217    ; Sector erase sequence.
     218    mov     [bx], al                ; [5555h] <- AAh
     219    xchg    bx, ax
     220    mov     [bx], al                ; [2AAAh] <- 55h
     221    xchg    bx, ax
     222    mov     BYTE [bx], 80h          ; [5555h] <- 80h
     223    mov     [bx], al                ; [5555h] <- AAh
     224    xchg    bx, ax
     225    mov     [bx], al                ; [2AAAh] <- 55h
     226    mov     BYTE [si], 30h
     227
     228    or      bl, al                  ; BL = 0FFh
    211229    mov     ax, 1163                ; 1163 x ~215us = 250ms = 10x datasheet max
    212230.TimeoutOuterLoop:
    213231    mov     cx, [bp+FLASHVARS.wTimeoutCounter]
    214232.TimeoutInnerLoop:
    215     cmp     BYTE [es:di], 0FFh      ; Will return 0FFh when erase complete.
    216     jz      SHORT .Exit
    217     loop    .TimeoutInnerLoop
     233    cmp     [si], bl                ; Will return 0FFh when erase complete
     234    loopne  .TimeoutInnerLoop
     235    je      SHORT .Return
    218236    dec     ax
    219237    jnz     SHORT .TimeoutOuterLoop
    220     stc                             ; Timed out.
    221 .Exit:
     238    ; Timed out (CF=1)
     239.Return:
    222240    pop     cx
    223241    ret
     
    226244; WriteSstPage
    227245;   Parameters:
    228 ;       DS:SI:  Source ptr.
    229 ;       ES:DI:  Destination ptr.
     246;       DX:     EEPROM page size
     247;       DS:SI:  Destination ptr
     248;       ES:DI:  Source ptr
    230249;   Returns:
    231250;       SI, DI: Each advanced forward 1 page.
    232251;       CF:     Set on error.
    233252;   Corrupts registers:
    234 ;       AL, BX, DX
     253;       AL, BX
    235254;--------------------------------------------------------------------
    236255ALIGN JUMP_ALIGN
    237256WriteSstPage:
    238257    push    cx
     258    push    dx
    239259
    240260    mov     bx, [bp+FLASHVARS.wTimeoutCounter]
    241     mov     dx, [bp+FLASHVARS.wEepromPageSize]
     261    xchg    si, di
    242262    cli
    243263
    244264.NextByte:
    245     lodsb
    246     mov     BYTE [es:05555h], 0AAh  ; Byte program sequence.
    247     mov     BYTE [es:02AAAh], 055h
    248     mov     BYTE [es:05555h], 0A0h
    249     mov     [es:di], al
     265    es lodsb                        ; Read byte from ES:SI
     266    mov     BYTE [5555h], 0AAh      ; Byte program sequence.
     267    mov     BYTE [2AAAh], 55h
     268    mov     BYTE [5555h], 0A0h
     269    mov     [di], al                ; Write byte to DS:DI
    250270
    251271    mov     cx, bx
    252272.WaitLoop:
    253     cmp     [es:di], al             ; Device won't return actual data until
    254     jz      SHORT .ByteFinished     ; write complete. Timeout ~215us, or
    255     loop    .WaitLoop               ; ~10x 20us max program time from datasheet.
    256 
    257     stc                             ; Write timeout.
    258     jmp     SHORT .Exit
    259 
    260 .ByteFinished:
     273    cmp     [di], al                ; Device won't return actual data until write complete.
     274    loopne  .WaitLoop               ; Timeout ~215us, or ~10x 20us max program time from datasheet.
     275    jne     SHORT .WriteTimeout
     276
    261277    inc     di
    262278    dec     dx
    263279    jnz     SHORT .NextByte
    264     clc
    265 .Exit:
     280    SKIP1B  al
     281.WriteTimeout:
     282    stc
    266283    sti
    267     pop     cx
    268     ret
     284    xchg    si, di
     285    pop     dx
     286    pop     cx
     287    ret
Note: See TracChangeset for help on using the changeset viewer.