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

Last change on this file since 499 was 493, checked in by gregli@…, 12 years ago

Separated MODULE_8BIT_IDE into the basic part used by XTIDE rev 1 and rev 2 which is PIO based, and MODULE_8BIT_IDE_ADVANCED for JRIDE and XTCF support which requires memory mapping and/or DMA. This allows for creating an 8KB image with boot menu support (but no hotkeys) for the XTIDE rev 1. Cleaned up how we reset the drive translation information, ensuring it is properly set between boot attempt on a primary and secondary drive - as a result we clean it when needed, rather than trying to always keep it clean. Also fixed translation bugs in int13h.asm where I had previously missed converting some MODULE_HOTKEYS into MODULE_DRIVEXLATE.

File size: 6.7 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.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE
78 mov WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
79 ; Fall to .InitializeInt13hStackChangeVariables
80
81;--------------------------------------------------------------------
82; .InitializeInt13hStackChangeVariables
83; Parameters:
84; DS: RAMVARS segment
85; Returns:
86; Nothing
87; Corrupts registers:
88; AX
89;--------------------------------------------------------------------
90%ifdef RELOCATE_INT13H_STACK
91.InitializeInt13hStackChangeVariables:
92 eMOVZX ax, BYTE [cs:ROMVARS.bStealSize]
93 eSHL_IM ax, 10 ; kiB to Bytes = Top of stack offset
94 mov [RAMVARS.wNewStackOffset], ax
95%endif
96
97;; There used to be a DriveXlate_Reset call here. It isn't necessary, as we reset
98;; when entering the boot menu and also before transferring control at boot time and
99;; for ROM boots (in int19h.asm).
100
101 pop es
102 ret
103
104;--------------------------------------------------------------------
105; Returns segment to RAMVARS.
106; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
107; or at the top of system base RAM.
108;
109; RamVars_GetSegmentToDS
110; Parameters:
111; Nothing
112; Returns:
113; DS: RAMVARS segment
114; Corrupts registers:
115; DI
116;--------------------------------------------------------------------
117ALIGN JUMP_ALIGN
118RamVars_GetSegmentToDS:
119
120%ifndef USE_AT ; Always in Full Mode for AT builds
121 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
122 jnz SHORT .GetStolenSegmentToDS
123 %ifndef USE_186
124 mov di, LITE_MODE_RAMVARS_SEGMENT
125 mov ds, di
126 %else
127 push LITE_MODE_RAMVARS_SEGMENT
128 pop ds
129 %endif
130 ret
131%endif
132
133ALIGN JUMP_ALIGN
134.GetStolenSegmentToDS:
135 LOAD_BDA_SEGMENT_TO ds, di
136 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
137 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
138ALIGN JUMP_ALIGN
139.LoopStolenKBs:
140 mov ds, di ; EBDA segment to DS
141 add di, BYTE 64 ; DI to next stolen kB
142 cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
143 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
144 ret
145
146
147;--------------------------------------------------------------------
148; RamVars_GetHardDiskCountFromBDAtoAX
149; Parameters:
150; DS: RAMVARS segment
151; Returns:
152; AX: Total hard disk count
153; Corrupts registers:
154; BX
155;--------------------------------------------------------------------
156%ifdef MODULE_BOOT_MENU
157RamVars_GetHardDiskCountFromBDAtoAX:
158 call RamVars_GetCountOfKnownDrivesToAX
159 push ds
160 LOAD_BDA_SEGMENT_TO ds, cx
161 mov bl, [BDA.bHDCount]
162 MAX_U al, bl
163 pop ds
164 ret
165%endif
166
167
168;--------------------------------------------------------------------
169; RamVars_GetCountOfKnownDrivesToAX
170; Parameters:
171; DS: RAMVARS segment
172; Returns:
173; AX: Total hard disk count
174; Corrupts registers:
175; None
176;--------------------------------------------------------------------
177ALIGN JUMP_ALIGN
178RamVars_GetCountOfKnownDrivesToAX:
179 mov ax, [RAMVARS.wFirstDrvAndCount]
180 add al, ah
181 and ax, BYTE 7fh
182 ret
183
184;--------------------------------------------------------------------
185; RamVars_GetIdeControllerCountToCX
186; Parameters:
187; Nothing
188; Returns:
189; CX: Number of IDE controllers to handle
190; Corrupts registers:
191; Nothing
192;--------------------------------------------------------------------
193ALIGN JUMP_ALIGN
194RamVars_GetIdeControllerCountToCX:
195 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
196 ret
197
198
199%ifdef MODULE_SERIAL_FLOPPY
200;--------------------------------------------------------------------
201; RamVars_UnpackFlopCntAndFirstToAL
202; Parameters:
203; DS: RAMVARS segment
204; Returns:
205; AL: First floppy drive number supported
206; CF: Number of floppy drives supported (clear = 1, set = 2)
207; SF: Emulating drives (clear = yes, set = no)
208; Corrupts registers:
209; Nothing
210;--------------------------------------------------------------------
211ALIGN JUMP_ALIGN
212RamVars_UnpackFlopCntAndFirstToAL:
213 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
214 sar al, 1
215 ret
216%endif
217
218
219%if 0 ; unused...
220;--------------------------------------------------------------------
221; RamVars_IsDriveDetectionInProgress
222; Parameters:
223; DS: RAMVARS segment
224; Returns:
225; ZF: Set if drive detection is in progress (ROM initialization)
226; Corrupts registers:
227; None
228;--------------------------------------------------------------------
229RamVars_IsDriveDetectionInProgress:
230 cmp WORD [RAMVARS.wSignature], RAMVARS_DRV_DETECT_SIGNATURE
231 ret
232%endif
Note: See TracBrowser for help on using the repository browser.