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

Last change on this file since 591 was 589, checked in by Krister Nordvall, 8 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 14.1 KB
RevLine 
[59]1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : "Flash EEPROM" menu structs and functions.
3
[376]4;
[526]5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[526]12;
[376]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
[526]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[526]18;
[376]19
[59]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
[108]53 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[59]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
[108]59 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
[59]60 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.bEepromType
61 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashEepromType
[108]62 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceEepromType
63 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForEepromType
[59]64 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForEepromType
65iend
66
67g_MenuitemFlashSdpCommand:
68istruc MENUITEM
[108]69 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[59]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
[108]75 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
[59]76 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.bSdpCommand
77 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashSDP
[108]78 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceSdpCommand
79 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForSdpCommand
[59]80 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForSdpCommand
81iend
82
83g_MenuitemFlashPageSize:
84istruc MENUITEM
[108]85 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[59]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
[108]91 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
[65]92 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.bEepromPage
[59]93 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashPageSize
[108]94 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoicePageSize
95 at MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup, dw g_rgwChoiceToValueLookupForPageSize
[59]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
[108]116 at MENUITEM.fnActivate, dw Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
[59]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
[108]122 at MENUITEM.bType, db TYPE_MENUITEM_MULTICHOICE
[59]123 at MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset, dw CFGVARS.wFlags
124 at MENUITEM.itemValue + ITEM_VALUE.szDialogTitle, dw g_szDlgFlashChecksum
[108]125 at MENUITEM.itemValue + ITEM_VALUE.szMultichoice, dw g_szMultichoiceBooleanFlag
[59]126 at MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup, dw g_rgszValueToStringLookupForFlagBooleans
127 at MENUITEM.itemValue + ITEM_VALUE.wValueBitmask, dw FLG_CFGVARS_CHECKSUM
128iend
129
[108]130g_rgwChoiceToValueLookupForEepromType:
[59]131 dw EEPROM_TYPE.2816_2kiB
132 dw EEPROM_TYPE.2864_8kiB
[159]133 dw EEPROM_TYPE.2864_8kiB_MOD
[59]134 dw EEPROM_TYPE.28256_32kiB
135 dw EEPROM_TYPE.28512_64kiB
136g_rgszValueToStringLookupForEepromType:
137 dw g_szValueFlash2816
138 dw g_szValueFlash2864
[159]139 dw g_szValueFlash2864Mod
[59]140 dw g_szValueFlash28256
141 dw g_szValueFlash28512
142
[108]143g_rgwChoiceToValueLookupForSdpCommand:
[59]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
[108]152g_rgwChoiceToValueLookupForPageSize:
[65]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
[59]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
[371]186
[568]187 cmp WORD [cs:g_cfgVars+CFGVARS.wEepromSegment], 0
188 jne .alreadySet
[371]189
190 push es
191 push di
192 call EEPROM_FindXtideUniversalBiosROMtoESDI
193 push es
194 pop ax
195 pop di
196 pop es
197 jc .storeEepromSegment
198 mov ax, DEFAULT_EEPROM_SEGMENT
[526]199.storeEepromSegment:
[568]200 mov WORD [cs:g_cfgVars+CFGVARS.wEepromSegment], ax
[526]201
202.alreadySet:
203
[59]204 mov si, g_MenupageForFlashMenu
205 jmp Menupage_ChangeToNewMenupageInDSSI
206
207
208;--------------------------------------------------------------------
209; MENUITEM activation functions (.fnActivate)
210; Parameters:
211; SS:BP: Ptr to MENU
212; Returns:
213; Nothing
214; Corrupts registers:
215; All, except segments
216;--------------------------------------------------------------------
217ALIGN JUMP_ALIGN
218StartFlashing:
[68]219 call .MakeSureThatImageFitsInEeprom
220 jc SHORT .InvalidFlashingParameters
[65]221 push es
222 push ds
223
224 call .PrepareBuffersForFlashing
225 mov cx, FLASHVARS_size + PROGRESS_DIALOG_IO_size
226 call Memory_ReserveCXbytesFromStackToDSSI
227 call .InitializeFlashvarsFromDSSI
228 mov bx, si ; DS:BX now points to FLASHVARS
229 add si, BYTE FLASHVARS_size ; DS:SI now points to PROGRESS_DIALOG_IO
230 call Dialogs_DisplayProgressDialogForFlashingWithDialogIoInDSSIandFlashvarsInDSBX
231 call .DisplayFlashingResultsFromFlashvarsInDSBX
232
233 add sp, BYTE FLASHVARS_size + PROGRESS_DIALOG_IO_size
234 pop ds
235 pop es
[68]236.InvalidFlashingParameters:
[59]237 ret
[65]238
239;--------------------------------------------------------------------
[68]240; .MakeSureThatImageFitsInEeprom
241; Parameters:
242; SS:BP: Ptr to MENU
243; Returns:
[118]244; CF: Set if EEPROM too small
[68]245; Corrupts registers:
246; AX, BX, DX
247;--------------------------------------------------------------------
248ALIGN JUMP_ALIGN
249.MakeSureThatImageFitsInEeprom:
250 call .GetSelectedEepromSizeInWordsToAX
251 cmp ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
252 jae SHORT .ImageFitsInSelectedEeprom
253 mov dx, g_szErrEepromTooSmall
254 call Dialogs_DisplayErrorFromCSDX
255 stc
[145]256ALIGN JUMP_ALIGN, ret
[68]257.ImageFitsInSelectedEeprom:
258 ret
259
260;--------------------------------------------------------------------
[65]261; .PrepareBuffersForFlashing
262; Parameters:
263; SS:BP: Ptr to MENU
264; Returns:
265; Nothing
266; Corrupts registers:
267; AX, BX, CX, SI, DI
268;--------------------------------------------------------------------
269ALIGN JUMP_ALIGN
270.PrepareBuffersForFlashing:
271 call EEPROM_LoadFromRomToRamComparisonBuffer
272 call Buffers_AppendZeroesIfNeeded
273 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_CHECKSUM
274 jz SHORT .DoNotGenerateChecksumByte
275 jmp Buffers_GenerateChecksum
276.DoNotGenerateChecksumByte:
277 ret
278
279;--------------------------------------------------------------------
280; .InitializeFlashvarsFromDSSI
281; Parameters:
282; DS:SI: Ptr to FLASHVARS to initialize
283; SS:BP: Ptr to MENU
284; Returns:
285; Nothing
286; Corrupts registers:
287; AX, BX, DX, DI, ES
288;--------------------------------------------------------------------
289ALIGN JUMP_ALIGN
290.InitializeFlashvarsFromDSSI:
291 call Buffers_GetFileBufferToESDI
292 mov [si+FLASHVARS.fpNextSourcePage], di
293 mov [si+FLASHVARS.fpNextSourcePage+2], es
294
295 call Buffers_GetFlashComparisonBufferToESDI
296 mov [si+FLASHVARS.fpNextComparisonPage], di
297 mov [si+FLASHVARS.fpNextComparisonPage+2], es
298
299 mov ax, [cs:g_cfgVars+CFGVARS.wEepromSegment]
300 mov WORD [si+FLASHVARS.fpNextDestinationPage], 0
301 mov [si+FLASHVARS.fpNextDestinationPage+2], ax
302
303 mov al, [cs:g_cfgVars+CFGVARS.bEepromType]
304 mov [si+FLASHVARS.bEepromType], al
305
306 mov al, [cs:g_cfgVars+CFGVARS.bSdpCommand]
307 mov [si+FLASHVARS.bEepromSdpCommand], al
308
[293]309 eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromPage]
[65]310 mov ax, [cs:bx+g_rgwEepromPageToSizeInBytes]
311 mov [si+FLASHVARS.wEepromPageSize], ax
312
313 call .GetNumberOfPagesToFlashToAX
314 mov [si+FLASHVARS.wPagesToFlash], ax
315 ret
316
317;--------------------------------------------------------------------
318; .GetNumberOfPagesToFlashToAX
319; Parameters:
320; DS:SI: Ptr to FLASHVARS to initialize
321; Returns:
322; AX: Number of pages to flash (0 = 65536)
323; Corrupts registers:
324; BX, DX
325;--------------------------------------------------------------------
326ALIGN JUMP_ALIGN
327.GetNumberOfPagesToFlashToAX:
[68]328 call .GetSelectedEepromSizeInWordsToAX
[65]329 xor dx, dx
[589]330 eSHL_IM ax, 1 ; Size in bytes to...
331 eRCL_IM dx, 1 ; ...DX:AX
[65]332
333 cmp WORD [si+FLASHVARS.wEepromPageSize], BYTE 1
334 jbe SHORT .PreventDivideException
335 div WORD [si+FLASHVARS.wEepromPageSize]
336.PreventDivideException:
337 ret
338
[68]339;--------------------------------------------------------------------
340; .GetSelectedEepromSizeInWordsToAX
341; Parameters:
342; Nothing
343; Returns:
344; AX: Selected EEPROM size in WORDs
345; Corrupts registers:
346; BX
347;--------------------------------------------------------------------
348ALIGN JUMP_ALIGN
349.GetSelectedEepromSizeInWordsToAX:
[293]350 eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromType]
[68]351 mov ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
352 ret
[65]353
354;--------------------------------------------------------------------
355; .DisplayFlashingResultsFromFlashvarsInDSBX
356; Parameters:
357; DS:BX: Ptr to FLASHVARS
358; SS:BP: Ptr to MENU
359; Returns:
360; Nothing
361; Corrupts registers:
362; AX, BX, DX
363;--------------------------------------------------------------------
364ALIGN JUMP_ALIGN
365.DisplayFlashingResultsFromFlashvarsInDSBX:
[293]366 eMOVZX bx, [bx+FLASHVARS.flashResult]
[65]367 jmp [cs:bx+.rgfnFlashResultMessage]
368
369ALIGN WORD_ALIGN
370.rgfnFlashResultMessage:
371 dw .DisplayFlashSuccessful
372 dw .DisplayPollingError
373 dw .DisplayDataVerifyError
374
375
376;--------------------------------------------------------------------
377; .DisplayPollingError
378; .DisplayDataVerifyError
379; .DisplayFlashSuccessful
380; Parameters:
381; SS:BP: Ptr to MENU
382; Returns:
383; Nothing
384; Corrupts registers:
385; AX, DX, DI, ES
386;--------------------------------------------------------------------
387ALIGN JUMP_ALIGN
388.DisplayPollingError:
389 mov dx, g_szErrEepromPolling
390 jmp Dialogs_DisplayErrorFromCSDX
391
392ALIGN JUMP_ALIGN
393.DisplayDataVerifyError:
394 mov dx, g_szErrEepromVerify
395 jmp Dialogs_DisplayErrorFromCSDX
396
397ALIGN JUMP_ALIGN
398.DisplayFlashSuccessful:
399 call Buffers_GetFileBufferToESDI
400 cmp WORD [es:di+ROMVARS.wRomSign], 0AA55h ; PC ROM?
401 je SHORT .DisplayRebootMessageAndReboot
402 mov dx, g_szForeignFlash
403 jmp Dialogs_DisplayNotificationFromCSDX
404ALIGN JUMP_ALIGN
405.DisplayRebootMessageAndReboot:
[293]406 mov dx, g_szPCFlashSuccessful
[65]407 call Dialogs_DisplayNotificationFromCSDX
[246]408 xor ax, ax ; Cold boot flag
409 jmp Reboot_ComputerWithBootFlagInAX
Note: See TracBrowser for help on using the repository browser.