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

Last change on this file since 616 was 602, checked in by Krister Nordvall, 6 years ago

Changes:

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