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


Ignore:
Timestamp:
Jun 23, 2013, 3:52:31 PM (11 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Building the BIOS Drive Information Tool now works again.
  • Moved all XT-CF related code to MODULE_8BIT_IDE_ADVANCED. I don't see how an XT-CF card could work without *_ADVANCED anyway but if I'm wrong, feel free to undo this. Note! The autodetection code in XTIDECFG has NOT been changed to reflect this (still relies on MODULE_8BIT_IDE).
  • Optimizations and fixes in general.
Location:
trunk/XTIDE_Universal_BIOS/Src/Device
Files:
5 edited

Legend:

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

    r551 r558  
    11; Project name  :   XTIDE Universal BIOS
    2 ; Description   :   IDE Read/Write functions for transferring
    3 ;           block using DMA.
    4 ;           These functions should only be called from IdeTransfer.asm.
     2; Description   :   IDE Read/Write functions for transferring block using DMA.
     3;                   These functions should only be called from IdeTransfer.asm.
     4
    55; Modified JJP 05-Jun-13
     6
    67;
    78; XTIDE Universal BIOS and Associated Tools
     
    8485    shl     cx, 9                                   ; CX = Block size in BYTEs
    8586%else
    86     xchg        cl, ch
     87    xchg    cl, ch
    8788    shl     cx, 1
    8889%endif
     
    9293    neg     ax          ; 2s compliment
    9394
    94     ; if DI was zero carry flag will be cleared (and set otherwise)
     95    ; If DI was zero carry flag will be cleared (and set otherwise)
    9596    ; When DI is zero only one transfer is required since we've limited the
    9697    ; XT-CFv3 block size to 32k
    97     jnc .TransferLastDmaPageWithSizeInCX
     98    jnc     SHORT .TransferLastDmaPageWithSizeInCX
    9899
    99100    ; CF was set, so DI != 0 and we might need one or two transfers
    100101    cmp     cx, ax                                  ; if we won't cross a physical page boundary...
    101     jbe SHORT .TransferLastDmaPageWithSizeInCX  ; ...perform the transfer in one operation
     102    jbe     SHORT .TransferLastDmaPageWithSizeInCX  ; ...perform the transfer in one operation
    102103
    103104    ; Calculate how much we can transfer on first and second rounds
    104     xchg        cx, ax          ; CX = BYTEs for first page
    105     sub     ax, cx          ; AX = BYTEs for second page
    106     push        ax          ; Save bytes for second transfer on stack
     105    xchg    cx, ax      ; CX = BYTEs for first page
     106    sub     ax, cx      ; AX = BYTEs for second page
     107    push    ax          ; Save bytes for second transfer on stack
    107108
    108109    ; Transfer first DMA page
     
    126127;       ES:DI updated (CX is added)
    127128;   Corrupts registers:
    128 ;       AX
     129;       AX, CX
    129130;--------------------------------------------------------------------
    130131ALIGN JUMP_ALIGN
     
    161162    sti                                                         ; Enable interrupts
    162163
     164    ; Update physical address in ES:DI - since IO might need several calls through this function either from here
     165    ; if crossing a physical page boundary, or from IdeTransfer.asm if requested sectors was > PIOVARS.wSectorsInBlock
     166    ; We update the pointer here (before the actual transfer) to avoid having to save the byte count on the stack
     167    mov     ax, es                      ; copy physical page address to ax
     168    add     di, cx                      ; add requested bytes to di
     169    adc     al, 0                       ; and increment physical page address, if required
     170    mov     es, ax                      ; and save it back in es
     171
    163172    ; XT-CF transfers 16 bytes at a time. We need to manually start transfer for every block by writing (anything)
    164173    ; to the XT-CFv3 Control Register, which raises DRQ thereby passing system control to the 8237 DMA controller.
     
    169178
    170179%if 0   ; Slow DMA code - works by checking 8237 status register after each 16-byte transfer, until it reports TC has been raised.
    171 ;ALIGN JUMP_ALIGN
    172 ;.TransferNextBlock:
    173 ;   cli                                 ; We want no ISR to read DMA Status Register before we do
    174 ;   out     dx, al                      ; Transfer up to 16 bytes to/from XT-CF card
    175 ;   in      al, STATUS_REGISTER_DMA8_in
    176 ;   sti
    177 ;   test    al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT
    178 ;   jz      SHORT .TransferNextBlock    ; All bytes transferred?
    179 %endif ; Slow DMA code
    180 
    181 %if 1   ; Fast DMA code - perform computed number of transfers, then check DMA status register to be sure
    182     push    cx                          ; need byte count to update pointer at the end
     180ALIGN JUMP_ALIGN
     181.TransferNextBlock:
     182    cli                                 ; We want no ISR to read DMA Status Register before we do
     183    out     dx, al                      ; Transfer up to 16 bytes to/from XT-CF card
     184    in      al, STATUS_REGISTER_DMA8_in
     185    sti
     186    test    al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT
     187    jz      SHORT .TransferNextBlock    ; All bytes transferred?
     188%else   ; Fast DMA code - perform computed number of transfers, then check DMA status register to be sure
    183189    add     cx, BYTE 15                 ; We'll divide transfers in 16-byte atomic transfers,
    184190    eSHR_IM cx, 4                       ; so include any partial block, which will be terminated
     
    191197    test    al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT  ; ... for channel 3 terminal count
    192198    jz      SHORT .TransferNextDmaBlock ; If not set, get more bytes
    193     pop     cx                          ; get back requested bytes
    194 %endif ; Fast DMA code
    195 
    196     ; Update physical address in ES:DI - since IO might need several calls through this function either from here
    197     ; if crossing a physical page boundary, and from IdeTransfer.asm if requested sectors was > PIOVARS.wSectorsInBlock
    198     mov     ax, es                      ; copy physical page address to ax
    199     add     di, cx                      ; add requested bytes to di
    200     adc     al, 0                       ; and increment physical page address, if required
    201     mov     es, ax                      ; and save it back in es
     199%endif
    202200
    203201    ret
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm

    r545 r558  
    6767    je      SHORT .InputToALfromMemoryMappedRegisterInBX
    6868    mov     bl, dl
    69     mov     bh, ADP50L_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET >> 8
     69    mov     bh, ADP50L_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET >> 8
    7070
    7171.InputToALfromMemoryMappedRegisterInBX:
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm

    r545 r558  
    11; Project name  :   XTIDE Universal BIOS
    2 ; Description   :   IDE Read/Write functions for transferring
    3 ;                   block using PIO modes.
     2; Description   :   IDE Read/Write functions for transferring block using PIO modes.
    43;                   These functions should only be called from IdeTransfer.asm.
    54
     
    6564;
    6665;   Parameters:
    67 ;       CX: Block size in 512 byte sectors
    68 ;       DX: IDE Data port address
     66;       CX:     Block size in 512 byte sectors
     67;       DX:     IDE Data port address
    6968;       ES:DI:  Normalized ptr to buffer to receive data
    7069;   Returns:
     
    10099;
    101100;   Parameters:
    102 ;       CX: Block size in 512 byte sectors
    103 ;       DX: IDE Data port address
     101;       CX:     Block size in 512 byte sectors
     102;       DX:     IDE Data port address
    104103;       ES:DI:  Normalized ptr to buffer to receive data
    105104;   Returns:
     
    111110IdePioBlock_ReadFrom16bitDataPort:
    112111%ifdef USE_186
    113     xchg        cl, ch  ; Sectors to WORDs
     112    xchg    cl, ch  ; Sectors to WORDs
    114113    rep insw
    115114    ret
     
    120119.ReadNextOword:
    121120    %rep 8  ; WORDs
    122         in      ax, dx  ; Read BYTE
    123         stosw           ; Store BYTE to [ES:DI]
     121        in      ax, dx  ; Read WORD
     122        stosw           ; Store WORD to [ES:DI]
    124123    %endrep
    125124    loop    .ReadNextOword
     
    152151; IdePioBlock_WriteToXtideRev1
    153152;   Parameters:
    154 ;       CX: Block size in 512-byte sectors
    155 ;       DX: IDE Data port address
     153;       CX:     Block size in 512-byte sectors
     154;       DX:     IDE Data port address
    156155;       ES:SI:  Normalized ptr to buffer containing data
    157156;   Returns:
     
    180179; IdePioBlock_WriteToXtideRev2  or rev 1 with swapped A0 and A3 (chuck-mod)
    181180;   Parameters:
    182 ;       CX: Block size in 512-byte sectors
    183 ;       DX: IDE Data port address
     181;       CX:     Block size in 512-byte sectors
     182;       DX:     IDE Data port address
    184183;       ES:SI:  Normalized ptr to buffer containing data
    185184;   Returns:
     
    191190IdePioBlock_WriteToXtideRev2:
    192191    UNROLL_SECTORS_IN_CX_TO_QWORDS
    193     push        ds
    194     push        es      ; Copy ES...
    195     pop         ds      ; ...to DS
     192    push    ds
     193    push    es      ; Copy ES...
     194    pop     ds      ; ...to DS
    196195ALIGN JUMP_ALIGN
    197196.WriteNextQword:
     
    207206; IdePioBlock_WriteTo8bitDataPort
    208207;   Parameters:
    209 ;       CX: Block size in 512-byte sectors
    210 ;       DX: IDE Data port address
     208;       CX:     Block size in 512-byte sectors
     209;       DX:     IDE Data port address
    211210;       ES:SI:  Normalized ptr to buffer containing data
    212211;   Returns:
     
    225224%else ; If 8088/8086
    226225    UNROLL_SECTORS_IN_CX_TO_QWORDS
    227     push        ds
    228     ;mov        ax, es
    229     ;mov        ds, ax  ; move es to ds via ax (does this run faster on 8088?)
    230     push        es
    231     pop         ds
     226    push    ds
     227    ;mov    ax, es
     228    ;mov    ds, ax  ; move es to ds via ax (does this run faster on 8088?)
     229    push    es
     230    pop     ds
    232231ALIGN JUMP_ALIGN
    233232.WriteNextQword:
     
    248247; IdePioBlock_WriteTo32bitDataPort      VLB/PCI 32-bit IDE
    249248;   Parameters:
    250 ;       CX: Block size in 512-byte sectors
    251 ;       DX: IDE Data port address
     249;       CX:     Block size in 512-byte sectors
     250;       DX:     IDE Data port address
    252251;       ES:SI:  Normalized ptr to buffer containing data
    253252;   Returns:
     
    274273.WriteNextQword:
    275274    %rep 4  ; WORDs
    276         lodsw           ; Load BYTE from [DS:SI]
    277         out dx, ax      ; Write BYTE
     275        lodsw           ; Load WORD from [DS:SI]
     276        out dx, ax      ; Write WORD
    278277    %endrep
    279278    loop    .WriteNextQword
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r545 r558  
    209209;       ES:SI:  Normalized pointer
    210210;       AH:     INT 13h Error Code (only when CF set)
    211 ;       CF:     Set of failed to normalize pointer (segment overflow)
     211;       CF:     Set if failed to normalize pointer (segment overflow)
    212212;               Cleared if success
    213213;   Corrupts registers:
     
    295295    ret
    296296%endif ; MODULE_8BIT_IDE_ADVANCED
    297     ; Fall to IdeTransfer_NormalizePointerInESSI if no MODULE_8BIT_IDE
     297    ; Fall to IdeTransfer_NormalizePointerInESSI if no MODULE_8BIT_IDE_ADVANCED
    298298
    299299
     
    305305;   Returns:
    306306;       ES:SI:  Normalized pointer (SI = 0...15)
    307 ;       AH:     INT 13h Error Code (only when CF set)
    308 ;       CF:     Set of failed to normalize pointer (segment overflow)
     307;       AH:     INT 13h Error Code (when USE_AT defined and normalization was attempted)
     308;       CF:     Set if failed to normalize pointer (segment overflow)
    309309;               Cleared if success
    310310;   Corrupts registers:
     
    319319%ifdef USE_AT
    320320    xor     dl, dl
    321     shl     dx, 1
     321    eSHL_IM dx, 1
    322322    dec     dx      ; Prevents normalization when bytes + offset will be zero
    323323    add     dx, si
     
    329329    NORMALIZE_FAR_POINTER   es, si, ax, dx
    330330%ifdef USE_AT       ; CF is always clear for XT builds
    331     jc      SHORT .SegmentOverflow
    332     ret
    333 .SegmentOverflow:
    334     mov     ah, RET_HD_INVALID
     331    ; AH = RET_HD_INVALID (01) if CF set, RET_HD_SUCCESS (00) if not. CF unchanged.
     332    sbb     ah, ah
     333    neg     ah
    335334%endif
    336335    ret
  • trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm

    r538 r558  
    6767        call    IdeTransfer_NormalizePointerInESSI
    6868%ifdef USE_AT
    69         jnc     SHORT .PointerNormalizationWasSuccessfull
     69        jnc     SHORT .PointerNormalizationWasSuccessful
    7070        xor     cx, cx          ; Nothing transferred
    71         jmp     SerialCommand_ReturnError
    72 .PointerNormalizationWasSuccessfull:
     71        stc
     72        ret
     73.PointerNormalizationWasSuccessful:
    7374%endif
    7475
Note: See TracChangeset for help on using the changeset viewer.