source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm@ 119

Last change on this file since 119 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: 5.2 KB
Line 
1; Project name : XTIDE Univeral BIOS Configurator v2
2; Author : Tomi Tilli
3; Description : Functions for managing EEPROM contents.
4
5; Section containing initialized data
6SECTION .data
7
8ALIGN WORD_ALIGN
9g_rgwEepromTypeToSizeInWords:
10 dw (2<<10) / 2 ; EEPROM_TYPE.2816_2kiB
11 dw (8<<10) / 2
12 dw (32<<10) / 2
13 dw (64<<10) / 2
14
15g_rgwEepromPageToSizeInBytes:
16 dw 1 ; EEPROM_PAGE.1_byte
17 dw 2
18 dw 4
19 dw 8
20 dw 16
21 dw 32
22 dw 64
23
24
25
26; Section containing code
27SECTION .text
28
29;--------------------------------------------------------------------
30; EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX
31; Parameters:
32; AX: Image size in WORDs
33; Returns:
34; CX: Required EEPROM size in WORDs
35; CF: Set if EEPROM size found
36; Cleared if no valid EEPROM found
37; Corrupts registers:
38; BX
39;--------------------------------------------------------------------
40ALIGN JUMP_ALIGN
41EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX:
42 mov bx, g_rgwEepromTypeToSizeInWords
43 mov cx, NUMBER_OF_EEPROM_TYPES
44ALIGN JUMP_ALIGN
45.CheckNextEepromSize:
46 cmp ax, [cs:bx]
47 jbe SHORT .ReturnEepromSizeInAX
48 inc bx
49 inc bx
50 loop .CheckNextEepromSize
51 clc ; None of the supported EEPROMs are large enough
52 ret
53ALIGN JUMP_ALIGN
54.ReturnEepromSizeInAX:
55 mov cx, [cs:bx]
56 stc
57 ret
58
59
60;--------------------------------------------------------------------
61; EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX
62; Parameters:
63; Nothing
64; Returns:
65; DX:CX: BIOS size in bytes
66; Corrupts registers:
67; AX, BX, SI, DI
68;--------------------------------------------------------------------
69ALIGN JUMP_ALIGN
70EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX:
71 push es
72
73 call EEPROM_FindXtideUniversalBiosROMtoESDI
74 call .GetXtideUniversalBiosSizeFromEStoDXCX
75 xor si, si ; Load from beginning of ROM
76 call LoadBytesFromRomToRamBuffer
77
78 call .GetXtideUniversalBiosSizeFromEStoDXCX
79 pop es
80 ret
81
82;--------------------------------------------------------------------
83; .GetXtideUniversalBiosSizeFromEStoDXCX
84; Parameters:
85; Nothing
86; Returns:
87; DX:CX: Bios size in bytes
88; Corrupts registers:
89; Nothing
90;--------------------------------------------------------------------
91ALIGN JUMP_ALIGN
92.GetXtideUniversalBiosSizeFromEStoDXCX:
93 xor dx, dx
94 eMOVZX cx, BYTE [es:ROMVARS.bRomSize]
95 eSHL_IM cx, 9 ; *= 512 for byte count
96 ret
97
98
99;--------------------------------------------------------------------
100; EEPROM_LoadOldSettingsFromRomToRamBuffer
101; Parameters:
102; Nothing
103; Returns:
104; CF: Set if EEPROM was found
105; Cleared if EEPROM not found
106; Corrupts registers:
107; AX, BX, CX, SI, DI
108;--------------------------------------------------------------------
109ALIGN JUMP_ALIGN
110EEPROM_LoadOldSettingsFromRomToRamBuffer:
111 mov cx, ROMVARS_size - ROMVARS.wFlags ; Number of bytes to load
112 mov si, ROMVARS.wFlags ; Offset where to start loading
113 ; Fall to LoadBytesFromRomToRamBuffer
114
115;--------------------------------------------------------------------
116; LoadBytesFromRomToRamBuffer
117; Parameters:
118; CX: Number of bytes to load from ROM
119; SI: Offset to first byte to load
120; Returns:
121; CF: Set if EEPROM was found
122; Cleared if EEPROM not found
123; Corrupts registers:
124; AX, BX, CX, SI, DI
125;--------------------------------------------------------------------
126ALIGN JUMP_ALIGN
127LoadBytesFromRomToRamBuffer:
128 push es
129 push ds
130
131 call EEPROM_FindXtideUniversalBiosROMtoESDI
132 jnc SHORT .XtideUniversalBiosNotFound
133 push es
134 pop ds ; DS:SI points to ROM
135
136 call Buffers_GetFileBufferToESDI
137 mov di, si ; ES:DI points to RAM buffer
138
139 cld
140 call Memory_CopyCXbytesFromDSSItoESDI
141 stc
142
143.XtideUniversalBiosNotFound:
144 pop ds
145 pop es
146 ret
147
148
149;--------------------------------------------------------------------
150; EEPROM_FindXtideUniversalBiosROMtoESDI
151; Parameters:
152; Nothing
153; Returns:
154; ES:DI: EEPROM segment
155; CF: Set if EEPROM was found
156; Cleared if EEPROM not found
157; Corrupts registers:
158; AX, BX
159;--------------------------------------------------------------------
160ALIGN JUMP_ALIGN
161EEPROM_FindXtideUniversalBiosROMtoESDI:
162 push si
163 push cx
164
165 xor di, di ; Zero DI (offset)
166 mov bx, 0C000h ; First possible ROM segment
167ALIGN JUMP_ALIGN
168.SegmentLoop:
169 mov es, bx ; Possible ROM segment to ES
170 call Buffers_IsXtideUniversalBiosSignatureInESDI
171 je SHORT .RomFound
172 add bx, 200h ; Increment by 8kB
173 jnc SHORT .SegmentLoop ; Loop until segment overflows
174 clc
175 jmp SHORT .ReturnWithoutUpdatingCF
176ALIGN JUMP_ALIGN
177.RomFound:
178 stc
179.ReturnWithoutUpdatingCF:
180 pop cx
181 pop si
182 ret
183
184
185;--------------------------------------------------------------------
186; EEPROM_LoadFromRomToRamComparisonBuffer
187; Parameters:
188; Nothing
189; Returns:
190; Nothing
191; Corrupts registers:
192; BX, CX, SI, DI
193;--------------------------------------------------------------------
194ALIGN JUMP_ALIGN
195EEPROM_LoadFromRomToRamComparisonBuffer:
196 push es
197 push ds
198
199 mov ds, [cs:g_cfgVars+CFGVARS.wEepromSegment]
200 xor si, si
201 call Buffers_GetFlashComparisonBufferToESDI
202 eMOVZX bx, BYTE [cs:g_cfgVars+CFGVARS.bEepromType]
203 mov cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
204 cld
205 rep movsw
206
207 pop ds
208 pop es
209 ret
Note: See TracBrowser for help on using the repository browser.