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

Last change on this file since 521 was 484, checked in by aitotat@…, 12 years ago

Changes to Configurator v2:

  • Large builds are now saved to correct size.
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-2012 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, [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, DI
111;--------------------------------------------------------------------
112ALIGN JUMP_ALIGN
113LoadBytesFromRomToRamBuffer:
114 push es
115 push ds
116
117 call EEPROM_FindXtideUniversalBiosROMtoESDI
118 jnc SHORT .XtideUniversalBiosNotFound
119 push es
120 pop ds ; DS:SI points to ROM
121
122 call Buffers_GetFileBufferToESDI
123 mov di, si ; ES:DI points to RAM buffer
124
125 cld
126 call Memory_CopyCXbytesFromDSSItoESDI
127 stc
128
129.XtideUniversalBiosNotFound:
130 pop ds
131 pop es
132 ret
133
134
135;--------------------------------------------------------------------
136; EEPROM_FindXtideUniversalBiosROMtoESDI
137; Parameters:
138; Nothing
139; Returns:
140; ES:DI: EEPROM segment
141; CF: Set if EEPROM was found
142; Cleared if EEPROM not found
143; Corrupts registers:
144; AX, BX
145;--------------------------------------------------------------------
146ALIGN JUMP_ALIGN
147EEPROM_FindXtideUniversalBiosROMtoESDI:
148 push si
149 push cx
150
151 xor di, di ; Zero DI (offset)
152 mov bx, 0C000h ; First possible ROM segment
153ALIGN JUMP_ALIGN
154.SegmentLoop:
155 mov es, bx ; Possible ROM segment to ES
156 call Buffers_IsXtideUniversalBiosSignatureInESDI
157 je SHORT .RomFound
158 add bh, 2 ; Increment by 8kB
159 jnc SHORT .SegmentLoop ; Loop until segment overflows
160 clc
161 jmp SHORT .ReturnWithoutUpdatingCF
162ALIGN JUMP_ALIGN
163.RomFound:
164 stc
165.ReturnWithoutUpdatingCF:
166 pop cx
167 pop si
168 ret
169
170
171;--------------------------------------------------------------------
172; EEPROM_LoadFromRomToRamComparisonBuffer
173; Parameters:
174; Nothing
175; Returns:
176; Nothing
177; Corrupts registers:
178; BX, CX, SI, DI
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
181EEPROM_LoadFromRomToRamComparisonBuffer:
182 push es
183 push ds
184
185 mov ds, [cs:g_cfgVars+CFGVARS.wEepromSegment]
186 xor si, si
187 call Buffers_GetFlashComparisonBufferToESDI
188 eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromType]
189 mov cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
190 cld
191 rep movsw
192
193 pop ds
194 pop es
195 ret
Note: See TracBrowser for help on using the repository browser.