source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm

Last change on this file was 621, checked in by krille_n_, 2 years ago

Changes:

  • Fixed three different bugs all causing the boot menu to show drives using IRQs even though the BIOS had been built without MODULE_IRQ.
  • Fixed two bugs in XTIDECFG where loading a BIOS from file and then loading the old settings from EEPROM would
    • overwrite ROMVARS.wFlags in the loaded BIOS file (in RAM). The possibly resulting mismatch of module flags could make it impossible to change settings for modules included in the BIOS or allow changing settings for modules not included in the BIOS.
    • not copy the color theme over to the loaded BIOS.
  • Also fixed two very minor bugs in XTIDECFG in BiosFile_LoadFileFromDSSItoRamBuffer and BiosFile_SaveRamBufferToFileInDSSI where the error handling in these routines would close whatever file handle that happened to match the error code returned by DOS in AX.
  • Made significant changes to the new flash ROM programming routines to reduce the size. Also fixed a minor bug that would cause the second verification to be skipped and return success when programming a 64 KB block of data.
  • Changed the custom BIOS build file names to the 8.3 format.
  • Changed some help strings in XTIDECFG to clarify things.
  • Other minor optimizations and fixes.
File size: 5.5 KB
Line 
1; Project name  :   XTIDE Univeral BIOS Configurator v2
2; Description   :   Functions for loading and saving BIOS image file.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; BiosFile_LoadFileFromDSSItoRamBuffer
25;   Parameters:
26;       DS:SI:  Name of file to open
27;       SS:BP:  Menu handle
28;   Returns:
29;       Nothing
30;   Corrupts registers:
31;       AX, BX, CX, DX, SI, DI
32;--------------------------------------------------------------------
33ALIGN JUMP_ALIGN
34BiosFile_LoadFileFromDSSItoRamBuffer:
35    mov     al, FILE_ACCESS.ReadOnly
36    call    FileIO_OpenWithPathInDSSIandFileAccessInAL
37    jc      SHORT .DisplayErrorMessage
38
39    call    FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
40    jc      SHORT .CloseUsingHandleFromBXandDisplayErrorMessage
41
42    cmp     dx, MAX_EEPROM_SIZE_IN_BYTES >> 16
43    jb      SHORT .FileNotTooBig
44    ja      SHORT .FileTooBig
45%if (MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh) = 0
46    test    ax, ax
47    jnz     SHORT .FileTooBig
48%else
49    cmp     ax, MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh
50    ja      SHORT .FileTooBig
51%endif
52.FileNotTooBig:
53    xchg    cx, ax
54
55    call    .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
56    jc      SHORT .CloseUsingHandleFromBXandDisplayErrorMessage
57
58    mov     al, FLG_CFGVARS_FILELOADED
59    call    Buffers_NewBiosWithSizeInDXCXandSourceInALhasBeenLoadedForConfiguration
60    call    FileIO_CloseUsingHandleFromBX
61    jmp     SHORT DisplayFileLoadedSuccessfully
62
63.FileTooBig:
64    call    DisplayFileTooBig
65.CloseUsingHandleFromBXandDisplayErrorMessage:
66    call    FileIO_CloseUsingHandleFromBX
67.DisplayErrorMessage:
68    jmp     SHORT DisplayFailedToLoadFile
69
70
71;--------------------------------------------------------------------
72; .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
73;   Parameters:
74;       BX:     File Handle
75;       DX:CX:  File size
76;       DS:SI:  File name
77;   Returns:
78;       CF:     Clear if successful
79;               Set if error
80;   Corrupts registers:
81;       AX, SI, DI, DS
82;--------------------------------------------------------------------
83ALIGN JUMP_ALIGN
84.LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer:
85    push    es
86
87    call    Buffers_GetFileBufferToESDI
88    call    Registers_ExchangeDSSIwithESDI
89    call    FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
90    jc      SHORT .ReturnError
91
92    ; Store filename to Cfgvars from ESDI
93    push    cx
94
95    call    Registers_CopyESDItoDSSI                ; File name in DS:SI
96    push    cs
97    pop     es
98    mov     di, g_cfgVars+CFGVARS.szOpenedFile
99%ifdef CLD_NEEDED
100    cld
101%endif
102    call    String_CopyDSSItoESDIandGetLengthToCX   ; Returns with CF cleared
103
104    pop     cx
105ALIGN JUMP_ALIGN
106.ReturnError:
107    pop     es
108    ret
109
110
111;--------------------------------------------------------------------
112; BiosFile_SaveUnsavedChanges
113;   Parameters:
114;       SS:BP:  Menu handle
115;   Returns:
116;       Nothing
117;   Corrupts registers:
118;       AX, BX, CX, SI, DI
119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121BiosFile_SaveUnsavedChanges:
122    push    ds
123
124    push    cs
125    pop     ds
126    mov     si, g_cfgVars+CFGVARS.szOpenedFile
127    call    BiosFile_SaveRamBufferToFileInDSSI
128
129    pop     ds
130    ret
131
132
133;--------------------------------------------------------------------
134; BiosFile_SaveRamBufferToFileInDSSI
135;   Parameters:
136;       DS:SI:  Name of file to save
137;       SS:BP:  Menu handle
138;   Returns:
139;       Nothing
140;   Corrupts registers:
141;       AX, BX, CX, SI, DI
142;--------------------------------------------------------------------
143ALIGN JUMP_ALIGN
144BiosFile_SaveRamBufferToFileInDSSI:
145    push    es
146
147    call    Buffers_GenerateChecksum
148    call    Buffers_GetFileBufferToESDI
149    call    EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
150
151    mov     al, FILE_ACCESS.WriteOnly
152    call    FileIO_OpenWithPathInDSSIandFileAccessInAL
153    jc      SHORT .DisplayErrorMessage
154
155    push    ds
156    call    Registers_CopyESDItoDSSI
157    call    FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
158    pop     ds
159    pushf
160    call    FileIO_CloseUsingHandleFromBX
161    popf
162    jc      SHORT .DisplayErrorMessage
163
164    call    Buffers_ClearUnsavedChanges
165    pop     es
166    jmp     SHORT DisplayFileSavedSuccessfully
167
168.DisplayErrorMessage:
169    pop     es
170    jmp     SHORT DisplayFailedToSaveFile
171
172
173;--------------------------------------------------------------------
174; DisplayFileLoadedSuccessfully
175; DisplayFileSavedSuccessfully
176; DisplayFailedToLoadFile
177; DisplayFailedToSaveFile
178; DisplayFileTooBig
179;   Parameters:
180;       SS:BP:  Menu handle
181;   Returns:
182;       Nothing
183;   Corrupts registers:
184;       AX, DX
185;--------------------------------------------------------------------
186ALIGN JUMP_ALIGN
187DisplayFileLoadedSuccessfully:
188    mov     dx, g_szDlgMainLoadFile
189    jmp     Dialogs_DisplayNotificationFromCSDX
190
191ALIGN JUMP_ALIGN
192DisplayFileSavedSuccessfully:
193    mov     dx, g_szDlgMainSaveFile
194    jmp     Dialogs_DisplayNotificationFromCSDX
195
196DisplayFailedToLoadFile:
197    mov     dx, g_szDlgMainLoadErr
198    jmp     Dialogs_DisplayErrorFromCSDX
199
200DisplayFailedToSaveFile:
201    mov     dx, g_szDlgMainSaveErr
202    jmp     Dialogs_DisplayErrorFromCSDX
203
204DisplayFileTooBig:
205    mov     dx, g_szDlgMainFileTooBig
206    jmp     Dialogs_DisplayErrorFromCSDX
Note: See TracBrowser for help on using the repository browser.