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
|
---|
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 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 | ;--------------------------------------------------------------------
|
---|
61 | ALIGN JUMP_ALIGN
|
---|
62 | ResetIdevarsToDefaultValues:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
94 | ALIGN JUMP_ALIGN
|
---|
95 | DetectIdePortsAndDevices:
|
---|
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 | add si, IDEVARS_size
|
---|
117 | cmp si, ROMVARS.ideVars3
|
---|
118 | jbe SHORT .DetectFromNextPort
|
---|
119 | .AllPortsAlreadyDetected:
|
---|
120 | ret
|
---|
121 |
|
---|
122 |
|
---|
123 | ;--------------------------------------------------------------------
|
---|
124 | ; StoreAndDisplayNumberOfControllers
|
---|
125 | ; Parameters:
|
---|
126 | ; CX: Number of controllers detected
|
---|
127 | ; DS:DI: Ptr to ROMVARS
|
---|
128 | ; SS:BP: Ptr to MENU
|
---|
129 | ; Returns:
|
---|
130 | ; Nothing
|
---|
131 | ; Corrupts registers:
|
---|
132 | ; AX, BX, DX, DI, SI, DS, ES
|
---|
133 | ;--------------------------------------------------------------------
|
---|
134 | ALIGN JUMP_ALIGN
|
---|
135 | StoreAndDisplayNumberOfControllers:
|
---|
136 | mov ax, 1
|
---|
137 | MAX_U al, cl ; Cannot store zero
|
---|
138 | test BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
139 | jnz SHORT .FullModeSoNoNeedToLimit
|
---|
140 | MIN_U al, MAX_LITE_MODE_CONTROLLERS
|
---|
141 | .FullModeSoNoNeedToLimit:
|
---|
142 |
|
---|
143 | ; Store number of IDE Controllers. This will also modify
|
---|
144 | ; menu and set unsaved changes flag.
|
---|
145 | push cs
|
---|
146 | pop ds
|
---|
147 | mov si, g_MenuitemConfigurationIdeControllers
|
---|
148 | call Menuitem_StoreValueFromAXtoMenuitemInDSSI
|
---|
149 |
|
---|
150 | ; Display results (should be changed to proper string formatting)
|
---|
151 | add cl, '0'
|
---|
152 | mov [cs:g_bControllersDetected], cl
|
---|
153 | mov dx, g_szDlgAutoConfigure
|
---|
154 | jmp Dialogs_DisplayNotificationFromCSDX
|
---|