summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Crocker <bcrocker@redhat.com>2018-11-07 16:22:58 -0500
committerDave Airlie <airlied@redhat.com>2018-11-27 05:41:47 +1000
commit0a672473f583c6e4df3b1714d4af79653910811e (patch)
treed4790f586b9084d7a12c2a8f9d5dd0a86f64bff5
parent6069e97c33181f4b452b3ca3f9b9b5f79dc67ffe (diff)
Make it work on ppc64le: add conditionals, fix implicitly big-endian ASM code.HEADmaster
Signed-off-by: Ben Crocker <bcrocker@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--avivotool.c25
-rw-r--r--radeonreg.c23
-rw-r--r--radeontool.c25
3 files changed, 65 insertions, 8 deletions
diff --git a/avivotool.c b/avivotool.c
index 658fdf3..fd673c6 100644
--- a/avivotool.c
+++ b/avivotool.c
@@ -35,6 +35,14 @@
#include "radeon_reg.h"
#include "xf86i2c.h"
+#ifdef __powerpc__
+#ifdef _LITTLE_ENDIAN
+#define ppc64le
+#else
+#define ppcBE
+#endif
+#endif
+
struct atom_context *atom_init(void *bios);
void atom_dump(struct atom_context *ctx);
@@ -75,6 +83,17 @@ static void die_error(int err, const char *why)
exit(-1);
}
+#ifdef ppc64le
+#define LOADX "lwzx"
+#define STOREX "stwx"
+#elif defined(ppcBE)
+#define LOADX "lwbrx"
+#define STOREX "stwbrx"
+#else
+#define LOADX
+#define STOREX
+#endif
+
static void radeon_set(unsigned long offset, const char *name, unsigned int value)
{
if (debug)
@@ -84,7 +103,7 @@ static void radeon_set(unsigned long offset, const char *name, unsigned int valu
die("internal error");
#ifdef __powerpc__
- __asm__ __volatile__ ("stwbrx %1,%2,%3\n\t"
+ __asm__ __volatile__ (STOREX " %1,%2,%3\n\t"
"eieio"
: "=m" (*((volatile unsigned int *)ctrl_mem+offset))
: "r"(value), "b"(ctrl_mem), "r"(offset));
@@ -112,7 +131,7 @@ static unsigned int radeon_get(unsigned long offset, const char *name)
die("internal error");
#ifdef __powerpc__
- __asm__ __volatile__ ("lwbrx %0,%1,%2\n\t"
+ __asm__ __volatile__ (LOADX " %0,%1,%2\n\t"
"eieio"
: "=r" (value)
: "b" (ctrl_mem), "r"(offset),
@@ -1934,7 +1953,7 @@ static int map_radeon_mem(void)
return 0;
}
-#ifdef __powerpc__
+#ifdef ppcBE
#define __swab16(x) \
({ \
unsigned short __x = (x); \
diff --git a/radeonreg.c b/radeonreg.c
index 7ebce54..1aa706c 100644
--- a/radeonreg.c
+++ b/radeonreg.c
@@ -34,6 +34,14 @@
#include "radeon.h"
#include "radeon_reg.h"
+#ifdef __powerpc__
+#ifdef _LITTLE_ENDIAN
+#define ppc64le
+#else
+#define ppcBE
+#endif
+#endif
+
int skip;
/* *ctrl_mem is mapped to the actual device's memory mapped control area. */
@@ -57,6 +65,17 @@ static void die_error(int err, const char *why)
exit(-1);
}
+#ifdef ppc64le
+#define LOADX "lwzx"
+#define STOREX "stwx"
+#elif defined(ppcBE)
+#define LOADX "lwbrx"
+#define STOREX "stwbrx"
+#else
+#define LOADX
+#define STOREX
+#endif
+
static void radeon_set(unsigned long offset, const char *name, unsigned int value)
{
@@ -64,7 +83,7 @@ static void radeon_set(unsigned long offset, const char *name, unsigned int valu
die("internal error");
#ifdef __powerpc__
- __asm__ __volatile__ ("stwbrx %1,%2,%3\n\t"
+ __asm__ __volatile__ (STOREX " %1,%2,%3\n\t"
"eieio"
: "=m" (*((volatile unsigned int *)ctrl_mem+offset))
: "r"(value), "b"(ctrl_mem), "r"(offset));
@@ -89,7 +108,7 @@ static unsigned int radeon_get(unsigned long offset, const char *name)
die("internal error");
#ifdef __powerpc__
- __asm__ __volatile__ ("lwbrx %0,%1,%2\n\t"
+ __asm__ __volatile__ (LOADX " %0,%1,%2\n\t"
"eieio"
: "=r" (value)
: "b" (ctrl_mem), "r"(offset),
diff --git a/radeontool.c b/radeontool.c
index 024028d..0fc4b63 100644
--- a/radeontool.c
+++ b/radeontool.c
@@ -27,6 +27,14 @@
#include "radeon_reg.h"
+#ifdef __powerpc__
+#ifdef _LITTLE_ENDIAN
+#define ppc64le
+#else
+#define ppcBE
+#endif
+#endif
+
int debug = 0;
int skip = 0;
@@ -50,6 +58,17 @@ static void die_error(int err, const char *why)
exit(-1);
}
+#ifdef ppc64le
+#define LOADX "lwzx"
+#define STOREX "stwx"
+#elif defined(ppcBE)
+#define LOADX "lwbrx"
+#define STOREX "stwbrx"
+#else
+#define LOADX
+#define STOREX
+#endif
+
static unsigned int radeon_get(unsigned long offset, const char *name)
{
unsigned int value;
@@ -57,7 +76,7 @@ static unsigned int radeon_get(unsigned long offset, const char *name)
printf("reading %s (%lx) is ",name,offset);
assert(radeon_cntl_mem);
#ifdef __powerpc__
- __asm__ __volatile__ ("lwbrx %0,%1,%2\n\t"
+ __asm__ __volatile__ (LOADX " %0,%1,%2\n\t"
"eieio"
: "=r" (value)
: "b" (radeon_cntl_mem), "r"(offset),
@@ -75,7 +94,7 @@ static void radeon_set(unsigned long offset, const char *name, unsigned int valu
printf("writing %s (%lx) -> %08x\n",name,offset,value);
assert(radeon_cntl_mem);
#ifdef __powerpc__
- __asm__ __volatile__ ("stwbrx %1,%2,%3\n\t"
+ __asm__ __volatile__ (STOREX " %1,%2,%3\n\t"
"eieio"
: "=m" (*((volatile unsigned int *)radeon_cntl_mem+offset))
: "r"(value), "b"(radeon_cntl_mem), "r"(offset));
@@ -1014,7 +1033,7 @@ static void map_radeon_cntl_mem(void)
radeon_cntl_mem = ctrl_mem;
}
-#ifdef __powerpc__
+#ifdef ppcBE
#define __swab16(x) \
({ \
unsigned short __x = (x); \