Changeset 363 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device


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!!!
Location:
trunk/XTIDE_Universal_BIOS/Src/Device/IDE
Files:
3 edited

Legend:

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

    r294 r363  
    5656    mov     [di+DPT.bIdevarsOffset], bp
    5757    mov     BYTE [di+DPT_ATA.bSetBlock], 1  ; Block = 1 sector
     58%ifdef MODULE_ADVANCED_ATA
     59    call    IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
     60%endif
    5861%ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
    5962    call    IdeDPT_StoreReversedAddressLinesFlagIfNecessary
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm

    r361 r363  
    1414;       CF:     Clear, IDE interface only supports hard disks
    1515;   Corrupts registers:
    16 ;       AX
     16;       AX, BX, CX, DX
    1717;--------------------------------------------------------------------
    1818IdeDPT_Finalize:
    19     ; Fall to .StoreBlockMode
    2019
    2120;--------------------------------------------------------------------
     
    3433    mov     ah, [es:si+ATA1.bBlckSize]      ; Max block size in sectors
    3534    mov     [di+DPT_ATA.wSetAndMaxBlock], ax
    36     ; Fall to IdeDPT_StoreReversedAddressLinesFlagIfNecessary
     35
     36%ifdef MODULE_ADVANCED_ATA
     37;--------------------------------------------------------------------
     38; .StoreDeviceType
     39;   Parameters:
     40;       DS:DI:  Ptr to Disk Parameter Table
     41;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     42;       CS:BP:  Ptr to IDEVARS for the controller
     43;   Returns:
     44;       Nothing
     45;   Corrupts registers:
     46;       Nothing
     47;--------------------------------------------------------------------
     48.StoreDeviceType:
     49    call    IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
     50
     51;--------------------------------------------------------------------
     52; .StorePioModeAndTimings
     53;   Parameters:
     54;       DS:DI:  Ptr to Disk Parameter Table
     55;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     56;       CS:BP:  Ptr to IDEVARS for the controller
     57;   Returns:
     58;       Nothing
     59;   Corrupts registers:
     60;       AX, CX, DX
     61;--------------------------------------------------------------------
     62.StorePioMode:
     63    call    AtaID_GetMaxPioModeToAXandMinCycleTimeToDX
     64    call    AtaID_ConvertPioModeFromAXandMinCycleTimeFromDXtoActiveAndRecoveryTime
     65    mov     [di+DPT_ATA.bPioMode], al
     66    mov     [di+DPT_ADVANCED_ATA.wMinPioActiveTimeNs], cx
     67    mov     [di+DPT_ADVANCED_ATA.wMinPioRecoveryTimeNs], dx
     68
     69;--------------------------------------------------------------------
     70; .DetectAdvancedIdeController
     71;   Parameters:
     72;       DS:DI:  Ptr to Disk Parameter Table
     73;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     74;       CS:BP:  Ptr to IDEVARS for the controller
     75;   Returns:
     76;       Nothing
     77;   Corrupts registers:
     78;       AX, BX, CX, DX
     79;--------------------------------------------------------------------
     80.DetectAdvancedIdeController:
     81    mov     dx, [cs:bp+IDEVARS.wPort]
     82    mov     [di+DPT_ADVANCED_ATA.wIdeBasePort], dx
     83    call    AdvAtaInit_DetectControllerForIdeBaseInDX
     84    mov     [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
     85    mov     [di+DPT_ADVANCED_ATA.wControllerBasePort], cx
     86    jnc     SHORT .NoAdvancedControllerDetected
     87
     88    ; Use highest common PIO mode from controller and drive.
     89    ; Many VLB controllers support PIO modes up to 2.
     90    call    AdvAtaInit_GetControllerMaxPioModeToAL
     91    jnc     SHORT .ChangeTo32bitDevice
     92    MIN_U   [di+DPT_ATA.bPioMode], al
     93
     94    ; We have detected 32-bit controller so change Device Type since
     95    ; it might have been set to 16-bit on IDEVARS
     96.ChangeTo32bitDevice:
     97    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
     98
     99.NoAdvancedControllerDetected:
     100
     101%endif ; MODULE_ADVANCED_ATA
    37102
    38103;--------------------------------------------------------------------
     
    42107;       CS:BP:  Ptr to IDEVARS for the controller
    43108;   Returns:
    44 ;       CF:     Always clear, we don't support floppies on the IDE inteface
     109;       CF:     Always clear
    45110;   Corrupts registers:
    46111;       Nothing
     
    53118.SetFlagForSwappedA0andA3:
    54119    or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3
    55 
    56120.EndDPT:
    57121    clc
    58122    ret
     123
     124
     125%ifdef MODULE_ADVANCED_ATA
     126;--------------------------------------------------------------------
     127; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
     128;   Parameters:
     129;       DS:DI:  Ptr to Disk Parameter Table
     130;       CS:BP:  Ptr to IDEVARS for the controller
     131;   Returns:
     132;       Nothing
     133;   Corrupts registers:
     134;       AL
     135;--------------------------------------------------------------------
     136IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI:
     137    mov     al, [cs:bp+IDEVARS.bDevice]
     138    mov     [di+DPT_ATA.bDevice], al
     139    ret
     140%endif
  • 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.