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

Last change on this file since 129 was 118, checked in by Tomi Tilli, 14 years ago

Changes to Configurator v2:

  • Warm boot flag is now reset when rebooting.
  • Checksum generation no longer corrupts images when image size is less than EEPROM size.
  • Configuration and flashing menu items are now displayed when loading BIOS from EEPROM.
File size: 6.8 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_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration
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 mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
86 ret
87
88
89;--------------------------------------------------------------------
90; Buffers_SetUnsavedChanges
91; Buffers_ClearUnsavedChanges
92; Parameters:
93; SS:BP: Menu handle
94; Returns:
95; Nothing
96; Corrupts registers:
97; Nothing
98;--------------------------------------------------------------------
99ALIGN JUMP_ALIGN
100Buffers_SetUnsavedChanges:
101 or WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
102 ret
103
104ALIGN JUMP_ALIGN
105Buffers_ClearUnsavedChanges:
106 and WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
107 ret
108
109
110;--------------------------------------------------------------------
111; Buffers_SaveChangesIfFileLoaded
112; Parameters:
113; Nothing
114; Returns:
115; Nothing
116; Corrupts registers:
117; AX, BX, CX, SI, DI
118;--------------------------------------------------------------------
119ALIGN JUMP_ALIGN
120Buffers_SaveChangesIfFileLoaded:
121 mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
122 and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
123 cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
124 jne SHORT .NothingToSave
125 call Dialogs_DisplaySaveChangesDialog
126 jnz SHORT .NothingToSave
127 jmp BiosFile_SaveUnsavedChanges
128ALIGN JUMP_ALIGN
129.NothingToSave:
130 ret
131
132
133;--------------------------------------------------------------------
134; Buffers_AppendZeroesIfNeeded
135; Parameters:
136; Nothing
137; Returns:
138; Nothing
139; Corrupts registers:
140; AX, CX, DI
141;--------------------------------------------------------------------
142ALIGN JUMP_ALIGN
143Buffers_AppendZeroesIfNeeded:
144 push es
145
146 eMOVZX di, BYTE [cs:g_cfgVars+CFGVARS.bEepromType]
147 mov cx, [cs:di+g_rgwEepromTypeToSizeInWords]
148 sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
149 jle SHORT .NoNeedToAppendZeroes
150
151 call Buffers_GetFileBufferToESDI
152 mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
153 shl ax, 1
154 add di, ax ; ES:DI now point first unused image byte
155 xor ax, ax
156 cld
157 rep stosw
158ALIGN JUMP_ALIGN
159.NoNeedToAppendZeroes:
160 pop es
161 ret
162
163
164;--------------------------------------------------------------------
165; Buffers_GenerateChecksum
166; Parameters:
167; Nothing
168; Returns:
169; Nothing
170; Corrupts registers:
171; AX, BX, CX, DI
172;--------------------------------------------------------------------
173ALIGN JUMP_ALIGN
174Buffers_GenerateChecksum:
175 push es
176
177 call Buffers_GetFileBufferToESDI
178 mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
179 call EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX
180 shl cx, 1 ; Words to bytes
181 dec cx ; Leave space for checksum byte
182 xor ax, ax
183ALIGN JUMP_ALIGN
184.SumNextByte:
185 add al, [es:di]
186 inc di
187 loop .SumNextByte
188 neg al
189 mov [es:di], al
190
191 pop es
192 ret
193
194
195;--------------------------------------------------------------------
196; Buffers_GetRomvarsFlagsToAX
197; Parameters:
198; Nothing
199; Returns:
200; AX: ROMVARS.wFlags
201; Corrupts registers:
202; BX
203;--------------------------------------------------------------------
204ALIGN JUMP_ALIGN
205Buffers_GetRomvarsFlagsToAX:
206 mov bx, ROMVARS.wFlags
207 ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
208
209;--------------------------------------------------------------------
210; Buffers_GetRomvarsValueToAXfromOffsetInBX
211; Parameters:
212; BX: ROMVARS offset
213; Returns:
214; AX: Value
215; Corrupts registers:
216; Nothing
217;--------------------------------------------------------------------
218ALIGN JUMP_ALIGN
219Buffers_GetRomvarsValueToAXfromOffsetInBX:
220 push es
221 push di
222 call Buffers_GetFileBufferToESDI
223 mov ax, [es:bx+di]
224 pop di
225 pop es
226 ret
227
228
229;--------------------------------------------------------------------
230; Buffers_GetFileBufferToESDI
231; Buffers_GetFlashComparisonBufferToESDI
232; Buffers_GetFileDialogItemBufferToESDI
233; Parameters:
234; Nothing
235; Returns:
236; ES:DI: Ptr to file buffer
237; Corrupts registers:
238; Nothing
239;--------------------------------------------------------------------
240ALIGN JUMP_ALIGN
241Buffers_GetFlashComparisonBufferToESDI:
242Buffers_GetFileDialogItemBufferToESDI:
243 call Buffers_GetFileBufferToESDI
244 push di
245 mov di, es
246 add di, 1000h ; Third 64k page
247 mov es, di
248 pop di
249 ret
250ALIGN JUMP_ALIGN
251Buffers_GetFileBufferToESDI:
252 mov di, cs
253 add di, 1000h ; Change to next 64k page
254 mov es, di
255 xor di, di ; Ptr now in ES:DI
256 ret
Note: See TracBrowser for help on using the repository browser.