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

Last change on this file since 592 was 592, checked in by krille_n_, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 14.2 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     cx, FLASHVARS_size + PROGRESS_DIALOG_IO_size
224    call    Memory_ReserveCXbytesFromStackToDSSI
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;%if g_rgwEepromTypeToSizeInWords = 0   ; *FIXME* It really is but NASM won't accept this.
349    mov     ax, [cs:bx]
350;%else
351;   mov     ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
352;%endif
353    ret
354
355;--------------------------------------------------------------------
356; .DisplayFlashingResultsFromFlashvarsInDSBX
357;   Parameters:
358;       DS:BX:  Ptr to FLASHVARS
359;       SS:BP:  Ptr to MENU
360;   Returns:
361;       Nothing
362;   Corrupts registers:
363;       AX, BX, DX
364;--------------------------------------------------------------------
365ALIGN JUMP_ALIGN
366.DisplayFlashingResultsFromFlashvarsInDSBX:
367    eMOVZX  bx, [bx+FLASHVARS.flashResult]
368    jmp     [cs:bx+.rgfnFlashResultMessage]
369
370ALIGN WORD_ALIGN
371.rgfnFlashResultMessage:
372    dw      .DisplayFlashSuccessful
373    dw      .DisplayPollingError
374    dw      .DisplayDataVerifyError
375
376
377;--------------------------------------------------------------------
378; .DisplayPollingError
379; .DisplayDataVerifyError
380; .DisplayFlashSuccessful
381;   Parameters:
382;       SS:BP:  Ptr to MENU
383;   Returns:
384;       Nothing
385;   Corrupts registers:
386;       AX, DX, DI, ES
387;--------------------------------------------------------------------
388ALIGN JUMP_ALIGN
389.DisplayPollingError:
390    mov     dx, g_szErrEepromPolling
391    jmp     Dialogs_DisplayErrorFromCSDX
392
393ALIGN JUMP_ALIGN
394.DisplayDataVerifyError:
395    mov     dx, g_szErrEepromVerify
396    jmp     Dialogs_DisplayErrorFromCSDX
397
398ALIGN JUMP_ALIGN
399.DisplayFlashSuccessful:
400    call    Buffers_GetFileBufferToESDI
401    cmp     WORD [es:di+ROMVARS.wRomSign], 0AA55h   ; PC ROM?
402    je      SHORT .DisplayRebootMessageAndReboot
403    mov     dx, g_szForeignFlash
404    jmp     Dialogs_DisplayNotificationFromCSDX
405ALIGN JUMP_ALIGN
406.DisplayRebootMessageAndReboot:
407    mov     dx, g_szPCFlashSuccessful
408    call    Dialogs_DisplayNotificationFromCSDX
409    xor     ax, ax          ; Cold boot flag
410    jmp     Reboot_ComputerWithBootFlagInAX
Note: See TracBrowser for help on using the repository browser.