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
|
---|
21 | SECTION .data
|
---|
22 |
|
---|
23 | ALIGN WORD_ALIGN
|
---|
24 | g_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 |
|
---|
31 | g_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
|
---|
43 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
54 | ALIGN JUMP_ALIGN
|
---|
55 | EEPROM_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 | ;--------------------------------------------------------------------
|
---|
77 | ALIGN JUMP_ALIGN
|
---|
78 | EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX:
|
---|
79 | xor dx, dx
|
---|
80 | mov ch, [es:di+ROMVARS.bRomSize]
|
---|
81 | mov cl, dl
|
---|
82 | eSHL_IM ch, 1
|
---|
83 | ret
|
---|
84 |
|
---|
85 |
|
---|
86 | ;--------------------------------------------------------------------
|
---|
87 | ; EEPROM_LoadOldSettingsFromRomToRamBuffer
|
---|
88 | ; Parameters:
|
---|
89 | ; Nothing
|
---|
90 | ; Returns:
|
---|
91 | ; CF: Set if EEPROM was found
|
---|
92 | ; Cleared if EEPROM not found
|
---|
93 | ; Corrupts registers:
|
---|
94 | ; AX, BX, CX, SI, DI
|
---|
95 | ;--------------------------------------------------------------------
|
---|
96 | ALIGN JUMP_ALIGN
|
---|
97 | EEPROM_LoadOldSettingsFromRomToRamBuffer:
|
---|
98 | mov cx, ROMVARS_size - ROMVARS.wFlags ; Number of bytes to load
|
---|
99 | mov si, ROMVARS.wFlags ; Offset where to start loading
|
---|
100 | ; Fall to LoadBytesFromRomToRamBuffer
|
---|
101 |
|
---|
102 | ;--------------------------------------------------------------------
|
---|
103 | ; LoadBytesFromRomToRamBuffer
|
---|
104 | ; Parameters:
|
---|
105 | ; CX: Number of bytes to load from ROM
|
---|
106 | ; SI: Offset to first byte to load
|
---|
107 | ; Returns:
|
---|
108 | ; CF: Set if EEPROM was found
|
---|
109 | ; Cleared if EEPROM not found
|
---|
110 | ; Corrupts registers:
|
---|
111 | ; AX, BX, CX, SI
|
---|
112 | ;--------------------------------------------------------------------
|
---|
113 | ALIGN JUMP_ALIGN
|
---|
114 | LoadBytesFromRomToRamBuffer:
|
---|
115 | push es
|
---|
116 | push ds
|
---|
117 | push di
|
---|
118 |
|
---|
119 | call EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
120 | jnc SHORT .XtideUniversalBiosNotFound
|
---|
121 | push es
|
---|
122 | pop ds ; DS:SI points to ROM
|
---|
123 |
|
---|
124 | call Buffers_GetFileBufferToESDI
|
---|
125 | mov di, si ; ES:DI points to RAM buffer
|
---|
126 |
|
---|
127 | cld
|
---|
128 | call Memory_CopyCXbytesFromDSSItoESDI
|
---|
129 | stc
|
---|
130 |
|
---|
131 | .XtideUniversalBiosNotFound:
|
---|
132 | pop di
|
---|
133 | pop ds
|
---|
134 | pop es
|
---|
135 | ret
|
---|
136 |
|
---|
137 |
|
---|
138 | ;--------------------------------------------------------------------
|
---|
139 | ; EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
140 | ; Parameters:
|
---|
141 | ; Nothing
|
---|
142 | ; Returns:
|
---|
143 | ; ES:DI: EEPROM segment
|
---|
144 | ; CF: Set if EEPROM was found
|
---|
145 | ; Cleared if EEPROM not found
|
---|
146 | ; Corrupts registers:
|
---|
147 | ; AX, BX
|
---|
148 | ;--------------------------------------------------------------------
|
---|
149 | ALIGN JUMP_ALIGN
|
---|
150 | EEPROM_FindXtideUniversalBiosROMtoESDI:
|
---|
151 | push si
|
---|
152 | push cx
|
---|
153 |
|
---|
154 | xor di, di ; Zero DI (offset)
|
---|
155 | mov bx, 0C000h ; First possible ROM segment
|
---|
156 | ALIGN JUMP_ALIGN
|
---|
157 | .SegmentLoop:
|
---|
158 | mov es, bx ; Possible ROM segment to ES
|
---|
159 | call Buffers_IsXtideUniversalBiosSignatureInESDI
|
---|
160 | je SHORT .RomFound
|
---|
161 | add bx, 80h ; Increment by 2kB (minimum possible distance from the beginning of one option ROM to the next)
|
---|
162 | jnc SHORT .SegmentLoop ; Loop until segment overflows
|
---|
163 | clc
|
---|
164 | jmp SHORT .ReturnWithoutUpdatingCF
|
---|
165 | ALIGN JUMP_ALIGN
|
---|
166 | .RomFound:
|
---|
167 | stc
|
---|
168 | .ReturnWithoutUpdatingCF:
|
---|
169 | pop cx
|
---|
170 | pop si
|
---|
171 | ret
|
---|
172 |
|
---|
173 |
|
---|
174 | ;--------------------------------------------------------------------
|
---|
175 | ; EEPROM_LoadFromRomToRamComparisonBuffer
|
---|
176 | ; Parameters:
|
---|
177 | ; Nothing
|
---|
178 | ; Returns:
|
---|
179 | ; Nothing
|
---|
180 | ; Corrupts registers:
|
---|
181 | ; BX, CX, SI, DI
|
---|
182 | ;--------------------------------------------------------------------
|
---|
183 | ALIGN JUMP_ALIGN
|
---|
184 | EEPROM_LoadFromRomToRamComparisonBuffer:
|
---|
185 | push es
|
---|
186 | push ds
|
---|
187 |
|
---|
188 | mov ds, [cs:g_cfgVars+CFGVARS.wEepromSegment]
|
---|
189 | xor si, si
|
---|
190 | call Buffers_GetFlashComparisonBufferToESDI
|
---|
191 | eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromType]
|
---|
192 | mov cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
|
---|
193 | cld
|
---|
194 | rep movsw
|
---|
195 |
|
---|
196 | pop ds
|
---|
197 | pop es
|
---|
198 | ret
|
---|