Ignore:
Timestamp:
Oct 10, 2012, 6:22:23 PM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Large changes to prepare full XT-CF support (DMA not yet implemented and memory mapped transfers are not working).
File:
1 edited

Legend:

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

    r445 r473  
    206206ALIGN JUMP_ALIGN
    207207InitializePiovarsInSSBPwithSectorCountInAH:
    208     ; Store sizes
     208    ; Store sizes and Data Port
    209209    mov     [bp+PIOVARS.bSectorsLeft], ah
     210    mov     ax, [di+DPT.wBasePort]
     211    mov     [bp+PIOVARS.wDataPort], ax
    210212    eMOVZX  ax, [di+DPT_ATA.bBlockSize]
    211213    mov     [bp+PIOVARS.wSectorsInBlock], ax
     
    214216    ; Get transfer function based on bus type
    215217    xchg    ax, bx                              ; Lookup table offset to AX
    216     mov     bl, [di+DPT.bIdevarsOffset]         ; CS:BX now points to IDEVARS
    217     mov     dx, [cs:bx+IDEVARS.wPort]           ; Load IDE Data port address
    218218    mov     bl, [di+DPT_ATA.bDevice]
    219219    add     bx, ax
    220 
    221     mov     [bp+PIOVARS.wDataPort], dx
    222220    mov     ax, [cs:bx]                         ; Load offset to transfer function
    223221    mov     [bp+PIOVARS.fnXfer], ax
     
    225223
    226224
    227 ;--------------------------------------------------------------------
    228 ; ReadBlockFromXtideRev1        XTIDE rev 1
    229 ; ReadBlockFromXtideRev2        XTIDE rev 2 or rev 1 with swapped A0 and A3 (chuck-mod)
    230 ; ReadBlockFrom8bitDataPort     CF-XT when using 8-bit PIO
    231 ; ReadBlockFrom16bitDataPort    Normal 16-bit IDE
    232 ; ReadBlockFrom32bitDataPort    VLB/PCI 32-bit IDE
    233 ;   Parameters:
    234 ;       CX:     Block size in 512 byte sectors
    235 ;       DX:     IDE Data port address
    236 ;       ES:DI:  Normalized ptr to buffer to receive data
    237 ;   Returns:
    238 ;       Nothing
    239 ;   Corrupts registers:
    240 ;       AX, BX, CX
    241 ;--------------------------------------------------------------------
    242 %ifdef MODULE_8BIT_IDE
    243 
    244     ALIGN JUMP_ALIGN
    245     ReadBlockFromXtideRev1:
    246         UNROLL_SECTORS_IN_CX_TO_OWORDS
    247         mov     bl, 8       ; Bit mask for toggling data low/high reg
    248     ALIGN JUMP_ALIGN
    249     .InswLoop:
    250     %rep 8  ; WORDs
    251         XTIDE_INSW
    252     %endrep
    253         loop    .InswLoop
    254         ret
    255 
    256     ;--------------------------------------------------------------------
    257     %ifndef USE_186         ; 8086/8088 compatible WORD read
    258         ALIGN JUMP_ALIGN
    259         ReadBlockFromXtideRev2:
    260             UNROLL_SECTORS_IN_CX_TO_OWORDS
    261         ALIGN JUMP_ALIGN
    262         .ReadNextOword:
    263         %rep 8  ; WORDs
    264             in      ax, dx      ; Read WORD
    265             stosw               ; Store WORD to [ES:DI]
    266         %endrep
    267             loop    .ReadNextOword
    268             ret
    269     %endif
    270 
    271     ;--------------------------------------------------------------------
    272     %ifdef USE_186
    273         ALIGN JUMP_ALIGN
    274         ReadBlockFrom8bitDataPort:
    275             shl     cx, 9       ; Sectors to BYTEs
    276             rep insb
    277             ret
    278 
    279     %else ; If 8088/8086
    280         ALIGN JUMP_ALIGN
    281         ReadBlockFrom8bitDataPort:
    282             UNROLL_SECTORS_IN_CX_TO_OWORDS
    283         ALIGN JUMP_ALIGN
    284         .ReadNextOword:
    285         %rep 16 ; BYTEs
    286             in      al, dx      ; Read BYTE
    287             stosb               ; Store BYTE to [ES:DI]
    288         %endrep
    289             loop    .ReadNextOword
    290             ret
    291     %endif
    292 %endif  ; MODULE_8BIT_IDE
    293 
    294 ;--------------------------------------------------------------------
    295 %ifdef USE_186
    296     ALIGN JUMP_ALIGN
    297     ReadBlockFrom16bitDataPort:
    298         xchg    cl, ch      ; Sectors to WORDs
    299         rep insw
    300         ret
    301 %endif
    302 
    303 ;--------------------------------------------------------------------
    304 %ifdef USE_AT
    305     ALIGN JUMP_ALIGN
    306     ReadBlockFrom32bitDataPort:
    307         shl     cx, 7       ; Sectors to DWORDs
    308         rep
    309         db      66h         ; Override operand size to 32-bit
    310         db      6Dh         ; INSW/INSD
    311         ret
    312 %endif
    313 
    314 
    315 ;--------------------------------------------------------------------
    316 ; WriteBlockToXtideRev1         XTIDE rev 1
    317 ; WriteBlockToXtideRev2         XTIDE rev 2 or rev 1 with swapped A0 and A3 (chuck-mod)
    318 ; WriteBlockTo8bitDataPort      XT-CF when using 8-bit PIO
    319 ; WriteBlockTo16bitDataPort     Normal 16-bit IDE
    320 ; WriteBlockTo32bitDataPort     VLB/PCI 32-bit IDE
    321 ;   Parameters:
    322 ;       CX:     Block size in 512-byte sectors
    323 ;       DX:     IDE Data port address
    324 ;       ES:SI:  Normalized ptr to buffer containing data
    325 ;   Returns:
    326 ;       Nothing
    327 ;   Corrupts registers:
    328 ;       AX, BX, CX, DX
    329 ;--------------------------------------------------------------------
    330 %ifdef MODULE_8BIT_IDE
    331 
    332     ALIGN JUMP_ALIGN
    333     WriteBlockToXtideRev1:
    334         push    ds
    335         UNROLL_SECTORS_IN_CX_TO_QWORDS
    336         mov     bl, 8       ; Bit mask for toggling data low/high reg
    337         push    es          ; Copy ES...
    338         pop     ds          ; ...to DS
    339     ALIGN JUMP_ALIGN
    340     .OutswLoop:
    341     %rep 4  ; WORDs
    342         XTIDE_OUTSW
    343     %endrep
    344         loop    .OutswLoop
    345         pop     ds
    346         ret
    347 
    348     ;--------------------------------------------------------------------
    349     ALIGN JUMP_ALIGN
    350     WriteBlockToXtideRev2:
    351         UNROLL_SECTORS_IN_CX_TO_QWORDS
    352         push    ds
    353         push    es          ; Copy ES...
    354         pop     ds          ; ...to DS
    355     ALIGN JUMP_ALIGN
    356     .WriteNextQword:
    357     %rep 4  ; WORDs
    358         XTIDE_MOD_OUTSW
    359     %endrep
    360         loop    .WriteNextQword
    361         pop     ds
    362         ret
    363 
    364     ;--------------------------------------------------------------------
    365     %ifdef USE_186
    366         ALIGN JUMP_ALIGN
    367         WriteBlockTo8bitDataPort:
    368             shl     cx, 9       ; Sectors to BYTEs
    369             es                  ; Source is ES segment
    370             rep outsb
    371             ret
    372 
    373     %else ; If 8088/8086
    374         ALIGN JUMP_ALIGN
    375         WriteBlockTo8bitDataPort:
    376             UNROLL_SECTORS_IN_CX_TO_DWORDS
    377             push    ds
    378             push    es
    379             pop     ds
    380         ALIGN JUMP_ALIGN
    381         .WriteNextDword:
    382         %rep 4  ; BYTEs
    383             lodsb               ; Load BYTE from [DS:SI]
    384             out     dx, al      ; Write BYTE
    385         %endrep
    386             loop    .WriteNextDword
    387             pop     ds
    388             ret
    389     %endif
    390 %endif  ; MODULE_8BIT_IDE
    391 
    392 ;--------------------------------------------------------------------
    393 %ifdef USE_AT
    394 ALIGN JUMP_ALIGN
    395 WriteBlockTo16bitDataPort:
    396     xchg    cl, ch      ; Sectors to WORDs
    397     es                  ; Source is ES segment
    398     rep outsw
    399     ret
    400 
    401 ;--------------------------------------------------------------------
    402 ALIGN JUMP_ALIGN
    403 WriteBlockTo32bitDataPort:
    404     shl     cx, 7       ; Sectors to DWORDs
    405     es                  ; Source is ES segment
    406     rep
    407     db      66h         ; Override operand size to 32-bit
    408     db      6Fh         ; OUTSW/OUTSD
    409     ret
    410 %endif ; USE_AT
    411 
    412 
    413225
    414226; Lookup tables to get transfer function based on bus type
    415227ALIGN WORD_ALIGN
    416228g_rgfnPioRead:
     229%ifdef USE_AT
     230        dw      IdePioBlock_ReadFrom16bitDataPort   ; 0, DEVICE_16BIT_ATA
     231        dw      IdePioBlock_ReadFrom32bitDataPort   ; 1, DEVICE_32BIT_ATA
     232%else
     233        dd      0
     234%endif
    417235%ifdef MODULE_8BIT_IDE
    418         dw      0                           ; 0, DEVICE_8BIT_JRIDE_ISA
    419         dw      ReadBlockFrom8bitDataPort   ; 1, DEVICE_8BIT_XTCF
    420     %ifdef USE_186
    421         dw      ReadBlockFrom16bitDataPort  ; 2, DEVICE_8BIT_XTIDE_REV2
    422     %else
    423         dw      ReadBlockFromXtideRev2      ; 2, DEVICE_8BIT_XTIDE_REV2
     236        dw      IdePioBlock_ReadFromXtideRev1       ; 2, DEVICE_8BIT_XTIDE_REV1
     237    %ifndef USE_AT
     238        g_rgfnPioWrite:
    424239    %endif
    425         dw      ReadBlockFromXtideRev1      ; 3, DEVICE_XTIDE_REV1
    426 
    427 %else
    428         times   COUNT_OF_8BIT_IDE_DEVICES   dw  0
    429 %endif
     240        dw      IdePioBlock_ReadFromXtideRev2       ; 3, DEVICE_8BIT_XTIDE_REV2
     241        dw      IdePioBlock_ReadFrom8bitDataPort    ; 4, DEVICE_8BIT_XTCF_PIO8
     242%endif
     243
    430244%ifdef USE_AT
    431         dw      ReadBlockFrom16bitDataPort  ; 4, DEVICE_16BIT_ATA
    432         dw      ReadBlockFrom32bitDataPort  ; 5, DEVICE_32BIT_ATA
    433 %endif
    434 
    435 
    436245g_rgfnPioWrite:
     246        dw      IdePioBlock_WriteTo16bitDataPort    ; 0, DEVICE_16BIT_ATA
     247        dw      IdePioBlock_WriteTo32bitDataPort    ; 1, DEVICE_32BIT_ATA
     248%endif
    437249%ifdef MODULE_8BIT_IDE
    438         dw      0                           ; 0, DEVICE_8BIT_JRIDE_ISA
    439         dw      WriteBlockTo8bitDataPort    ; 1, DEVICE_8BIT_XTCF
    440         dw      WriteBlockToXtideRev2       ; 2, DEVICE_XTIDE_REV2
    441         dw      WriteBlockToXtideRev1       ; 3, DEVICE_XTIDE_REV1
    442 
    443 %else
    444         times   COUNT_OF_8BIT_IDE_DEVICES   dw  0
    445 %endif
    446 %ifdef USE_AT
    447         dw      WriteBlockTo16bitDataPort   ; 4, DEVICE_16BIT_ATA
    448         dw      WriteBlockTo32bitDataPort   ; 5, DEVICE_32BIT_ATA
    449 %endif
     250        dw      IdePioBlock_WriteToXtideRev1        ; 2, DEVICE_8BIT_XTIDE_REV1
     251        dw      IdePioBlock_WriteToXtideRev2        ; 3, DEVICE_8BIT_XTIDE_REV2
     252        dw      IdePioBlock_WriteTo8bitDataPort     ; 4, DEVICE_8BIT_XTCF_PIO8
     253%endif
Note: See TracChangeset for help on using the changeset viewer.