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_, 3 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
RevLine 
[57]1; Project name  :   XTIDE Univeral BIOS Configurator v2
2; Description   :   Functions for managing EEPROM contents.
3
[376]4;
[526]5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[526]12;
[376]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
[526]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[526]18;
[376]19
[65]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
[159]27    dw      (8<<10) / 2     ; EEPROM_TYPE.2864_8kiB_MOD
[65]28    dw      (32<<10) / 2
29    dw      (64<<10) / 2
[620]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.
[65]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
[57]45; Section containing code
46SECTION .text
47
48;--------------------------------------------------------------------
[68]49; EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX
[57]50;   Parameters:
51;       Nothing
52;   Returns:
[68]53;       DX:CX:  BIOS size in bytes
[57]54;   Corrupts registers:
[592]55;       BX, SI, DI
[57]56;--------------------------------------------------------------------
57ALIGN JUMP_ALIGN
[68]58EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX:
[57]59    push    es
60
61    call    EEPROM_FindXtideUniversalBiosROMtoESDI
[484]62    call    EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
[57]63    xor     si, si              ; Load from beginning of ROM
64    call    LoadBytesFromRomToRamBuffer
65
66    pop     es
67    ret
68
[484]69
[57]70;--------------------------------------------------------------------
[484]71; EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
[57]72;   Parameters:
[484]73;       ES:DI:  Ptr to XTIDE Universal BIOS
[57]74;   Returns:
[68]75;       DX:CX:  Bios size in bytes
[57]76;   Corrupts registers:
[68]77;       Nothing
[57]78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
[484]80EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX:
[68]81    xor     dx, dx
[558]82    mov     ch, [es:di+ROMVARS.bRomSize]
83    mov     cl, dl
84    eSHL_IM ch, 1
[589]85    eRCL_IM dl, 1
[57]86    ret
87
88
89;--------------------------------------------------------------------
90; EEPROM_LoadOldSettingsFromRomToRamBuffer
91;   Parameters:
92;       Nothing
93;   Returns:
[592]94;       CF:     Cleared if EEPROM was found
95;               Set if EEPROM not found
[57]96;   Corrupts registers:
[592]97;       BX, CX, SI
[57]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:
[592]111;       CF:     Cleared if EEPROM was found
112;               Set if EEPROM not found
[57]113;   Corrupts registers:
[592]114;       BX, SI
[57]115;--------------------------------------------------------------------
116ALIGN JUMP_ALIGN
117LoadBytesFromRomToRamBuffer:
118    push    es
119    push    ds
[523]120    push    di
[57]121
122    call    EEPROM_FindXtideUniversalBiosROMtoESDI
[592]123    jc      SHORT .XtideUniversalBiosNotFound
[57]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
[592]130%ifdef CLD_NEEDED
[57]131    cld
[592]132%endif
133    call    Memory_CopyCXbytesFromDSSItoESDI            ; Clears CF
[57]134
135.XtideUniversalBiosNotFound:
[523]136    pop     di
[57]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
[592]148;       CF:     Cleared if EEPROM was found
149;               Set if EEPROM not found
[57]150;   Corrupts registers:
[592]151;       BX
[57]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
[592]164    je      SHORT .RomFound         ; If equal, CF=0
[568]165    add     bx, 80h                 ; Increment by 2kB (minimum possible distance from the beginning of one option ROM to the next)
[57]166    jnc     SHORT .SegmentLoop      ; Loop until segment overflows
167.RomFound:
168    pop     cx
169    pop     si
170    ret
171
172
173;--------------------------------------------------------------------
[65]174; EEPROM_LoadFromRomToRamComparisonBuffer
[57]175;   Parameters:
176;       Nothing
177;   Returns:
[65]178;       Nothing
[57]179;   Corrupts registers:
[65]180;       BX, CX, SI, DI
[57]181;--------------------------------------------------------------------
182ALIGN JUMP_ALIGN
[65]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
[293]190    eMOVZX  bx, [cs:g_cfgVars+CFGVARS.bEepromType]
[592]191%ifdef CLD_NEEDED
[65]192    cld
[592]193%endif
[593]194    mov     cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
[65]195    rep movsw
196
197    pop     ds
198    pop     es
[57]199    ret
Note: See TracBrowser for help on using the repository browser.