1 | ; $Id: env-bs2-r0-common.mac 96407 2022-08-22 17:43:14Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; Instruction Test Environment - Boot Sector Type 2, Ring-0.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2022 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 | ; SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | ;
|
---|
27 |
|
---|
28 | %ifndef ___env_bs2_r0_common_mac
|
---|
29 | %define ___env_bs2_r0_common_mac
|
---|
30 |
|
---|
31 |
|
---|
32 | ;; Same as BEGINPROC in asmdefs.mac.
|
---|
33 | %macro VBINSTST_BEGINPROC 1
|
---|
34 | VBINSTST_GLOBALNAME_EX %1, function hidden
|
---|
35 | %endm
|
---|
36 |
|
---|
37 | ;; Same as ENDPROC in asmdefs.mac.
|
---|
38 | %macro VBINSTST_ENDPROC 1,
|
---|
39 | VBINSTST_GLOBALNAME_EX %1 %+ _EndProc, function hidden
|
---|
40 | %endm
|
---|
41 |
|
---|
42 | ;; Same as NAME in asmdefs.mac.
|
---|
43 | %define VBINSTST_NAME(a_Name) TMPL_NM(a_Name)
|
---|
44 |
|
---|
45 | ;; Same as GLOBALNAME_EX in asmdefs.mac.
|
---|
46 | %macro VBINSTST_GLOBALNAME_EX 2,
|
---|
47 | VBINSTST_NAME(%1):
|
---|
48 | %endmacro
|
---|
49 |
|
---|
50 | ;; Same as BEGINCODE in asmdefs.mac.
|
---|
51 | %macro VBINSTST_BEGINCODE 0,
|
---|
52 | BEGINCODE
|
---|
53 | %endmacro
|
---|
54 |
|
---|
55 | ;; Same as BEGINDATA in asmdefs.mac.
|
---|
56 | %macro VBINSTST_BEGINDATA 0,
|
---|
57 | BEGINDATA
|
---|
58 | %endmacro
|
---|
59 |
|
---|
60 |
|
---|
61 | ;
|
---|
62 | ; Trap related macros.
|
---|
63 | ;
|
---|
64 | %define VBINSTST_CAN_DO_TRAPS 1
|
---|
65 |
|
---|
66 | %macro VBINSTST_TRAP_INSTR 3+,
|
---|
67 | section .traprecs
|
---|
68 | istruc BS2TRAPREC
|
---|
69 | at BS2TRAPREC.offWhere, dd (%%trapinstr - VBINSTST_IMAGE_BASE_LABLE)
|
---|
70 | at BS2TRAPREC.offResumeAddend, db (%%resume - %%trapinstr)
|
---|
71 | at BS2TRAPREC.u8TrapNo, db %1
|
---|
72 | at BS2TRAPREC.u16ErrCd, dw %2
|
---|
73 | iend
|
---|
74 | VBINSTST_BEGINCODE
|
---|
75 | %if %1 != X86_XCPT_BP
|
---|
76 | %%trapinstr:
|
---|
77 | %3
|
---|
78 | %else
|
---|
79 | %3
|
---|
80 | %%trapinstr:
|
---|
81 | %endif
|
---|
82 | call VBINSTST_NAME(Common_MissingTrap_ %+ %1)
|
---|
83 | %%resume:
|
---|
84 | %endmacro
|
---|
85 |
|
---|
86 | %macro VBINSTST_TRAP_RECS_BEGIN 0,
|
---|
87 | VBINSTST_BEGINDATA
|
---|
88 | section .traprecs progbits valign=8 vfollows=.data align=8 follows=.data
|
---|
89 | dq 0ffffffffeeeeeeeeh
|
---|
90 | dq 0ddddddddcccccccch
|
---|
91 | VBINSTST_GLOBALNAME_EX g_aTrapRecs, hidden
|
---|
92 | VBINSTST_BEGINCODE
|
---|
93 | %endmacro
|
---|
94 |
|
---|
95 | %macro VBINSTST_TRAP_RECS_END 0,
|
---|
96 | section .traprecs
|
---|
97 | VBINSTST_GLOBALNAME_EX g_aTrapRecsEnd, hidden
|
---|
98 | dq 0ddddddddcccccccch
|
---|
99 | dq 0ffffffffeeeeeeeeh
|
---|
100 | VBINSTST_BEGINCODE
|
---|
101 | %endmacro
|
---|
102 |
|
---|
103 | %macro VBINSTST_TRAP_RECS_INSTALL 0,
|
---|
104 | mov sAX, VBINSTST_NAME(g_aTrapRecs)
|
---|
105 | mov edx, VBINSTST_NAME(g_aTrapRecsEnd) - VBINSTST_NAME(g_aTrapRecs)
|
---|
106 | shr edx, BS2TRAPREC_SIZE_SHIFT
|
---|
107 | mov sCX, VBINSTST_IMAGE_BASE_LABLE
|
---|
108 | VBINSTST_CALL_TEST_INSTALL_TRAP_RECS
|
---|
109 | %endmacro
|
---|
110 |
|
---|
111 | %macro VBINSTST_TRAP_RECS_UNINSTALL 0,
|
---|
112 | xor sAX, sAX
|
---|
113 | xor edx, edx
|
---|
114 | xor sCX, sCX
|
---|
115 | VBINSTST_CALL_TEST_INSTALL_TRAP_RECS
|
---|
116 | %endmacro
|
---|
117 |
|
---|
118 |
|
---|
119 | ;
|
---|
120 | ; Include the common bits (contains code using above macros)
|
---|
121 | ;
|
---|
122 | %include "env-common.mac"
|
---|
123 |
|
---|
124 | %endif
|
---|
125 |
|
---|