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

Last change on this file since 111 was 108, checked in by krille_n_@…, 14 years ago

Fixed a spelling mistake and cleaned the source some. No changes to the actual code.

File size: 13.6 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.28256_32kiB
118 dw EEPROM_TYPE.28512_64kiB
119g_rgszValueToStringLookupForEepromType:
120 dw g_szValueFlash2816
121 dw g_szValueFlash2864
122 dw g_szValueFlash28256
123 dw g_szValueFlash28512
124
125g_rgwChoiceToValueLookupForSdpCommand:
126 dw SDP_COMMAND.none
127 dw SDP_COMMAND.enable
128 dw SDP_COMMAND.disable
129g_rgszValueToStringLookupForSdpCommand:
130 dw g_szValueFlashNone
131 dw g_szValueFlashEnable
132 dw g_szValueFlashDisable
133
134g_rgwChoiceToValueLookupForPageSize:
135 dw EEPROM_PAGE.1_byte
136 dw EEPROM_PAGE.2_bytes
137 dw EEPROM_PAGE.4_bytes
138 dw EEPROM_PAGE.8_bytes
139 dw EEPROM_PAGE.16_bytes
140 dw EEPROM_PAGE.32_bytes
141 dw EEPROM_PAGE.64_bytes
142g_rgszValueToStringLookupForPageSize:
143 dw g_szValueFlash1byte
144 dw g_szValueFlash2bytes
145 dw g_szValueFlash4bytes
146 dw g_szValueFlash8bytes
147 dw g_szValueFlash16bytes
148 dw g_szValueFlash32bytes
149 dw g_szValueFlash64bytes
150
151
152; Section containing code
153SECTION .text
154
155;--------------------------------------------------------------------
156; MainMenu_EnterMenuOrModifyItemVisibility
157; Parameters:
158; SS:BP: Menu handle
159; Returns:
160; Nothing
161; Corrupts registers:
162; All, except BP
163;--------------------------------------------------------------------
164ALIGN JUMP_ALIGN
165FlashMenu_EnterMenuOrModifyItemVisibility:
166 push cs
167 pop ds
168 mov si, g_MenupageForFlashMenu
169 jmp Menupage_ChangeToNewMenupageInDSSI
170
171
172;--------------------------------------------------------------------
173; MENUITEM activation functions (.fnActivate)
174; Parameters:
175; SS:BP: Ptr to MENU
176; Returns:
177; Nothing
178; Corrupts registers:
179; All, except segments
180;--------------------------------------------------------------------
181ALIGN JUMP_ALIGN
182StartFlashing:
183 call .MakeSureThatImageFitsInEeprom
184 jc SHORT .InvalidFlashingParameters
185 push es
186 push ds
187
188 call .PrepareBuffersForFlashing
189 mov cx, FLASHVARS_size + PROGRESS_DIALOG_IO_size
190 call Memory_ReserveCXbytesFromStackToDSSI
191 call .InitializeFlashvarsFromDSSI
192 mov bx, si ; DS:BX now points to FLASHVARS
193 add si, BYTE FLASHVARS_size ; DS:SI now points to PROGRESS_DIALOG_IO
194 call Dialogs_DisplayProgressDialogForFlashingWithDialogIoInDSSIandFlashvarsInDSBX
195 call .DisplayFlashingResultsFromFlashvarsInDSBX
196
197 add sp, BYTE FLASHVARS_size + PROGRESS_DIALOG_IO_size
198 pop ds
199 pop es
200.InvalidFlashingParameters:
201 ret
202
203;--------------------------------------------------------------------
204; .MakeSureThatImageFitsInEeprom
205; Parameters:
206; SS:BP: Ptr to MENU
207; Returns:
208; Nothing
209; Corrupts registers:
210; AX, BX, DX
211;--------------------------------------------------------------------
212ALIGN JUMP_ALIGN
213.MakeSureThatImageFitsInEeprom:
214 call .GetSelectedEepromSizeInWordsToAX
215 cmp ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
216 jae SHORT .ImageFitsInSelectedEeprom
217 mov dx, g_szErrEepromTooSmall
218 call Dialogs_DisplayErrorFromCSDX
219 stc
220 ret
221ALIGN JUMP_ALIGN
222.ImageFitsInSelectedEeprom:
223 clc
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 ; Fall to .RebootComputer
375
376
377;--------------------------------------------------------------------
378; .RebootComputer
379; Parameters:
380; Nothing
381; Returns:
382; Nothing, function never returns
383; Corrupts registers:
384; Doesn't matter
385;--------------------------------------------------------------------
386.RebootComputer:
387.ResetAT:
388 mov al, 0FEh ; System reset (AT+ keyboard controller)
389 out 64h, al ; Reset computer (AT+)
390 mov ax, 10
391 call Delay_MicrosecondsFromAX
392.ResetXT:
393 xor ax, ax
394 push ax
395 popf ; Clear FLAGS (disables interrupt)
396 mov ds, ax
397 mov es, ax
398 mov ss, ax
399 jmp WORD 0FFFFh:0h ; XT reset
Note: See TracBrowser for help on using the repository browser.