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

Last change on this file since 57 was 57, checked in by Tomi Tilli, 14 years ago

Initial commit (Work in progress).

File size: 3.9 KB
Line 
1; File name : EEPROM.asm
2; Project name : XTIDE Univeral BIOS Configurator v2
3; Created date : 19.4.2010
4; Last update : 10.10.2010
5; Author : Tomi Tilli
6; Description : Functions for managing EEPROM contents.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; EEPROM_LoadXtideUniversalBiosFromRomToRamBuffer
13; Parameters:
14; Nothing
15; Returns:
16; CX: BIOS size in bytes
17; Corrupts registers:
18; AX, BX, SI, DI
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21EEPROM_LoadXtideUniversalBiosFromRomToRamBuffer:
22 push es
23
24 call EEPROM_FindXtideUniversalBiosROMtoESDI
25 call .GetXtideUniversalBiosSizeFromEStoCX
26 xor si, si ; Load from beginning of ROM
27 call LoadBytesFromRomToRamBuffer
28
29 call .GetXtideUniversalBiosSizeFromEStoCX
30 pop es
31 ret
32
33;--------------------------------------------------------------------
34; .GetXtideUniversalBiosSizeFromEStoCX
35; Parameters:
36; Nothing
37; Returns:
38; AX: Bios size in bytes
39; Corrupts registers:
40; AX, BX
41;--------------------------------------------------------------------
42ALIGN JUMP_ALIGN
43.GetXtideUniversalBiosSizeFromEStoCX:
44 eMOVZX cx, BYTE [es:ROMVARS.bRomSize]
45 eSHL_IM cx, 9 ; *= 512 for byte count
46 ret
47
48
49;--------------------------------------------------------------------
50; EEPROM_LoadOldSettingsFromRomToRamBuffer
51; Parameters:
52; Nothing
53; Returns:
54; CF: Set if EEPROM was found
55; Cleared if EEPROM not found
56; Corrupts registers:
57; AX, BX, CX, SI, DI
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60EEPROM_LoadOldSettingsFromRomToRamBuffer:
61 mov cx, ROMVARS_size - ROMVARS.wFlags ; Number of bytes to load
62 mov si, ROMVARS.wFlags ; Offset where to start loading
63 ; Fall to LoadBytesFromRomToRamBuffer
64
65;--------------------------------------------------------------------
66; LoadBytesFromRomToRamBuffer
67; Parameters:
68; CX: Number of bytes to load from ROM
69; SI: Offset to first byte to load
70; Returns:
71; CF: Set if EEPROM was found
72; Cleared if EEPROM not found
73; Corrupts registers:
74; AX, BX, CX, SI, DI
75;--------------------------------------------------------------------
76ALIGN JUMP_ALIGN
77LoadBytesFromRomToRamBuffer:
78 push es
79 push ds
80
81 call EEPROM_FindXtideUniversalBiosROMtoESDI
82 jnc SHORT .XtideUniversalBiosNotFound
83 push es
84 pop ds ; DS:SI points to ROM
85
86 call Buffers_GetFileBufferToESDI
87 mov di, si ; ES:DI points to RAM buffer
88
89 cld
90 call Memory_CopyCXbytesFromDSSItoESDI
91 stc
92
93.XtideUniversalBiosNotFound:
94 pop ds
95 pop es
96 ret
97
98
99;--------------------------------------------------------------------
100; EEPROM_FindXtideUniversalBiosROMtoESDI
101; Parameters:
102; Nothing
103; Returns:
104; ES:DI: EEPROM segment
105; CF: Set if EEPROM was found
106; Cleared if EEPROM not found
107; Corrupts registers:
108; AX, BX
109;--------------------------------------------------------------------
110ALIGN JUMP_ALIGN
111EEPROM_FindXtideUniversalBiosROMtoESDI:
112 push si
113 push cx
114
115 xor di, di ; Zero DI (offset)
116 mov bx, 0C000h ; First possible ROM segment
117ALIGN JUMP_ALIGN
118.SegmentLoop:
119 mov es, bx ; Possible ROM segment to ES
120 call Buffers_IsXtideUniversalBiosSignatureInESDI
121 je SHORT .RomFound
122 add bx, 200h ; Increment by 8kB
123 jnc SHORT .SegmentLoop ; Loop until segment overflows
124 clc
125 jmp SHORT .ReturnWithoutUpdatingCF
126ALIGN JUMP_ALIGN
127.RomFound:
128 stc
129.ReturnWithoutUpdatingCF:
130 pop cx
131 pop si
132 ret
133
134
135;--------------------------------------------------------------------
136; EEPROM_GetPointerForFlashingToESDI
137; Parameters:
138; Nothing
139; Returns:
140; ES:DI: Ptr to EEPROM to be flashed
141; Corrupts registers:
142; Nothing
143;--------------------------------------------------------------------
144ALIGN JUMP_ALIGN
145EEPROM_GetPointerForFlashingToESDI:
146 mov es, [cs:g_cfgVars+CFGVARS.wEepromSegment]
147 xor di, di
148 ret
Note: See TracBrowser for help on using the repository browser.