[57] | 1 | ; Project name : XTIDE Univeral BIOS Configurator v2
|
---|
| 2 | ; Description : Functions for managing EEPROM contents.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
| 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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 |
|
---|
[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
|
---|
| 30 |
|
---|
| 31 | g_rgwEepromPageToSizeInBytes:
|
---|
| 32 | dw 1 ; EEPROM_PAGE.1_byte
|
---|
| 33 | dw 2
|
---|
| 34 | dw 4
|
---|
| 35 | dw 8
|
---|
| 36 | dw 16
|
---|
| 37 | dw 32
|
---|
| 38 | dw 64
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 |
|
---|
[57] | 42 | ; Section containing code
|
---|
| 43 | SECTION .text
|
---|
| 44 |
|
---|
| 45 | ;--------------------------------------------------------------------
|
---|
[118] | 46 | ; EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX
|
---|
| 47 | ; Parameters:
|
---|
| 48 | ; AX: Image size in WORDs
|
---|
| 49 | ; Returns:
|
---|
| 50 | ; CX: Required EEPROM size in WORDs
|
---|
| 51 | ; CF: Set if EEPROM size found
|
---|
| 52 | ; Cleared if no valid EEPROM found
|
---|
| 53 | ; Corrupts registers:
|
---|
| 54 | ; BX
|
---|
| 55 | ;--------------------------------------------------------------------
|
---|
| 56 | ALIGN JUMP_ALIGN
|
---|
| 57 | EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX:
|
---|
| 58 | mov bx, g_rgwEepromTypeToSizeInWords
|
---|
| 59 | mov cx, NUMBER_OF_EEPROM_TYPES
|
---|
| 60 | ALIGN JUMP_ALIGN
|
---|
| 61 | .CheckNextEepromSize:
|
---|
| 62 | cmp ax, [cs:bx]
|
---|
[138] | 63 | jbe SHORT .ReturnEepromSizeInCX
|
---|
[118] | 64 | inc bx
|
---|
| 65 | inc bx
|
---|
| 66 | loop .CheckNextEepromSize
|
---|
[145] | 67 | ret ; Return with CF cleared (none of the supported EEPROMs are large enough)
|
---|
[118] | 68 | ALIGN JUMP_ALIGN
|
---|
[138] | 69 | .ReturnEepromSizeInCX:
|
---|
[118] | 70 | mov cx, [cs:bx]
|
---|
| 71 | stc
|
---|
| 72 | ret
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | ;--------------------------------------------------------------------
|
---|
[68] | 76 | ; EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX
|
---|
[57] | 77 | ; Parameters:
|
---|
| 78 | ; Nothing
|
---|
| 79 | ; Returns:
|
---|
[68] | 80 | ; DX:CX: BIOS size in bytes
|
---|
[57] | 81 | ; Corrupts registers:
|
---|
| 82 | ; AX, BX, SI, DI
|
---|
| 83 | ;--------------------------------------------------------------------
|
---|
| 84 | ALIGN JUMP_ALIGN
|
---|
[68] | 85 | EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX:
|
---|
[57] | 86 | push es
|
---|
| 87 |
|
---|
| 88 | call EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
[68] | 89 | call .GetXtideUniversalBiosSizeFromEStoDXCX
|
---|
[57] | 90 | xor si, si ; Load from beginning of ROM
|
---|
| 91 | call LoadBytesFromRomToRamBuffer
|
---|
| 92 |
|
---|
[68] | 93 | call .GetXtideUniversalBiosSizeFromEStoDXCX
|
---|
[57] | 94 | pop es
|
---|
| 95 | ret
|
---|
| 96 |
|
---|
| 97 | ;--------------------------------------------------------------------
|
---|
[68] | 98 | ; .GetXtideUniversalBiosSizeFromEStoDXCX
|
---|
[57] | 99 | ; Parameters:
|
---|
| 100 | ; Nothing
|
---|
| 101 | ; Returns:
|
---|
[68] | 102 | ; DX:CX: Bios size in bytes
|
---|
[57] | 103 | ; Corrupts registers:
|
---|
[68] | 104 | ; Nothing
|
---|
[57] | 105 | ;--------------------------------------------------------------------
|
---|
| 106 | ALIGN JUMP_ALIGN
|
---|
[68] | 107 | .GetXtideUniversalBiosSizeFromEStoDXCX:
|
---|
| 108 | xor dx, dx
|
---|
[293] | 109 | eMOVZX cx, [es:ROMVARS.bRomSize]
|
---|
[57] | 110 | eSHL_IM cx, 9 ; *= 512 for byte count
|
---|
| 111 | ret
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | ;--------------------------------------------------------------------
|
---|
| 115 | ; EEPROM_LoadOldSettingsFromRomToRamBuffer
|
---|
| 116 | ; Parameters:
|
---|
| 117 | ; Nothing
|
---|
| 118 | ; Returns:
|
---|
| 119 | ; CF: Set if EEPROM was found
|
---|
| 120 | ; Cleared if EEPROM not found
|
---|
| 121 | ; Corrupts registers:
|
---|
| 122 | ; AX, BX, CX, SI, DI
|
---|
| 123 | ;--------------------------------------------------------------------
|
---|
| 124 | ALIGN JUMP_ALIGN
|
---|
| 125 | EEPROM_LoadOldSettingsFromRomToRamBuffer:
|
---|
| 126 | mov cx, ROMVARS_size - ROMVARS.wFlags ; Number of bytes to load
|
---|
| 127 | mov si, ROMVARS.wFlags ; Offset where to start loading
|
---|
| 128 | ; Fall to LoadBytesFromRomToRamBuffer
|
---|
| 129 |
|
---|
| 130 | ;--------------------------------------------------------------------
|
---|
| 131 | ; LoadBytesFromRomToRamBuffer
|
---|
| 132 | ; Parameters:
|
---|
| 133 | ; CX: Number of bytes to load from ROM
|
---|
| 134 | ; SI: Offset to first byte to load
|
---|
| 135 | ; Returns:
|
---|
| 136 | ; CF: Set if EEPROM was found
|
---|
| 137 | ; Cleared if EEPROM not found
|
---|
| 138 | ; Corrupts registers:
|
---|
| 139 | ; AX, BX, CX, SI, DI
|
---|
| 140 | ;--------------------------------------------------------------------
|
---|
| 141 | ALIGN JUMP_ALIGN
|
---|
| 142 | LoadBytesFromRomToRamBuffer:
|
---|
| 143 | push es
|
---|
| 144 | push ds
|
---|
| 145 |
|
---|
| 146 | call EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
| 147 | jnc SHORT .XtideUniversalBiosNotFound
|
---|
| 148 | push es
|
---|
| 149 | pop ds ; DS:SI points to ROM
|
---|
| 150 |
|
---|
| 151 | call Buffers_GetFileBufferToESDI
|
---|
| 152 | mov di, si ; ES:DI points to RAM buffer
|
---|
| 153 |
|
---|
| 154 | cld
|
---|
| 155 | call Memory_CopyCXbytesFromDSSItoESDI
|
---|
| 156 | stc
|
---|
| 157 |
|
---|
| 158 | .XtideUniversalBiosNotFound:
|
---|
| 159 | pop ds
|
---|
| 160 | pop es
|
---|
| 161 | ret
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 | ;--------------------------------------------------------------------
|
---|
| 165 | ; EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
| 166 | ; Parameters:
|
---|
| 167 | ; Nothing
|
---|
| 168 | ; Returns:
|
---|
| 169 | ; ES:DI: EEPROM segment
|
---|
| 170 | ; CF: Set if EEPROM was found
|
---|
| 171 | ; Cleared if EEPROM not found
|
---|
| 172 | ; Corrupts registers:
|
---|
| 173 | ; AX, BX
|
---|
| 174 | ;--------------------------------------------------------------------
|
---|
| 175 | ALIGN JUMP_ALIGN
|
---|
| 176 | EEPROM_FindXtideUniversalBiosROMtoESDI:
|
---|
| 177 | push si
|
---|
| 178 | push cx
|
---|
| 179 |
|
---|
| 180 | xor di, di ; Zero DI (offset)
|
---|
| 181 | mov bx, 0C000h ; First possible ROM segment
|
---|
| 182 | ALIGN JUMP_ALIGN
|
---|
| 183 | .SegmentLoop:
|
---|
| 184 | mov es, bx ; Possible ROM segment to ES
|
---|
| 185 | call Buffers_IsXtideUniversalBiosSignatureInESDI
|
---|
| 186 | je SHORT .RomFound
|
---|
[181] | 187 | add bh, 2 ; Increment by 8kB
|
---|
[57] | 188 | jnc SHORT .SegmentLoop ; Loop until segment overflows
|
---|
| 189 | clc
|
---|
| 190 | jmp SHORT .ReturnWithoutUpdatingCF
|
---|
| 191 | ALIGN JUMP_ALIGN
|
---|
| 192 | .RomFound:
|
---|
| 193 | stc
|
---|
| 194 | .ReturnWithoutUpdatingCF:
|
---|
| 195 | pop cx
|
---|
| 196 | pop si
|
---|
| 197 | ret
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | ;--------------------------------------------------------------------
|
---|
[65] | 201 | ; EEPROM_LoadFromRomToRamComparisonBuffer
|
---|
[57] | 202 | ; Parameters:
|
---|
| 203 | ; Nothing
|
---|
| 204 | ; Returns:
|
---|
[65] | 205 | ; Nothing
|
---|
[57] | 206 | ; Corrupts registers:
|
---|
[65] | 207 | ; BX, CX, SI, DI
|
---|
[57] | 208 | ;--------------------------------------------------------------------
|
---|
| 209 | ALIGN JUMP_ALIGN
|
---|
[65] | 210 | EEPROM_LoadFromRomToRamComparisonBuffer:
|
---|
| 211 | push es
|
---|
| 212 | push ds
|
---|
| 213 |
|
---|
| 214 | mov ds, [cs:g_cfgVars+CFGVARS.wEepromSegment]
|
---|
| 215 | xor si, si
|
---|
| 216 | call Buffers_GetFlashComparisonBufferToESDI
|
---|
[293] | 217 | eMOVZX bx, [cs:g_cfgVars+CFGVARS.bEepromType]
|
---|
[65] | 218 | mov cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
|
---|
| 219 | cld
|
---|
| 220 | rep movsw
|
---|
| 221 |
|
---|
| 222 | pop ds
|
---|
| 223 | pop es
|
---|
[57] | 224 | ret
|
---|