[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
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
[68] | 46 | ; EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX
|
---|
[57] | 47 | ; Parameters:
|
---|
| 48 | ; Nothing
|
---|
| 49 | ; Returns:
|
---|
[68] | 50 | ; DX:CX: BIOS size in bytes
|
---|
[57] | 51 | ; Corrupts registers:
|
---|
| 52 | ; AX, BX, SI, DI
|
---|
| 53 | ;--------------------------------------------------------------------
|
---|
| 54 | ALIGN JUMP_ALIGN
|
---|
[68] | 55 | EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX:
|
---|
[57] | 56 | push es
|
---|
| 57 |
|
---|
| 58 | call EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
[484] | 59 | call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
|
---|
[57] | 60 | xor si, si ; Load from beginning of ROM
|
---|
| 61 | call LoadBytesFromRomToRamBuffer
|
---|
| 62 |
|
---|
[484] | 63 | call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
|
---|
[57] | 64 | pop es
|
---|
| 65 | ret
|
---|
| 66 |
|
---|
[484] | 67 |
|
---|
[57] | 68 | ;--------------------------------------------------------------------
|
---|
[484] | 69 | ; EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
|
---|
[57] | 70 | ; Parameters:
|
---|
[484] | 71 | ; ES:DI: Ptr to XTIDE Universal BIOS
|
---|
[57] | 72 | ; Returns:
|
---|
[68] | 73 | ; DX:CX: Bios size in bytes
|
---|
[57] | 74 | ; Corrupts registers:
|
---|
[68] | 75 | ; Nothing
|
---|
[57] | 76 | ;--------------------------------------------------------------------
|
---|
| 77 | ALIGN JUMP_ALIGN
|
---|
[484] | 78 | EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX:
|
---|
[68] | 79 | xor dx, dx
|
---|
[523] | 80 | eMOVZX cx, BYTE [es:di+ROMVARS.bRomSize]
|
---|
[57] | 81 | eSHL_IM cx, 9 ; *= 512 for byte count
|
---|
| 82 | ret
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | ;--------------------------------------------------------------------
|
---|
| 86 | ; EEPROM_LoadOldSettingsFromRomToRamBuffer
|
---|
| 87 | ; Parameters:
|
---|
| 88 | ; Nothing
|
---|
| 89 | ; Returns:
|
---|
| 90 | ; CF: Set if EEPROM was found
|
---|
| 91 | ; Cleared if EEPROM not found
|
---|
| 92 | ; Corrupts registers:
|
---|
| 93 | ; AX, BX, CX, SI, DI
|
---|
| 94 | ;--------------------------------------------------------------------
|
---|
| 95 | ALIGN JUMP_ALIGN
|
---|
| 96 | EEPROM_LoadOldSettingsFromRomToRamBuffer:
|
---|
| 97 | mov cx, ROMVARS_size - ROMVARS.wFlags ; Number of bytes to load
|
---|
| 98 | mov si, ROMVARS.wFlags ; Offset where to start loading
|
---|
| 99 | ; Fall to LoadBytesFromRomToRamBuffer
|
---|
| 100 |
|
---|
| 101 | ;--------------------------------------------------------------------
|
---|
| 102 | ; LoadBytesFromRomToRamBuffer
|
---|
| 103 | ; Parameters:
|
---|
| 104 | ; CX: Number of bytes to load from ROM
|
---|
| 105 | ; SI: Offset to first byte to load
|
---|
| 106 | ; Returns:
|
---|
| 107 | ; CF: Set if EEPROM was found
|
---|
| 108 | ; Cleared if EEPROM not found
|
---|
| 109 | ; Corrupts registers:
|
---|
[523] | 110 | ; AX, BX, CX, SI
|
---|
[57] | 111 | ;--------------------------------------------------------------------
|
---|
| 112 | ALIGN JUMP_ALIGN
|
---|
| 113 | LoadBytesFromRomToRamBuffer:
|
---|
| 114 | push es
|
---|
| 115 | push ds
|
---|
[523] | 116 | push di
|
---|
[57] | 117 |
|
---|
| 118 | call EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
| 119 | jnc SHORT .XtideUniversalBiosNotFound
|
---|
| 120 | push es
|
---|
| 121 | pop ds ; DS:SI points to ROM
|
---|
| 122 |
|
---|
| 123 | call Buffers_GetFileBufferToESDI
|
---|
| 124 | mov di, si ; ES:DI points to RAM buffer
|
---|
| 125 |
|
---|
| 126 | cld
|
---|
| 127 | call Memory_CopyCXbytesFromDSSItoESDI
|
---|
| 128 | stc
|
---|
| 129 |
|
---|
| 130 | .XtideUniversalBiosNotFound:
|
---|
[523] | 131 | pop di
|
---|
[57] | 132 | pop ds
|
---|
| 133 | pop es
|
---|
| 134 | ret
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | ;--------------------------------------------------------------------
|
---|
| 138 | ; EEPROM_FindXtideUniversalBiosROMtoESDI
|
---|
| 139 | ; Parameters:
|
---|
| 140 | ; Nothing
|
---|
| 141 | ; Returns:
|
---|
| 142 | ; ES:DI: EEPROM segment
|
---|
| 143 | ; CF: Set if EEPROM was found
|
---|
| 144 | ; Cleared if EEPROM not found
|
---|
| 145 | ; Corrupts registers:
|
---|
| 146 | ; AX, BX
|
---|
| 147 | ;--------------------------------------------------------------------
|
---|
| 148 | ALIGN JUMP_ALIGN
|
---|
| 149 | EEPROM_FindXtideUniversalBiosROMtoESDI:
|
---|
| 150 | push si
|
---|
| 151 | push cx
|
---|
| 152 |
|
---|
| 153 | xor di, di ; Zero DI (offset)
|
---|
| 154 | mov bx, 0C000h ; First possible ROM segment
|
---|
| 155 | ALIGN JUMP_ALIGN
|
---|
| 156 | .SegmentLoop:
|
---|
| 157 | mov es, bx ; Possible ROM segment to ES
|
---|
| 158 | call Buffers_IsXtideUniversalBiosSignatureInESDI
|
---|
| 159 | je SHORT .RomFound
|
---|
[181] | 160 | add bh, 2 ; Increment by 8kB
|
---|
[57] | 161 | jnc SHORT .SegmentLoop ; Loop until segment overflows
|
---|
| 162 | clc
|
---|
| 163 | jmp SHORT .ReturnWithoutUpdatingCF
|
---|
| 164 | ALIGN JUMP_ALIGN
|
---|
| 165 | .RomFound:
|
---|
| 166 | stc
|
---|
| 167 | .ReturnWithoutUpdatingCF:
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
| 182 | ALIGN JUMP_ALIGN
|
---|
[65] | 183 | EEPROM_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]
|
---|
[65] | 191 | mov cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
|
---|
| 192 | cld
|
---|
| 193 | rep movsw
|
---|
| 194 |
|
---|
| 195 | pop ds
|
---|
| 196 | pop es
|
---|
[57] | 197 | ret
|
---|