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

Subversion Repositories or1k_old

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /or1k_old/trunk/rc203soc/sw/uClinux/arch/i960/lib
    from Rev 1765 to Rev 1782
    Reverse comparison

Rev 1765 → Rev 1782

/bzero.c
0,0 → 1,78
 
#include <linux/types.h>
#include <linux/string.h>
 
/* Optimization used unaligned access, so it had to go. */
 
void bzero(void * s, size_t count) {
memset(s, '\0', count);
}
 
#if 0
void * memset(void * s, int c, size_t count)
{
void *xs = s;
size_t temp, temp1;
 
if (!count)
return xs;
c &= 0xff;
c |= c << 8;
c |= c << 16;
if ((long) s & 1)
{
char *cs = s;
*cs++ = c;
s = cs;
count--;
}
if (count > 2 && (long) s & 2)
{
short *ss = s;
*ss++ = c;
s = ss;
count -= 2;
}
temp = count >> 2;
if (temp)
{
long *ls = s;
 
__asm__ __volatile__("movel %1,%2\n\t"
"andw #7,%2\n\t"
"lsrl #3,%1\n\t"
"negw %2\n\t"
"jmp %%pc@(2f,%2:w:2)\n\t"
"1:\t"
"movel %3,%0@+\n\t"
"movel %3,%0@+\n\t"
"movel %3,%0@+\n\t"
"movel %3,%0@+\n\t"
"movel %3,%0@+\n\t"
"movel %3,%0@+\n\t"
"movel %3,%0@+\n\t"
"movel %3,%0@+\n\t"
"2:\t"
"dbra %1,1b\n\t"
"clrw %1\n\t"
"subql #1,%1\n\t"
"jpl 1b\n\t"
: "=a" (ls), "=d" (temp), "=&d" (temp1)
: "d" (c), "0" (ls), "1" (temp)
);
s = ls;
}
if (count & 2)
{
short *ss = s;
*ss++ = c;
s = ss;
}
if (count & 1)
{
char *cs = s;
*cs = c;
}
return xs;
}
#endif
/checksum.c
0,0 → 1,172
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system.
*
* IP/TCP/UDP checksumming routines
*
* Authors: Keith Adams, <kma@cse.ogi.edu>
* Jorge Cwik, <jorge@laser.satlink.net>
* Arnt Gulbrandsen, <agulbra@nvg.unit.no>
* Tom May, <ftom@netcom.com>
* Andreas Schwab, <schwab@issan.informatik.uni-dortmund.de>
* Lots of code moved from tcp.c and ip.c; see those files
* for more names.
*
*/
#include <net/checksum.h>
 
#if 1
static unsigned long do_csum(const unsigned char * buff, int len)
{
int odd, count;
unsigned long result = 0;
 
if (len <= 0)
goto out;
odd = 1 & (unsigned long) buff;
if (odd) {
result = *buff;
len--;
buff++;
}
count = len >> 1; /* nr of 16-bit words.. */
if (count) {
if (2 & (unsigned long) buff) {
result += *(unsigned short *) buff;
count--;
len -= 2;
buff += 2;
}
count >>= 1; /* nr of 32-bit words.. */
if (count) {
#if 1
unsigned long carry = 0;
do {
unsigned long w = *(unsigned long *) buff;
count--;
buff += 4;
result += carry;
result += w;
carry = (w > result);
} while (count);
result += carry;
#else
asm("cmpo 0, 1"); /* clear carry */
do {
unsigned long w = *(unsigned long*) buff;
count--;
buff += 4;
asm("addc 0, %0, %0\n\t" /* r += carry */
"cmpo 0, 1\n\t" /* reset c */
"addc %1, %0, %0" /* r += w */
: "=&r"(result)
: "r"(w), "0"(result));
} while (count);
asm("addc 0, %0, %0" /* result += carry */
: "=r"(result) : "0"(result));
#endif
result = (result & 0xffff) + (result >> 16);
}
if (len & 2) {
result += *(unsigned short *) buff;
buff += 2;
}
}
if (len & 1)
result += *buff;
 
result = from32to16(result);
if (odd)
return ntohs(result);
out:
return result;
}
#else
 
/*
* Naive implementation stolen from Stevens
*/
static unsigned long do_csum(const unsigned char * buff, int len)
{
long sum=0;
while (len > 1) {
sum += *((unsigned short*)buff)++;
if (sum & (1<<31))
sum = (sum & 0xffff);
len -= 2;
}
if (len)
sum += (unsigned short) *buff;
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
 
return sum;
}
#endif
 
/*
* This is a version of ip_compute_csum() optimized for IP headers,
* which always checksum on 4 octet boundaries.
*/
unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl)
{
return ~do_csum(iph,ihl*4);
}
 
/*
* computes the checksum of a memory block at buff, length len,
* and adds in "sum" (32-bit)
*
* returns a 32-bit number suitable for feeding into itself
* or csum_tcpudp_magic
*
* this function must be called with even lengths, except
* for the last fragment, which may be odd
*
* it's best to have buff aligned on a 32-bit boundary
*/
unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
{
unsigned int result = do_csum(buff, len);
 
/* add in old sum, and carry.. */
result += sum;
/* 16+c bits -> 16 bits */
result = (result & 0xffff) + (result >> 16);
return result;
}
 
/*
* this routine is used for miscellaneous IP-like checksums, mainly
* in icmp.c
*/
unsigned short ip_compute_csum(const unsigned char * buff, int len)
{
return ~do_csum(buff,len);
}
 
 
/*
* copy from fs while checksumming, otherwise like csum_partial
*/
 
unsigned int
csum_partial_copy_fromuser(const char *src, char *dst, int len, int sum)
{
memcpy(dst, src, len);
return csum_partial(dst, len, sum);
}
/*
* copy from ds while checksumming, otherwise like csum_partial
*/
 
unsigned int
csum_partial_copy(const char *src, char *dst, int len, int sum)
{
memcpy(dst, src, len);
return csum_partial(dst, len, sum);
}
/abs.c
0,0 → 1,12
/*
* FILE: abs.c
* AUTHOR: kma
* DESCR: absolute value; we need this
*/
 
#ident "$Id: abs.c,v 1.1 2005-12-20 09:42:40 jcastillo Exp $"
 
int abs(int j)
{
return (j<0)? -j : j;
}
/__adddi3.S
0,0 → 1,41
/*
* Copyright (C) 1999 Keith Adams <kma@cse.ogi.edu>
* Oregon Graduate Institute
*/
 
#include <linux/linkage.h>
 
/*
* 64-bit math routines that gcc needs but doesn't have.
*/
 
/*
* 64-bit addition.
*
* registers:
* g0 = low word of arg 1, g1 = hi word of arg 1
* g2 = low word of arg 2, g3 = hi word of arg 2
* it wants result in g0-g1
*/
#define AC_OVERFLOW_BIT 8
.globl SYMBOL_NAME(__adddi3)
SYMBOL_NAME_LABEL(__adddi3)
cmpo 1, 0
addc g0, g2, g0
addc g1, g3, g1
ret
 
/*
* 64-bit subtraction: a-b = c
*
* registers in:
* g0-g1 = a; g2-g3 = b
* registers out:
* g0-g1 = c
*/
.globl SYMBOL_NAME(__subdi3)
SYMBOL_NAME_LABEL(__subdi3)
cmpo 1, 0
subc g2, g0, g0
subc g3, g1, g1
ret
/Makefile
0,0 → 1,11
#
# Makefile for m68k-specific library files..
#
 
.S.o:
$(CC) $(AFLAGS) -D__ASSEMBLY__ -traditional -c $< -o $@
 
L_TARGET = lib.a
L_OBJS = abs.o ashrdi3.o checksum.o __adddi3.o
 
include $(TOPDIR)/Rules.make
/ashrdi3.c
0,0 → 1,65
/* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */
/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
 
This file is part of GNU CC.
 
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
 
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
 
#include <linux/stddef.h>
 
#define BITS_PER_UNIT 8
 
typedef int SItype __attribute__ ((mode (SI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI)));
typedef int word_type __attribute__ ((mode (__word__)));
 
struct DIstruct {SItype high, low;};
 
typedef union
{
struct DIstruct s;
DItype ll;
} DIunion;
 
DItype
__ashrdi3 (DItype u, word_type b)
{
DIunion w;
word_type bm;
DIunion uu;
 
if (b == 0)
return u;
 
uu.ll = u;
 
bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
if (bm <= 0)
{
/* w.s.high = 1..1 or 0..0 */
w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1);
w.s.low = uu.s.high >> -bm;
}
else
{
USItype carries = (USItype)uu.s.high << bm;
w.s.high = uu.s.high >> b;
w.s.low = ((USItype)uu.s.low >> b) | carries;
}
 
return w.ll;
}

powered by: WebSVN 2.1.0

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