|
From: <sv...@va...> - 2006-10-03 20:08:55
|
Author: sewardj
Date: 2006-10-03 21:08:50 +0100 (Tue, 03 Oct 2006)
New Revision: 6151
Log:
AIX5 support.
Modified:
branches/AIX5/coregrind/m_debuglog.c
Modified: branches/AIX5/coregrind/m_debuglog.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_debuglog.c 2006-10-03 20:05:40 UTC (rev 615=
0)
+++ branches/AIX5/coregrind/m_debuglog.c 2006-10-03 20:08:50 UTC (rev 615=
1)
@@ -47,6 +47,7 @@
stage1 and stage2. */
=20
#include "pub_core_basics.h" /* basic types */
+#include "pub_core_vkiscnums.h" /* for syscall numbers */
#include "pub_core_debuglog.h" /* our own iface */
#include "valgrind.h" /* for RUNNING_ON_VALGRIND */
=20
@@ -226,6 +227,174 @@
return (UInt)__res;
}
=20
+#elif defined(VGP_ppc32_aix5)
+
+static UInt local_sys_write_stderr ( HChar* buf, Int n )
+{
+ /* For some reason gcc-3.3.2 doesn't preserve r31 across the asm
+ even though we state it to be trashed. So use r27 instead. */
+ UInt block[3];
+ block[0] =3D (UInt)buf;
+ block[1] =3D n;
+ block[2] =3D __NR_write;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "lwz 2,8(28)\n\t" /* set %r2 =3D __NR_write */
+ "li 3,2\n\t" /* set %r3 =3D stderr */
+ "lwz 4,0(28)\n\t" /* set %r4 =3D buf */
+ "lwz 5,4(28)\n\t" /* set %r5 =3D n */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* write() */
+
+ "stw 3,0(28)\n\t" /* result */
+ "stw 4,4(28)\n\t" /* error? */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ if (block[1] !=3D 0)
+ return -1;
+ else
+ return block[0];
+}
+
+static UInt local_sys_getpid ( void )
+{
+ /* For some reason gcc-3.3.2 doesn't preserve r31 across the asm
+ even though we state it to be trashed. So use r27 instead. */
+ UInt block[1];
+ block[0] =3D __NR_getpid;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "lwz 2,0(28)\n\t" /* set %r2 =3D __NR_getpid */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* getpid() */
+
+ "stw 3,0(28)\n\t" /* result -> block[0] */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ return block[0];
+}
+
+#undef __NR_getpid
+#undef __NR_write
+
+#elif defined(VGP_ppc64_aix5)
+
+static UInt local_sys_write_stderr ( HChar* buf, Int n )
+{
+ ULong block[3];
+ block[0] =3D (ULong)buf;
+ block[1] =3D n;
+ block[2] =3D (ULong)__NR_write;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "ld 2,16(28)\n\t" /* set %r2 =3D __NR_write */
+ "li 3,2\n\t" /* set %r3 =3D stderr */
+ "ld 4,0(28)\n\t" /* set %r4 =3D buf */
+ "ld 5,8(28)\n\t" /* set %r5 =3D n */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* write() */
+
+ "std 3,0(28)\n\t" /* result */
+ "std 4,8(28)\n\t" /* error? */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ if (block[1] !=3D 0)
+ return (UInt)-1;
+ else
+ return (UInt)block[0];
+}
+
+static UInt local_sys_getpid ( void )
+{
+ ULong block[1];
+ block[0] =3D __NR_getpid;
+ __asm__ __volatile__ (
+ "mr 28,%0\n\t" /* establish base ptr */
+ "mr 27,2\n\t" /* save r2 in r27 */
+ "mflr 30\n\t" /* save lr in r30 */
+
+ "ld 2,0(28)\n\t" /* set %r2 =3D __NR_getpid */
+
+ ".long 0x48000005\n\t" /* bl .+4 */
+ "mflr 29\n\t"
+ "addi 29,29,16\n\t"
+ "mtlr 29\n\t"
+ "sc\n\t" /* getpid() */
+
+ "std 3,0(28)\n\t" /* result -> block[0] */
+
+ "mr 2,27\n\t" /* restore r2 */
+ "mtlr 30" /* restore lr */
+
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/
+ /*temps*/ "r31","r30","r29","r28","r27",
+ /*args*/ "r3","r4","r5","r6","r7","r8","r9","r10",
+ /*paranoia*/ "memory","cc","r0","r1","r11","r12","r13",
+ "xer","ctr","cr0","cr1","cr2","cr3",
+ "cr4","cr5","cr6","cr7"
+ );
+ return (UInt)block[0];
+}
+
+#undef __NR_getpid
+#undef __NR_write
+
#else
# error Unknown platform
#endif
|