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

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

Changes to XTIDE Universal BIOS:

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