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

Last change on this file since 549 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 5.2 KB
Line 
1; Project name : XTIDE Univeral BIOS Configurator v2
2; Description : Functions for managing EEPROM contents.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing initialized data
21SECTION .data
22
23ALIGN WORD_ALIGN
24g_rgwEepromTypeToSizeInWords:
25 dw (2<<10) / 2 ; EEPROM_TYPE.2816_2kiB
26 dw (8<<10) / 2
27 dw (8<<10) / 2 ; EEPROM_TYPE.2864_8kiB_MOD
28 dw (32<<10) / 2
29 dw (64<<10) / 2
30
31g_rgwEepromPageToSizeInBytes:
32 dw 1 ; EEPROM_PAGE.1_byte
33 dw 2
34 dw 4
35 dw 8
36 dw 16
37 dw 32
38 dw 64
39
40
41
42; Section containing code
43SECTION .text
44
45;--------------------------------------------------------------------
46; EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX
47; Parameters:
48; Nothing
49; Returns:
50; DX:CX: BIOS size in bytes
51; Corrupts registers:
52; AX, BX, SI, DI
53;--------------------------------------------------------------------
54ALIGN JUMP_ALIGN
55EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX:
56 push es
57
58 call EEPROM_FindXtideUniversalBiosROMtoESDI
59 call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
60 xor si, si ; Load from beginning of ROM
61 call LoadBytesFromRomToRamBuffer
62
63 call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
64 pop es
65 ret
66
67
68;--------------------------------------------------------------------
69; EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
70; Parameters:
71; ES:DI: Ptr to XTIDE Universal BIOS
72; Returns:
73; DX:CX: Bios size in bytes
74; Corrupts registers:
75; Nothing
76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
78EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX:
79 xor dx, dx
80 eMOVZX cx, BYTE [es:di+ROMVARS.bRomSize]
81 eSHL_IM cx, 9 ; *= 512 for byte count
82 ret
83
84
85;--------------------------------------------------------------------
86; EEPROM_LoadOldSettingsFromRomToRamBuffer
87; Parameters:
88; Nothing
89; Returns:
90; CF: Set if EEPROM was found
91; Cleared if EEPROM not found
92; Corrupts registers:
93; AX, BX, CX, SI, DI
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
96EEPROM_LoadOldSettingsFromRomToRamBuffer:
97 mov cx, ROMVARS_size - ROMVARS.wFlags ; Number of bytes to load
98 mov si, ROMVARS.wFlags ; Offset where to start loading
99 ; Fall to LoadBytesFromRomToRamBuffer
100
101;--------------------------------------------------------------------
102; LoadBytesFromRomToRamBuffer
103; Parameters:
104; CX: Number of bytes to load from ROM
105; SI: Offset to first byte to load
106; Returns:
107; CF: Set if EEPROM was found
108; Cleared if EEPROM not found
109; Corrupts registers:
110; AX, BX, CX, SI
111;--------------------------------------------------------------------
112ALIGN JUMP_ALIGN
113LoadBytesFromRomToRamBuffer:
114 push es
115 push ds
116 push di
117
118 call EEPROM_FindXtideUniversalBiosROMtoESDI
119 jnc SHORT .XtideUniversalBiosNotFound
120 push es
121 pop ds ; DS:SI points to ROM
122
123 call Buffers_GetFileBufferToESDI
124 mov di, si ; ES:DI points to RAM buffer
125
126 cld
127 call Memory_CopyCXbytesFromDSSItoESDI
128 stc
129
130.XtideUniversalBiosNotFound:
131 pop di
132 pop ds
133 pop es
134 ret
135
136
137;--------------------------------------------------------------------
138; EEPROM_FindXtideUniversalBiosROMtoESDI
139; Parameters:
140; Nothing
141; Returns:
142; ES:DI: EEPROM segment
143; CF: Set if EEPROM was found
144; Cleared if EEPROM not found
145; Corrupts registers:
146; AX, BX
147;--------------------------------------------------------------------
148ALIGN JUMP_ALIGN
149EEPROM_FindXtideUniversalBiosROMtoESDI:
150 push si
151 push cx
152
153 xor di, di ; Zero DI (offset)
154 mov bx, 0C000h ; First possible ROM segment
155ALIGN JUMP_ALIGN
156.SegmentLoop:
157 mov es, bx ; Possible ROM segment to ES
158 call Buffers_IsXtideUniversalBiosSignatureInESDI
159 je SHORT .RomFound
160 add bh, 2 ; Increment by 8kB
161 jnc SHORT .SegmentLoop ; Loop until segment overflows
162 clc
163 jmp SHORT .ReturnWithoutUpdatingCF
164ALIGN JUMP_ALIGN
165.RomFound:
166 stc
167.ReturnWithoutUpdatingCF:
168 pop cx
169 pop si
170 ret
171
172
173;--------------------------------------------------------------------
174; EEPROM_LoadFromRomToRamComparisonBuffer
175; Parameters:
176; Nothing
177; Returns:
178; Nothing
179; Corrupts registers:
180; BX, CX, SI, DI
181;--------------------------------------------------------------------
182ALIGN JUMP_ALIGN
183EEPROM_LoadFromRomToRamComparisonBuffer:
184 push es
185 push ds
186
187 mov ds, [cs:g_cfgVars+CFGVARS.wEepromSegment]
188 xor si, si
189 call Buffers_GetFlashComparisonBufferToESDI
190 eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromType]
191 mov cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
192 cld
193 rep movsw
194
195 pop ds
196 pop es
197 ret
Note: See TracBrowser for help on using the repository browser.