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