~ubuntu-branches/ubuntu/precise/linux-ti-omap/precise

« back to all changes in this revision

Viewing changes to ubuntu/rtl8192se/rtl_endianfree.h

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader, Amit Kucheria
  • Date: 2010-03-23 18:05:12 UTC
  • Revision ID: james.westby@ubuntu.com-20100323180512-iavj906ocnphdubp
Tags: 2.6.33-500.3
[ Amit Kucheria ]

* [Config] Fix the debug package name to end in -dbgsym
* SAUCE: Add the ubuntu/ drivers to omap
* SAUCE: Re-export the symbols for aufs
* [Config] Enable AUFS and COMPCACHE

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __INC_ENDIANFREE_H
 
2
#define __INC_ENDIANFREE_H
 
3
 
 
4
/*
 
5
 *      Call endian free function when
 
6
 *              1. Read/write packet content.
 
7
 *              2. Before write integer to IO.
 
8
 *              3. After read integer from IO.
 
9
 */
 
10
 
 
11
#define __MACHINE_LITTLE_ENDIAN 1234    /* LSB first: i386, vax */
 
12
#define __MACHINE_BIG_ENDIAN    4321    /* MSB first: 68000, ibm, net, ppc */
 
13
 
 
14
#define BYTE_ORDER __MACHINE_LITTLE_ENDIAN
 
15
 
 
16
#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
 
17
#define EF1Byte(_val)                           ((u8)(_val))
 
18
#define EF2Byte(_val)                           ((u16)(_val))
 
19
#define EF4Byte(_val)                           ((u32)(_val))
 
20
 
 
21
#else
 
22
#define EF1Byte(_val)                           ((u8)(_val))
 
23
#define EF2Byte(_val)                           (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8))
 
24
#define EF4Byte(_val)                           (((((u32)(_val))&0x000000ff)<<24)|\
 
25
                                                ((((u32)(_val))&0x0000ff00)<<8)|\
 
26
                                                ((((u32)(_val))&0x00ff0000)>>8)|\
 
27
                                                ((((u32)(_val))&0xff000000)>>24))
 
28
#endif
 
29
 
 
30
#define ReadEF1Byte(_ptr)               EF1Byte(*((u8 *)(_ptr)))
 
31
#define ReadEF2Byte(_ptr)               EF2Byte(*((u16 *)(_ptr)))
 
32
#define ReadEF4Byte(_ptr)               EF4Byte(*((u32 *)(_ptr)))
 
33
 
 
34
#define WriteEF1Byte(_ptr, _val)        (*((u8 *)(_ptr)))=EF1Byte(_val)
 
35
#define WriteEF2Byte(_ptr, _val)        (*((u16 *)(_ptr)))=EF2Byte(_val)
 
36
#define WriteEF4Byte(_ptr, _val)        (*((u32 *)(_ptr)))=EF4Byte(_val)                                                                        
 
37
#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
 
38
#define H2N1BYTE(_val)  ((u8)(_val))
 
39
#define H2N2BYTE(_val)  (((((u16)(_val))&0x00ff)<<8)|\
 
40
                        ((((u16)(_val))&0xff00)>>8))
 
41
#define H2N4BYTE(_val)  (((((u32)(_val))&0x000000ff)<<24)|\
 
42
                        ((((u32)(_val))&0x0000ff00)<<8) |\
 
43
                        ((((u32)(_val))&0x00ff0000)>>8) |\
 
44
                        ((((u32)(_val))&0xff000000)>>24))
 
45
#else
 
46
#define H2N1BYTE(_val)                  ((u8)(_val))
 
47
#define H2N2BYTE(_val)                  ((u16)(_val))
 
48
#define H2N4BYTE(_val)                  ((u32)(_val))
 
49
#endif
 
50
 
 
51
#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
 
52
#define N2H1BYTE(_val)  ((u8)(_val))
 
53
#define N2H2BYTE(_val)  (((((u16)(_val))&0x00ff)<<8)|\
 
54
                        ((((u16)(_val))&0xff00)>>8))
 
55
#define N2H4BYTE(_val)  (((((u32)(_val))&0x000000ff)<<24)|\
 
56
                        ((((u32)(_val))&0x0000ff00)<<8) |\
 
57
                        ((((u32)(_val))&0x00ff0000)>>8) |\
 
58
                        ((((u32)(_val))&0xff000000)>>24))
 
59
#else
 
60
#define N2H1BYTE(_val)                  ((u8)(_val))
 
61
#define N2H2BYTE(_val)                  ((u16)(_val))
 
62
#define N2H4BYTE(_val)                  ((u32)(_val))
 
63
#endif
 
64
 
 
65
#define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen)))
 
66
#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) 
 
67
 
 
68
#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart))))
 
69
 
 
70
#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
 
71
        ( \
 
72
          ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \
 
73
          & \
 
74
          BIT_LEN_MASK_32(__BitLen) \
 
75
        )
 
76
 
 
77
#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
 
78
        ( \
 
79
          LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
 
80
          & \
 
81
          ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \
 
82
        )
 
83
 
 
84
#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \
 
85
        *((u32 *)(__pStart)) = \
 
86
        EF4Byte( \
 
87
        LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
 
88
        | \
 
89
        ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \
 
90
       );
 
91
 
 
92
 
 
93
#define BIT_LEN_MASK_16(__BitLen) \
 
94
        (0xFFFF >> (16 - (__BitLen)))
 
95
 
 
96
#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
 
97
        (BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
 
98
 
 
99
#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
 
100
        (EF2Byte(*((u16 *)(__pStart))))
 
101
 
 
102
#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
 
103
        ( \
 
104
          ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \
 
105
          & \
 
106
          BIT_LEN_MASK_16(__BitLen) \
 
107
        )
 
108
 
 
109
#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
 
110
        ( \
 
111
          LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
 
112
          & \
 
113
          ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \
 
114
        )
 
115
 
 
116
#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \
 
117
        *((u16 *)(__pStart)) = \
 
118
        EF2Byte( \
 
119
                LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
 
120
                | \
 
121
                ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \
 
122
       );
 
123
 
 
124
#define BIT_LEN_MASK_8(__BitLen) \
 
125
        (0xFF >> (8 - (__BitLen)))
 
126
 
 
127
#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
 
128
        (BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
 
129
 
 
130
#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
 
131
        (EF1Byte(*((u8 *)(__pStart))))
 
132
 
 
133
#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
 
134
        ( \
 
135
          ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \
 
136
          & \
 
137
          BIT_LEN_MASK_8(__BitLen) \
 
138
        )
 
139
 
 
140
#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
 
141
        ( \
 
142
          LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
 
143
          & \
 
144
          ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \
 
145
        )
 
146
 
 
147
#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \
 
148
        *((u8 *)(__pStart)) = \
 
149
        EF1Byte( \
 
150
                LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
 
151
                | \
 
152
                ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \
 
153
       );
 
154
 
 
155
#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment))
 
156
#endif