Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Commit 741dc13

Browse files
author
Bhanu Chetlapalli
committed
[MIPS] Add Goldfish target support
Basic Goldfish support for MIPS. Also, Fix host CPU consumption when guest is idle When the CPU is in wait state, do not wake-up if an interrupt can't be taken. This avoid host CPU running at 100% if a device (e.g. timer) has an interrupt line left enabled. Also factorize code to check if interrupts are enabled in cpu_mips_hw_interrupts_pending(). CPU consumption based on a patch from Edgar E. Iglesias <[email protected]> Change-Id: Ie8371c8d0c9af1e0c8ba4cac419979350de0f5d9 Signed-off-by: yajin <[email protected]> Signed-off-by: Douglas Leung <[email protected]> Signed-off-by: Bhanu Chetlapalli <[email protected]> Signed-off-by: Chris Dearman <[email protected]>
1 parent cf9ba9a commit 741dc13

File tree

12 files changed

+445
-22
lines changed

12 files changed

+445
-22
lines changed

Makefile.android

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
ifneq (,$(filter $(TARGET_ARCH),arm x86))
1+
ifneq (,$(filter $(TARGET_ARCH),arm x86 mips))
22
LOCAL_PATH:= $(call my-dir)
33

44
# determine the target cpu
55
ifeq ($(TARGET_ARCH),arm)
66
EMULATOR_TARGET_CPU := target-arm
7-
else
7+
endif
8+
ifeq ($(TARGET_ARCH),x86)
89
EMULATOR_TARGET_CPU := target-i386
910
endif
11+
ifeq ($(TARGET_ARCH),mips)
12+
EMULATOR_TARGET_CPU := target-mips
13+
endif
1014

1115
# determine the host tag to use
1216
QEMU_HOST_TAG := $(HOST_PREBUILT_TAG)
@@ -253,6 +257,9 @@ include $(LOCAL_PATH)/Makefile.target
253257
EMULATOR_TARGET_ARCH := x86
254258
include $(LOCAL_PATH)/Makefile.target
255259

260+
EMULATOR_TARGET_ARCH := mips
261+
include $(LOCAL_PATH)/Makefile.target
262+
256263
##############################################################################
257264
##############################################################################
258265
###
@@ -316,4 +323,4 @@ $(call end-emulator-program)
316323

317324
## VOILA!!
318325

319-
endif # TARGET_ARCH == arm || TARGET_ARCH == x86
326+
endif # TARGET_ARCH == arm || TARGET_ARCH == x86 || TARGET_ARCH == mips

Makefile.target

+47-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is included several times to build target-specific
22
# modules for the Android emulator. It will be called several times
3-
# (e.g. once for the arm target, and once for the x86 target).
3+
# for arm, x86 and mips
44
#
55

66
ifndef EMULATOR_TARGET_ARCH
@@ -26,7 +26,7 @@ EMULATOR_TARGET_CFLAGS := \
2626
-I$(LOCAL_PATH)/android/config/target-$(EMULATOR_TARGET_ARCH) \
2727
-I$(LOCAL_PATH)/target-$(EMULATOR_TARGET_CPU) \
2828
-I$(LOCAL_PATH)/fpu \
29-
-DNEED_CPU_H \
29+
-DNEED_CPU_H
3030

3131
TCG_TARGET := $(HOST_ARCH)
3232
ifeq ($(HOST_ARCH),x86)
@@ -96,7 +96,7 @@ HW_SOURCES += android_arm.c \
9696
goldfish_switch.c \
9797
goldfish_timer.c \
9898
goldfish_trace.c \
99-
arm_boot.c \
99+
arm_boot.c
100100

101101
# The following sources must be compiled with the final executables
102102
# because they contain device_init() or machine_init() statements.
@@ -135,6 +135,31 @@ HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS)
135135

136136
endif
137137

138+
ifeq ($(EMULATOR_TARGET_ARCH),mips)
139+
HW_SOURCES += \
140+
android_mips.c \
141+
mips_pic.c \
142+
goldfish_interrupt.c \
143+
goldfish_switch.c \
144+
goldfish_timer.c \
145+
goldfish_trace.c \
146+
mips_timer.c \
147+
mips_int.c
148+
149+
# The following sources must be compiled with the final executables
150+
# because they contain device_init() or machine_init() statements.
151+
HW_OBJ_SOURCES := hw/smc91c111.c
152+
HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS)
153+
154+
common_LOCAL_SRC_FILES += mips-dis.c
155+
156+
# smc91c111.c requires <zlib.h>
157+
LOCAL_CFLAGS += $(ZLIB_CFLAGS)
158+
ifeq ($(ARCH_HAS_BIGENDIAN),true)
159+
LOCAL_CFLAGS += -DTARGET_WORDS_BIGENDIAN
160+
endif
161+
162+
endif
138163
common_LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
139164

140165
common_LOCAL_SRC_FILES += \
@@ -143,7 +168,7 @@ common_LOCAL_SRC_FILES += \
143168
translate-all.c \
144169
trace.c \
145170
varint.c \
146-
softmmu_outside_jit.c \
171+
softmmu_outside_jit.c
147172

148173
##############################################################################
149174
# CPU-specific emulation.
@@ -165,7 +190,7 @@ common_LOCAL_SRC_FILES += \
165190
target-arm/machine.c \
166191
hw/armv7m.c \
167192
hw/armv7m_nvic.c \
168-
arm-semi.c \
193+
arm-semi.c
169194

170195
common_LOCAL_SRC_FILES += fpu/softfloat.c
171196
endif
@@ -192,6 +217,16 @@ endif
192217
common_LOCAL_SRC_FILES += fpu/softfloat-native.c
193218
endif
194219

220+
ifeq ($(EMULATOR_TARGET_ARCH), mips)
221+
common_LOCAL_SRC_FILES += \
222+
target-mips/op_helper.c \
223+
target-mips/helper.c \
224+
target-mips/translate.c \
225+
target-mips/machine.c
226+
227+
common_LOCAL_SRC_FILES += fpu/softfloat.c
228+
endif
229+
195230
# compile KVM only if target is x86 on x86 Linux
196231
QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH)
197232
QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false)
@@ -220,7 +255,7 @@ MCHK_SOURCES := \
220255
memcheck_proc_management.c \
221256
memcheck_malloc_map.c \
222257
memcheck_mmrange_map.c \
223-
memcheck_util.c \
258+
memcheck_util.c
224259

225260
common_LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
226261

@@ -272,7 +307,7 @@ LOCAL_CFLAGS += \
272307
$(ELFF_CFLAGS) \
273308
$(EMULATOR_LIBQEMU_CFLAGS) \
274309
$(EMULATOR_TARGET_CFLAGS) \
275-
-DCONFIG_STANDALONE_CORE \
310+
-DCONFIG_STANDALONE_CORE
276311

277312
ifneq ($(QEMU_OPENGLES_INCLUDE),)
278313
LOCAL_CFLAGS += -I$(QEMU_OPENGLES_INCLUDE)
@@ -284,13 +319,12 @@ LOCAL_STATIC_LIBRARIES := \
284319
emulator-libqemu \
285320
emulator-target-$(EMULATOR_TARGET_CPU) \
286321
emulator-libelff \
287-
emulator-common \
288-
322+
emulator-common
289323

290324
LOCAL_LDLIBS += \
291325
$(EMULATOR_COMMON_LDLIBS) \
292326
$(EMULATOR_LIBQEMU_LDLIBS) \
293-
$(ELFF_LDLIBS) \
327+
$(ELFF_LDLIBS)
294328

295329
LOCAL_SRC_FILES := \
296330
audio/audio.c \
@@ -312,7 +346,7 @@ LOCAL_SRC_FILES := \
312346
android/protocol/user-events-impl.c \
313347
android/protocol/ui-commands-proxy.c \
314348
android/protocol/core-commands-impl.c \
315-
android/protocol/core-commands-qemu.c \
349+
android/protocol/core-commands-qemu.c
316350

317351
$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c)
318352
$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
@@ -360,13 +394,13 @@ common_LOCAL_STATIC_LIBRARIES := \
360394
emulator-libqemu \
361395
emulator-target-$(EMULATOR_TARGET_CPU) \
362396
emulator-libelff \
363-
emulator-common \
397+
emulator-common
364398

365399
common_LOCAL_LDLIBS += \
366400
$(EMULATOR_COMMON_LDLIBS) \
367401
$(EMULATOR_LIBQEMU_LDLIBS) \
368402
$(EMULATOR_LIBUI_LDLIBS) \
369-
$(ELFF_LDLIBS) \
403+
$(ELFF_LDLIBS)
370404

371405
common_LOCAL_CFLAGS += \
372406
$(EMULATOR_TARGET_CFLAGS) \

android-configure.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ OPTION_IGNORE_AUDIO=no
2222
OPTION_NO_PREBUILTS=no
2323
OPTION_TRY_64=no
2424
OPTION_HELP=no
25-
OPTION_DEBUG=no
2625
OPTION_STATIC=no
2726
OPTION_MINGW=no
2827

@@ -60,8 +59,6 @@ for opt do
6059
;;
6160
--no-strip) OPTION_NO_STRIP=yes
6261
;;
63-
--debug) OPTION_DEBUG=yes
64-
;;
6562
--ignore-audio) OPTION_IGNORE_AUDIO=yes
6663
;;
6764
--no-prebuilts) OPTION_NO_PREBUILTS=yes
@@ -541,6 +538,10 @@ if [ $TARGET_ARCH = x86 ] ; then
541538
echo "TARGET_ARCH := x86" >> $config_mk
542539
fi
543540

541+
if [ $TARGET_ARCH = mips ] ; then
542+
echo "TARGET_ARCH := mips" >> $config_mk
543+
fi
544+
544545
echo "HOST_PREBUILT_TAG := $TARGET_OS" >> $config_mk
545546
echo "HOST_EXEEXT := $TARGET_EXEEXT" >> $config_mk
546547
echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk

android/avd/util.c

+2
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ path_getBuildTargetArch( const char* androidOut )
254254
result = "arm";
255255
else if (!strcmp("armeabi-v7a", cpuAbi))
256256
result = "arm";
257+
else if (!strncmp("mips", cpuAbi, 4))
258+
result = "mips";
257259
else
258260
result = cpuAbi;
259261

android/config/target-mips/config.h

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* MIPS-specific configuration */
2+
#include "android/config/config.h"
3+
4+
#define TARGET_MIPS 1
5+
#define CONFIG_SOFTFLOAT 1

android/main.c

+3
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ int main(int argc, char **argv)
407407
#elif defined(TARGET_I386)
408408
free(android_hw->hw_cpu_arch);
409409
android_hw->hw_cpu_arch = ASTRDUP("x86");
410+
#elif defined(TARGET_MIPS)
411+
free(android_hw->hw_cpu_arch);
412+
android_hw->hw_cpu_arch = ASTRDUP("mips");
410413
#endif
411414
}
412415

0 commit comments

Comments
 (0)