1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Sets IDE Device specific parameters to DPT.
|
---|
3 |
|
---|
4 | ;
|
---|
5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
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.
|
---|
12 | ;
|
---|
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
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
18 | ;
|
---|
19 |
|
---|
20 | ; Section containing code
|
---|
21 | SECTION .text
|
---|
22 |
|
---|
23 | ;--------------------------------------------------------------------
|
---|
24 | ; IdeDPT_Finalize
|
---|
25 | ; Parameters:
|
---|
26 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
27 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
28 | ; CS:BP: Ptr to IDEVARS for the controller
|
---|
29 | ; Returns:
|
---|
30 | ; CF: Clear, IDE interface only supports hard disks
|
---|
31 | ; Corrupts registers:
|
---|
32 | ; AX, BX, CX, DX
|
---|
33 | ;--------------------------------------------------------------------
|
---|
34 | IdeDPT_Finalize:
|
---|
35 |
|
---|
36 | %ifdef MODULE_FEATURE_SETS
|
---|
37 | ;--------------------------------------------------------------------
|
---|
38 | ; .DetectPowerManagementSupport
|
---|
39 | ; Parameters:
|
---|
40 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
41 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
42 | ; Returns:
|
---|
43 | ; Nothing
|
---|
44 | ; Corrupts registers:
|
---|
45 | ; Nothing
|
---|
46 | ;--------------------------------------------------------------------
|
---|
47 | .DetectPowerManagementSupport:
|
---|
48 | test BYTE [es:si+ATA6.wSetSup82], A6_wSetSup82_POWERMAN
|
---|
49 | jz .NoPowerManagementSupport
|
---|
50 | or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_POWER_MANAGEMENT_SUPPORTED
|
---|
51 | .NoPowerManagementSupport:
|
---|
52 | %endif ; MODULE_FEATURE_SETS
|
---|
53 |
|
---|
54 | ;--------------------------------------------------------------------
|
---|
55 | ; .StoreBlockMode
|
---|
56 | ; Parameters:
|
---|
57 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
58 | ; Returns:
|
---|
59 | ; Nothing
|
---|
60 | ; Corrupts registers:
|
---|
61 | ; Nothing
|
---|
62 | ;--------------------------------------------------------------------
|
---|
63 | .StoreBlockMode:
|
---|
64 | mov BYTE [di+DPT_ATA.bBlockSize], 1
|
---|
65 |
|
---|
66 | %ifdef MODULE_ADVANCED_ATA
|
---|
67 | ;--------------------------------------------------------------------
|
---|
68 | ; .StoreDeviceType
|
---|
69 | ; Parameters:
|
---|
70 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
71 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
72 | ; CS:BP: Ptr to IDEVARS for the controller
|
---|
73 | ; Returns:
|
---|
74 | ; Nothing
|
---|
75 | ; Corrupts registers:
|
---|
76 | ; Nothing
|
---|
77 | ;--------------------------------------------------------------------
|
---|
78 | .StoreDeviceType:
|
---|
79 | call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
|
---|
80 |
|
---|
81 | ;--------------------------------------------------------------------
|
---|
82 | ; .StorePioModeAndTimings
|
---|
83 | ; Parameters:
|
---|
84 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
85 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
86 | ; CS:BP: Ptr to IDEVARS for the controller
|
---|
87 | ; Returns:
|
---|
88 | ; Nothing
|
---|
89 | ; Corrupts registers:
|
---|
90 | ; AX, BX, CX
|
---|
91 | ;--------------------------------------------------------------------
|
---|
92 | .StorePioMode:
|
---|
93 | call AtaID_GetMaxPioModeToAXandMinCycleTimeToCX
|
---|
94 | mov [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx
|
---|
95 | mov [di+DPT_ADVANCED_ATA.bPioMode], al
|
---|
96 | or [di+DPT.bFlagsHigh], ah
|
---|
97 |
|
---|
98 | ;--------------------------------------------------------------------
|
---|
99 | ; .DetectAdvancedIdeController
|
---|
100 | ; Parameters:
|
---|
101 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
102 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
103 | ; CS:BP: Ptr to IDEVARS for the controller
|
---|
104 | ; Returns:
|
---|
105 | ; Nothing
|
---|
106 | ; Corrupts registers:
|
---|
107 | ; AX, BX, CX, DX
|
---|
108 | ;--------------------------------------------------------------------
|
---|
109 | .DetectAdvancedIdeController:
|
---|
110 | call AccessDPT_GetIdeBasePortToBX
|
---|
111 | call AdvAtaInit_DetectControllerForIdeBaseInBX
|
---|
112 | mov [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
|
---|
113 | mov [di+DPT_ADVANCED_ATA.wControllerBasePort], dx
|
---|
114 | jnc SHORT .NoAdvancedControllerDetected
|
---|
115 |
|
---|
116 | ; Use highest common PIO mode from controller and drive.
|
---|
117 | ; Many VLB controllers support PIO modes up to 2.
|
---|
118 | call AdvAtaInit_GetControllerMaxPioModeToAL
|
---|
119 | jnc SHORT .ChangeTo32bitDevice
|
---|
120 | and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_IORDY ; No IORDY supported if need to limit
|
---|
121 | MIN_U [di+DPT_ADVANCED_ATA.bPioMode], al
|
---|
122 |
|
---|
123 | ; We have detected 32-bit controller so change Device Type since
|
---|
124 | ; it might have been set to 16-bit on IDEVARS
|
---|
125 | .ChangeTo32bitDevice:
|
---|
126 | mov BYTE [di+DPT_ADVANCED_ATA.bDevice], DEVICE_32BIT_ATA
|
---|
127 |
|
---|
128 | .NoAdvancedControllerDetected:
|
---|
129 |
|
---|
130 | %endif ; MODULE_ADVANCED_ATA
|
---|
131 |
|
---|
132 | ;--------------------------------------------------------------------
|
---|
133 | ; IdeDPT_StoreReversedAddressLinesFlagIfNecessary
|
---|
134 | ; Parameters:
|
---|
135 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
136 | ; CS:BP: Ptr to IDEVARS for the controller
|
---|
137 | ; Returns:
|
---|
138 | ; CF: Always clear
|
---|
139 | ; Corrupts registers:
|
---|
140 | ; Nothing
|
---|
141 | ;--------------------------------------------------------------------
|
---|
142 | IdeDPT_StoreReversedAddressLinesFlagIfNecessary:
|
---|
143 | cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_XTIDE_REV2
|
---|
144 | je SHORT .SetFlagForSwappedA0andA3
|
---|
145 | cmp BYTE [cs:bp+IDEVARS.bDevice], DEVICE_FAST_XTIDE
|
---|
146 | jne SHORT .EndDPT
|
---|
147 | .SetFlagForSwappedA0andA3:
|
---|
148 | or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3
|
---|
149 | .EndDPT:
|
---|
150 | clc
|
---|
151 | ret
|
---|
152 |
|
---|
153 |
|
---|
154 | %ifdef MODULE_ADVANCED_ATA
|
---|
155 | ;--------------------------------------------------------------------
|
---|
156 | ; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
|
---|
157 | ; Parameters:
|
---|
158 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
159 | ; CS:BP: Ptr to IDEVARS for the controller
|
---|
160 | ; Returns:
|
---|
161 | ; Nothing
|
---|
162 | ; Corrupts registers:
|
---|
163 | ; AL
|
---|
164 | ;--------------------------------------------------------------------
|
---|
165 | IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI:
|
---|
166 | mov al, [cs:bp+IDEVARS.bDevice]
|
---|
167 | mov [di+DPT_ADVANCED_ATA.bDevice], al
|
---|
168 | ret
|
---|
169 |
|
---|
170 | %endif
|
---|