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

Last change on this file since 629 was 621, checked in by Krister Nordvall, 3 years ago

Changes:

  • Fixed three different bugs all causing the boot menu to show drives using IRQs even though the BIOS had been built without MODULE_IRQ.
  • Fixed two bugs in XTIDECFG where loading a BIOS from file and then loading the old settings from EEPROM would
    • overwrite ROMVARS.wFlags in the loaded BIOS file (in RAM). The possibly resulting mismatch of module flags could make it impossible to change settings for modules included in the BIOS or allow changing settings for modules not included in the BIOS.
    • not copy the color theme over to the loaded BIOS.
  • Also fixed two very minor bugs in XTIDECFG in BiosFile_LoadFileFromDSSItoRamBuffer and BiosFile_SaveRamBufferToFileInDSSI where the error handling in these routines would close whatever file handle that happened to match the error code returned by DOS in AX.
  • Made significant changes to the new flash ROM programming routines to reduce the size. Also fixed a minor bug that would cause the second verification to be skipped and return success when programming a 64 KB block of data.
  • Changed the custom BIOS build file names to the 8.3 format.
  • Changed some help strings in XTIDECFG to clarify things.
  • Other minor optimizations and fixes.
File size: 5.3 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 dw (32<<10) / 2 ; EEPROM_TYPE.SST_39SF
31 ; Actual size of flash will be larger than 32K,
32 ; however most (all?) XUB devices map a 32K window.
33
34g_rgwEepromPageToSizeInBytes:
35 dw 1 ; EEPROM_PAGE.1_byte
36 dw 2
37 dw 4
38 dw 8
39 dw 16
40 dw 32
41 dw 64
42
43
44
45; Section containing code
46SECTION .text
47
48;--------------------------------------------------------------------
49; EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX
50; Parameters:
51; Nothing
52; Returns:
53; DX:CX: BIOS size in bytes
54; Corrupts registers:
55; BX, SI, DI
56;--------------------------------------------------------------------
57ALIGN JUMP_ALIGN
58EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX:
59 push es
60
61 call EEPROM_FindXtideUniversalBiosROMtoESDI
62 call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
63 xor si, si ; Load from beginning of ROM
64 call LoadBytesFromRomToRamBuffer
65
66 pop es
67 ret
68
69
70;--------------------------------------------------------------------
71; EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
72; Parameters:
73; ES:DI: Ptr to XTIDE Universal BIOS
74; Returns:
75; DX:CX: Bios size in bytes
76; Corrupts registers:
77; Nothing
78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX:
81 xor dx, dx
82 mov ch, [es:di+ROMVARS.bRomSize]
83 mov cl, dl
84 eSHL_IM ch, 1
85 eRCL_IM dl, 1
86 ret
87
88
89;--------------------------------------------------------------------
90; EEPROM_LoadOldSettingsFromRomToRamBuffer
91; Parameters:
92; Nothing
93; Returns:
94; CF: Cleared if EEPROM was found
95; Set if EEPROM not found
96; Corrupts registers:
97; BX, CX, SI
98;--------------------------------------------------------------------
99ALIGN JUMP_ALIGN
100EEPROM_LoadOldSettingsFromRomToRamBuffer:
101 mov cx, ROMVARS_size - ROMVARS.wFlags - 2 ; Number of bytes to load
102 mov si, ROMVARS.wFlags + 2 ; Offset where to start loading
103 ; Fall to LoadBytesFromRomToRamBuffer
104
105;--------------------------------------------------------------------
106; LoadBytesFromRomToRamBuffer
107; Parameters:
108; CX: Number of bytes to load from ROM
109; SI: Offset to first byte to load
110; Returns:
111; CF: Cleared if EEPROM was found
112; Set if EEPROM not found
113; Corrupts registers:
114; BX, SI
115;--------------------------------------------------------------------
116ALIGN JUMP_ALIGN
117LoadBytesFromRomToRamBuffer:
118 push es
119 push ds
120 push di
121
122 call EEPROM_FindXtideUniversalBiosROMtoESDI
123 jc SHORT .XtideUniversalBiosNotFound
124 push es
125 pop ds ; DS:SI points to ROM
126
127 call Buffers_GetFileBufferToESDI
128 mov di, si ; ES:DI points to RAM buffer
129
130%ifdef CLD_NEEDED
131 cld
132%endif
133 call Memory_CopyCXbytesFromDSSItoESDI ; Clears CF
134
135.XtideUniversalBiosNotFound:
136 pop di
137 pop ds
138 pop es
139 ret
140
141
142;--------------------------------------------------------------------
143; EEPROM_FindXtideUniversalBiosROMtoESDI
144; Parameters:
145; Nothing
146; Returns:
147; ES:DI: EEPROM segment
148; CF: Cleared if EEPROM was found
149; Set if EEPROM not found
150; Corrupts registers:
151; BX
152;--------------------------------------------------------------------
153ALIGN JUMP_ALIGN
154EEPROM_FindXtideUniversalBiosROMtoESDI:
155 push si
156 push cx
157
158 xor di, di ; Zero DI (offset)
159 mov bx, 0C000h ; First possible ROM segment
160ALIGN JUMP_ALIGN
161.SegmentLoop:
162 mov es, bx ; Possible ROM segment to ES
163 call Buffers_IsXtideUniversalBiosSignatureInESDI
164 je SHORT .RomFound ; If equal, CF=0
165 sub bx, -80h ; Increment by 2kB (minimum possible distance from the beginning of one option ROM to the next)
166 jc SHORT .SegmentLoop ; Loop until segment overflows
167 stc
168.RomFound:
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;--------------------------------------------------------------------
183ALIGN JUMP_ALIGN
184EEPROM_LoadFromRomToRamComparisonBuffer:
185 push es
186 push ds
187
188 eMOVZX bx, [g_cfgVars+CFGVARS.bEepromType]
189 mov cx, [bx+g_rgwEepromTypeToSizeInWords]
190 mov ds, [g_cfgVars+CFGVARS.wEepromSegment]
191 xor si, si
192 call Buffers_GetFlashComparisonBufferToESDI
193%ifdef CLD_NEEDED
194 cld
195%endif
196 rep movsw
197
198 pop ds
199 pop es
200 ret
Note: See TracBrowser for help on using the repository browser.