1 | ; $Id: VMMRC.mac 54763 2015-03-15 03:15:58Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VMMGC - Raw-mode Context Assembly Macros.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2012 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 __VMMGC_mac__
|
---|
19 | %define __VMMGC_mac__
|
---|
20 |
|
---|
21 | %include "VBox/asmdefs.mac"
|
---|
22 |
|
---|
23 |
|
---|
24 | ;; @def VMMR0_SEG
|
---|
25 | ; Set the output segment to one of the special VMMR0 segments.
|
---|
26 | ; @param %1 The segment name.
|
---|
27 | ; @remark Use BEGINCODE to switch back to the code segment.
|
---|
28 |
|
---|
29 | ;; @def VMMR0_SEG_CODE
|
---|
30 | ; Set the output segment to one of the special VMMR0 code segments.
|
---|
31 | ; @param %1 The segment name.
|
---|
32 | %ifdef ASM_FORMAT_OMF
|
---|
33 | %macro VMMR0_SEG 1
|
---|
34 | segment VMMR0.%1 public CLASS=CONST align=1 use32 flat
|
---|
35 | %endmacro
|
---|
36 |
|
---|
37 | %macro VMMR0_CODE_SEG 1
|
---|
38 | segment VMMR0.%1 public CLASS=CODE align=16 use32 flat
|
---|
39 | %endmacro
|
---|
40 | %endif
|
---|
41 |
|
---|
42 | %ifdef ASM_FORMAT_ELF
|
---|
43 | %macro VMMR0_SEG 1
|
---|
44 | %ifndef DEFINED_VMMR0_SEG.%1
|
---|
45 | %define DEFINED_VMMR0_SEG.%1 1
|
---|
46 | [section .VMMR0.%1 progbits alloc noexec nowrite align=1 ]
|
---|
47 | %else
|
---|
48 | [section .VMMR0.%1 ]
|
---|
49 | %endif
|
---|
50 | %endmacro
|
---|
51 |
|
---|
52 | %macro VMMR0_CODE_SEG 1
|
---|
53 | %ifndef DEFINED_VMMR0_CODE_SEG.%1
|
---|
54 | %define DEFINED_VMMR0_CODE_SEG.%1 1
|
---|
55 | [section .VMMR0.%1 progbits alloc exec nowrite align=16 ]
|
---|
56 | %else
|
---|
57 | [section .VMMR0.%1 ]
|
---|
58 | %endif
|
---|
59 | %endmacro
|
---|
60 | %endif
|
---|
61 |
|
---|
62 | %ifdef ASM_FORMAT_MACHO
|
---|
63 | %ifdef __YASM__
|
---|
64 | %macro VMMR0_SEG 1
|
---|
65 | %ifndef DEFINED_VMMR0_SEG.%1
|
---|
66 | %define DEFINED_VMMR0_SEG.%1 1
|
---|
67 | [section VMMR0 %1 align=1 ]
|
---|
68 | %else
|
---|
69 | [section VMMR0 %1 ]
|
---|
70 | %endif
|
---|
71 | %endmacro
|
---|
72 | %else
|
---|
73 | %macro VMMR0_SEG 1
|
---|
74 | [section VMMR0.%1 rdata align=1 ]
|
---|
75 | %endmacro
|
---|
76 | %endif
|
---|
77 |
|
---|
78 | %ifdef __YASM__
|
---|
79 | %macro VMMR0_CODE_SEG 1
|
---|
80 | %ifndef DEFINED_VMMR0_CODE_SEG.%1
|
---|
81 | %define DEFINED_VMMR0_CODE_SEG.%1 1
|
---|
82 | [section VMMR0 %1 exec align=16 ]
|
---|
83 | %else
|
---|
84 | [section VMMR0 %1 ]
|
---|
85 | %endif
|
---|
86 | %endmacro
|
---|
87 | %else
|
---|
88 | %macro VMMR0_CODE_SEG 1
|
---|
89 | [section VMMR0.%1 exec align=16 ]
|
---|
90 | %endmacro
|
---|
91 | %endif
|
---|
92 | %endif
|
---|
93 |
|
---|
94 | %ifdef ASM_FORMAT_PE
|
---|
95 | %macro VMMR0_SEG 1
|
---|
96 | [section .rdata$VMMR0.%1 align=1 ]
|
---|
97 | %endmacro
|
---|
98 |
|
---|
99 | %macro VMMR0_CODE_SEG 1
|
---|
100 | [section .text$VMMR0.%1 align=16 ]
|
---|
101 | %endmacro
|
---|
102 | %endif
|
---|
103 |
|
---|
104 | %ifnmacro VMMR0_SEG
|
---|
105 | %error "VMMR0_CODE_SEG / ASM_FORMAT_xxx"
|
---|
106 | %endif
|
---|
107 | %ifnmacro VMMR0_CODE_SEG
|
---|
108 | %error "VMMR0_CODE_SEG / ASM_FORMAT_xxx"
|
---|
109 | %endif
|
---|
110 |
|
---|
111 |
|
---|
112 | ;; @def TRPM_HANDLER
|
---|
113 | ; Sets up a trap handler.
|
---|
114 | ;
|
---|
115 | ; @param %1 The segment name.
|
---|
116 | ; @param %2 The end address. Use 0 to just handle one instruction.
|
---|
117 | ; @param %3 Address of the handler function.
|
---|
118 | ; @param %4 The user data member.
|
---|
119 | %macro TRPM_HANDLER 4
|
---|
120 |
|
---|
121 | VMMR0_SEG %1 ; switch to the record segment.
|
---|
122 |
|
---|
123 | dd %%current_instr ; uStartEip
|
---|
124 | dd %2 ; uEndEip
|
---|
125 | dd %3 ; pfnHandler
|
---|
126 | dd %4 ; pvUser
|
---|
127 |
|
---|
128 | BEGINCODE ; back to the code segment.
|
---|
129 | %%current_instr:
|
---|
130 |
|
---|
131 | %endmacro
|
---|
132 |
|
---|
133 | ;; @def TRPM_NP_HANDLER
|
---|
134 | ; Sets up a segment not present fault handler for the current (=next) instruction.
|
---|
135 | ;
|
---|
136 | ; @param %1 Address of the handler function.
|
---|
137 | ; @param %2 The user data member.
|
---|
138 | %macro TRPM_NP_HANDLER 2
|
---|
139 | TRPM_HANDLER Trap0b, 0, %1, %2
|
---|
140 | %endmacro
|
---|
141 |
|
---|
142 |
|
---|
143 | ;; @def TRPM_GP_HANDLER
|
---|
144 | ; Sets up a general protection fault handler for the current (=next) instruction.
|
---|
145 | ;
|
---|
146 | ; @param %1 Address of the handler function.
|
---|
147 | ; @param %2 The user data member.
|
---|
148 | %macro TRPM_GP_HANDLER 2
|
---|
149 | TRPM_HANDLER Trap0d, 0, %1, %2
|
---|
150 | %endmacro
|
---|
151 |
|
---|
152 |
|
---|
153 | ;; @def TRPM_PF_HANDLER
|
---|
154 | ; Sets up a page fault handler for the current (=next) instruction.
|
---|
155 | ;
|
---|
156 | ; @param %1 Address of the handler function.
|
---|
157 | ; @param %2 The user data member.
|
---|
158 | %macro TRPM_PF_HANDLER 2
|
---|
159 | TRPM_HANDLER Trap0e, 0, %1, %2
|
---|
160 | %endmacro
|
---|
161 |
|
---|
162 |
|
---|
163 | ;; @def TRPM_NP_GP_HANDLER
|
---|
164 | ; Sets up a segment not present fault and general protection fault handler
|
---|
165 | ; for the current (=next) instruction.
|
---|
166 | ;
|
---|
167 | ; @param %1 Address of the handler function.
|
---|
168 | ; @param %2 The user data member.
|
---|
169 | %macro TRPM_NP_GP_HANDLER 2
|
---|
170 | TRPM_HANDLER Trap0b, 0, %1, %2
|
---|
171 | TRPM_HANDLER Trap0d, 0, %1, %2
|
---|
172 | %endmacro
|
---|
173 |
|
---|
174 |
|
---|
175 |
|
---|
176 | ;; @def PATCH_HLP_SEG
|
---|
177 | ; Set the output segment a special code segment for patch helpers (runs in ring-1 or ring-2).
|
---|
178 | ; @param %1 The segment name.
|
---|
179 | ; @remark Use BEGINCODE to switch back to the code segment.
|
---|
180 | %macro BEGIN_PATCH_HLP_SEG 0
|
---|
181 | VMMR0_CODE_SEG PatchHlp
|
---|
182 | %endmacro
|
---|
183 |
|
---|
184 | %endif
|
---|