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