summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-20 14:37:17 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-20 14:37:17 +0000
commit3f098aed4500da38db8afdff111f02198158203a (patch)
tree370225501caf56821883daa3971214b3d82e28bb /cpukit
parentBase files (diff)
downloadrtems-3f098aed4500da38db8afdff111f02198158203a.tar.bz2
FreeBSD stack compiles for the first time (except libc/strsep.c).
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libnetworking/machine/conf.h0
-rw-r--r--cpukit/libnetworking/machine/cpu.h0
-rw-r--r--cpukit/libnetworking/machine/cpufunc.h0
-rw-r--r--cpukit/libnetworking/machine/endian.h60
-rw-r--r--cpukit/libnetworking/machine/in_cksum.h118
-rw-r--r--cpukit/libnetworking/machine/limits.h0
-rw-r--r--cpukit/libnetworking/machine/param.h88
-rw-r--r--cpukit/libnetworking/machine/types.h32
-rw-r--r--cpukit/libnetworking/machine/vmparam.h0
9 files changed, 298 insertions, 0 deletions
diff --git a/cpukit/libnetworking/machine/conf.h b/cpukit/libnetworking/machine/conf.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cpukit/libnetworking/machine/conf.h
diff --git a/cpukit/libnetworking/machine/cpu.h b/cpukit/libnetworking/machine/cpu.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cpukit/libnetworking/machine/cpu.h
diff --git a/cpukit/libnetworking/machine/cpufunc.h b/cpukit/libnetworking/machine/cpufunc.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cpukit/libnetworking/machine/cpufunc.h
diff --git a/cpukit/libnetworking/machine/endian.h b/cpukit/libnetworking/machine/endian.h
new file mode 100644
index 0000000000..cd0d6f551c
--- /dev/null
+++ b/cpukit/libnetworking/machine/endian.h
@@ -0,0 +1,60 @@
+#ifndef _MACHINE_ENDIAN_H_
+#define _MACHINE_ENDIAN_H_
+
+#include <rtems/score/cpu.h>
+
+/*
+ * BSD-style endian declaration
+ */
+#define BIG_ENDIAN 4321
+#define LITTLE_ENDIAN 1234
+
+#if CPU_BIG_ENDIAN
+# define BYTE_ORDER BIG_ENDIAN
+#elif CPU_LITTLE_ENDIAN
+# define BYTE_ORDER LITTLE_ENDIAN
+#else
+# error "Can't decide which end is which!"
+#endif
+
+#if ( CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES == FALSE )
+
+#if ( CPU_BIG_ENDIAN == TRUE )
+
+/*
+ * Very simply on big endian CPUs
+ */
+
+#define ntohl(_x) (_x)
+#define ntohs(_x) (_x)
+#define htonl(_x) (_x)
+#define htons(_x) (_x)
+
+#define NTOHS(x)
+#define HTONS(x)
+#define NTOHL(x)
+#define HTONL(x)
+
+#elif ( CPU_LITTLE_ENDIAN == TRUE )
+
+/*
+ * A little more complicated on little endian CPUs
+ */
+
+#define ntohl(_x) ((long) CPU_swap_u32((unsigned32)_x))
+#define ntohs(_x) ((short) CPU_swap_u16((unsigned16)_x))
+#define htonl(_x) ((long) CPU_swap_u32((unsigned32)_x))
+#define htons(_x) ((short) CPU_swap_u16((unsigned16)_x))
+
+#define NTOHS(x) (x) = ntohs(x)
+#define HTONS(x) (x) = htons(x)
+#define NTOHL(x) (x) = ntohl(x)
+#define HTONL(x) (x) = htonl(x)
+
+#else
+#error "Unknown endian-ness for this cpu"
+#endif
+
+#endif /* CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES */
+
+#endif /* _MACHINE_ENDIAN_H_ */
diff --git a/cpukit/libnetworking/machine/in_cksum.h b/cpukit/libnetworking/machine/in_cksum.h
new file mode 100644
index 0000000000..15509b3888
--- /dev/null
+++ b/cpukit/libnetworking/machine/in_cksum.h
@@ -0,0 +1,118 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from tahoe: in_cksum.c 1.2 86/01/05
+ * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
+ * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp
+ * $Id$
+ */
+
+#ifndef _MACHINE_IN_CKSUM_H_
+#define _MACHINE_IN_CKSUM_H_ 1
+
+#include <sys/cdefs.h>
+
+/*
+ * It it useful to have an Internet checksum routine which is inlineable
+ * and optimized specifically for the task of computing IP header checksums
+ * in the normal case (where there are no options and the header length is
+ * therefore always exactly five 32-bit words.
+ */
+#if (defined(__GNUC__) && defined(__i386__))
+static __inline u_int
+in_cksum_hdr(const struct ip *ip)
+{
+ register u_int sum = 0;
+
+#define ADD(n) __asm("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
+#define ADDC(n) __asm("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
+#define MOP __asm("adcl $0, %0" : "=r" (sum) : "0" (sum))
+
+ ADD(0);
+ ADDC(4);
+ ADDC(8);
+ ADDC(12);
+ ADDC(16);
+ MOP;
+ sum = (sum & 0xffff) + (sum >> 16);
+ if (sum > 0xffff)
+ sum -= 0xffff;
+
+ return ~sum & 0xffff;
+}
+
+static __inline void
+in_cksum_update(struct ip *ip)
+{
+ int __tmpsum;
+ __tmpsum = (int)ntohs(ip->ip_sum) + 256;
+ ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
+}
+
+#elif (defined(__GNUC__) && (defined(__mc68000__) || defined(__m68k__)))
+
+static __inline__ u_int
+in_cksum_hdr(const struct ip *ip)
+{
+ register u_int *ap = (u_int *)ip;
+ register u_int sum = *ap++;
+ register u_int tmp;
+
+ __asm__("addl %2@+,%0\n\t"
+ "movel %2@+,%1\n\t"
+ "addxl %1,%0\n\t"
+ "movel %2@+,%1\n\t"
+ "addxl %1,%0\n\t"
+ "movel %2@,%1\n\t"
+ "addxl %1,%0\n\t"
+ "moveq #0,%1\n\t"
+ "addxl %1,%0\n" :
+ "=d" (sum), "=d" (tmp), "=a" (ap) :
+ "0" (sum), "2" (ap));
+ sum = (sum & 0xffff) + (sum >> 16);
+ if (sum > 0xffff)
+ sum -= 0xffff;
+ return ~sum & 0xffff;
+}
+
+#else
+u_int in_cksum_hdr __P((const struct ip *));
+#define in_cksum_update(ip) \
+ do { \
+ int __tmpsum; \
+ __tmpsum = (int)ntohs(ip->ip_sum) + 256; \
+ ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \
+ } while(0)
+
+#endif
+
+#endif /* _MACHINE_IN_CKSUM_H_ */
diff --git a/cpukit/libnetworking/machine/limits.h b/cpukit/libnetworking/machine/limits.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cpukit/libnetworking/machine/limits.h
diff --git a/cpukit/libnetworking/machine/param.h b/cpukit/libnetworking/machine/param.h
new file mode 100644
index 0000000000..eae8554c2a
--- /dev/null
+++ b/cpukit/libnetworking/machine/param.h
@@ -0,0 +1,88 @@
+#ifndef _MACHINE_PARAM_H_
+#define _MACHINE_PARAM_H_
+
+/*
+ * These aren't really machine-dependent for RTEMS.....
+ */
+
+/*
+#define MACHINE "i386"
+#define MID_MACHINE MID_I386
+*/
+
+/*
+ * Round p (pointer or byte index) up to a correctly-aligned value
+ * for all data types (int, long, ...). The result is unsigned int
+ * and must be cast to any desired pointer type.
+ */
+#define ALIGNBYTES (sizeof(int) - 1)
+#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES)
+
+#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */
+#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */
+#define PAGE_MASK (PAGE_SIZE-1)
+#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
+
+#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t)))
+#define PDRSHIFT 22 /* LOG2(NBPDR) */
+#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */
+
+#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
+#define DEV_BSIZE (1<<DEV_BSHIFT)
+
+#define BLKDEV_IOSIZE 2048
+#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
+
+#define UPAGES 2 /* pages of u-area */
+
+/*
+ * Constants related to network buffer management.
+ * MCLBYTES must be no larger than CLBYTES (the software page size), and,
+ * on machines that exchange pages of input or output buffers with mbuf
+ * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
+ * of the hardware page size.
+ */
+#ifndef MSIZE
+#define MSIZE 128 /* size of an mbuf */
+#endif /* MSIZE */
+
+#ifndef MCLSHIFT
+#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
+#endif /* MCLSHIFT */
+#define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */
+#define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */
+
+/*
+ * Some macros for units conversion
+ */
+
+/* clicks to bytes */
+#define ctob(x) ((x)<<PAGE_SHIFT)
+
+/* bytes to clicks */
+#define btoc(x) (((unsigned)(x)+PAGE_MASK)>>PAGE_SHIFT)
+
+/*
+ * btodb() is messy and perhaps slow because `bytes' may be an off_t. We
+ * want to shift an unsigned type to avoid sign extension and we don't
+ * want to widen `bytes' unnecessarily. Assume that the result fits in
+ * a daddr_t.
+ */
+#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
+ (sizeof (bytes) > sizeof(long) \
+ ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
+ : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
+
+#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
+ ((off_t)(db) << DEV_BSHIFT)
+
+/*
+ * Mach derived conversion macros
+ */
+#define trunc_page(x) ((unsigned)(x) & ~PAGE_MASK)
+#define round_page(x) ((((unsigned)(x)) + PAGE_MASK) & ~PAGE_MASK)
+
+#define atop(x) ((unsigned)(x) >> PAGE_SHIFT)
+#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT)
+
+#endif /* !_MACHINE_PARAM_H_ */
diff --git a/cpukit/libnetworking/machine/types.h b/cpukit/libnetworking/machine/types.h
new file mode 100644
index 0000000000..1f9ee143a5
--- /dev/null
+++ b/cpukit/libnetworking/machine/types.h
@@ -0,0 +1,32 @@
+/*
+ * This file will have to be incorparated into the RTEMS source
+ * tree (probably in the existing <machine/types.h> so that these
+ * contents are included when an application source file includes
+ * <sys/types.h>.
+ */
+
+#ifndef _MACHINE_TYPES_H_
+#define _MACHINE_TYPES_H_
+
+#include <rtems.h>
+#include <machine/endian.h>
+
+typedef rtems_signed64 int64_t;
+typedef rtems_signed32 int32_t;
+typedef rtems_signed16 int16_t;
+typedef rtems_signed8 int8_t;
+
+typedef rtems_unsigned64 u_int64_t;
+typedef rtems_unsigned32 u_int32_t;
+typedef rtems_unsigned16 u_int16_t;
+typedef rtems_unsigned8 u_int8_t;
+
+#define _CLOCK_T_ unsigned long
+#define _TIME_T_ long
+
+#ifdef _COMPILING_BSD_KERNEL_
+#include <rtems/rtems_bsdnet_internal.h>
+#include <rtems/rtems_bsdnet.h>
+#endif
+
+#endif /* _MACHINE_TYPES_H_ */
diff --git a/cpukit/libnetworking/machine/vmparam.h b/cpukit/libnetworking/machine/vmparam.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cpukit/libnetworking/machine/vmparam.h