source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm@ 510

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

Changes to Configurator v2:

  • Added Auto Configure.
File size: 15.7 KB
Line 
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
21SECTION .data
22
23ALIGN WORD_ALIGN
24g_MenupageForConfigurationMenu:
25istruc MENUPAGE
26 at MENUPAGE.fnEnter, dw ConfigurationMenu_EnterMenuOrModifyItemVisibility
27 at MENUPAGE.fnBack, dw MainMenu_EnterMenuOrModifyItemVisibility
28 at MENUPAGE.wMenuitems, dw 11
29iend
30
31g_MenuitemConfigurationBackToMainMenu:
32istruc 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
39iend
40
41g_MenuitemConfigurationPrimaryIdeController:
42istruc 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
49iend
50
51g_MenuitemConfigurationSecondaryIdeController:
52istruc 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
59iend
60
61g_MenuitemConfigurationTertiaryIdeController:
62istruc 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
69iend
70
71g_MenuitemConfigurationQuaternaryIdeController:
72istruc 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
79iend
80
81g_MenuitemConfigurationBootMenuSettings:
82istruc 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
89iend
90
91g_MenuitemAutoConfigure:
92istruc MENUITEM
93 at MENUITEM.fnActivate, dw AutoConfigure_ForThisSystem
94 at MENUITEM.szName, dw g_szItemAutoConfigure
95 at MENUITEM.szQuickInfo, dw g_szNfoAutoConfigure
96 at MENUITEM.szHelp, dw g_szNfoAutoConfigure
97 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU
98 at MENUITEM.bType, db TYPE_MENUITEM_ACTION
99iend
100
101g_MenuitemConfigurationFullOperatingMode:
102istruc MENUITEM
103 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
104 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
105 at MENUITEM.szName, dw g_szItemCfgFullMode
106 at MENUITEM.szQuickInfo, dw g_szNfoCfgFullMode
107 at MENUITEM.szHelp, dw g_szHelpCfgFullMode
108 at MENUITEM.bFlags, db FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
109 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
110 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw ROMVARS.wFlags
111 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgCfgFullMode
112 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceBooleanFlag
113 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForFlagBooleans
114 at MENUITEM.itemValue + ITEM_VALUE.wValueBitmask, dw FLG_ROMVARS_FULLMODE
115iend
116
117g_MenuitemConfigurationKiBtoStealFromRAM:
118istruc MENUITEM
119 at MENUITEM.fnActivate, dw Menuitem_ActivateUnsignedInputForMenuitemInDSSI
120 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
121 at MENUITEM.szName, dw g_szItemCfgStealSize
122 at MENUITEM.szQuickInfo, dw g_szNfoCfgStealSize
123 at MENUITEM.szHelp, dw g_szHelpCfgStealSize
124 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
125 at MENUITEM.bType, db TYPE_MENUITEM_UNSIGNED
126 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw ROMVARS.bStealSize
127 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgCfgStealSize
128 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 1
129 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw 255
130iend
131
132g_MenuitemConfigurationIdeControllers:
133istruc MENUITEM
134 at MENUITEM.fnActivate, dw ActivateInputForNumberOfIdeControllersMenuitemInDSSI
135 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
136 at MENUITEM.szName, dw g_szItemCfgIdeCnt
137 at MENUITEM.szQuickInfo, dw g_szNfoCfgIdeCnt
138 at MENUITEM.szHelp, dw g_szNfoCfgIdeCnt
139 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
140 at MENUITEM.bType, db TYPE_MENUITEM_UNSIGNED
141 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw ROMVARS.bIdeCnt
142 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgCfgIdeCnt
143 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 1
144 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw MAX_ALLOWED_IDE_CONTROLLERS
145iend
146
147g_MenuitemConfigurationIdleTimeout:
148istruc MENUITEM
149 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
150 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
151 at MENUITEM.szName, dw g_szItemCfgIdleTimeout
152 at MENUITEM.szQuickInfo, dw g_szNfoCfgIdleTimeout
153 at MENUITEM.szHelp, dw g_szHelpCfgIdleTimeout
154 at MENUITEM.bFlags, db FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_CHOICESTRINGS
155 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
156 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw ROMVARS.bIdleTimeout
157 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgCfgIdleTimeout
158 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceIdleTimeout
159 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForIdleTimeout
160 at MENUITEM.itemValue + ITEM_VALUE.rgszChoiceToStringLookup, dw g_rgszChoiceToStringLookupForIdleTimeout
161iend
162
163g_rgwChoiceToValueLookupForIdleTimeout:
164 %assign i -12
165 %rep 21
166 %assign i i+12
167 dw i ; i / 12 = 0 (disabled) or 1...20 minutes
168 %endrep
169 %rep 4
170 %assign i i+1
171 dw i ; 241...244 = (i - 240) * 30 minutes
172 %endrep
173g_rgszChoiceToStringLookupForIdleTimeout:
174 %assign i 0
175 %rep 25
176 dw g_szIdleTimeoutChoice%[i]
177 %assign i i+1
178 %endrep
179 ; dw NULL ; Is this needed? *FIXME*
180
181; Section containing code
182SECTION .text
183
184;--------------------------------------------------------------------
185; MainMenu_EnterMenuOrModifyItemVisibility
186; Parameters:
187; SS:BP: Menu handle
188; Returns:
189; Nothing
190; Corrupts registers:
191; All, except BP
192;--------------------------------------------------------------------
193ALIGN JUMP_ALIGN
194ConfigurationMenu_EnterMenuOrModifyItemVisibility:
195 push cs
196 pop ds
197 call .DisableAllIdeControllerMenuitems
198 call .EnableIdeControllerMenuitemsBasedOnConfiguration
199 call .EnableOrDisableOperatingModeSelection
200 call .EnableOrDisableKiBtoStealFromRAM
201 call .EnableOrDisableIdleTimeout
202 call LimitIdeControllersForLiteMode
203 mov si, g_MenupageForConfigurationMenu
204 jmp Menupage_ChangeToNewMenupageInDSSI
205
206;--------------------------------------------------------------------
207; .DisableAllIdeControllerMenuitems
208; .EnableIdeControllerMenuitemsBasedOnConfiguration
209; Parameters:
210; SS:BP: Menu handle
211; Returns:
212; Nothing
213; Corrupts registers:
214; AX, BX, CX, DI, ES
215;--------------------------------------------------------------------
216ALIGN JUMP_ALIGN
217.DisableAllIdeControllerMenuitems:
218 mov cx, MAX_ALLOWED_IDE_CONTROLLERS-1
219 mov bx, g_MenuitemConfigurationSecondaryIdeController
220ALIGN JUMP_ALIGN
221.DisableNextIdeControllerMenuitem:
222 call .DisableMenuitemFromCSBX
223 add bx, BYTE MENUITEM_size
224 loop .DisableNextIdeControllerMenuitem
225 ret
226
227ALIGN JUMP_ALIGN
228.EnableIdeControllerMenuitemsBasedOnConfiguration:
229 call Buffers_GetIdeControllerCountToCX
230 dec cx ; Primary always enabled
231 jz SHORT .PrimaryControllerAlreadyEnabled
232 mov bx, g_MenuitemConfigurationSecondaryIdeController
233ALIGN JUMP_ALIGN
234.EnableNextIdeControllerMenuitem:
235 call .EnableMenuitemFromCSBX
236 add bx, BYTE MENUITEM_size
237 loop .EnableNextIdeControllerMenuitem
238.PrimaryControllerAlreadyEnabled:
239 ret
240
241
242;--------------------------------------------------------------------
243; .EnableOrDisableOperatingModeSelection
244; Parameters:
245; SS:BP: Menu handle
246; Returns:
247; Nothing
248; Corrupts registers:
249; BX, DI, ES
250;--------------------------------------------------------------------
251ALIGN JUMP_ALIGN
252.EnableOrDisableOperatingModeSelection:
253 mov bx, g_MenuitemConfigurationFullOperatingMode
254 call Buffers_IsXTbuildLoaded
255 je SHORT .EnableMenuitemFromCSBX
256 jmp SHORT .DisableMenuitemFromCSBX
257
258
259;--------------------------------------------------------------------
260; .EnableOrDisableKiBtoStealFromRAM
261; Parameters:
262; SS:BP: Menu handle
263; Returns:
264; Nothing
265; Corrupts registers:
266; AX, BX, CX
267;--------------------------------------------------------------------
268ALIGN JUMP_ALIGN
269.EnableOrDisableKiBtoStealFromRAM:
270 call Buffers_GetRomvarsFlagsToAX
271 mov bx, g_MenuitemConfigurationKiBtoStealFromRAM
272 test ax, FLG_ROMVARS_FULLMODE
273 jz SHORT .DisableMenuitemFromCSBX
274 jmp SHORT .EnableMenuitemFromCSBX
275
276
277;--------------------------------------------------------------------
278; .EnableOrDisableIdleTimeout
279; Parameters:
280; SS:BP: Menu handle
281; Returns:
282; Nothing
283; Corrupts registers:
284; AX, BX
285;--------------------------------------------------------------------
286ALIGN JUMP_ALIGN
287.EnableOrDisableIdleTimeout:
288 call Buffers_GetRomvarsFlagsToAX
289 mov bx, g_MenuitemConfigurationIdleTimeout
290 test ax, FLG_ROMVARS_MODULE_FEATURE_SETS
291 jz SHORT .DisableMenuitemFromCSBX
292 ; Fall to .EnableMenuitemFromCSBX
293
294
295;--------------------------------------------------------------------
296; .EnableMenuitemFromCSBX
297; .DisableMenuitemFromCSBX
298; Parameters:
299; CS:BX: Ptr to MENUITEM
300; Returns:
301; Nothing
302; Corrupts registers:
303; Nothing
304;--------------------------------------------------------------------
305ALIGN JUMP_ALIGN
306.EnableMenuitemFromCSBX:
307 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
308 ret
309
310ALIGN JUMP_ALIGN
311.DisableMenuitemFromCSBX:
312 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
313 ret
314
315
316
317;--------------------------------------------------------------------
318; MENUITEM activation functions (.fnActivate)
319; Parameters:
320; SS:BP: Ptr to MENU
321; Returns:
322; Nothing
323; Corrupts registers:
324; All, except segments
325;--------------------------------------------------------------------
326ALIGN JUMP_ALIGN
327PrimaryIdeController:
328 mov bx, ROMVARS.ideVars0
329 jmp SHORT DisplayIdeControllerMenu
330
331ALIGN JUMP_ALIGN
332SecondaryIdeController:
333 mov bx, ROMVARS.ideVars1
334 jmp SHORT DisplayIdeControllerMenu
335
336ALIGN JUMP_ALIGN
337TertiaryIdeController:
338 mov bx, ROMVARS.ideVars2
339 jmp SHORT DisplayIdeControllerMenu
340
341ALIGN JUMP_ALIGN
342QuaternaryIdeController:
343 mov bx, ROMVARS.ideVars3
344 ; Fall to DisplayIdeControllerMenu
345
346ALIGN JUMP_ALIGN
347DisplayIdeControllerMenu:
348 call IdeControllerMenu_InitializeToIdevarsOffsetInBX
349 jmp IdeControllerMenu_EnterMenuOrModifyItemVisibility
350
351
352ALIGN JUMP_ALIGN
353ActivateInputForNumberOfIdeControllersMenuitemInDSSI:
354 call Menuitem_ActivateUnsignedInputForMenuitemInDSSI
355 ; Fall to LimitIdeControllersForLiteMode
356
357;--------------------------------------------------------------------
358; LimitIdeControllersForLiteMode
359; Parameters:
360; SS:BP: Menu handle
361; Returns:
362; Nothing
363; Corrupts registers:
364; AX, CX, DI
365;--------------------------------------------------------------------
366ALIGN JUMP_ALIGN
367LimitIdeControllersForLiteMode:
368 push es
369 call Buffers_GetIdeControllerCountToCX
370 mov [es:di+ROMVARS.bIdeCnt], cl
371 CALL_MENU_LIBRARY GetHighlightedItemToAX
372 CALL_MENU_LIBRARY RefreshItemFromAX
373 pop es
374 ; Fall to ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
375
376;----------------------------------------------------------------------
377; ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
378;
379; Checks to ensure that serial adapters are at the end of the
380; IDEVARS structures list, as serial floppies (if present) need to be
381; the last drives detected by the BIOS. If there are other controllers
382; after a serial controller, the other controllers are moved up on the list
383; and the serial controller is placed at the end of the list.
384;
385; Parameters:
386; SS:BP: Menu handle
387; Returns:
388; Nothing
389; Corrupts registers:
390; All
391;----------------------------------------------------------------------
392ConfigurationMenu_CheckAndMoveSerialDrivesToBottom:
393 push es
394 push ds
395 push di
396 push si
397
398 call Buffers_GetIdeControllerCountToCX ; will also set ES:DI to point to file buffer
399 push es
400 pop ds
401 xor ch, ch ; clearing high order of CX and notification flag
402 mov dx, cx ; (probably unnecessary, CX should be less than 127, but just to be sure)
403 jcxz .done ; probably unnecessary, but make sure there is at least one controller
404
405 lea bx, [di+ROMVARS.ideVars0] ; add in offset of first idevars
406
407.outerLoop:
408 mov di, bx ; start of idevars
409 xor si, si ; first serial found
410 xor ax, ax ; first non-serial found
411 mov cl, dl ; idevars count
412 xor ch, ch
413
414.loop:
415 cmp byte [di+IDEVARS.bDevice], DEVICE_SERIAL_PORT
416 jnz .notSerial
417
418 test si, si ; record the first serial controller that we find
419 jnz .next
420 mov si, di
421 jmp .next
422
423.notSerial:
424 mov ax, di ; record the *last* non-serial controller that we find
425
426.next:
427 add di, IDEVARS_size
428 loop .loop
429
430 test si, si ; no serial drives, nothing to do
431 jz .done
432 cmp si, ax ; serial port is already later on the list than any other controllers
433 ja .done ; (also takes care of the case where there are no other controllers)
434
435;
436; move serial to end of list, others up
437;
438 cld
439
440 mov ax, di ; save end pointer of list after scan
441
442 sub sp, IDEVARS_size ; copy serial to temporary space on stack
443
444 mov di, sp
445
446 mov cx, IDEVARS_size
447 push ss
448 pop es
449
450 rep movsb
451
452 lea di, [si-IDEVARS_size] ; move up all the idevars below the serial, by one slot
453
454 mov cx, ax ; restore end pointer of list, subtract off end of serial idevars
455 sub cx, si
456
457 push ds
458 pop es
459
460 rep movsb
461
462 mov si, sp ; place serial (currently on the stack) at bottom of list
463 push ss
464 pop ds
465 mov cx, IDEVARS_size
466 ; di is already at last IDEVARS position
467
468 rep movsb
469
470 add sp, IDEVARS_size
471
472 push es
473 pop ds
474
475 mov dh, 1 ; set flag that we have done a relocation
476
477 jmp .outerLoop
478
479.done:
480 pop si
481 pop di
482 pop ds
483 pop es
484
485 test dh, dh
486 jz .noWorkDone
487
488 mov dx, g_szSerialMoved
489 call Dialogs_DisplayNotificationFromCSDX
490
491.noWorkDone:
492 ret
Note: See TracBrowser for help on using the repository browser.