Commit de83cd02e0124536e05e6ad1fd5e4dc783156dab

Authored by bellard
1 parent 6380ab5e

arm emulation support


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@246 c046a42c-6fe2-441c-8c8c-71466251a162
Changelog
1 version 0.3: 1 version 0.3:
  2 +
  3 + - initial support for ARM emulation
2 - added fnsave, frstor, fnstenv, fldenv FPU instructions 4 - added fnsave, frstor, fnstenv, fldenv FPU instructions
3 - added FPU register save in signal emulation 5 - added FPU register save in signal emulation
4 - ARM port 6 - ARM port
  7 + - Sparc and Alpha ports work on the regression test
  8 + - generic ioctl number conversion
  9 + - fixed ioctl type conversion
5 10
6 version 0.2: 11 version 0.2:
7 12
Makefile
@@ -86,24 +86,38 @@ LDFLAGS+=-p @@ -86,24 +86,38 @@ LDFLAGS+=-p
86 main.o: CFLAGS+=-p 86 main.o: CFLAGS+=-p
87 endif 87 endif
88 88
89 -OBJS= elfload.o main.o syscall.o mmap.o signal.o vm86.o path.o 89 +OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o
  90 +ifeq ($(TARGET_ARCH), i386)
  91 +OBJS+= vm86.o
  92 +endif
90 SRCS:= $(OBJS:.o=.c) 93 SRCS:= $(OBJS:.o=.c)
91 OBJS+= libqemu.a 94 OBJS+= libqemu.a
92 95
93 -LIBOBJS+=thunk.o translate-i386.o op-i386.o helper-i386.o exec-i386.o exec.o 96 +# cpu emulator library
  97 +LIBOBJS=thunk.o exec.o translate.o cpu-exec.o
  98 +
  99 +ifeq ($(TARGET_ARCH), i386)
  100 +LIBOBJS+=translate-i386.o op-i386.o helper-i386.o
  101 +endif
  102 +ifeq ($(TARGET_ARCH), arm)
  103 +LIBOBJS+=translate-arm.o op-arm.o
  104 +endif
94 105
95 # NOTE: the disassembler code is only needed for debugging 106 # NOTE: the disassembler code is only needed for debugging
96 -LIBOBJS+=disas.o i386-dis.o  
97 -ifeq ($(ARCH),alpha) 107 +LIBOBJS+=disas.o
  108 +ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
  109 +LIBOBJS+=i386-dis.o
  110 +endif
  111 +ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
98 LIBOBJS+=alpha-dis.o 112 LIBOBJS+=alpha-dis.o
99 endif 113 endif
100 -ifeq ($(ARCH),ppc) 114 +ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
101 LIBOBJS+=ppc-dis.o 115 LIBOBJS+=ppc-dis.o
102 endif 116 endif
103 -ifeq ($(ARCH),sparc) 117 +ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
104 LIBOBJS+=sparc-dis.o 118 LIBOBJS+=sparc-dis.o
105 endif 119 endif
106 -ifeq ($(ARCH),arm) 120 +ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
107 LIBOBJS+=arm-dis.o 121 LIBOBJS+=arm-dis.o
108 endif 122 endif
109 123
@@ -133,20 +147,29 @@ libqemu.a: $(LIBOBJS) @@ -133,20 +147,29 @@ libqemu.a: $(LIBOBJS)
133 dyngen: dyngen.c 147 dyngen: dyngen.c
134 $(HOST_CC) -O2 -Wall -g $< -o $@ 148 $(HOST_CC) -O2 -Wall -g $< -o $@
135 149
136 -translate-i386.o: translate-i386.c op-i386.h opc-i386.h cpu-i386.h 150 +translate-$(TARGET_ARCH).o: translate-$(TARGET_ARCH).c gen-op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
  151 +
  152 +translate.o: translate.c op-$(TARGET_ARCH).h opc-$(TARGET_ARCH).h cpu-$(TARGET_ARCH).h
137 153
138 -op-i386.h: op-i386.o dyngen 154 +op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
139 ./dyngen -o $@ $< 155 ./dyngen -o $@ $<
140 156
141 -opc-i386.h: op-i386.o dyngen 157 +opc-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
142 ./dyngen -c -o $@ $< 158 ./dyngen -c -o $@ $<
143 159
144 -op-i386.o: op-i386.c opreg_template.h ops_template.h 160 +gen-op-$(TARGET_ARCH).h: op-$(TARGET_ARCH).o dyngen
  161 + ./dyngen -g -o $@ $<
  162 +
  163 +op-$(TARGET_ARCH).o: op-$(TARGET_ARCH).c
145 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< 164 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
146 165
147 -helper-i386.o: helper-i386.c 166 +helper-$(TARGET_ARCH).o: helper-$(TARGET_ARCH).c
148 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< 167 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
149 168
  169 +op-i386.o: op-i386.c opreg_template.h ops_template.h
  170 +
  171 +op-arm.o: op-arm.c op-arm-template.h
  172 +
150 %.o: %.c 173 %.o: %.c
151 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< 174 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
152 175
@@ -173,17 +196,24 @@ qemu-doc.html: qemu-doc.texi @@ -173,17 +196,24 @@ qemu-doc.html: qemu-doc.texi
173 196
174 FILES= \ 197 FILES= \
175 README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \ 198 README README.distrib COPYING COPYING.LIB TODO Changelog VERSION \
176 -dyngen.c dyngen.h ioctls.h ops_template.h op_string.h syscall_types.h\  
177 -Makefile elf.h thunk.c\  
178 -elfload.c main.c signal.c thunk.h exec.h\  
179 -cpu-i386.h qemu.h op-i386.c helper-i386.c syscall-i386.h translate-i386.c\  
180 -syscall.c opreg_template.h syscall_defs.h vm86.c\  
181 -dis-asm.h disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c sparc-dis.c arm-dis.c\  
182 -ppc.ld alpha.ld s390.ld sparc.ld arm.ld exec-i386.h exec-i386.c path.c exec.c mmap.c configure \  
183 -tests/Makefile\  
184 -tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h\  
185 -tests/test-i386-muldiv.h tests/test-i386-code16.S\  
186 -tests/hello.c tests/hello tests/sha1.c \ 199 +configure \
  200 +dyngen.c dyngen.h dyngen-exec.h ioctls.h syscall_types.h \
  201 +Makefile elf.h elfload.c main.c signal.c qemu.h \
  202 +syscall.c syscall_defs.h vm86.c path.c mmap.c \
  203 +ppc.ld alpha.ld s390.ld sparc.ld arm.ld\
  204 +thunk.c cpu-exec.c translate.c cpu-all.h thunk.h exec.h\
  205 +exec.c cpu-exec.c\
  206 +cpu-i386.h op-i386.c helper-i386.c syscall-i386.h translate-i386.c \
  207 +exec-i386.h ops_template.h op_string.h opreg_template.h \
  208 +cpu-arm.h syscall-arm.h exec-arm.h op-arm.c translate-arm.c op-arm-template.h \
  209 +dis-asm.h disas.c disas.h alpha-dis.c ppc-dis.c i386-dis.c sparc-dis.c \
  210 +arm-dis.c \
  211 +tests/Makefile \
  212 +tests/test-i386.c tests/test-i386-shift.h tests/test-i386.h \
  213 +tests/test-i386-muldiv.h tests/test-i386-code16.S tests/test-i386-vm86.S \
  214 +tests/hello.c tests/hello \
  215 +tests/hello-arm.c tests/hello-arm \
  216 +tests/sha1.c \
187 tests/testsig.c tests/testclone.c tests/testthread.c \ 217 tests/testsig.c tests/testclone.c tests/testthread.c \
188 tests/runcom.c tests/pi_10.com \ 218 tests/runcom.c tests/pi_10.com \
189 tests/test_path.c \ 219 tests/test_path.c \
1 -0.2  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +0.3
3 \ No newline at end of file 3 \ No newline at end of file
configure
@@ -28,6 +28,7 @@ ar=&quot;ar&quot; @@ -28,6 +28,7 @@ ar=&quot;ar&quot;
28 make="make" 28 make="make"
29 strip="strip" 29 strip="strip"
30 target_cpu="x86" 30 target_cpu="x86"
  31 +target_bigendian="default"
31 cpu=`uname -m` 32 cpu=`uname -m`
32 case "$cpu" in 33 case "$cpu" in
33 i386|i486|i586|i686|i86pc|BePC) 34 i386|i486|i586|i686|i86pc|BePC)
@@ -103,6 +104,12 @@ for opt do @@ -103,6 +104,12 @@ for opt do
103 ;; 104 ;;
104 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2` 105 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
105 ;; 106 ;;
  107 + --target-cpu=*) target_cpu=`echo $opt | cut -d '=' -f 2`
  108 + ;;
  109 + --target-big-endian) target_bigendian="yes"
  110 + ;;
  111 + --target-little-endian) target_bigendian="no"
  112 + ;;
106 --enable-gprof) gprof="yes" 113 --enable-gprof) gprof="yes"
107 ;; 114 ;;
108 --static) static="yes" 115 --static) static="yes"
@@ -162,6 +169,16 @@ if $cc -o $TMPO $TMPC 2&gt; /dev/null ; then @@ -162,6 +169,16 @@ if $cc -o $TMPO $TMPC 2&gt; /dev/null ; then
162 gcc_major="3" 169 gcc_major="3"
163 fi 170 fi
164 171
  172 +if test "$target_bigendian" = "default" ; then
  173 + if test "$target_cpu" = "x86" ; then
  174 + target_bigendian="no"
  175 + elif test "$target_cpu" = "arm" ; then
  176 + target_bigendian="no"
  177 + else
  178 + target_bigendian="no"
  179 + fi
  180 +fi
  181 +
165 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then 182 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
166 cat << EOF 183 cat << EOF
167 184
@@ -173,6 +190,7 @@ echo &quot;Standard options:&quot; @@ -173,6 +190,7 @@ echo &quot;Standard options:&quot;
173 echo " --help print this message" 190 echo " --help print this message"
174 echo " --prefix=PREFIX install in PREFIX [$prefix]" 191 echo " --prefix=PREFIX install in PREFIX [$prefix]"
175 echo " --interp-prefix=PREFIX where to find shared libraries, etc. [$interp_prefix]" 192 echo " --interp-prefix=PREFIX where to find shared libraries, etc. [$interp_prefix]"
  193 +echo " --target_cpu=CPU set target cpu (x86 or arm) [$target_cpu]"
176 echo "" 194 echo ""
177 echo "Advanced options (experts only):" 195 echo "Advanced options (experts only):"
178 echo " --source-path=PATH path of source code [$source_path]" 196 echo " --source-path=PATH path of source code [$source_path]"
@@ -191,8 +209,9 @@ echo &quot;ELF interp prefix $interp_prefix&quot; @@ -191,8 +209,9 @@ echo &quot;ELF interp prefix $interp_prefix&quot;
191 echo "C compiler $cc" 209 echo "C compiler $cc"
192 echo "make $make" 210 echo "make $make"
193 echo "host CPU $cpu" 211 echo "host CPU $cpu"
194 -echo "Big Endian $bigendian" 212 +echo "host big endian $bigendian"
195 echo "target CPU $target_cpu" 213 echo "target CPU $target_cpu"
  214 +echo "target big endian $target_bigendian"
196 echo "gprof enabled $gprof" 215 echo "gprof enabled $gprof"
197 echo "static build $static" 216 echo "static build $static"
198 217
@@ -246,6 +265,24 @@ if test &quot;$bigendian&quot; = &quot;yes&quot; ; then @@ -246,6 +265,24 @@ if test &quot;$bigendian&quot; = &quot;yes&quot; ; then
246 echo "WORDS_BIGENDIAN=yes" >> config.mak 265 echo "WORDS_BIGENDIAN=yes" >> config.mak
247 echo "#define WORDS_BIGENDIAN 1" >> $TMPH 266 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
248 fi 267 fi
  268 +
  269 +if test "$target_cpu" = "x86" ; then
  270 + echo "TARGET_ARCH=i386" >> config.mak
  271 + echo "#define TARGET_ARCH \"i386\"" >> $TMPH
  272 + echo "#define TARGET_I386 1" >> $TMPH
  273 +elif test "$target_cpu" = "arm" ; then
  274 + echo "TARGET_ARCH=arm" >> config.mak
  275 + echo "#define TARGET_ARCH \"arm\"" >> $TMPH
  276 + echo "#define TARGET_ARM 1" >> $TMPH
  277 +else
  278 + echo "Unsupported target CPU"
  279 + exit 1
  280 +fi
  281 +if test "$target_bigendian" = "yes" ; then
  282 + echo "TARGET_WORDS_BIGENDIAN=yes" >> config.mak
  283 + echo "#define TARGET_WORDS_BIGENDIAN 1" >> $TMPH
  284 +fi
  285 +
249 if test "$gprof" = "yes" ; then 286 if test "$gprof" = "yes" ; then
250 echo "TARGET_GPROF=yes" >> config.mak 287 echo "TARGET_GPROF=yes" >> config.mak
251 echo "#define HAVE_GPROF 1" >> $TMPH 288 echo "#define HAVE_GPROF 1" >> $TMPH
translate.c
@@ -123,7 +123,7 @@ int cpu_gen_code(TranslationBlock *tb, @@ -123,7 +123,7 @@ int cpu_gen_code(TranslationBlock *tb,
123 123
124 static const unsigned short opc_copy_size[] = { 124 static const unsigned short opc_copy_size[] = {
125 #define DEF(s, n, copy_size) copy_size, 125 #define DEF(s, n, copy_size) copy_size,
126 -#include "opc-i386.h" 126 +#include "opc-" TARGET_ARCH ".h"
127 #undef DEF 127 #undef DEF
128 }; 128 };
129 129