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