summaryrefslogtreecommitdiffstats
path: root/src/VBox/VMM/testcase/Instructions/env-bs2-r0-common.mac
blob: 7cd299f8122b74b6c7deb85e0b5645bcd4e04b43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
; $Id: env-bs2-r0-common.mac $
;; @file
; Instruction Test Environment - Boot Sector Type 2, Ring-0.
;

;
; Copyright (C) 2006-2023 Oracle and/or its affiliates.
;
; This file is part of VirtualBox base platform packages, as
; available from https://www.virtualbox.org.
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation, in version 3 of the
; License.
;
; This program is distributed in the hope that it will be useful, but
; WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
; General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, see <https://www.gnu.org/licenses>.
;
; SPDX-License-Identifier: GPL-3.0-only
;

%ifndef ___env_bs2_r0_common_mac
%define ___env_bs2_r0_common_mac


;; Same as BEGINPROC in asmdefs.mac.
%macro VBINSTST_BEGINPROC 1
VBINSTST_GLOBALNAME_EX %1, function hidden
%endm

;; Same as ENDPROC in asmdefs.mac.
%macro VBINSTST_ENDPROC 1,
VBINSTST_GLOBALNAME_EX %1 %+ _EndProc, function hidden
%endm

;; Same as NAME in asmdefs.mac.
%define VBINSTST_NAME(a_Name)   TMPL_NM(a_Name)

;; Same as GLOBALNAME_EX in asmdefs.mac.
%macro VBINSTST_GLOBALNAME_EX 2,
VBINSTST_NAME(%1):
%endmacro

;; Same as BEGINCODE in asmdefs.mac.
%macro VBINSTST_BEGINCODE 0,
BEGINCODE
%endmacro

;; Same as BEGINDATA in asmdefs.mac.
%macro VBINSTST_BEGINDATA 0,
BEGINDATA
%endmacro


;
; Trap related macros.
;
%define VBINSTST_CAN_DO_TRAPS 1

%macro VBINSTST_TRAP_INSTR 3+,
        section .traprecs
    istruc BS2TRAPREC
        at BS2TRAPREC.offWhere,           dd (%%trapinstr - VBINSTST_IMAGE_BASE_LABLE)
        at BS2TRAPREC.offResumeAddend,    db (%%resume - %%trapinstr)
        at BS2TRAPREC.u8TrapNo,           db %1
        at BS2TRAPREC.u16ErrCd,           dw %2
    iend
        VBINSTST_BEGINCODE
 %if %1 != X86_XCPT_BP
  %%trapinstr:
        %3
 %else
        %3
  %%trapinstr:
 %endif
        call    VBINSTST_NAME(Common_MissingTrap_ %+ %1)
 %%resume:
%endmacro

%macro VBINSTST_TRAP_RECS_BEGIN 0,
        VBINSTST_BEGINDATA
        section .traprecs progbits valign=8 vfollows=.data align=8 follows=.data
        dq 0ffffffffeeeeeeeeh
        dq 0ddddddddcccccccch
VBINSTST_GLOBALNAME_EX g_aTrapRecs, hidden
        VBINSTST_BEGINCODE
%endmacro

%macro VBINSTST_TRAP_RECS_END 0,
        section .traprecs
VBINSTST_GLOBALNAME_EX g_aTrapRecsEnd, hidden
        dq 0ddddddddcccccccch
        dq 0ffffffffeeeeeeeeh
        VBINSTST_BEGINCODE
%endmacro

%macro VBINSTST_TRAP_RECS_INSTALL 0,
        mov     sAX, VBINSTST_NAME(g_aTrapRecs)
        mov     edx, VBINSTST_NAME(g_aTrapRecsEnd) - VBINSTST_NAME(g_aTrapRecs)
        shr     edx, BS2TRAPREC_SIZE_SHIFT
        mov     sCX, VBINSTST_IMAGE_BASE_LABLE
        VBINSTST_CALL_TEST_INSTALL_TRAP_RECS
%endmacro

%macro VBINSTST_TRAP_RECS_UNINSTALL 0,
        xor     sAX, sAX
        xor     edx, edx
        xor     sCX, sCX
        VBINSTST_CALL_TEST_INSTALL_TRAP_RECS
%endmacro


;
; Include the common bits (contains code using above macros)
;
%include "env-common.mac"

%endif