[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
|
---|
| 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
|
---|
[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 |
|
---|
| 34 | g_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
|
---|
| 46 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
| 57 | ALIGN JUMP_ALIGN
|
---|
[68] | 58 | EEPROM_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 | ;--------------------------------------------------------------------
|
---|
| 79 | ALIGN JUMP_ALIGN
|
---|
[484] | 80 | EEPROM_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 | ;--------------------------------------------------------------------
|
---|
| 99 | ALIGN JUMP_ALIGN
|
---|
| 100 | EEPROM_LoadOldSettingsFromRomToRamBuffer:
|
---|
[621] | 101 | mov cx, ROMVARS_size - ROMVARS.wFlags - 2 ; Number of bytes to load
|
---|
| 102 | mov si, ROMVARS.wFlags + 2 ; Offset where to start loading
|
---|
[57] | 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 | ;--------------------------------------------------------------------
|
---|
| 116 | ALIGN JUMP_ALIGN
|
---|
| 117 | LoadBytesFromRomToRamBuffer:
|
---|
| 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
|
---|
[621] | 125 | pop ds ; DS:SI points to ROM
|
---|
[57] | 126 |
|
---|
| 127 | call Buffers_GetFileBufferToESDI
|
---|
[621] | 128 | mov di, si ; ES:DI points to RAM buffer
|
---|
[57] | 129 |
|
---|
[592] | 130 | %ifdef CLD_NEEDED
|
---|
[57] | 131 | cld
|
---|
[592] | 132 | %endif
|
---|
[621] | 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 | ;--------------------------------------------------------------------
|
---|
| 153 | ALIGN JUMP_ALIGN
|
---|
| 154 | EEPROM_FindXtideUniversalBiosROMtoESDI:
|
---|
| 155 | push si
|
---|
| 156 | push cx
|
---|
| 157 |
|
---|
| 158 | xor di, di ; Zero DI (offset)
|
---|
| 159 | mov bx, 0C000h ; First possible ROM segment
|
---|
| 160 | ALIGN 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
|
---|
[621] | 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
|
---|
[57] | 168 | .RomFound:
|
---|
| 169 | pop cx
|
---|
| 170 | pop si
|
---|
| 171 | ret
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | ;--------------------------------------------------------------------
|
---|
[65] | 175 | ; EEPROM_LoadFromRomToRamComparisonBuffer
|
---|
[57] | 176 | ; Parameters:
|
---|
| 177 | ; Nothing
|
---|
| 178 | ; Returns:
|
---|
[65] | 179 | ; Nothing
|
---|
[57] | 180 | ; Corrupts registers:
|
---|
[65] | 181 | ; BX, CX, SI, DI
|
---|
[57] | 182 | ;--------------------------------------------------------------------
|
---|
| 183 | ALIGN JUMP_ALIGN
|
---|
[65] | 184 | EEPROM_LoadFromRomToRamComparisonBuffer:
|
---|
| 185 | push es
|
---|
| 186 | push ds
|
---|
| 187 |
|
---|
[621] | 188 | eMOVZX bx, [g_cfgVars+CFGVARS.bEepromType]
|
---|
| 189 | mov cx, [bx+g_rgwEepromTypeToSizeInWords]
|
---|
| 190 | mov ds, [g_cfgVars+CFGVARS.wEepromSegment]
|
---|
[65] | 191 | xor si, si
|
---|
| 192 | call Buffers_GetFlashComparisonBufferToESDI
|
---|
[592] | 193 | %ifdef CLD_NEEDED
|
---|
[65] | 194 | cld
|
---|
[592] | 195 | %endif
|
---|
[65] | 196 | rep movsw
|
---|
| 197 |
|
---|
| 198 | pop ds
|
---|
| 199 | pop es
|
---|
[57] | 200 | ret
|
---|