1 | ; Project name : XTIDE Universal BIOS Configurator v2
|
---|
2 | ; Description : "Configure XTIDE Universal BIOS" menu structs and functions.
|
---|
3 |
|
---|
4 | ;
|
---|
5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
|
---|
7 | ;
|
---|
8 | ; This program is free software; you can redistribute it and/or modify
|
---|
9 | ; it under the terms of the GNU General Public License as published by
|
---|
10 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
11 | ; (at your option) any later version.
|
---|
12 | ;
|
---|
13 | ; This program is distributed in the hope that it will be useful,
|
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
18 | ;
|
---|
19 |
|
---|
20 | ; Section containing initialized data
|
---|
21 | SECTION .data
|
---|
22 |
|
---|
23 | ALIGN WORD_ALIGN
|
---|
24 | g_MenupageForConfigurationMenu:
|
---|
25 | istruc MENUPAGE
|
---|
26 | at MENUPAGE.fnEnter, dw ConfigurationMenu_EnterMenuOrModifyItemVisibility
|
---|
27 | at MENUPAGE.fnBack, dw MainMenu_EnterMenuOrModifyItemVisibility
|
---|
28 | at MENUPAGE.wMenuitems, dw 9
|
---|
29 | iend
|
---|
30 |
|
---|
31 | g_MenuitemConfigurationBackToMainMenu:
|
---|
32 | istruc MENUITEM
|
---|
33 | at MENUITEM.fnActivate, dw MainMenu_EnterMenuOrModifyItemVisibility
|
---|
34 | at MENUITEM.szName, dw g_szItemCfgBackToMain
|
---|
35 | at MENUITEM.szQuickInfo, dw g_szItemCfgBackToMain
|
---|
36 | at MENUITEM.szHelp, dw g_szItemCfgBackToMain
|
---|
37 | at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
|
---|
38 | at MENUITEM.bType, db TYPE_MENUITEM_PAGEBACK
|
---|
39 | iend
|
---|
40 |
|
---|
41 | g_MenuitemConfigurationPrimaryIdeController:
|
---|
42 | istruc MENUITEM
|
---|
43 | at MENUITEM.fnActivate, dw PrimaryIdeController
|
---|
44 | at MENUITEM.szName, dw g_szItemCfgIde1
|
---|
45 | at MENUITEM.szQuickInfo, dw g_szNfoCfgIde
|
---|
46 | at MENUITEM.szHelp, dw g_szNfoCfgIde
|
---|
47 | at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
|
---|
48 | at MENUITEM.bType, db TYPE_MENUITEM_PAGENEXT
|
---|
49 | iend
|
---|
50 |
|
---|
51 | g_MenuitemConfigurationSecondaryIdeController:
|
---|
52 | istruc MENUITEM
|
---|
53 | at MENUITEM.fnActivate, dw SecondaryIdeController
|
---|
54 | at MENUITEM.szName, dw g_szItemCfgIde2
|
---|
55 | at MENUITEM.szQuickInfo, dw g_szNfoCfgIde
|
---|
56 | at MENUITEM.szHelp, dw g_szNfoCfgIde
|
---|
57 | at MENUITEM.bFlags, db NULL
|
---|
58 | at MENUITEM.bType, db TYPE_MENUITEM_PAGENEXT
|
---|
59 | iend
|
---|
60 |
|
---|
61 | g_MenuitemConfigurationTertiaryIdeController:
|
---|
62 | istruc MENUITEM
|
---|
63 | at MENUITEM.fnActivate, dw TertiaryIdeController
|
---|
64 | at MENUITEM.szName, dw g_szItemCfgIde3
|
---|
65 | at MENUITEM.szQuickInfo, dw g_szNfoCfgIde
|
---|
66 | at MENUITEM.szHelp, dw g_szNfoCfgIde
|
---|
67 | at MENUITEM.bFlags, db NULL
|
---|
68 | at MENUITEM.bType, db TYPE_MENUITEM_PAGENEXT
|
---|
69 | iend
|
---|
70 |
|
---|
71 | g_MenuitemConfigurationQuaternaryIdeController:
|
---|
72 | istruc MENUITEM
|
---|
73 | at MENUITEM.fnActivate, dw QuaternaryIdeController
|
---|
74 | at MENUITEM.szName, dw g_szItemCfgIde4
|
---|
75 | at MENUITEM.szQuickInfo, dw g_szNfoCfgIde
|
---|
76 | at MENUITEM.szHelp, dw g_szNfoCfgIde
|
---|
77 | at MENUITEM.bFlags, db NULL
|
---|
78 | at MENUITEM.bType, db TYPE_MENUITEM_PAGENEXT
|
---|
79 | iend
|
---|
80 |
|
---|
81 | g_MenuitemConfigurationBootMenuSettings:
|
---|
82 | istruc MENUITEM
|
---|
83 | at MENUITEM.fnActivate, dw BootMenuSettingsMenu_EnterMenuOrModifyItemVisibility
|
---|
84 | at MENUITEM.szName, dw g_szItemCfgBootMenu
|
---|
85 | at MENUITEM.szQuickInfo, dw g_szNfoCfgBootMenu
|
---|
86 | at MENUITEM.szHelp, dw g_szNfoCfgBootMenu
|
---|
87 | at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
|
---|
88 | at MENUITEM.bType, db TYPE_MENUITEM_PAGENEXT
|
---|
89 | iend
|
---|
90 |
|
---|
91 | g_MenuitemConfigurationFullOperatingMode:
|
---|
92 | istruc MENUITEM
|
---|
93 | at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
|
---|
94 | at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
|
---|
95 | at MENUITEM.szName, dw g_szItemCfgFullMode
|
---|
96 | at MENUITEM.szQuickInfo, dw g_szNfoCfgFullMode
|
---|
97 | at MENUITEM.szHelp, dw g_szHelpCfgFullMode
|
---|
98 | at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
|
---|
99 | at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
|
---|
100 | at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw ROMVARS.wFlags
|
---|
101 | at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgCfgFullMode
|
---|
102 | at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceBooleanFlag
|
---|
103 | at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForFlagBooleans
|
---|
104 | at MENUITEM.itemValue + ITEM_VALUE.wValueBitmask, dw FLG_ROMVARS_FULLMODE
|
---|
105 | iend
|
---|
106 |
|
---|
107 | g_MenuitemConfigurationKiBtoStealFromRAM:
|
---|
108 | istruc MENUITEM
|
---|
109 | at MENUITEM.fnActivate, dw Menuitem_ActivateUnsignedInputForMenuitemInDSSI
|
---|
110 | at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
|
---|
111 | at MENUITEM.szName, dw g_szItemCfgStealSize
|
---|
112 | at MENUITEM.szQuickInfo, dw g_szNfoCfgStealSize
|
---|
113 | at MENUITEM.szHelp, dw g_szHelpCfgStealSize
|
---|
114 | at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
|
---|
115 | at MENUITEM.bType, db TYPE_MENUITEM_UNSIGNED
|
---|
116 | at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw ROMVARS.bStealSize
|
---|
117 | at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgCfgStealSize
|
---|
118 | at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 1
|
---|
119 | at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw 255
|
---|
120 | iend
|
---|
121 |
|
---|
122 | g_MenuitemConfigurationIdeControllers:
|
---|
123 | istruc MENUITEM
|
---|
124 | at MENUITEM.fnActivate, dw ActivateInputForNumberOfIdeControllersMenuitemInDSSI
|
---|
125 | at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
|
---|
126 | at MENUITEM.szName, dw g_szItemCfgIdeCnt
|
---|
127 | at MENUITEM.szQuickInfo, dw g_szNfoCfgIdeCnt
|
---|
128 | at MENUITEM.szHelp, dw g_szNfoCfgIdeCnt
|
---|
129 | at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
|
---|
130 | at MENUITEM.bType, db TYPE_MENUITEM_UNSIGNED
|
---|
131 | at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw ROMVARS.bIdeCnt
|
---|
132 | at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgCfgIdeCnt
|
---|
133 | at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 1
|
---|
134 | at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw MAX_ALLOWED_IDE_CONTROLLERS
|
---|
135 | iend
|
---|
136 |
|
---|
137 |
|
---|
138 | ; Section containing code
|
---|
139 | SECTION .text
|
---|
140 |
|
---|
141 | ;--------------------------------------------------------------------
|
---|
142 | ; MainMenu_EnterMenuOrModifyItemVisibility
|
---|
143 | ; Parameters:
|
---|
144 | ; SS:BP: Menu handle
|
---|
145 | ; Returns:
|
---|
146 | ; Nothing
|
---|
147 | ; Corrupts registers:
|
---|
148 | ; All, except BP
|
---|
149 | ;--------------------------------------------------------------------
|
---|
150 | ALIGN JUMP_ALIGN
|
---|
151 | ConfigurationMenu_EnterMenuOrModifyItemVisibility:
|
---|
152 | push cs
|
---|
153 | pop ds
|
---|
154 | call .DisableAllIdeControllerMenuitems
|
---|
155 | call .EnableIdeControllerMenuitemsBasedOnConfiguration
|
---|
156 | call .EnableOrDisableKiBtoStealFromRAM
|
---|
157 | call LimitIdeControllersForLiteMode
|
---|
158 | mov si, g_MenupageForConfigurationMenu
|
---|
159 | jmp Menupage_ChangeToNewMenupageInDSSI
|
---|
160 |
|
---|
161 | ;--------------------------------------------------------------------
|
---|
162 | ; .DisableAllIdeControllerMenuitems
|
---|
163 | ; .EnableIdeControllerMenuitemsBasedOnConfiguration
|
---|
164 | ; Parameters:
|
---|
165 | ; SS:BP: Menu handle
|
---|
166 | ; Returns:
|
---|
167 | ; Nothing
|
---|
168 | ; Corrupts registers:
|
---|
169 | ; AX, BX, CX, DI, ES
|
---|
170 | ;--------------------------------------------------------------------
|
---|
171 | ALIGN JUMP_ALIGN
|
---|
172 | .DisableAllIdeControllerMenuitems:
|
---|
173 | mov cx, MAX_ALLOWED_IDE_CONTROLLERS-1
|
---|
174 | mov bx, g_MenuitemConfigurationSecondaryIdeController
|
---|
175 | ALIGN JUMP_ALIGN
|
---|
176 | .DisableNextIdeControllerMenuitem:
|
---|
177 | call .DisableMenuitemFromCSBX
|
---|
178 | add bx, BYTE MENUITEM_size
|
---|
179 | loop .DisableNextIdeControllerMenuitem
|
---|
180 | ret
|
---|
181 |
|
---|
182 | ALIGN JUMP_ALIGN
|
---|
183 | .EnableIdeControllerMenuitemsBasedOnConfiguration:
|
---|
184 | call Buffers_GetIdeControllerCountToCX
|
---|
185 | dec cx ; Primary always enabled
|
---|
186 | jz SHORT .PrimaryControllerAlreadyEnabled
|
---|
187 | mov bx, g_MenuitemConfigurationSecondaryIdeController
|
---|
188 | ALIGN JUMP_ALIGN
|
---|
189 | .EnableNextIdeControllerMenuitem:
|
---|
190 | call .EnableMenuitemFromCSBX
|
---|
191 | add bx, BYTE MENUITEM_size
|
---|
192 | loop .EnableNextIdeControllerMenuitem
|
---|
193 | .PrimaryControllerAlreadyEnabled:
|
---|
194 | ret
|
---|
195 |
|
---|
196 |
|
---|
197 | ;--------------------------------------------------------------------
|
---|
198 | ; .EnableOrDisableKiBtoStealFromRAM
|
---|
199 | ; Parameters:
|
---|
200 | ; SS:BP: Menu handle
|
---|
201 | ; Returns:
|
---|
202 | ; Nothing
|
---|
203 | ; Corrupts registers:
|
---|
204 | ; AX, BX, CX
|
---|
205 | ;--------------------------------------------------------------------
|
---|
206 | ALIGN JUMP_ALIGN
|
---|
207 | .EnableOrDisableKiBtoStealFromRAM:
|
---|
208 | call Buffers_GetRomvarsFlagsToAX
|
---|
209 | mov bx, g_MenuitemConfigurationKiBtoStealFromRAM
|
---|
210 | test ax, FLG_ROMVARS_FULLMODE
|
---|
211 | jz SHORT .DisableMenuitemFromCSBX
|
---|
212 | ; Fall to .EnableMenuitemFromCSBX
|
---|
213 |
|
---|
214 |
|
---|
215 | ;--------------------------------------------------------------------
|
---|
216 | ; .EnableMenuitemFromCSBX
|
---|
217 | ; .DisableMenuitemFromCSBX
|
---|
218 | ; Parameters:
|
---|
219 | ; CS:BX: Ptr to MENUITEM
|
---|
220 | ; Returns:
|
---|
221 | ; Nothing
|
---|
222 | ; Corrupts registers:
|
---|
223 | ; Nothing
|
---|
224 | ;--------------------------------------------------------------------
|
---|
225 | ALIGN JUMP_ALIGN
|
---|
226 | .EnableMenuitemFromCSBX:
|
---|
227 | or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
|
---|
228 | ret
|
---|
229 |
|
---|
230 | ALIGN JUMP_ALIGN
|
---|
231 | .DisableMenuitemFromCSBX:
|
---|
232 | and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
|
---|
233 | ret
|
---|
234 |
|
---|
235 |
|
---|
236 |
|
---|
237 | ;--------------------------------------------------------------------
|
---|
238 | ; MENUITEM activation functions (.fnActivate)
|
---|
239 | ; Parameters:
|
---|
240 | ; SS:BP: Ptr to MENU
|
---|
241 | ; Returns:
|
---|
242 | ; Nothing
|
---|
243 | ; Corrupts registers:
|
---|
244 | ; All, except segments
|
---|
245 | ;--------------------------------------------------------------------
|
---|
246 | ALIGN JUMP_ALIGN
|
---|
247 | PrimaryIdeController:
|
---|
248 | mov bx, ROMVARS.ideVars0
|
---|
249 | jmp SHORT DisplayIdeControllerMenu
|
---|
250 |
|
---|
251 | ALIGN JUMP_ALIGN
|
---|
252 | SecondaryIdeController:
|
---|
253 | mov bx, ROMVARS.ideVars1
|
---|
254 | jmp SHORT DisplayIdeControllerMenu
|
---|
255 |
|
---|
256 | ALIGN JUMP_ALIGN
|
---|
257 | TertiaryIdeController:
|
---|
258 | mov bx, ROMVARS.ideVars2
|
---|
259 | jmp SHORT DisplayIdeControllerMenu
|
---|
260 |
|
---|
261 | ALIGN JUMP_ALIGN
|
---|
262 | QuaternaryIdeController:
|
---|
263 | mov bx, ROMVARS.ideVars3
|
---|
264 | ; Fall to DisplayIdeControllerMenu
|
---|
265 |
|
---|
266 | ALIGN JUMP_ALIGN
|
---|
267 | DisplayIdeControllerMenu:
|
---|
268 | call IdeControllerMenu_InitializeToIdevarsOffsetInBX
|
---|
269 | jmp IdeControllerMenu_EnterMenuOrModifyItemVisibility
|
---|
270 |
|
---|
271 |
|
---|
272 | ALIGN JUMP_ALIGN
|
---|
273 | ActivateInputForNumberOfIdeControllersMenuitemInDSSI:
|
---|
274 | call Menuitem_ActivateUnsignedInputForMenuitemInDSSI
|
---|
275 | ; Fall to LimitIdeControllersForLiteMode
|
---|
276 |
|
---|
277 | ;--------------------------------------------------------------------
|
---|
278 | ; LimitIdeControllersForLiteMode
|
---|
279 | ; Parameters:
|
---|
280 | ; SS:BP: Menu handle
|
---|
281 | ; Returns:
|
---|
282 | ; Nothing
|
---|
283 | ; Corrupts registers:
|
---|
284 | ; AX, CX, DI
|
---|
285 | ;--------------------------------------------------------------------
|
---|
286 | ALIGN JUMP_ALIGN
|
---|
287 | LimitIdeControllersForLiteMode:
|
---|
288 | push es
|
---|
289 | call Buffers_GetIdeControllerCountToCX
|
---|
290 | mov [es:di+ROMVARS.bIdeCnt], cl
|
---|
291 | CALL_MENU_LIBRARY GetHighlightedItemToAX
|
---|
292 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
293 | pop es
|
---|
294 | ; Fall to ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
|
---|
295 |
|
---|
296 | ;----------------------------------------------------------------------
|
---|
297 | ; ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
|
---|
298 | ;
|
---|
299 | ; Checks to ensure that serial adapters are at the end of the
|
---|
300 | ; IDEVARS structures list, as serial floppies (if present) need to be
|
---|
301 | ; the last drives detected by the BIOS. If there are other controllers
|
---|
302 | ; after a serial controller, the other controllers are moved up on the list
|
---|
303 | ; and the serial controller is placed at the end of the list.
|
---|
304 | ;
|
---|
305 | ; Parameters:
|
---|
306 | ; SS:BP: Menu handle
|
---|
307 | ; Returns:
|
---|
308 | ; Nothing
|
---|
309 | ; Corrupts registers:
|
---|
310 | ; All
|
---|
311 | ;----------------------------------------------------------------------
|
---|
312 | ConfigurationMenu_CheckAndMoveSerialDrivesToBottom:
|
---|
313 | push es
|
---|
314 | push ds
|
---|
315 | push di
|
---|
316 | push si
|
---|
317 |
|
---|
318 | call Buffers_GetIdeControllerCountToCX ; will also set ES:DI to point to file buffer
|
---|
319 | push es
|
---|
320 | pop ds
|
---|
321 | mov ch, 0 ; clearing high order of CX and notification flag
|
---|
322 | mov dx, cx ; (probably unncessary, CX should be less than 127, but just to be sure)
|
---|
323 | jcxz .done ; probably unnecessary, but make sure there is at least one controller
|
---|
324 |
|
---|
325 | add di, ROMVARS.ideVars0 ; add in offset of first idevars
|
---|
326 | mov bx, di
|
---|
327 |
|
---|
328 | .outerLoop:
|
---|
329 | mov di, bx ; start of idevars
|
---|
330 | xor si, si ; first serial found
|
---|
331 | xor ax, ax ; first non-serial found
|
---|
332 | mov cl, dl ; idevars count
|
---|
333 | mov ch, 0
|
---|
334 |
|
---|
335 | .loop:
|
---|
336 | cmp byte [di+IDEVARS.bDevice], DEVICE_SERIAL_PORT
|
---|
337 | jnz .notSerial
|
---|
338 |
|
---|
339 | test si, si ; record the first serial controllert that we find
|
---|
340 | jnz .next
|
---|
341 | mov si, di
|
---|
342 | jmp .next
|
---|
343 |
|
---|
344 | .notSerial:
|
---|
345 | mov ax, di ; record the *last* non-serial controller that we find
|
---|
346 |
|
---|
347 | .next:
|
---|
348 | add di, IDEVARS_size
|
---|
349 | loop .loop
|
---|
350 |
|
---|
351 | test si,si ; no serial drives, nothing to do
|
---|
352 | jz .done
|
---|
353 | cmp si,ax ; serial port is already later on the list than any other controllers
|
---|
354 | ja .done ; (also takes care of the case where ther are no other controllers)
|
---|
355 |
|
---|
356 | ;
|
---|
357 | ; move serial to end of list, others up
|
---|
358 | ;
|
---|
359 | cld
|
---|
360 |
|
---|
361 | mov ax, di ; save end pointer of list after scan
|
---|
362 |
|
---|
363 | sub sp, IDEVARS_size ; copy serial to temporary space on stack
|
---|
364 |
|
---|
365 | mov di, sp
|
---|
366 |
|
---|
367 | mov cx, IDEVARS_size
|
---|
368 | push ss
|
---|
369 | pop es
|
---|
370 |
|
---|
371 | rep movsb
|
---|
372 |
|
---|
373 | mov di, si ; move up all the idevars below the serial, by one slot
|
---|
374 | sub di, IDEVARS_size
|
---|
375 |
|
---|
376 | mov cx, ax ; restore end pointer of list, subtract off end of serial idevars
|
---|
377 | sub cx, si
|
---|
378 |
|
---|
379 | push ds
|
---|
380 | pop es
|
---|
381 |
|
---|
382 | rep movsb
|
---|
383 |
|
---|
384 | mov si, sp ; place serial (currently on the stack) at bottom of list
|
---|
385 | push ss
|
---|
386 | pop ds
|
---|
387 | mov cx, IDEVARS_size
|
---|
388 | ; di is already at last IDEVARS position
|
---|
389 |
|
---|
390 | rep movsb
|
---|
391 |
|
---|
392 | add sp, IDEVARS_size
|
---|
393 |
|
---|
394 | push es
|
---|
395 | pop ds
|
---|
396 |
|
---|
397 | mov dh, 1 ; set flag that we have done a relocation
|
---|
398 |
|
---|
399 | jmp .outerLoop
|
---|
400 |
|
---|
401 | .done:
|
---|
402 | pop si
|
---|
403 | pop di
|
---|
404 | pop ds
|
---|
405 | pop es
|
---|
406 |
|
---|
407 | test dh, dh
|
---|
408 | jz .noWorkDone
|
---|
409 |
|
---|
410 | mov dx, g_szSerialMoved
|
---|
411 | call Dialogs_DisplayNotificationFromCSDX
|
---|
412 |
|
---|
413 | .noWorkDone:
|
---|
414 | ret
|
---|