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


Ignore:
Timestamp:
Apr 19, 2013, 11:44:35 AM (11 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Integrated XT-CFv3 support by James Pearce.
  • XT-CFv2 memory mapped I/O and DMA modes are no longer supported (but PIO mode is).
Location:
trunk/XTIDE_Universal_BIOS/Src/Device/IDE
Files:
6 edited

Legend:

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

    r540 r545  
    8080    test    bh, FLG_DRVNHEAD_DRV        ; Wait already done for Master
    8181    jnz     SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster
    82     mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_DRDY)
     82    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_BSY)
    8383    call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
    8484.SkipLongWaitSinceDriveIsNotPrimaryMaster:
     
    8888    call    Idepack_FakeToSSBP
    8989
    90 %ifdef MODULE_8BIT_IDE_ADVANCED
     90%ifdef MODULE_8BIT_IDE
    9191    ; Enable 8-bit PIO mode for 8-bit ATA and XT-CF
    9292    push    si
    9393    call    AH9h_Enable8bitModeForDevice8bitAta
    94     xor     al, al                      ; XTCF_8BIT_PIO_MODE
     94%ifdef MODULE_8BIT_IDE_ADVANCED
     95    mov     al, XTCF_8BIT_PIO_MODE      ; initialise with most basic transfer mode
    9596    call    AH9h_SetModeFromALtoXTCF
     97%endif ; MODULE_8BIT_IDE_ADVANCED
    9698    pop     si
    97 %endif ; MODULE_8BIT_IDE_ADVANCED
     99%endif ; MODULE_8BIT_IDE
    98100
    99101    ; Prepare to output Identify Device command
     
    173175    jne     SHORT .WaitUntilNonTransferCommandCompletes
    174176%ifdef MODULE_8BIT_IDE_ADVANCED
    175     cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_MEMMAP
    176     jae     SHORT JrIdeTransfer_StartWithCommandInAL    ; DEVICE_8BIT_XTCF_MEMMAP, DEVICE_8BIT_JRIDE_ISA or DEVICE_8BIT_ADP50L
     177    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_JRIDE_ISA
     178    jae     SHORT JrIdeTransfer_StartWithCommandInAL    ; DEVICE_8BIT_JRIDE_ISA or DEVICE_8BIT_ADP50L
    177179%endif
    178180    jmp     IdeTransfer_StartWithCommandInAL
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDmaBlock.asm

    r526 r545  
    7878    ; so we never need to separate transfer to more than 2 separate DMA operations.
    7979
    80     ; Load XT-CF Control Register port to DX
     80    ; Load XT-CFv3 Control Register port to DX
    8181    add     dl, XTCF_CONTROL_REGISTER
    8282
     
    9090    shl     cx, 1
    9191%endif
    92     cmp     cx, ax
    93     jbe     SHORT .TransferLastDmaPageWithSizeInCX
     92    cmp     cx, ax                                  ; if we won't cross a physical page boundary...
     93    jbe     SHORT .TransferLastDmaPageWithSizeInCX  ; ...perform the transfer in one operation
    9494
    95     ; Push size for second DMA page
     95    ; Calculate how much we can transfer on first and second rounds
    9696    xchg    cx, ax                                  ; CX = BYTEs for first page
    9797    sub     ax, cx                                  ; AX = BYTEs for second page
    98     push    ax
     98    push    ax                                      ; Save bytes for second transfer on stack
    9999
    100100    ; Transfer first DMA page
     
    108108;--------------------------------------------------------------------
    109109; StartDMAtransferForXTCFwithDmaModeInBL
     110; Updated for XT-CFv3, 11-Apr-13
    110111;   Parameters:
    111112;       BL:     Byte for DMA Mode Register
    112 ;       CX:     Number of BYTEs to transfer (1...32768 since max block size is limited to 64)
    113 ;       DX:     XTCF Control Register
     113;       CX:     Number of BYTEs to transfer (512...32768 since max block size is limited to 64)
     114;       DX:     XT-CFv3 Control Register
     115;       ES:     Bits 3..0 have physical address bits 19..16
     116;       DI:     Physical address bits 15..0
    114117;   Returns:
    115 ;       Nothing
     118;       ES:DI updated (CX is added)
    116119;   Corrupts registers:
    117120;       AX
     
    122125    ; Disable Interrupts and DMA Channel 3 during DMA setup
    123126    mov     al, SET_CH3_MASK_BIT
    124     cli                                     ; Disable interrupts
    125     out     MASK_REGISTER_DMA8_out, al      ; Disable DMA Channel 3
     127    cli                                 ; Disable interrupts - programming must be atomic
     128    out     MASK_REGISTER_DMA8_out, al  ; Disable DMA Channel 3
    126129
    127130    ; Set DMA Mode (read or write using channel 3)
     
    129132    out     MODE_REGISTER_DMA8_out, al
    130133
    131     ; Set address to DMA controller
    132     out     CLEAR_FLIPFLOP_DMA8_out, al     ; Reset flip-flop to low byte
     134    ; Send start address to DMA controller
    133135    mov     ax, es
    134136    out     PAGE_DMA8_CH_3, al
    135137    mov     ax, di
     138    out     CLEAR_FLIPFLOP_DMA8_out, al                         ; Reset flip-flop to low byte
    136139    out     BASE_AND_CURRENT_ADDRESS_REGISTER_DMA8_CH3_out, al  ; Low byte
    137140    mov     al, ah
     
    140143    ; Set number of bytes to transfer (DMA controller must be programmed number of bytes - 1)
    141144    mov     ax, cx
    142     dec     ax                              ; DMA controller is programmed for one byte less
     145    dec     ax                                                  ; DMA controller is programmed for one byte less
    143146    out     BASE_AND_CURRENT_COUNT_REGISTER_DMA8_CH3_out, al    ; Low byte
    144147    mov     al, ah
     
    147150    ; Enable DMA Channel 3
    148151    mov     al, CLEAR_CH3_MASK_BIT
    149     out     MASK_REGISTER_DMA8_out, al      ; Enable DMA Channel 3
    150     sti                                     ; Enable interrupts
     152    out     MASK_REGISTER_DMA8_out, al                          ; Enable DMA Channel 3
     153    sti                                                         ; Enable interrupts
    151154
     155    ; XT-CF transfers 16 bytes at a time. We need to manually start transfer for every block by writing (anything)
     156    ; to the XT-CFv3 Control Register, which raises DRQ thereby passing system control to the 8237 DMA controller.
     157    ; The XT-CFv3 logic releases DRQ after 16 transfers, thereby handing control back to the CPU and allowing any other IRQs or
     158    ; DRQs to be serviced (which, on the PC and PC/XT will include DRAM refresh via DMA channel 0).  The 16-byte transfers can
     159    ; also be interrupted by the DMA controller raising TC (i.e. when done).  Each transfer cannot be otherwise interrupted
     160    ; and is therefore atomic (and hence fast).
    152161
    153 %if 0 ; Slow DMA code
    154     ; XT-CF transfers 16 bytes at a time. We need to manually
    155     ; start transfer for every block.
    156 ALIGN JUMP_ALIGN
    157 .TransferNextBlock:
    158     mov     al, RAISE_DRQ_AND_CLEAR_XTCF_XFER_COUNTER
    159     cli                                 ; We want no ISR to read DMA Status Register before we do
    160     out     dx, al                      ; Transfer up to 16 bytes to/from XT-CF card
    161     ; * Here XT-CF sets CPU to wait states during transfer *
    162     in      al, STATUS_REGISTER_DMA8_in
    163     sti
    164     test    al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT
    165     jz      SHORT .TransferNextBlock    ; All bytes transferred?
     162%if 0   ; Slow DMA code - works by checking 8237 status register after each 16-byte transfer, until it reports TC has been raised.
     163;ALIGN JUMP_ALIGN
     164;.TransferNextBlock:
     165;   cli                                 ; We want no ISR to read DMA Status Register before we do
     166;   out     dx, al                      ; Transfer up to 16 bytes to/from XT-CF card
     167;   in      al, STATUS_REGISTER_DMA8_in
     168;   sti
     169;   test    al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT
     170;   jz      SHORT .TransferNextBlock    ; All bytes transferred?
    166171%endif ; Slow DMA code
    167172
    168 
    169 %if 1 ; Fast DMA code
    170     push    cx
    171     add     cx, BYTE 15                 ; Include any partial DMA block (since we had to divide transfer to 64k physical pages)
    172     eSHR_IM cx, 4                       ; Drive Block size to 16 Byte DMA Block Size
    173 
    174 .JustOneMoreDmaBlock:
    175     mov     al, RAISE_DRQ_AND_CLEAR_XTCF_XFER_COUNTER
    176 ALIGN JUMP_ALIGN
     173%if 1   ; Fast DMA code - perform computed number of transfers, then check DMA status register to be sure
     174    push    cx                          ; need byte count to update pointer at the end
     175    add     cx, BYTE 15                 ; We'll divide transfers in 16-byte atomic transfers,
     176    eSHR_IM cx, 4                       ; so include any partial block, which will be terminated
     177ALIGN JUMP_ALIGN                        ; by the DMA controller raising T/C
    177178.TransferNextDmaBlock:
    178     out     dx, al                      ; Transfer 16 bytes to/from XT-CF card
    179     loop    .TransferNextDmaBlock
    180 
     179    out     dx, al                      ; Transfer up to 16 bytes to/from XT-CF card
     180    loop    .TransferNextDmaBlock       ; dec CX and loop if CX > 0, also adds required wait-state
    181181    inc     cx                          ; set up CX, in case we need to do an extra iteration
    182     in      al, STATUS_REGISTER_DMA8_in
    183     test    al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT
    184     jz      SHORT .JustOneMoreDmaBlock          ; it wasn't set so get more bytes
    185     pop     cx
     182    in      al, STATUS_REGISTER_DMA8_in ; check 8237 DMA controller status flags...
     183    test    al, FLG_CH3_HAS_REACHED_TERMINAL_COUNT  ; ... for channel 3 terminal count
     184    jz      SHORT .TransferNextDmaBlock ; If not set, get more bytes
     185    pop     cx                          ; get back requested bytes
    186186%endif ; Fast DMA code
    187187
     188    ; Update physical address in ES:DI - since IO might need several calls through this function either from here
     189    ; if crossing a physical page boundary, and from IdeTransfer.asm if requested sectors was > PIOVARS.wSectorsInBlock
     190    mov     ax, es                      ; copy physical page address to ax
     191    add     di, cx                      ; add requested bytes to di
     192    adc     al, 0                       ; and increment physical page address, if required
     193    mov     es, ax                      ; and save it back in es
    188194
    189     ; Restore XT-CF to normal operation
    190     mov     al, XTCF_DMA_MODE
    191     out     dx, al
    192 
    193     ; Increment physical address in ES:DI
    194     mov     ax, es
    195     add     di, cx
    196     adc     al, ah
    197     mov     es, ax
    198195    ret
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm

    r536 r545  
    5252;--------------------------------------------------------------------
    5353IdeIO_InputToALfromIdeRegisterInDL:
    54     xor     dh, dh  ; IDE Register index now in DX
    55     mov     bx, dx  ; and BX
     54    xor     dh, dh  ; IDE Register index now in DX...
    5655    mov     al, [di+DPT_ATA.bDevice]
    5756    cmp     al, DEVICE_8BIT_XTIDE_REV2
    5857    jb      SHORT .InputToALfromRegisterInDX    ; Standard IDE controllers and XTIDE rev 1
     58    mov     bx, dx  ; ...and BX for A0<->A3 swap and for memory mapped I/O
    5959
    6060%ifdef MODULE_8BIT_IDE_ADVANCED
     
    109109    ; At this point remaining controllers (JRIDE, XTCF and ADP50L) all have a control
    110110    ; block offset of 8 or (8<<1) so we add 8 here and do the SHL 1 later if needed.
    111     add     dx, 8
     111    add     dx, BYTE 8
    112112    cmp     bl, DEVICE_8BIT_JRIDE_ISA
    113113    jb      SHORT IdeIO_OutputALtoIdeRegisterInDL.ShlRegisterIndexInDXandOutputAL   ; All XT-CF modes
     
    127127    ; a small trick since we only access Device Control Register at
    128128    ; offset 6h: Always clear A3 and set A0.
    129     mov     bh, dh  ; Zero BH
     129    call    AccessDPT_GetIdevarsToCSBX
    130130    add     dx, [cs:bx+IDEVARS.wControlBlockPort]
    131131    xor     dl, 1001b                       ; Clear A3, Set A0
     
    134134
    135135.OutputALtoControlBlockRegisterInDX:
    136     call    AccessDPT_GetIdevarsToCSBX      ; *FIXME* Why is this call here but not in the above block?
     136    call    AccessDPT_GetIdevarsToCSBX
    137137    add     dx, [cs:bx+IDEVARS.wControlBlockPort]
    138138    out     dx, al
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm

    r526 r545  
    2020;
    2121
     22; Modified by JJP for XT-CFv3 support, Mar-13
     23
    2224; Section containing code
    2325SECTION .text
     26
     27
     28; --------------------------------------------------------------------------------------------------
     29;
     30; READ routines follow
     31;
     32; --------------------------------------------------------------------------------------------------
     33
    2434
    2535%ifdef MODULE_8BIT_IDE
     
    5060
    5161;--------------------------------------------------------------------
    52 ; IdePioBlock_ReadFromXtideRev2     or rev 1 with swapped A0 and A3 (chuck-mod)
    53 ;   Parameters:
    54 ;       CX:     Block size in 512 byte sectors
    55 ;       DX:     IDE Data port address
     62; IdePioBlock_ReadFrom8bitDataPort
     63;
     64; 8-bit PIO from a single data port.
     65;
     66;   Parameters:
     67;       CX: Block size in 512 byte sectors
     68;       DX: IDE Data port address
    5669;       ES:DI:  Normalized ptr to buffer to receive data
    5770;   Returns:
     
    6073;       AX, BX, CX
    6174;--------------------------------------------------------------------
    62 %ifndef USE_186         ; 8086/8088 compatible WORD read
    63 
    64 ALIGN JUMP_ALIGN
    65 IdePioBlock_ReadFromXtideRev2:
     75ALIGN JUMP_ALIGN
     76IdePioBlock_ReadFrom8bitDataPort:
     77%ifdef USE_186
     78    shl     cx, 9       ; Sectors to BYTEs
     79    rep insb
     80    ret
     81%else ; If 8088/8086
     82    UNROLL_SECTORS_IN_CX_TO_OWORDS
     83ALIGN JUMP_ALIGN
     84.ReadNextOword:
     85    %rep 16 ; BYTEs
     86        in      al, dx  ; Read BYTE
     87        stosb           ; Store BYTE to [ES:DI]
     88    %endrep
     89    loop    .ReadNextOword
     90    ret
     91%endif
     92
     93%endif  ; MODULE_8BIT_IDE
     94
     95
     96;--------------------------------------------------------------------
     97; IdePioBlock_ReadFrom16bitDataPort
     98;
     99; 16-bit PIO from a single data port.
     100;
     101;   Parameters:
     102;       CX: Block size in 512 byte sectors
     103;       DX: IDE Data port address
     104;       ES:DI:  Normalized ptr to buffer to receive data
     105;   Returns:
     106;       Nothing
     107;   Corrupts registers:
     108;       AX, BX, CX
     109;--------------------------------------------------------------------
     110ALIGN JUMP_ALIGN
     111IdePioBlock_ReadFrom16bitDataPort:
     112%ifdef USE_186
     113    xchg        cl, ch  ; Sectors to WORDs
     114    rep insw
     115    ret
     116
     117%else ; If 8088/8086
    66118    UNROLL_SECTORS_IN_CX_TO_OWORDS
    67119ALIGN JUMP_ALIGN
    68120.ReadNextOword:
    69121    %rep 8  ; WORDs
    70         in      ax, dx      ; Read WORD
    71         stosw               ; Store WORD to [ES:DI]
    72     %endrep
    73         loop    .ReadNextOword
    74         ret
    75 
     122        in      ax, dx  ; Read BYTE
     123        stosw           ; Store BYTE to [ES:DI]
     124    %endrep
     125    loop    .ReadNextOword
     126    ret
    76127%endif
    77128
    78 
    79 ;--------------------------------------------------------------------
    80 ; IdePioBlock_ReadFrom8bitDataPort      CF-XT when using 8-bit PIO
    81 ;   Parameters:
    82 ;       CX:     Block size in 512 byte sectors
    83 ;       DX:     IDE Data port address
    84 ;       ES:DI:  Normalized ptr to buffer to receive data
    85 ;   Returns:
    86 ;       Nothing
    87 ;   Corrupts registers:
    88 ;       AX, BX, CX
    89 ;--------------------------------------------------------------------
    90 ALIGN JUMP_ALIGN
    91 IdePioBlock_ReadFrom8bitDataPort:
    92 %ifdef USE_186
    93     shl     cx, 9       ; Sectors to BYTEs
    94     rep insb
    95     ret
    96 
    97 %else ; If 8088/8086
    98     UNROLL_SECTORS_IN_CX_TO_OWORDS
    99 ALIGN JUMP_ALIGN
    100 .ReadNextOword:
    101     %rep 16 ; BYTEs
    102         in      al, dx      ; Read BYTE
    103         stosb               ; Store BYTE to [ES:DI]
    104     %endrep
    105     loop    .ReadNextOword
    106     ret
    107 %endif
    108 
    109 
    110 ;--------------------------------------------------------------------
    111 ; IdePioBlock_WriteToXtideRev1
    112 ;   Parameters:
    113 ;       CX:     Block size in 512-byte sectors
    114 ;       DX:     IDE Data port address
    115 ;       ES:SI:  Normalized ptr to buffer containing data
    116 ;   Returns:
    117 ;       Nothing
    118 ;   Corrupts registers:
    119 ;       AX, BX, CX, DX
    120 ;--------------------------------------------------------------------
    121 ALIGN JUMP_ALIGN
    122 IdePioBlock_WriteToXtideRev1:
    123     push    ds
    124     UNROLL_SECTORS_IN_CX_TO_QWORDS
    125     mov     bl, 8       ; Bit mask for toggling data low/high reg
    126     push    es          ; Copy ES...
    127     pop     ds          ; ...to DS
    128 ALIGN JUMP_ALIGN
    129 .OutswLoop:
    130     %rep 4  ; WORDs
    131         XTIDE_OUTSW
    132     %endrep
    133     loop    .OutswLoop
    134     pop     ds
    135     ret
    136 
    137 
    138 ;--------------------------------------------------------------------
    139 ; IdePioBlock_WriteToXtideRev2  or rev 1 with swapped A0 and A3 (chuck-mod)
    140 ;   Parameters:
    141 ;       CX:     Block size in 512-byte sectors
    142 ;       DX:     IDE Data port address
    143 ;       ES:SI:  Normalized ptr to buffer containing data
    144 ;   Returns:
    145 ;       Nothing
    146 ;   Corrupts registers:
    147 ;       AX, BX, CX, DX
    148 ;--------------------------------------------------------------------
    149 ALIGN JUMP_ALIGN
    150 IdePioBlock_WriteToXtideRev2:
    151     UNROLL_SECTORS_IN_CX_TO_QWORDS
    152     push    ds
    153     push    es          ; Copy ES...
    154     pop     ds          ; ...to DS
    155 ALIGN JUMP_ALIGN
    156 .WriteNextQword:
    157     %rep 4  ; WORDs
    158         XTIDE_MOD_OUTSW
    159     %endrep
    160     loop    .WriteNextQword
    161     pop     ds
    162     ret
    163 
    164 
    165 ;--------------------------------------------------------------------
    166 ; IdePioBlock_WriteTo8bitDataPort       XT-CF when using 8-bit PIO
    167 ;   Parameters:
    168 ;       CX:     Block size in 512-byte sectors
    169 ;       DX:     IDE Data port address
    170 ;       ES:SI:  Normalized ptr to buffer containing data
    171 ;   Returns:
    172 ;       Nothing
    173 ;   Corrupts registers:
    174 ;       AX, BX, CX, DX
    175 ;--------------------------------------------------------------------
    176 ALIGN JUMP_ALIGN
    177 IdePioBlock_WriteTo8bitDataPort:
    178 
    179 %ifdef USE_186
    180     shl     cx, 9       ; Sectors to BYTEs
    181     es                  ; Source is ES segment
    182     rep outsb
    183     ret
    184 
    185 %else ; If 8088/8086
    186     UNROLL_SECTORS_IN_CX_TO_DWORDS
    187     push    ds
    188     push    es
    189     pop     ds
    190 ALIGN JUMP_ALIGN
    191 .WriteNextDword:
    192     %rep 4  ; BYTEs
    193         lodsb               ; Load BYTE from [DS:SI]
    194         out     dx, al      ; Write BYTE
    195     %endrep
    196     loop    .WriteNextDword
    197     pop     ds
    198     ret
    199 %endif
    200 
    201 %endif ; MODULE_8BIT_IDE
    202 
    203 
    204 ;--------------------------------------------------------------------
    205 ; IdePioBlock_ReadFromXtideRev2         (when 80186/80188 instructions are available)
    206 ; IdePioBlock_ReadFrom16bitDataPort     Normal 16-bit IDE
    207 ; IdePioBlock_ReadFrom32bitDataPort     VLB/PCI 32-bit IDE
    208 ;   Parameters:
    209 ;       CX:     Block size in 512 byte sectors
    210 ;       DX:     IDE Data port address
    211 ;       ES:DI:  Normalized ptr to buffer to receive data
    212 ;   Returns:
    213 ;       Nothing
    214 ;   Corrupts registers:
    215 ;       AX, BX, CX
    216 ;--------------------------------------------------------------------
    217 ALIGN JUMP_ALIGN
    218 %ifdef USE_186
    219 %ifdef MODULE_8BIT_IDE
    220 IdePioBlock_ReadFromXtideRev2:
    221 %endif
    222 %endif
    223 IdePioBlock_ReadFrom16bitDataPort:
    224     xchg    cl, ch      ; Sectors to WORDs
    225     rep
    226     db      6Dh         ; INSW
    227     ret
    228129
    229130;--------------------------------------------------------------------
     
    239140
    240141
    241 ;--------------------------------------------------------------------
    242 ; IdePioBlock_WriteTo16bitDataPort      Normal 16-bit IDE
     142
     143; --------------------------------------------------------------------------------------------------
     144;
     145; WRITE routines follow
     146;
     147; --------------------------------------------------------------------------------------------------
     148
     149%ifdef MODULE_8BIT_IDE
     150
     151;--------------------------------------------------------------------
     152; IdePioBlock_WriteToXtideRev1
     153;   Parameters:
     154;       CX: Block size in 512-byte sectors
     155;       DX: IDE Data port address
     156;       ES:SI:  Normalized ptr to buffer containing data
     157;   Returns:
     158;       Nothing
     159;   Corrupts registers:
     160;       AX, BX, CX, DX
     161;--------------------------------------------------------------------
     162ALIGN JUMP_ALIGN
     163IdePioBlock_WriteToXtideRev1:
     164    push    ds
     165    UNROLL_SECTORS_IN_CX_TO_QWORDS
     166    mov     bl, 8       ; Bit mask for toggling data low/high reg
     167    push    es          ; Copy ES...
     168    pop     ds          ; ...to DS
     169ALIGN JUMP_ALIGN
     170.OutswLoop:
     171    %rep 4  ; WORDs
     172        XTIDE_OUTSW
     173    %endrep
     174    loop    .OutswLoop
     175    pop     ds
     176    ret
     177
     178
     179;--------------------------------------------------------------------
     180; IdePioBlock_WriteToXtideRev2  or rev 1 with swapped A0 and A3 (chuck-mod)
     181;   Parameters:
     182;       CX: Block size in 512-byte sectors
     183;       DX: IDE Data port address
     184;       ES:SI:  Normalized ptr to buffer containing data
     185;   Returns:
     186;       Nothing
     187;   Corrupts registers:
     188;       AX, BX, CX, DX
     189;--------------------------------------------------------------------
     190ALIGN JUMP_ALIGN
     191IdePioBlock_WriteToXtideRev2:
     192    UNROLL_SECTORS_IN_CX_TO_QWORDS
     193    push        ds
     194    push        es      ; Copy ES...
     195    pop         ds      ; ...to DS
     196ALIGN JUMP_ALIGN
     197.WriteNextQword:
     198    %rep 4  ; WORDs
     199        XTIDE_MOD_OUTSW ; special macro
     200    %endrep
     201    loop    .WriteNextQword
     202    pop     ds
     203    ret
     204
     205
     206;--------------------------------------------------------------------
     207; IdePioBlock_WriteTo8bitDataPort
     208;   Parameters:
     209;       CX: Block size in 512-byte sectors
     210;       DX: IDE Data port address
     211;       ES:SI:  Normalized ptr to buffer containing data
     212;   Returns:
     213;       Nothing
     214;   Corrupts registers:
     215;       AX, BX, CX, DX
     216;--------------------------------------------------------------------
     217ALIGN JUMP_ALIGN
     218IdePioBlock_WriteTo8bitDataPort:
     219%ifdef USE_186
     220    shl     cx, 9       ; Sectors to BYTEs
     221    es                  ; Source is ES segment
     222    rep outsb
     223    ret
     224
     225%else ; If 8088/8086
     226    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
     232ALIGN JUMP_ALIGN
     233.WriteNextQword:
     234    %rep 8  ; BYTEs
     235        lodsb           ; Load BYTE from [DS:SI]
     236        out dx, al      ; Write BYTE
     237    %endrep
     238    loop    .WriteNextQword
     239    pop     ds
     240    ret
     241%endif
     242
     243%endif ; MODULE_8BIT_IDE
     244
     245
     246;--------------------------------------------------------------------
     247; IdePioBlock_WriteTo16bitDataPort      Normal 16-bit IDE, XT-CFv3 in BIU Mode
    243248; IdePioBlock_WriteTo32bitDataPort      VLB/PCI 32-bit IDE
    244249;   Parameters:
    245 ;       CX:     Block size in 512-byte sectors
    246 ;       DX:     IDE Data port address
     250;       CX: Block size in 512-byte sectors
     251;       DX: IDE Data port address
    247252;       ES:SI:  Normalized ptr to buffer containing data
    248253;   Returns:
     
    253258ALIGN JUMP_ALIGN
    254259IdePioBlock_WriteTo16bitDataPort:
     260%ifdef USE_186
    255261    xchg    cl, ch      ; Sectors to WORDs
    256262    es                  ; Source is ES segment
    257     rep
    258     db      6Fh         ; OUTSW
    259     ret
     263    rep outsw
     264    ret
     265
     266%else ; If 8088/8086
     267    UNROLL_SECTORS_IN_CX_TO_QWORDS
     268    push    ds
     269    ;mov    ax, es
     270    ;mov    ds, ax      ; move es to ds via ax (does this run faster on 8088?)
     271    push    es
     272    pop     ds
     273ALIGN JUMP_ALIGN
     274.WriteNextQword:
     275    %rep 4  ; WORDs
     276        lodsw           ; Load BYTE from [DS:SI]
     277        out dx, ax      ; Write BYTE
     278    %endrep
     279    loop    .WriteNextQword
     280    pop     ds
     281    ret
     282%endif  ; if/else USE_186
    260283
    261284;--------------------------------------------------------------------
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r539 r545  
    346346        dw      IdePioBlock_ReadFrom8bitDataPort    ; 2, DEVICE_8BIT_ATA
    347347        dw      IdePioBlock_ReadFromXtideRev1       ; 3, DEVICE_8BIT_XTIDE_REV1
    348         dw      IdePioBlock_ReadFromXtideRev2       ; 4, DEVICE_8BIT_XTIDE_REV2
     348        dw      IdePioBlock_ReadFrom16bitDataPort   ; 4, DEVICE_8BIT_XTIDE_REV2
     349        dw      IdePioBlock_ReadFrom8bitDataPort    ; 5, DEVICE_8BIT_XTCF_PIO8
     350        dw      IdePioBlock_ReadFrom16bitDataPort   ; 6, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
    349351%ifdef MODULE_8BIT_IDE_ADVANCED
    350         dw      IdePioBlock_ReadFrom8bitDataPort    ; 5, DEVICE_8BIT_XTCF_PIO8
    351         dw      IdeDmaBlock_ReadFromXTCF            ; 6, DEVICE_8BIT_XTCF_DMA
    352 %endif
    353 %endif
     352        dw      IdeDmaBlock_ReadFromXTCF            ; 7, DEVICE_8BIT_XTCF_DMA
     353%endif ; MODULE_8BIT_IDE_ADVANCED
     354%endif ; MODULE_8BIT_IDE
    354355
    355356
     
    361362        dw      IdePioBlock_WriteToXtideRev1        ; 3, DEVICE_8BIT_XTIDE_REV1
    362363        dw      IdePioBlock_WriteToXtideRev2        ; 4, DEVICE_8BIT_XTIDE_REV2
     364        dw      IdePioBlock_WriteTo8bitDataPort     ; 5, DEVICE_8BIT_XTCF_PIO8
     365        dw      IdePioBlock_WriteTo16bitDataPort    ; 6, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
    363366%ifdef MODULE_8BIT_IDE_ADVANCED
    364         dw      IdePioBlock_WriteTo8bitDataPort     ; 5, DEVICE_8BIT_XTCF_PIO8
    365         dw      IdeDmaBlock_WriteToXTCF             ; 6, DEVICE_8BIT_XTCF_DMA
    366 %endif
    367 %endif
     367        dw      IdeDmaBlock_WriteToXTCF             ; 7, DEVICE_8BIT_XTCF_DMA
     368%endif ; MODULE_8BIT_IDE_ADVANCED
     369%endif ; MODULE_8BIT_IDE
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm

    r538 r545  
    6767
    6868    ; Get far pointer to Sector Access Window
    69     mov     dx, [di+DPT.wBasePort]
    7069    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_JRIDE_ISA
    71     jb      SHORT .GetSectorAccessWindowForXTCF
    72 
    73     ; Get Sector Access Window for JR-IDE/ISA and ADP50L
    74     mov     ds, dx      ; Segment for JR-IDE/ISA and ADP50L
    75     mov     di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
    76     je      SHORT .SectorAccessWindowLoadedToDSDI
     70    mov     ds, [di+DPT.wBasePort]  ; Segment for JR-IDE/ISA and ADP50L
    7771    mov     di, ADP50L_SECTOR_ACCESS_WINDOW_OFFSET
    78     jmp     SHORT .SectorAccessWindowLoadedToDSDI
    79 
    80 .GetSectorAccessWindowForXTCF:
    81     xor     di, di
    82     add     dl, XTCF_CONTROL_REGISTER
    83     in      al, dx                  ; Read high byte for Sector Access Window segment
    84     xchg    ah, al
    85     mov     ds, ax
     72    eCMOVE  di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
    8673
    8774    ; Are we reading or writing?
Note: See TracChangeset for help on using the changeset viewer.