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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
# $Id: Makefile.kmk $
## @file
# Sub-Makefile for the VMM testcases.
#
#
# Copyright (C) 2006-2007 Sun Microsystems, Inc.
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 USA or visit http://www.sun.com if you need
# additional information or have any questions.
#
SUB_DEPTH = ../../../..
include $(KBUILD_PATH)/subheader.kmk
#
# Target lists.
#
PROGRAMS += tstVMStructSize tstVMStructGC tstAsmStructs tstAsmStructsGC tstVMM tstVMM-HwAccm tstGlobalConfig tstInstrEmul
ifneq ($(KBUILD_TARGET),win)
PROGRAMS += tstVMMFork
endif
ifdef VBOX_WITH_TESTCASES
PROGRAMS += tstCFGM tstSSM tstMMHyperHeap tstVMM-2 tstVMREQ tstMicro tstCompiler tstVMMR0CallHost-1
ifneq ($(KBUILD_TARGET),l4)
PROGRAMS += tstAnimate
endif
SYSMODS += tstMicroGC
endif # VBOX_WITH_TESTCASES
ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
PROGRAMS += tstPDMAsyncCompletion
endif
# Where we put our temporary files (just for simplicity)
VBOX_VMM_TESTCASE_OUT_DIR := $(PATH_TARGET)/VMM
BLDDIRS += $(VBOX_VMM_TESTCASE_OUT_DIR)
#
# We setup two 'other' targets for executing the two structure & alignment
# validation testcases. Perhaps a bit hackish, but extremely useful.
#
ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
ifeq ($(filter-out x86.x86 amd64.amd64 x86.amd64, $(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH)),)
OTHERS += \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructs.run \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructSize.run \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstInstrEmul.run
endif
endif
# The normal testing pass.
TESTING += \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructs.run \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructSize.run \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstInstrEmul.run
OTHER_CLEAN += \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructs.run \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructSize.run \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstInstrEmul.run \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructs.h \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.o \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.mac \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.mac.o \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.mac.lst \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructs.h.dump \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsGC.h \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsHC.h \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructGC.h
#
# Globals
#
VBOX_PATH_VMM_SRC = $(PATH_ROOT)/src/VBox/VMM
#
# Targets
#
tstVMStructGC_TEMPLATE = VBOXGCEXE
tstVMStructGC_DEFS = IN_VMM_RC IN_DIS IN_RT_RC IN_RT_GC
ifdef VBOX_WITH_R0_LOGGING
tstVMStructGC_DEFS += VBOX_WITH_R0_LOGGING
endif
ifdef VBOX_WITH_NEW_RECOMPILER
tstVMStructGC_DEFS += VBOX_WITH_NEW_RECOMPILER
endif
tstVMStructGC_SOURCES = tstVMStructGC.cpp
tstVMStructGC_INCS = $(VBOX_PATH_VMM_SRC) $(VBOX_PATH_VMM_SRC)/PATM
tstVMStructSize_TEMPLATE= VBOXR3AUTOTST
tstVMStructSize_DEFS = IN_VMM_R3 IN_DIS
tstVMStructSize_INCS = $(VBOX_PATH_VMM_SRC) $(VBOX_PATH_VMM_SRC)/PATM $(VBOX_VMM_TESTCASE_OUT_DIR)
tstVMStructSize_SOURCES = tstVMStructSize.cpp
tstVMStructSize.cpp_DEPS= $(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructGC.h
ifdef VBOX_WITH_R0_LOGGING
tstVMStructSize_DEFS += VBOX_WITH_R0_LOGGING
endif
ifdef VBOX_WITH_NEW_RECOMPILER
tstVMStructSize_DEFS += VBOX_WITH_NEW_RECOMPILER
endif
ifdef VBOX_WITH_VMI
tstVMStructSize_DEFS += VBOX_WITH_VMI
tstVMStructSize_INCS += $(VBOX_PATH_VMM_SRC)/PARAV
endif
tstAsmStructs_TEMPLATE = VBOXR3AUTOTST
tstAsmStructs_DEFS = IN_VMM_R3 IN_DIS
ifdef VBOX_WITH_R0_LOGGING
tstAsmStructs_DEFS += VBOX_WITH_R0_LOGGING
endif
ifdef VBOX_WITH_NEW_RECOMPILER
tstAsmStruct_DEFS += VBOX_WITH_NEW_RECOMPILER
endif
tstAsmStructs_INCS = $(VBOX_PATH_VMM_SRC) $(VBOX_VMM_TESTCASE_OUT_DIR)
tstAsmStructs_SOURCES = tstAsmStructs.cpp
tstAsmStructsGC_TEMPLATE= VBOXGCEXE
tstAsmStructsGC_DEFS = IN_VMM_RC IN_DIS IN_RT_RC IN_RT_GC
ifdef VBOX_WITH_R0_LOGGING
tstAsmStructsGC_DEFS += VBOX_WITH_R0_LOGGING
endif
ifdef VBOX_WITH_NEW_RECOMPILER
tstAsmStructGC_DEFS += VBOX_WITH_NEW_RECOMPILER
endif
tstAsmStructsGC_INCS = $(VBOX_PATH_VMM_SRC) $(VBOX_VMM_TESTCASE_OUT_DIR)
tstAsmStructsGC_SOURCES = tstAsmStructs.cpp
tstAsmStructs.cpp_DEPS = $(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsHC.h $(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsGC.h
tstGlobalConfig_TEMPLATE= VBOXR3TSTEXE
tstGlobalConfig_SOURCES = tstGlobalConfig.cpp
tstGlobalConfig_LIBS = $(LIB_RUNTIME)
tstMMHyperHeap_TEMPLATE = VBOXR3TSTEXE
tstMMHyperHeap_SOURCES = tstMMHyperHeap.cpp
tstMMHyperHeap_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstSSM_TEMPLATE = VBOXR3TSTEXE
tstSSM_SOURCES = tstSSM.cpp
tstSSM_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstInstrEmul_TEMPLATE = VBOXR3TSTEXE
tstInstrEmul_SOURCES = tstInstrEmul.cpp ../VMMAll/EMAllA.asm
tstInstrEmul_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstCFGM_TEMPLATE = VBOXR3TSTEXE
tstCFGM_SOURCES = tstCFGM.cpp
tstCFGM_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMM_TEMPLATE = VBOXR3EXE
tstVMM_SOURCES = tstVMM.cpp
tstVMM_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMM-HwAccm_TEMPLATE = VBOXR3EXE
tstVMM-HwAccm_SOURCES = tstVMM-HwAccm.cpp
tstVMM-HwAccm_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMMFork_TEMPLATE = VBOXR3EXE
tstVMMFork_SOURCES = tstVMMFork.cpp
tstVMMFork_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMM-2_TEMPLATE = VBOXR3EXE
tstVMM-2_SOURCES = tstVMM-2.cpp
tstVMM-2_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMMR0CallHost-1_TEMPLATE = VBOXR3EXE
tstVMMR0CallHost-1_INCS = $(VBOX_PATH_VMM_SRC)
tstVMMR0CallHost-1_SOURCES = \
tstVMMR0CallHost-1.cpp \
$(VBOX_PATH_VMM_SRC)/VMMR0/VMMR0A.asm
tstVMMR0CallHost-1_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstVMREQ_TEMPLATE = VBOXR3EXE
tstVMREQ_SOURCES = tstVMREQ.cpp
tstVMREQ_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstAnimate_TEMPLATE = VBOXR3EXE
tstAnimate_SOURCES = tstAnimate.cpp
tstAnimate_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstCompiler_TEMPLATE = VBOXR3TSTEXE
tstCompiler_SOURCES = tstCompiler.cpp
tstCompiler_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
tstMicro_TEMPLATE = VBOXR3EXE
tstMicro_SOURCES = tstMicro.cpp
tstMicro_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
# tstMicroGC.gc
tstMicroGC_TEMPLATE = VBOXGC
tstMicroGC_SOURCES = tstMicroGC.cpp tstMicroGCA.asm
tstMicroGC_DEFS =
tstMicroGC_INCS = $(VBOX_PATH_VMM_SRC)/testcase
ifeq ($(VBOX_LDR_FMT32),pe)
tstMicroGC_LDFLAGS = -Entry:tstMicroGC
endif
tstMicroGC_SYSSUFF = .gc
tstMicroGC_LIBS = \
$(PATH_LIB)/DisasmGC$(VBOX_SUFF_LIB) \
$(PATH_LIB)/RuntimeGC$(VBOX_SUFF_LIB)
ifeq ($(filter-out pe lx,$(VBOX_LDR_FMT32)),)
tstMicroGC_LIBS += \
$(PATH_LIB)/VMMGCBuiltin$(VBOX_SUFF_LIB) \
$(LIB_VMMGC)
endif
tstMicroGC_SOURCES.win = tstMicroGC.def
ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
tstPDMAsyncCompletion_TEMPLATE = VBOXR3EXE
tstPDMAsyncCompletion_SOURCES = tstPDMAsyncCompletion.cpp
tstPDMAsyncCompletion_LIBS = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
endif
include $(KBUILD_PATH)/subfooter.kmk
#
# Some handcrafted support targets for tstAsmStructs.
#
ifeq ($(KBUILD_HOST),win)
ifndef TOOL_MINGW32
include $(KBUILD_PATH)/tools/MINGW32.kmk
endif
VBOX_NM ?= $(PATH_TOOL_MINGW32)/bin/nm.exe -p
else
VBOX_NM ?= nm -p
endif
MY_ASA_ASM_STUFF = \
$(addprefix -D, \
$(DEFS) \
$(DEFS.$(KBUILD_TYPE)) \
$(DEFS.$(KBUILD_TARGET)) \
IN_RING3 $(ARCH_BITS_DEFS) \
$(DEFS.$(KBUILD_TARGET_ARCH)) \
$(DEFS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) \
) \
-f $(if $(eq $(KBUILD_TARGET),darwin),macho,elf) \
$(foreach inc,$(INCS) $(VBOX_PATH_VMM_SRC)/testcase $(VBOX_VMM_TESTCASE_OUT_DIR),-I$(inc)/)
# 1a. make a header file which makes all the structures+members globals.
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.mac: \
$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm.asm \
$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm-lst.sed \
$(DEPTH)/include/iprt/asmdefs.mac \
$(DEPTH)/include/VBox/cpum.mac \
$(DEPTH)/include/VBox/sup.mac \
$(DEPTH)/include/VBox/vm.mac \
$(VBOX_PATH_VMM_SRC)/CPUMInternal.mac \
$(VBOX_PATH_VMM_SRC)/TRPMInternal.mac \
$(VBOX_PATH_VMM_SRC)/HWACCMInternal.mac \
$(VBOX_PATH_VMM_SRC)/VMMInternal.mac \
$(VBOX_PATH_VMM_SRC)/testcase/Makefile.kmk \
$(PATH_ROOT)/Config.kmk $(LOCALCFG) $(AUTOCFG) \
| $$(dir $$@)
$(call MSG_GENERATE,tstVMStructSize,$@,$<)
ifndef DONT_USE_YASM
$(QUIET)$(TOOL_YASM_AS) $(MY_ASA_ASM_STUFF) -o $@.o -l $@.lst $<
$(SED) -f $(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm-lst.sed --output $@ $@.lst
else
$(QUIET)$(TOOL_NASM_AS) -g $(MY_ASA_ASM_STUFF) -o $@.o -l $@.lst $<
$(VBOX_NM) $@.o | $(SED) \
-e '/[0-9a-fA-F][0-9a-fA-F]* [^a] /d' \
-e 's/[0-9a-fA-F][0-9a-fA-F]* a \([^ ]*\)/global \1/' \
> $@
endif
# 1b. make an elf/macho object containing the offsets.
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.o: \
$(VBOX_PATH_VMM_SRC)/testcase/tstAsmStructsAsm.asm \
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.mac \
$(VBOX_PATH_VMM_SRC)/testcase/Makefile.kmk \
| $$(dir $$@)
$(call MSG_COMPILE,tstAsmStructsasm,$<,$@,AS)
ifndef DONT_USE_YASM
$(QUIET)$(TOOL_YASM_AS) $(MY_ASA_ASM_STUFF) -DDO_GLOBALS -o $@ $<
else
$(QUIET)$(TOOL_NASM_AS) $(MY_ASA_ASM_STUFF) -DDO_GLOBALS -o $@ $<
endif
# 2. use nm and sed to transform this into the header we want.
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsHC.h: $(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsAsm.o
$(call MSG_GENERATE,tstVMStructSize,$@,$<)
$(QUIET)$(RM) -f $@ $@.dump $@.tmp
$(QUIET)$(REDIRECT) -wo $@.dump -- $(VBOX_NM) $<
$(QUIET)$(SED) -e '/STAMPROFILEADV/d' \
-e '/00[0-9a-fA-F]* [aA] [^_.]*\./!d' -e 's/\(00[0-9a-fA-F]*\) [aA] \([^.]*\)\.\(.*$$\)/ CHECK_OFF(\2, 0x0\1, \3);/' \
--output $@.tmp $@.dump
$(QUIET)$(SED) -e '/VM_size$$/d' -e '/VMCPU_size$$/d' \
-e '/00[0-9a-fA-F]* [aA] [^_.]*_size$$/!d' -e 's/\(00[0-9a-fA-F]*\) [aA] \([^_.]*\)_size/ CHECK_SIZE(\2, 0x0\1);/' \
--append $@.tmp $@.dump
$(QUIET)$(MV) -f $@.tmp $@
$(QUIET)$(RM) -f $@.dump
# 3. transform the HC header into a GC one by omitting some HC only structures.
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsGC.h: $(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructsHC.h
$(call MSG_GENERATE,tstVMStructSize,$@,$<)
$(QUIET)$(SED) -e '/VMMSWITCHERDEF/d' --output $@ $^
## @todo make this default kBuild behaviour.
.SECONDEXPANSION:
# 4. run it.
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructs.run: $$(INSTARGET_tstAsmStructs) $$(INSTARGET_tstAsmStructsGC)
$(QUIET)$(RM) -f $@
$(INSTARGET_tstAsmStructs)
$(INSTARGET_tstAsmStructsGC)
$(QUIET)$(APPEND) "$@" "done"
#
# Run rule for tstVMStructSize.
#
# 1. Manually dump selected structures and members.
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructGC.h: $$(INSTARGET_tstVMStructGC) | $$(dir $$@)
$(call MSG_GENERATE,tstVMStructSize,$@)
$(QUIET)$(REDIRECT) -wo $@ -- $<
# 2. run it.
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructSize.run: $$(INSTARGET_tstVMStructSize) | $$(dir $$@)
$(QUIET)$(RM) -f $@
$<
$(QUIET)$(APPEND) "$@" "done"
# alias for the two struct tests.
run-struct-tests: $(VBOX_VMM_TESTCASE_OUT_DIR)/tstAsmStructs.run $(VBOX_VMM_TESTCASE_OUT_DIR)/tstVMStructSize.run
#
# Run rule for tstInstrEmul.
#
$(VBOX_VMM_TESTCASE_OUT_DIR)/tstInstrEmul.run: $$(INSTARGET_tstInstrEmul) | $$(dir $$@)
$(QUIET)$(RM) -f $@
$(QUIET)$(REDIRECT) -E 'VBOX_LOG_FLAGS=disabled' -E 'VBOX_LOG_DEST=nofile' \
$(if $(eq $(KBUILD_TARGET),darwin), -E 'DYLD_FALLBACK_LIBRARY_PATH=$(dir $(LIB_RUNTIME))') \
-- \
$(INSTARGET_tstInstrEmul)
$(QUIET)$(APPEND) "$@" "done"
|