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

Last change on this file since 76 was 74, checked in by Tomi Tilli, 14 years ago

Changes to Configurator v2:

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