tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8800x / endian_conv.h
1 #ifndef _ENDIAN_CONV_H_
2 #define _ENDIAN_CONV_H_
3 /* Endianess stuff */
4 #define my_swab32(data32_ptr) \
5         do{\
6                     uint8_t* data8_ptr = (uint8_t*)data32_ptr;\
7                     uint8_t tmp;\
8                     tmp = data8_ptr[3];\
9                     data8_ptr[3] = data8_ptr[0];\
10                     data8_ptr[0] = tmp;\
11                 \
12                     tmp = data8_ptr[2];\
13                     data8_ptr[2] = data8_ptr[1];\
14                     data8_ptr[1] = tmp;\
15         }while(0)
16
17 #define my_swab16(data16_ptr)\
18         do{\
19                     uint8_t* data8_ptr = (uint8_t*)data16_ptr;\
20                     uint8_t tmp;\
21                     tmp = data8_ptr[1];\
22                     data8_ptr[1] = data8_ptr[0];\
23                     data8_ptr[0] = tmp;\
24         }while(0)
25
26 #define _INT_SWAP(type, ptr) \
27            do{ if(sizeof(type) == 4) {  \
28                                my_swab32(ptr); \
29                            }else if(sizeof(type) == 2) { \
30                                                    my_swab16(ptr);}   \
31                        }while(0)
32
33 #ifdef CMDLINE_NEED_CONV
34 #define INT_SWAP(data) _INT_SWAP(data, &(data))
35 #else
36 #define INT_SWAP(data)
37 #endif
38
39 #endif // end of _ENDIAN_CONV_H_