00001 #ifndef _SYS_TYPES_H_
00002 #define _SYS_TYPES_H_
00003
00004 /*
00005 * Copyright (C) 2001-2002 by egnite Software GmbH. All rights reserved.
00006 *
00007 * Redistribution and use in source and binary forms, with or without
00008 * modification, are permitted provided that the following conditions
00009 * are met:
00010 *
00011 * 1. Redistributions of source code must retain the above copyright
00012 * notice, this list of conditions and the following disclaimer.
00013 * 2. Redistributions in binary form must reproduce the above copyright
00014 * notice, this list of conditions and the following disclaimer in the
00015 * documentation and/or other materials provided with the distribution.
00016 * 3. All advertising materials mentioning features or use of this
00017 * software must display the following acknowledgement:
00018 *
00019 * This product includes software developed by egnite Software GmbH
00020 * and its contributors.
00021 *
00022 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00023 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00026 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00029 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00030 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00032 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033 * SUCH DAMAGE.
00034 *
00035 * For additional information see http://www.ethernut.de/
00036 *
00037 * -
00038 * Portions Copyright (c) 1983, 1993 by
00039 * The Regents of the University of California. All rights reserved.
00040 *
00041 * Redistribution and use in source and binary forms, with or without
00042 * modification, are permitted provided that the following conditions
00043 * are met:
00044 * 1. Redistributions of source code must retain the above copyright
00045 * notice, this list of conditions and the following disclaimer.
00046 * 2. Redistributions in binary form must reproduce the above copyright
00047 * notice, this list of conditions and the following disclaimer in the
00048 * documentation and/or other materials provided with the distribution.
00049 * 3. All advertising materials mentioning features or use of this software
00050 * must display the following acknowledgement:
00051 * This product includes software developed by the University of
00052 * California, Berkeley and its contributors.
00053 * 4. Neither the name of the University nor the names of its contributors
00054 * may be used to endorse or promote products derived from this software
00055 * without specific prior written permission.
00056 *
00057 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00058 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00059 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00060 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00061 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00062 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00063 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00064 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00065 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00066 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00067 * SUCH DAMAGE.
00068 */
00069
00070 /*
00071 * $Log: types.h,v $
00072 * Revision 1.1 2002/08/01 17:34:30 harald
00073 * First check in
00074 *
00075 */
00076
00077 /*!
00078 * \brief Nut/OS type declarations.
00079 */
00080
00081 /*!
00082 * \weakgroup xgEBoot
00083 */
00084 /*@{*/
00085
00086 /*! \brief Unsigned 8-bit value. */
00087 typedef unsigned char u_char;
00088 /*! \brief Unsigned 16-bit value. */
00089 typedef unsigned short u_short;
00090 /*! \brief Unsigned 16-bit value. */
00091 typedef unsigned int u_int;
00092 /*! \brief Unsigned 32-bit value */
00093 typedef unsigned long u_long;
00094 /*! \brief Unsigned 64-bit value */
00095 typedef unsigned long long u_longlong;
00096 /*! \brief Void pointer */
00097 typedef void * HANDLE;
00098
00099
00100 /*
00101 * Conversion of 16 bit value to network order.
00102 */
00103 static inline u_short __byte_swap2(u_short val)
00104 {
00105 asm volatile(
00106 "mov __tmp_reg__, %A0\n\t"
00107 "mov %A0, %B0\n\t"
00108 "mov %B0, __tmp_reg__\n\t"
00109 : "=r" (val)
00110 : "0" (val)
00111 );
00112 return val;
00113 }
00114
00115 /*
00116 * Conversion of 32 bit value to network order.
00117 */
00118 static inline u_long __byte_swap4(u_long val)
00119 {
00120 asm volatile(
00121 "mov __tmp_reg__, %A0\n\t"
00122 "mov %A0, %D0\n\t"
00123 "mov %D0, __tmp_reg__\n\t"
00124 "mov __tmp_reg__, %B0\n\t"
00125 "mov %B0, %C0\n\t"
00126 "mov %C0, __tmp_reg__\n\t"
00127 : "=r" (val)
00128 : "0" (val)
00129 );
00130 return val;
00131 }
00132
00133 /*!
00134 * \brief Convert short value from host to network byte order.
00135 */
00136 #define htons(x) __byte_swap2(x)
00137
00138 /*!
00139 * \brief Convert long value from host to network byte order.
00140 */
00141 #define htonl(x) __byte_swap4(x)
00142
00143 /*!
00144 * \brief Convert short value from network to host byte order.
00145 */
00146 #define ntohs(x) __byte_swap2(x)
00147
00148 /*!
00149 * \brief Convert long value from network to host byte order.
00150 */
00151 #define ntohl(x) __byte_swap4(x)
00152
00153 /*@}*/
00154
00155 #endif