[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: |
---|
| 35 | ; BX |
---|
| 36 | ;-------------------------------------------------------------------- |
---|
| 37 | AdvAtaInit_DetectControllerForIdeBaseInBX: |
---|
| 38 | call Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent |
---|
| 39 | jne SHORT .NoAdvancedControllerForPortBX |
---|
| 40 | call Vision_DoesIdePortInBXbelongToControllerWithIDinAX |
---|
| 41 | jne SHORT .NoAdvancedControllerForPortBX |
---|
[587] | 42 | call PDC20x30_DetectControllerForIdeBaseInBX |
---|
| 43 | jnc SHORT .NoAdvancedControllerForPortBX |
---|
[392] | 44 | |
---|
| 45 | stc ; Advanced Controller found for port BX |
---|
| 46 | ret |
---|
| 47 | |
---|
| 48 | .NoAdvancedControllerForPortBX: |
---|
| 49 | xor ax, ax |
---|
| 50 | ret |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | ;-------------------------------------------------------------------- |
---|
[564] | 54 | ; AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX |
---|
[392] | 55 | ; Parameters: |
---|
| 56 | ; AX: ID WORD specific for detected controller |
---|
| 57 | ; Returns: |
---|
| 58 | ; AL: Max supported PIO mode |
---|
| 59 | ; AH: FLGH_DPT_IORDY if IORDY supported, zero otherwise |
---|
[582] | 60 | ; BX: Min PIO cycle time (only if ZF set) |
---|
| 61 | ; ZF: Set if PIO limit necessary |
---|
[392] | 62 | ; Cleared if no need to limit timings |
---|
| 63 | ; Corrupts registers: |
---|
[582] | 64 | ; Nothing |
---|
[392] | 65 | ;-------------------------------------------------------------------- |
---|
[587] | 66 | AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX: |
---|
| 67 | cmp ah, ID_QD6580_ALTERNATE |
---|
| 68 | jae SHORT .Vision |
---|
| 69 | jmp PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX |
---|
| 70 | .Vision: |
---|
| 71 | jmp Vision_GetMaxPioModeToALandMinCycleTimeToBX |
---|
[392] | 72 | |
---|
| 73 | |
---|
| 74 | ;-------------------------------------------------------------------- |
---|
| 75 | ; AdvAtaInit_InitializeControllerForDPTinDSDI |
---|
| 76 | ; Parameters: |
---|
| 77 | ; DS:DI: Ptr to DPT for Single or Slave Drive |
---|
| 78 | ; Returns: |
---|
[507] | 79 | ; AH: Int 13h return status |
---|
[392] | 80 | ; CF: Cleared if success or no controller to initialize |
---|
| 81 | ; Set if error |
---|
| 82 | ; Corrupts registers: |
---|
[507] | 83 | ; AL, BX, CX, DX |
---|
[392] | 84 | ;-------------------------------------------------------------------- |
---|
| 85 | AdvAtaInit_InitializeControllerForDPTinDSDI: |
---|
| 86 | ; Call Controller Specific initialization function |
---|
| 87 | mov ax, [di+DPT_ADVANCED_ATA.wControllerID] |
---|
| 88 | test ax, ax |
---|
| 89 | jz SHORT .NoAdvancedController ; Return with CF cleared |
---|
[587] | 90 | |
---|
| 91 | cmp ah, ID_QD6580_ALTERNATE |
---|
| 92 | jae SHORT .Vision |
---|
| 93 | jmp PDC20x30_InitializeForDPTinDSDI |
---|
[392] | 94 | |
---|
[587] | 95 | .Vision: |
---|
[399] | 96 | push bp |
---|
| 97 | push si |
---|
| 98 | |
---|
[392] | 99 | call AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI |
---|
| 100 | call Vision_InitializeWithIDinAHandConfigInAL |
---|
[567] | 101 | xor ax, ax ; Success |
---|
[392] | 102 | |
---|
| 103 | pop si |
---|
| 104 | pop bp |
---|
[399] | 105 | |
---|
| 106 | .NoAdvancedController: |
---|
[392] | 107 | ret |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | ;-------------------------------------------------------------------- |
---|
| 111 | ; AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI |
---|
| 112 | ; Parameters: |
---|
| 113 | ; DS:DI: Ptr to DPT for Single or Slave Drive |
---|
| 114 | ; Returns: |
---|
| 115 | ; SI: Offset to Master DPT if Slave Drive present |
---|
| 116 | ; Zero if Slave Drive not present |
---|
| 117 | ; Corrupts registers: |
---|
| 118 | ; AX |
---|
| 119 | ;-------------------------------------------------------------------- |
---|
| 120 | AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI: |
---|
| 121 | ; Must be Slave Drive if previous DPT has same IDEVARS offset |
---|
| 122 | lea si, [di-LARGEST_DPT_SIZE] ; DS:SI points to previous DPT |
---|
| 123 | mov al, [di+DPT.bIdevarsOffset] |
---|
| 124 | cmp al, [si+DPT.bIdevarsOffset] |
---|
| 125 | je SHORT .MasterAndSlaveDrivePresent |
---|
| 126 | |
---|
| 127 | ; We only have single drive so zero SI |
---|
| 128 | xor si, si |
---|
| 129 | .MasterAndSlaveDrivePresent: |
---|
| 130 | ret |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | ;-------------------------------------------------------------------- |
---|
| 134 | ; AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI |
---|
| 135 | ; Parameters: |
---|
| 136 | ; DS:DI: Ptr to DPT for Single or Slave Drive |
---|
| 137 | ; SI: Offset to Master DPT if Slave Drive present |
---|
| 138 | ; Zero if Slave Drive not present |
---|
| 139 | ; Returns: |
---|
| 140 | ; BX: Best common PIO mode |
---|
| 141 | ; CX: Slowest common PIO Cycle Time in nanosecs |
---|
| 142 | ; Corrupts registers: |
---|
| 143 | ; Nothing |
---|
| 144 | ;-------------------------------------------------------------------- |
---|
| 145 | AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI: |
---|
| 146 | eMOVZX bx, [di+DPT_ADVANCED_ATA.bPioMode] |
---|
| 147 | mov cx, [di+DPT_ADVANCED_ATA.wMinPioCycleTime] |
---|
| 148 | test si, si |
---|
[568] | 149 | jz SHORT .PioTimingsLoadedToBXandCX |
---|
[392] | 150 | MIN_U bl, [si+DPT_ADVANCED_ATA.bPioMode] |
---|
| 151 | MAX_U cx, [si+DPT_ADVANCED_ATA.wMinPioCycleTime] |
---|
[568] | 152 | .PioTimingsLoadedToBXandCX: |
---|
[392] | 153 | ret |
---|