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

Last change on this file since 412 was 380, checked in by krille_n_@…, 13 years ago

Changes:

  • Added code to XTIDECFG for Power Management (standby timer) support in the BIOS.
  • Some minor optimizations.
File size: 14.3 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_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
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_VISIBLE | 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 .EnableOrDisableKiBtoStealFromRAM
190 call LimitIdeControllersForLiteMode
191 mov si, g_MenupageForConfigurationMenu
192 jmp Menupage_ChangeToNewMenupageInDSSI
193
194;--------------------------------------------------------------------
195; .DisableAllIdeControllerMenuitems
196; .EnableIdeControllerMenuitemsBasedOnConfiguration
197; Parameters:
198; SS:BP: Menu handle
199; Returns:
200; Nothing
201; Corrupts registers:
202; AX, BX, CX, DI, ES
203;--------------------------------------------------------------------
204ALIGN JUMP_ALIGN
205.DisableAllIdeControllerMenuitems:
206 mov cx, MAX_ALLOWED_IDE_CONTROLLERS-1
207 mov bx, g_MenuitemConfigurationSecondaryIdeController
208ALIGN JUMP_ALIGN
209.DisableNextIdeControllerMenuitem:
210 call .DisableMenuitemFromCSBX
211 add bx, BYTE MENUITEM_size
212 loop .DisableNextIdeControllerMenuitem
213 ret
214
215ALIGN JUMP_ALIGN
216.EnableIdeControllerMenuitemsBasedOnConfiguration:
217 call Buffers_GetIdeControllerCountToCX
218 dec cx ; Primary always enabled
219 jz SHORT .PrimaryControllerAlreadyEnabled
220 mov bx, g_MenuitemConfigurationSecondaryIdeController
221ALIGN JUMP_ALIGN
222.EnableNextIdeControllerMenuitem:
223 call .EnableMenuitemFromCSBX
224 add bx, BYTE MENUITEM_size
225 loop .EnableNextIdeControllerMenuitem
226.PrimaryControllerAlreadyEnabled:
227 ret
228
229
230;--------------------------------------------------------------------
231; .EnableOrDisableKiBtoStealFromRAM
232; Parameters:
233; SS:BP: Menu handle
234; Returns:
235; Nothing
236; Corrupts registers:
237; AX, BX, CX
238;--------------------------------------------------------------------
239ALIGN JUMP_ALIGN
240.EnableOrDisableKiBtoStealFromRAM:
241 call Buffers_GetRomvarsFlagsToAX
242 mov bx, g_MenuitemConfigurationKiBtoStealFromRAM
243 test ax, FLG_ROMVARS_FULLMODE
244 jz SHORT .DisableMenuitemFromCSBX
245 ; Fall to .EnableMenuitemFromCSBX
246
247
248;--------------------------------------------------------------------
249; .EnableMenuitemFromCSBX
250; .DisableMenuitemFromCSBX
251; Parameters:
252; CS:BX: Ptr to MENUITEM
253; Returns:
254; Nothing
255; Corrupts registers:
256; Nothing
257;--------------------------------------------------------------------
258ALIGN JUMP_ALIGN
259.EnableMenuitemFromCSBX:
260 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
261 ret
262
263ALIGN JUMP_ALIGN
264.DisableMenuitemFromCSBX:
265 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
266 ret
267
268
269
270;--------------------------------------------------------------------
271; MENUITEM activation functions (.fnActivate)
272; Parameters:
273; SS:BP: Ptr to MENU
274; Returns:
275; Nothing
276; Corrupts registers:
277; All, except segments
278;--------------------------------------------------------------------
279ALIGN JUMP_ALIGN
280PrimaryIdeController:
281 mov bx, ROMVARS.ideVars0
282 jmp SHORT DisplayIdeControllerMenu
283
284ALIGN JUMP_ALIGN
285SecondaryIdeController:
286 mov bx, ROMVARS.ideVars1
287 jmp SHORT DisplayIdeControllerMenu
288
289ALIGN JUMP_ALIGN
290TertiaryIdeController:
291 mov bx, ROMVARS.ideVars2
292 jmp SHORT DisplayIdeControllerMenu
293
294ALIGN JUMP_ALIGN
295QuaternaryIdeController:
296 mov bx, ROMVARS.ideVars3
297 ; Fall to DisplayIdeControllerMenu
298
299ALIGN JUMP_ALIGN
300DisplayIdeControllerMenu:
301 call IdeControllerMenu_InitializeToIdevarsOffsetInBX
302 jmp IdeControllerMenu_EnterMenuOrModifyItemVisibility
303
304
305ALIGN JUMP_ALIGN
306ActivateInputForNumberOfIdeControllersMenuitemInDSSI:
307 call Menuitem_ActivateUnsignedInputForMenuitemInDSSI
308 ; Fall to LimitIdeControllersForLiteMode
309
310;--------------------------------------------------------------------
311; LimitIdeControllersForLiteMode
312; Parameters:
313; SS:BP: Menu handle
314; Returns:
315; Nothing
316; Corrupts registers:
317; AX, CX, DI
318;--------------------------------------------------------------------
319ALIGN JUMP_ALIGN
320LimitIdeControllersForLiteMode:
321 push es
322 call Buffers_GetIdeControllerCountToCX
323 mov [es:di+ROMVARS.bIdeCnt], cl
324 CALL_MENU_LIBRARY GetHighlightedItemToAX
325 CALL_MENU_LIBRARY RefreshItemFromAX
326 pop es
327 ; Fall to ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
328
329;----------------------------------------------------------------------
330; ConfigurationMenu_CheckAndMoveSerialDrivesToBottom
331;
332; Checks to ensure that serial adapters are at the end of the
333; IDEVARS structures list, as serial floppies (if present) need to be
334; the last drives detected by the BIOS. If there are other controllers
335; after a serial controller, the other controllers are moved up on the list
336; and the serial controller is placed at the end of the list.
337;
338; Parameters:
339; SS:BP: Menu handle
340; Returns:
341; Nothing
342; Corrupts registers:
343; All
344;----------------------------------------------------------------------
345ConfigurationMenu_CheckAndMoveSerialDrivesToBottom:
346 push es
347 push ds
348 push di
349 push si
350
351 call Buffers_GetIdeControllerCountToCX ; will also set ES:DI to point to file buffer
352 push es
353 pop ds
354 xor ch, ch ; clearing high order of CX and notification flag
355 mov dx, cx ; (probably unnecessary, CX should be less than 127, but just to be sure)
356 jcxz .done ; probably unnecessary, but make sure there is at least one controller
357
358 lea bx, [di+ROMVARS.ideVars0] ; add in offset of first idevars
359
360.outerLoop:
361 mov di, bx ; start of idevars
362 xor si, si ; first serial found
363 xor ax, ax ; first non-serial found
364 mov cl, dl ; idevars count
365 xor ch, ch
366
367.loop:
368 cmp byte [di+IDEVARS.bDevice], DEVICE_SERIAL_PORT
369 jnz .notSerial
370
371 test si, si ; record the first serial controller that we find
372 jnz .next
373 mov si, di
374 jmp .next
375
376.notSerial:
377 mov ax, di ; record the *last* non-serial controller that we find
378
379.next:
380 add di, IDEVARS_size
381 loop .loop
382
383 test si, si ; no serial drives, nothing to do
384 jz .done
385 cmp si, ax ; serial port is already later on the list than any other controllers
386 ja .done ; (also takes care of the case where there are no other controllers)
387
388;
389; move serial to end of list, others up
390;
391 cld
392
393 mov ax, di ; save end pointer of list after scan
394
395 sub sp, IDEVARS_size ; copy serial to temporary space on stack
396
397 mov di, sp
398
399 mov cx, IDEVARS_size
400 push ss
401 pop es
402
403 rep movsb
404
405 lea di, [si-IDEVARS_size] ; move up all the idevars below the serial, by one slot
406
407 mov cx, ax ; restore end pointer of list, subtract off end of serial idevars
408 sub cx, si
409
410 push ds
411 pop es
412
413 rep movsb
414
415 mov si, sp ; place serial (currently on the stack) at bottom of list
416 push ss
417 pop ds
418 mov cx, IDEVARS_size
419 ; di is already at last IDEVARS position
420
421 rep movsb
422
423 add sp, IDEVARS_size
424
425 push es
426 pop ds
427
428 mov dh, 1 ; set flag that we have done a relocation
429
430 jmp .outerLoop
431
432.done:
433 pop si
434 pop di
435 pop ds
436 pop es
437
438 test dh, dh
439 jz .noWorkDone
440
441 mov dx, g_szSerialMoved
442 call Dialogs_DisplayNotificationFromCSDX
443
444.noWorkDone:
445 ret
Note: See TracBrowser for help on using the repository browser.