[471] | 1 | ; Project name : XTIDE Universal BIOS |
---|
| 2 | ; Description : Int 13h function AH=1Eh, Lo-tech XT-CF features. |
---|
| 3 | |
---|
| 4 | ; |
---|
[491] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
[471] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
| 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
[491] | 12 | ; |
---|
[471] | 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[491] | 16 | ; GNU General Public License for more details. |
---|
[471] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
[491] | 18 | ; |
---|
[471] | 19 | |
---|
| 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; Int 13h function AH=1Eh, Lo-tech XT-CF features. |
---|
| 25 | ; This function is supported only by XTIDE Universal BIOS. |
---|
| 26 | ; |
---|
| 27 | ; AH1Eh_HandlerForXTCFfeatures |
---|
| 28 | ; Parameters: |
---|
| 29 | ; AL, CX: Same as in INTPACK |
---|
| 30 | ; DL: Translated Drive number |
---|
| 31 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 32 | ; SS:BP: Ptr to IDEPACK |
---|
| 33 | ; Parameters on INTPACK: |
---|
| 34 | ; AL: XT-CF subcommand (see XTCF.inc for more info) |
---|
| 35 | ; Returns with INTPACK: |
---|
| 36 | ; AH: Int 13h return status |
---|
| 37 | ; CF: 0 if successful, 1 if error |
---|
| 38 | ;-------------------------------------------------------------------- |
---|
| 39 | AH1Eh_HandlerForXTCFfeatures: |
---|
| 40 | %ifndef USE_186 |
---|
[475] | 41 | call ProcessXTCFsubcommandFromAL |
---|
[471] | 42 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|
| 43 | %else |
---|
| 44 | push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|
[475] | 45 | ; Fall to ProcessXTCFsubcommandFromAL |
---|
[471] | 46 | %endif |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | ;-------------------------------------------------------------------- |
---|
[475] | 50 | ; ProcessXTCFsubcommandFromAL |
---|
[471] | 51 | ; Parameters: |
---|
[473] | 52 | ; AL: XT-CF subcommand (see XTCF.inc for more info) |
---|
[471] | 53 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 54 | ; SS:BP: Ptr to IDEPACK |
---|
| 55 | ; Returns: |
---|
| 56 | ; AH: Int 13h return status |
---|
| 57 | ; CF: 0 if successful, 1 if error |
---|
| 58 | ; Corrupts registers: |
---|
[473] | 59 | ; AL, BX, CX, DX, SI |
---|
[471] | 60 | ;-------------------------------------------------------------------- |
---|
[475] | 61 | ProcessXTCFsubcommandFromAL: |
---|
[472] | 62 | ; IS_THIS_DRIVE_XTCF. We check this for all commands. |
---|
[473] | 63 | call AccessDPT_IsThisDeviceXTCF |
---|
| 64 | jne SHORT XTCFnotFound |
---|
[491] | 65 | and ax, BYTE 7Fh ; Subcommand now in AX (clears AH and CF) |
---|
[473] | 66 | jz SHORT .ReturnWithSuccess ; IS_THIS_DRIVE_XTCF |
---|
[472] | 67 | |
---|
| 68 | ; READ_XTCF_CONTROL_REGISTER_TO_DH |
---|
[473] | 69 | dec ax ; Subcommand |
---|
[472] | 70 | jnz SHORT .SkipReadXtcfControlRegisterToDH |
---|
[473] | 71 | mov dx, [di+DPT.wBasePort] |
---|
[491] | 72 | add dl, XTCF_CONTROL_REGISTER ; Will never overflow (keeps CF cleared) |
---|
[472] | 73 | in al, dx |
---|
| 74 | mov [bp+IDEPACK.intpack+INTPACK.dh], al |
---|
[473] | 75 | .ReturnWithSuccess: |
---|
[491] | 76 | ret ; With AH and CF cleared |
---|
| 77 | |
---|
[472] | 78 | .SkipReadXtcfControlRegisterToDH: |
---|
| 79 | ; WRITE_DH_TO_XTCF_CONTROL_REGISTER |
---|
[473] | 80 | dec ax ; Subcommand |
---|
[472] | 81 | jnz SHORT XTCFnotFound ; Invalid subcommand |
---|
| 82 | mov al, [bp+IDEPACK.intpack+INTPACK.dh] |
---|
[473] | 83 | ; Fall to AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | ;-------------------------------------------------------------------- |
---|
| 87 | ; AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL |
---|
| 88 | ; Parameters: |
---|
| 89 | ; AL: XT-CF Control Register |
---|
| 90 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 91 | ; SS:BP: Ptr to IDEPACK |
---|
| 92 | ; Returns: |
---|
| 93 | ; AH: Int 13h return status |
---|
| 94 | ; CF: 0 if successful, 1 if error |
---|
| 95 | ; Corrupts registers: |
---|
| 96 | ; AL, BX, CX, DX, SI |
---|
| 97 | ;-------------------------------------------------------------------- |
---|
| 98 | AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL: |
---|
| 99 | ; Output Control Register |
---|
| 100 | mov dx, [di+DPT.wBasePort] |
---|
| 101 | add dl, XTCF_CONTROL_REGISTER |
---|
[472] | 102 | out dx, al |
---|
| 103 | |
---|
[473] | 104 | ; Convert Control Register Contents to device code |
---|
| 105 | test al, al |
---|
| 106 | jz SHORT .Set8bitPioMode |
---|
| 107 | cmp al, XTCF_MEMORY_MAPPED_MODE |
---|
| 108 | jae SHORT .SetMemoryMappedMode |
---|
[472] | 109 | |
---|
[473] | 110 | ; Set DMA Mode |
---|
| 111 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA |
---|
[474] | 112 | mov al, [di+DPT_ATA.bBlockSize] |
---|
[477] | 113 | call AH24h_SetBlockSize ; AH=24h limits block size if necessary |
---|
| 114 | jmp SHORT .Enable8bitPioMode |
---|
[473] | 115 | |
---|
| 116 | .SetMemoryMappedMode: |
---|
| 117 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_MEMMAP |
---|
[474] | 118 | jmp SHORT .Enable8bitPioMode |
---|
[473] | 119 | |
---|
| 120 | .Set8bitPioMode: |
---|
| 121 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_PIO8 |
---|
[477] | 122 | ; Fall to .Enable8bitPioMode |
---|
[491] | 123 | |
---|
[477] | 124 | ; We always need to enable 8-bit mode since 16-bit mode is restored |
---|
[491] | 125 | ; when controller is reset (AH=00h or 0Dh) |
---|
| 126 | .Enable8bitPioMode: |
---|
[473] | 127 | jmp AH23h_Enable8bitPioMode |
---|
| 128 | |
---|
| 129 | |
---|
[472] | 130 | ;-------------------------------------------------------------------- |
---|
| 131 | ; AH1Eh_DetectXTCFwithBasePortInDX |
---|
| 132 | ; Parameters: |
---|
| 133 | ; DX: Base I/O port address to check |
---|
| 134 | ; Returns: |
---|
| 135 | ; AH: RET_HD_SUCCESS if XT-CF is found from port |
---|
| 136 | ; RET_HD_INVALID if XT-CF is not found |
---|
| 137 | ; CF: Cleared if XT-CF found |
---|
| 138 | ; Set if XT-CF not found |
---|
| 139 | ; Corrupts registers: |
---|
[473] | 140 | ; AL |
---|
[472] | 141 | ;-------------------------------------------------------------------- |
---|
| 142 | AH1Eh_DetectXTCFwithBasePortInDX: |
---|
[473] | 143 | push dx |
---|
[491] | 144 | add dl, XTCF_CONTROL_REGISTER_INVERTED_in ; set DX to XT-CF config register (inverted) |
---|
[472] | 145 | in al, dx ; get value |
---|
| 146 | mov ah, al ; save in ah |
---|
| 147 | inc dx ; set DX to XT-CF config register (non-inverted) |
---|
| 148 | in al, dx ; get value |
---|
[473] | 149 | not al ; invert value |
---|
| 150 | pop dx |
---|
[472] | 151 | sub ah, al ; do they match? (clear AH if they do) |
---|
| 152 | jz SHORT XTCFfound |
---|
| 153 | |
---|
| 154 | XTCFnotFound: |
---|
[473] | 155 | AH1Eh_LoadInvalidCommandToAHandSetCF: |
---|
[472] | 156 | stc ; set carry flag since XT-CF not found |
---|
| 157 | mov ah, RET_HD_INVALID |
---|
| 158 | XTCFfound: |
---|
| 159 | ret ; and return |
---|