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

Last change on this file since 369 was 369, checked in by gregli@…, 13 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 8.0 KB
Line 
1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : Functions for accessing file and flash buffers.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Buffers_Clear
9; Parameters:
10; Nothing
11; Returns:
12; Nothing
13; Corrupts registers:
14; AX, CX, DI, ES
15;--------------------------------------------------------------------
16ALIGN JUMP_ALIGN
17Buffers_Clear:
18 call Buffers_GetFileBufferToESDI
19 mov cx, ROMVARS_size
20 jmp Memory_ZeroESDIwithSizeInCX
21
22
23;--------------------------------------------------------------------
24; Buffers_IsXtideUniversalBiosLoaded
25; Parameters:
26; Nothing
27; Returns:
28; ZF: Set if supported version of XTIDE Universal BIOS is loaded
29; Cleared no file or some other file is loaded
30; Corrupts registers:
31; CX, SI, DI, ES
32;--------------------------------------------------------------------
33ALIGN JUMP_ALIGN
34Buffers_IsXtideUniversalBiosLoaded:
35 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
36 jz SHORT .NoFileOrBiosLoaded
37
38 call Buffers_GetFileBufferToESDI
39 jmp SHORT Buffers_IsXtideUniversalBiosSignatureInESDI
40.NoFileOrBiosLoaded:
41 or cl, 1 ; Clear ZF
42 ret
43
44
45;--------------------------------------------------------------------
46; Buffers_IsXtideUniversalBiosSignatureInESDI
47; Parameters:
48; ES:DI: Ptr to possible XTIDE Universal BIOS location
49; Returns:
50; ZF: Set if supported version of XTIDE Universal BIOS is loaded
51; Cleared no file or some other file is loaded
52; Corrupts registers:
53; CX, SI
54;--------------------------------------------------------------------
55ALIGN JUMP_ALIGN
56Buffers_IsXtideUniversalBiosSignatureInESDI:
57 push di
58
59 mov si, g_szXtideUniversalBiosSignature
60 add di, BYTE ROMVARS.rgbSign
61 mov cx, XTIDE_SIGNATURE_LENGTH / 2
62 cld
63 eSEG_STR repe, cs, cmpsw
64
65 pop di
66 ret
67
68
69;--------------------------------------------------------------------
70; Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
71; Parameters:
72; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
73; DX:CX: EEPROM size in bytes
74; Returns:
75; Nothing
76; Corrupts registers:
77; AX, CX, DX
78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration:
81 and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
82 or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
83 shr dx, 1
84 rcr cx, 1
85 adc cx, BYTE 0 ; Round up to next WORD
86 mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
87 ret
88
89
90;--------------------------------------------------------------------
91; Buffers_SetUnsavedChanges
92; Buffers_ClearUnsavedChanges
93; Parameters:
94; SS:BP: Menu handle
95; Returns:
96; Nothing
97; Corrupts registers:
98; Nothing
99;--------------------------------------------------------------------
100ALIGN JUMP_ALIGN
101Buffers_SetUnsavedChanges:
102 or WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
103 ret
104
105ALIGN JUMP_ALIGN
106Buffers_ClearUnsavedChanges:
107 and WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
108 ret
109
110;--------------------------------------------------------------------
111; Buffers_TestLoaded
112; Parameters:
113; SS:BP: Menu handle
114; Returns:
115; CF: Set = BIOS Loaded
116; Corrupts registers:
117; AX
118;--------------------------------------------------------------------
119ALIGN JUMP_ALIGN
120Buffers_TestLoaded:
121 test word [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED ; Clears CF
122 jz .done
123 stc
124.done:
125 ret
126
127
128;--------------------------------------------------------------------
129; Buffers_SaveChangesIfFileLoaded
130; Parameters:
131; Nothing
132; Returns:
133; Nothing
134; Corrupts registers:
135; AX, BX, CX, SI, DI
136;--------------------------------------------------------------------
137ALIGN JUMP_ALIGN
138Buffers_SaveChangesIfFileLoaded:
139 mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
140 and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
141 cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
142 jne SHORT .NothingToSave
143 call Dialogs_DisplaySaveChangesDialog
144 jnz SHORT .NothingToSave
145 jmp BiosFile_SaveUnsavedChanges
146ALIGN JUMP_ALIGN
147.NothingToSave:
148 ret
149
150
151;--------------------------------------------------------------------
152; Buffers_AppendZeroesIfNeeded
153; Parameters:
154; Nothing
155; Returns:
156; Nothing
157; Corrupts registers:
158; AX, CX, DI
159;--------------------------------------------------------------------
160ALIGN JUMP_ALIGN
161Buffers_AppendZeroesIfNeeded:
162 push es
163
164 eMOVZX di, [cs:g_cfgVars+CFGVARS.bEepromType]
165 mov cx, [cs:di+g_rgwEepromTypeToSizeInWords]
166 sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
167 jle SHORT .NoNeedToAppendZeroes
168
169 call Buffers_GetFileBufferToESDI
170 mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
171 shl ax, 1
172 add di, ax ; ES:DI now point first unused image byte
173 xor ax, ax
174 cld
175 rep stosw
176ALIGN JUMP_ALIGN
177.NoNeedToAppendZeroes:
178 pop es
179 ret
180
181
182;--------------------------------------------------------------------
183; Buffers_GenerateChecksum
184; Parameters:
185; Nothing
186; Returns:
187; Nothing
188; Corrupts registers:
189; AX, BX, CX, DI
190;--------------------------------------------------------------------
191ALIGN JUMP_ALIGN
192Buffers_GenerateChecksum:
193 push es
194
195 call Buffers_GetFileBufferToESDI
196 mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
197 call EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX
198 shl cx, 1 ; Words to bytes
199 dec cx ; Leave space for checksum byte
200 xor ax, ax
201ALIGN JUMP_ALIGN
202.SumNextByte:
203 add al, [es:di]
204 inc di
205 loop .SumNextByte
206 neg al
207 mov [es:di], al
208
209 pop es
210 ret
211
212
213;--------------------------------------------------------------------
214; Buffers_GetRomvarsFlagsToAX
215; Parameters:
216; Nothing
217; Returns:
218; AX: ROMVARS.wFlags
219; Corrupts registers:
220; BX
221;--------------------------------------------------------------------
222ALIGN JUMP_ALIGN
223Buffers_GetRomvarsFlagsToAX:
224 mov bx, ROMVARS.wFlags
225 ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
226
227;--------------------------------------------------------------------
228; Buffers_GetRomvarsValueToAXfromOffsetInBX
229; Parameters:
230; BX: ROMVARS offset
231; Returns:
232; AX: Value
233; Corrupts registers:
234; Nothing
235;--------------------------------------------------------------------
236ALIGN JUMP_ALIGN
237Buffers_GetRomvarsValueToAXfromOffsetInBX:
238 push es
239 push di
240 call Buffers_GetFileBufferToESDI
241 mov ax, [es:bx+di]
242 pop di
243 pop es
244 ret
245
246
247;--------------------------------------------------------------------
248; Buffers_GetIdeControllerCountToCX
249; Parameters:
250; SS:BP: Menu handle
251; Returns:
252; CX: Number of IDE controllers to configure
253; ES:DI: Ptr to file buffer
254; Corrupts registers:
255; AX
256;--------------------------------------------------------------------
257ALIGN JUMP_ALIGN
258Buffers_GetIdeControllerCountToCX:
259 call Buffers_GetFileBufferToESDI
260 mov al, [es:di+ROMVARS.bIdeCnt]
261
262 ; Limit controller count for lite mode
263 test BYTE [es:di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
264 jnz SHORT .ReturnControllerCountInCX
265 MIN_U al, MAX_LITE_MODE_CONTROLLERS
266
267.ReturnControllerCountInCX:
268 cbw ; A maximum of 127 controllers should be sufficient
269 xchg cx, ax
270 ret
271
272
273;--------------------------------------------------------------------
274; Buffers_GetFileBufferToESDI
275; Buffers_GetFlashComparisonBufferToESDI
276; Buffers_GetFileDialogItemBufferToESDI
277; Parameters:
278; Nothing
279; Returns:
280; ES:DI: Ptr to file buffer
281; Corrupts registers:
282; Nothing
283;--------------------------------------------------------------------
284ALIGN JUMP_ALIGN
285Buffers_GetFlashComparisonBufferToESDI:
286Buffers_GetFileDialogItemBufferToESDI:
287 call Buffers_GetFileBufferToESDI
288 push di
289 mov di, es
290 add di, 1000h ; Third 64k page
291 mov es, di
292 pop di
293 ret
294ALIGN JUMP_ALIGN
295Buffers_GetFileBufferToESDI:
296 mov di, cs
297 add di, 1000h ; Change to next 64k page
298 mov es, di
299 xor di, di ; Ptr now in ES:DI
300 ret
Note: See TracBrowser for help on using the repository browser.