Changeset 558 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h


Ignore:
Timestamp:
Jun 23, 2013, 3:52:31 PM (11 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Building the BIOS Drive Information Tool now works again.
  • Moved all XT-CF related code to MODULE_8BIT_IDE_ADVANCED. I don't see how an XT-CF card could work without *_ADVANCED anyway but if I'm wrong, feel free to undo this. Note! The autodetection code in XTIDECFG has NOT been changed to reflect this (still relies on MODULE_8BIT_IDE).
  • Optimizations and fixes in general.
Location:
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1Eh_XTCF.asm

    r545 r558  
    4040;       AH:     Int 13h return status
    4141;       CF:     0 if successful, 1 if error
     42;       DX:     Command return values (see XTCF.inc)
    4243;--------------------------------------------------------------------
    4344AH1Eh_HandlerForXTCFfeatures:
     
    4647    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    4748%else
    48     push        Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     49    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    4950    ; Fall to ProcessXTCFsubcommandFromAL
    5051%endif
     
    6061;       AH:     Int 13h return status
    6162;       CF:     0 if successful, 1 if error
    62 ;       DX      Command return values (see XTCF.inc)
    6363;   Corrupts registers:
    6464;       AL, BX, CX, DX, SI
     
    6868    call    AccessDPT_IsThisDeviceXTCF
    6969    jne     SHORT .XTCFnotFound
    70     and     ax, BYTE 7Fh                ; Subcommand now in AX (clears AH and CF)
     70    and     ax, 0FFh                    ; Subcommand now in AX (clears AH and CF)
    7171    jz      SHORT .XTCFfound            ; Sub-function IS_THIS_DRIVE_XTCF (=0)
    7272
     
    7575
    7676    dec     ax                          ; Test subcommand for value 2 (GET_XTCF_TRANSFER_MODE)
    77     jnz     SHORT .XTCFnotFound         ; Invalid subcommand
     77    jnz     SHORT .AH1Eh_LoadInvalidCommandToAHandSetCF
    7878
    7979    ; GET_XTCF_TRANSFER_MODE
    8080    call    AH1Eh_GetCurrentXTCFmodeToAX
     81    mov     dh, al
    8182    mov     dl, [di+DPT_ATA.bBlockSize]
    82     mov     [bp+IDEPACK.intpack+INTPACK.dh], al ; return mode value...
    83     mov     [bp+IDEPACK.intpack+INTPACK.dl], dl ; ...and block size, via INTPACK...
     83    mov     [bp+IDEPACK.intpack+INTPACK.dx], dx ; Return mode value (DH) and block size (DL) via INTPACK
    8484.XTCFfound:
    85     ret                                         ; ...with AH and CF cleared
     85    ret     ; With AH and CF cleared
    8686
    8787.XTCFnotFound:
    8888.AH1Eh_LoadInvalidCommandToAHandSetCF:
    89     stc                 ; set carry flag since XT-CF not found
     89    stc     ; Set carry flag since XT-CF not found or invalid subcommand
    9090    mov     ah, RET_HD_INVALID
    91     ret                 ; and return
     91    ret
    9292
    9393.SetXTCFtransferMode:
    94     mov     al, [bp+IDEPACK.intpack+INTPACK.dh] ; get specified mode (eg XTCF_DMA_MODE)
    95     ; and fall to AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL
     94    mov     al, [bp+IDEPACK.intpack+INTPACK.dh] ; Get specified mode (eg XTCF_DMA_MODE)
     95    ; Fall to AH1Eh_ChangeXTCFmodeBasedOnModeInAL
    9696
    9797
     
    102102;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    103103;       SS:BP:  Ptr to IDEPACK
    104 ;   Returns:   
     104;   Returns:
    105105;       AH:     Int 13h return status
    106106;       CF:     0 if successful, 1 if error
     
    110110AH1Eh_ChangeXTCFmodeBasedOnModeInAL:
    111111    ; Note: Control register (as of XT-CFv3) is now a write-only register,
    112     ;       whos purpose is *only* to raise DRQ.  The register cannot be read.
     112    ;       whose purpose is *only* to raise DRQ.  The register cannot be read.
    113113    ;       Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice).
    114114
    115     ; We always need to enable 8-bit mode since 16-bit mode is restored
    116     ; when controller is reset (AH=00h or 0Dh)
    117     ;
    118115    ; Note that when selecting 'DEVICE_8BIT_PIO_MODE_WITH_BIU_OFFLOAD' mode,
    119116    ; the ATA device (i.e. CompactFlash card) will operate in 8-bit mode, but
    120     ; data will be transferred from it's data register using 16-bit CPU instructions
     117    ; data will be transferred from its data register using 16-bit CPU instructions
    121118    ; like REP INSW.  This works because XT-CF adapters are 8-bit cards, and
    122119    ; the BIU in the machine splits each WORD requested by the CPU into two 8-bit
     
    125122    ; the data for presentation to the CPU.
    126123    ;
    127     ; Also note though that some machines, noteably AT&T PC6300, have hardware
    128     ; errors in the BIU logic, resulting in reversed byte ordering.  Therefore,
    129     ; mode DEVICE_8BIT_PIO is the default transfer mode for best system
    130     ; compatibility.
     124    ; Also note that some machines, noteably the Olivetti M24 (also known as
     125    ; the AT&T PC6300 and Xerox 6060), have hardware errors in the BIU logic,
     126    ; resulting in reversed byte ordering.  Therefore, mode DEVICE_8BIT_PIO is
     127    ; the default transfer mode for best system compatibility.
    131128
     129    ; We always need to enable 8-bit mode since 16-bit mode is restored
     130    ; when controller is reset (AH=00h or 0Dh)
    132131    ePUSH_T bx, AH23h_Enable8bitPioMode
    133132
    134133    ; Convert mode to device type (see XTCF.inc for full details)
    135134    and     ax, 3
    136     jz  SHORT .Set8bitPioMode   ; XTCF_8BIT_PIO_MODE = 0
    137     dec     ax                  ; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
    138     jz  SHORT .Set8bitPioModeWithBIUOffload
     135    jz      SHORT .Set8bitPioMode   ; XTCF_8BIT_PIO_MODE = 0
     136    dec     ax                      ; XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD = 1
     137    jz      SHORT .Set8bitPioModeWithBIUOffload
    139138
    140139    ; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code)
    141140    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
    142141
    143     ; DMA transfers have limited block sizee
     142    ; DMA transfers have limited block size
    144143    mov     al, [di+DPT_ATA.bBlockSize]
    145     MIN_U   al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
    146     jmp     AH24h_SetBlockSize
    147     ; exit via ret in AH24_SetBlockSize then through AH23h_Enable8bitPioMode
     144    cmp     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
     145    jbe     SHORT AH24h_SetBlockSize
     146    mov     al, XTCF_DMA_MODE_MAX_BLOCK_SIZE
     147    jmp     SHORT AH24h_SetBlockSize
    148148
    149149.Set8bitPioMode:
    150     mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8
    151     ret     ; through AH23h_Enable8bitPioMode
     150    mov     al, DEVICE_8BIT_XTCF_PIO8
     151    SKIP2B  bx
    152152
    153153.Set8bitPioModeWithBIUOffload:
    154     mov     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
    155     ret     ; through AH23h_Enable8bitPioMode
     154    mov     al, DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD
     155    mov     [di+DPT_ATA.bDevice], al
     156    ret
    156157
    157158
     
    160161;   Parameters:
    161162;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    162 ;   Returns:   
     163;   Returns:
    163164;       AX:     XT-CF mode (XTCF_8BIT_PIO_MODE, XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD or XTCF_DMA_MODE)
    164165;       CF:     Clear
     
    167168;--------------------------------------------------------------------
    168169AH1Eh_GetCurrentXTCFmodeToAX:
    169     eMOVZX  ax, BYTE [di+DPT_ATA.bDevice]   ; get current mode from DPT
    170     sub     al, DEVICE_8BIT_XTCF_PIO8
    171     shr     ax, 1                           ; Device type to XT-CF mode
     170    mov     al, [di+DPT_ATA.bDevice]
     171    shr     al, 1
     172    cbw
     173    sub     al, DEVICE_8BIT_XTCF_PIO8 >> 1
    172174    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm

    r550 r558  
    8484    pop     bx          ; Pop block size to BL
    8585    jc      SHORT .DisableBlockMode
    86     mov     bh, bl      ; BL and BH both have block size we tried to set
    87     dec     bh
    88     jz      SHORT .DisableBlockMode
     86
     87    ; All valid block sizes are powers of 2 which means BL have just one bit set (parity odd).
     88    ; Incrementing BX will cause all block sizes except 1 to have two bits set (parity even).
     89    ; Note that PF reflects only the lowest 8 bits of any register being modified.
     90    inc     bx                      ; 1 -> 2 ?
     91    jpo     SHORT .DisableBlockMode ; Jump if BL = 2
     92    dec     bx                      ; Restore block size (was larger than 1)
    8993
    9094    ; Enable block mode and store block size
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r550 r558  
    112112
    113113
     114%ifdef MODULE_8BIT_IDE_ADVANCED
    114115;;; Set XT-CF mode
    115 %ifdef MODULE_8BIT_IDE_ADVANCED
    116116    call    AH1Eh_GetCurrentXTCFmodeToAX
    117117    call    AH9h_SetModeFromALtoXTCF
    118118    STORE_ERROR_FLAG_TO_DPT     FLG_INITERROR_FAILED_TO_SET_XTCF_MODE
    119 .DoNotSetXTCFmode:
    120119%endif  ; MODULE_8BIT_IDE_ADVANCED
    121120
     
    124123    call    AH9h_Enable8bitModeForDevice8bitAta
    125124    STORE_ERROR_FLAG_TO_DPT     FLG_INITERROR_FAILED_TO_SET_8BIT_MODE
    126 .DoNotSet8bitMode:
    127125%endif ; MODULE_8BIT_IDE
    128126
     
    138136    call    Idepack_StoreNonExtParametersAndIssueCommandFromAL
    139137    STORE_ERROR_FLAG_TO_DPT     FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS
    140 .SkipInitializeDeviceParameters:
    141138
    142139
     
    302299    jne     SHORT IgnoreInvalidCommandError
    303300    jmp     AH23h_Enable8bitPioMode
    304 %endif
     301%endif ; MODULE_8BIT_IDE
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm

    r550 r558  
    4545
    4646    ; Make sure that sector count is valid
     47%ifdef USE_UNDOC_INTEL
     48    eSALC   ; Clear AL using CF (CF is cleared since JB above fell through)
     49    or      al, [es:si+DAP.wSectorCount]
     50%else
    4751    mov     al, [es:si+DAP.wSectorCount]
    4852    test    al, al
     53%endif
    4954    jz      SHORT ZeroSectorsRequestedSoNoErrors
    5055    js      SHORT InvalidNumberOfSectorsRequested
     
    6267    call    Prepare_GetOldInt13hCommandIndexToBX
    6368    mov     al, [di+DPT.bFlagsLow]
    64     shl     al, 1                   ; Set CF if LBA48 supported
     69    eSHL_IM al, 1                   ; Set CF if LBA48 supported
    6570    adc     bl, bh                  ; LBA48 EXT commands
    6671    ret
Note: See TracChangeset for help on using the changeset viewer.