source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm@ 479

Last change on this file since 479 was 473, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Large changes to prepare full XT-CF support (DMA not yet implemented and memory mapped transfers are not working).
File size: 6.9 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for accessings RAMVARS.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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; Initializes RAMVARS.
25; Drive detection can be started after this function returns.
26;
27; RamVars_Initialize
28; Parameters:
29; Nothing
30; Returns:
31; DS: RAMVARS segment
32; Corrupts registers:
33; AX, CX, DI
34;--------------------------------------------------------------------
35RamVars_Initialize:
36 push es
37 ; Fall to .StealMemoryForRAMVARS
38
39;--------------------------------------------------------------------
40; .StealMemoryForRAMVARS
41; Parameters:
42; Nothing
43; Returns:
44; DS: RAMVARS segment
45; Corrupts registers:
46; AX
47;--------------------------------------------------------------------
48.StealMemoryForRAMVARS:
49%ifndef USE_AT
50 mov ax, LITE_MODE_RAMVARS_SEGMENT
51 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
52 jz SHORT .InitializeRamvars ; No need to steal RAM
53%endif
54
55 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
56 mov al, [cs:ROMVARS.bStealSize]
57 sub [BDA.wBaseMem], ax
58 mov ax, [BDA.wBaseMem]
59 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
60 ; Fall to .InitializeRamvars
61
62;--------------------------------------------------------------------
63; .InitializeRamvars
64; Parameters:
65; AX: RAMVARS segment
66; Returns:
67; DS: RAMVARS segment
68; Corrupts registers:
69; AX, CX, DI, ES
70;--------------------------------------------------------------------
71.InitializeRamvars:
72 mov ds, ax
73 mov es, ax
74 mov cx, RAMVARS_size
75 xor di, di
76 call Memory_ZeroESDIwithSizeInCX
77 mov WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE
78 mov WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
79 ; Fall to .InitializeInt13hStackChangeVariables
80
81;--------------------------------------------------------------------
82; .InitializeInt13hStackChangeVariables
83; Parameters:
84; DS: RAMVARS segment
85; Returns:
86; Nothing
87; Corrupts registers:
88; AX
89;--------------------------------------------------------------------
90%ifdef RELOCATE_INT13H_STACK
91.InitializeInt13hStackChangeVariables:
92 eMOVZX ax, BYTE [cs:ROMVARS.bStealSize]
93 eSHL_IM ax, 10 ; kiB to Bytes = Top of stack offset
94 mov [RAMVARS.wNewStackOffset], ax
95%endif
96 ; Fall to .InitializeDriveTranslationAndReturn
97
98;--------------------------------------------------------------------
99; .InitializeDriveTranslationAndReturn
100; Parameters:
101; DS: RAMVARS segment
102; Returns:
103; Nothing
104; Corrupts registers:
105; AX
106;--------------------------------------------------------------------
107.InitializeDriveTranslationAndReturn:
108 pop es
109%ifdef MODULE_HOTKEYS
110 jmp DriveXlate_Reset
111%else
112 ret
113%endif
114
115
116;--------------------------------------------------------------------
117; Returns segment to RAMVARS.
118; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
119; or at the top of system base RAM.
120;
121; RamVars_GetSegmentToDS
122; Parameters:
123; Nothing
124; Returns:
125; DS: RAMVARS segment
126; Corrupts registers:
127; DI
128;--------------------------------------------------------------------
129ALIGN JUMP_ALIGN
130RamVars_GetSegmentToDS:
131
132%ifndef USE_AT ; Always in Full Mode for AT builds
133 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
134 jnz SHORT .GetStolenSegmentToDS
135 %ifndef USE_186
136 mov di, LITE_MODE_RAMVARS_SEGMENT
137 mov ds, di
138 %else
139 push LITE_MODE_RAMVARS_SEGMENT
140 pop ds
141 %endif
142 ret
143%endif
144
145ALIGN JUMP_ALIGN
146.GetStolenSegmentToDS:
147 LOAD_BDA_SEGMENT_TO ds, di
148 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
149 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
150ALIGN JUMP_ALIGN
151.LoopStolenKBs:
152 mov ds, di ; EBDA segment to DS
153 add di, BYTE 64 ; DI to next stolen kB
154 cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
155 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
156 ret
157
158
159;--------------------------------------------------------------------
160; RamVars_GetHardDiskCountFromBDAtoAX
161; Parameters:
162; DS: RAMVARS segment
163; Returns:
164; AX: Total hard disk count
165; Corrupts registers:
166; CX
167;--------------------------------------------------------------------
168%ifdef MODULE_BOOT_MENU
169RamVars_GetHardDiskCountFromBDAtoAX:
170 call RamVars_GetCountOfKnownDrivesToAX
171 push ds
172 LOAD_BDA_SEGMENT_TO ds, cx
173 mov cl, [BDA.bHDCount]
174 MAX_U al, cl
175 pop ds
176 ret
177%endif
178
179
180;--------------------------------------------------------------------
181; RamVars_GetCountOfKnownDrivesToAX
182; Parameters:
183; DS: RAMVARS segment
184; Returns:
185; AX: Total hard disk count
186; Corrupts registers:
187; None
188;--------------------------------------------------------------------
189ALIGN JUMP_ALIGN
190RamVars_GetCountOfKnownDrivesToAX:
191 mov ax, [RAMVARS.wFirstDrvAndCount]
192 add al, ah
193 and ax, BYTE 7fh
194 ret
195
196;--------------------------------------------------------------------
197; RamVars_GetIdeControllerCountToCX
198; Parameters:
199; Nothing
200; Returns:
201; CX: Number of IDE controllers to handle
202; Corrupts registers:
203; Nothing
204;--------------------------------------------------------------------
205ALIGN JUMP_ALIGN
206RamVars_GetIdeControllerCountToCX:
207 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
208 ret
209
210
211%ifdef MODULE_SERIAL_FLOPPY
212;--------------------------------------------------------------------
213; RamVars_UnpackFlopCntAndFirstToAL
214; Parameters:
215; DS: RAMVARS segment
216; Returns:
217; AL: First floppy drive number supported
218; CF: Number of floppy drives supported (clear = 1, set = 2)
219; SF: Emulating drives (clear = yes, set = no)
220; Corrupts registers:
221; Nothing
222;--------------------------------------------------------------------
223ALIGN JUMP_ALIGN
224RamVars_UnpackFlopCntAndFirstToAL:
225 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
226 sar al, 1
227 ret
228%endif
229
230
231;--------------------------------------------------------------------
232; RamVars_IsDriveDetectionInProgress
233; Parameters:
234; DS: RAMVARS segment
235; Returns:
236; ZF: Set if drive detection is in progress (ROM initialization)
237; Corrupts registers:
238; None
239;--------------------------------------------------------------------
240RamVars_IsDriveDetectionInProgress:
241 cmp WORD [RAMVARS.wSignature], RAMVARS_DRV_DETECT_SIGNATURE
242 ret
Note: See TracBrowser for help on using the repository browser.