Changeset 480 in xtideuniversalbios


Ignore:
Timestamp:
Oct 27, 2012, 11:26:11 AM (12 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • XT-CF DMA transfers should now work.
Location:
trunk/XTIDE_Universal_BIOS
Files:
1 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc

    r474 r480  
    9494    FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER    EQU (1<<6)
    9595    FLG_INITERROR_FAILED_TO_SET_XTCF_MODE               EQU (1<<7)
     96    FLG_INITERROR_FAILED_TO_SET_8BIT_MODE               EQU FLG_INITERROR_FAILED_TO_SET_XTCF_MODE
    9697
    9798
  • trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc

    r473 r480  
    139139; IDE Devices are grouped so device numbers cannot be changed without modifying code elsewhere!
    140140;
    141 COUNT_OF_STANDARD_IDE_DEVICES           EQU 2
    142 COUNT_OF_8BIT_IDE_DEVICES               EQU 6
     141COUNT_OF_STANDARD_IDE_DEVICES           EQU 2   ; 16- and 32-bit controllers
     142COUNT_OF_8BIT_IDE_DEVICES               EQU 7
    143143COUNT_OF_ALL_IDE_DEVICES                EQU (COUNT_OF_8BIT_IDE_DEVICES + COUNT_OF_STANDARD_IDE_DEVICES)
    144144; Standard port mapped I/O
    145145DEVICE_16BIT_ATA                        EQU (0<<1)
    146146DEVICE_32BIT_ATA                        EQU (1<<1)
    147 DEVICE_8BIT_XTIDE_REV1                  EQU (COUNT_OF_STANDARD_IDE_DEVICES<<1)
     147DEVICE_8BIT_ATA                         EQU (COUNT_OF_STANDARD_IDE_DEVICES+0<<1)    ; 16- or 32-bit controller in 8-bit mode
     148DEVICE_8BIT_XTIDE_REV1                  EQU (COUNT_OF_STANDARD_IDE_DEVICES+1<<1)
    148149; Address lines A0 and A3 are swapped
    149 DEVICE_8BIT_XTIDE_REV2                  EQU ((COUNT_OF_STANDARD_IDE_DEVICES+1)<<1)  ; Or rev 1 with swapped A0 and A3
     150DEVICE_8BIT_XTIDE_REV2                  EQU ((COUNT_OF_STANDARD_IDE_DEVICES+2)<<1)  ; Or rev 1 with swapped A0 and A3
    150151; IDE Register offsets are SHL 1
    151 DEVICE_8BIT_XTCF_PIO8                   EQU ((COUNT_OF_STANDARD_IDE_DEVICES+2)<<1)  ; XT-CF using 8-bit PIO mode
    152 DEVICE_8BIT_XTCF_DMA                    EQU ((COUNT_OF_STANDARD_IDE_DEVICES+3)<<1)  ; XT-CF using DMA
    153 DEVICE_8BIT_XTCF_MEMMAP                 EQU ((COUNT_OF_STANDARD_IDE_DEVICES+4)<<1)  ; XT-CF using Memory Mapped transfers (not I/O)
     152DEVICE_8BIT_XTCF_PIO8                   EQU ((COUNT_OF_STANDARD_IDE_DEVICES+3)<<1)  ; XT-CF using 8-bit PIO mode
     153DEVICE_8BIT_XTCF_DMA                    EQU ((COUNT_OF_STANDARD_IDE_DEVICES+4)<<1)  ; XT-CF using DMA
     154DEVICE_8BIT_XTCF_MEMMAP                 EQU ((COUNT_OF_STANDARD_IDE_DEVICES+5)<<1)  ; XT-CF using Memory Mapped transfers (not I/O)
    154155; Memory Mapped I/O
    155 DEVICE_8BIT_JRIDE_ISA                   EQU ((COUNT_OF_STANDARD_IDE_DEVICES+5)<<1)  ; JR-IDE/ISA (Memory Mapped I/O)
     156DEVICE_8BIT_JRIDE_ISA                   EQU ((COUNT_OF_STANDARD_IDE_DEVICES+6)<<1)  ; JR-IDE/ISA (Memory Mapped I/O)
    156157; Virtual devices
    157158DEVICE_SERIAL_PORT                      EQU (COUNT_OF_ALL_IDE_DEVICES<<1)
  • trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm

    r473 r480  
    8484;       DX:     Autodetected port (for devices that support autodetection)
    8585;       DS:     Segment to RAMVARS
    86 ;       ES:SI:  Ptr to normalized buffer to receive 512-byte IDE Information
     86;       ES:SI:  Ptr to buffer to receive 512-byte IDE Information
    8787;       CS:BP:  Ptr to IDEVARS
    8888;   Returns:
     
    109109;       BH:     Default system timer ticks for timeout (can be ignored)
    110110;       BL:     IDE Status Register bit to poll after command
    111 ;       ES:SI:  Ptr to normalized buffer (for data transfer commands)
     111;       ES:SI:  Ptr to buffer (for data transfer commands)
    112112;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    113113;       SS:BP:  Ptr to IDEPACK
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm

    r474 r480  
    8888
    8989%ifdef MODULE_8BIT_IDE
    90     ; We set XT-CF to 8-bit PIO mode for Identify Device command.
    91     ; Correct XT-CF mode is later set on AH=09h (after all drives are detected).
    92     call    AccessDPT_IsThisDeviceXTCF
    93     jne     SHORT .SkipXTCFmodeChange
    94 
     90    ; Enable 8-bit PIO mode for 8-bit ATA and XT-CF
     91    push    si
     92    call    AH9h_Enable8bitModeForDevice8bitAta
    9593    xor     al, al                      ; XTCF_8BIT_PIO_MODE
    96     push    si
    97     call    AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
     94    call    AH9h_SetModeFromALtoXTCF
    9895    pop     si
    99     jc      SHORT .FailedToSet8bitMode
    100 .SkipXTCFmodeChange:
    10196%endif ; MODULE_8BIT_IDE
    10297
     
    178173    jne     SHORT .WaitUntilNonTransferCommandCompletes
    179174%ifdef MODULE_8BIT_IDE
    180     cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
    181     je      SHORT .StartDmaTransfer
    182     ja      SHORT JrIdeTransfer_StartWithCommandInAL    ; DEVICE_8BIT_XTCF_MEMMAP or DEVICE_8BIT_JRIDE_ISA
     175    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_MEMMAP
     176    jae     SHORT JrIdeTransfer_StartWithCommandInAL    ; DEVICE_8BIT_XTCF_MEMMAP or DEVICE_8BIT_JRIDE_ISA
     177%endif
    183178    jmp     IdeTransfer_StartWithCommandInAL
    184 .StartDmaTransfer:
    185     jmp     IdeDmaTransfer_StartWithCommandInAL
    186 %else
    187     jmp     IdeTransfer_StartWithCommandInAL
    188 %endif
    189179
    190180.WaitUntilNonTransferCommandCompletes:
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm

    r473 r480  
    215215;       AX, BX, CX
    216216;--------------------------------------------------------------------
    217 %ifdef USE_186  ; Also used by XTIDE rev 2 when 80186/80188 commands allowed
    218 ALIGN JUMP_ALIGN
     217ALIGN JUMP_ALIGN
     218%ifdef USE_186
    219219IdePioBlock_ReadFromXtideRev2:
     220%endif
    220221IdePioBlock_ReadFrom16bitDataPort:
    221222    xchg    cl, ch      ; Sectors to WORDs
    222     rep insw
    223     ret
    224 %endif
    225 
    226 ;--------------------------------------------------------------------
    227 %ifdef USE_AT
     223    rep
     224    db      6Dh         ; INSW
     225    ret
     226
     227;--------------------------------------------------------------------
    228228ALIGN JUMP_ALIGN
    229229IdePioBlock_ReadFrom32bitDataPort:
    230     shl     cx, 7       ; Sectors to DWORDs
     230    db      0C1h        ; SHL
     231    db      0E1h        ; CX
     232    db      7           ; 7 (Sectors to DWORDs)
    231233    rep
    232234    db      66h         ; Override operand size to 32-bit
    233235    db      6Dh         ; INSW/INSD
    234236    ret
    235 %endif
    236237
    237238
     
    248249;       AX, BX, CX, DX
    249250;--------------------------------------------------------------------
    250 %ifdef USE_AT
    251 
    252251ALIGN JUMP_ALIGN
    253252IdePioBlock_WriteTo16bitDataPort:
    254253    xchg    cl, ch      ; Sectors to WORDs
    255254    es                  ; Source is ES segment
    256     rep outsw
     255    rep
     256    db      6Fh         ; OUTSW
    257257    ret
    258258
     
    260260ALIGN JUMP_ALIGN
    261261IdePioBlock_WriteTo32bitDataPort:
    262     shl     cx, 7       ; Sectors to DWORDs
     262    db      0C1h        ; SHL
     263    db      0E1h        ; CX
     264    db      7           ; 7 (Sectors to DWORDs)
    263265    es                  ; Source is ES segment
    264266    rep
     
    266268    db      6Fh         ; OUTSW/OUTSD
    267269    ret
    268 
    269 %endif ; USE_AT
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r473 r480  
    3838;       AL:     IDE command that was used to start the transfer
    3939;               (all PIO read and write commands including Identify Device)
    40 ;       ES:SI:  Ptr to normalized data buffer
     40;       ES:SI:  Ptr to data buffer
    4141;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    4242;       SS:BP:  Ptr to IDEPACK
     
    6262;   Parameters:
    6363;       AH:     Number of sectors to transfer (1...128)
    64 ;       ES:SI:  Normalized ptr to buffer to receive data
     64;       ES:SI:  Ptr to buffer to receive data
    6565;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    6666;       SS:BP:  Ptr to PIOVARS
     
    139139;       AH:     Number of sectors to transfer (1...128)
    140140;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    141 ;       ES:SI:  Normalized ptr to buffer containing data
     141;       ES:SI:  Ptr to buffer containing data
    142142;       SS:BP:  Ptr to PIOVARS
    143143;   Returns:
     
    198198;       BX:     Offset to transfer function lookup table
    199199;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     200;       ES:SI:  Ptr to data buffer
    200201;       SS:BP:  Ptr to PIOVARS
    201202;   Returns:
     
    217218    xchg    ax, bx                              ; Lookup table offset to AX
    218219    mov     bl, [di+DPT_ATA.bDevice]
     220%ifdef MODULE_8BIT_IDE
     221    mov     dl, bl
     222%endif
    219223    add     bx, ax
    220224    mov     ax, [cs:bx]                         ; Load offset to transfer function
    221225    mov     [bp+PIOVARS.fnXfer], ax
    222     ret
    223 
     226
     227    ; Normalize pointer for PIO-transfers and convert to physical address for DMA transfers
     228%ifdef MODULE_8BIT_IDE
     229    cmp     dl, DEVICE_8BIT_XTCF_DMA
     230    jb      SHORT IdeTransfer_NormalizePointerInESSI
     231
     232    ; Convert ES:SI to physical address
     233    xor     dx, dx
     234    mov     ax, es
     235%rep 4
     236    shl     ax, 1
     237    rcl     dx, 1
     238%endrep
     239    add     si, ax
     240    adc     dl, dh
     241    mov     es, dx
     242    ret
     243%endif ; MODULE_8BIT_IDE
     244    ; Fall to IdeTransfer_NormalizePointerInESSI if no MODULE_8BIT_IDE
     245
     246
     247;--------------------------------------------------------------------
     248; IdeTransfer_NormalizePointerInESSI
     249;   Parameters:
     250;       ES:SI:  Ptr to be normalized
     251;   Returns:
     252;       ES:SI:  Normalized pointer (SI = 0...15)
     253;   Corrupts registers:
     254;       AX, DX
     255;--------------------------------------------------------------------
     256IdeTransfer_NormalizePointerInESSI:
     257    NORMALIZE_FAR_POINTER   es, si, ax, dx
     258    ret
    224259
    225260
     
    227262ALIGN WORD_ALIGN
    228263g_rgfnPioRead:
    229 %ifdef USE_AT
    230264        dw      IdePioBlock_ReadFrom16bitDataPort   ; 0, DEVICE_16BIT_ATA
    231265        dw      IdePioBlock_ReadFrom32bitDataPort   ; 1, DEVICE_32BIT_ATA
    232 %else
    233         dd      0
    234 %endif
    235 %ifdef MODULE_8BIT_IDE
    236         dw      IdePioBlock_ReadFromXtideRev1       ; 2, DEVICE_8BIT_XTIDE_REV1
    237     %ifndef USE_AT
    238         g_rgfnPioWrite:
    239     %endif
    240         dw      IdePioBlock_ReadFromXtideRev2       ; 3, DEVICE_8BIT_XTIDE_REV2
    241         dw      IdePioBlock_ReadFrom8bitDataPort    ; 4, DEVICE_8BIT_XTCF_PIO8
    242 %endif
    243 
    244 %ifdef USE_AT
     266%ifdef MODULE_8BIT_IDE
     267        dw      IdePioBlock_ReadFrom8bitDataPort    ; 2, DEVICE_8BIT_ATA
     268        dw      IdePioBlock_ReadFromXtideRev1       ; 3, DEVICE_8BIT_XTIDE_REV1     
     269        dw      IdePioBlock_ReadFromXtideRev2       ; 4, DEVICE_8BIT_XTIDE_REV2
     270        dw      IdePioBlock_ReadFrom8bitDataPort    ; 5, DEVICE_8BIT_XTCF_PIO8
     271        dw      IdeDmaBlock_ReadFromXTCF            ; 6, DEVICE_8BIT_XTCF_DMA
     272%endif
     273
     274
    245275g_rgfnPioWrite:
    246276        dw      IdePioBlock_WriteTo16bitDataPort    ; 0, DEVICE_16BIT_ATA
    247277        dw      IdePioBlock_WriteTo32bitDataPort    ; 1, DEVICE_32BIT_ATA
    248 %endif
    249 %ifdef MODULE_8BIT_IDE
    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
     278%ifdef MODULE_8BIT_IDE
     279        dw      IdePioBlock_WriteTo8bitDataPort     ; 2, DEVICE_8BIT_ATA
     280        dw      IdePioBlock_WriteToXtideRev1        ; 3, DEVICE_8BIT_XTIDE_REV1
     281        dw      IdePioBlock_WriteToXtideRev2        ; 4, DEVICE_8BIT_XTIDE_REV2
     282        dw      IdePioBlock_WriteTo8bitDataPort     ; 5, DEVICE_8BIT_XTCF_PIO8
     283        dw      IdeDmaBlock_WriteToXTCF             ; 6, DEVICE_8BIT_XTCF_DMA
     284%endif
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/JrIdeTransfer.asm

    r476 r480  
    3939;       AL:     IDE command that was used to start the transfer
    4040;               (all PIO read and write commands including Identify Device)
    41 ;       ES:SI:  Ptr to normalized data buffer
     41;       ES:SI:  Ptr to data buffer
    4242;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    4343;       SS:BP:  Ptr to IDEPACK
     
    6161    mov     [bp+MEMPIOVARS.fpDPT], di
    6262    mov     [bp+MEMPIOVARS.fpDPT+2], ds
     63
     64    ; Normalize pointer
     65    call    IdeTransfer_NormalizePointerInESSI
    6366
    6467    ; Get far pointer to Sector Access Window
  • trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm

    r477 r480  
    7474    mov     [bp+IDEPACK.bDrvAndHead], al
    7575
    76     ; Normalize data buffer pointer to ES:SI
    77 %ifdef MODULE_8BIT_IDE
    78     cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
    79     jne     SHORT .NormalizeForSmallestPossibleOffset
    80 
    81     ; DMA transfers do not need to normalize pointer
    82     ; (it will be converted to physical address in IdeDmaTransfer.asm)
     76    ; Load data buffer pointer to ES:SI
    8377    les     si, [es:si+DAP.dwMemoryAddress]
    84     jmp     SHORT GetDeviceControlByteToIdepackAndStartTransfer
    85 %endif ; MODULE_8BIT_IDE
    86 
    87 .NormalizeForSmallestPossibleOffset:
    88     mov     ax, [es:si+DAP.wOffset]
    89     mov     cx, ax
    90     eSHR_IM ax, 4                               ; Divide offset by 16
    91     add     ax, [es:si+DAP.wSegment]            ; Add segment
    92     mov     es, ax                              ; Segment normalized
    93     mov     si, cx
    94     and     si, BYTE 0Fh                        ; Offset normalized
    9578    jmp     SHORT GetDeviceControlByteToIdepackAndStartTransfer
    9679%endif ; MODULE_EBIOS
  • trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm

    r376 r480  
    6161
    6262.readOrWrite:
     63        call    IdeTransfer_NormalizePointerInESSI
    6364        mov     [bp+IDEPACK.bFeatures],ah       ; store protocol command
    6465               
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r473 r480  
    108108;;; Set XT-CF mode
    109109%ifdef MODULE_8BIT_IDE
    110     call    AccessDPT_IsThisDeviceXTCF
    111     jne     SHORT .DoNotSetXTCFmode
    112 
    113110    call    AccessDPT_GetIdevarsToCSBX
    114111    mov     al, [cs:bx+IDEVARS.bXTCFcontrolRegister]
    115     call    AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
     112    call    AH9h_SetModeFromALtoXTCF
    116113    STORE_ERROR_FLAG_TO_DPT     FLG_INITERROR_FAILED_TO_SET_XTCF_MODE
    117114.DoNotSetXTCFmode:
    118 %endif
     115
     116
     117;;; Set 8-bit PIO mode
     118    call    AH9h_Enable8bitModeForDevice8bitAta
     119    STORE_ERROR_FLAG_TO_DPT     FLG_INITERROR_FAILED_TO_SET_8BIT_MODE
     120.DoNotSet8bitMode:
     121%endif ; MODULE_8BIT_IDE
    119122
    120123
     
    261264.NoErrorFlagToSet:
    262265    ret
     266
     267
     268%ifdef MODULE_8BIT_IDE
     269;--------------------------------------------------------------------
     270; AH9h_SetModeFromALtoXTCF
     271;   Parameters:
     272;       AL:     XT-CF Mode to set
     273;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     274;       SS:BP:  Ptr to IDEPACK
     275;   Returns:
     276;       AH:     Int 13h return status
     277;       CF:     Clear if successful or device is not XT-CF
     278;               Set if failed to set mode for XT-CF
     279;   Corrupts registers:
     280;       AL, BX, CX, DX, SI
     281;--------------------------------------------------------------------
     282AH9h_SetModeFromALtoXTCF:
     283    call    AccessDPT_IsThisDeviceXTCF
     284    jne     SHORT IgnoreInvalidCommandError
     285    jmp     AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
     286
     287
     288;--------------------------------------------------------------------
     289; AH9h_Enable8bitModeForDevice8bitAta
     290;   Parameters:
     291;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     292;       SS:BP:  Ptr to IDEPACK
     293;   Returns:
     294;       AH:     Int 13h return status
     295;       CF:     Clear if successful or device is not DEVICE_8BIT_ATA
     296;               Set if failed to set 8-bit mode for DEVICE_8BIT_ATA
     297;   Corrupts registers:
     298;       AL, BX, CX, DX, SI
     299;--------------------------------------------------------------------
     300AH9h_Enable8bitModeForDevice8bitAta:
     301    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_ATA
     302    jne     SHORT IgnoreInvalidCommandError
     303    jmp     AH23h_Enable8bitPioMode
     304%endif ; MODULE_8BIT_IDE
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm

    r477 r480  
    9595Prepare_BufferToESSIforOldInt13hTransfer:
    9696    mov     si, [bp+IDEPACK.intpack+INTPACK.bx] ; Load offset
    97 
    98 %ifdef MODULE_8BIT_IDE
    99     cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
    100     jne     SHORT .NormalizeForSmallestPossibleOffset
    101 
    102     ; DMA transfers do not need to normalize pointer
    103     ; (it will be converted to physical address in IdeDmaTransfer.asm)
    104     mov     es, [bp+IDEPACK.intpack+INTPACK.es]
    105     jmp     SHORT Prepare_ByValidatingSectorsInALforOldInt13h
    106 %endif ; MODULE_8BIT_IDE
    107 
    108     ; Normalize segment for 16b pages
    109 .NormalizeForSmallestPossibleOffset:
    110     mov     bx, si
    111     eSHR_IM bx, 4                               ; Divide offset by 16
    112     add     bx, [bp+IDEPACK.intpack+INTPACK.es]
    113     mov     es, bx                              ; Segment normalized
    114     and     si, BYTE 0Fh                        ; Offset normalized
     97    mov     es, [bp+IDEPACK.intpack+INTPACK.es] ; Load segment
    11598    ; Fall to Prepare_ByValidatingSectorsInALforOldInt13h
    116 
    11799
    118100;---------------------------------------------------------------------
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r477 r480  
    232232%ifdef MODULE_8BIT_IDE
    233233    %include "JrIdeTransfer.asm"    ; Must be included after IdeCommand.asm
    234     %include "IdeDmaTransfer.asm"
     234    %include "IdeDmaBlock.asm"
    235235%endif
    236236    %include "IdeTransfer.asm"
Note: See TracChangeset for help on using the changeset viewer.