OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/rtos/rtems/c/src/libnetworking/machine
    from Rev 30 to Rev 173
    Reverse comparison

Rev 30 → Rev 173

/endian.h
0,0 → 1,64
/*
* $Id: endian.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
#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_ */
/param.h
0,0 → 1,92
/*
* $Id: param.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
#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_ */
/limits.h
0,0 → 1,6
/*
* $Id: limits.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
/* intentionally empty file */
 
/Makefile.am
0,0 → 1,23
##
## $Id: Makefile.am,v 1.2 2001-09-27 12:01:53 chris Exp $
##
 
AUTOMAKE_OPTIONS = foreign 1.4
 
H_FILES = conf.h cpu.h cpufunc.h endian.h in_cksum.h limits.h param.h \
types.h vmparam.h
 
noinst_HEADERS = $(H_FILES)
 
PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine \
$(H_FILES:%=$(PROJECT_INCLUDE)/machine/%)
 
$(PROJECT_INCLUDE)/machine:
@$(mkinstalldirs) $@
 
$(PROJECT_INCLUDE)/machine/%.h: %.h
$(INSTALL_DATA) $< $@
 
all-local: $(PREINSTALL_FILES)
 
include $(top_srcdir)/../../../automake/local.am
/cpufunc.h
0,0 → 1,5
/*
* $Id: cpufunc.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
/* intentionally empty file */
/vmparam.h
0,0 → 1,6
/*
* $Id: vmparam.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
/* intentionally empty file */
 
/types.h
0,0 → 1,34
/*
* 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>.
*
* $Id: types.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
#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_ */
/conf.h
0,0 → 1,6
/*
* $Id: conf.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
/* intentionally empty file */
 
/cpu.h
0,0 → 1,6
/*
* $Id: cpu.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
/* intentionally empty file */
 
/in_cksum.h
0,0 → 1,218
/*
* 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: in_cksum.h,v 1.2 2001-09-27 12:01:53 chris Exp $
*/
 
#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.
*/
 
/*
* Optimized version for the i386 family
*/
 
#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__ volatile ("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
#define ADDC(n) \
__asm__ volatile ("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
#define MOP \
__asm__ volatile ("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));
}
 
/*
* Optimized version for the MC68xxx and Coldfire families
*/
 
#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;
}
 
/*
* Optimized version for the PowerPC family
*/
 
#elif (defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__)))
 
static __inline u_int
in_cksum_hdr(const struct ip *ip)
{
register u_int sum = 0;
register u_int tmp;
 
#define ADD(n) \
__asm__ volatile ("addc %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
#define ADDC(n) \
__asm__ volatile ("adde %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
#define MOP \
__asm__ volatile ("addic %0,%0,0" : "=r" (sum) : "0" (sum))
 
tmp = *(((u_int *) ip)); ADD(tmp);
tmp = *(((u_int *) ip) + 1); ADDC(tmp);
tmp = *(((u_int *) ip) + 2); ADDC(tmp);
tmp = *(((u_int *) ip) + 3); ADDC(tmp);
tmp = *(((u_int *) ip) + 4); ADDC(tmp);
tmp = 0; ADDC(tmp);
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));
}
 
/*
* SPARC Version
*/
 
#elif (defined(__GNUC__) && defined(sparc))
 
static __inline u_int
in_cksum_hdr(const struct ip *ip)
{
register u_int sum = 0;
register u_int tmp_o2;
register u_int tmp_o3;
 
__asm__ volatile ("
ld [%0], %1 ; \
ld [%0+4], %2 ; \
addcc %1, %2, %1 ; \
ld [%0+8], %2 ; \
addxcc %1, %2, %1 ; \
ld [%0+12], %2 ; \
addxcc %1, %2, %1 ; \
ld [%0+16], %2 ; \
addxcc %1, %2, %1 ; \
set 0x0ffff, %3 ; \
srl %1, 16, %2 ; \
and %1, %3, %1 ; \
addx %1, %2, %1 ; \
srl %1, 16, %1 ; \
add %1, %%g0, %1 ; \
neg %1 ; \
and %1, %3, %1 ; \
" : "=r" (ip), "=r" (sum), "=r" (tmp_o2), "=r" (tmp_o3)
: "0" (ip), "1" (sum)
);
return sum;
}
 
#define in_cksum_update(ip) \
do { \
int __tmpsum; \
__tmpsum = (int)ntohs(ip->ip_sum) + 256; \
ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \
} while(0)
/*
* Here is the generic, portable, inefficient algorithm.
*/
 
#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_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.