1 | ; $Id: VMMGC.mac 19 2007-01-15 13:07:05Z 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 | %macro VMMR0_SEG 1
|
---|
48 | [section VMMR0.%1 rdata align=1 ]
|
---|
49 | %endmacro
|
---|
50 | %define VMMR0_SEG_DEFINED
|
---|
51 | %endif
|
---|
52 |
|
---|
53 | %ifdef ASM_FORMAT_PE
|
---|
54 | %macro VMMR0_SEG 1
|
---|
55 | [section .VMMR0.%1 rdata align=1 ]
|
---|
56 | %endmacro
|
---|
57 | %define VMMR0_SEG_DEFINED
|
---|
58 | %endif
|
---|
59 |
|
---|
60 | %ifndef VMMR0_SEG_DEFINED
|
---|
61 | %error "VMMR0_SEG / ASM_FORMAT_xxx"
|
---|
62 | %endif
|
---|
63 |
|
---|
64 |
|
---|
65 | ;; @def TRPM_HANDLER
|
---|
66 | ; Sets up a trap handler.
|
---|
67 | ;
|
---|
68 | ; @param %1 The segment name.
|
---|
69 | ; @param %2 The end address. Use 0 to just handle one instruction.
|
---|
70 | ; @param %3 Address of the handler function.
|
---|
71 | ; @param %4 The user data member.
|
---|
72 | %macro TRPM_HANDLER 4
|
---|
73 |
|
---|
74 | VMMR0_SEG %1 ; switch to the record segemnt.
|
---|
75 |
|
---|
76 | dd %%current_instr ; uStartEip
|
---|
77 | dd %2 ; uEndEip
|
---|
78 | dd %3 ; pfnHandler
|
---|
79 | dd %4 ; pvUser
|
---|
80 |
|
---|
81 | BEGINCODE ; back to the code segment.
|
---|
82 | %%current_instr:
|
---|
83 |
|
---|
84 | %endmacro
|
---|
85 |
|
---|
86 | ;; @def TRPM_NP_HANDLER
|
---|
87 | ; Sets up a segment not present fault handler for the current (=next) instruction.
|
---|
88 | ;
|
---|
89 | ; @param %1 Address of the handler function.
|
---|
90 | ; @param %2 The user data member.
|
---|
91 | %macro TRPM_NP_HANDLER 2
|
---|
92 | TRPM_HANDLER Trap0b, 0, %1, %2
|
---|
93 | %endmacro
|
---|
94 |
|
---|
95 |
|
---|
96 | ;; @def TRPM_GP_HANDLER
|
---|
97 | ; Sets up a general protection fault handler for the current (=next) instruction.
|
---|
98 | ;
|
---|
99 | ; @param %1 Address of the handler function.
|
---|
100 | ; @param %2 The user data member.
|
---|
101 | %macro TRPM_GP_HANDLER 2
|
---|
102 | TRPM_HANDLER Trap0d, 0, %1, %2
|
---|
103 | %endmacro
|
---|
104 |
|
---|
105 |
|
---|
106 | ;; @def TRPM_PF_HANDLER
|
---|
107 | ; Sets up a page fault handler for the current (=next) instruction.
|
---|
108 | ;
|
---|
109 | ; @param %1 Address of the handler function.
|
---|
110 | ; @param %2 The user data member.
|
---|
111 | %macro TRPM_PF_HANDLER 2
|
---|
112 | TRPM_HANDLER Trap0e, 0, %1, %2
|
---|
113 | %endmacro
|
---|
114 |
|
---|
115 |
|
---|
116 | ;; @def TRPM_NP_GP_HANDLER
|
---|
117 | ; Sets up a segment not present fault and genernal protection fault handler
|
---|
118 | ; for the current (=next) instruction.
|
---|
119 | ;
|
---|
120 | ; @param %1 Address of the handler function.
|
---|
121 | ; @param %2 The user data member.
|
---|
122 | %macro TRPM_NP_GP_HANDLER 2
|
---|
123 | TRPM_HANDLER Trap0b, 0, %1, %2
|
---|
124 | TRPM_HANDLER Trap0d, 0, %1, %2
|
---|
125 | %endmacro
|
---|
126 |
|
---|
127 |
|
---|
128 | %endif
|
---|