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

Last change on this file since 620 was 620, checked in by krille_n_, 2 years ago

Changes:

  • A huge thank you to Jayeson Lee-Steere for adding SST39SF0x0 flash ROM programming support to the configurator (XTIDECFG.COM). This means that there is no longer a need to use a separate program for flashing the Lo-Tech boards and other devices using these flash ROMs.
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   ; Number of bytes to load
102    mov     si, ROMVARS.wFlags                  ; 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    add     bx, 80h                 ; Increment by 2kB (minimum possible distance from the beginning of one option ROM to the next)
166    jnc     SHORT .SegmentLoop      ; Loop until segment overflows
167.RomFound:
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%ifdef CLD_NEEDED
192    cld
193%endif
194    mov     cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
195    rep movsw
196
197    pop     ds
198    pop     es
199    ret
Note: See TracBrowser for help on using the repository browser.