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).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;--------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.