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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# This file is included several times to build target-specific
# modules for the Android emulator. It will be called several times
# (e.g. once for the arm target, and once for the x86 target).
#
ifndef EMULATOR_TARGET_ARCH
$(error EMULATOR_TARGET_ARCH is not defined!)
endif
EMULATOR_TARGET_CPU := $(EMULATOR_TARGET_ARCH)
ifeq ($(EMULATOR_TARGET_CPU),x86)
EMULATOR_TARGET_CPU := i386
endif
##############################################################################
##############################################################################
###
### emulator-target-$CPU: target-specific emulation code.
###
### Used by both the core and standalone programs.
###
# Common compiler flags for all target-dependent libraries
EMULATOR_TARGET_CFLAGS := \
-I$(LOCAL_PATH)/android/config/$(HOST_PREBUILT_TAG) \
-I$(LOCAL_PATH)/android/config/target-$(EMULATOR_TARGET_ARCH) \
-I$(LOCAL_PATH)/target-$(EMULATOR_TARGET_CPU) \
-I$(LOCAL_PATH)/fpu \
-DNEED_CPU_H \
TCG_TARGET := $(HOST_ARCH)
ifeq ($(HOST_ARCH),x86)
TCG_TARGET := i386
endif
ifeq ($(HOST_ARCH),x86_64)
TCG_TARGET := i386
endif
EMULATOR_TARGET_CFLAGS += \
-I$(LOCAL_PATH)/tcg \
-I$(LOCAL_PATH)/tcg/$(TCG_TARGET) \
-DTARGET_ARCH=\"$(EMULATOR_TARGET_ARCH)\"
$(call start-emulator-library, emulator-target-$(EMULATOR_TARGET_CPU))
# The following is to ensure that "config.h" will map to a target-specific
# configuration file header.
LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS)
LOCAL_SRC_FILES += \
tcg/tcg.c \
##############################################################################
# Emulated hardware devices.
#
HW_SOURCES := \
bt.c \
bt-hci.c \
bt-hid.c \
bt-l2cap.c \
bt-sdp.c \
cdrom.c \
dma.c \
irq.c \
goldfish_audio.c \
goldfish_device.c \
goldfish_events_device.c \
goldfish_fb.c \
goldfish_battery.c \
goldfish_mmc.c \
goldfish_memlog.c \
goldfish_nand.c \
goldfish_pipe.c \
goldfish_tty.c \
msmouse.c \
pci.c \
qdev.c \
scsi-disk.c \
sysbus.c \
usb-hid.c \
usb-hub.c \
usb-msd.c \
usb-ohci.c \
usb.c \
watchdog.c
$(call gen-hw-config-defs)
ifeq ($(EMULATOR_TARGET_ARCH),arm)
HW_SOURCES += android_arm.c \
arm_pic.c \
goldfish_interrupt.c \
goldfish_switch.c \
goldfish_timer.c \
goldfish_trace.c \
arm_boot.c \
# The following sources must be compiled with the final executables
# because they contain device_init() or machine_init() statements.
HW_OBJ_SOURCES := hw/smc91c111.c
HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS)
LOCAL_SRC_FILES += arm-dis.c
# smc91c111.c requires <zlib.h>
LOCAL_CFLAGS += $(ZLIB_CFLAGS)
endif
# required to ensure we properly initialize virtual audio hardware
LOCAL_CFLAGS += -DHAS_AUDIO
ifeq ($(EMULATOR_TARGET_ARCH),x86)
HW_SOURCES += \
apic.c \
i8259.c \
mc146818rtc.c \
piix_pci.c \
i8254.c \
pckbd.c \
ioapic.c \
ps2.c \
smbios.c \
fw_cfg.c
# The following sources must be compiled with the final executables
# because they contain device_init() or machine_init() statements.
HW_OBJ_SOURCES := \
hw/ne2000.c \
hw/pc.c
HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS)
endif
LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
LOCAL_SRC_FILES += \
cpu-exec.c \
exec.c \
translate-all.c \
trace.c \
varint.c \
softmmu_outside_jit.c \
##############################################################################
# CPU-specific emulation.
#
LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare
ifeq ($(HOST_ARCH),ppc)
LOCAL_CFLAGS += -D__powerpc__
endif
ifeq ($(EMULATOR_TARGET_ARCH),arm)
LOCAL_SRC_FILES += \
target-arm/op_helper.c \
target-arm/iwmmxt_helper.c \
target-arm/neon_helper.c \
target-arm/helper.c \
target-arm/helper-android.c \
target-arm/translate.c \
target-arm/machine.c \
hw/armv7m.c \
hw/armv7m_nvic.c \
arm-semi.c \
LOCAL_SRC_FILES += fpu/softfloat.c
endif
ifeq ($(EMULATOR_TARGET_ARCH), x86)
LOCAL_SRC_FILES += \
target-i386/op_helper.c \
target-i386/helper.c \
target-i386/translate.c \
target-i386/machine.c \
LOCAL_SRC_FILES += fpu/softfloat-native.c
endif
# compile KVM only if target is x86 on x86 Linux
QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH)
QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false)
ifeq ($(QEMU_DO_KVM),true)
LOCAL_SRC_FILES += \
target-i386/kvm.c \
target-i386/kvm-gs-restore.c \
kvm-all.c \
kvm-android.c
endif
##############################################################################
# Memory-access checking support.
# Memory access checker uses information collected by instrumented code in
# libc.so in order to keep track of memory blocks allocated from heap. Memory
# checker then uses this information to make sure that every access to allocated
# memory is within allocated block. This information also allows detecting
# memory leaks and attempts to free/realloc invalid pointers.
#
LOCAL_CFLAGS += \
-I$(LOCAL_PATH)/memcheck \
-I$(LOCAL_PATH)/elff
MCHK_SOURCES := \
memcheck.c \
memcheck_proc_management.c \
memcheck_malloc_map.c \
memcheck_mmrange_map.c \
memcheck_util.c \
LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
LOCAL_SRC_FILES += \
cpus.c \
arch_init.c
# What a mess, os-posix.c depends on the exact values of options
# which are target specific.
ifeq ($(HOST_OS),windows)
LOCAL_SRC_FILES += os-win32.c oslib-win32.c
else
LOCAL_SRC_FILES += os-posix.c oslib-posix.c
endif
$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c)
$(call end-emulator-library)
##############################################################################
##############################################################################
###
### qemu-android-$CPU: headless emulator core program
###
###
$(call start-emulator-program, qemu-android-$(EMULATOR_TARGET_ARCH))
LOCAL_CFLAGS += \
$(EMULATOR_COMMON_CFLAGS) \
$(ELFF_CFLAGS) \
$(EMULATOR_LIBQEMU_CFLAGS) \
$(EMULATOR_TARGET_CFLAGS) \
-DCONFIG_STANDALONE_CORE \
LOCAL_CFLAGS += -Wno-missing-field-initializers
LOCAL_STATIC_LIBRARIES := \
emulator-libqemu \
emulator-target-$(EMULATOR_TARGET_CPU) \
emulator-libelff \
emulator-common \
LOCAL_LDLIBS += \
$(EMULATOR_COMMON_LDLIBS) \
$(EMULATOR_LIBQEMU_LDLIBS) \
$(ELFF_LDLIBS) \
LOCAL_SRC_FILES := \
audio/audio.c \
disas.c \
dma-helpers.c \
gdbstub.c \
keymaps.c \
loader.c \
monitor.c \
qemu-timer.c \
qemu-timer-common.c \
user-events-qemu.c \
vl-android.c \
android/console.c \
android/display-core.c \
android/protocol/attach-ui-proxy.c \
android/protocol/fb-updates-proxy.c \
android/protocol/user-events-impl.c \
android/protocol/ui-commands-proxy.c \
android/protocol/core-commands-impl.c \
android/protocol/core-commands-qemu.c \
$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c)
$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
$(call gen-hw-config-defs)
ifeq ($(HOST_OS),darwin)
FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
endif
# Generate a completely static executable if needed.
# Note that this means no sound and graphics on Linux.
#
ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
LOCAL_SRC_FILES += dynlink-static.c
LOCAL_LDLIBS += -static
endif
# The following files cannot be in static libraries because they contain
# constructor functions that are otherwise stripped by the final linker
LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
LOCAL_CFLAGS += $(HW_OBJ_CFLAGS)
LOCAL_SRC_FILES += $(BLOCK_SOURCES)
LOCAL_CFLAGS += $(BLOCK_CFLAGS)
LOCAL_MODULE_TAGS := debug
$(call end-emulator-program)
##############################################################################
##############################################################################
###
### emulator-$ARCH: Standalone emulator program
###
###
$(call start-emulator-program, emulator-$(EMULATOR_TARGET_ARCH))
LOCAL_STATIC_LIBRARIES := \
emulator-libui \
emulator-libqemu \
emulator-target-$(EMULATOR_TARGET_CPU) \
emulator-libelff \
emulator-common \
LOCAL_LDLIBS += \
$(EMULATOR_COMMON_LDLIBS) \
$(EMULATOR_LIBQEMU_LDLIBS) \
$(EMULATOR_LIBUI_LDLIBS) \
$(ELFF_LDLIBS) \
LOCAL_CFLAGS += \
$(EMULATOR_TARGET_CFLAGS) \
$(EMULATOR_COMMON_CFLAGS) \
$(EMULATOR_LIBQEMU_CFLAGS) \
$(EMULATOR_LIBUI_CFLAGS)
LOCAL_SRC_FILES := \
audio/audio.c \
disas.c \
dma-helpers.c \
gdbstub.c \
keymaps.c \
loader.c \
monitor.c \
qemu-timer.c \
qemu-timer-common.c \
user-events-qemu.c \
vl-android.c \
android/cmdline-option.c \
android/console.c \
android/display.c \
android/display-core.c \
android/help.c \
android/main-common.c \
android/main.c \
android/protocol/core-commands-qemu.c \
android/protocol/ui-commands-qemu.c \
android/
$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c)
$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
$(call gen-hw-config-defs)
# The following files cannot be in static libraries because they contain
# constructor functions that are otherwise stripped by the final linker
LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
LOCAL_CFLAGS += $(HW_OBJ_CFLAGS)
LOCAL_SRC_FILES += $(BLOCK_SOURCES)
LOCAL_CFLAGS += $(BLOCK_CFLAGS)
LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
# Generate a completely static executable if needed.
# Note that this means no sound and graphics on Linux.
#
ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
LOCAL_SRC_FILES += dynlink-static.c
LOCAL_LDLIBS += -static
endif
LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
$(call end-emulator-program)
|