[392] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
| 2 | ; Description : Common functions for initializing different
|
---|
| 3 | ; VLB and PCI IDE Controllers.
|
---|
| 4 |
|
---|
| 5 | ;
|
---|
[399] | 6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
[526] | 7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
[392] | 8 | ;
|
---|
| 9 | ; This program is free software; you can redistribute it and/or modify
|
---|
| 10 | ; it under the terms of the GNU General Public License as published by
|
---|
| 11 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
| 12 | ; (at your option) any later version.
|
---|
[399] | 13 | ;
|
---|
[392] | 14 | ; This program is distributed in the hope that it will be useful,
|
---|
| 15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
[399] | 17 | ; GNU General Public License for more details.
|
---|
[392] | 18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
[399] | 19 | ;
|
---|
[392] | 20 |
|
---|
| 21 | ; Section containing code
|
---|
| 22 | SECTION .text
|
---|
| 23 |
|
---|
| 24 | ;--------------------------------------------------------------------
|
---|
| 25 | ; AdvAtaInit_DetectControllerForIdeBaseInBX
|
---|
| 26 | ; Parameters:
|
---|
| 27 | ; BX: IDE Controller base port
|
---|
| 28 | ; Returns:
|
---|
| 29 | ; AX: ID WORD specific for detected controller
|
---|
| 30 | ; Zero if no controller detected
|
---|
| 31 | ; DX: Controller base port (not IDE)
|
---|
| 32 | ; CF: Set if controller detected
|
---|
| 33 | ; Cleared if no controller
|
---|
| 34 | ; Corrupts registers:
|
---|
[593] | 35 | ; BX, CX
|
---|
[392] | 36 | ;--------------------------------------------------------------------
|
---|
| 37 | AdvAtaInit_DetectControllerForIdeBaseInBX:
|
---|
[593] | 38 | ; Detect if system has PCI bus. If it does, we can skip VLB detection. This is
|
---|
[596] | 39 | ; good thing since detecting Vision QD6580 is dangerous since Intel PIIX4 south bridge
|
---|
[593] | 40 | ; mirrors Interrupt Controller registers from Axh to Bxh. This can lead to faulty
|
---|
[596] | 41 | ; detection of QD6580 that will eventually crash the system when ports are written.
|
---|
[593] | 42 |
|
---|
| 43 | ; We should save the 32-bit registers but we don't since system BIOS has stored
|
---|
| 44 | ; them already and we don't use the 32-bit registers ourselves anywhere at the moment.
|
---|
| 45 | push bx
|
---|
| 46 | push di
|
---|
| 47 | xor edi, edi ; Some BIOSes require this to be set to zero
|
---|
| 48 | mov ax, PCI_INSTALLATION_CHECK
|
---|
| 49 | int BIOS_TIME_PCI_PNP_1Ah
|
---|
| 50 | pop di
|
---|
| 51 | pop bx
|
---|
| 52 | test ah, ah
|
---|
| 53 | jz SHORT .ThisSystemHasPCIbus
|
---|
| 54 |
|
---|
| 55 | ; Detect VLB controllers
|
---|
[392] | 56 | call Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent
|
---|
[589] | 57 | jnz SHORT .NoVisionControllerFound
|
---|
| 58 |
|
---|
[392] | 59 | call Vision_DoesIdePortInBXbelongToControllerWithIDinAX
|
---|
[589] | 60 | jz SHORT .AdvancedControllerFoundForPortBX
|
---|
| 61 |
|
---|
| 62 | .NoVisionControllerFound:
|
---|
[587] | 63 | call PDC20x30_DetectControllerForIdeBaseInBX
|
---|
| 64 | jnc SHORT .NoAdvancedControllerForPortBX
|
---|
[392] | 65 |
|
---|
[589] | 66 | .AdvancedControllerFoundForPortBX:
|
---|
| 67 | stc
|
---|
[392] | 68 | ret
|
---|
| 69 |
|
---|
| 70 | .NoAdvancedControllerForPortBX:
|
---|
[593] | 71 | .ThisSystemHasPCIbus:
|
---|
[589] | 72 | xor ax, ax ; Clear ID in AX and CF
|
---|
[392] | 73 | ret
|
---|
| 74 |
|
---|
| 75 |
|
---|
| 76 | ;--------------------------------------------------------------------
|
---|
[564] | 77 | ; AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX
|
---|
[392] | 78 | ; Parameters:
|
---|
| 79 | ; AX: ID WORD specific for detected controller
|
---|
| 80 | ; Returns:
|
---|
[592] | 81 | ; AL: Max supported PIO mode (only if ZF set)
|
---|
| 82 | ; AH: ~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
|
---|
[582] | 83 | ; BX: Min PIO cycle time (only if ZF set)
|
---|
| 84 | ; ZF: Set if PIO limit necessary
|
---|
[392] | 85 | ; Cleared if no need to limit timings
|
---|
| 86 | ; Corrupts registers:
|
---|
[582] | 87 | ; Nothing
|
---|
[392] | 88 | ;--------------------------------------------------------------------
|
---|
[587] | 89 | AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX:
|
---|
| 90 | cmp ah, ID_QD6580_ALTERNATE
|
---|
[589] | 91 | %ifdef USE_386
|
---|
| 92 | jae Vision_GetMaxPioModeToALandMinCycleTimeToBX
|
---|
| 93 | jmp PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX
|
---|
| 94 | %else
|
---|
[587] | 95 | jae SHORT .Vision
|
---|
| 96 | jmp PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX
|
---|
| 97 | .Vision:
|
---|
| 98 | jmp Vision_GetMaxPioModeToALandMinCycleTimeToBX
|
---|
[589] | 99 | %endif
|
---|
[392] | 100 |
|
---|
| 101 |
|
---|
| 102 | ;--------------------------------------------------------------------
|
---|
| 103 | ; AdvAtaInit_InitializeControllerForDPTinDSDI
|
---|
| 104 | ; Parameters:
|
---|
| 105 | ; DS:DI: Ptr to DPT for Single or Slave Drive
|
---|
| 106 | ; Returns:
|
---|
[507] | 107 | ; AH: Int 13h return status
|
---|
[392] | 108 | ; CF: Cleared if success or no controller to initialize
|
---|
| 109 | ; Set if error
|
---|
| 110 | ; Corrupts registers:
|
---|
[507] | 111 | ; AL, BX, CX, DX
|
---|
[392] | 112 | ;--------------------------------------------------------------------
|
---|
| 113 | AdvAtaInit_InitializeControllerForDPTinDSDI:
|
---|
| 114 | ; Call Controller Specific initialization function
|
---|
| 115 | mov ax, [di+DPT_ADVANCED_ATA.wControllerID]
|
---|
| 116 | test ax, ax
|
---|
| 117 | jz SHORT .NoAdvancedController ; Return with CF cleared
|
---|
[589] | 118 |
|
---|
[587] | 119 | cmp ah, ID_QD6580_ALTERNATE
|
---|
| 120 | jae SHORT .Vision
|
---|
| 121 | jmp PDC20x30_InitializeForDPTinDSDI
|
---|
[392] | 122 |
|
---|
[587] | 123 | .Vision:
|
---|
[399] | 124 | push bp
|
---|
| 125 | push si
|
---|
| 126 |
|
---|
[392] | 127 | call AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
|
---|
[589] | 128 | call Vision_InitializeWithIDinAH
|
---|
[567] | 129 | xor ax, ax ; Success
|
---|
[392] | 130 |
|
---|
| 131 | pop si
|
---|
| 132 | pop bp
|
---|
[399] | 133 |
|
---|
| 134 | .NoAdvancedController:
|
---|
[392] | 135 | ret
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | ;--------------------------------------------------------------------
|
---|
| 139 | ; AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
|
---|
| 140 | ; Parameters:
|
---|
| 141 | ; DS:DI: Ptr to DPT for Single or Slave Drive
|
---|
| 142 | ; Returns:
|
---|
| 143 | ; SI: Offset to Master DPT if Slave Drive present
|
---|
| 144 | ; Zero if Slave Drive not present
|
---|
| 145 | ; Corrupts registers:
|
---|
[589] | 146 | ; AL
|
---|
[392] | 147 | ;--------------------------------------------------------------------
|
---|
| 148 | AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI:
|
---|
| 149 | ; Must be Slave Drive if previous DPT has same IDEVARS offset
|
---|
| 150 | lea si, [di-LARGEST_DPT_SIZE] ; DS:SI points to previous DPT
|
---|
| 151 | mov al, [di+DPT.bIdevarsOffset]
|
---|
| 152 | cmp al, [si+DPT.bIdevarsOffset]
|
---|
| 153 | je SHORT .MasterAndSlaveDrivePresent
|
---|
| 154 |
|
---|
| 155 | ; We only have single drive so zero SI
|
---|
| 156 | xor si, si
|
---|
| 157 | .MasterAndSlaveDrivePresent:
|
---|
| 158 | ret
|
---|
| 159 |
|
---|
| 160 |
|
---|
| 161 | ;--------------------------------------------------------------------
|
---|
| 162 | ; AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI
|
---|
| 163 | ; Parameters:
|
---|
| 164 | ; DS:DI: Ptr to DPT for Single or Slave Drive
|
---|
| 165 | ; SI: Offset to Master DPT if Slave Drive present
|
---|
| 166 | ; Zero if Slave Drive not present
|
---|
| 167 | ; Returns:
|
---|
| 168 | ; BX: Best common PIO mode
|
---|
| 169 | ; CX: Slowest common PIO Cycle Time in nanosecs
|
---|
| 170 | ; Corrupts registers:
|
---|
| 171 | ; Nothing
|
---|
| 172 | ;--------------------------------------------------------------------
|
---|
| 173 | AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI:
|
---|
| 174 | eMOVZX bx, [di+DPT_ADVANCED_ATA.bPioMode]
|
---|
| 175 | mov cx, [di+DPT_ADVANCED_ATA.wMinPioCycleTime]
|
---|
| 176 | test si, si
|
---|
[568] | 177 | jz SHORT .PioTimingsLoadedToBXandCX
|
---|
[392] | 178 | MIN_U bl, [si+DPT_ADVANCED_ATA.bPioMode]
|
---|
| 179 | MAX_U cx, [si+DPT_ADVANCED_ATA.wMinPioCycleTime]
|
---|
[568] | 180 | .PioTimingsLoadedToBXandCX:
|
---|
[392] | 181 | ret
|
---|