summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@fairlite.demon.co.uk>2000-07-12 23:35:37 +0000
committerAlan Hourihane <alanh@fairlite.demon.co.uk>2000-07-12 23:35:37 +0000
commit4234dc27e082a24f60cda5b9639fcd409338c2f2 (patch)
treeda68e18a4c2a912033f7b31900fd81b288a35ee2
parent3fdcc554e29fc62e2bc987e044607326324f768f (diff)
First round of AXP patches.
-rw-r--r--linux-core/drmP.h75
-rw-r--r--linux/Makefile.linux8
-rw-r--r--linux/drmP.h75
-rw-r--r--linux/mga_context.c2
-rw-r--r--linux/mga_dma.c12
-rw-r--r--linux/r128_context.c2
-rw-r--r--linux/r128_dma.c20
-rw-r--r--linux/tdfx_context.c2
8 files changed, 191 insertions, 5 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 9ad83bde7..9a2b125cd 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -33,6 +33,12 @@
#define _DRM_P_H_
#ifdef __KERNEL__
+#ifdef __alpha__
+/* add include of current.h so that "current" is defined
+ * before static inline funcs in wait.h. Doing this so we
+ * can build the DRM (part of PI DRI). 4/21/2000 S + B */
+#include <asm/current.h>
+#endif /* __alpha__ */
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -44,6 +50,9 @@
#include <linux/pci.h>
#include <linux/wrapper.h>
#include <linux/version.h>
+#ifdef __alpha__
+#include <asm/pgtable.h> /* For pte_wrprotect */
+#endif
#include <asm/io.h>
#include <asm/mman.h>
#include <asm/uaccess.h>
@@ -133,6 +142,71 @@ typedef struct wait_queue *wait_queue_head_t;
#ifndef __HAVE_ARCH_CMPXCHG
/* Include this here so that driver can be
used with older kernels. */
+#if defined(__alpha__)
+static __inline__ unsigned long
+__cmpxchg_u32(volatile int *m, int old, int new)
+{
+ unsigned long prev, cmp;
+
+ __asm__ __volatile__(
+ "1: ldl_l %0,%2\n"
+ " cmpeq %0,%3,%1\n"
+ " beq %1,2f\n"
+ " mov %4,%1\n"
+ " stl_c %1,%2\n"
+ " beq %1,3f\n"
+ "2: mb\n"
+ ".subsection 2\n"
+ "3: br 1b\n"
+ ".previous"
+ : "=&r"(prev), "=&r"(cmp), "=m"(*m)
+ : "r"((long) old), "r"(new), "m"(*m));
+
+ return prev;
+}
+
+static __inline__ unsigned long
+__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
+{
+ unsigned long prev, cmp;
+
+ __asm__ __volatile__(
+ "1: ldq_l %0,%2\n"
+ " cmpeq %0,%3,%1\n"
+ " beq %1,2f\n"
+ " mov %4,%1\n"
+ " stq_c %1,%2\n"
+ " beq %1,3f\n"
+ "2: mb\n"
+ ".subsection 2\n"
+ "3: br 1b\n"
+ ".previous"
+ : "=&r"(prev), "=&r"(cmp), "=m"(*m)
+ : "r"((long) old), "r"(new), "m"(*m));
+
+ return prev;
+}
+
+static __inline__ unsigned long
+__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
+{
+ switch (size) {
+ case 4:
+ return __cmpxchg_u32(ptr, old, new);
+ case 8:
+ return __cmpxchg_u64(ptr, old, new);
+ }
+ return old;
+}
+#define cmpxchg(ptr,o,n) \
+ ({ \
+ __typeof__(*(ptr)) _o_ = (o); \
+ __typeof__(*(ptr)) _n_ = (n); \
+ (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
+ (unsigned long)_n_, sizeof(*(ptr))); \
+ })
+
+#elif __i386__
static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
unsigned long new, int size)
{
@@ -163,6 +237,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
#define cmpxchg(ptr,o,n) \
((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
(unsigned long)(n),sizeof(*(ptr))))
+#endif /* i386 & alpha */
#endif
/* Macros to make printk easier */
diff --git a/linux/Makefile.linux b/linux/Makefile.linux
index ecc196bdd..f19994828 100644
--- a/linux/Makefile.linux
+++ b/linux/Makefile.linux
@@ -122,6 +122,7 @@ AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'AGP = ' | cut -d' ' -f3)
PARAMS := $(shell if fgrep kill_fasync $(TREE)/linux/fs.h \
| fgrep -q band; then echo 3; else echo 2; fi)
+MACHINE := $(shell echo `uname -m`)
ifeq ($(AGP),0)
AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'AGP_MODULE = ' | cut -d' ' -f3)
@@ -130,7 +131,11 @@ endif
ifeq ($(AGP),1)
MODCFLAGS += -DDRM_AGP
DRMOBJS += agpsupport.o
-MODS += mga.o i810.o
+MODS += mga.o
+ifeq ($(MACHINE),i386)
+MODS += i810.o
+endif
+
MGAOBJS= mga_drv.o mga_dma.o mga_bufs.o mga_state.o mga_context.o
MGAHEADERS= mga_drv.h $(DRMHEADERS)
@@ -142,6 +147,7 @@ endif
all::;@echo === KERNEL HEADERS IN $(TREE)
all::;@echo === SMP=${SMP} MODVERSIONS=${MODVERSIONS} AGP=${AGP}
all::;@echo === kill_fasync has $(PARAMS) parameters
+all::;@echo === Compiling for machine $(MACHINE)
all:: $(LIBS) $(MODS) $(PROGS)
endif
diff --git a/linux/drmP.h b/linux/drmP.h
index 9ad83bde7..9a2b125cd 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -33,6 +33,12 @@
#define _DRM_P_H_
#ifdef __KERNEL__
+#ifdef __alpha__
+/* add include of current.h so that "current" is defined
+ * before static inline funcs in wait.h. Doing this so we
+ * can build the DRM (part of PI DRI). 4/21/2000 S + B */
+#include <asm/current.h>
+#endif /* __alpha__ */
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -44,6 +50,9 @@
#include <linux/pci.h>
#include <linux/wrapper.h>
#include <linux/version.h>
+#ifdef __alpha__
+#include <asm/pgtable.h> /* For pte_wrprotect */
+#endif
#include <asm/io.h>
#include <asm/mman.h>
#include <asm/uaccess.h>
@@ -133,6 +142,71 @@ typedef struct wait_queue *wait_queue_head_t;
#ifndef __HAVE_ARCH_CMPXCHG
/* Include this here so that driver can be
used with older kernels. */
+#if defined(__alpha__)
+static __inline__ unsigned long
+__cmpxchg_u32(volatile int *m, int old, int new)
+{
+ unsigned long prev, cmp;
+
+ __asm__ __volatile__(
+ "1: ldl_l %0,%2\n"
+ " cmpeq %0,%3,%1\n"
+ " beq %1,2f\n"
+ " mov %4,%1\n"
+ " stl_c %1,%2\n"
+ " beq %1,3f\n"
+ "2: mb\n"
+ ".subsection 2\n"
+ "3: br 1b\n"
+ ".previous"
+ : "=&r"(prev), "=&r"(cmp), "=m"(*m)
+ : "r"((long) old), "r"(new), "m"(*m));
+
+ return prev;
+}
+
+static __inline__ unsigned long
+__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
+{
+ unsigned long prev, cmp;
+
+ __asm__ __volatile__(
+ "1: ldq_l %0,%2\n"
+ " cmpeq %0,%3,%1\n"
+ " beq %1,2f\n"
+ " mov %4,%1\n"
+ " stq_c %1,%2\n"
+ " beq %1,3f\n"
+ "2: mb\n"
+ ".subsection 2\n"
+ "3: br 1b\n"
+ ".previous"
+ : "=&r"(prev), "=&r"(cmp), "=m"(*m)
+ : "r"((long) old), "r"(new), "m"(*m));
+
+ return prev;
+}
+
+static __inline__ unsigned long
+__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
+{
+ switch (size) {
+ case 4:
+ return __cmpxchg_u32(ptr, old, new);
+ case 8:
+ return __cmpxchg_u64(ptr, old, new);
+ }
+ return old;
+}
+#define cmpxchg(ptr,o,n) \
+ ({ \
+ __typeof__(*(ptr)) _o_ = (o); \
+ __typeof__(*(ptr)) _n_ = (n); \
+ (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
+ (unsigned long)_n_, sizeof(*(ptr))); \
+ })
+
+#elif __i386__
static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
unsigned long new, int size)
{
@@ -163,6 +237,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
#define cmpxchg(ptr,o,n) \
((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
(unsigned long)(n),sizeof(*(ptr))))
+#endif /* i386 & alpha */
#endif
/* Macros to make printk easier */
diff --git a/linux/mga_context.c b/linux/mga_context.c
index d02592740..0ff171730 100644
--- a/linux/mga_context.c
+++ b/linux/mga_context.c
@@ -29,11 +29,11 @@
*
*/
-#include <linux/sched.h>
#define __NO_VERSION__
#include "drmP.h"
#include "mga_drv.h"
+#include <linux/sched.h>
static int mga_alloc_queue(drm_device_t *dev)
{
diff --git a/linux/mga_dma.c b/linux/mga_dma.c
index 28e8811c8..b1ac948f3 100644
--- a/linux/mga_dma.c
+++ b/linux/mga_dma.c
@@ -82,6 +82,7 @@ static void mga_delay(void)
return;
}
+#ifdef __i386__
void mga_flush_write_combine(void)
{
int xchangeDummy;
@@ -92,6 +93,7 @@ void mga_flush_write_combine(void)
" movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;"
" pop %%eax" : /* no outputs */ : /* no inputs */ );
}
+#endif
/* These are two age tags that will never be sent to
* the hardware */
@@ -427,7 +429,12 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
}
}
+#ifdef __i386__
mga_flush_write_combine();
+#endif
+#ifdef __alpha__
+ mb();
+#endif
atomic_inc(&dev_priv->pending_bufs);
MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL);
MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp);
@@ -824,7 +831,12 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
* the status register will be correct
*/
+#ifdef __i386__
mga_flush_write_combine();
+#endif
+#ifdef __alpha
+ mb();
+#endif
MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL);
MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) |
diff --git a/linux/r128_context.c b/linux/r128_context.c
index f11453ba1..388af82a9 100644
--- a/linux/r128_context.c
+++ b/linux/r128_context.c
@@ -28,11 +28,11 @@
*
*/
-#include <linux/sched.h>
#define __NO_VERSION__
#include "drmP.h"
#include "r128_drv.h"
+#include <linux/sched.h>
extern drm_ctx_t r128_res_ctx;
diff --git a/linux/r128_dma.c b/linux/r128_dma.c
index 16f79c1f6..330dbe637 100644
--- a/linux/r128_dma.c
+++ b/linux/r128_dma.c
@@ -68,6 +68,7 @@ int R128_READ_PLL(drm_device_t *dev, int addr)
return R128_READ(R128_CLOCK_CNTL_DATA);
}
+#ifdef __i386__
static void r128_flush_write_combine(void)
{
int xchangeDummy;
@@ -86,6 +87,7 @@ static void r128_flush_write_combine(void)
"pop %%ebx ;"
"pop %%eax" : /* no outputs */ : /* no inputs */ );
}
+#endif
static void r128_status(drm_device_t *dev)
{
@@ -496,8 +498,13 @@ static int r128_submit_packets_ring_secure(drm_device_t *dev,
dev_priv->ring_start,
write * sizeof(u32));
+#ifdef __i386__
/* Make sure WC cache has been flushed */
r128_flush_write_combine();
+#endif
+#ifdef __alpha
+ mb();
+#endif
dev_priv->sarea_priv->ring_write = write;
R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write);
@@ -599,8 +606,13 @@ static int r128_submit_packets_ring(drm_device_t *dev,
dev_priv->ring_start,
write * sizeof(u32));
+#ifdef __i386__
/* Make sure WC cache has been flushed */
r128_flush_write_combine();
+#endif
+#ifdef __alpha__
+ mb();
+#endif
dev_priv->sarea_priv->ring_write = write;
R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write);
@@ -767,7 +779,13 @@ static int r128_send_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v)
}
/* Make sure WC cache has been flushed (if in PIO mode) */
- if (!dev_priv->cce_is_bm_mode) r128_flush_write_combine();
+ if (!dev_priv->cce_is_bm_mode)
+#ifdef __i386__
+ r128_flush_write_combine();
+#endif
+#ifdef __alpha__
+ mb();
+#endif
/* FIXME: Add support for sending vertex buffer to the CCE here
instead of in client code. The v->prim holds the primitive
diff --git a/linux/tdfx_context.c b/linux/tdfx_context.c
index c8d6e50ea..55ffdeecd 100644
--- a/linux/tdfx_context.c
+++ b/linux/tdfx_context.c
@@ -30,11 +30,11 @@
*
*/
-#include <linux/sched.h>
#define __NO_VERSION__
#include "drmP.h"
#include "tdfx_drv.h"
+#include <linux/sched.h>
extern drm_ctx_t tdfx_res_ctx;