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