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

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

Changes to Configurator v2:

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