~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-sa1100/include/mach/bitfield.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *      FILE            bitfield.h
  3  *
  4  *      Version         1.1
  5  *      Author          Copyright (c) Marc A. Viredaz, 1998
  6  *                      DEC Western Research Laboratory, Palo Alto, CA
  7  *      Date            April 1998 (April 1997)
  8  *      System          Advanced RISC Machine (ARM)
  9  *      Language        C or ARM Assembly
 10  *      Purpose         Definition of macros to operate on bit fields.
 11  */
 12 
 13 
 14 
 15 #ifndef __BITFIELD_H
 16 #define __BITFIELD_H
 17 
 18 #ifndef __ASSEMBLY__
 19 #define UData(Data)     ((unsigned long) (Data))
 20 #else
 21 #define UData(Data)     (Data)
 22 #endif
 23 
 24 
 25 /*
 26  * MACRO: Fld
 27  *
 28  * Purpose
 29  *    The macro "Fld" encodes a bit field, given its size and its shift value
 30  *    with respect to bit 0.
 31  *
 32  * Note
 33  *    A more intuitive way to encode bit fields would have been to use their
 34  *    mask. However, extracting size and shift value information from a bit
 35  *    field's mask is cumbersome and might break the assembler (255-character
 36  *    line-size limit).
 37  *
 38  * Input
 39  *    Size              Size of the bit field, in number of bits.
 40  *    Shft              Shift value of the bit field with respect to bit 0.
 41  *
 42  * Output
 43  *    Fld               Encoded bit field.
 44  */
 45 
 46 #define Fld(Size, Shft) (((Size) << 16) + (Shft))
 47 
 48 
 49 /*
 50  * MACROS: FSize, FShft, FMsk, FAlnMsk, F1stBit
 51  *
 52  * Purpose
 53  *    The macros "FSize", "FShft", "FMsk", "FAlnMsk", and "F1stBit" return
 54  *    the size, shift value, mask, aligned mask, and first bit of a
 55  *    bit field.
 56  *
 57  * Input
 58  *    Field             Encoded bit field (using the macro "Fld").
 59  *
 60  * Output
 61  *    FSize             Size of the bit field, in number of bits.
 62  *    FShft             Shift value of the bit field with respect to bit 0.
 63  *    FMsk              Mask for the bit field.
 64  *    FAlnMsk           Mask for the bit field, aligned on bit 0.
 65  *    F1stBit           First bit of the bit field.
 66  */
 67 
 68 #define FSize(Field)    ((Field) >> 16)
 69 #define FShft(Field)    ((Field) & 0x0000FFFF)
 70 #define FMsk(Field)     (((UData (1) << FSize (Field)) - 1) << FShft (Field))
 71 #define FAlnMsk(Field)  ((UData (1) << FSize (Field)) - 1)
 72 #define F1stBit(Field)  (UData (1) << FShft (Field))
 73 
 74 
 75 /*
 76  * MACRO: FInsrt
 77  *
 78  * Purpose
 79  *    The macro "FInsrt" inserts a value into a bit field by shifting the
 80  *    former appropriately.
 81  *
 82  * Input
 83  *    Value             Bit-field value.
 84  *    Field             Encoded bit field (using the macro "Fld").
 85  *
 86  * Output
 87  *    FInsrt            Bit-field value positioned appropriately.
 88  */
 89 
 90 #define FInsrt(Value, Field) \
 91                         (UData (Value) << FShft (Field))
 92 
 93 
 94 /*
 95  * MACRO: FExtr
 96  *
 97  * Purpose
 98  *    The macro "FExtr" extracts the value of a bit field by masking and
 99  *    shifting it appropriately.
100  *
101  * Input
102  *    Data              Data containing the bit-field to be extracted.
103  *    Field             Encoded bit field (using the macro "Fld").
104  *
105  * Output
106  *    FExtr             Bit-field value.
107  */
108 
109 #define FExtr(Data, Field) \
110                         ((UData (Data) >> FShft (Field)) & FAlnMsk (Field))
111 
112 
113 #endif /* __BITFIELD_H */
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php