source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.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: 9.2 KB
RevLine 
[57]1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : Functions for accessing file and flash buffers.
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
[57]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Buffers_Clear
25; Parameters:
26; Nothing
27; Returns:
28; Nothing
29; Corrupts registers:
30; AX, CX, DI, ES
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33Buffers_Clear:
34 call Buffers_GetFileBufferToESDI
35 mov cx, ROMVARS_size
36 jmp Memory_ZeroESDIwithSizeInCX
37
38
39;--------------------------------------------------------------------
40; Buffers_IsXtideUniversalBiosLoaded
41; Parameters:
42; Nothing
43; Returns:
44; ZF: Set if supported version of XTIDE Universal BIOS is loaded
[567]45; Cleared if no file or some other file is loaded
[57]46; Corrupts registers:
47; CX, SI, DI, ES
48;--------------------------------------------------------------------
49ALIGN JUMP_ALIGN
50Buffers_IsXtideUniversalBiosLoaded:
51 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
[567]52 jnz SHORT .FileOrBiosLoaded
[57]53 or cl, 1 ; Clear ZF
54 ret
55
[567]56.FileOrBiosLoaded:
57 call Buffers_GetFileBufferToESDI
58 ; Fall to Buffers_IsXtideUniversalBiosSignatureInESDI
[57]59
[567]60
[57]61;--------------------------------------------------------------------
62; Buffers_IsXtideUniversalBiosSignatureInESDI
63; Parameters:
64; ES:DI: Ptr to possible XTIDE Universal BIOS location
65; Returns:
66; ZF: Set if supported version of XTIDE Universal BIOS is loaded
[567]67; Cleared if no file or some other file is loaded
[57]68; Corrupts registers:
69; CX, SI
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72Buffers_IsXtideUniversalBiosSignatureInESDI:
73 push di
74
75 mov si, g_szXtideUniversalBiosSignature
76 add di, BYTE ROMVARS.rgbSign
77 mov cx, XTIDE_SIGNATURE_LENGTH / 2
78 cld
79 eSEG_STR repe, cs, cmpsw
80
81 pop di
82 ret
83
84
85;--------------------------------------------------------------------
[457]86; Buffers_IsXTbuildLoaded
87; Parameters:
88; Nothing
89; Returns:
90; ZF: Set if XT or XT+ build is loaded
91; Cleared if some other (AT, 386) build is loaded
92; Corrupts registers:
93; DI, ES
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
96Buffers_IsXTbuildLoaded:
97%strlen BUILD_TYPE_OFFSET TITLE_STRING_START
98 call Buffers_GetFileBufferToESDI
99 cmp WORD [es:di+ROMVARS.szTitle+BUILD_TYPE_OFFSET+1], 'XT' ; +1 is for '('
100 ret
101%undef BUILD_TYPE_OFFSET
102
103
104;--------------------------------------------------------------------
[145]105; Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
[57]106; Parameters:
107; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
[68]108; DX:CX: EEPROM size in bytes
[57]109; Returns:
110; Nothing
111; Corrupts registers:
[68]112; AX, CX, DX
[57]113;--------------------------------------------------------------------
114ALIGN JUMP_ALIGN
[68]115Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration:
[57]116 and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
117 or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
[68]118 shr dx, 1
119 rcr cx, 1
[144]120 adc cx, BYTE 0 ; Round up to next WORD
[65]121 mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
[57]122 ret
123
124
125;--------------------------------------------------------------------
126; Buffers_SetUnsavedChanges
127; Buffers_ClearUnsavedChanges
128; Parameters:
129; SS:BP: Menu handle
130; Returns:
131; Nothing
132; Corrupts registers:
133; Nothing
134;--------------------------------------------------------------------
135ALIGN JUMP_ALIGN
136Buffers_SetUnsavedChanges:
[371]137 or WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
[57]138 ret
139
140ALIGN JUMP_ALIGN
141Buffers_ClearUnsavedChanges:
[371]142 and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
[57]143 ret
144
145
146;--------------------------------------------------------------------
[59]147; Buffers_SaveChangesIfFileLoaded
148; Parameters:
149; Nothing
150; Returns:
151; Nothing
152; Corrupts registers:
153; AX, BX, CX, SI, DI
154;--------------------------------------------------------------------
155ALIGN JUMP_ALIGN
156Buffers_SaveChangesIfFileLoaded:
157 mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
158 and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
159 cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
160 jne SHORT .NothingToSave
161 call Dialogs_DisplaySaveChangesDialog
162 jnz SHORT .NothingToSave
163 jmp BiosFile_SaveUnsavedChanges
164ALIGN JUMP_ALIGN
165.NothingToSave:
166 ret
167
168
169;--------------------------------------------------------------------
[65]170; Buffers_AppendZeroesIfNeeded
171; Parameters:
172; Nothing
173; Returns:
174; Nothing
175; Corrupts registers:
176; AX, CX, DI
177;--------------------------------------------------------------------
178ALIGN JUMP_ALIGN
179Buffers_AppendZeroesIfNeeded:
180 push es
181
[293]182 eMOVZX di, [cs:g_cfgVars+CFGVARS.bEepromType]
[65]183 mov cx, [cs:di+g_rgwEepromTypeToSizeInWords]
184 sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
[567]185 jbe SHORT .NoNeedToAppendZeroes
[65]186
187 call Buffers_GetFileBufferToESDI
188 mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
189 shl ax, 1
190 add di, ax ; ES:DI now point first unused image byte
191 xor ax, ax
192 cld
193 rep stosw
194ALIGN JUMP_ALIGN
195.NoNeedToAppendZeroes:
196 pop es
197 ret
198
199
200;--------------------------------------------------------------------
[57]201; Buffers_GenerateChecksum
202; Parameters:
203; Nothing
204; Returns:
205; Nothing
206; Corrupts registers:
207; AX, BX, CX, DI
208;--------------------------------------------------------------------
209ALIGN JUMP_ALIGN
210Buffers_GenerateChecksum:
211 push es
[484]212 push dx
[57]213
214 call Buffers_GetFileBufferToESDI
[484]215 call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
[589]216
217; Compatibility fix for 3Com 3C503 cards where the ASIC returns 8080h as the last two bytes of the ROM.
218
219 ; Assume the BIOS size is not 8K, ie generate a normal checksum.
220 dec cx
221 mov ax, 100h
222 cmp cx, 8192 - 1
223 jne SHORT .BiosSizeIsNot8K
224 ; The BIOS size is 8K and therefore a potential candidate for a 3Com 3C503 card.
225 dec cx
226 dec cx
227 mov ah, 3
[57]228ALIGN JUMP_ALIGN
[589]229.BiosSizeIsNot8K:
[57]230.SumNextByte:
231 add al, [es:di]
[589]232.NextChecksumByte:
[57]233 inc di
234 loop .SumNextByte
235 neg al
236 mov [es:di], al
[589]237 inc cx
238 dec ah
239 jnz SHORT .NextChecksumByte
[57]240
[484]241 pop dx
[57]242 pop es
243 ret
244
245
246;--------------------------------------------------------------------
[59]247; Buffers_GetRomvarsFlagsToAX
248; Parameters:
249; Nothing
250; Returns:
251; AX: ROMVARS.wFlags
252; Corrupts registers:
253; BX
254;--------------------------------------------------------------------
255ALIGN JUMP_ALIGN
256Buffers_GetRomvarsFlagsToAX:
257 mov bx, ROMVARS.wFlags
258 ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
259
260;--------------------------------------------------------------------
[57]261; Buffers_GetRomvarsValueToAXfromOffsetInBX
262; Parameters:
263; BX: ROMVARS offset
264; Returns:
265; AX: Value
266; Corrupts registers:
267; Nothing
268;--------------------------------------------------------------------
269ALIGN JUMP_ALIGN
270Buffers_GetRomvarsValueToAXfromOffsetInBX:
271 push es
272 push di
273 call Buffers_GetFileBufferToESDI
274 mov ax, [es:bx+di]
275 pop di
276 pop es
277 ret
278
279
280;--------------------------------------------------------------------
[204]281; Buffers_GetIdeControllerCountToCX
282; Parameters:
283; SS:BP: Menu handle
284; Returns:
285; CX: Number of IDE controllers to configure
286; ES:DI: Ptr to file buffer
287; Corrupts registers:
[589]288; Nothing
[204]289;--------------------------------------------------------------------
290ALIGN JUMP_ALIGN
291Buffers_GetIdeControllerCountToCX:
[589]292 xor cx, cx
[204]293 call Buffers_GetFileBufferToESDI
[589]294 or cl, [es:di+ROMVARS.bIdeCnt]
295 jnz SHORT .LimitControllerCountForLiteMode
296 inc cx ; Make sure there is at least one controller
[204]297
[589]298.LimitControllerCountForLiteMode:
[204]299 test BYTE [es:di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
300 jnz SHORT .ReturnControllerCountInCX
[589]301 MIN_U cl, MAX_LITE_MODE_CONTROLLERS
[204]302
303.ReturnControllerCountInCX:
304 ret
305
306
307;--------------------------------------------------------------------
[57]308; Buffers_GetFileBufferToESDI
[65]309; Buffers_GetFlashComparisonBufferToESDI
[57]310; Buffers_GetFileDialogItemBufferToESDI
311; Parameters:
312; Nothing
313; Returns:
314; ES:DI: Ptr to file buffer
315; Corrupts registers:
316; Nothing
317;--------------------------------------------------------------------
318ALIGN JUMP_ALIGN
[65]319Buffers_GetFlashComparisonBufferToESDI:
[57]320Buffers_GetFileDialogItemBufferToESDI:
[59]321 call Buffers_GetFileBufferToESDI
322 push di
323 mov di, es
324 add di, 1000h ; Third 64k page
325 mov es, di
326 pop di
327 ret
[65]328ALIGN JUMP_ALIGN
[57]329Buffers_GetFileBufferToESDI:
330 mov di, cs
331 add di, 1000h ; Change to next 64k page
332 mov es, di
333 xor di, di ; Ptr now in ES:DI
334 ret
Note: See TracBrowser for help on using the repository browser.