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

Last change on this file since 563 was 556, checked in by aitotat@…, 11 years ago

Changes to XTIDE Universal BIOS:

  • Removed Windows 98 fix since it broke floppy drive translation.
  • Removed very late initialization from AT builds since it slowed down Windows 98 for unknown reason.
File size: 5.6 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-2013 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] ; We can save a byte here by using INT 12h instead
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%ifdef MODULE_DRIVEXLATE
80 call DriveXlate_Reset
81%endif
82
83 pop es
84 ret
85
86;--------------------------------------------------------------------
87; Returns segment to RAMVARS.
88; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
89; or at the top of system base RAM.
90;
91; RamVars_GetSegmentToDS
92; Parameters:
93; Nothing
94; Returns:
95; DS: RAMVARS segment
96; Corrupts registers:
97; DI
98;--------------------------------------------------------------------
99ALIGN JUMP_ALIGN
100RamVars_GetSegmentToDS:
101
102%ifndef USE_AT ; Always in Full Mode for AT builds
103 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
104 jnz SHORT .GetStolenSegmentToDS
105 %ifndef USE_186
106 mov di, LITE_MODE_RAMVARS_SEGMENT
107 mov ds, di
108 %else
109 push LITE_MODE_RAMVARS_SEGMENT
110 pop ds
111 %endif
112 ret
113%endif
114
115ALIGN JUMP_ALIGN
116.GetStolenSegmentToDS:
117 LOAD_BDA_SEGMENT_TO ds, di
118 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
119 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
120ALIGN JUMP_ALIGN
121.LoopStolenKBs:
122 mov ds, di ; EBDA segment to DS
123 add di, BYTE 64 ; DI to next stolen kB
124 cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
125 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
126 ret
127
128
129;--------------------------------------------------------------------
130; RamVars_GetHardDiskCountFromBDAtoAX
131; Parameters:
132; DS: RAMVARS segment
133; Returns:
134; AX: Total hard disk count
135; Corrupts registers:
136; BX
137;--------------------------------------------------------------------
138%ifdef MODULE_BOOT_MENU
139RamVars_GetHardDiskCountFromBDAtoAX:
140 call RamVars_GetCountOfKnownDrivesToAX
141 push ds
142 LOAD_BDA_SEGMENT_TO ds, bx
143 mov bl, [BDA.bHDCount]
144 MAX_U al, bl
145 pop ds
146 ret
147%endif
148
149
150;--------------------------------------------------------------------
151; RamVars_GetCountOfKnownDrivesToAX
152; Parameters:
153; DS: RAMVARS segment
154; Returns:
155; AX: Total hard disk count
156; Corrupts registers:
157; None
158;--------------------------------------------------------------------
159ALIGN JUMP_ALIGN
160RamVars_GetCountOfKnownDrivesToAX:
161 mov ax, [RAMVARS.wFirstDrvAndCount]
162 add al, ah
163 and ax, BYTE 7fh
164 ret
165
166;--------------------------------------------------------------------
167; RamVars_GetIdeControllerCountToCX
168; Parameters:
169; Nothing
170; Returns:
171; CX: Number of IDE controllers to handle
172; Corrupts registers:
173; Nothing
174;--------------------------------------------------------------------
175ALIGN JUMP_ALIGN
176RamVars_GetIdeControllerCountToCX:
177 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
178 ret
179
180
181%ifdef MODULE_SERIAL_FLOPPY
182;--------------------------------------------------------------------
183; RamVars_UnpackFlopCntAndFirstToAL
184; Parameters:
185; DS: RAMVARS segment
186; Returns:
187; AL: First floppy drive number supported
188; CF: Number of floppy drives supported (clear = 1, set = 2)
189; SF: Emulating drives (clear = yes, set = no)
190; Corrupts registers:
191; Nothing
192;--------------------------------------------------------------------
193ALIGN JUMP_ALIGN
194RamVars_UnpackFlopCntAndFirstToAL:
195 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
196 sar al, 1
197 ret
198%endif
Note: See TracBrowser for help on using the repository browser.