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

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

Minor size optimizations to all parts of the project (even the old Configurator).
Also added a new 'release' option to the makefiles of both versions of the Configurator. It invokes UPX and makes the Configurator programs ridiculously tiny.

File size: 13.7 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; CF: Set if EEPROM too small
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
220ALIGN JUMP_ALIGN, ret
221.ImageFitsInSelectedEeprom:
222 ret
223
224;--------------------------------------------------------------------
225; .PrepareBuffersForFlashing
226; Parameters:
227; SS:BP: Ptr to MENU
228; Returns:
229; Nothing
230; Corrupts registers:
231; AX, BX, CX, SI, DI
232;--------------------------------------------------------------------
233ALIGN JUMP_ALIGN
234.PrepareBuffersForFlashing:
235 call EEPROM_LoadFromRomToRamComparisonBuffer
236 call Buffers_AppendZeroesIfNeeded
237 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_CHECKSUM
238 jz SHORT .DoNotGenerateChecksumByte
239 jmp Buffers_GenerateChecksum
240.DoNotGenerateChecksumByte:
241 ret
242
243;--------------------------------------------------------------------
244; .InitializeFlashvarsFromDSSI
245; Parameters:
246; DS:SI: Ptr to FLASHVARS to initialize
247; SS:BP: Ptr to MENU
248; Returns:
249; Nothing
250; Corrupts registers:
251; AX, BX, DX, DI, ES
252;--------------------------------------------------------------------
253ALIGN JUMP_ALIGN
254.InitializeFlashvarsFromDSSI:
255 call Buffers_GetFileBufferToESDI
256 mov [si+FLASHVARS.fpNextSourcePage], di
257 mov [si+FLASHVARS.fpNextSourcePage+2], es
258
259 call Buffers_GetFlashComparisonBufferToESDI
260 mov [si+FLASHVARS.fpNextComparisonPage], di
261 mov [si+FLASHVARS.fpNextComparisonPage+2], es
262
263 mov ax, [cs:g_cfgVars+CFGVARS.wEepromSegment]
264 mov WORD [si+FLASHVARS.fpNextDestinationPage], 0
265 mov [si+FLASHVARS.fpNextDestinationPage+2], ax
266
267 mov al, [cs:g_cfgVars+CFGVARS.bEepromType]
268 mov [si+FLASHVARS.bEepromType], al
269
270 mov al, [cs:g_cfgVars+CFGVARS.bSdpCommand]
271 mov [si+FLASHVARS.bEepromSdpCommand], al
272
273 eMOVZX bx, BYTE [cs:g_cfgVars+CFGVARS.bEepromPage]
274 mov ax, [cs:bx+g_rgwEepromPageToSizeInBytes]
275 mov [si+FLASHVARS.wEepromPageSize], ax
276
277 call .GetNumberOfPagesToFlashToAX
278 mov [si+FLASHVARS.wPagesToFlash], ax
279 ret
280
281;--------------------------------------------------------------------
282; .GetNumberOfPagesToFlashToAX
283; Parameters:
284; DS:SI: Ptr to FLASHVARS to initialize
285; Returns:
286; AX: Number of pages to flash (0 = 65536)
287; Corrupts registers:
288; BX, DX
289;--------------------------------------------------------------------
290ALIGN JUMP_ALIGN
291.GetNumberOfPagesToFlashToAX:
292 call .GetSelectedEepromSizeInWordsToAX
293 xor dx, dx
294 shl ax, 1 ; Size in bytes to...
295 rcl dx, 1 ; ...DX:AX
296
297 cmp WORD [si+FLASHVARS.wEepromPageSize], BYTE 1
298 jbe SHORT .PreventDivideException
299 div WORD [si+FLASHVARS.wEepromPageSize]
300.PreventDivideException:
301 ret
302
303;--------------------------------------------------------------------
304; .GetSelectedEepromSizeInWordsToAX
305; Parameters:
306; Nothing
307; Returns:
308; AX: Selected EEPROM size in WORDs
309; Corrupts registers:
310; BX
311;--------------------------------------------------------------------
312ALIGN JUMP_ALIGN
313.GetSelectedEepromSizeInWordsToAX:
314 eMOVZX bx, BYTE [cs:g_cfgVars+CFGVARS.bEepromType]
315 mov ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
316 ret
317
318;--------------------------------------------------------------------
319; .DisplayFlashingResultsFromFlashvarsInDSBX
320; Parameters:
321; DS:BX: Ptr to FLASHVARS
322; SS:BP: Ptr to MENU
323; Returns:
324; Nothing
325; Corrupts registers:
326; AX, BX, DX
327;--------------------------------------------------------------------
328ALIGN JUMP_ALIGN
329.DisplayFlashingResultsFromFlashvarsInDSBX:
330 eMOVZX bx, BYTE [bx+FLASHVARS.flashResult]
331 jmp [cs:bx+.rgfnFlashResultMessage]
332
333ALIGN WORD_ALIGN
334.rgfnFlashResultMessage:
335 dw .DisplayFlashSuccessful
336 dw .DisplayPollingError
337 dw .DisplayDataVerifyError
338
339
340;--------------------------------------------------------------------
341; .DisplayPollingError
342; .DisplayDataVerifyError
343; .DisplayFlashSuccessful
344; Parameters:
345; SS:BP: Ptr to MENU
346; Returns:
347; Nothing
348; Corrupts registers:
349; AX, DX, DI, ES
350;--------------------------------------------------------------------
351ALIGN JUMP_ALIGN
352.DisplayPollingError:
353 mov dx, g_szErrEepromPolling
354 jmp Dialogs_DisplayErrorFromCSDX
355
356ALIGN JUMP_ALIGN
357.DisplayDataVerifyError:
358 mov dx, g_szErrEepromVerify
359 jmp Dialogs_DisplayErrorFromCSDX
360
361ALIGN JUMP_ALIGN
362.DisplayFlashSuccessful:
363 call Buffers_GetFileBufferToESDI
364 cmp WORD [es:di+ROMVARS.wRomSign], 0AA55h ; PC ROM?
365 je SHORT .DisplayRebootMessageAndReboot
366 mov dx, g_szForeignFlash
367 jmp Dialogs_DisplayNotificationFromCSDX
368ALIGN JUMP_ALIGN
369.DisplayRebootMessageAndReboot:
370 mov dx, g_szPCFlashSuccessfull
371 call Dialogs_DisplayNotificationFromCSDX
372 ; Fall to .RebootComputer
373
374
375;--------------------------------------------------------------------
376; .RebootComputer
377; Parameters:
378; Nothing
379; Returns:
380; Nothing, function never returns
381; Corrupts registers:
382; Doesn't matter
383;--------------------------------------------------------------------
384.RebootComputer:
385.ResetAT:
386 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Force use of AX so we can
387 mov [BDA.wBoot], ax ; make sure soft reset flag is not set
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.