Ignore:
Timestamp:
Mar 26, 2012, 4:20:43 PM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Added Advanced ATA Module (MODULE_ADVANCED_ATA) with native support for QDI Vision QD6500 and QD6580 VLB IDE Controllers.
  • Hopefully optimized IDE transfer functions for 8088 (replaced some memory accesses from WORD to BYTE).
  • XT build does not fit in 8k at the moment!!!
File:
1 edited

Legend:

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

    r361 r363  
    55; This struct must not be larger than IDEPACK without INTPACK.
    66struc PIOVARS
    7     .wWordsInBlock          resb    2   ; 0, Block size in WORDs
    8     .wWordsLeft             resb    2   ; 2, WORDs left to transfer
    9     .wWordsDone             resb    2   ; 4, Number of sectors xferred
    10                             resb    1   ; 6,
     7    .wDataPort              resb    2   ; 0, IDE Data Port
     8    .fnXfer                 resb    2   ; 2, Offset to transfer function
     9    .wSectorsInBlock        resb    2   ; 4, Block size in sectors
     10    .bSectorsLeft           resb    1   ; 6, Sectors left to transfer
    1111                            resb    1   ; 7, IDEPACK.bDeviceControl
    12     .wDataPort              resb    2   ; 8, IDE Data Port
    13     .fnXfer                 resb    2   ; 10, Offset to transfer function
     12    .bSectorsDone           resb    1   ; 8, Number of sectors xferred
    1413endstruc
    1514
     
    6968    xchg    si, di                              ; ES:DI now points buffer
    7069
    71     mov     cx, [bp+PIOVARS.wWordsInBlock]
     70    mov     cx, [bp+PIOVARS.wSectorsInBlock]    ; Max 128
    7271
    7372ALIGN JUMP_ALIGN
    7473.ReadNextBlockFromDrive:
    7574    mov     dx, [bp+PIOVARS.wDataPort]
    76     cmp     [bp+PIOVARS.wWordsLeft], cx
     75    cmp     [bp+PIOVARS.bSectorsLeft], cl
    7776    jbe     SHORT .ReadLastBlockFromDrive
    7877    call    [bp+PIOVARS.fnXfer]
     
    8483    xchg    si, di                              ; ES:DI now points buffer
    8584
    86     ; Increment number of successfully read WORDs
    87     mov     cx, [bp+PIOVARS.wWordsInBlock]
    88     sub     [bp+PIOVARS.wWordsLeft], cx
    89     add     [bp+PIOVARS.wWordsDone], cx
     85    ; Increment number of successfully read sectors
     86    mov     cx, [bp+PIOVARS.wSectorsInBlock]
     87    sub     [bp+PIOVARS.bSectorsLeft], cl
     88    add     [bp+PIOVARS.bSectorsDone], cl
    9089    jmp     SHORT .ReadNextBlockFromDrive
    9190
    9291ALIGN JUMP_ALIGN
    9392.ReadLastBlockFromDrive:
    94     mov     cx, [bp+PIOVARS.wWordsLeft]
     93    mov     cl, [bp+PIOVARS.bSectorsLeft]       ; CH is already zero
    9594    call    [bp+PIOVARS.fnXfer]                 ; Transfer possibly partial block
    9695
     
    103102    ; Return number of successfully read sectors
    104103ReturnWithTransferErrorInAH:
    105     mov     cx, [bp+PIOVARS.wWordsDone]
    106     jc      SHORT .ConvertTransferredWordsInCXtoSectors
    107     add     cx, [bp+PIOVARS.wWordsLeft]         ; Never sets CF
    108 .ConvertTransferredWordsInCXtoSectors:
    109     xchg    cl, ch
     104    mov     cl, [bp+PIOVARS.bSectorsDone]
     105    mov     ch, 0                               ; Preserve CF
    110106    ret
    111107
     
    137133    jc      SHORT ReturnWithTransferErrorInAH
    138134
    139     mov     cx, [bp+PIOVARS.wWordsInBlock]
     135    mov     cx, [bp+PIOVARS.wSectorsInBlock]    ; Max 128
    140136
    141137ALIGN JUMP_ALIGN
    142138.WriteNextBlockToDrive:
    143139    mov     dx, [bp+PIOVARS.wDataPort]
    144     cmp     [bp+PIOVARS.wWordsLeft], cx
     140    cmp     [bp+PIOVARS.bSectorsLeft], cl
    145141    jbe     SHORT .WriteLastBlockToDrive
    146142    call    [bp+PIOVARS.fnXfer]
     
    150146    jc      SHORT ReturnWithTransferErrorInAH
    151147
    152     ; Increment number of successfully written WORDs
    153     mov     cx, [bp+PIOVARS.wWordsInBlock]
    154     sub     [bp+PIOVARS.wWordsLeft], cx
    155     add     [bp+PIOVARS.wWordsDone], cx
     148    ; Increment number of successfully written sectors
     149    mov     cx, [bp+PIOVARS.wSectorsInBlock]
     150    sub     [bp+PIOVARS.bSectorsLeft], cl
     151    add     [bp+PIOVARS.bSectorsDone], cl
    156152    jmp     SHORT .WriteNextBlockToDrive
    157153
    158154ALIGN JUMP_ALIGN
    159155.WriteLastBlockToDrive:
    160     mov     cx, [bp+PIOVARS.wWordsLeft]
     156    mov     cl, [bp+PIOVARS.bSectorsLeft]       ; CH is already zero
    161157%ifdef USE_186
    162158    push    CheckErrorsAfterTransferringLastBlock
     
    183179InitializePiovarsInSSBPwithSectorCountInAH:
    184180    ; Store sizes
    185     xor     al, al
    186     mov     [bp+PIOVARS.wWordsLeft], ax
    187     mov     ah, [di+DPT_ATA.bSetBlock]
    188     mov     [bp+PIOVARS.wWordsInBlock], ax
    189     cbw
    190     mov     [bp+PIOVARS.wWordsDone], ax         ; Zero
     181    mov     [bp+PIOVARS.bSectorsLeft], ah
     182    eMOVZX  ax, BYTE [di+DPT_ATA.bSetBlock]
     183    mov     [bp+PIOVARS.wSectorsInBlock], ax
     184    mov     [bp+PIOVARS.bSectorsDone], ah       ; Zero
    191185
    192186    ; Get transfer function based on bus type
     
    194188    mov     bl, [di+DPT.bIdevarsOffset]         ; CS:BX now points to IDEVARS
    195189    mov     dx, [cs:bx+IDEVARS.wPort]           ; Load IDE Data port address
     190%ifdef MODULE_ADVANCED_ATA
     191    mov     bl, [di+DPT_ATA.bDevice]
     192%else
    196193    mov     bl, [cs:bx+IDEVARS.bDevice]         ; Load device type to BX
     194%endif
    197195    add     bx, ax
     196
    198197    mov     [bp+PIOVARS.wDataPort], dx
    199198    mov     ax, [cs:bx]                         ; Load offset to transfer function
     
    208207; ReadBlockFrom32bitDataPort    VLB/PCI 32-bit IDE
    209208;   Parameters:
    210 ;       CX:     Block size in WORDs
     209;       CX:     Block size in 512 byte sectors
    211210;       DX:     IDE Data port address
    212211;       ES:DI:  Normalized ptr to buffer to receive data
     
    218217ALIGN JUMP_ALIGN
    219218ReadBlockFromXtideRev1:
    220     eSHR_IM cx, 2       ; Loop unrolling
     219    UNROLL_SECTORS_IN_CX_TO_QWORDS
    221220    mov     bx, 8       ; Bit mask for toggling data low/high reg
    222221ALIGN JUMP_ALIGN
     
    233232ALIGN JUMP_ALIGN
    234233ReadBlockFromXtideRev2:
    235     times 2 shr cx, 1   ; WORD count to QWORD count
     234    UNROLL_SECTORS_IN_CX_TO_QWORDS
    236235ALIGN JUMP_ALIGN
    237236.ReadNextQword:
     
    251250ALIGN JUMP_ALIGN
    252251ReadBlockFrom16bitDataPort:
     252    xchg    cl, ch      ; Sectors to WORDs
    253253    rep
    254254    db      6Dh         ; INSW (we want this in XT build)
     
    258258ALIGN JUMP_ALIGN
    259259ReadBlockFrom32bitDataPort:
    260     shr     cx, 1       ; WORD count to DWORD count
     260    db      0C1h        ; SHL
     261    db      0E1h        ; CX
     262    db      7           ; 7 (Sectors to DWORDs)
    261263    rep
    262264    db      66h         ; Override operand size to 32-bit
     
    272274; WriteBlockTo32bitDataPort     VLB/PCI 32-bit IDE
    273275;   Parameters:
    274 ;       CX:     Block size in WORDs
     276;       CX:     Block size in 512-byte sectors
    275277;       DX:     IDE Data port address
    276278;       ES:SI:  Normalized ptr to buffer containing data
     
    284286    push    ds
    285287    push    bx
    286     eSHR_IM cx, 2       ; Loop unrolling
     288    UNROLL_SECTORS_IN_CX_TO_QWORDS
    287289    mov     bx, 8       ; Bit mask for toggling data low/high reg
    288290    push    es          ; Copy ES...
     
    302304ALIGN JUMP_ALIGN
    303305WriteBlockToXtideRev2:
     306    UNROLL_SECTORS_IN_CX_TO_QWORDS
    304307    push    ds
    305     eSHR_IM cx, 2       ; Loop unrolling
    306308    push    es          ; Copy ES...
    307309    pop     ds          ; ...to DS
     
    320322ALIGN JUMP_ALIGN
    321323WriteBlockToFastXtide:
    322     times 2 shr cx, 1   ; WORD count to QWORD count
     324    UNROLL_SECTORS_IN_CX_TO_QWORDS
    323325    push    ds
    324326    push    es
     
    342344ALIGN JUMP_ALIGN
    343345WriteBlockTo16bitDataPort:
     346    xchg    cl, ch      ; Sectors to WORDs
    344347    es                  ; Source is ES segment
    345348    rep
     
    350353ALIGN JUMP_ALIGN
    351354WriteBlockTo32bitDataPort:
    352     shr     cx, 1       ; WORD count to DWORD count
     355    db      0C1h        ; SHL
     356    db      0E1h        ; CX
     357    db      7           ; 7 (Sectors to DWORDs)
    353358    es                  ; Source is ES segment
    354359    rep
Note: See TracChangeset for help on using the changeset viewer.