source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm@ 620

Last change on this file since 620 was 620, checked in by Krister Nordvall, 4 years ago

Changes:

  • A huge thank you to Jayeson Lee-Steere for adding SST39SF0x0 flash ROM programming support to the configurator (XTIDECFG.COM). This means that there is no longer a need to use a separate program for flashing the Lo-Tech boards and other devices using these flash ROMs.
File size: 9.8 KB
Line 
1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : Functions for accessing file and flash buffers.
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 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
45; Cleared if no file or some other file is loaded
46; Corrupts registers:
47; CX, SI, DI, ES
48;--------------------------------------------------------------------
49ALIGN JUMP_ALIGN
50Buffers_IsXtideUniversalBiosLoaded:
51 test BYTE [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
52 jnz SHORT .FileOrBiosLoaded
53 test sp, sp ; Clear ZF
54 ret
55
56.FileOrBiosLoaded:
57 call Buffers_GetFileBufferToESDI
58 ; Fall to Buffers_IsXtideUniversalBiosSignatureInESDI
59
60
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
67; Cleared if no file or some other file is loaded
68; Corrupts registers:
69; CX, SI
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72Buffers_IsXtideUniversalBiosSignatureInESDI:
73 push di
74
75 mov si, g_sXtideUniversalBiosSignature
76 add di, BYTE ROMVARS.rgbSign
77 mov cx, XTIDE_SIGNATURE_LENGTH / 2
78%ifdef CLD_NEEDED
79 cld
80%endif
81 eSEG_STR repe, cs, cmpsw
82
83 pop di
84 ret
85
86
87;--------------------------------------------------------------------
88; Buffers_IsXTbuildLoaded
89; Parameters:
90; Nothing
91; Returns:
92; ZF: Set if XT or XT+ build is loaded
93; Cleared if some other (AT, 386) build is loaded
94; Corrupts registers:
95; Nothing
96;--------------------------------------------------------------------
97ALIGN JUMP_ALIGN
98Buffers_IsXTbuildLoaded:
99%strlen BUILD_TYPE_OFFSET TITLE_STRING_START
100 push es
101 push di
102 call Buffers_GetFileBufferToESDI
103 cmp WORD [es:di+ROMVARS.szTitle+BUILD_TYPE_OFFSET+1], 'XT' ; +1 is for '('
104 pop di
105 pop es
106 ret
107%undef BUILD_TYPE_OFFSET
108
109
110;--------------------------------------------------------------------
111; Buffers_NewBiosWithSizeInDXCXandSourceInALhasBeenLoadedForConfiguration
112; Parameters:
113; AL: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
114; DX:CX: EEPROM size in bytes
115; Returns:
116; Nothing
117; Corrupts registers:
118; CX, DX
119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121Buffers_NewBiosWithSizeInDXCXandSourceInALhasBeenLoadedForConfiguration:
122 and BYTE [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
123 or [cs:g_cfgVars+CFGVARS.wFlags], al
124 shr dx, 1
125 rcr cx, 1
126 adc cx, BYTE 0 ; Round up to next WORD
127 mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
128 ret
129
130
131;--------------------------------------------------------------------
132; Buffers_SetUnsavedChanges
133; Buffers_ClearUnsavedChanges
134; Parameters:
135; SS:BP: Menu handle
136; Returns:
137; Nothing
138; Corrupts registers:
139; Nothing
140;--------------------------------------------------------------------
141ALIGN JUMP_ALIGN
142Buffers_SetUnsavedChanges:
143 or BYTE [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
144 ret
145
146ALIGN JUMP_ALIGN
147Buffers_ClearUnsavedChanges:
148 and BYTE [cs:g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
149 ret
150
151
152;--------------------------------------------------------------------
153; Buffers_SaveChangesIfFileLoaded
154; Parameters:
155; Nothing
156; Returns:
157; Nothing
158; Corrupts registers:
159; AX, BX, CX, SI, DI
160;--------------------------------------------------------------------
161ALIGN JUMP_ALIGN
162Buffers_SaveChangesIfFileLoaded:
163 mov al, [cs:g_cfgVars+CFGVARS.wFlags]
164 and al, FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED
165 jz SHORT .NothingToSave
166 jpo SHORT .NothingToSave
167 mov bx, g_szDlgSaveChanges
168 call Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX
169 jnz SHORT .NothingToSave
170 jmp BiosFile_SaveUnsavedChanges
171ALIGN JUMP_ALIGN
172.NothingToSave:
173 ret
174
175;--------------------------------------------------------------------
176; Buffers_GetSelectedEepromSizeInWordsToAX
177; Parameters:
178; Nothing
179; Returns:
180; AX: Selected EEPROM size in WORDs
181; Corrupts registers:
182; BX
183;--------------------------------------------------------------------
184ALIGN JUMP_ALIGN
185Buffers_GetSelectedEepromSizeInWordsToAX:
186 eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromType]
187 mov ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
188
189 cmp bl, EEPROM_TYPE.SST_39SF
190 jnz SHORT .HaveEepromSize
191 cmp ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
192 jae SHORT .HaveEepromSize
193 shl ax, 1 ; Auto-double SST size when too small.
194.HaveEepromSize:
195 ret
196
197;--------------------------------------------------------------------
198; Buffers_AppendZeroesIfNeeded
199; Parameters:
200; Nothing
201; Returns:
202; Nothing
203; Corrupts registers:
204; AX, BX, CX, DI
205;--------------------------------------------------------------------
206ALIGN JUMP_ALIGN
207Buffers_AppendZeroesIfNeeded:
208 push es
209
210 call Buffers_GetSelectedEepromSizeInWordsToAX
211 mov cx, ax
212 sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
213 jbe SHORT .NoNeedToAppendZeroes
214
215 call Buffers_GetFileBufferToESDI
216 mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
217 eSHL_IM ax, 1
218 add di, ax ; ES:DI now point first unused image byte
219 xor ax, ax
220%ifdef CLD_NEEDED
221 cld
222%endif
223 rep stosw
224ALIGN JUMP_ALIGN
225.NoNeedToAppendZeroes:
226 pop es
227 ret
228
229
230;--------------------------------------------------------------------
231; Buffers_GenerateChecksum
232; Parameters:
233; Nothing
234; Returns:
235; Nothing
236; Corrupts registers:
237; AX, BX, CX, DI
238;--------------------------------------------------------------------
239ALIGN JUMP_ALIGN
240Buffers_GenerateChecksum:
241 push es
242 push dx
243
244 call Buffers_GetFileBufferToESDI
245 call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
246%ifdef CLD_NEEDED
247 cld
248%endif
249
250; Compatibility fix for 3Com 3C503 cards where the ASIC returns 8080h as the last two bytes of the ROM.
251
252 ; Assume the BIOS size is not 8K, ie generate a normal checksum.
253 dec cx
254 mov ax, 100h
255 cmp cx, 8192 - 1
256 jne SHORT .BiosSizeIsNot8K
257 ; The BIOS size is 8K and therefore a potential candidate for a 3Com 3C503 card.
258 mov cl, (8192 - 3) & 0FFh
259 mov ah, 3
260ALIGN JUMP_ALIGN
261.BiosSizeIsNot8K:
262.SumNextByte:
263 add al, [es:di]
264 inc di
265 loop .SumNextByte
266.NextChecksumByte:
267 neg al
268 stosb
269 dec ah
270 jnz SHORT .NextChecksumByte
271
272 pop dx
273 pop es
274 ret
275
276
277;--------------------------------------------------------------------
278; Buffers_GetRomvarsFlagsToAX
279; Parameters:
280; Nothing
281; Returns:
282; AX: ROMVARS.wFlags
283; Corrupts registers:
284; BX
285;--------------------------------------------------------------------
286ALIGN JUMP_ALIGN
287Buffers_GetRomvarsFlagsToAX:
288 mov bx, ROMVARS.wFlags
289 ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
290
291;--------------------------------------------------------------------
292; Buffers_GetRomvarsValueToAXfromOffsetInBX
293; Parameters:
294; BX: ROMVARS offset
295; Returns:
296; AX: Value
297; Corrupts registers:
298; Nothing
299;--------------------------------------------------------------------
300ALIGN JUMP_ALIGN
301Buffers_GetRomvarsValueToAXfromOffsetInBX:
302 push es
303 push di
304 call Buffers_GetFileBufferToESDI
305 mov ax, [es:bx+di]
306 pop di
307 pop es
308 ret
309
310
311;--------------------------------------------------------------------
312; Buffers_GetIdeControllerCountToCX
313; Parameters:
314; SS:BP: Menu handle
315; Returns:
316; CX: Number of IDE controllers to configure
317; ES:DI: Ptr to file buffer
318; Corrupts registers:
319; Nothing
320;--------------------------------------------------------------------
321ALIGN JUMP_ALIGN
322Buffers_GetIdeControllerCountToCX:
323 xor cx, cx
324 call Buffers_GetFileBufferToESDI
325 or cl, [es:di+ROMVARS.bIdeCnt]
326 jnz SHORT .LimitControllerCountForLiteMode
327 inc cx ; Make sure there is at least one controller
328
329.LimitControllerCountForLiteMode:
330 test BYTE [es:di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
331 jnz SHORT .ReturnControllerCountInCX
332 MIN_U cl, MAX_LITE_MODE_CONTROLLERS
333
334.ReturnControllerCountInCX:
335 ret
336
337
338;--------------------------------------------------------------------
339; Buffers_GetFlashComparisonBufferToESDI
340; Buffers_GetFileDialogItemBufferToESDI
341; Buffers_GetFileBufferToESDI
342; Parameters:
343; Nothing
344; Returns:
345; ES:DI: Ptr to file buffer
346; Corrupts registers:
347; Nothing
348;--------------------------------------------------------------------
349ALIGN JUMP_ALIGN
350Buffers_GetFlashComparisonBufferToESDI:
351Buffers_GetFileDialogItemBufferToESDI:
352 call Buffers_GetFileBufferToESDI
353 mov di, es
354 SKIP2B f
355Buffers_GetFileBufferToESDI:
356 mov di, cs
357 add di, 1000h ; Change to next 64k page
358 mov es, di
359 xor di, di ; Ptr now in ES:DI
360 ret
Note: See TracBrowser for help on using the repository browser.