[471] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[545] | 2 | ; Description : Int 13h function AH=1Eh, Lo-tech XT-CF features |
---|
| 3 | ; |
---|
| 4 | ; More information at http://www.lo-tech.co.uk/XT-CF |
---|
[471] | 5 | |
---|
| 6 | ; |
---|
[491] | 7 | ; XTIDE Universal BIOS and Associated Tools |
---|
[526] | 8 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[471] | 9 | ; |
---|
| 10 | ; This program is free software; you can redistribute it and/or modify |
---|
| 11 | ; it under the terms of the GNU General Public License as published by |
---|
| 12 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | ; (at your option) any later version. |
---|
[491] | 14 | ; |
---|
[471] | 15 | ; This program is distributed in the hope that it will be useful, |
---|
| 16 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[491] | 18 | ; GNU General Public License for more details. |
---|
[471] | 19 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
[491] | 20 | ; |
---|
[471] | 21 | |
---|
[545] | 22 | ; Modified by JJP for XT-CFv3 support, Mar-13 |
---|
| 23 | |
---|
[471] | 24 | ; Section containing code |
---|
| 25 | SECTION .text |
---|
| 26 | |
---|
| 27 | ;-------------------------------------------------------------------- |
---|
| 28 | ; Int 13h function AH=1Eh, Lo-tech XT-CF features. |
---|
| 29 | ; This function is supported only by XTIDE Universal BIOS. |
---|
| 30 | ; |
---|
| 31 | ; AH1Eh_HandlerForXTCFfeatures |
---|
| 32 | ; Parameters: |
---|
| 33 | ; AL, CX: Same as in INTPACK |
---|
| 34 | ; DL: Translated Drive number |
---|
| 35 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 36 | ; SS:BP: Ptr to IDEPACK |
---|
| 37 | ; Parameters on INTPACK: |
---|
| 38 | ; AL: XT-CF subcommand (see XTCF.inc for more info) |
---|
| 39 | ; Returns with INTPACK: |
---|
| 40 | ; AH: Int 13h return status |
---|
| 41 | ; CF: 0 if successful, 1 if error |
---|
| 42 | ;-------------------------------------------------------------------- |
---|
| 43 | AH1Eh_HandlerForXTCFfeatures: |
---|
| 44 | %ifndef USE_186 |
---|
[475] | 45 | call ProcessXTCFsubcommandFromAL |
---|
[471] | 46 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|
| 47 | %else |
---|
[545] | 48 | push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|
[475] | 49 | ; Fall to ProcessXTCFsubcommandFromAL |
---|
[471] | 50 | %endif |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | ;-------------------------------------------------------------------- |
---|
[475] | 54 | ; ProcessXTCFsubcommandFromAL |
---|
[471] | 55 | ; Parameters: |
---|
[473] | 56 | ; AL: XT-CF subcommand (see XTCF.inc for more info) |
---|
[471] | 57 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 58 | ; SS:BP: Ptr to IDEPACK |
---|
| 59 | ; Returns: |
---|
| 60 | ; AH: Int 13h return status |
---|
| 61 | ; CF: 0 if successful, 1 if error |
---|
[545] | 62 | ; DX Command return values (see XTCF.inc) |
---|
[471] | 63 | ; Corrupts registers: |
---|
[473] | 64 | ; AL, BX, CX, DX, SI |
---|
[471] | 65 | ;-------------------------------------------------------------------- |
---|
[475] | 66 | ProcessXTCFsubcommandFromAL: |
---|
[472] | 67 | ; IS_THIS_DRIVE_XTCF. We check this for all commands. |
---|
[473] | 68 | call AccessDPT_IsThisDeviceXTCF |
---|
[545] | 69 | jne SHORT .XTCFnotFound |
---|
[491] | 70 | and ax, BYTE 7Fh ; Subcommand now in AX (clears AH and CF) |
---|
[545] | 71 | jz SHORT .XTCFfound ; Sub-function IS_THIS_DRIVE_XTCF (=0) |
---|
[472] | 72 | |
---|
[545] | 73 | dec ax ; Test subcommand... |
---|
| 74 | jz SHORT .SetXTCFtransferMode ; ...for value 1 (SET_XTCF_TRANSFER_MODE) |
---|
[491] | 75 | |
---|
[545] | 76 | dec ax ; Test subcommand for value 2 (GET_XTCF_TRANSFER_MODE) |
---|
| 77 | jnz SHORT .XTCFnotFound ; Invalid subcommand |
---|
[473] | 78 | |
---|
[545] | 79 | ; GET_XTCF_TRANSFER_MODE |
---|
| 80 | call AH1Eh_GetCurrentXTCFmodeToAX |
---|
| 81 | 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... |
---|
| 84 | .XTCFfound: |
---|
| 85 | ret ; ...with AH and CF cleared |
---|
[473] | 86 | |
---|
[545] | 87 | .XTCFnotFound: |
---|
| 88 | .AH1Eh_LoadInvalidCommandToAHandSetCF: |
---|
| 89 | stc ; set carry flag since XT-CF not found |
---|
| 90 | mov ah, RET_HD_INVALID |
---|
| 91 | ret ; and return |
---|
| 92 | |
---|
| 93 | .SetXTCFtransferMode: |
---|
| 94 | mov al, [bp+IDEPACK.intpack+INTPACK.dh] ; get specified mode (eg XTCF_DMA_MODE) |
---|
| 95 | ; and fall to AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL |
---|
| 96 | |
---|
| 97 | |
---|
[473] | 98 | ;-------------------------------------------------------------------- |
---|
[545] | 99 | ; AH1Eh_ChangeXTCFmodeBasedOnModeInAL |
---|
[473] | 100 | ; Parameters: |
---|
[545] | 101 | ; AL: XT-CF Mode (see XTCF.inc) |
---|
[473] | 102 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 103 | ; SS:BP: Ptr to IDEPACK |
---|
[545] | 104 | ; Returns: |
---|
[473] | 105 | ; AH: Int 13h return status |
---|
| 106 | ; CF: 0 if successful, 1 if error |
---|
| 107 | ; Corrupts registers: |
---|
| 108 | ; AL, BX, CX, DX, SI |
---|
| 109 | ;-------------------------------------------------------------------- |
---|
[545] | 110 | AH1Eh_ChangeXTCFmodeBasedOnModeInAL: |
---|
| 111 | ; 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. |
---|
| 113 | ; Selected transfer mode is stored in BIOS variable (DPT_ATA.bDevice). |
---|
[472] | 114 | |
---|
[505] | 115 | ; We always need to enable 8-bit mode since 16-bit mode is restored |
---|
| 116 | ; when controller is reset (AH=00h or 0Dh) |
---|
[545] | 117 | ; |
---|
| 118 | ; Note that when selecting 'DEVICE_8BIT_PIO_MODE_WITH_BIU_OFFLOAD' mode, |
---|
| 119 | ; 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 |
---|
| 121 | ; like REP INSW. This works because XT-CF adapters are 8-bit cards, and |
---|
| 122 | ; the BIU in the machine splits each WORD requested by the CPU into two 8-bit |
---|
| 123 | ; ISA cycles at base+0h and base+1h. The XT-CF cards do not decode A0, hence |
---|
| 124 | ; both accesses appear the same to the card and the BIU then re-constructs |
---|
| 125 | ; the data for presentation to the CPU. |
---|
| 126 | ; |
---|
| 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. |
---|
| 131 | |
---|
[505] | 132 | ePUSH_T bx, AH23h_Enable8bitPioMode |
---|
| 133 | |
---|
[545] | 134 | ; Convert mode to device type (see XTCF.inc for full details) |
---|
| 135 | 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 |
---|
[472] | 139 | |
---|
[545] | 140 | ; XTCF_DMA_MODE = 2 (allow 3 as well for more optimized code) |
---|
[473] | 141 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA |
---|
[545] | 142 | |
---|
| 143 | ; DMA transfers have limited block sizee |
---|
[474] | 144 | mov al, [di+DPT_ATA.bBlockSize] |
---|
[545] | 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 |
---|
[473] | 148 | |
---|
| 149 | .Set8bitPioMode: |
---|
[545] | 150 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8 |
---|
| 151 | ret ; through AH23h_Enable8bitPioMode |
---|
[491] | 152 | |
---|
[545] | 153 | .Set8bitPioModeWithBIUOffload: |
---|
| 154 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8_WITH_BIU_OFFLOAD |
---|
| 155 | ret ; through AH23h_Enable8bitPioMode |
---|
[473] | 156 | |
---|
[545] | 157 | |
---|
[472] | 158 | ;-------------------------------------------------------------------- |
---|
[545] | 159 | ; AH1Eh_GetCurrentXTCFmodeToAX |
---|
[472] | 160 | ; Parameters: |
---|
[545] | 161 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 162 | ; Returns: |
---|
| 163 | ; AX: XT-CF mode (XTCF_8BIT_PIO_MODE, XTCF_8BIT_PIO_MODE_WITH_BIU_OFFLOAD or XTCF_DMA_MODE) |
---|
| 164 | ; CF: Clear |
---|
[472] | 165 | ; Corrupts registers: |
---|
[545] | 166 | ; Nothing |
---|
[472] | 167 | ;-------------------------------------------------------------------- |
---|
[545] | 168 | AH1Eh_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 |
---|
| 172 | ret |
---|