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

Last change on this file since 595 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
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 pop ds
47 ret
48
49.DisplayErrorMessage:
50 call FileIO_CloseUsingHandleFromBX
51 call DisplayFailedToLoadFile
52 pop ds
53 ret
54
55;--------------------------------------------------------------------
56; .OpenFileForLoadingFromDSSIandGetSizeInBytesToDXCX
57; Parameters:
58; DS:SI: Name of file to open
59; Returns:
60; BX: File handle (if successful)
61; DX:CX: File size (if successful)
62; CF: Clear if successful
63; Set if error
64; Corrupts registers:
65; AX
66;--------------------------------------------------------------------
67ALIGN JUMP_ALIGN
68.OpenFileForLoadingFromDSSIandGetSizeToDXCX:
69 mov al, FILE_ACCESS.ReadOnly
70 call FileIO_OpenWithPathInDSSIandFileAccessInAL
71 jc SHORT .FileError
72 call FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
73 jc SHORT .FileError
74
75 cmp dx, MAX_EEPROM_SIZE_IN_BYTES >> 16
76 jb SHORT .FileNotTooBig
77 ja SHORT .FileTooBig
78 cmp ax, MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh
79 ja SHORT .FileTooBig
80.FileNotTooBig:
81 xchg cx, ax
82 clc
83 ret
84.FileTooBig:
85 call DisplayFileTooBig
86 stc
87.FileError:
88 ret
89
90;--------------------------------------------------------------------
91; .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
92; Parameters:
93; BX: File Handle
94; DX:CX: File size
95; DS:SI: File name
96; Returns:
97; CF: Clear if successful
98; Set if error
99; Corrupts registers:
100; AX, SI, DI, DS
101;--------------------------------------------------------------------
102ALIGN JUMP_ALIGN
103.LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer:
104 push es
105
106 call Buffers_GetFileBufferToESDI
107 call Registers_ExchangeDSSIwithESDI
108 call FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
109 jc SHORT .ReturnError
110
111 ; Store filename to Cfgvars from ESDI
112 push cx
113
114 call Registers_CopyESDItoDSSI ; File name in DS:SI
115 push cs
116 pop es
117 mov di, g_cfgVars+CFGVARS.szOpenedFile
118%ifdef CLD_NEEDED
119 cld
120%endif
121 call String_CopyDSSItoESDIandGetLengthToCX
122 clc
123
124 pop cx
125ALIGN JUMP_ALIGN
126.ReturnError:
127 pop es
128 ret
129
130
131;--------------------------------------------------------------------
132; BiosFile_SaveUnsavedChanges
133; Parameters:
134; SS:BP: Menu handle
135; Returns:
136; Nothing
137; Corrupts registers:
138; AX, BX, CX, SI, DI
139;--------------------------------------------------------------------
140ALIGN JUMP_ALIGN
141BiosFile_SaveUnsavedChanges:
142 push ds
143
144 push cs
145 pop ds
146 mov si, g_cfgVars+CFGVARS.szOpenedFile
147 call BiosFile_SaveRamBufferToFileInDSSI
148
149 pop ds
150 ret
151
152
153;--------------------------------------------------------------------
154; BiosFile_SaveRamBufferToFileInDSSI
155; Parameters:
156; DS:SI: Name of file to save
157; SS:BP: Menu handle
158; Returns:
159; Nothing
160; Corrupts registers:
161; AX, BX, CX, SI, DI
162;--------------------------------------------------------------------
163ALIGN JUMP_ALIGN
164BiosFile_SaveRamBufferToFileInDSSI:
165 push es
166 push ds
167
168 call Buffers_GenerateChecksum
169 call Buffers_GetFileBufferToESDI
170 call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
171
172 mov al, FILE_ACCESS.WriteOnly
173 call FileIO_OpenWithPathInDSSIandFileAccessInAL
174 jc SHORT .DisplayErrorMessage
175
176 call Registers_CopyESDItoDSSI
177 call FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
178 jc SHORT .DisplayErrorMessage
179
180 call FileIO_CloseUsingHandleFromBX
181 call Buffers_ClearUnsavedChanges
182 call DisplayFileSavedSuccessfully
183 jmp SHORT .Return
184
185.DisplayErrorMessage:
186 call FileIO_CloseUsingHandleFromBX
187 call DisplayFailedToSaveFile
188ALIGN JUMP_ALIGN
189.Return:
190 pop ds
191 pop es
192 ret
193
194
195;--------------------------------------------------------------------
196; DisplayFileLoadedSuccessfully
197; DisplayFileSavedSuccessfully
198; DisplayFailedToLoadFile
199; DisplayFailedToSaveFile
200; DisplayFileTooBig
201; Parameters:
202; SS:BP: Menu handle
203; Returns:
204; Nothing
205; Corrupts registers:
206; AX, DX
207;--------------------------------------------------------------------
208ALIGN JUMP_ALIGN
209DisplayFileLoadedSuccessfully:
210 mov dx, g_szDlgMainLoadFile
211 jmp Dialogs_DisplayNotificationFromCSDX
212
213ALIGN JUMP_ALIGN
214DisplayFileSavedSuccessfully:
215 mov dx, g_szDlgMainSaveFile
216 jmp Dialogs_DisplayNotificationFromCSDX
217
218DisplayFailedToLoadFile:
219 mov dx, g_szDlgMainLoadErr
220 jmp Dialogs_DisplayErrorFromCSDX
221
222DisplayFailedToSaveFile:
223 mov dx, g_szDlgMainSaveErr
224 jmp Dialogs_DisplayErrorFromCSDX
225
226DisplayFileTooBig:
227 mov dx, g_szDlgMainFileTooBig
228 jmp Dialogs_DisplayErrorFromCSDX
Note: See TracBrowser for help on using the repository browser.