source: xtideuniversalbios/trunk/Configurator/Src/EEPROM.asm@ 408

Last change on this file since 408 was 293, checked in by krille_n_@…, 13 years ago

Commit 1/2 (Library, Configurators and Serial Server):

  • Changed Emulate.inc so that making 286 and 386 versions now works. Additionally, only one processor type define is needed in the makefile.
  • Minor optimizations.
  • Fixed spelling and did some cleaning.
File size: 7.1 KB
RevLine 
[2]1; Project name : XTIDE Univeral BIOS Configurator
2; Description : Functions for managing EEPROM contents.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Loads XTIDE Universal BIOS from ROM to RAM to be configured.
9;
10; EEPROM_LoadBiosFromROM
11; Parameters:
12; Nothing
13; Returns:
14; CX: BIOS size in bytes
15; Corrupts registers:
16; AX, BX, ES
17;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19EEPROM_LoadBiosFromROM:
20 push si
21 call EEPROM_FindXtideUniversalBiosROM
22 xor si, si ; Load from beginning of ROM
[293]23 eMOVZX cx, [es:ROMVARS.bRomSize]
[2]24 eSHL_IM cx, 9 ; *= 512 for byte count
25 call EEPROM_LoadBytesFromROM
26 pop si
27 ret
28
29
30;--------------------------------------------------------------------
31; Loads old XTIDE Universal BIOS settings from ROM to RAM.
32;
33; EEPROM_LoadSettingsFromRomToRam
34; Parameters:
35; Nothing
36; Returns:
37; Nothing
38; Corrupts registers:
39; AX, BX, CX, SI, ES
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42EEPROM_LoadSettingsFromRomToRam:
43 mov cx, ROMVARS_size - ROMVARS.wFlags ; Number of bytes to load
44 mov si, ROMVARS.wFlags ; Offset where to start loading
45 ; Fall to EEPROM_LoadBytesFromROM
46
47;--------------------------------------------------------------------
48; Loads wanted number of bytes from XTIDE Universal BIOS ROM.
49;
50; EEPROM_LoadBytesFromROM
51; Parameters:
52; CX: Number of bytes to load from beginning of ROM
53; SI: Offset to first byte
54; Returns:
55; Nothing
56; Corrupts registers:
57; AX, BX, SI, ES
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60EEPROM_LoadBytesFromROM:
61 push ds
62 push di
63 push cx
64
65 call EEPROM_FindXtideUniversalBiosROM
66 push es
67 pop ds ; DS:SI points to ROM
68 push cs
69 pop es
70 lea di, [si+g_cfgVars+CFGVARS.rgbEepromBuffers] ; ES:DI points to RAM buffer
71 shr cx, 1 ; Byte count to word count
72 cld ; MOVSW to increment SI and DI
73 rep movsw ; Read from ROM to RAM
74
75 pop cx
76 pop di
77 pop ds
78 ret
79
80
81;--------------------------------------------------------------------
82; Finds EEPROM using known signature.
83;
84; EEPROM_FindXtideUniversalBiosROM
85; Parameters:
86; Nothing
87; Returns:
88; ES: EEPROM segment
89; CF: Set if EEPROM was found
90; Cleared if EEPROM not found
91; Corrupts registers:
92; AX, BX
93;--------------------------------------------------------------------
94ALIGN JUMP_ALIGN
95EEPROM_FindXtideUniversalBiosROM:
96 push di
97 xor di, di ; Zero DI
98 mov bx, 0C000h ; First possible ROM segment
99ALIGN JUMP_ALIGN
100.SegmentLoop:
101 mov es, bx ; Possible ROM segment to ES
102 call EEPROM_IsXtideUniversalBiosSignaturePresent
103 je SHORT .RomFound
104 add bx, 200h ; Increment by 8kB
105 jnc SHORT .SegmentLoop ; Loop until segment overflows
106 pop di
107 clc
108 ret
109ALIGN JUMP_ALIGN
110.RomFound:
111 pop di
112 stc
113 ret
114
115
116;--------------------------------------------------------------------
117; Checks if XTIDE Universal BIOS is loaded to be configured.
118;
119; EEPROM_IsXtideUniversalBiosLoaded
120; Parameters:
121; Nothing
122; Returns:
123; ZF: Set if signature found
124; Cleared if signature not present
125; Corrupts registers:
126; AX
127;--------------------------------------------------------------------
128ALIGN JUMP_ALIGN
129EEPROM_IsXtideUniversalBiosLoaded:
130 push es
131 push di
132
133 push cs
134 pop es
135 mov di, g_cfgVars+CFGVARS.rgbEepromBuffers
136 call EEPROM_IsXtideUniversalBiosSignaturePresent
137
138 pop di
139 pop es
140 ret
141
142
143;--------------------------------------------------------------------
144; Checks if ROM contains Xtide Universal BIOS signature.
145;
146; EEPROM_IsXtideUniversalBiosSignaturePresent
147; Parameters:
148; ES:DI: Ptr to ROM contents
149; Returns:
150; ZF: Set if signature found
151; Cleared if signature not present
152; Corrupts registers:
153; AX
154;--------------------------------------------------------------------
155ALIGN JUMP_ALIGN
156EEPROM_IsXtideUniversalBiosSignaturePresent:
157 push ds
158 push di
159 push si
160 push cx
161
162 push cs
163 pop ds
164 mov si, g_szSignature ; DS:SI points to known signature string
165 add di, BYTE ROMVARS.rgbSign ; ES:DI points to possible ROM signature
166 mov cx, LEN_SIGNATURE/2 ; Signature string length in words
167 cld ; CMPSW to increment DI and SI
168 repe cmpsw
169
170 pop cx
171 pop si
172 pop di
173 pop ds
174 ret
175
176
177;--------------------------------------------------------------------
178; Called when new BIOS has been loaded to be flashed.
179;
180; EEPROM_NewBiosLoadedFromFileOrROM
181; Parameters:
182; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
183; CX: EEPROM size in bytes
184; Returns:
185; Nothing
186; Corrupts registers:
187; Nothing
188;--------------------------------------------------------------------
189ALIGN JUMP_ALIGN
190EEPROM_NewBiosLoadedFromFileOrROM:
191 and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
192 or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
193 mov WORD [cs:g_cfgVars+CFGVARS.wEepromSize], cx
194 ret
195
196
197;--------------------------------------------------------------------
198; Generated checksum byte to the end of BIOS image buffer.
199;
200; EEPROM_GenerateChecksum
201; Parameters:
202; Nothing
203; Returns:
204; Nothing
205; Corrupts registers:
206; AX, BX, CX
207;--------------------------------------------------------------------
208ALIGN JUMP_ALIGN
209EEPROM_GenerateChecksum:
210 xor ax, ax
211 mov bx, g_cfgVars+CFGVARS.rgbEepromBuffers
212 mov cx, [cs:g_cfgVars+CFGVARS.wEepromSize]
213 dec cx
214ALIGN JUMP_ALIGN
215.ByteLoop:
216 add al, [cs:bx]
217 inc bx
218 loop .ByteLoop
219 neg al
220 mov [cs:bx], al
221 ret
222
223
224;--------------------------------------------------------------------
225; Returns pointer source data to be flashed to EEPROM.
226;
227; EEPROM_GetSourceBufferPointerToDSSI
228; Parameters:
229; Nothing
230; Returns:
231; DS:SI: Ptr to source buffer
232; Corrupts registers:
233; Nothing
234;--------------------------------------------------------------------
235ALIGN JUMP_ALIGN
236EEPROM_GetSourceBufferPointerToDSSI:
237 push cs
238 pop ds
239 mov si, g_cfgVars+CFGVARS.rgbEepromBuffers
240 ret
241
242
243;--------------------------------------------------------------------
244; Returns pointer to comparison buffer for old EEPROM data.
245;
246; EEPROM_GetComparisonBufferPointerToDSBX
247; Parameters:
248; Nothing
249; Returns:
250; DS:BX: Ptr to verify buffer
251; Corrupts registers:
252; Nothing
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255EEPROM_GetComparisonBufferPointerToDSBX:
256 push cs
257 pop ds
258 mov bx, [cs:g_cfgVars+CFGVARS.wEepromSize]
259 add bx, g_cfgVars+CFGVARS.rgbEepromBuffers
260 ret
261
262
263;--------------------------------------------------------------------
264; Returns pointer to EEPROM where to flash.
265;
266; EEPROM_GetEepromPointerToESDI
267; Parameters:
268; Nothing
269; Returns:
270; ES:DI: Ptr to EEPROM
271; Corrupts registers:
272; Nothing
273;--------------------------------------------------------------------
274ALIGN JUMP_ALIGN
275EEPROM_GetEepromPointerToESDI:
276 mov es, [cs:g_cfgVars+CFGVARS.wEepromSegment]
277 xor di, di
278 ret
Note: See TracBrowser for help on using the repository browser.