VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bootsector2-cpu-a20-1-template.mac@ 101470

Last change on this file since 101470 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.0 KB
Line 
1; $Id: bootsector2-cpu-a20-1-template.mac 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; bootsector2 A20 - multi mode template.
4;
5
6;
7; Copyright (C) 2007-2023 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; The contents of this file may alternatively be used under the terms
26; of the Common Development and Distribution License Version 1.0
27; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28; in the VirtualBox distribution, in which case the provisions of the
29; CDDL are applicable instead of those of the GPL.
30;
31; You may elect to license modified versions of this file under the
32; terms and conditions of either the GPL or the CDDL or both.
33;
34; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35;
36
37
38%include "bootsector2-template-header.mac"
39
40
41;;
42; Inner loop dealing with one 64KB segment.
43;
44BEGINPROC TMPL_NM(TestA20_EnabledInner)
45.inner_loop:
46 mov ah, [es:xDI]
47 mov al, [ds:xSI]
48 cmp al, ah
49 jne .inner_next
50
51 not al
52 mov [es:xDI], al
53 cmp al, [ds:xSI]
54 mov [es:xDI], ah
55 je .failed
56
57.inner_next:
58 inc xDI
59 inc xSI
60 dec ecx
61 jnz .inner_loop
62
63 clc
64 ret
65
66.failed:
67 push sBX
68 push sAX
69 push sSI
70 push sDI
71%ifdef TMPL_16BIT
72 push cs
73%endif
74 push .s_szModifiyError
75 call TMPL_NM_CMN(TestFailedF)
76 add xSP, sCB * 5
77 stc
78 ret
79.s_szModifiyError:
80 db TMPL_MODE_STR, '- Same memory; EDI=%RX32 ESI=%RX32 EAX=%RX32 EBX=%RX32', 13, 10, 0
81ENDPROC TMPL_NM(TestA20_EnabledInner)
82
83
84;;
85; Inner loop dealing with one 64KB segment.
86;
87BEGINPROC TMPL_NM(TestA20_DisabledInner)
88.inner_loop:
89 mov ah, [es:xDI]
90 mov al, [ds:xSI]
91 cmp al, ah
92 jne .failed1
93
94 not al
95 mov [es:xDI], al
96 cmp al, [ds:xSI]
97 mov [es:xDI], ah
98 jne .failed2
99
100 inc xDI
101 inc xSI
102 dec ecx
103 jnz .inner_loop
104
105 clc
106 ret
107
108.failed1:
109 push sCX
110 push sBX
111 push sAX
112 push sSI
113 push sDI
114%ifdef TMPL_16BIT
115 push cs
116%endif
117 push .s_szNotEqual
118 call TMPL_NM_CMN(TestFailedF)
119 add xSP, sCB * 6
120 stc
121 ret
122.s_szNotEqual:
123 db TMPL_MODE_STR, ' - Not equal; EDI=%RX32 ESI=%RX32 EAX=%RX32 EBX=%RX32 ECX=%RX32', 13, 10, 0
124
125.failed2:
126 push sCX
127 push sBX
128 push sAX
129 push sSI
130 push sDI
131%ifdef TMPL_16BIT
132 push cs
133%endif
134 push .s_szModifiyError
135 call TMPL_NM_CMN(TestFailedF)
136 add xSP, sCB * 6
137 stc
138 ret
139
140.s_szModifiyError:
141 db TMPL_MODE_STR, ' - Modify error; EDI=%RX32 ESI=%RX32 EAX=%RX32 EBX=%RX32 ECX=%RX32', 13, 10, 0
142ENDPROC TMPL_NM(TestA20_DisabledInner)
143
144
145;;
146; Scans memory calling sDX for each segment.
147;
148BEGINPROC TMPL_NM(TestA20_ScanMemory)
149 push sAX
150 push sBX
151 push sCX
152 push sDX
153 push sSI
154 push sDI
155 pushf
156 cli
157%ifdef TMPL_16BIT
158 push es
159 push ds
160%endif
161
162 ;
163 ; The outer loop walks a segment (64 KB) at a time.
164 ;
165 mov ebx, _1M
166.outer_loop:
167
168 ; Set up the registers.
169%ifdef TMPL_CMN_R86
170 mov ax, 0ffffh
171 mov edi, 00010h
172 mov es, ax
173 mov ax, 00000h
174 mov esi, 00000h
175 mov ds, ax
176 mov ecx, 01000h ; at 101000 there was a VMMDevTesting MMIO page.
177%elifdef TMPL_16BIT
178 ;; @todo need a selector we can modify.
179 jmp .done
180
181%else
182 mov edi, ebx
183 mov esi, ebx
184 and esi, ~_1M
185 mov ecx, _64K
186%endif
187%ifndef TMPL_CMN_R86
188 ; Should we skip this segment or only check parts of it?
189 cmp esi, edi ; affected by A20?
190 je .outer_next
191
192%if BS2_PXX_LAST != 09ffffh
193 %error BS2_PXX_LAST does not have the expected value.
194%endif
195 cmp ebx, BS2_PXX_BASE + _1M ; don't mess with page tables, stacks, MMIO or ROMs.
196 jb .not_low_rom_mmio_region
197 cmp ebx, _1M + _1M
198 jb .outer_next
199.not_low_rom_mmio_region:
200
201 cmp ebx, BS2_ADDR + _1M
202 ja .not_bs2
203 mov ecx, BS2_ADDR ; don't overwrite our own code.
204.not_bs2:
205 cmp ebx, _1M
206 jne .not_VMMDevTestingMMIO
207 mov ecx, 1000h ; don't bother with the MMIO
208.not_VMMDevTestingMMIO:
209%endif ; TMPL_CMN_R86
210
211 ; Invoke the callback.
212 call xDX
213 jc .failure
214
215%ifndef TMPL_CMN_R86
216.outer_next:
217 add ebx, _64K
218 cmp ebx, 32*_1M
219 jbe .outer_loop
220%endif
221
222.done:
223%ifdef TMPL_16BIT
224 pop ds
225 pop es
226%endif
227 popf
228 pop sDI
229 pop sSI
230 pop sDX
231 pop sCX
232 pop sBX
233 pop sAX
234 ret
235
236.failure:
237%if 1
238 cmp ebx, _1M
239 je .contine_at_next_MB
240 cmp ebx, _2M
241 je .contine_at_next_MB
242 cmp ebx, _1M + _2M
243 je .contine_at_next_MB
244 cmp ebx, _4M
245 je .contine_at_next_MB
246%endif
247 jmp .done
248
249.contine_at_next_MB:
250 add ebx, _1M
251 jmp .outer_loop
252ENDPROC TMPL_NM(TestA20_ScanMemory)
253
254
255BEGINPROC TMPL_NM(TestA20_Enabled)
256 push sDX
257 mov xDX, TMPL_NM(TestA20_EnabledInner)
258 call TMPL_NM(TestA20_ScanMemory)
259 pop sDX
260 ret
261ENDPROC TMPL_NM(TestA20_Enabled)
262
263
264;;
265; Checks that the first 64KB at 1MB wraps is the same physical memory as at
266; address 0.
267;
268BEGINPROC TMPL_NM(TestA20_Disabled)
269 push sDX
270 mov xDX, TMPL_NM(TestA20_DisabledInner)
271 call TMPL_NM(TestA20_ScanMemory)
272 pop sDX
273 ret
274ENDPROC TMPL_NM(TestA20_Disabled)
275
276
277BEGINPROC TMPL_NM(TestA20_FlushAll)
278 push sAX
279 wbinvd
280 mov sAX, cr3
281 mov cr3, sAX
282 wbinvd
283 pop sAX
284 ret
285ENDPROC TMPL_NM(TestA20_FlushAll)
286
287
288
289;;
290; Do the A20 tests for this mode.
291;
292; @uses nothing
293;
294BEGINCODELOW
295BITS 16
296BEGINPROC TMPL_NM(TestA20_rm)
297 push eax
298
299 mov ax, .s_szTestName
300 call TestSub_r86
301
302 call TMPL_NM(Bs2IsModeSupported_rm)
303 jz .skip_not_supported
304
305 ;
306 ; Do tests with A20 enabled.
307 ;
308 call Bs2EnableA20_r86
309 call TMPL_NM(Bs2EnterMode_rm)
310BITS TMPL_BITS
311 call TMPL_NM(TestA20_FlushAll)
312 call TMPL_NM(TestA20_Enabled)
313 call TMPL_NM(Bs2ExitMode)
314BITS 16
315 call TestSubErrorCount_r86
316 cmp ax, 0
317 jne .done
318
319 ;
320 ; Do tests with A20 disabled.
321 ;
322 call Bs2DisableA20_r86
323 call TMPL_NM(Bs2EnterMode_rm)
324BITS TMPL_BITS
325 call TMPL_NM(TestA20_FlushAll)
326 call TMPL_NM(TestA20_Disabled)
327 call TMPL_NM(Bs2ExitMode)
328BITS 16
329 call TestSubErrorCount_r86
330 cmp ax, 0
331 jne .done
332
333%ifndef TMPL_CMN_V86
334 ;
335 ; Change A20 state without leaving and entering the CPU mode.
336 ;
337 call Bs2EnableA20_r86
338 call TMPL_NM(Bs2EnterMode_rm)
339BITS TMPL_BITS
340 call TMPL_NM(TestA20_Enabled)
341
342 call TMPL_NM_CMN(Bs2DisableA20)
343 call TMPL_NM(TestA20_FlushAll)
344 call TMPL_NM(TestA20_Disabled)
345
346 call TMPL_NM_CMN(Bs2EnableA20)
347 call TMPL_NM(TestA20_FlushAll)
348 call TMPL_NM(TestA20_Enabled)
349
350 call TMPL_NM_CMN(Bs2DisableA20)
351 call TMPL_NM(TestA20_FlushAll)
352 call TMPL_NM(TestA20_Disabled)
353
354 call TMPL_NM_CMN(Bs2EnableA20)
355 call TMPL_NM(TestA20_FlushAll)
356 call TMPL_NM(TestA20_Enabled)
357
358 call TMPL_NM(Bs2ExitMode)
359BITS 16
360%endif ; !TMPL_CMN_V86
361
362.done:
363 call Bs2DisableA20_r86
364.done1:
365 call TestSubDone_r86
366
367 pop eax
368 ret
369
370.skip_not_supported:
371 mov eax, .s_szSkipNotSupported
372 call TestSkipped_r86
373 jmp .done1
374
375.s_szTestName:
376 db TMPL_MODE_STR, 0
377.s_szSkipNotSupported:
378 db TMPL_MODE_STR, ' is not supported by the CPU', 10, 13, 0
379ENDPROC TMPL_NM(TestA20_rm)
380TMPL_BEGINCODE
381BITS TMPL_BITS
382
383
384%include "bootsector2-template-footer.mac"
385
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette