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

Last change on this file since 381 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

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;--------------------------------------------------------------------
148ALIGN JUMP_ALIGN
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
158;--------------------------------------------------------------------
159; RamVars_GetCountOfKnownDrivesToAX
160; Parameters:
161; DS: RAMVARS segment
162; Returns:
163; AX: Total hard disk count
164; Corrupts registers:
165; None
166;--------------------------------------------------------------------
167ALIGN JUMP_ALIGN
168RamVars_GetCountOfKnownDrivesToAX:
169 mov ax, [RAMVARS.wDrvCntAndFirst]
170 add al, ah
171 and ax, BYTE 7fh
172 ret
173
174;--------------------------------------------------------------------
175; RamVars_GetIdeControllerCountToCX
176; Parameters:
177; Nothing
178; Returns:
179; CX: Number of IDE controllers to handle
180; Corrupts registers:
181; Nothing
182;--------------------------------------------------------------------
183ALIGN JUMP_ALIGN
184RamVars_GetIdeControllerCountToCX:
185 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
186 ret
187
188%ifdef MODULE_SERIAL_FLOPPY
189;--------------------------------------------------------------------
190; RamVars_UnpackFlopCntAndFirstToAL
191; Parameters:
192; Nothing
193; Returns:
194; AL: First floppy drive number supported
195; CF: Number of floppy drives supported (clear = 1, set = 2)
196; SF: Emulating drives (clear = yes, set = no)
197; Corrupts registers:
198; Nothing
199;--------------------------------------------------------------------
200ALIGN JUMP_ALIGN
201RamVars_UnpackFlopCntAndFirstToAL:
202 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
203 sar al, 1
204 ret
205%endif
Note: See TracBrowser for help on using the repository browser.