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

Last change on this file since 551 was 526, checked in by krille_n_@…, 12 years ago

Changes:

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