[57] | 1 | ; Project name : XTIDE Universal BIOS Configurator v2
|
---|
| 2 | ; Description : Functions for accessing file and flash buffers.
|
---|
| 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 |
|
---|
[57] | 20 | ; Section containing code
|
---|
| 21 | SECTION .text
|
---|
| 22 |
|
---|
| 23 | ;--------------------------------------------------------------------
|
---|
| 24 | ; Buffers_Clear
|
---|
| 25 | ; Parameters:
|
---|
| 26 | ; Nothing
|
---|
| 27 | ; Returns:
|
---|
| 28 | ; Nothing
|
---|
| 29 | ; Corrupts registers:
|
---|
| 30 | ; AX, CX, DI, ES
|
---|
| 31 | ;--------------------------------------------------------------------
|
---|
| 32 | ALIGN JUMP_ALIGN
|
---|
| 33 | Buffers_Clear:
|
---|
| 34 | call Buffers_GetFileBufferToESDI
|
---|
| 35 | mov cx, ROMVARS_size
|
---|
| 36 | jmp Memory_ZeroESDIwithSizeInCX
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | ;--------------------------------------------------------------------
|
---|
| 40 | ; Buffers_IsXtideUniversalBiosLoaded
|
---|
| 41 | ; Parameters:
|
---|
| 42 | ; Nothing
|
---|
| 43 | ; Returns:
|
---|
| 44 | ; ZF: Set if supported version of XTIDE Universal BIOS is loaded
|
---|
| 45 | ; Cleared no file or some other file is loaded
|
---|
| 46 | ; Corrupts registers:
|
---|
| 47 | ; CX, SI, DI, ES
|
---|
| 48 | ;--------------------------------------------------------------------
|
---|
| 49 | ALIGN JUMP_ALIGN
|
---|
| 50 | Buffers_IsXtideUniversalBiosLoaded:
|
---|
| 51 | test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
|
---|
| 52 | jz SHORT .NoFileOrBiosLoaded
|
---|
| 53 |
|
---|
| 54 | call Buffers_GetFileBufferToESDI
|
---|
[68] | 55 | jmp SHORT Buffers_IsXtideUniversalBiosSignatureInESDI
|
---|
[57] | 56 | .NoFileOrBiosLoaded:
|
---|
| 57 | or cl, 1 ; Clear ZF
|
---|
| 58 | ret
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | ;--------------------------------------------------------------------
|
---|
| 62 | ; Buffers_IsXtideUniversalBiosSignatureInESDI
|
---|
| 63 | ; Parameters:
|
---|
| 64 | ; ES:DI: Ptr to possible XTIDE Universal BIOS location
|
---|
| 65 | ; Returns:
|
---|
| 66 | ; ZF: Set if supported version of XTIDE Universal BIOS is loaded
|
---|
| 67 | ; Cleared no file or some other file is loaded
|
---|
| 68 | ; Corrupts registers:
|
---|
| 69 | ; CX, SI
|
---|
| 70 | ;--------------------------------------------------------------------
|
---|
| 71 | ALIGN JUMP_ALIGN
|
---|
| 72 | Buffers_IsXtideUniversalBiosSignatureInESDI:
|
---|
| 73 | push di
|
---|
| 74 |
|
---|
| 75 | mov si, g_szXtideUniversalBiosSignature
|
---|
| 76 | add di, BYTE ROMVARS.rgbSign
|
---|
| 77 | mov cx, XTIDE_SIGNATURE_LENGTH / 2
|
---|
| 78 | cld
|
---|
| 79 | eSEG_STR repe, cs, cmpsw
|
---|
| 80 |
|
---|
| 81 | pop di
|
---|
| 82 | ret
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | ;--------------------------------------------------------------------
|
---|
[457] | 86 | ; Buffers_IsXTbuildLoaded
|
---|
| 87 | ; Parameters:
|
---|
| 88 | ; Nothing
|
---|
| 89 | ; Returns:
|
---|
| 90 | ; ZF: Set if XT or XT+ build is loaded
|
---|
| 91 | ; Cleared if some other (AT, 386) build is loaded
|
---|
| 92 | ; Corrupts registers:
|
---|
| 93 | ; DI, ES
|
---|
| 94 | ;--------------------------------------------------------------------
|
---|
| 95 | ALIGN JUMP_ALIGN
|
---|
| 96 | Buffers_IsXTbuildLoaded:
|
---|
| 97 | %strlen BUILD_TYPE_OFFSET TITLE_STRING_START
|
---|
| 98 | call Buffers_GetFileBufferToESDI
|
---|
| 99 | cmp WORD [es:di+ROMVARS.szTitle+BUILD_TYPE_OFFSET+1], 'XT' ; +1 is for '('
|
---|
| 100 | ret
|
---|
| 101 | %undef BUILD_TYPE_OFFSET
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | ;--------------------------------------------------------------------
|
---|
[145] | 105 | ; Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
|
---|
[57] | 106 | ; Parameters:
|
---|
| 107 | ; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
|
---|
[68] | 108 | ; DX:CX: EEPROM size in bytes
|
---|
[57] | 109 | ; Returns:
|
---|
| 110 | ; Nothing
|
---|
| 111 | ; Corrupts registers:
|
---|
[68] | 112 | ; AX, CX, DX
|
---|
[57] | 113 | ;--------------------------------------------------------------------
|
---|
| 114 | ALIGN JUMP_ALIGN
|
---|
[68] | 115 | Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration:
|
---|
[57] | 116 | and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
|
---|
| 117 | or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
|
---|
[68] | 118 | shr dx, 1
|
---|
| 119 | rcr cx, 1
|
---|
[144] | 120 | adc cx, BYTE 0 ; Round up to next WORD
|
---|
[65] | 121 | mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
|
---|
[57] | 122 | ret
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | ;--------------------------------------------------------------------
|
---|
| 126 | ; Buffers_SetUnsavedChanges
|
---|
| 127 | ; Buffers_ClearUnsavedChanges
|
---|
| 128 | ; Parameters:
|
---|
| 129 | ; SS:BP: Menu handle
|
---|
| 130 | ; Returns:
|
---|
| 131 | ; Nothing
|
---|
| 132 | ; Corrupts registers:
|
---|
| 133 | ; Nothing
|
---|
| 134 | ;--------------------------------------------------------------------
|
---|
| 135 | ALIGN JUMP_ALIGN
|
---|
| 136 | Buffers_SetUnsavedChanges:
|
---|
[371] | 137 | or WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
|
---|
[57] | 138 | ret
|
---|
| 139 |
|
---|
| 140 | ALIGN JUMP_ALIGN
|
---|
| 141 | Buffers_ClearUnsavedChanges:
|
---|
[371] | 142 | and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
|
---|
[57] | 143 | ret
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | ;--------------------------------------------------------------------
|
---|
[59] | 147 | ; Buffers_SaveChangesIfFileLoaded
|
---|
| 148 | ; Parameters:
|
---|
| 149 | ; Nothing
|
---|
| 150 | ; Returns:
|
---|
| 151 | ; Nothing
|
---|
| 152 | ; Corrupts registers:
|
---|
| 153 | ; AX, BX, CX, SI, DI
|
---|
| 154 | ;--------------------------------------------------------------------
|
---|
| 155 | ALIGN JUMP_ALIGN
|
---|
| 156 | Buffers_SaveChangesIfFileLoaded:
|
---|
| 157 | mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
|
---|
| 158 | and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
|
---|
| 159 | cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
|
---|
| 160 | jne SHORT .NothingToSave
|
---|
| 161 | call Dialogs_DisplaySaveChangesDialog
|
---|
| 162 | jnz SHORT .NothingToSave
|
---|
| 163 | jmp BiosFile_SaveUnsavedChanges
|
---|
| 164 | ALIGN JUMP_ALIGN
|
---|
| 165 | .NothingToSave:
|
---|
| 166 | ret
|
---|
| 167 |
|
---|
| 168 |
|
---|
| 169 | ;--------------------------------------------------------------------
|
---|
[65] | 170 | ; Buffers_AppendZeroesIfNeeded
|
---|
| 171 | ; Parameters:
|
---|
| 172 | ; Nothing
|
---|
| 173 | ; Returns:
|
---|
| 174 | ; Nothing
|
---|
| 175 | ; Corrupts registers:
|
---|
| 176 | ; AX, CX, DI
|
---|
| 177 | ;--------------------------------------------------------------------
|
---|
| 178 | ALIGN JUMP_ALIGN
|
---|
| 179 | Buffers_AppendZeroesIfNeeded:
|
---|
| 180 | push es
|
---|
| 181 |
|
---|
[293] | 182 | eMOVZX di, [cs:g_cfgVars+CFGVARS.bEepromType]
|
---|
[65] | 183 | mov cx, [cs:di+g_rgwEepromTypeToSizeInWords]
|
---|
| 184 | sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
|
---|
| 185 | jle SHORT .NoNeedToAppendZeroes
|
---|
| 186 |
|
---|
| 187 | call Buffers_GetFileBufferToESDI
|
---|
| 188 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
|
---|
| 189 | shl ax, 1
|
---|
| 190 | add di, ax ; ES:DI now point first unused image byte
|
---|
| 191 | xor ax, ax
|
---|
| 192 | cld
|
---|
| 193 | rep stosw
|
---|
| 194 | ALIGN JUMP_ALIGN
|
---|
| 195 | .NoNeedToAppendZeroes:
|
---|
| 196 | pop es
|
---|
| 197 | ret
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | ;--------------------------------------------------------------------
|
---|
[57] | 201 | ; Buffers_GenerateChecksum
|
---|
| 202 | ; Parameters:
|
---|
| 203 | ; Nothing
|
---|
| 204 | ; Returns:
|
---|
| 205 | ; Nothing
|
---|
| 206 | ; Corrupts registers:
|
---|
| 207 | ; AX, BX, CX, DI
|
---|
| 208 | ;--------------------------------------------------------------------
|
---|
| 209 | ALIGN JUMP_ALIGN
|
---|
| 210 | Buffers_GenerateChecksum:
|
---|
| 211 | push es
|
---|
[484] | 212 | push dx
|
---|
[57] | 213 |
|
---|
| 214 | call Buffers_GetFileBufferToESDI
|
---|
[484] | 215 | call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
|
---|
[57] | 216 | dec cx ; Leave space for checksum byte
|
---|
| 217 | xor ax, ax
|
---|
| 218 | ALIGN JUMP_ALIGN
|
---|
| 219 | .SumNextByte:
|
---|
| 220 | add al, [es:di]
|
---|
| 221 | inc di
|
---|
| 222 | loop .SumNextByte
|
---|
| 223 | neg al
|
---|
| 224 | mov [es:di], al
|
---|
| 225 |
|
---|
[484] | 226 | pop dx
|
---|
[57] | 227 | pop es
|
---|
| 228 | ret
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 | ;--------------------------------------------------------------------
|
---|
[59] | 232 | ; Buffers_GetRomvarsFlagsToAX
|
---|
| 233 | ; Parameters:
|
---|
| 234 | ; Nothing
|
---|
| 235 | ; Returns:
|
---|
| 236 | ; AX: ROMVARS.wFlags
|
---|
| 237 | ; Corrupts registers:
|
---|
| 238 | ; BX
|
---|
| 239 | ;--------------------------------------------------------------------
|
---|
| 240 | ALIGN JUMP_ALIGN
|
---|
| 241 | Buffers_GetRomvarsFlagsToAX:
|
---|
| 242 | mov bx, ROMVARS.wFlags
|
---|
| 243 | ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
|
---|
| 244 |
|
---|
| 245 | ;--------------------------------------------------------------------
|
---|
[57] | 246 | ; Buffers_GetRomvarsValueToAXfromOffsetInBX
|
---|
| 247 | ; Parameters:
|
---|
| 248 | ; BX: ROMVARS offset
|
---|
| 249 | ; Returns:
|
---|
| 250 | ; AX: Value
|
---|
| 251 | ; Corrupts registers:
|
---|
| 252 | ; Nothing
|
---|
| 253 | ;--------------------------------------------------------------------
|
---|
| 254 | ALIGN JUMP_ALIGN
|
---|
| 255 | Buffers_GetRomvarsValueToAXfromOffsetInBX:
|
---|
| 256 | push es
|
---|
| 257 | push di
|
---|
| 258 | call Buffers_GetFileBufferToESDI
|
---|
| 259 | mov ax, [es:bx+di]
|
---|
| 260 | pop di
|
---|
| 261 | pop es
|
---|
| 262 | ret
|
---|
| 263 |
|
---|
| 264 |
|
---|
| 265 | ;--------------------------------------------------------------------
|
---|
[204] | 266 | ; Buffers_GetIdeControllerCountToCX
|
---|
| 267 | ; Parameters:
|
---|
| 268 | ; SS:BP: Menu handle
|
---|
| 269 | ; Returns:
|
---|
| 270 | ; CX: Number of IDE controllers to configure
|
---|
| 271 | ; ES:DI: Ptr to file buffer
|
---|
| 272 | ; Corrupts registers:
|
---|
| 273 | ; AX
|
---|
| 274 | ;--------------------------------------------------------------------
|
---|
| 275 | ALIGN JUMP_ALIGN
|
---|
| 276 | Buffers_GetIdeControllerCountToCX:
|
---|
| 277 | call Buffers_GetFileBufferToESDI
|
---|
| 278 | mov al, [es:di+ROMVARS.bIdeCnt]
|
---|
| 279 |
|
---|
| 280 | ; Limit controller count for lite mode
|
---|
| 281 | test BYTE [es:di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
| 282 | jnz SHORT .ReturnControllerCountInCX
|
---|
| 283 | MIN_U al, MAX_LITE_MODE_CONTROLLERS
|
---|
| 284 |
|
---|
| 285 | .ReturnControllerCountInCX:
|
---|
| 286 | cbw ; A maximum of 127 controllers should be sufficient
|
---|
| 287 | xchg cx, ax
|
---|
| 288 | ret
|
---|
| 289 |
|
---|
| 290 |
|
---|
| 291 | ;--------------------------------------------------------------------
|
---|
[57] | 292 | ; Buffers_GetFileBufferToESDI
|
---|
[65] | 293 | ; Buffers_GetFlashComparisonBufferToESDI
|
---|
[57] | 294 | ; Buffers_GetFileDialogItemBufferToESDI
|
---|
| 295 | ; Parameters:
|
---|
| 296 | ; Nothing
|
---|
| 297 | ; Returns:
|
---|
| 298 | ; ES:DI: Ptr to file buffer
|
---|
| 299 | ; Corrupts registers:
|
---|
| 300 | ; Nothing
|
---|
| 301 | ;--------------------------------------------------------------------
|
---|
| 302 | ALIGN JUMP_ALIGN
|
---|
[65] | 303 | Buffers_GetFlashComparisonBufferToESDI:
|
---|
[57] | 304 | Buffers_GetFileDialogItemBufferToESDI:
|
---|
[59] | 305 | call Buffers_GetFileBufferToESDI
|
---|
| 306 | push di
|
---|
| 307 | mov di, es
|
---|
| 308 | add di, 1000h ; Third 64k page
|
---|
| 309 | mov es, di
|
---|
| 310 | pop di
|
---|
| 311 | ret
|
---|
[65] | 312 | ALIGN JUMP_ALIGN
|
---|
[57] | 313 | Buffers_GetFileBufferToESDI:
|
---|
| 314 | mov di, cs
|
---|
| 315 | add di, 1000h ; Change to next 64k page
|
---|
| 316 | mov es, di
|
---|
| 317 | xor di, di ; Ptr now in ES:DI
|
---|
| 318 | ret
|
---|