The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/drm/drm_atomic.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /**
    2  * \file drm_atomic.h
    3  * Atomic operations used in the DRM which may or may not be provided by the OS.
    4  * 
    5  * \author Eric Anholt <anholt@FreeBSD.org>
    6  */
    7 
    8 /*-
    9  * Copyright 2004 Eric Anholt
   10  * All Rights Reserved.
   11  *
   12  * Permission is hereby granted, free of charge, to any person obtaining a
   13  * copy of this software and associated documentation files (the "Software"),
   14  * to deal in the Software without restriction, including without limitation
   15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   16  * and/or sell copies of the Software, and to permit persons to whom the
   17  * Software is furnished to do so, subject to the following conditions:
   18  *
   19  * The above copyright notice and this permission notice (including the next
   20  * paragraph) shall be included in all copies or substantial portions of the
   21  * Software.
   22  *
   23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   26  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   27  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   28  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   29  * OTHER DEALINGS IN THE SOFTWARE.
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __FBSDID("$FreeBSD: releng/9.0/sys/dev/drm/drm_atomic.h 183573 2008-10-03 16:59:11Z rnoland $");
   34 
   35 /* Many of these implementations are rather fake, but good enough. */
   36 
   37 typedef u_int32_t atomic_t;
   38 
   39 #define atomic_set(p, v)        (*(p) = (v))
   40 #define atomic_read(p)          (*(p))
   41 #define atomic_inc(p)           atomic_add_int(p, 1)
   42 #define atomic_dec(p)           atomic_subtract_int(p, 1)
   43 #define atomic_add(n, p)        atomic_add_int(p, n)
   44 #define atomic_sub(n, p)        atomic_subtract_int(p, n)
   45 
   46 static __inline atomic_t
   47 test_and_set_bit(int b, volatile void *p)
   48 {
   49         int s = splhigh();
   50         unsigned int m = 1<<b;
   51         unsigned int r = *(volatile int *)p & m;
   52         *(volatile int *)p |= m;
   53         splx(s);
   54         return r;
   55 }
   56 
   57 static __inline void
   58 clear_bit(int b, volatile void *p)
   59 {
   60         atomic_clear_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f));
   61 }
   62 
   63 static __inline void
   64 set_bit(int b, volatile void *p)
   65 {
   66         atomic_set_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f));
   67 }
   68 
   69 static __inline int
   70 test_bit(int b, volatile void *p)
   71 {
   72         return ((volatile int *)p)[b >> 5] & (1 << (b & 0x1f));
   73 }
   74 
   75 static __inline int
   76 find_first_zero_bit(volatile void *p, int max)
   77 {
   78         int b;
   79         volatile int *ptr = (volatile int *)p;
   80 
   81         for (b = 0; b < max; b += 32) {
   82                 if (ptr[b >> 5] != ~0) {
   83                         for (;;) {
   84                                 if ((ptr[b >> 5] & (1 << (b & 0x1f))) == 0)
   85                                         return b;
   86                                 b++;
   87                         }
   88                 }
   89         }
   90         return max;
   91 }

Cache object: cf0e04b79bb0adb6954abe833922e9b8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.