1 | ; $Id: VMMGC.mac 1405 2007-03-12 04:17:51Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VMMGC - Guest Context Assembly Macros.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | ; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | ; distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | ; be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; If you received this file as part of a commercial VirtualBox
|
---|
18 | ; distribution, then only the terms of your commercial VirtualBox
|
---|
19 | ; license agreement apply instead of the previous paragraph.
|
---|
20 | ;
|
---|
21 |
|
---|
22 | %ifndef __VMMGC_mac__
|
---|
23 | %define __VMMGC_mac__
|
---|
24 |
|
---|
25 | %include "VBox/asmdefs.mac"
|
---|
26 |
|
---|
27 |
|
---|
28 | ;; @def VMMR0_SEG
|
---|
29 | ; Set the output segment to one of the special VMMR0 segments.
|
---|
30 | ; @param %1 The segment name.
|
---|
31 | ; @remark Use BEGINCODE to switch back to the code segment.
|
---|
32 | %ifdef ASM_FORMAT_OMF
|
---|
33 | %macro VMMR0_SEG 1
|
---|
34 | segment VMMR0.%1 public CLASS=CONST align=1 use32
|
---|
35 | %endmacro
|
---|
36 | %define VMMR0_SEG_DEFINED
|
---|
37 | %endif
|
---|
38 |
|
---|
39 | %ifdef ASM_FORMAT_ELF
|
---|
40 | %macro VMMR0_SEG 1
|
---|
41 | [section .VMMR0.%1 progbits alloc noexec nowrite align=1 ]
|
---|
42 | %endmacro
|
---|
43 | %define VMMR0_SEG_DEFINED
|
---|
44 | %endif
|
---|
45 |
|
---|
46 | %ifdef ASM_FORMAT_MACHO
|
---|
47 | %ifdef __YASM__
|
---|
48 | ; this syntax requires a patch yasm, sorry.
|
---|
49 | %macro VMMR0_SEG 1
|
---|
50 | [section %1 segname VMMR0 align=1 ]
|
---|
51 | %endmacro
|
---|
52 | %else
|
---|
53 | [section VMMR0.%1 rdata align=1 ]
|
---|
54 | %endmacro
|
---|
55 | %endif
|
---|
56 | %define VMMR0_SEG_DEFINED
|
---|
57 | %endif
|
---|
58 |
|
---|
59 | %ifdef ASM_FORMAT_PE
|
---|
60 | %macro VMMR0_SEG 1
|
---|
61 | [section .VMMR0.%1 rdata align=1 ]
|
---|
62 | %endmacro
|
---|
63 | %define VMMR0_SEG_DEFINED
|
---|
64 | %endif
|
---|
65 |
|
---|
66 | %ifndef VMMR0_SEG_DEFINED
|
---|
67 | %error "VMMR0_SEG / ASM_FORMAT_xxx"
|
---|
68 | %endif
|
---|
69 |
|
---|
70 |
|
---|
71 | ;; @def TRPM_HANDLER
|
---|
72 | ; Sets up a trap handler.
|
---|
73 | ;
|
---|
74 | ; @param %1 The segment name.
|
---|
75 | ; @param %2 The end address. Use 0 to just handle one instruction.
|
---|
76 | ; @param %3 Address of the handler function.
|
---|
77 | ; @param %4 The user data member.
|
---|
78 | %macro TRPM_HANDLER 4
|
---|
79 |
|
---|
80 | VMMR0_SEG %1 ; switch to the record segemnt.
|
---|
81 |
|
---|
82 | dd %%current_instr ; uStartEip
|
---|
83 | dd %2 ; uEndEip
|
---|
84 | dd %3 ; pfnHandler
|
---|
85 | dd %4 ; pvUser
|
---|
86 |
|
---|
87 | BEGINCODE ; back to the code segment.
|
---|
88 | %%current_instr:
|
---|
89 |
|
---|
90 | %endmacro
|
---|
91 |
|
---|
92 | ;; @def TRPM_NP_HANDLER
|
---|
93 | ; Sets up a segment not present fault handler for the current (=next) instruction.
|
---|
94 | ;
|
---|
95 | ; @param %1 Address of the handler function.
|
---|
96 | ; @param %2 The user data member.
|
---|
97 | %macro TRPM_NP_HANDLER 2
|
---|
98 | TRPM_HANDLER Trap0b, 0, %1, %2
|
---|
99 | %endmacro
|
---|
100 |
|
---|
101 |
|
---|
102 | ;; @def TRPM_GP_HANDLER
|
---|
103 | ; Sets up a general protection fault handler for the current (=next) instruction.
|
---|
104 | ;
|
---|
105 | ; @param %1 Address of the handler function.
|
---|
106 | ; @param %2 The user data member.
|
---|
107 | %macro TRPM_GP_HANDLER 2
|
---|
108 | TRPM_HANDLER Trap0d, 0, %1, %2
|
---|
109 | %endmacro
|
---|
110 |
|
---|
111 |
|
---|
112 | ;; @def TRPM_PF_HANDLER
|
---|
113 | ; Sets up a page fault handler for the current (=next) instruction.
|
---|
114 | ;
|
---|
115 | ; @param %1 Address of the handler function.
|
---|
116 | ; @param %2 The user data member.
|
---|
117 | %macro TRPM_PF_HANDLER 2
|
---|
118 | TRPM_HANDLER Trap0e, 0, %1, %2
|
---|
119 | %endmacro
|
---|
120 |
|
---|
121 |
|
---|
122 | ;; @def TRPM_NP_GP_HANDLER
|
---|
123 | ; Sets up a segment not present fault and genernal protection fault handler
|
---|
124 | ; for the current (=next) instruction.
|
---|
125 | ;
|
---|
126 | ; @param %1 Address of the handler function.
|
---|
127 | ; @param %2 The user data member.
|
---|
128 | %macro TRPM_NP_GP_HANDLER 2
|
---|
129 | TRPM_HANDLER Trap0b, 0, %1, %2
|
---|
130 | TRPM_HANDLER Trap0d, 0, %1, %2
|
---|
131 | %endmacro
|
---|
132 |
|
---|
133 |
|
---|
134 | %endif
|
---|