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

Last change on this file since 372 was 371, checked in by gregli@…, 13 years ago

Small changes. 1) Changes biosdrvs.com to output CR+LF instead of LF+CR, consistent with DOS/Windows, but I did not update the Assembly Library as this would break the Configurator; 2) Put a C/C++ section in Version.inc for the serial server; 3) Configurator defaults the EEPROM address after scanning for a EEPROM in memory (as it does for loading the BIOS from ROM); 4) Added a command to the Configurator main menu to save chages to the file from which it was loaded (if it was loaded form a file), which is symmetric with the Load command and more discoverable than exiting DOS and then being prompted (which is still there too, if changes are unsaved).

File size: 13.4 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
171 cmp word [cs:g_cfgVars+CFGVARS.wEepromSegment], 0
172 jnz .alreadySet
173
174 push es
175 push di
176 call EEPROM_FindXtideUniversalBiosROMtoESDI
177 push es
178 pop ax
179 pop di
180 pop es
181 jc .storeEepromSegment
182 mov ax, DEFAULT_EEPROM_SEGMENT
183.storeEepromSegment:
184 mov word [cs:g_cfgVars+CFGVARS.wEepromSegment], ax
185
186.alreadySet:
187
188 mov si, g_MenupageForFlashMenu
189 jmp Menupage_ChangeToNewMenupageInDSSI
190
191
192;--------------------------------------------------------------------
193; MENUITEM activation functions (.fnActivate)
194; Parameters:
195; SS:BP: Ptr to MENU
196; Returns:
197; Nothing
198; Corrupts registers:
199; All, except segments
200;--------------------------------------------------------------------
201ALIGN JUMP_ALIGN
202StartFlashing:
203 call .MakeSureThatImageFitsInEeprom
204 jc SHORT .InvalidFlashingParameters
205 push es
206 push ds
207
208 call .PrepareBuffersForFlashing
209 mov cx, FLASHVARS_size + PROGRESS_DIALOG_IO_size
210 call Memory_ReserveCXbytesFromStackToDSSI
211 call .InitializeFlashvarsFromDSSI
212 mov bx, si ; DS:BX now points to FLASHVARS
213 add si, BYTE FLASHVARS_size ; DS:SI now points to PROGRESS_DIALOG_IO
214 call Dialogs_DisplayProgressDialogForFlashingWithDialogIoInDSSIandFlashvarsInDSBX
215 call .DisplayFlashingResultsFromFlashvarsInDSBX
216
217 add sp, BYTE FLASHVARS_size + PROGRESS_DIALOG_IO_size
218 pop ds
219 pop es
220.InvalidFlashingParameters:
221 ret
222
223;--------------------------------------------------------------------
224; .MakeSureThatImageFitsInEeprom
225; Parameters:
226; SS:BP: Ptr to MENU
227; Returns:
228; CF: Set if EEPROM too small
229; Corrupts registers:
230; AX, BX, DX
231;--------------------------------------------------------------------
232ALIGN JUMP_ALIGN
233.MakeSureThatImageFitsInEeprom:
234 call .GetSelectedEepromSizeInWordsToAX
235 cmp ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
236 jae SHORT .ImageFitsInSelectedEeprom
237 mov dx, g_szErrEepromTooSmall
238 call Dialogs_DisplayErrorFromCSDX
239 stc
240ALIGN JUMP_ALIGN, ret
241.ImageFitsInSelectedEeprom:
242 ret
243
244;--------------------------------------------------------------------
245; .PrepareBuffersForFlashing
246; Parameters:
247; SS:BP: Ptr to MENU
248; Returns:
249; Nothing
250; Corrupts registers:
251; AX, BX, CX, SI, DI
252;--------------------------------------------------------------------
253ALIGN JUMP_ALIGN
254.PrepareBuffersForFlashing:
255 call EEPROM_LoadFromRomToRamComparisonBuffer
256 call Buffers_AppendZeroesIfNeeded
257 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_CHECKSUM
258 jz SHORT .DoNotGenerateChecksumByte
259 jmp Buffers_GenerateChecksum
260.DoNotGenerateChecksumByte:
261 ret
262
263;--------------------------------------------------------------------
264; .InitializeFlashvarsFromDSSI
265; Parameters:
266; DS:SI: Ptr to FLASHVARS to initialize
267; SS:BP: Ptr to MENU
268; Returns:
269; Nothing
270; Corrupts registers:
271; AX, BX, DX, DI, ES
272;--------------------------------------------------------------------
273ALIGN JUMP_ALIGN
274.InitializeFlashvarsFromDSSI:
275 call Buffers_GetFileBufferToESDI
276 mov [si+FLASHVARS.fpNextSourcePage], di
277 mov [si+FLASHVARS.fpNextSourcePage+2], es
278
279 call Buffers_GetFlashComparisonBufferToESDI
280 mov [si+FLASHVARS.fpNextComparisonPage], di
281 mov [si+FLASHVARS.fpNextComparisonPage+2], es
282
283 mov ax, [cs:g_cfgVars+CFGVARS.wEepromSegment]
284 mov WORD [si+FLASHVARS.fpNextDestinationPage], 0
285 mov [si+FLASHVARS.fpNextDestinationPage+2], ax
286
287 mov al, [cs:g_cfgVars+CFGVARS.bEepromType]
288 mov [si+FLASHVARS.bEepromType], al
289
290 mov al, [cs:g_cfgVars+CFGVARS.bSdpCommand]
291 mov [si+FLASHVARS.bEepromSdpCommand], al
292
293 eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromPage]
294 mov ax, [cs:bx+g_rgwEepromPageToSizeInBytes]
295 mov [si+FLASHVARS.wEepromPageSize], ax
296
297 call .GetNumberOfPagesToFlashToAX
298 mov [si+FLASHVARS.wPagesToFlash], ax
299 ret
300
301;--------------------------------------------------------------------
302; .GetNumberOfPagesToFlashToAX
303; Parameters:
304; DS:SI: Ptr to FLASHVARS to initialize
305; Returns:
306; AX: Number of pages to flash (0 = 65536)
307; Corrupts registers:
308; BX, DX
309;--------------------------------------------------------------------
310ALIGN JUMP_ALIGN
311.GetNumberOfPagesToFlashToAX:
312 call .GetSelectedEepromSizeInWordsToAX
313 xor dx, dx
314 shl ax, 1 ; Size in bytes to...
315 rcl dx, 1 ; ...DX:AX
316
317 cmp WORD [si+FLASHVARS.wEepromPageSize], BYTE 1
318 jbe SHORT .PreventDivideException
319 div WORD [si+FLASHVARS.wEepromPageSize]
320.PreventDivideException:
321 ret
322
323;--------------------------------------------------------------------
324; .GetSelectedEepromSizeInWordsToAX
325; Parameters:
326; Nothing
327; Returns:
328; AX: Selected EEPROM size in WORDs
329; Corrupts registers:
330; BX
331;--------------------------------------------------------------------
332ALIGN JUMP_ALIGN
333.GetSelectedEepromSizeInWordsToAX:
334 eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromType]
335 mov ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
336 ret
337
338;--------------------------------------------------------------------
339; .DisplayFlashingResultsFromFlashvarsInDSBX
340; Parameters:
341; DS:BX: Ptr to FLASHVARS
342; SS:BP: Ptr to MENU
343; Returns:
344; Nothing
345; Corrupts registers:
346; AX, BX, DX
347;--------------------------------------------------------------------
348ALIGN JUMP_ALIGN
349.DisplayFlashingResultsFromFlashvarsInDSBX:
350 eMOVZX bx, [bx+FLASHVARS.flashResult]
351 jmp [cs:bx+.rgfnFlashResultMessage]
352
353ALIGN WORD_ALIGN
354.rgfnFlashResultMessage:
355 dw .DisplayFlashSuccessful
356 dw .DisplayPollingError
357 dw .DisplayDataVerifyError
358
359
360;--------------------------------------------------------------------
361; .DisplayPollingError
362; .DisplayDataVerifyError
363; .DisplayFlashSuccessful
364; Parameters:
365; SS:BP: Ptr to MENU
366; Returns:
367; Nothing
368; Corrupts registers:
369; AX, DX, DI, ES
370;--------------------------------------------------------------------
371ALIGN JUMP_ALIGN
372.DisplayPollingError:
373 mov dx, g_szErrEepromPolling
374 jmp Dialogs_DisplayErrorFromCSDX
375
376ALIGN JUMP_ALIGN
377.DisplayDataVerifyError:
378 mov dx, g_szErrEepromVerify
379 jmp Dialogs_DisplayErrorFromCSDX
380
381ALIGN JUMP_ALIGN
382.DisplayFlashSuccessful:
383 call Buffers_GetFileBufferToESDI
384 cmp WORD [es:di+ROMVARS.wRomSign], 0AA55h ; PC ROM?
385 je SHORT .DisplayRebootMessageAndReboot
386 mov dx, g_szForeignFlash
387 jmp Dialogs_DisplayNotificationFromCSDX
388ALIGN JUMP_ALIGN
389.DisplayRebootMessageAndReboot:
390 mov dx, g_szPCFlashSuccessful
391 call Dialogs_DisplayNotificationFromCSDX
392 xor ax, ax ; Cold boot flag
393 jmp Reboot_ComputerWithBootFlagInAX
Note: See TracBrowser for help on using the repository browser.