[BACK]Return to maskbits.h CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / dev

Annotation of sys/arch/hp300/dev/maskbits.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: maskbits.h,v 1.6 2006/08/05 09:58:56 miod Exp $       */
                      2: /*     $NetBSD: maskbits.h,v 1.3 1997/03/31 07:37:28 scottr Exp $      */
                      3:
                      4: /*-
                      5:  * Copyright (c) 1994
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. Neither the name of the University nor the names of its contributors
                     17:  *    may be used to endorse or promote products derived from this software
                     18:  *    without specific prior written permission.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     30:  * SUCH DAMAGE.
                     31:  *
                     32:  *     @(#)maskbits.h  8.2 (Berkeley) 3/21/94
                     33:  */
                     34:
                     35: /*
                     36:  * Derived from X11R4
                     37:  */
                     38:
                     39: /* the following notes use the following conventions:
                     40: SCREEN LEFT                            SCREEN RIGHT
                     41: in this file and maskbits.c, left and right refer to screen coordinates,
                     42: NOT bit numbering in registers.
                     43:
                     44: rasops_lmask[n]
                     45:        bits[0,n-1] = 0 bits[n,31] = 1
                     46: rasops_rmask[n] =
                     47:        bits[0,n-1] = 1 bits[n,31] = 0
                     48:
                     49: maskbits(x, w, startmask, endmask, nlw)
                     50:        for a span of width w starting at position x, returns
                     51: a mask for ragged bits at start, mask for ragged bits at end,
                     52: and the number of whole longwords between the ends.
                     53:
                     54: */
                     55:
                     56: #define maskbits(x, w, startmask, endmask, nlw)                                \
                     57: do {                                                                   \
                     58:        startmask = rasops_lmask[(x) & 0x1f];                           \
                     59:        endmask = rasops_rmask[((x) + (w)) & 0x1f];                     \
                     60:        if (startmask)                                                  \
                     61:                nlw = (((w) - (32 - ((x) & 0x1f))) >> 5);               \
                     62:        else                                                            \
                     63:                nlw = (w) >> 5;                                         \
                     64: } while (0)
                     65:
                     66: #define FASTGETBITS(psrc, x, w, dst) \
                     67:     asm ("bfextu %3{%1:%2},%0" \
                     68:     : "=d" (dst) : "di" (x), "di" (w), "o" (*(char *)(psrc)))
                     69:
                     70: #define FASTPUTBITS(src, x, w, pdst) \
                     71:     asm ("bfins %3,%0{%1:%2}" \
                     72:         : "=o" (*(char *)(pdst)) \
                     73:         : "di" (x), "di" (w), "d" (src), "0" (*(char *) (pdst)))
                     74:
                     75: #define getandputrop(psrc, srcbit, dstbit, width, pdst, rop)           \
                     76: do {                                                                   \
                     77:        unsigned int _tmpdst;                                           \
                     78:        if (rop == RR_CLEAR)                                            \
                     79:                _tmpdst = 0;                                            \
                     80:        else                                                            \
                     81:                FASTGETBITS(psrc, srcbit, width, _tmpdst);              \
                     82:        FASTPUTBITS(_tmpdst, dstbit, width, pdst);                      \
                     83: } while (0)
                     84:
                     85: #define getunalignedword(psrc, x, dst)                                 \
                     86: do {                                                                   \
                     87:         int _tmp;                                                      \
                     88:         FASTGETBITS(psrc, x, 32, _tmp);                                        \
                     89:         dst = _tmp;                                                    \
                     90: } while (0)

CVSweb