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

Last change on this file since 370 was 258, checked in by gregli@…, 13 years ago

Added floppy drive emulation over the serial connection (MODULE_SERIAL_FLOPPY). Along the way, various optimizations were made to stay within the 8K ROM size target. Also, serial code now returns the number of sectors transferred.

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