Changeset 445 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src


Ignore:
Timestamp:
Aug 29, 2012, 12:59:23 PM (12 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • A speed optimization to the eSHL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Memory_SumCXbytesFromESSItoAL now returns with the zero flag set/cleared according to the result.
  • Unrolled all the 8 bit READ transfer loops to do 16 bytes per iteration. Added a new macro (UNROLL_SECTORS_IN_CX_TO_OWORDS) as part of it. Size wise this is expensive but I think it should be worth the ROM space. The WRITE transfer loops were left as is since writes are rare anyway (<10% of all disk I/O IIRC).
  • Minor optimizations and fixes here and there.
Location:
trunk/XTIDE_Universal_BIOS/Src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm

    r444 r445  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616; GNU General Public License for more details.
    17 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html               
    18 ;       
     17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18;
    1919
    2020; Section containing code
     
    7979    test    bh, FLG_DRVNHEAD_DRV            ; Wait already done for Master
    8080    jnz     SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster
    81     call    AHDh_WaitUnilDriveMotorHasReachedFullSpeed
     81    call    AHDh_WaitUntilDriveMotorHasReachedFullSpeed
    8282.SkipLongWaitSinceDriveIsNotPrimaryMaster:
    8383
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r444 r445  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Structure containing variables for PIO transfer functions.
     
    119119    jc      SHORT ReturnWithTransferErrorInAH
    120120
    121     ; All sectors succesfully transferred
     121    ; All sectors successfully transferred
    122122    add     cx, [bp+PIOVARS.bSectorsDone]       ; Never sets CF
    123123    ret
     
    244244    ALIGN JUMP_ALIGN
    245245    ReadBlockFromXtideRev1:
    246         UNROLL_SECTORS_IN_CX_TO_QWORDS
     246        UNROLL_SECTORS_IN_CX_TO_OWORDS
    247247        mov     bl, 8       ; Bit mask for toggling data low/high reg
    248248    ALIGN JUMP_ALIGN
    249249    .InswLoop:
     250    %rep 8  ; WORDs
    250251        XTIDE_INSW
    251         XTIDE_INSW
    252         XTIDE_INSW
    253         XTIDE_INSW
     252    %endrep
    254253        loop    .InswLoop
    255254        ret
     
    259258        ALIGN JUMP_ALIGN
    260259        ReadBlockFromXtideRev2:
    261             UNROLL_SECTORS_IN_CX_TO_QWORDS
    262         ALIGN JUMP_ALIGN
    263         .ReadNextQword:
    264             in      ax, dx      ; Read 1st WORD
    265             stosw               ; Store 1st WORD to [ES:DI]
    266             in      ax, dx
    267             stosw               ; 2nd
    268             in      ax, dx
    269             stosw               ; 3rd
    270             in      ax, dx
    271             stosw               ; 4th
    272             loop    .ReadNextQword
     260            UNROLL_SECTORS_IN_CX_TO_OWORDS
     261        ALIGN JUMP_ALIGN
     262        .ReadNextOword:
     263        %rep 8  ; WORDs
     264            in      ax, dx      ; Read WORD
     265            stosw               ; Store WORD to [ES:DI]
     266        %endrep
     267            loop    .ReadNextOword
    273268            ret
    274269    %endif
     
    283278
    284279    %else ; If 8088/8086
    285             ALIGN JUMP_ALIGN
     280        ALIGN JUMP_ALIGN
    286281        ReadBlockFrom8bitDataPort:
    287             UNROLL_SECTORS_IN_CX_TO_DWORDS
    288         ALIGN JUMP_ALIGN
    289         .ReadNextDword:
    290             in      al, dx      ; Read 1st BYTE
    291             stosb               ; Store 1st BYTE to [ES:DI]
    292             in      al, dx
    293             stosb
    294 
    295             in      al, dx
    296             stosb
    297             in      al, dx
    298             stosb
    299             loop    .ReadNextDword
     282            UNROLL_SECTORS_IN_CX_TO_OWORDS
     283        ALIGN JUMP_ALIGN
     284        .ReadNextOword:
     285        %rep 16 ; BYTEs
     286            in      al, dx      ; Read BYTE
     287            stosb               ; Store BYTE to [ES:DI]
     288        %endrep
     289            loop    .ReadNextOword
    300290            ret
    301291    %endif
     
    349339    ALIGN JUMP_ALIGN
    350340    .OutswLoop:
     341    %rep 4  ; WORDs
    351342        XTIDE_OUTSW
    352         XTIDE_OUTSW
    353         XTIDE_OUTSW
    354         XTIDE_OUTSW
     343    %endrep
    355344        loop    .OutswLoop
    356345        pop     ds
     
    366355    ALIGN JUMP_ALIGN
    367356    .WriteNextQword:
     357    %rep 4  ; WORDs
    368358        XTIDE_MOD_OUTSW
    369         XTIDE_MOD_OUTSW
    370         XTIDE_MOD_OUTSW
    371         XTIDE_MOD_OUTSW
     359    %endrep
    372360        loop    .WriteNextQword
    373361        pop     ds
     
    392380        ALIGN JUMP_ALIGN
    393381        .WriteNextDword:
    394             lodsb               ; Load 1st BYTE from [DS:SI]
    395             out     dx, al      ; Write 1st BYTE
    396             lodsb
    397             out     dx, al
    398 
    399             lodsb
    400             out     dx, al
    401             lodsb
    402             out     dx, al
     382        %rep 4  ; BYTEs
     383            lodsb               ; Load BYTE from [DS:SI]
     384            out     dx, al      ; Write BYTE
     385        %endrep
    403386            loop    .WriteNextDword
    404387            pop     ds
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm

    r419 r445  
    121121    jc      SHORT ReturnWithMemoryIOtransferErrorInAH
    122122
    123     ; All rectors succesfully transferred
     123    ; All sectors successfully transferred
    124124    add     cx, [bp+PIOVARS.bSectorsDone]       ; Never sets CF
    125125    ret
  • trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm

    r376 r445  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing code
     
    3737
    3838;
    39 ; Note that this section is not under %ifdef MODULE_SERIAL_FLOPPY.  It is important to 
     39; Note that this section is not under %ifdef MODULE_SERIAL_FLOPPY.  It is important to
    4040; distinguish floppy disks presented by the server and not treat them as hard disks, even
    4141; if the floppy support is disabled.
    4242;
    4343        mov     al, [es:si+SerialServer_ATA_wDriveFlags]
    44         shl     al, 1
     44        eSHL_IM al, 1
    4545        mov     byte [di+DPT.bFlagsHigh], al
    46        
     46
    4747        ret
    4848
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r443 r445  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing code
     
    103103    ; Jump to correct BIOS function
    104104    eMOVZX  bx, ah
    105     shl     bx, 1
     105    eSHL_IM bx, 1
    106106    cmp     ah, 25h                     ; Possible EBIOS function?
    107107%ifndef MODULE_EBIOS
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r443 r445  
    244244;       Nothing
    245245;--------------------------------------------------------------------
     246DoNotEnable8bitMode:
    246247IgnoreInvalidCommandError:
    247248    xor     ah, ah  ; Clears CF
     
    270271;--------------------------------------------------------------------
    271272AH9h_Enable8bitPioModeForXTCF:
    272     eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]
     273    eMOVZX  bx, [di+DPT.bIdevarsOffset]
    273274    cmp     BYTE [cs:bx+IDEVARS.bDevice], DEVICE_8BIT_XTCF
    274     je      SHORT .Enable8bitMode
    275     xor     ah, ah      ; Do nothing for this device
    276     ret
    277 .Enable8bitMode:
     275    jne     SHORT DoNotEnable8bitMode
     276
    278277    mov     si, FEATURE_ENABLE_8BIT_PIO_TRANSFER_MODE
    279278    jmp     AH23h_SetControllerFeatures
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r429 r445  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616; GNU General Public License for more details.
    17 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html               
    18 ;               
     17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18;
    1919
    2020; Section containing code
     
    106106    push    cx
    107107    push    ax
    108     call    AHDh_WaitUnilDriveMotorHasReachedFullSpeed
     108    call    AHDh_WaitUntilDriveMotorHasReachedFullSpeed
    109109    call    AH9h_InitializeDriveForUse          ; Initialize Master or Slave (Master will come first in DPT list)
    110110
     
    133133
    134134;--------------------------------------------------------------------
    135 ; AHDh_WaitUnilDriveMotorHasReachedFullSpeed
     135; AHDh_WaitUntilDriveMotorHasReachedFullSpeed
    136136;   Parameters:
    137137;       DS:DI:  Ptr to DPT
     
    142142;       AL, BX, CX, DX
    143143;--------------------------------------------------------------------
    144 AHDh_WaitUnilDriveMotorHasReachedFullSpeed:
     144AHDh_WaitUntilDriveMotorHasReachedFullSpeed:
    145145%ifdef MODULE_SERIAL
    146146    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm

    r421 r445  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616; GNU General Public License for more details.
    17 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html               
    18 ;               
     17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18;
    1919
    2020; Section containing code
     
    5555    call    Prepare_GetOldInt13hCommandIndexToBX
    5656    mov     al, [di+DPT.bFlagsLow]
    57     shl     al, 1                   ; Set CF if LBA48 supported
     57    eSHL_IM al, 1                   ; Set CF if LBA48 supported
    5858    adc     bl, bh                  ; LBA48 EXT commands
    5959    ret
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm

    r442 r445  
    44
    55;
    6 ; XTIDE Universal BIOS and Associated Tools 
     6; XTIDE Universal BIOS and Associated Tools
    77; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    88;
     
    1111; the Free Software Foundation; either version 2 of the License, or
    1212; (at your option) any later version.
    13 ; 
     13;
    1414; This program is distributed in the hope that it will be useful,
    1515; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17 ; GNU General Public License for more details.     
     17; GNU General Public License for more details.
    1818; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    19 ;       
     19;
    2020
    2121; Section containing code
     
    2828;   Returns:
    2929;       CF:     Set if failed to verify ATA-ID
    30 ;               Cleared if ATA-ID verified succesfully
     30;               Cleared if ATA-ID verified successfully
    3131;   Corrupts registers:
    3232;       AX, BX, CX
     
    4444    call    .CompareCHorSfromOffsetBXtoMaxValueInCX
    4545
    46     add     bx, BYTE ATA1.wHeadCnt - ATA1.wCylCnt
     46    mov     bl, ATA1.wHeadCnt & 0FFh
    4747    mov     cx, MAX_VALID_PCHS_HEADS
    4848    call    .CompareCHorSfromOffsetBXtoMaxValueInCX
    4949
    50     add     bx, BYTE ATA1.wSPT - ATA1.wHeadCnt
     50    mov     bl, ATA1.wSPT & 0FFh
    5151    mov     cl, MAX_VALID_PCHS_SECTORS_PER_TRACK
    5252    call    .CompareCHorSfromOffsetBXtoMaxValueInCX
     
    6969    ; Check checksum byte
    7070    mov     cx, ATA6_size
    71     call    Memory_SumCXbytesFromESSItoAL
    72     test    al, al
     71    call    Memory_SumCXbytesFromESSItoAL       ; Returns with ZF set according to result
    7372    jnz     SHORT .FailedToVerifyAtaID
    7473
     
    119118    mov     bx, [es:si+ATA1.bPioMode]
    120119    mov     ax, bx                  ; AH = 0, AL = PIO mode 0, 1 or 2
    121     shl     bx, 1                   ; Shift for WORD lookup
     120    eSHL_IM bx, 1                   ; Shift for WORD lookup
    122121    mov     cx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs]
    123122
     
    187186;--------------------------------------------------------------------
    188187AtaID_GetActiveTimeToAXfromPioModeInBX:
    189     shl     bx, 1
    190     mov     ax, [cs:bx+.rgwPioModeToActiveTimeNs]
    191     shr     bx, 1
    192     ret
    193 
    194 .rgwPioModeToActiveTimeNs:
    195     dw      PIO_0_MIN_ACTIVE_TIME_NS
    196     dw      PIO_1_MIN_ACTIVE_TIME_NS
    197     dw      PIO_2_MIN_ACTIVE_TIME_NS
    198     dw      PIO_3_MIN_ACTIVE_TIME_NS
    199     dw      PIO_4_MIN_ACTIVE_TIME_NS
    200     dw      PIO_5_MIN_ACTIVE_TIME_NS
    201     dw      PIO_6_MIN_ACTIVE_TIME_NS
     188    eMOVZX  ax, [cs:bx+.rgbPioModeToActiveTimeNs]
     189    ret
     190
     191.rgbPioModeToActiveTimeNs:
     192    db      PIO_0_MIN_ACTIVE_TIME_NS
     193    db      PIO_1_MIN_ACTIVE_TIME_NS
     194    db      PIO_2_MIN_ACTIVE_TIME_NS
     195    db      PIO_3_MIN_ACTIVE_TIME_NS
     196    db      PIO_4_MIN_ACTIVE_TIME_NS
     197    db      PIO_5_MIN_ACTIVE_TIME_NS
     198    db      PIO_6_MIN_ACTIVE_TIME_NS
    202199
    203200%endif ; MODULE_ADVANCED_ATA
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm

    r423 r445  
    44;
    55;                   These algorithms are taken from: http://www.mossywell.com/boot-sequence
    6 ;                   Take a look at it for more detailed information.       
     6;                   Take a look at it for more detailed information.
    77;
    88;                   This file is shared with BIOS Drive Information Tool.
    99
    1010;
    11 ; XTIDE Universal BIOS and Associated Tools 
     11; XTIDE Universal BIOS and Associated Tools
    1212; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    1313;
     
    1616; the Free Software Foundation; either version 2 of the License, or
    1717; (at your option) any later version.
    18 ; 
     18;
    1919; This program is distributed in the hope that it will be useful,
    2020; but WITHOUT ANY WARRANTY; without even the implied warranty of
    2121; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22 ; GNU General Public License for more details.     
     22; GNU General Public License for more details.
    2323; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2424;
    25        
     25
    2626; Section containing code
    2727SECTION .text
     
    3333;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    3434;   Returns:
    35 ;       BX:DX:AX:   48-bit sectohr count
     35;       BX:DX:AX:   48-bit sector count
    3636;       CL:         FLGL_DPT_LBA48 if LBA48 supported
    3737;                   Zero if only LBA28 is supported
     
    239239    jbe     SHORT ReturnLCHSinAXBLBH
    240240    shr     ax, 1       ; Halve cylinders
    241     shl     bl, 1       ; Double heads
     241    eSHL_IM bl, 1       ; Double heads
    242242    inc     cx          ; Increment bit shift count
    243243    mov     dl, TRANSLATEMODE_LARGE
     
    300300    cmp     ax, cx
    301301    jbe     SHORT .NumberOfHeadsNowInCX
    302     shl     cx, 1                       ; Double number of heads
    303     test    ch, ch                      ; Reached 256 heads?
    304     jz      SHORT .CompareNextValidNumberOfHeads
    305     dec     cx                          ;  If so, limit heads to 255
     302    eSHL_IM cl, 1                       ; Double number of heads
     303    jnz     SHORT .CompareNextValidNumberOfHeads    ; Reached 256 heads?
     304    dec     cl                          ;  If so, limit heads to 255
    306305.NumberOfHeadsNowInCX:
    307306    mov     bx, cx                      ; Number of heads are returned in BL
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r422 r445  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing code
     
    145145
    146146    ; Compare user defined and ATA-ID sector count and select smaller
    147     xor     dx, dx
    148     xchg    bx, dx      ; User defined LBA now in BX:DX:AX
     147    mov     dx, bx
     148    xor     bx, bx      ; User defined LBA now in BX:DX:AX
    149149    cmp     bx, [di+DPT.twLbaSectors+4]
    150150    jb      SHORT .StoreUserDefinedSectorCountToDPT
Note: See TracChangeset for help on using the changeset viewer.