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

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

Changes to XTIDE Universal BIOS:

  • Greatly improved Hotkey Bar is displayed during drive detection.
  • 8k builds no longer include boot menu.
  • Boot menu is displayed only if F2 is pressed during drive detection.
  • Some changes to directory structure.


File size: 5.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 ; 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 jmp DriveXlate_Reset
94
95
96;--------------------------------------------------------------------
97; Returns segment to RAMVARS.
98; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
99; or at the top of system base RAM.
100;
101; RamVars_GetSegmentToDS
102; Parameters:
103; Nothing
104; Returns:
105; DS: RAMVARS segment
106; Corrupts registers:
107; DI
108;--------------------------------------------------------------------
109ALIGN JUMP_ALIGN
110RamVars_GetSegmentToDS:
111
112%ifndef MODULE_ADVANCED_ATA ; Always in Full Mode when using Advanced ATA Module
113 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
114 jnz SHORT .GetStolenSegmentToDS
115%ifndef USE_186
116 mov di, LITE_MODE_RAMVARS_SEGMENT
117 mov ds, di
118%else
119 push LITE_MODE_RAMVARS_SEGMENT
120 pop ds
121%endif
122 ret
123%endif ; MODULE_ADVANCED_ATA
124
125ALIGN JUMP_ALIGN
126.GetStolenSegmentToDS:
127 LOAD_BDA_SEGMENT_TO ds, di
128 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
129 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
130ALIGN JUMP_ALIGN
131.LoopStolenKBs:
132 mov ds, di ; EBDA segment to DS
133 add di, BYTE 64 ; DI to next stolen kB
134 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
135 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
136 ret
137
138
139;--------------------------------------------------------------------
140; RamVars_GetHardDiskCountFromBDAtoAX
141; Parameters:
142; DS: RAMVARS segment
143; Returns:
144; AX: Total hard disk count
145; Corrupts registers:
146; CX
147;--------------------------------------------------------------------
148%ifdef MODULE_BOOT_MENU
149RamVars_GetHardDiskCountFromBDAtoAX:
150 call RamVars_GetCountOfKnownDrivesToAX
151 push ds
152 LOAD_BDA_SEGMENT_TO ds, cx
153 mov cl, [BDA.bHDCount]
154 MAX_U al, cl
155 pop ds
156 ret
157%endif
158
159
160;--------------------------------------------------------------------
161; RamVars_GetCountOfKnownDrivesToAX
162; Parameters:
163; DS: RAMVARS segment
164; Returns:
165; AX: Total hard disk count
166; Corrupts registers:
167; None
168;--------------------------------------------------------------------
169ALIGN JUMP_ALIGN
170RamVars_GetCountOfKnownDrivesToAX:
171 mov ax, [RAMVARS.wDrvCntAndFirst]
172 add al, ah
173 and ax, BYTE 7fh
174 ret
175
176;--------------------------------------------------------------------
177; RamVars_GetIdeControllerCountToCX
178; Parameters:
179; Nothing
180; Returns:
181; CX: Number of IDE controllers to handle
182; Corrupts registers:
183; Nothing
184;--------------------------------------------------------------------
185ALIGN JUMP_ALIGN
186RamVars_GetIdeControllerCountToCX:
187 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
188 ret
189
190%ifdef MODULE_SERIAL_FLOPPY
191;--------------------------------------------------------------------
192; RamVars_UnpackFlopCntAndFirstToAL
193; Parameters:
194; Nothing
195; Returns:
196; AL: First floppy drive number supported
197; CF: Number of floppy drives supported (clear = 1, set = 2)
198; SF: Emulating drives (clear = yes, set = no)
199; Corrupts registers:
200; Nothing
201;--------------------------------------------------------------------
202ALIGN JUMP_ALIGN
203RamVars_UnpackFlopCntAndFirstToAL:
204 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
205 sar al, 1
206 ret
207%endif
Note: See TracBrowser for help on using the repository browser.