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

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

Changes to XTIDE Universal BIOS Configurator v2:

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