source: xtideuniversalbios/tags/Configurator_for_v2.0.0_beta1/Src/EEPROM.asm@ 625

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