1 | ; Project name : XTIDE Universal BIOS Configurator v2
|
---|
2 | ; Description : Functions to automatically configure XTIDE
|
---|
3 | ; Universal BIOS for current system.
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
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.
|
---|
13 | ;
|
---|
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
|
---|
17 | ; GNU General Public License for more details.
|
---|
18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
19 | ;
|
---|
20 |
|
---|
21 | ; Section containing code
|
---|
22 | SECTION .text
|
---|
23 |
|
---|
24 |
|
---|
25 | ;--------------------------------------------------------------------
|
---|
26 | ; AutoConfigure_ForThisSystem
|
---|
27 | ; MENUITEM activation function (.fnActivate)
|
---|
28 | ; Parameters:
|
---|
29 | ; SS:BP: Ptr to MENU
|
---|
30 | ; Returns:
|
---|
31 | ; Nothing
|
---|
32 | ; Corrupts registers:
|
---|
33 | ; All, except segments
|
---|
34 | ;--------------------------------------------------------------------
|
---|
35 | ALIGN JUMP_ALIGN
|
---|
36 | AutoConfigure_ForThisSystem:
|
---|
37 | push es
|
---|
38 | push ds
|
---|
39 |
|
---|
40 | call Buffers_GetFileBufferToESDI ; ROMVARS now in ES:DI
|
---|
41 | push es
|
---|
42 | pop ds ; ROMVARS now in DS:DI
|
---|
43 | call ResetIdevarsToDefaultValues
|
---|
44 | call DetectIdePortsAndDevices
|
---|
45 | call EnableInterruptsForAllStandardControllers
|
---|
46 | call StoreAndDisplayNumberOfControllers
|
---|
47 |
|
---|
48 | pop ds
|
---|
49 | pop es
|
---|
50 | ret
|
---|
51 |
|
---|
52 |
|
---|
53 | ;--------------------------------------------------------------------
|
---|
54 | ; ResetIdevarsToDefaultValues
|
---|
55 | ; Parameters:
|
---|
56 | ; DS:DI: Ptr to ROMVARS
|
---|
57 | ; ES:DI: Ptr to ROMVARS
|
---|
58 | ; Returns:
|
---|
59 | ; Nothing
|
---|
60 | ; Corrupts registers:
|
---|
61 | ; AX, CX
|
---|
62 | ;--------------------------------------------------------------------
|
---|
63 | ALIGN JUMP_ALIGN
|
---|
64 | ResetIdevarsToDefaultValues:
|
---|
65 | push di
|
---|
66 | add di, BYTE ROMVARS.ideVarsBegin
|
---|
67 | mov cx, ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin
|
---|
68 | call Memory_ZeroESDIwithSizeInCX ; Never clears ROMVARS.ideVarsSerialAuto
|
---|
69 | pop di
|
---|
70 |
|
---|
71 | ; Set default values (other than zero)
|
---|
72 | mov ax, DISABLE_WRITE_CACHE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) | FLG_DRVPARAMS_BLOCKMODE
|
---|
73 | mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
|
---|
74 | mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
|
---|
75 |
|
---|
76 | mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
|
---|
77 | mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
|
---|
78 |
|
---|
79 | mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
|
---|
80 | mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
|
---|
81 |
|
---|
82 | mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
|
---|
83 | mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
|
---|
84 | ret
|
---|
85 |
|
---|
86 |
|
---|
87 | ;--------------------------------------------------------------------
|
---|
88 | ; DetectIdePortsAndDevices
|
---|
89 | ; Parameters:
|
---|
90 | ; DS:DI: Ptr to ROMVARS
|
---|
91 | ; Returns:
|
---|
92 | ; CX: Number of controllers detected
|
---|
93 | ; Corrupts registers:
|
---|
94 | ; AX, BX, DX, SI
|
---|
95 | ;--------------------------------------------------------------------
|
---|
96 | ALIGN JUMP_ALIGN
|
---|
97 | DetectIdePortsAndDevices:
|
---|
98 | xor cx, cx ; Number of devices found
|
---|
99 | xor dx, dx ; IDE_PORT_TO_START_DETECTION
|
---|
100 | lea si, [di+ROMVARS.ideVarsBegin] ; DS:SI points to first IDEVARS
|
---|
101 |
|
---|
102 | .DetectFromNextPort:
|
---|
103 | call IdeAutodetect_IncrementDXtoNextIdeBasePort
|
---|
104 | jz SHORT .AllPortsAlreadyDetected
|
---|
105 | push si
|
---|
106 | call IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInSI
|
---|
107 | mov bx, si
|
---|
108 | pop si
|
---|
109 | jc SHORT .DetectFromNextPort
|
---|
110 |
|
---|
111 | ; Device found from port DX, Device Type returned in AL
|
---|
112 | inc cx ; Increment number of controllers found
|
---|
113 | mov [si+IDEVARS.wBasePort], dx
|
---|
114 | mov [si+IDEVARS.wControlBlockPort], bx
|
---|
115 | mov [si+IDEVARS.bDevice], al
|
---|
116 |
|
---|
117 | ; Point to next IDEVARS
|
---|
118 | add si, IDEVARS_size
|
---|
119 | cmp si, ROMVARS.ideVars3
|
---|
120 | jbe SHORT .DetectFromNextPort
|
---|
121 | .AllPortsAlreadyDetected:
|
---|
122 | ret
|
---|
123 |
|
---|
124 |
|
---|
125 | ;--------------------------------------------------------------------
|
---|
126 | ; EnableInterruptsForAllStandardControllers
|
---|
127 | ; Parameters:
|
---|
128 | ; DS:DI: Ptr to ROMVARS
|
---|
129 | ; CX: Number of controllers detected
|
---|
130 | ; Returns:
|
---|
131 | ; Nothing
|
---|
132 | ; Corrupts registers:
|
---|
133 | ; AX
|
---|
134 | ;--------------------------------------------------------------------
|
---|
135 | ALIGN JUMP_ALIGN
|
---|
136 | EnableInterruptsForAllStandardControllers:
|
---|
137 | jcxz .NoControllersDetected
|
---|
138 | call Buffers_IsXTbuildLoaded
|
---|
139 | je SHORT .DoNotEnableIRQforXTbuilds
|
---|
140 | push di
|
---|
141 | push cx
|
---|
142 |
|
---|
143 | add di, BYTE ROMVARS.ideVars0 ; DS:DI now points first IDEVARS
|
---|
144 | .CheckNextController:
|
---|
145 | mov al, 14
|
---|
146 | cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_PRIMARY_PORT
|
---|
147 | je SHORT .EnableIrqAL
|
---|
148 |
|
---|
149 | inc ax ; 15
|
---|
150 | cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_SECONDARY_PORT
|
---|
151 |
|
---|
152 | %if 0
|
---|
153 | je SHORT .EnableIrqAL
|
---|
154 |
|
---|
155 | ; Defaults on the GSI Inc. Model 2C EIDE controller
|
---|
156 | mov al, 11
|
---|
157 | cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_TERTIARY_PORT
|
---|
158 | je SHORT .EnableIrqAL
|
---|
159 |
|
---|
160 | dec ax ; 10
|
---|
161 | cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_QUATERNARY_PORT
|
---|
162 | %endif
|
---|
163 |
|
---|
164 | jne SHORT .DoNotEnableIRQ
|
---|
165 |
|
---|
166 | .EnableIrqAL:
|
---|
167 | mov [di+IDEVARS.bIRQ], al
|
---|
168 | .DoNotEnableIRQ:
|
---|
169 | add di, IDEVARS_size
|
---|
170 | loop .CheckNextController
|
---|
171 | pop cx
|
---|
172 | pop di
|
---|
173 | .DoNotEnableIRQforXTbuilds:
|
---|
174 | .NoControllersDetected:
|
---|
175 | ret
|
---|
176 |
|
---|
177 |
|
---|
178 | ;--------------------------------------------------------------------
|
---|
179 | ; StoreAndDisplayNumberOfControllers
|
---|
180 | ; Parameters:
|
---|
181 | ; CX: Number of controllers detected
|
---|
182 | ; DS:DI: Ptr to ROMVARS
|
---|
183 | ; SS:BP: Ptr to MENU
|
---|
184 | ; Returns:
|
---|
185 | ; Nothing
|
---|
186 | ; Corrupts registers:
|
---|
187 | ; AX, BX, DX, DI, SI, DS, ES
|
---|
188 | ;--------------------------------------------------------------------
|
---|
189 | ALIGN JUMP_ALIGN
|
---|
190 | StoreAndDisplayNumberOfControllers:
|
---|
191 | xor ax, ax
|
---|
192 | or al, cl
|
---|
193 | jnz SHORT .AtLeastOneController
|
---|
194 | inc ax ; Cannot store zero
|
---|
195 | .AtLeastOneController:
|
---|
196 | test BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
197 | jnz SHORT .FullModeSoNoNeedToLimit
|
---|
198 | MIN_U al, MAX_LITE_MODE_CONTROLLERS
|
---|
199 | .FullModeSoNoNeedToLimit:
|
---|
200 |
|
---|
201 | ; Store number of IDE Controllers. This will also modify
|
---|
202 | ; menu and set unsaved changes flag.
|
---|
203 | push cs
|
---|
204 | pop ds
|
---|
205 | mov si, g_MenuitemConfigurationIdeControllers
|
---|
206 | call Menuitem_StoreValueFromAXtoMenuitemInDSSI
|
---|
207 |
|
---|
208 | ; Display results (should be changed to proper string formatting)
|
---|
209 | add cl, '0'
|
---|
210 | mov [cs:g_bControllersDetected], cl
|
---|
211 | mov dx, g_szDlgAutoConfigure
|
---|
212 | jmp Dialogs_DisplayNotificationFromCSDX
|
---|