source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm@ 616

Last change on this file since 616 was 614, checked in by Krister Nordvall, 3 years ago

Changes:

  • BIOSDRVS should now build again (broke in r613).
  • Removed the NO_ATAID_CORRECTION define from the Tiny build.
  • Added a new configuration option to skip detection of slave drives.
  • Made FLASH_SIGNATURE 2 bytes shorter to free up ROM space.
  • "Auto Configure" in XTIDECFG should now detect if running on an Olivetti M24, AT&T PC6300, Xerox 6060 or Logabax Persona 1600 and automatically select the fastest compatible transfer mode/device type for any IDE controllers found in the system.
  • Cleaned out some duplicate/unused definitions.
File size: 8.9 KB
Line 
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
22SECTION .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;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36AutoConfigure_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 ChecksumSystemBios
44 call DetectOlivettiM24
45 call ResetIdevarsToDefaultValues
46 call DetectIdePortsAndDevices
47 call EnableInterruptsForAllStandardControllers
48 call StoreAndDisplayNumberOfControllers
49
50 pop ds
51 pop es
52.Return:
53 ret
54
55
56;--------------------------------------------------------------------
57; ChecksumSystemBios
58; Parameters:
59; DS:DI: Ptr to ROMVARS
60; Returns:
61; Nothing
62; Corrupts registers:
63; AX, BX, CX, DX, SI
64;--------------------------------------------------------------------
65ALIGN JUMP_ALIGN
66ChecksumSystemBios:
67 push ds
68 mov si, 0F000h
69 mov ds, si
70 mov si, 0FFFFh
71 ; DS:SI now points to the end of the System BIOS.
72 std
73 mov cx, 32768 ; The smallest known problematic BIOS so far.
74 mov dx, si ; Initialize the checksum
75 call CalculateCRC_CCITTfromDSSIwithSizeInCX
76 pop ds
77 mov bx, .Checksums
78 cld
79.NextChecksum:
80 mov ax, [cs:bx]
81 test ax, ax
82 jz SHORT AutoConfigure_ForThisSystem.Return
83 inc bx
84 inc bx
85 cmp ax, dx
86 jne SHORT .NextChecksum
87 or BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_CLEAR_BDA_HD_COUNT
88 mov dx, g_szDlgBadBiosFound
89 jmp Dialogs_DisplayNotificationFromCSDX
90
91ALIGN WORD_ALIGN
92.Checksums:
93 dw 0D192h ; 32 KB Zenith Z-161 (071784)
94 dw 02F69h ; 32 KB Zenith Z-171 (031485)
95 dw 0
96
97
98;--------------------------------------------------------------------
99; CalculateCRC_CCITTfromDSSIwithSizeInCX
100; Parameters:
101; DS:SI: Pointer to string to checksum
102; CX: Length of string to checksum
103; DX: Checksum (initially 0FFFFh)
104; DF: Set/Clear depending on direction wanted
105; Returns:
106; DX: Checksum
107; DS:SI: Pointer to byte after the end of checksummed string
108; Corrupts registers:
109; AX, BX, CX
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112CalculateCRC_CCITTfromDSSIwithSizeInCX:
113; jcxz .Return
114 xor bh, bh
115 mov ah, 0E0h
116.NextByte:
117 lodsb
118 xor dh, al
119 mov bl, dh
120 rol bx, 1
121 rol bx, 1
122 rol bx, 1
123 rol bx, 1
124 xor dx, bx
125 rol bx, 1
126 xchg dh, dl
127 xor dx, bx
128 ror bx, 1
129 ror bx, 1
130 ror bx, 1
131 ror bx, 1
132 and bl, ah
133 xor dx, bx
134 ror bx, 1
135 xor dh, bl
136 loop .NextByte
137;.Return:
138 ret
139
140
141;--------------------------------------------------------------------
142; DetectOlivettiM24
143; Parameters:
144; Nothing
145; Returns:
146; ZF: Set if computer is not an Olivetti M24
147; Clear if computer is an Olivetti M24
148; Corrupts registers:
149; AX, BX, CX, DX
150;--------------------------------------------------------------------
151ALIGN JUMP_ALIGN
152DetectOlivettiM24:
153 mov ah, 0FEh ; Request the current date and time
154 mov ch, 0FFh ; Set the hours to an invalid value
155 int BIOS_TIME_PCI_PNP_INTERRUPT_1Ah
156 inc ch ; Hours changed?
157 jz SHORT .ThisIsNotAnOlivettiM24
158 mov BYTE [cs:IsOlivettiM24], 1
159.ThisIsNotAnOlivettiM24:
160 ret
161
162IsOlivettiM24:
163 db 0
164
165
166;--------------------------------------------------------------------
167; ResetIdevarsToDefaultValues
168; Parameters:
169; DS:DI: Ptr to ROMVARS
170; ES:DI: Ptr to ROMVARS
171; Returns:
172; Nothing
173; Corrupts registers:
174; AX, CX
175;--------------------------------------------------------------------
176ALIGN JUMP_ALIGN
177ResetIdevarsToDefaultValues:
178 push di
179 add di, BYTE ROMVARS.ideVarsBegin
180 mov cx, ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin
181 call Memory_ZeroESDIwithSizeInCX ; Never clears ROMVARS.ideVarsSerialAuto
182 pop di
183
184 ; Set default values (other than zero)
185 mov ax, DISABLE_WRITE_CACHE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) | FLG_DRVPARAMS_BLOCKMODE
186 mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
187 mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
188
189 mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
190 mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
191
192 mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
193 mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
194
195 mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
196 mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
197 ret
198
199
200;--------------------------------------------------------------------
201; DetectIdePortsAndDevices
202; Parameters:
203; DS:DI: Ptr to ROMVARS
204; Returns:
205; CX: Number of controllers detected
206; Corrupts registers:
207; AX, BX, DX, SI
208;--------------------------------------------------------------------
209ALIGN JUMP_ALIGN
210DetectIdePortsAndDevices:
211 xor cx, cx ; Number of devices found
212 xor dx, dx ; IDE_PORT_TO_START_DETECTION
213 lea si, [di+ROMVARS.ideVarsBegin] ; DS:SI points to first IDEVARS
214
215.DetectFromNextPort:
216 call IdeAutodetect_IncrementDXtoNextIdeBasePort
217 jz SHORT .AllPortsAlreadyDetected
218 push si
219 call IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInSI
220 mov bx, si
221 pop si
222 jc SHORT .DetectFromNextPort
223
224 ; Device found from port DX, Device Type returned in AL
225 inc cx ; Increment number of controllers found
226 mov [si+IDEVARS.wBasePort], dx
227 mov [si+IDEVARS.wControlBlockPort], bx
228 mov [si+IDEVARS.bDevice], al
229
230 ; Point to next IDEVARS
231 add si, IDEVARS_size
232 cmp si, ROMVARS.ideVars3
233 jbe SHORT .DetectFromNextPort
234.AllPortsAlreadyDetected:
235 ret
236
237
238;--------------------------------------------------------------------
239; EnableInterruptsForAllStandardControllers
240; Parameters:
241; DS:DI: Ptr to ROMVARS
242; CX: Number of controllers detected
243; Returns:
244; Nothing
245; Corrupts registers:
246; AX
247;--------------------------------------------------------------------
248ALIGN JUMP_ALIGN
249EnableInterruptsForAllStandardControllers:
250 jcxz .NoControllersDetected
251 call Buffers_IsXTbuildLoaded
252 je SHORT .DoNotEnableIRQforXTbuilds
253 push di
254 push cx
255
256 add di, BYTE ROMVARS.ideVars0 ; DS:DI now points first IDEVARS
257.CheckNextController:
258 mov al, 14
259 cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_PRIMARY_PORT
260 je SHORT .EnableIrqAL
261
262 inc ax ; 15
263 cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_SECONDARY_PORT
264
265%if 0
266 je SHORT .EnableIrqAL
267
268 ; Defaults on the GSI Inc. Model 2C EIDE controller
269 mov al, 11
270 cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_TERTIARY_PORT
271 je SHORT .EnableIrqAL
272
273 dec ax ; 10
274 cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_QUATERNARY_PORT
275%endif
276
277 jne SHORT .DoNotEnableIRQ
278
279.EnableIrqAL:
280 mov [di+IDEVARS.bIRQ], al
281.DoNotEnableIRQ:
282 add di, IDEVARS_size
283 loop .CheckNextController
284 pop cx
285 pop di
286.DoNotEnableIRQforXTbuilds:
287.NoControllersDetected:
288 ret
289
290
291;--------------------------------------------------------------------
292; StoreAndDisplayNumberOfControllers
293; Parameters:
294; CX: Number of controllers detected
295; DS:DI: Ptr to ROMVARS
296; SS:BP: Ptr to MENU
297; Returns:
298; Nothing
299; Corrupts registers:
300; AX, BX, DX, DI, SI, DS, ES
301;--------------------------------------------------------------------
302ALIGN JUMP_ALIGN
303StoreAndDisplayNumberOfControllers:
304 xor ax, ax
305 or al, cl
306 jnz SHORT .AtLeastOneController
307 inc ax ; Cannot store zero
308.AtLeastOneController:
309 test BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
310 jnz SHORT .FullModeSoNoNeedToLimit
311 MIN_U al, MAX_LITE_MODE_CONTROLLERS
312.FullModeSoNoNeedToLimit:
313
314 ; Store number of IDE Controllers. This will also modify
315 ; menu and set unsaved changes flag.
316 push cs
317 pop ds
318 mov si, g_MenuitemConfigurationIdeControllers
319 call Menuitem_StoreValueFromAXtoMenuitemInDSSI
320
321 ; Display results (should be changed to proper string formatting)
322 add cl, '0'
323 mov [cs:g_bControllersDetected], cl
324 mov dx, g_szDlgAutoConfigure
325 jmp Dialogs_DisplayNotificationFromCSDX
Note: See TracBrowser for help on using the repository browser.