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/JrIdeTransfer.asm

    r445 r473  
    2828endstruc
    2929
     30SECTOR_ACCESS_WINDOW_SIZE   EQU     512 ; 512 bytes
     31
    3032
    3133; Section containing code
     
    3739;       AL:     IDE command that was used to start the transfer
    3840;               (all PIO read and write commands including Identify Device)
    39 ;       ES:SI:  Ptr to normalized data buffer
     41;       ES:SI:  Ptr to normalized data buffer (SI 0...15)
    4042;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    4143;       SS:BP:  Ptr to IDEPACK
     
    4951ALIGN JUMP_ALIGN
    5052JrIdeTransfer_StartWithCommandInAL:
    51     push    cs  ; We push CS here (segment of SAW) and later pop it to DS (reads) or ES (writes)
    52 
    53     ; Initialize PIOVARS
    54     xor     cx, cx
    55     mov     [bp+MEMPIOVARS.bSectorsDone], cl
    56     mov     cl, [bp+IDEPACK.bSectorCount]
    57     mov     [bp+MEMPIOVARS.bSectorsLeft], cl
    58     mov     cl, [di+DPT_ATA.bBlockSize]
    59     mov     [bp+MEMPIOVARS.wSectorsInBlock], cx
     53    ; Initialize MEMPIOVARS
     54    xchg    cx, ax          ; IDE command to CL
     55    xor     ax, ax
     56    mov     [bp+MEMPIOVARS.bSectorsDone], al
     57    mov     al, [bp+IDEPACK.bSectorCount]
     58    mov     [bp+MEMPIOVARS.bSectorsLeft], al
     59    mov     al, [di+DPT_ATA.bBlockSize]
     60    mov     [bp+MEMPIOVARS.wSectorsInBlock], ax
    6061    mov     [bp+MEMPIOVARS.fpDPT], di
    6162    mov     [bp+MEMPIOVARS.fpDPT+2], ds
    6263
     64    ; Get far pointer to Sector Access Window
     65    mov     dx, [di+DPT.wBasePort]
     66    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_JRIDE_ISA
     67    jne     SHORT .GetSectorAccessWindowForXTCF
     68
     69    ; Get Sector Access Window for JR-IDE/ISA
     70    mov     di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
     71    mov     ds, dx      ; Segment for JR-IDE/ISA
     72    jmp     SHORT .SectorAccessWindowLoadedToDSDI
     73
     74.GetSectorAccessWindowForXTCF:
     75    xor     di, di
     76    add     dl, XTCF_CONTROL_REGISTER
     77    in      al, dx                  ; Read high byte for Sector Access Window segment
     78    xchg    ah, al
     79    mov     ds, ax
     80
    6381    ; Are we reading or writing?
    64     test    al, 16  ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands
     82.SectorAccessWindowLoadedToDSDI:
     83    test    cl, 16  ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands
    6584    jnz     SHORT WriteToSectorAccessWindow
    66     cmp     al, COMMAND_WRITE_MULTIPLE
     85    cmp     cl, COMMAND_WRITE_MULTIPLE
    6786    je      SHORT WriteToSectorAccessWindow
    6887    ; Fall to ReadFromSectorAccessWindow
     
    7190; ReadFromSectorAccessWindow
    7291;   Parameters:
    73 ;       Stack:  Segment part of ptr to Sector Access Window
     92;       DS:DI:  Ptr to Sector Access Window
    7493;       ES:SI:  Normalized ptr to buffer to receive data
    7594;       SS:BP:  Ptr to MEMPIOVARS
     
    84103;--------------------------------------------------------------------
    85104ReadFromSectorAccessWindow:
    86     pop     ds      ; CS -> DS
    87     mov     di, si  ; ES:DI = destination
    88     mov     si, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET   ; DS:SI = source
    89 
     105    xchg    si, di  ; DS:SI = source, ES:DI = Destination
    90106    call    WaitUntilReadyToTransferNextBlock
    91107    jc      SHORT ReturnWithMemoryIOtransferErrorInAH
     
    140156; WriteToSectorAccessWindow
    141157;   Parameters:
    142 ;       Stack:  Segment part of ptr to Sector Access Window
     158;       DS:DI:  Ptr to Sector Access Window
    143159;       ES:SI:  Normalized ptr to buffer containing data
    144160;       SS:BP:  Ptr to MEMPIOVARS
     
    155171WriteToSectorAccessWindow:
    156172    push    es
    157     pop     ds
    158     pop     es  ; CS -> ES
    159     mov     di, JRIDE_SECTOR_ACCESS_WINDOW_OFFSET
     173    push    ds
     174    pop     es      ; ES:DI = Sector Access Window (destination)
     175    pop     ds      ; DS:SI = Ptr to source buffer
    160176
    161177    ; Always poll when writing first block (IRQs are generated for following blocks)
     
    205221ALIGN JUMP_ALIGN
    206222.WriteBlock:
    207     mov     ch, JRIDE_SECTOR_ACCESS_WINDOW_SIZE >> 9
     223    mov     ch, SECTOR_ACCESS_WINDOW_SIZE >> 9
    208224    rep movsw
    209225    mov     di, bx  ; Reset for next sector
     
    232248ALIGN JUMP_ALIGN
    233249.ReadBlock:
    234     mov     ch, JRIDE_SECTOR_ACCESS_WINDOW_SIZE >> 9
     250    mov     ch, SECTOR_ACCESS_WINDOW_SIZE >> 9
    235251    rep movsw
    236252    mov     si, bx  ; Reset for next sector
     
    261277
    262278
    263 %if JRIDE_SECTOR_ACCESS_WINDOW_SIZE <> 512
    264     %error "JRIDE_SECTOR_ACCESS_WINDOW_SIZE is no longer equal to 512. JrIdeTransfer.asm needs changes."
     279%if SECTOR_ACCESS_WINDOW_SIZE <> 512
     280    %error "SECTOR_ACCESS_WINDOW_SIZE is no longer equal to 512. JrIdeTransfer.asm needs changes."
    265281%endif
Note: See TracChangeset for help on using the changeset viewer.