Print this page
5042 stop using deprecated atomic functions


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 /*
  29  * zuluvm module
  30  *
  31  * Provides services required by the XVR-4000 graphics accelerator (zulu)
  32  * that are not provided by the ddi. See PSARC 2002/231.
  33  *
  34  * Zulu has 2 dma engines with built in MMUs. zuluvm provides TLB miss
  35  * interrupt support obtaining virtual to physical address translations
  36  * using the XHAT interface PSARC/2003/517.
  37  *
  38  * The module has 3 components. This file, sun4u/vm/zulu_hat.c, and the
  39  * assembly language routines in sun4u/ml/zulu_asm.s and
  40  * sun4u/ml/zulu_hat_asm.s.
  41  *
  42  * The interrupt handler is a data bearing mondo interrupt handled at TL=1
  43  * If no translation is found in the zulu hat's tsb, or if the tsb is locked by
  44  * C code, the handler posts a soft interrupt which wakes up a parked
  45  * thread belonging to zuludaemon(1M).
  46  */
  47 


  61 #include <sys/machsystm.h>
  62 #include <sys/ivintr.h>
  63 #include <sys/tnf_probe.h>
  64 #include <sys/intreg.h>
  65 #include <sys/atomic.h>
  66 #include <vm/as.h>
  67 #include <vm/seg_enum.h>
  68 #include <vm/faultcode.h>
  69 #include <sys/dmv.h>
  70 #include <sys/zulumod.h>
  71 #include <sys/zulu_hat.h>
  72 
  73 #define ZULUVM_GET_PAGE(val) \
  74         (caddr_t)((uintptr_t)(val) & PAGEMASK)
  75 #define ZULUVM_GET_AS   curthread->t_procp->p_as
  76 
  77 #define ZULUVM_LOCK   mutex_enter(&(zdev->dev_lck))
  78 #define ZULUVM_UNLOCK mutex_exit(&(zdev->dev_lck))
  79 
  80 #define ZULUVM_SET_STATE(_z, b, c) \
  81         cas32((uint32_t *)&((_z)->zvm.state), c, b)
  82 #define ZULUVM_GET_STATE(_z) \
  83         (_z)->zvm.state
  84 #define ZULUVM_SET_IDLE(_z) \
  85         (_z)->zvm.state = ZULUVM_STATE_IDLE;
  86 
  87 #define ZULUVM_INO_MASK ((1<<INO_SIZE)-1)
  88 #define ZULUVM_IGN_MASK ((1<<IGN_SIZE)-1)
  89 #define ZULUVM_MONDO(_zdev, _n) \
  90         ((ZULUVM_IGN_MASK & _zdev->agentid) << INO_SIZE) | \
  91         (ZULUVM_INO_MASK & (_n))
  92 
  93 static void zuluvm_stop(zuluvm_state_t *, int, char *);
  94 static zuluvm_proc_t *zuluvm_find_proc(zuluvm_state_t *, struct as *);
  95 static int zuluvm_proc_release(zuluvm_state_t *zdev, zuluvm_proc_t *proc);
  96 static int zuluvm_get_intr_props(zuluvm_state_t *zdev, dev_info_t *devi);
  97 static int zuluvm_driver_attach(zuluvm_state_t *);
  98 static int zuluvm_driver_detach(zuluvm_state_t *);
  99 static void zuluvm_retarget_intr(void *arg);
 100 static void zuluvm_do_retarget(zuluvm_state_t *zdev);
 101 




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 


  26 /*
  27  * zuluvm module
  28  *
  29  * Provides services required by the XVR-4000 graphics accelerator (zulu)
  30  * that are not provided by the ddi. See PSARC 2002/231.
  31  *
  32  * Zulu has 2 dma engines with built in MMUs. zuluvm provides TLB miss
  33  * interrupt support obtaining virtual to physical address translations
  34  * using the XHAT interface PSARC/2003/517.
  35  *
  36  * The module has 3 components. This file, sun4u/vm/zulu_hat.c, and the
  37  * assembly language routines in sun4u/ml/zulu_asm.s and
  38  * sun4u/ml/zulu_hat_asm.s.
  39  *
  40  * The interrupt handler is a data bearing mondo interrupt handled at TL=1
  41  * If no translation is found in the zulu hat's tsb, or if the tsb is locked by
  42  * C code, the handler posts a soft interrupt which wakes up a parked
  43  * thread belonging to zuludaemon(1M).
  44  */
  45 


  59 #include <sys/machsystm.h>
  60 #include <sys/ivintr.h>
  61 #include <sys/tnf_probe.h>
  62 #include <sys/intreg.h>
  63 #include <sys/atomic.h>
  64 #include <vm/as.h>
  65 #include <vm/seg_enum.h>
  66 #include <vm/faultcode.h>
  67 #include <sys/dmv.h>
  68 #include <sys/zulumod.h>
  69 #include <sys/zulu_hat.h>
  70 
  71 #define ZULUVM_GET_PAGE(val) \
  72         (caddr_t)((uintptr_t)(val) & PAGEMASK)
  73 #define ZULUVM_GET_AS   curthread->t_procp->p_as
  74 
  75 #define ZULUVM_LOCK   mutex_enter(&(zdev->dev_lck))
  76 #define ZULUVM_UNLOCK mutex_exit(&(zdev->dev_lck))
  77 
  78 #define ZULUVM_SET_STATE(_z, b, c) \
  79         atomic_cas_32((uint32_t *)&((_z)->zvm.state), c, b)
  80 #define ZULUVM_GET_STATE(_z) \
  81         (_z)->zvm.state
  82 #define ZULUVM_SET_IDLE(_z) \
  83         (_z)->zvm.state = ZULUVM_STATE_IDLE;
  84 
  85 #define ZULUVM_INO_MASK ((1<<INO_SIZE)-1)
  86 #define ZULUVM_IGN_MASK ((1<<IGN_SIZE)-1)
  87 #define ZULUVM_MONDO(_zdev, _n) \
  88         ((ZULUVM_IGN_MASK & _zdev->agentid) << INO_SIZE) | \
  89         (ZULUVM_INO_MASK & (_n))
  90 
  91 static void zuluvm_stop(zuluvm_state_t *, int, char *);
  92 static zuluvm_proc_t *zuluvm_find_proc(zuluvm_state_t *, struct as *);
  93 static int zuluvm_proc_release(zuluvm_state_t *zdev, zuluvm_proc_t *proc);
  94 static int zuluvm_get_intr_props(zuluvm_state_t *zdev, dev_info_t *devi);
  95 static int zuluvm_driver_attach(zuluvm_state_t *);
  96 static int zuluvm_driver_detach(zuluvm_state_t *);
  97 static void zuluvm_retarget_intr(void *arg);
  98 static void zuluvm_do_retarget(zuluvm_state_t *zdev);
  99