VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bootsector2-cpu-db-loop.asm@ 103131

Last change on this file since 103131 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1; $Id: bootsector2-cpu-db-loop.asm 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; Bootsector test for debug exception loop.
4;
5; Recommended (but not necessary):
6; VBoxManage setextradata bs-cpu-db-loop VBoxInternal/Devices/VMMDev/0/Config/TestingEnabled 1
7;
8
9;
10; Copyright (C) 2007-2023 Oracle and/or its affiliates.
11;
12; This file is part of VirtualBox base platform packages, as
13; available from https://www.virtualbox.org.
14;
15; This program is free software; you can redistribute it and/or
16; modify it under the terms of the GNU General Public License
17; as published by the Free Software Foundation, in version 3 of the
18; License.
19;
20; This program is distributed in the hope that it will be useful, but
21; WITHOUT ANY WARRANTY; without even the implied warranty of
22; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23; General Public License for more details.
24;
25; You should have received a copy of the GNU General Public License
26; along with this program; if not, see <https://www.gnu.org/licenses>.
27;
28; The contents of this file may alternatively be used under the terms
29; of the Common Development and Distribution License Version 1.0
30; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
31; in the VirtualBox distribution, in which case the provisions of the
32; CDDL are applicable instead of those of the GPL.
33;
34; You may elect to license modified versions of this file under the
35; terms and conditions of either the GPL or the CDDL or both.
36;
37; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
38;
39
40
41;*******************************************************************************
42;* Header Files *
43;*******************************************************************************
44%include "iprt/asmdefs.mac"
45%include "iprt/x86.mac"
46%include "VBox/VMMDevTesting.mac"
47
48
49;
50; Include and execute the init code.
51;
52 %define BS2_INIT_PE32
53 %define BS2_WITH_TRAPS
54 %define BS2_WITH_XCPT_DB_CLEARING_TF
55 %define BS2_INC_PE16
56 %define BS2_INC_PE32
57 %define BS2_INC_RM ; for SetCpuModeGlobals_rm
58 %include "bootsector2-common-init-code.mac"
59
60
61;
62; The main() function.
63;
64BEGINPROC main
65 BITS 32
66 ;
67 ; Test prologue.
68 ;
69 mov ax, .s_szTstName
70 call TestInit_p32
71 call Bs2EnableA20_p32
72 cli ; raw-mode hack
73 sub esp, 20h
74
75 call Bs2Thunk_p32_p16
76 BITS 16
77
78 ;
79 ; We require a stack that can wrap around here. The default stack
80 ; doesn't allow us to do this, so we'll configure a custom one
81 ; where the page tables usually are.
82 ;
83 mov eax, [bs2Gdt + BS2_SEL_SS16]
84 mov ebx, [bs2Gdt + BS2_SEL_SS16 + 4]
85
86 and eax, 0xffff
87 or eax, (BS2_PXX_BASE & 0xffff) << 16
88 and ebx, 0x00ffff00
89 or ebx, BS2_PXX_BASE & 0xff000000
90 or ebx, (BS2_PXX_BASE & 0x00ff0000) >> 16
91 mov [bs2GdtSpare0], eax
92 mov [bs2GdtSpare0 + 4], ebx
93
94
95 ;
96 ; Switch the stack.
97 ;
98 mov ax, ss
99 mov es, ax ; saved ss
100 mov edi, esp ; saved esp
101
102 mov ax, BS2_SEL_SPARE0
103 mov ss, ax
104 mov esp, 0xfff0
105
106
107 ;
108 ; Arm the breakpoint.
109 ;
110 and dword [esp + 2], 0
111 sidt [esp]
112 mov eax, [esp + 2]
113 add eax, 8
114 mov dr0, eax
115 mov eax, X86_DR7_RA1_MASK | X86_DR7_GE \
116 | X86_DR7_L0 | X86_DR7_G0 | X86_DR7_RW(0, X86_DR7_RW_RW) | X86_DR7_LEN(0, X86_DR7_LEN_DWORD)
117 mov dr7, eax
118
119 ;
120 ; Trigger a single step exception.
121 ;
122 pushf
123 or word [xSP], X86_EFL_TF
124 popf
125 xchg eax, ebx
126 xchg edx, ecx ; should get a #DB here.
127 xchg eax, ebx
128 xchg edx, ecx
129
130 ;
131 ; If we get thus far, we've failed.
132 ;
133 mov ax, es ; restore ss
134 mov ss, ax
135 mov esp, edi ; restore esp
136
137 call Bs2Thunk_p16_p32
138 BITS 32
139
140 mov eax, .s_szFailed
141 call TestFailed_p32
142
143 ;
144 ; We're done.
145 ;
146 call TestTerm_p32
147 add esp, 20h
148 ret
149
150.s_szTstName:
151 db 'tstCpuDbLoop', 0
152.s_szFailed:
153 db 'no #DB loop detected',0
154ENDPROC main
155
156
157;
158; End sections and image.
159;
160%include "bootsector2-common-end.mac"
161
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