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

Last change on this file since 399 was 395, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Hotkey Bar and drive translations are now in MODULE_HOTKEYS.
File size: 6.0 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 ; Always steal memory when using Advanced ATA module since it
50 ; uses larger DPTs
51%ifndef MODULE_ADVANCED_ATA
52 mov ax, LITE_MODE_RAMVARS_SEGMENT
53 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
54 jz SHORT .InitializeRamvars ; No need to steal RAM
55%endif
56
57 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
58 mov al, [cs:ROMVARS.bStealSize]
59 sub [BDA.wBaseMem], ax
60 mov ax, [BDA.wBaseMem]
61 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
62 ; Fall to .InitializeRamvars
63
64;--------------------------------------------------------------------
65; .InitializeRamvars
66; Parameters:
67; AX: RAMVARS segment
68; Returns:
69; DS: RAMVARS segment
70; Corrupts registers:
71; AX, CX, DI, ES
72;--------------------------------------------------------------------
73.InitializeRamvars:
74 mov ds, ax
75 mov es, ax
76 mov cx, RAMVARS_size
77 xor di, di
78 call Memory_ZeroESDIwithSizeInCX
79 mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
80 ; Fall to .InitializeDriveTranslationAndReturn
81
82;--------------------------------------------------------------------
83; .InitializeDriveTranslationAndReturn
84; Parameters:
85; DS: RAMVARS segment
86; Returns:
87; Nothing
88; Corrupts registers:
89; AX
90;--------------------------------------------------------------------
91.InitializeDriveTranslationAndReturn:
92 pop es
93%ifdef MODULE_HOTKEYS
94 jmp DriveXlate_Reset
95%else
96 ret
97%endif
98
99
100;--------------------------------------------------------------------
101; Returns segment to RAMVARS.
102; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
103; or at the top of system base RAM.
104;
105; RamVars_GetSegmentToDS
106; Parameters:
107; Nothing
108; Returns:
109; DS: RAMVARS segment
110; Corrupts registers:
111; DI
112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114RamVars_GetSegmentToDS:
115
116%ifndef MODULE_ADVANCED_ATA ; Always in Full Mode when using Advanced ATA Module
117 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
118 jnz SHORT .GetStolenSegmentToDS
119%ifndef USE_186
120 mov di, LITE_MODE_RAMVARS_SEGMENT
121 mov ds, di
122%else
123 push LITE_MODE_RAMVARS_SEGMENT
124 pop ds
125%endif
126 ret
127%endif ; MODULE_ADVANCED_ATA
128
129ALIGN JUMP_ALIGN
130.GetStolenSegmentToDS:
131 LOAD_BDA_SEGMENT_TO ds, di
132 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
133 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
134ALIGN JUMP_ALIGN
135.LoopStolenKBs:
136 mov ds, di ; EBDA segment to DS
137 add di, BYTE 64 ; DI to next stolen kB
138 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
139 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
140 ret
141
142
143;--------------------------------------------------------------------
144; RamVars_GetHardDiskCountFromBDAtoAX
145; Parameters:
146; DS: RAMVARS segment
147; Returns:
148; AX: Total hard disk count
149; Corrupts registers:
150; CX
151;--------------------------------------------------------------------
152%ifdef MODULE_BOOT_MENU
153RamVars_GetHardDiskCountFromBDAtoAX:
154 call RamVars_GetCountOfKnownDrivesToAX
155 push ds
156 LOAD_BDA_SEGMENT_TO ds, cx
157 mov cl, [BDA.bHDCount]
158 MAX_U al, cl
159 pop ds
160 ret
161%endif
162
163
164;--------------------------------------------------------------------
165; RamVars_GetCountOfKnownDrivesToAX
166; Parameters:
167; DS: RAMVARS segment
168; Returns:
169; AX: Total hard disk count
170; Corrupts registers:
171; None
172;--------------------------------------------------------------------
173ALIGN JUMP_ALIGN
174RamVars_GetCountOfKnownDrivesToAX:
175 mov ax, [RAMVARS.wDrvCntAndFirst]
176 add al, ah
177 and ax, BYTE 7fh
178 ret
179
180;--------------------------------------------------------------------
181; RamVars_GetIdeControllerCountToCX
182; Parameters:
183; Nothing
184; Returns:
185; CX: Number of IDE controllers to handle
186; Corrupts registers:
187; Nothing
188;--------------------------------------------------------------------
189ALIGN JUMP_ALIGN
190RamVars_GetIdeControllerCountToCX:
191 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
192 ret
193
194%ifdef MODULE_SERIAL_FLOPPY
195;--------------------------------------------------------------------
196; RamVars_UnpackFlopCntAndFirstToAL
197; Parameters:
198; Nothing
199; Returns:
200; AL: First floppy drive number supported
201; CF: Number of floppy drives supported (clear = 1, set = 2)
202; SF: Emulating drives (clear = yes, set = no)
203; Corrupts registers:
204; Nothing
205;--------------------------------------------------------------------
206ALIGN JUMP_ALIGN
207RamVars_UnpackFlopCntAndFirstToAL:
208 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
209 sar al, 1
210 ret
211%endif
Note: See TracBrowser for help on using the repository browser.