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

Last change on this file since 589 was 589, checked in by krille_n_, 8 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 5.9 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    push    ds
36
37    call    .OpenFileForLoadingFromDSSIandGetSizeToDXCX
38    jc      SHORT .DisplayErrorMessage
39    call    .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
40    jc      SHORT .DisplayErrorMessage
41
42    mov     ax, FLG_CFGVARS_FILELOADED
43    call    Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
44    call    FileIO_CloseUsingHandleFromBX
45    call    DisplayFileLoadedSuccessfully
46    jmp     SHORT .Return
47
48.DisplayErrorMessage:
49    call    FileIO_CloseUsingHandleFromBX
50    call    DisplayFailedToLoadFile
51ALIGN JUMP_ALIGN
52.Return:
53    pop     ds
54    ret
55
56;--------------------------------------------------------------------
57; .OpenFileForLoadingFromDSSIandGetSizeInBytesToDXCX
58;   Parameters:
59;       DS:SI:  Name of file to open
60;   Returns:
61;       BX:     File handle (if successful)
62;       DX:CX:  File size (if successful)
63;       CF:     Clear if successful
64;               Set if error
65;   Corrupts registers:
66;       AX
67;--------------------------------------------------------------------
68ALIGN JUMP_ALIGN
69.OpenFileForLoadingFromDSSIandGetSizeToDXCX:
70    mov     al, FILE_ACCESS.ReadOnly
71    call    FileIO_OpenWithPathInDSSIandFileAccessInAL
72    jc      SHORT .FileError
73    call    FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
74    jc      SHORT .FileError
75
76    cmp     dx, MAX_EEPROM_SIZE_IN_BYTES >> 16
77    jb      SHORT .FileNotTooBig
78    ja      SHORT .FileTooBig
79    cmp     ax, MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh
80    ja      SHORT .FileTooBig
81.FileNotTooBig:
82    xchg    cx, ax
83    clc
84    ret
85.FileTooBig:
86    call    DisplayFileTooBig
87    stc
88.FileError:
89    ret
90
91;--------------------------------------------------------------------
92; .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
93;   Parameters:
94;       BX:     File Handle
95;       DX:CX:  File size
96;       DS:SI:  File name
97;   Returns:
98;       CF:     Clear if successful
99;               Set if error
100;   Corrupts registers:
101;       AX, SI, DI, DS
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
104.LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer:
105    push    es
106
107    call    Buffers_GetFileBufferToESDI
108    call    Registers_ExchangeDSSIwithESDI
109    call    FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
110    jc      SHORT .ReturnError
111
112    ; Store filename to Cfgvars from ESDI
113    push    cx
114
115    call    Registers_CopyESDItoDSSI    ; File name in DS:SI
116    push    cs
117    pop     es
118    mov     di, g_cfgVars+CFGVARS.szOpenedFile
119    cld
120    call    String_CopyDSSItoESDIandGetLengthToCX
121    clc
122
123    pop     cx
124ALIGN JUMP_ALIGN
125.ReturnError:
126    pop     es
127    ret
128
129
130;--------------------------------------------------------------------
131; BiosFile_SaveUnsavedChanges
132;   Parameters:
133;       SS:BP:  Menu handle
134;   Returns:
135;       Nothing
136;   Corrupts registers:
137;       AX, BX, CX, SI, DI
138;--------------------------------------------------------------------
139ALIGN JUMP_ALIGN
140BiosFile_SaveUnsavedChanges:
141    push    ds
142
143    push    cs
144    pop     ds
145    mov     si, g_cfgVars+CFGVARS.szOpenedFile
146    call    BiosFile_SaveRamBufferToFileInDSSI
147
148    pop     ds
149    ret
150
151
152;--------------------------------------------------------------------
153; BiosFile_SaveRamBufferToFileInDSSI
154;   Parameters:
155;       DS:SI:  Name of file to save
156;       SS:BP:  Menu handle
157;   Returns:
158;       Nothing
159;   Corrupts registers:
160;       AX, BX, CX, SI, DI
161;--------------------------------------------------------------------
162ALIGN JUMP_ALIGN
163BiosFile_SaveRamBufferToFileInDSSI:
164    push    es
165    push    ds
166
167    call    Buffers_GenerateChecksum
168    call    Buffers_GetFileBufferToESDI
169    call    EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
170
171    mov     al, FILE_ACCESS.WriteOnly
172    call    FileIO_OpenWithPathInDSSIandFileAccessInAL
173    jc      SHORT .DisplayErrorMessage
174
175    call    Registers_CopyESDItoDSSI
176    call    FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
177    jc      SHORT .DisplayErrorMessage
178
179    call    FileIO_CloseUsingHandleFromBX
180    call    Buffers_ClearUnsavedChanges
181    call    DisplayFileSavedSuccessfully
182    jmp     SHORT .Return
183
184.DisplayErrorMessage:
185    call    FileIO_CloseUsingHandleFromBX
186    call    DisplayFailedToSaveFile
187ALIGN JUMP_ALIGN
188.Return:
189    pop     ds
190    pop     es
191    ret
192
193
194;--------------------------------------------------------------------
195; DisplayFileLoadedSuccessfully
196; DisplayFileSavedSuccessfully
197; DisplayFailedToLoadFile
198; DisplayFailedToSaveFile
199; DisplayFileTooBig
200;   Parameters:
201;       SS:BP:  Menu handle
202;   Returns:
203;       Nothing
204;   Corrupts registers:
205;       AX, DX
206;--------------------------------------------------------------------
207ALIGN JUMP_ALIGN
208DisplayFileLoadedSuccessfully:
209    mov     dx, g_szDlgMainLoadFile
210    jmp     Dialogs_DisplayNotificationFromCSDX
211
212ALIGN JUMP_ALIGN
213DisplayFileSavedSuccessfully:
214    mov     dx, g_szDlgMainSaveFile
215    jmp     Dialogs_DisplayNotificationFromCSDX
216
217DisplayFailedToLoadFile:
218    mov     dx, g_szDlgMainLoadErr
219    jmp     Dialogs_DisplayErrorFromCSDX
220
221DisplayFailedToSaveFile:
222    mov     dx, g_szDlgMainSaveErr
223    jmp     Dialogs_DisplayErrorFromCSDX
224
225DisplayFileTooBig:
226    mov     dx, g_szDlgMainFileTooBig
227    jmp     Dialogs_DisplayErrorFromCSDX
Note: See TracBrowser for help on using the repository browser.