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

Last change on this file since 531 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 6.0 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 ResetIdevarsToDefaultValues
44 call DetectIdePortsAndDevices
45 call EnableInterruptsForPrimaryAndSecondaryControllers
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; Returns:
58; Nothing
59; Corrupts registers:
60; AX, CX
61;--------------------------------------------------------------------
62ALIGN JUMP_ALIGN
63ResetIdevarsToDefaultValues:
64 push di
65 add di, BYTE ROMVARS.ideVarsBegin
66 mov cx, ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin
67 call Memory_ZeroESDIwithSizeInCX ; Never clears ROMVARS.ideVarsSerialAuto
68 pop di
69
70 ; Set default values (other than zero)
71 mov ax, DISABLE_WRITE_CACHE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) | FLG_DRVPARAMS_BLOCKMODE
72 mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
73 mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
74
75 mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
76 mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
77
78 mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
79 mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
80
81 mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
82 mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
83 ret
84
85
86;--------------------------------------------------------------------
87; DetectIdePortsAndDevices
88; Parameters:
89; DS:DI: Ptr to ROMVARS
90; Returns:
91; CX: Number of controllers detected
92; Corrupts registers:
93; AX, BX, DX, SI
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
96DetectIdePortsAndDevices:
97 xor cx, cx ; Number of devices found
98 xor dx, dx ; IDE_PORT_TO_START_DETECTION
99 lea si, [di+ROMVARS.ideVarsBegin] ; DS:SI points to first IDEVARS
100
101.DetectFromNextPort:
102 call IdeAutodetect_IncrementDXtoNextIdeBasePort
103 jz SHORT .AllPortsAlreadyDetected
104 push si
105 call IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInSI
106 mov bx, si
107 pop si
108 jc SHORT .DetectFromNextPort
109
110 ; Device found from port DX, Device Type returned in AL
111 inc cx ; Increment number of controllers found
112 mov [si+IDEVARS.wBasePort], dx
113 mov [si+IDEVARS.wControlBlockPort], bx
114 mov [si+IDEVARS.bDevice], al
115
116 ; Point to next IDEVARS
117 add si, IDEVARS_size
118 cmp si, ROMVARS.ideVars3
119 jbe SHORT .DetectFromNextPort
120.AllPortsAlreadyDetected:
121 ret
122
123
124;--------------------------------------------------------------------
125; EnableInterruptsForPrimaryAndSecondaryControllers
126; Parameters:
127; DS:DI: Ptr to ROMVARS
128; CX: Number of controllers detected
129; Returns:
130; Nothing
131; Corrupts registers:
132; AX, ES
133;--------------------------------------------------------------------
134ALIGN JUMP_ALIGN
135EnableInterruptsForPrimaryAndSecondaryControllers:
136 jcxz .NoControllersDetected
137 call Buffers_IsXTbuildLoaded
138 je SHORT .DoNotEnableIRQforXTbuilds
139 push di
140 push cx
141
142 add di, BYTE ROMVARS.ideVars0 ; DS:DI now points first IDEVARS
143.CheckNextController:
144 mov al, 14
145 cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_PRIMARY_PORT
146 je SHORT .EnableIrqAL
147
148 inc ax ; 15
149 cmp WORD [di+IDEVARS.wBasePort], DEVICE_ATA_SECONDARY_PORT
150 jne SHORT .DoNotEnableIRQ
151
152.EnableIrqAL:
153 mov [di+IDEVARS.bIRQ], al
154.DoNotEnableIRQ:
155 loop .CheckNextController
156 pop cx
157 pop di
158.DoNotEnableIRQforXTbuilds:
159.NoControllersDetected:
160 ret
161
162
163;--------------------------------------------------------------------
164; StoreAndDisplayNumberOfControllers
165; Parameters:
166; CX: Number of controllers detected
167; DS:DI: Ptr to ROMVARS
168; SS:BP: Ptr to MENU
169; Returns:
170; Nothing
171; Corrupts registers:
172; AX, BX, DX, DI, SI, DS, ES
173;--------------------------------------------------------------------
174ALIGN JUMP_ALIGN
175StoreAndDisplayNumberOfControllers:
176 xor ax, ax
177 or al, cl
178 jnz SHORT .AtLeastOneController
179 inc ax ; Cannot store zero
180.AtLeastOneController:
181 test BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
182 jnz SHORT .FullModeSoNoNeedToLimit
183 MIN_U al, MAX_LITE_MODE_CONTROLLERS
184.FullModeSoNoNeedToLimit:
185
186 ; Store number of IDE Controllers. This will also modify
187 ; menu and set unsaved changes flag.
188 push cs
189 pop ds
190 mov si, g_MenuitemConfigurationIdeControllers
191 call Menuitem_StoreValueFromAXtoMenuitemInDSSI
192
193 ; Display results (should be changed to proper string formatting)
194 add cl, '0'
195 mov [cs:g_bControllersDetected], cl
196 mov dx, g_szDlgAutoConfigure
197 jmp Dialogs_DisplayNotificationFromCSDX
Note: See TracBrowser for help on using the repository browser.