VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bootsector2-common-traprec.mac@ 107044

Last change on this file since 107044 was 106061, checked in by vboxsync, 2 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: 5.3 KB
Line 
1; $Id: bootsector2-common-traprec.mac 106061 2024-09-16 14:03:52Z vboxsync $
2;; @file
3; Boot sector 2 - Trap Records.
4;
5; @note Don't forget to cinldue bootsector2-common-traprec-end.mac!
6;
7
8;
9; Copyright (C) 2007-2024 Oracle and/or its affiliates.
10;
11; This file is part of VirtualBox base platform packages, as
12; available from https://www.virtualbox.org.
13;
14; This program is free software; you can redistribute it and/or
15; modify it under the terms of the GNU General Public License
16; as published by the Free Software Foundation, in version 3 of the
17; License.
18;
19; This program is distributed in the hope that it will be useful, but
20; WITHOUT ANY WARRANTY; without even the implied warranty of
21; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22; General Public License for more details.
23;
24; You should have received a copy of the GNU General Public License
25; along with this program; if not, see <https://www.gnu.org/licenses>.
26;
27; The contents of this file may alternatively be used under the terms
28; of the Common Development and Distribution License Version 1.0
29; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
30; in the VirtualBox distribution, in which case the provisions of the
31; CDDL are applicable instead of those of the GPL.
32;
33; You may elect to license modified versions of this file under the
34; terms and conditions of either the GPL or the CDDL or both.
35;
36; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
37;
38
39%ifndef ___bootsector2_common_traprec_mac___
40%define ___bootsector2_common_traprec_mac___
41
42
43;*******************************************************************************
44;* Header Files *
45;*******************************************************************************
46%include "iprt/x86.mac"
47
48
49;*******************************************************************************
50;* Defined Constants And Macros *
51;*******************************************************************************
52;;
53; The base address for the records (only important for 64-bit code
54; loaded above 4GB).
55; We use 0 by default so we don't create too complex expressions for YASM.
56%ifndef BS2_TRAP_RECS_BASE
57 %define BS2_TRAP_RECS_BASE 0
58%endif
59
60;;
61; Macro to emit an trapping instruction.
62;
63; @param 1 The trap number (X86_XCPT_XXX).
64; @param 2 The error code, 0 if none.
65; @param 3+ The instruction.
66;
67; @sa BS2_TRAP_BRANCH_INSTR
68;
69%macro BS2_TRAP_INSTR 3+,
70 [section .traprecs]
71 istruc BS2TRAPREC
72 at BS2TRAPREC.offWhere, dd (%%trapinstr - BS2_TRAP_RECS_BASE)
73 at BS2TRAPREC.offResumeAddend, db (%%resume - %%trapinstr)
74 at BS2TRAPREC.u8TrapNo, db %1
75 at BS2TRAPREC.u16ErrCd, dw %2
76 iend
77 __SECT__
78 %if %1 != X86_XCPT_BP
79 %%trapinstr:
80 %3
81 %else
82 %3
83 %%trapinstr:
84 %endif
85 call TMPL_NM_CMN(TestFailedMissingTrap_ %+ %1)
86 %%resume:
87%endmacro
88
89;;
90; Macro to emit an trapping instruction.
91;
92; @param 1 The trap number (X86_XCPT_XXX).
93; @param 2 The error code, 0 if none.
94; @param 3 The name of the branch label.
95; @param 4+ The instruction.
96;
97%macro BS2_TRAP_BRANCH_INSTR 4+,
98 [section .traprecs]
99 istruc BS2TRAPREC
100 at BS2TRAPREC.offWhere, dd (%%trapinstr - BS2_TRAP_RECS_BASE)
101 at BS2TRAPREC.offResumeAddend, db (%%resume - %%trapinstr)
102 at BS2TRAPREC.u8TrapNo, db %1
103 at BS2TRAPREC.u16ErrCd, dw %2
104 iend
105 __SECT__
106 %%trapinstr:
107 %4
108 %3:
109 call TMPL_NM_CMN(TestFailedMissingTrap_ %+ %1)
110 %%resume:
111%endmacro
112
113;;
114; Sets up the trap records section.
115; @internal
116%macro BS2_TRAP_RECS_BEGIN 0,
117 [section .traprecs] ; Declared in bootsector2-common-init-code.mac
118 dq 0ffffffffeeeeeeeeh
119g_aTrapRecs:
120 __SECT__
121%endmacro
122
123;;
124; Terminates the trap records section.
125; @internal
126%macro BS2_TRAP_RECS_END 0,
127 [section .traprecs]
128g_aTrapRecsEnd:
129 dq 0ddddddddcccccccch
130 __SECT__
131%endmacro
132
133
134;;
135; Macro for installing the trap records.
136;
137; This must be invoked prior to the traps.
138;
139; @uses Stack
140;
141%macro BS2_TRAP_RECS_INSTALL 0,
142 push sAX
143 push sDX
144 push sCX
145
146 mov sAX, NAME(g_aTrapRecs)
147 mov edx, NAME(g_aTrapRecsEnd) - NAME(g_aTrapRecs)
148 shr edx, BS2TRAPREC_SIZE_SHIFT
149 mov sCX, BS2_TRAP_RECS_BASE
150 call TMPL_NM_CMN(TestInstallTrapRecs)
151
152 pop sAX
153 pop sDX
154 pop sCX
155%endmacro
156
157
158;;
159; Macro for uninstalling the trap records.
160;
161; @uses Stack
162;
163%macro BS2_TRAP_RECS_UNINSTALL 0,
164 push sAX
165 push sDX
166 push sCX
167
168 xor sAX, sAX
169 xor edx, edx
170 xor sCX, sCX
171 call TMPL_NM_CMN(TestInstallTrapRecs)
172
173 pop sAX
174 pop sDX
175 pop sCX
176%endmacro
177
178
179;
180; Setup the trap record segment.
181;
182BS2_TRAP_RECS_BEGIN
183BEGINCODELOW
184
185
186;
187; Instantiate code templates.
188;
189%ifdef BS2_INC_CMN_R86
190 %define TMPL_RM
191 %include "bootsector2-common-traprec-template.mac"
192%endif
193%ifdef BS2_INC_CMN_P16
194 %define TMPL_PE16
195 %include "bootsector2-common-traprec-template.mac"
196%endif
197%ifdef BS2_INC_CMN_P32
198 %define TMPL_PE32
199 %include "bootsector2-common-traprec-template.mac"
200%endif
201%ifdef BS2_INC_LM64
202 %define TMPL_LM64
203 %include "bootsector2-common-traprec-template.mac"
204%endif
205
206BEGINCODELOW
207
208%endif
209
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