Commit b29fe3ed48c72e6a30a29c7fbdf3b841c59551c5

Authored by malc
1 parent 14f87098

Preliminary AIX support

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5732 c046a42c-6fe2-441c-8c8c-71466251a162
Makefile.target
@@ -763,10 +763,12 @@ endif @@ -763,10 +763,12 @@ endif
763 ifndef CONFIG_DARWIN 763 ifndef CONFIG_DARWIN
764 ifndef CONFIG_WIN32 764 ifndef CONFIG_WIN32
765 ifndef CONFIG_SOLARIS 765 ifndef CONFIG_SOLARIS
  766 +ifndef CONFIG_AIX
766 LIBS+=-lutil 767 LIBS+=-lutil
767 endif 768 endif
768 endif 769 endif
769 endif 770 endif
  771 +endif
770 ifdef TARGET_GPROF 772 ifdef TARGET_GPROF
771 vl.o: CFLAGS+=-p 773 vl.o: CFLAGS+=-p
772 LDFLAGS+=-p 774 LDFLAGS+=-p
configure
@@ -32,7 +32,7 @@ ar="ar" @@ -32,7 +32,7 @@ ar="ar"
32 make="make" 32 make="make"
33 install="install" 33 install="install"
34 strip="strip" 34 strip="strip"
35 -cpu=`uname -m` 35 +cpu=`test $(uname -s) = AIX && uname -p || uname -m`
36 target_list="" 36 target_list=""
37 case "$cpu" in 37 case "$cpu" in
38 i386|i486|i586|i686|i86pc|BePC) 38 i386|i486|i586|i686|i86pc|BePC)
@@ -68,7 +68,7 @@ case "$cpu" in @@ -68,7 +68,7 @@ case "$cpu" in
68 mips64) 68 mips64)
69 cpu="mips64" 69 cpu="mips64"
70 ;; 70 ;;
71 - "Power Macintosh"|ppc|ppc64) 71 + "Power Macintosh"|ppc|ppc64|powerpc)
72 cpu="powerpc" 72 cpu="powerpc"
73 ;; 73 ;;
74 s390*) 74 s390*)
@@ -117,6 +117,7 @@ mixemu="no" @@ -117,6 +117,7 @@ mixemu="no"
117 bluez="yes" 117 bluez="yes"
118 kvm="yes" 118 kvm="yes"
119 kerneldir="" 119 kerneldir=""
  120 +aix="no"
120 121
121 # OS specific 122 # OS specific
122 targetos=`uname -s` 123 targetos=`uname -s`
@@ -206,6 +207,10 @@ SunOS) @@ -206,6 +207,10 @@ SunOS)
206 fi 207 fi
207 audio_possible_drivers="oss sdl" 208 audio_possible_drivers="oss sdl"
208 ;; 209 ;;
  210 +AIX)
  211 +aix="yes"
  212 +make="gmake"
  213 +;;
209 *) 214 *)
210 audio_drv_list="oss" 215 audio_drv_list="oss"
211 audio_possible_drivers="oss alsa sdl esd pa" 216 audio_possible_drivers="oss alsa sdl esd pa"
@@ -1220,6 +1225,12 @@ if test "$darwin" = "yes" ; then @@ -1220,6 +1225,12 @@ if test "$darwin" = "yes" ; then
1220 echo "CONFIG_DARWIN=yes" >> $config_mak 1225 echo "CONFIG_DARWIN=yes" >> $config_mak
1221 echo "#define CONFIG_DARWIN 1" >> $config_h 1226 echo "#define CONFIG_DARWIN 1" >> $config_h
1222 fi 1227 fi
  1228 +
  1229 +if test "$aix" = "yes" ; then
  1230 + echo "CONFIG_AIX=yes" >> $config_mak
  1231 + echo "#define CONFIG_AIX 1" >> $config_h
  1232 +fi
  1233 +
1223 if test "$solaris" = "yes" ; then 1234 if test "$solaris" = "yes" ; then
1224 echo "CONFIG_SOLARIS=yes" >> $config_mak 1235 echo "CONFIG_SOLARIS=yes" >> $config_mak
1225 echo "#define HOST_SOLARIS $solarisrev" >> $config_h 1236 echo "#define HOST_SOLARIS $solarisrev" >> $config_h
fpu/softfloat.h
@@ -50,8 +50,10 @@ these four paragraphs for those parts of this code that are retained. @@ -50,8 +50,10 @@ these four paragraphs for those parts of this code that are retained.
50 typedef uint8_t flag; 50 typedef uint8_t flag;
51 typedef uint8_t uint8; 51 typedef uint8_t uint8;
52 typedef int8_t int8; 52 typedef int8_t int8;
  53 +#ifndef _AIX
53 typedef int uint16; 54 typedef int uint16;
54 typedef int int16; 55 typedef int int16;
  56 +#endif
55 typedef unsigned int uint32; 57 typedef unsigned int uint32;
56 typedef signed int int32; 58 typedef signed int int32;
57 typedef uint64_t uint64; 59 typedef uint64_t uint64;
@@ -780,6 +780,12 @@ static int tap_open(char *ifname, int ifname_size) @@ -780,6 +780,12 @@ static int tap_open(char *ifname, int ifname_size)
780 fcntl(fd, F_SETFL, O_NONBLOCK); 780 fcntl(fd, F_SETFL, O_NONBLOCK);
781 return fd; 781 return fd;
782 } 782 }
  783 +#elif defined (_AIX)
  784 +static int tap_open(char *ifname, int ifname_size)
  785 +{
  786 + fprintf (stderr, "no tap on AIX\n");
  787 + return -1;
  788 +}
783 #else 789 #else
784 static int tap_open(char *ifname, int ifname_size) 790 static int tap_open(char *ifname, int ifname_size)
785 { 791 {
@@ -1441,6 +1447,7 @@ int net_client_init(const char *device, const char *p) @@ -1441,6 +1447,7 @@ int net_client_init(const char *device, const char *p)
1441 vlan->nb_host_devs++; 1447 vlan->nb_host_devs++;
1442 ret = tap_win32_init(vlan, ifname); 1448 ret = tap_win32_init(vlan, ifname);
1443 } else 1449 } else
  1450 +#elif defined (_AIX)
1444 #else 1451 #else
1445 if (!strcmp(device, "tap")) { 1452 if (!strcmp(device, "tap")) {
1446 char ifname[64]; 1453 char ifname[64];
tcg/ppc/tcg-target.c
@@ -27,6 +27,9 @@ static uint8_t *tb_ret_addr; @@ -27,6 +27,9 @@ static uint8_t *tb_ret_addr;
27 #ifdef __APPLE__ 27 #ifdef __APPLE__
28 #define LINKAGE_AREA_SIZE 24 28 #define LINKAGE_AREA_SIZE 24
29 #define LR_OFFSET 8 29 #define LR_OFFSET 8
  30 +#elif defined _AIX
  31 +#define LINKAGE_AREA_SIZE 52
  32 +#define LR_OFFSET 8
30 #else 33 #else
31 #define LINKAGE_AREA_SIZE 8 34 #define LINKAGE_AREA_SIZE 8
32 #define LR_OFFSET 4 35 #define LR_OFFSET 4
@@ -137,6 +140,9 @@ static const int tcg_target_callee_save_regs[] = { @@ -137,6 +140,9 @@ static const int tcg_target_callee_save_regs[] = {
137 TCG_REG_R11, 140 TCG_REG_R11,
138 TCG_REG_R13, 141 TCG_REG_R13,
139 #endif 142 #endif
  143 +#ifdef _AIX
  144 + TCG_REG_R13,
  145 +#endif
140 TCG_REG_R14, 146 TCG_REG_R14,
141 TCG_REG_R15, 147 TCG_REG_R15,
142 TCG_REG_R16, 148 TCG_REG_R16,
@@ -455,6 +461,24 @@ static void tcg_out_b (TCGContext *s, int mask, tcg_target_long target) @@ -455,6 +461,24 @@ static void tcg_out_b (TCGContext *s, int mask, tcg_target_long target)
455 } 461 }
456 } 462 }
457 463
  464 +#ifdef _AIX
  465 +static void tcg_out_call (TCGContext *s, tcg_target_long arg, int const_arg)
  466 +{
  467 + int reg;
  468 +
  469 + if (const_arg) {
  470 + reg = 2;
  471 + tcg_out_movi (s, TCG_TYPE_I32, reg, arg);
  472 + }
  473 + else reg = arg;
  474 +
  475 + tcg_out32 (s, LWZ | RT (0) | RA (reg));
  476 + tcg_out32 (s, MTSPR | RA (0) | CTR);
  477 + tcg_out32 (s, LWZ | RT (2) | RA (reg) | 4);
  478 + tcg_out32 (s, BCCTR | BO_ALWAYS | LK);
  479 +}
  480 +#endif
  481 +
458 #if defined(CONFIG_SOFTMMU) 482 #if defined(CONFIG_SOFTMMU)
459 483
460 #include "../../softmmu_defs.h" 484 #include "../../softmmu_defs.h"
@@ -548,7 +572,11 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc) @@ -548,7 +572,11 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)
548 tcg_out_movi (s, TCG_TYPE_I32, 5, mem_index); 572 tcg_out_movi (s, TCG_TYPE_I32, 5, mem_index);
549 #endif 573 #endif
550 574
  575 +#ifdef _AIX
  576 + tcg_out_call (s, (tcg_target_long) qemu_ld_helpers[s_bits], 1);
  577 +#else
551 tcg_out_b (s, LK, (tcg_target_long) qemu_ld_helpers[s_bits]); 578 tcg_out_b (s, LK, (tcg_target_long) qemu_ld_helpers[s_bits]);
  579 +#endif
552 switch (opc) { 580 switch (opc) {
553 case 0|4: 581 case 0|4:
554 tcg_out32 (s, EXTSB | RA (data_reg) | RS (3)); 582 tcg_out32 (s, EXTSB | RA (data_reg) | RS (3));
@@ -766,7 +794,11 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc) @@ -766,7 +794,11 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
766 ir++; 794 ir++;
767 795
768 tcg_out_movi (s, TCG_TYPE_I32, ir, mem_index); 796 tcg_out_movi (s, TCG_TYPE_I32, ir, mem_index);
  797 +#ifdef _AIX
  798 + tcg_out_call (s, (tcg_target_long) qemu_st_helpers[opc], 1);
  799 +#else
769 tcg_out_b (s, LK, (tcg_target_long) qemu_st_helpers[opc]); 800 tcg_out_b (s, LK, (tcg_target_long) qemu_st_helpers[opc]);
  801 +#endif
770 label2_ptr = s->code_ptr; 802 label2_ptr = s->code_ptr;
771 tcg_out32 (s, B); 803 tcg_out32 (s, B);
772 804
@@ -836,6 +868,16 @@ void tcg_target_qemu_prologue (TCGContext *s) @@ -836,6 +868,16 @@ void tcg_target_qemu_prologue (TCGContext *s)
836 ; 868 ;
837 frame_size = (frame_size + 15) & ~15; 869 frame_size = (frame_size + 15) & ~15;
838 870
  871 +#ifdef _AIX
  872 + {
  873 + uint32_t addr;
  874 +
  875 + /* First emit adhoc function descriptor */
  876 + addr = (uint32_t) s->code_ptr + 12;
  877 + tcg_out32 (s, addr); /* entry point */
  878 + s->code_ptr += 8; /* skip TOC and environment pointer */
  879 + }
  880 +#endif
839 tcg_out32 (s, MFSPR | RT (0) | LR); 881 tcg_out32 (s, MFSPR | RT (0) | LR);
840 tcg_out32 (s, STWU | RS (1) | RA (1) | (-frame_size & 0xffff)); 882 tcg_out32 (s, STWU | RS (1) | RA (1) | (-frame_size & 0xffff));
841 for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) 883 for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i)
@@ -1106,6 +1148,9 @@ static void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -1106,6 +1148,9 @@ static void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
1106 } 1148 }
1107 break; 1149 break;
1108 case INDEX_op_call: 1150 case INDEX_op_call:
  1151 +#ifdef _AIX
  1152 + tcg_out_call (s, args[0], const_args[0]);
  1153 +#else
1109 if (const_args[0]) { 1154 if (const_args[0]) {
1110 tcg_out_b (s, LK, args[0]); 1155 tcg_out_b (s, LK, args[0]);
1111 } 1156 }
@@ -1113,6 +1158,7 @@ static void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -1113,6 +1158,7 @@ static void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
1113 tcg_out32 (s, MTSPR | RS (args[0]) | LR); 1158 tcg_out32 (s, MTSPR | RS (args[0]) | LR);
1114 tcg_out32 (s, BCLR | BO_ALWAYS | LK); 1159 tcg_out32 (s, BCLR | BO_ALWAYS | LK);
1115 } 1160 }
  1161 +#endif
1116 break; 1162 break;
1117 case INDEX_op_jmp: 1163 case INDEX_op_jmp:
1118 if (const_args[0]) { 1164 if (const_args[0]) {
tcg/ppc/tcg-target.h
@@ -65,11 +65,15 @@ enum { @@ -65,11 +65,15 @@ enum {
65 /* used for function call generation */ 65 /* used for function call generation */
66 #define TCG_REG_CALL_STACK TCG_REG_R1 66 #define TCG_REG_CALL_STACK TCG_REG_R1
67 #define TCG_TARGET_STACK_ALIGN 16 67 #define TCG_TARGET_STACK_ALIGN 16
68 -#ifdef __APPLE__ 68 +#if defined __APPLE__
69 #define TCG_TARGET_CALL_STACK_OFFSET 24 69 #define TCG_TARGET_CALL_STACK_OFFSET 24
70 -#else 70 +#elif defined _AIX
  71 +#define TCG_TARGET_CALL_STACK_OFFSET 52
  72 +#elif defined __linux__
71 #define TCG_TARGET_CALL_ALIGN_ARGS 1 73 #define TCG_TARGET_CALL_ALIGN_ARGS 1
72 #define TCG_TARGET_CALL_STACK_OFFSET 8 74 #define TCG_TARGET_CALL_STACK_OFFSET 8
  75 +#else
  76 +#error Unsupported system
73 #endif 77 #endif
74 78
75 /* optional instructions */ 79 /* optional instructions */
tcg/tcg.c
@@ -37,6 +37,9 @@ @@ -37,6 +37,9 @@
37 #ifdef _WIN32 37 #ifdef _WIN32
38 #include <malloc.h> 38 #include <malloc.h>
39 #endif 39 #endif
  40 +#ifdef _AIX
  41 +#include <alloca.h>
  42 +#endif
40 43
41 #include "config.h" 44 #include "config.h"
42 #include "qemu-common.h" 45 #include "qemu-common.h"