linux-old/drivers/char/drm/via_drv.h
<<
>>
Prefs
   1/*
   2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
   3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
   4 *
   5 * Permission is hereby granted, free of charge, to any person obtaining a
   6 * copy of this software and associated documentation files (the "Software"),
   7 * to deal in the Software without restriction, including without limitation
   8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
   9 * and/or sell copies of the Software, and to permit persons to whom the
  10 * Software is furnished to do so, subject to the following conditions:
  11 *
  12 * The above copyright notice and this permission notice (including the
  13 * next paragraph) shall be included in all copies or substantial portions
  14 * of the Software.
  15 *
  16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22 * DEALINGS IN THE SOFTWARE.
  23 */
  24#ifndef _VIA_DRV_H_
  25#define _VIA_DRV_H_
  26
  27typedef struct drm_via_private {
  28        drm_via_sarea_t *sarea_priv;
  29        drm_map_t *sarea;
  30        drm_map_t *fb;
  31        drm_map_t *mmio;
  32        unsigned long agpAddr;
  33} drm_via_private_t;
  34
  35extern int via_do_init_map(drm_device_t *dev, drm_via_init_t *init);
  36extern int via_do_cleanup_map(drm_device_t *dev);
  37extern int via_map_init(struct inode *inode, struct file *filp,
  38                   unsigned int cmd, unsigned long arg);
  39
  40/*=* [DBG] For RedHat7.3 insert kernel module has unresolved symbol
  41   cmpxchg() *=*/
  42
  43/* Include this here so that driver can be used with older kernels. */
  44#ifndef __HAVE_ARCH_CMPXCHG 
  45
  46#ifdef CONFIG_SMP
  47#define LOCK_PREFIX "lock ; "
  48#else
  49#define LOCK_PREFIX ""
  50#endif          
  51
  52#if defined(__alpha__)
  53static __inline__ unsigned long
  54__cmpxchg_u32(volatile int *m, int old, int new)
  55{
  56        unsigned long prev, cmp;
  57
  58        __asm__ __volatile__(
  59        "1:     ldl_l %0,%2\n"
  60        "       cmpeq %0,%3,%1\n"
  61        "       beq %1,2f\n"
  62        "       mov %4,%1\n"
  63        "       stl_c %1,%2\n"
  64        "       beq %1,3f\n"
  65        "2:     mb\n"
  66        ".subsection 2\n"
  67        "3:     br 1b\n"
  68        ".previous"
  69        : "=&r"(prev), "=&r"(cmp), "=m"(*m)
  70        : "r"((long) old), "r"(new), "m"(*m));
  71
  72        return prev;
  73}
  74
  75static __inline__ unsigned long
  76__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
  77{
  78        unsigned long prev, cmp;
  79
  80        __asm__ __volatile__(
  81        "1:     ldq_l %0,%2\n"
  82        "       cmpeq %0,%3,%1\n"
  83        "       beq %1,2f\n"
  84        "       mov %4,%1\n"
  85        "       stq_c %1,%2\n"
  86        "       beq %1,3f\n"
  87        "2:     mb\n"
  88        ".subsection 2\n"
  89        "3:     br 1b\n"
  90        ".previous"
  91        : "=&r"(prev), "=&r"(cmp), "=m"(*m)
  92        : "r"((long) old), "r"(new), "m"(*m));
  93
  94        return prev;
  95}
  96
  97static __inline__ unsigned long
  98__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
  99{
 100        switch (size) {
 101                case 4:
 102                        return __cmpxchg_u32(ptr, old, new);
 103                case 8:
 104                        return __cmpxchg_u64(ptr, old, new);
 105        }
 106        return old;
 107}
 108#define cmpxchg(ptr,o,n)                                                 \
 109  ({                                                                     \
 110     __typeof__(*(ptr)) _o_ = (o);                                       \
 111     __typeof__(*(ptr)) _n_ = (n);                                       \
 112     (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_,           \
 113                                    (unsigned long)_n_, sizeof(*(ptr))); \
 114  })
 115
 116#elif __i386__
 117static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
 118                                      unsigned long new, int size)
 119{
 120        unsigned long prev;
 121        switch (size) {
 122        case 1:
 123                __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
 124                                     : "=a"(prev)
 125                                     : "q"(new), "m"(*__xg(ptr)), "0"(old)
 126                                     : "memory");
 127                return prev;
 128        case 2:
 129                __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
 130                                     : "=a"(prev)
 131                                     : "q"(new), "m"(*__xg(ptr)), "0"(old)
 132                                     : "memory");
 133                return prev;
 134        case 4:
 135                __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
 136                                     : "=a"(prev)
 137                                     : "q"(new), "m"(*__xg(ptr)), "0"(old)
 138                                     : "memory");
 139                return prev;
 140        }
 141        return old;
 142}
 143
 144#define cmpxchg(ptr,o,n)                                                \
 145  ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),              \
 146                                 (unsigned long)(n),sizeof(*(ptr))))
 147#endif /* i386 & alpha */
 148#endif
 149#endif
 150
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.