1 | ; $Id: env-bs2-r0-common.mac 56287 2015-06-09 11:15:22Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; Instruction Test Environment - Boot Sector Type 2, Ring-0.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2015 Oracle Corporation
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
11 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | ; General Public License (GPL) as published by the Free Software
|
---|
13 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 |
|
---|
18 | %ifndef ___env_bs2_r0_common_mac
|
---|
19 | %define ___env_bs2_r0_common_mac
|
---|
20 |
|
---|
21 |
|
---|
22 | ;; Same as BEGINPROC in asmdefs.mac.
|
---|
23 | %macro VBINSTST_BEGINPROC 1
|
---|
24 | VBINSTST_GLOBALNAME_EX %1, function hidden
|
---|
25 | %endm
|
---|
26 |
|
---|
27 | ;; Same as ENDPROC in asmdefs.mac.
|
---|
28 | %macro VBINSTST_ENDPROC 1,
|
---|
29 | VBINSTST_GLOBALNAME_EX %1 %+ _EndProc, function hidden
|
---|
30 | %endm
|
---|
31 |
|
---|
32 | ;; Same as NAME in asmdefs.mac.
|
---|
33 | %define VBINSTST_NAME(a_Name) TMPL_NM(a_Name)
|
---|
34 |
|
---|
35 | ;; Same as GLOBALNAME_EX in asmdefs.mac.
|
---|
36 | %macro VBINSTST_GLOBALNAME_EX 2,
|
---|
37 | VBINSTST_NAME(%1):
|
---|
38 | %endmacro
|
---|
39 |
|
---|
40 | ;; Same as BEGINCODE in asmdefs.mac.
|
---|
41 | %macro VBINSTST_BEGINCODE 0,
|
---|
42 | BEGINCODE
|
---|
43 | %endmacro
|
---|
44 |
|
---|
45 | ;; Same as BEGINDATA in asmdefs.mac.
|
---|
46 | %macro VBINSTST_BEGINDATA 0,
|
---|
47 | BEGINDATA
|
---|
48 | %endmacro
|
---|
49 |
|
---|
50 |
|
---|
51 | ;
|
---|
52 | ; Trap related macros.
|
---|
53 | ;
|
---|
54 | %define VBINSTST_CAN_DO_TRAPS 1
|
---|
55 |
|
---|
56 | %macro VBINSTST_TRAP_INSTR 3+,
|
---|
57 | section .traprecs
|
---|
58 | istruc BS2TRAPREC
|
---|
59 | at BS2TRAPREC.offWhere, dd (%%trapinstr - VBINSTST_IMAGE_BASE_LABLE)
|
---|
60 | at BS2TRAPREC.offResumeAddend, db (%%resume - %%trapinstr)
|
---|
61 | at BS2TRAPREC.u8TrapNo, db %1
|
---|
62 | at BS2TRAPREC.u16ErrCd, dw %2
|
---|
63 | iend
|
---|
64 | VBINSTST_BEGINCODE
|
---|
65 | %if %1 != X86_XCPT_BP
|
---|
66 | %%trapinstr:
|
---|
67 | %3
|
---|
68 | %else
|
---|
69 | %3
|
---|
70 | %%trapinstr:
|
---|
71 | %endif
|
---|
72 | call VBINSTST_NAME(Common_MissingTrap_ %+ %1)
|
---|
73 | %%resume:
|
---|
74 | %endmacro
|
---|
75 |
|
---|
76 | %macro VBINSTST_TRAP_RECS_BEGIN 0,
|
---|
77 | VBINSTST_BEGINDATA
|
---|
78 | section .traprecs progbits valign=8 vfollows=.data align=8 follows=.data
|
---|
79 | dq 0ffffffffeeeeeeeeh
|
---|
80 | dq 0ddddddddcccccccch
|
---|
81 | VBINSTST_GLOBALNAME_EX g_aTrapRecs, hidden
|
---|
82 | VBINSTST_BEGINCODE
|
---|
83 | %endmacro
|
---|
84 |
|
---|
85 | %macro VBINSTST_TRAP_RECS_END 0,
|
---|
86 | section .traprecs
|
---|
87 | VBINSTST_GLOBALNAME_EX g_aTrapRecsEnd, hidden
|
---|
88 | dq 0ddddddddcccccccch
|
---|
89 | dq 0ffffffffeeeeeeeeh
|
---|
90 | VBINSTST_BEGINCODE
|
---|
91 | %endmacro
|
---|
92 |
|
---|
93 | %macro VBINSTST_TRAP_RECS_INSTALL 0,
|
---|
94 | mov sAX, VBINSTST_NAME(g_aTrapRecs)
|
---|
95 | mov edx, VBINSTST_NAME(g_aTrapRecsEnd) - VBINSTST_NAME(g_aTrapRecs)
|
---|
96 | shr edx, BS2TRAPREC_SIZE_SHIFT
|
---|
97 | mov sCX, VBINSTST_IMAGE_BASE_LABLE
|
---|
98 | VBINSTST_CALL_TEST_INSTALL_TRAP_RECS
|
---|
99 | %endmacro
|
---|
100 |
|
---|
101 | %macro VBINSTST_TRAP_RECS_UNINSTALL 0,
|
---|
102 | xor sAX, sAX
|
---|
103 | xor edx, edx
|
---|
104 | xor sCX, sCX
|
---|
105 | VBINSTST_CALL_TEST_INSTALL_TRAP_RECS
|
---|
106 | %endmacro
|
---|
107 |
|
---|
108 |
|
---|
109 | ;
|
---|
110 | ; Include the common bits (contains code using above macros)
|
---|
111 | ;
|
---|
112 | %include "env-common.mac"
|
---|
113 |
|
---|
114 | %endif
|
---|
115 |
|
---|