source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm@ 251

Last change on this file since 251 was 246, checked in by aitotat@…, 13 years ago

Changes to Configurator v2:

  • Replaced reboot code with a call to Assembly Library reboot function.
File size: 13.1 KB
Line 
1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : "Flash EEPROM" menu structs and functions.
3
4; Section containing initialized data
5SECTION .data
6
7ALIGN WORD_ALIGN
8g_MenupageForFlashMenu:
9istruc MENUPAGE
10 at MENUPAGE.fnEnter, dw FlashMenu_EnterMenuOrModifyItemVisibility
11 at MENUPAGE.fnBack, dw MainMenu_EnterMenuOrModifyItemVisibility
12 at MENUPAGE.wMenuitems, dw 7
13iend
14
15g_MenuitemFlashBackToMainMenu:
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_MenuitemFlashStartFlashing:
26istruc MENUITEM
27 at MENUITEM.fnActivate, dw StartFlashing
28 at MENUITEM.szName, dw g_szItemFlashStart
29 at MENUITEM.szQuickInfo, dw g_szNfoFlashStart
30 at MENUITEM.szHelp, dw g_szNfoFlashStart
31 at MENUITEM.bFlags, db FLG_MENUITEM_VISIBLE
32 at MENUITEM.bType, db TYPE_MENUITEM_ACTION
33iend
34
35g_MenuitemFlashEepromType:
36istruc MENUITEM
37 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
38 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
39 at MENUITEM.szName, dw g_szItemFlashEepromType
40 at MENUITEM.szQuickInfo, dw g_szNfoFlashEepromType
41 at MENUITEM.szHelp, dw g_szNfoFlashEepromType
42 at MENUITEM.bFlags, db FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_VISIBLE
43 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
44 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.bEepromType
45 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashEepromType
46 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceEepromType
47 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForEepromType
48 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForEepromType
49iend
50
51g_MenuitemFlashSdpCommand:
52istruc MENUITEM
53 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
54 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
55 at MENUITEM.szName, dw g_szItemFlashSDP
56 at MENUITEM.szQuickInfo, dw g_szNfoFlashSDP
57 at MENUITEM.szHelp, dw g_szHelpFlashSDP
58 at MENUITEM.bFlags, db FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_VISIBLE
59 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
60 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.bSdpCommand
61 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashSDP
62 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceSdpCommand
63 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForSdpCommand
64 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForSdpCommand
65iend
66
67g_MenuitemFlashPageSize:
68istruc MENUITEM
69 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
70 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
71 at MENUITEM.szName, dw g_szItemFlashPageSize
72 at MENUITEM.szQuickInfo, dw g_szNfoFlashPageSize
73 at MENUITEM.szHelp, dw g_szHelpFlashPageSize
74 at MENUITEM.bFlags, db FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_VISIBLE
75 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
76 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.bEepromPage
77 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashPageSize
78 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoicePageSize
79 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForPageSize
80 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForPageSize
81iend
82
83g_MenuitemFlashEepromAddress:
84istruc MENUITEM
85 at MENUITEM.fnActivate, dw Menuitem_ActivateHexInputForMenuitemInDSSI
86 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
87 at MENUITEM.szName, dw g_szItemFlashAddr
88 at MENUITEM.szQuickInfo, dw g_szNfoFlashAddr
89 at MENUITEM.szHelp, dw g_szNfoFlashAddr
90 at MENUITEM.bFlags, db FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_VISIBLE
91 at MENUITEM.bType, db TYPE_MENUITEM_HEX
92 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.wEepromSegment
93 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashAddr
94 at MENUITEM.itemValue + ITEM_VALUE.wMinValue, dw 0C000h
95 at MENUITEM.itemValue + ITEM_VALUE.wMaxValue, dw 0F800h
96iend
97
98g_MenuitemFlashGenerateChecksum:
99istruc MENUITEM
100 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
101 at MENUITEM.fnFormatValue, dw MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
102 at MENUITEM.szName, dw g_szItemFlashChecksum
103 at MENUITEM.szQuickInfo, dw g_szNfoFlashChecksum
104 at MENUITEM.szHelp, dw g_szHelpFlashChecksum
105 at MENUITEM.bFlags, db FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_VISIBLE | FLG_MENUITEM_FLAGVALUE
106 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
107 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.wFlags
108 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashChecksum
109 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceBooleanFlag
110 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForFlagBooleans
111 at MENUITEM.itemValue + ITEM_VALUE.wValueBitmask, dw FLG_CFGVARS_CHECKSUM
112iend
113
114g_rgwChoiceToValueLookupForEepromType:
115 dw EEPROM_TYPE.2816_2kiB
116 dw EEPROM_TYPE.2864_8kiB
117 dw EEPROM_TYPE.2864_8kiB_MOD
118 dw EEPROM_TYPE.28256_32kiB
119 dw EEPROM_TYPE.28512_64kiB
120g_rgszValueToStringLookupForEepromType:
121 dw g_szValueFlash2816
122 dw g_szValueFlash2864
123 dw g_szValueFlash2864Mod
124 dw g_szValueFlash28256
125 dw g_szValueFlash28512
126
127g_rgwChoiceToValueLookupForSdpCommand:
128 dw SDP_COMMAND.none
129 dw SDP_COMMAND.enable
130 dw SDP_COMMAND.disable
131g_rgszValueToStringLookupForSdpCommand:
132 dw g_szValueFlashNone
133 dw g_szValueFlashEnable
134 dw g_szValueFlashDisable
135
136g_rgwChoiceToValueLookupForPageSize:
137 dw EEPROM_PAGE.1_byte
138 dw EEPROM_PAGE.2_bytes
139 dw EEPROM_PAGE.4_bytes
140 dw EEPROM_PAGE.8_bytes
141 dw EEPROM_PAGE.16_bytes
142 dw EEPROM_PAGE.32_bytes
143 dw EEPROM_PAGE.64_bytes
144g_rgszValueToStringLookupForPageSize:
145 dw g_szValueFlash1byte
146 dw g_szValueFlash2bytes
147 dw g_szValueFlash4bytes
148 dw g_szValueFlash8bytes
149 dw g_szValueFlash16bytes
150 dw g_szValueFlash32bytes
151 dw g_szValueFlash64bytes
152
153
154; Section containing code
155SECTION .text
156
157;--------------------------------------------------------------------
158; MainMenu_EnterMenuOrModifyItemVisibility
159; Parameters:
160; SS:BP: Menu handle
161; Returns:
162; Nothing
163; Corrupts registers:
164; All, except BP
165;--------------------------------------------------------------------
166ALIGN JUMP_ALIGN
167FlashMenu_EnterMenuOrModifyItemVisibility:
168 push cs
169 pop ds
170 mov si, g_MenupageForFlashMenu
171 jmp Menupage_ChangeToNewMenupageInDSSI
172
173
174;--------------------------------------------------------------------
175; MENUITEM activation functions (.fnActivate)
176; Parameters:
177; SS:BP: Ptr to MENU
178; Returns:
179; Nothing
180; Corrupts registers:
181; All, except segments
182;--------------------------------------------------------------------
183ALIGN JUMP_ALIGN
184StartFlashing:
185 call .MakeSureThatImageFitsInEeprom
186 jc SHORT .InvalidFlashingParameters
187 push es
188 push ds
189
190 call .PrepareBuffersForFlashing
191 mov cx, FLASHVARS_size + PROGRESS_DIALOG_IO_size
192 call Memory_ReserveCXbytesFromStackToDSSI
193 call .InitializeFlashvarsFromDSSI
194 mov bx, si ; DS:BX now points to FLASHVARS
195 add si, BYTE FLASHVARS_size ; DS:SI now points to PROGRESS_DIALOG_IO
196 call Dialogs_DisplayProgressDialogForFlashingWithDialogIoInDSSIandFlashvarsInDSBX
197 call .DisplayFlashingResultsFromFlashvarsInDSBX
198
199 add sp, BYTE FLASHVARS_size + PROGRESS_DIALOG_IO_size
200 pop ds
201 pop es
202.InvalidFlashingParameters:
203 ret
204
205;--------------------------------------------------------------------
206; .MakeSureThatImageFitsInEeprom
207; Parameters:
208; SS:BP: Ptr to MENU
209; Returns:
210; CF: Set if EEPROM too small
211; Corrupts registers:
212; AX, BX, DX
213;--------------------------------------------------------------------
214ALIGN JUMP_ALIGN
215.MakeSureThatImageFitsInEeprom:
216 call .GetSelectedEepromSizeInWordsToAX
217 cmp ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
218 jae SHORT .ImageFitsInSelectedEeprom
219 mov dx, g_szErrEepromTooSmall
220 call Dialogs_DisplayErrorFromCSDX
221 stc
222ALIGN JUMP_ALIGN, ret
223.ImageFitsInSelectedEeprom:
224 ret
225
226;--------------------------------------------------------------------
227; .PrepareBuffersForFlashing
228; Parameters:
229; SS:BP: Ptr to MENU
230; Returns:
231; Nothing
232; Corrupts registers:
233; AX, BX, CX, SI, DI
234;--------------------------------------------------------------------
235ALIGN JUMP_ALIGN
236.PrepareBuffersForFlashing:
237 call EEPROM_LoadFromRomToRamComparisonBuffer
238 call Buffers_AppendZeroesIfNeeded
239 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_CHECKSUM
240 jz SHORT .DoNotGenerateChecksumByte
241 jmp Buffers_GenerateChecksum
242.DoNotGenerateChecksumByte:
243 ret
244
245;--------------------------------------------------------------------
246; .InitializeFlashvarsFromDSSI
247; Parameters:
248; DS:SI: Ptr to FLASHVARS to initialize
249; SS:BP: Ptr to MENU
250; Returns:
251; Nothing
252; Corrupts registers:
253; AX, BX, DX, DI, ES
254;--------------------------------------------------------------------
255ALIGN JUMP_ALIGN
256.InitializeFlashvarsFromDSSI:
257 call Buffers_GetFileBufferToESDI
258 mov [si+FLASHVARS.fpNextSourcePage], di
259 mov [si+FLASHVARS.fpNextSourcePage+2], es
260
261 call Buffers_GetFlashComparisonBufferToESDI
262 mov [si+FLASHVARS.fpNextComparisonPage], di
263 mov [si+FLASHVARS.fpNextComparisonPage+2], es
264
265 mov ax, [cs:g_cfgVars+CFGVARS.wEepromSegment]
266 mov WORD [si+FLASHVARS.fpNextDestinationPage], 0
267 mov [si+FLASHVARS.fpNextDestinationPage+2], ax
268
269 mov al, [cs:g_cfgVars+CFGVARS.bEepromType]
270 mov [si+FLASHVARS.bEepromType], al
271
272 mov al, [cs:g_cfgVars+CFGVARS.bSdpCommand]
273 mov [si+FLASHVARS.bEepromSdpCommand], al
274
275 eMOVZX bx, BYTE [cs:g_cfgVars+CFGVARS.bEepromPage]
276 mov ax, [cs:bx+g_rgwEepromPageToSizeInBytes]
277 mov [si+FLASHVARS.wEepromPageSize], ax
278
279 call .GetNumberOfPagesToFlashToAX
280 mov [si+FLASHVARS.wPagesToFlash], ax
281 ret
282
283;--------------------------------------------------------------------
284; .GetNumberOfPagesToFlashToAX
285; Parameters:
286; DS:SI: Ptr to FLASHVARS to initialize
287; Returns:
288; AX: Number of pages to flash (0 = 65536)
289; Corrupts registers:
290; BX, DX
291;--------------------------------------------------------------------
292ALIGN JUMP_ALIGN
293.GetNumberOfPagesToFlashToAX:
294 call .GetSelectedEepromSizeInWordsToAX
295 xor dx, dx
296 shl ax, 1 ; Size in bytes to...
297 rcl dx, 1 ; ...DX:AX
298
299 cmp WORD [si+FLASHVARS.wEepromPageSize], BYTE 1
300 jbe SHORT .PreventDivideException
301 div WORD [si+FLASHVARS.wEepromPageSize]
302.PreventDivideException:
303 ret
304
305;--------------------------------------------------------------------
306; .GetSelectedEepromSizeInWordsToAX
307; Parameters:
308; Nothing
309; Returns:
310; AX: Selected EEPROM size in WORDs
311; Corrupts registers:
312; BX
313;--------------------------------------------------------------------
314ALIGN JUMP_ALIGN
315.GetSelectedEepromSizeInWordsToAX:
316 eMOVZX bx, BYTE [cs:g_cfgVars+CFGVARS.bEepromType]
317 mov ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
318 ret
319
320;--------------------------------------------------------------------
321; .DisplayFlashingResultsFromFlashvarsInDSBX
322; Parameters:
323; DS:BX: Ptr to FLASHVARS
324; SS:BP: Ptr to MENU
325; Returns:
326; Nothing
327; Corrupts registers:
328; AX, BX, DX
329;--------------------------------------------------------------------
330ALIGN JUMP_ALIGN
331.DisplayFlashingResultsFromFlashvarsInDSBX:
332 eMOVZX bx, BYTE [bx+FLASHVARS.flashResult]
333 jmp [cs:bx+.rgfnFlashResultMessage]
334
335ALIGN WORD_ALIGN
336.rgfnFlashResultMessage:
337 dw .DisplayFlashSuccessful
338 dw .DisplayPollingError
339 dw .DisplayDataVerifyError
340
341
342;--------------------------------------------------------------------
343; .DisplayPollingError
344; .DisplayDataVerifyError
345; .DisplayFlashSuccessful
346; Parameters:
347; SS:BP: Ptr to MENU
348; Returns:
349; Nothing
350; Corrupts registers:
351; AX, DX, DI, ES
352;--------------------------------------------------------------------
353ALIGN JUMP_ALIGN
354.DisplayPollingError:
355 mov dx, g_szErrEepromPolling
356 jmp Dialogs_DisplayErrorFromCSDX
357
358ALIGN JUMP_ALIGN
359.DisplayDataVerifyError:
360 mov dx, g_szErrEepromVerify
361 jmp Dialogs_DisplayErrorFromCSDX
362
363ALIGN JUMP_ALIGN
364.DisplayFlashSuccessful:
365 call Buffers_GetFileBufferToESDI
366 cmp WORD [es:di+ROMVARS.wRomSign], 0AA55h ; PC ROM?
367 je SHORT .DisplayRebootMessageAndReboot
368 mov dx, g_szForeignFlash
369 jmp Dialogs_DisplayNotificationFromCSDX
370ALIGN JUMP_ALIGN
371.DisplayRebootMessageAndReboot:
372 mov dx, g_szPCFlashSuccessfull
373 call Dialogs_DisplayNotificationFromCSDX
374 xor ax, ax ; Cold boot flag
375 jmp Reboot_ComputerWithBootFlagInAX
Note: See TracBrowser for help on using the repository browser.