source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm @ 592

Last change on this file since 592 was 592, checked in by krille_n_, 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.3 KB
Line 
1; Project name  :   XTIDE Univeral BIOS Configurator v2
2; Description   :   Functions for managing EEPROM contents.
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 initialized data
21SECTION .data
22
23ALIGN WORD_ALIGN
24g_rgwEepromTypeToSizeInWords:
25    dw      (2<<10) / 2     ; EEPROM_TYPE.2816_2kiB
26    dw      (8<<10) / 2
27    dw      (8<<10) / 2     ; EEPROM_TYPE.2864_8kiB_MOD
28    dw      (32<<10) / 2
29    dw      (64<<10) / 2
30
31g_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
42; Section containing code
43SECTION .text
44
45;--------------------------------------------------------------------
46; EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX
47;   Parameters:
48;       Nothing
49;   Returns:
50;       DX:CX:  BIOS size in bytes
51;   Corrupts registers:
52;       BX, SI, DI
53;--------------------------------------------------------------------
54ALIGN JUMP_ALIGN
55EEPROM_LoadXtideUniversalBiosFromRomToRamBufferAndReturnSizeInDXCX:
56    push    es
57
58    call    EEPROM_FindXtideUniversalBiosROMtoESDI
59    call    EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
60    xor     si, si              ; Load from beginning of ROM
61    call    LoadBytesFromRomToRamBuffer
62
63    pop     es
64    ret
65
66
67;--------------------------------------------------------------------
68; EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
69;   Parameters:
70;       ES:DI:  Ptr to XTIDE Universal BIOS
71;   Returns:
72;       DX:CX:  Bios size in bytes
73;   Corrupts registers:
74;       Nothing
75;--------------------------------------------------------------------
76ALIGN JUMP_ALIGN
77EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX:
78    xor     dx, dx
79    mov     ch, [es:di+ROMVARS.bRomSize]
80    mov     cl, dl
81    eSHL_IM ch, 1
82    eRCL_IM dl, 1
83    ret
84
85
86;--------------------------------------------------------------------
87; EEPROM_LoadOldSettingsFromRomToRamBuffer
88;   Parameters:
89;       Nothing
90;   Returns:
91;       CF:     Cleared if EEPROM was found
92;               Set if EEPROM not found
93;   Corrupts registers:
94;       BX, CX, SI
95;--------------------------------------------------------------------
96ALIGN JUMP_ALIGN
97EEPROM_LoadOldSettingsFromRomToRamBuffer:
98    mov     cx, ROMVARS_size - ROMVARS.wFlags   ; Number of bytes to load
99    mov     si, ROMVARS.wFlags                  ; Offset where to start loading
100    ; Fall to LoadBytesFromRomToRamBuffer
101
102;--------------------------------------------------------------------
103; LoadBytesFromRomToRamBuffer
104;   Parameters:
105;       CX:     Number of bytes to load from ROM
106;       SI:     Offset to first byte to load
107;   Returns:
108;       CF:     Cleared if EEPROM was found
109;               Set if EEPROM not found
110;   Corrupts registers:
111;       BX, SI
112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114LoadBytesFromRomToRamBuffer:
115    push    es
116    push    ds
117    push    di
118
119    call    EEPROM_FindXtideUniversalBiosROMtoESDI
120    jc      SHORT .XtideUniversalBiosNotFound
121    push    es
122    pop     ds                                          ; DS:SI points to ROM
123
124    call    Buffers_GetFileBufferToESDI
125    mov     di, si                                      ; ES:DI points to RAM buffer
126
127%ifdef CLD_NEEDED
128    cld
129%endif
130    call    Memory_CopyCXbytesFromDSSItoESDI            ; Clears CF
131
132.XtideUniversalBiosNotFound:
133    pop     di
134    pop     ds
135    pop     es
136    ret
137
138
139;--------------------------------------------------------------------
140; EEPROM_FindXtideUniversalBiosROMtoESDI
141;   Parameters:
142;       Nothing
143;   Returns:
144;       ES:DI:  EEPROM segment
145;       CF:     Cleared if EEPROM was found
146;               Set if EEPROM not found
147;   Corrupts registers:
148;       BX
149;--------------------------------------------------------------------
150ALIGN JUMP_ALIGN
151EEPROM_FindXtideUniversalBiosROMtoESDI:
152    push    si
153    push    cx
154
155    xor     di, di                  ; Zero DI (offset)
156    mov     bx, 0C000h              ; First possible ROM segment
157ALIGN JUMP_ALIGN
158.SegmentLoop:
159    mov     es, bx                  ; Possible ROM segment to ES
160    call    Buffers_IsXtideUniversalBiosSignatureInESDI
161    je      SHORT .RomFound         ; If equal, CF=0
162    add     bx, 80h                 ; Increment by 2kB (minimum possible distance from the beginning of one option ROM to the next)
163    jnc     SHORT .SegmentLoop      ; Loop until segment overflows
164.RomFound:
165    pop     cx
166    pop     si
167    ret
168
169
170;--------------------------------------------------------------------
171; EEPROM_LoadFromRomToRamComparisonBuffer
172;   Parameters:
173;       Nothing
174;   Returns:
175;       Nothing
176;   Corrupts registers:
177;       BX, CX, SI, DI
178;--------------------------------------------------------------------
179ALIGN JUMP_ALIGN
180EEPROM_LoadFromRomToRamComparisonBuffer:
181    push    es
182    push    ds
183
184    mov     ds, [cs:g_cfgVars+CFGVARS.wEepromSegment]
185    xor     si, si
186    call    Buffers_GetFlashComparisonBufferToESDI
187    eMOVZX  bx, [cs:g_cfgVars+CFGVARS.bEepromType]
188%ifdef CLD_NEEDED
189    cld
190%endif
191;%if g_rgwEepromTypeToSizeInWords = 0   ; *FIXME* It really is but NASM won't accept this.
192    mov     cx, [cs:bx]
193;%else
194;   mov     cx, [cs:bx+g_rgwEepromTypeToSizeInWords]
195;%endif
196    rep movsw
197
198    pop     ds
199    pop     es
200    ret
Note: See TracBrowser for help on using the repository browser.