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

Last change on this file since 504 was 504, checked in by aitotat@…, 12 years ago

Changes to Configurator v2:

  • Cleaned IDE autodetect code.
File size: 4.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-2012 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 StoreAndDisplayNumberOfControllers
46
47 pop ds
48 pop es
49 ret
50
51
52;--------------------------------------------------------------------
53; ResetIdevarsToDefaultValues
54; Parameters:
55; DS:DI: Ptr to ROMVARS
56; Returns:
57; Nothing
58; Corrupts registers:
59; AX, CX
60;--------------------------------------------------------------------
61ALIGN JUMP_ALIGN
62ResetIdevarsToDefaultValues:
63 push di
64 add di, BYTE ROMVARS.ideVarsBegin
65 mov cx, ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin
66 call Memory_ZeroESDIwithSizeInCX ; Never clears ROMVARS.ideVarsSerialAuto
67 pop di
68
69 ; Set default values (other than zero)
70 mov ax, DISABLE_WRITE_CACHE | (TRANSLATEMODE_AUTO<<TRANSLATEMODE_FIELD_POSITION) | FLG_DRVPARAMS_BLOCKMODE
71 mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
72 mov [di+ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
73
74 mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
75 mov [di+ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
76
77 mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
78 mov [di+ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
79
80 mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags], ax
81 mov [di+ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags], ax
82 ret
83
84
85;--------------------------------------------------------------------
86; DetectIdePortsAndDevices
87; Parameters:
88; DS:DI: Ptr to ROMVARS
89; Returns:
90; CX: Number of controllers detected
91; Corrupts registers:
92; AX, BX, DX, SI
93;--------------------------------------------------------------------
94ALIGN JUMP_ALIGN
95DetectIdePortsAndDevices:
96 xor cx, cx ; Number of devices found
97 xor dx, dx ; IDE_PORT_TO_START_DETECTION
98 lea si, [di+ROMVARS.ideVarsBegin] ; DS:SI points to first IDEVARS
99
100.DetectFromNextPort:
101 call IdeAutodetect_IncrementDXtoNextIdeBasePort
102 jz SHORT .AllPortsAlreadyDetected
103 push si
104 call IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInSI
105 mov bx, si
106 pop si
107 jc SHORT .DetectFromNextPort
108
109 ; Device found from port DX, Device Type returned in AL
110 inc cx ; Increment number of controllers found
111 mov [si+IDEVARS.wBasePort], dx
112 mov [si+IDEVARS.wControlBlockPort], bx
113 mov [si+IDEVARS.bDevice], al
114
115 ; Point to next IDEVARS
116 cmp si, ROMVARS.ideVars3
117 jae SHORT .AllPortsAlreadyDetected
118 add si, IDEVARS_size
119 jmp SHORT .DetectFromNextPort
120.AllPortsAlreadyDetected:
121 ret
122
123
124;--------------------------------------------------------------------
125; StoreAndDisplayNumberOfControllers
126; Parameters:
127; CX: Number of controllers detected
128; DS:DI: Ptr to ROMVARS
129; SS:BP: Ptr to MENU
130; Returns:
131; Nothing
132; Corrupts registers:
133; AX, BX, DX, DI, SI, DS, ES
134;--------------------------------------------------------------------
135ALIGN JUMP_ALIGN
136StoreAndDisplayNumberOfControllers:
137 mov ax, 1
138 MAX_U al, cl ; Cannot store zero
139 test BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
140 jnz SHORT .FullModeSoNoNeedToLimit
141 MIN_U al, MAX_LITE_MODE_CONTROLLERS
142.FullModeSoNoNeedToLimit:
143
144 ; Store number of IDE Controllers. This will also modify
145 ; menu and set unsaved changes flag.
146 push cs
147 pop ds
148 mov si, g_MenuitemConfigurationIdeControllers
149 call Menuitem_StoreValueFromAXtoMenuitemInDSSI
150
151 ; Display results (should be changed to proper string formatting)
152 add cl, '0'
153 mov [cs:g_bControllersDetected], cl
154 mov dx, g_szDlgAutoConfigure
155 jmp Dialogs_DisplayNotificationFromCSDX
Note: See TracBrowser for help on using the repository browser.