Main Page Modules Alphabetical List Data Structures File List Data Fields Globals # IxOsServicesEndianess.h Go to the documentation of this file.
    00001
    00048 #ifndef IxOsServicesEndianess_H
    00049 #define IxOsServicesEndianess_H
    00050
    00051 #if defined (__vxworks) || defined (__linux)
    00052
    00053 /* get ntohl/ntohs/htohl/htons macros and CPU definitions for VxWorks */
    00054 #include <netinet/in.h>
    00055
    00056 #else
    00057
    00058 #error Unknown OS, please add a section with the include file for htonl/htons/ntohl/ntohs
    00059
    00060 #endif /* vxworks or linux */
    00061
    00062 /* Compiler specific endianness selector - WARNING this works only with arm gcc, use appropriate defines with diab */
    00063 #if defined (__ARMEL__)
    00064
    00065 #ifndef __LITTLE_ENDIAN
    00066
    00067 #define __LITTLE_ENDIAN
    00068
    00069 #endif
    00070
    00071 #elif defined (__ARMEB__) || CPU == SIMSPARCSOLARIS
    00072
    00073 #ifndef __BIG_ENDIAN
    00074
    00075 #define __BIG_ENDIAN
    00076
    00077 #endif
    00078
    00079 #else
    00080
    00081 #error Error, could not identify target endianness
    00082
    00083 #endif /* endianness selector */
    00084
    00085 /* OS mode selector */
    00086 #if defined (__vxworks) && defined (__LITTLE_ENDIAN)
    00087
    00088 #define IX_OSSERV_VXWORKS_LE
    00089
    00090 #elif defined (__vxworks) && defined (__BIG_ENDIAN)
    00091
    00092 #define IX_OSSERV_VXWORKS_BE
    00093
    00094 #elif defined (__linux) && defined (__BIG_ENDIAN)
    00095
    00096 #define IX_OSSERV_LINUX_BE
    00097
    00098 #else
    00099
    00100 #error Unknown OS/Endianess combination - only WxWorks LE, VxWorks BE and Linux BE are supported
    00101
    00102 #endif /* mode selector */
    00103
    00104 #ifdef __XSCALE__
    00105 static __inline__ UINT32 ixOsServWordSwap(UINT32 wordIn)
    00106 {
    00107     /* Storage for the swapped word */
    00108     UINT32 wordOut;
    00109
    00110     /* wordIn = A, B, C, D */
    00111     __asm__ (" eor r1, %1, %1, ror #16;"  /* R1 =      A^C, B^D, C^A, D^B */
    00112          " bic r1, r1, #0x00ff0000;"  /* R1 =      A^C, 0  , C^A, D^B */
    00113          " mov %0, %1, ror #8;"       /* wordOut = D,   A,   B,   C   */
    00114          " eor %0, %0, r1, lsr #8;"   /* wordOut = D,   C,   B,   A   */
    00115          : "=r" (wordOut) : "r" (wordIn) : "r1");
    00116
    00117     return wordOut;
    00118 }
    00119 #endif
    00120
    00121
    00122 /* Low-level conversion macros - DO NOT USE UNLESS ABSOLUTELY NEEDED */
    00123 #ifdef __XSCALE__
    00124 #define IX_OSSERV_SWAP_LONG(wData)          (ixOsServWordSwap(wData))
    00125 #else
    00126 #define IX_OSSERV_SWAP_LONG(wData)          ((wData >> 24) | (((wData >> 16) & 0xFF) << 8) | (((wData >> 8) & 0xFF) << 16) | ((wData & 0xFF) << 24))
    00127 #endif
    00128 #define IX_OSSERV_SWAP_SHORT(sData)         ((sData >> 8) | ((sData & 0xFF) << 8))
    00129 #define IX_OSSERV_SWAP_SHORT_ADDRESS(sAddr) ((sAddr) ^ 0x2)
    00130 #define IX_OSSERV_SWAP_BYTE_ADDRESS(bAddr)  ((bAddr) ^ 0x3)
    00131
    00132 #define IX_OSSERV_BE_XSTOBUSL(wData)  (wData)
    00133 #define IX_OSSERV_BE_XSTOBUSS(sData)  (sData)
    00134 #define IX_OSSERV_BE_XSTOBUSB(bData)  (bData)
    00135 #define IX_OSSERV_BE_BUSTOXSL(wData)  (wData)
    00136 #define IX_OSSERV_BE_BUSTOXSS(sData)  (sData)
    00137 #define IX_OSSERV_BE_BUSTOXSB(bData)  (bData)
    00138
    00139 #define IX_OSSERV_LE_AC_XSTOBUSL(wAddr) (wAddr)
    00140 #define IX_OSSERV_LE_AC_XSTOBUSS(sAddr) IX_OSSERV_SWAP_SHORT_ADDRESS(sAddr)
    00141 #define IX_OSSERV_LE_AC_XSTOBUSB(bAddr) IX_OSSERV_SWAP_BYTE_ADDRESS(bAddr)
    00142 #define IX_OSSERV_LE_AC_BUSTOXSL(wAddr) (wAddr)
    00143 #define IX_OSSERV_LE_AC_BUSTOXSS(sAddr) IX_OSSERV_SWAP_SHORT_ADDRESS(sAddr)
    00144 #define IX_OSSERV_LE_AC_BUSTOXSB(bAddr) IX_OSSERV_SWAP_BYTE_ADDRESS(bAddr)
    00145
    00146 #define IX_OSSERV_LE_DC_XSTOBUSL(wData) IX_OSSERV_SWAP_LONG(wData)
    00147 #define IX_OSSERV_LE_DC_XSTOBUSS(sData) IX_OSSERV_SWAP_SHORT(sData)
    00148 #define IX_OSSERV_LE_DC_XSTOBUSB(bData) (bData)
    00149 #define IX_OSSERV_LE_DC_BUSTOXSL(wData) IX_OSSERV_SWAP_LONG(wData)
    00150 #define IX_OSSERV_LE_DC_BUSTOXSS(sData) IX_OSSERV_SWAP_SHORT(sData)
    00151 #define IX_OSSERV_LE_DC_BUSTOXSB(bData) (bData)
    00152
    00153 #endif /* IxOsServicesEndianess_H */
Automatically generated from sources. © Intel Corp. 2003