Remove libkern, leave just header.

Boot stuff dependencies from NetBSD.

Patch by Antoine Leca. Relocated to src/sys.

The port is using the same libminc.a as usual MINIX services (and does
not use NetBSD libkern); the headers imported from NetBSD sys/ tree
have been kept to a minimum (still numbers higher than 30 though.)

Note the peculiar way to use libraries (libsa, libi386, etc.): the
source code is shared, but each component builds its own copy of the
library, with its own set of preprocessor defines.
This commit is contained in:
Evgeniy Ivanov 2012-01-25 16:29:07 +04:00 committed by Ben Gras
parent 002fecdd9e
commit 7f2d47d84c
156 changed files with 6819 additions and 17149 deletions

View file

@ -6,6 +6,5 @@ INCS+= elf32.h elf64.h elf_common.h elf_generic.h \
ioc_block.h ioc_fbd.h ioc_file.h ioc_tape.h ioc_disk.h \
ioc_memory.h ioc_sound.h ioc_tty.h \
kbdio.h mtio.h svrctl.h video.h vm.h procfs.h elf_core.h exec_elf.h \
disk.h dkio.h ioccom.h mutex.h iostat.h disklabel.h bootblock.h \
dkbad.h
disk.h dkio.h ioccom.h mutex.h iostat.h disklabel.h disklabel_gpt.h \
bootblock.h dkbad.h

View file

@ -0,0 +1,170 @@
/* $NetBSD: disklabel_gpt.h,v 1.7 2008/11/12 22:50:22 thorpej Exp $ */
/*
* Copyright (c) 2002 Marcel Moolenaar
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* $FreeBSD: src/sys/sys/gpt.h,v 1.7 2004/08/02 18:46:52 marcel Exp $
*/
#ifndef _SYS_DISKLABEL_GPT_H_
#define _SYS_DISKLABEL_GPT_H_
/*
* Definitions for the EFI GUID Partition Table disk partitioning scheme.
*
* NOTE: As EFI is an Intel specification, all fields are stored in
* little-endian byte-order.
*/
/*
* GUID Partition Table Header
*/
struct gpt_hdr {
int8_t hdr_sig[8]; /* identifies GUID Partition Table */
uint32_t hdr_revision; /* GPT specification revsion */
uint32_t hdr_size; /* size of GPT Header */
uint32_t hdr_crc_self; /* CRC32 of GPT Header */
uint32_t hdr__rsvd0; /* must be zero */
uint64_t hdr_lba_self; /* LBA that contains this Header */
uint64_t hdr_lba_alt; /* LBA of backup GPT Header */
uint64_t hdr_lba_start; /* first LBA usable for partitions */
uint64_t hdr_lba_end; /* last LBA usable for partitions */
uint8_t hdr_guid[16]; /* GUID to identify the disk */
uint64_t hdr_lba_table; /* first LBA of GPE array */
uint32_t hdr_entries; /* number of entries in GPE array */
uint32_t hdr_entsz; /* size of each GPE */
uint32_t hdr_crc_table; /* CRC32 of GPE array */
/*
* The remainder of the block that contains the GPT Header
* is reserved by EFI for future GPT Header expansion, and
* must be zero.
*/
};
#define GPT_HDR_SIG "EFI PART"
#define GPT_HDR_REVISION 0x00010000 /* 1.0 */
#define GPT_HDR_BLKNO 1
#define GPT_HDR_SIZE 0x5c
/*
* GUID Partition Entry
*/
struct gpt_ent {
uint8_t ent_type[16]; /* partition type GUID */
uint8_t ent_guid[16]; /* unique partition GUID */
uint64_t ent_lba_start; /* start of partition */
uint64_t ent_lba_end; /* end of partition */
uint64_t ent_attr; /* partition attributes */
uint16_t ent_name[36]; /* partition name in UNICODE-16 */
};
#define GPT_ENT_ATTR_PLATFORM (1ULL << 0) /* required for platform
to function */
/*
* Partition types defined by the EFI specification:
*
* GPT_ENT_TYPE_UNUSED Unused Entry
* GPT_ENT_TYPE_EFI EFI System Partition
* GPT_ENT_TYPE_MBR Partition containing legacy MBR
*/
#define GPT_ENT_TYPE_UNUSED \
{0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}
#define GPT_ENT_TYPE_EFI \
{0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}
#define GPT_ENT_TYPE_MBR \
{0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}}
/*
* Partition types defined by other operating systems.
*/
#define GPT_ENT_TYPE_NETBSD_SWAP \
{0x49f48d32,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
#define GPT_ENT_TYPE_NETBSD_FFS \
{0x49f48d5a,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
#define GPT_ENT_TYPE_NETBSD_LFS \
{0x49f48d82,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
#define GPT_ENT_TYPE_NETBSD_RAIDFRAME \
{0x49f48daa,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
#define GPT_ENT_TYPE_NETBSD_CCD \
{0x2db519c4,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
#define GPT_ENT_TYPE_NETBSD_CGD \
{0x2db519ec,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
#define GPT_ENT_TYPE_FREEBSD \
{0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
#define GPT_ENT_TYPE_FREEBSD_SWAP \
{0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
#define GPT_ENT_TYPE_FREEBSD_UFS \
{0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
#define GPT_ENT_TYPE_FREEBSD_VINUM \
{0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
#define GPT_ENT_TYPE_FREEBSD_ZFS \
{0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
#define GPT_ENT_TYPE_FREEBSD_BOOT \
{0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}}
/*
* The following are unused but documented here to avoid reuse.
*
* GPT_ENT_TYPE_FREEBSD_UFS2 \
* {0x516e7cb7,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
*/
#define GPT_ENT_TYPE_MS_RESERVED \
{0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,{0xf9,0x2d,0xf0,0x02,0x15,0xae}}
#define GPT_ENT_TYPE_MS_BASIC_DATA \
{0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}}
#define GPT_ENT_TYPE_MS_LDM_METADATA \
{0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,{0xe1,0xe9,0x04,0x34,0xcf,0xb3}}
#define GPT_ENT_TYPE_MS_LDM_DATA \
{0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,{0x33,0x11,0x71,0x4a,0x69,0xad}}
#define GPT_ENT_TYPE_LINUX_DATA_OLD GPT_ENT_TYPE_MS_BASIC_DATA
#define GPT_ENT_TYPE_LINUX_DATA \
{0x0fc63daf,0x8483,0x4772,0x8e,0x79,{0x3d,0x69,0xd8,0x47,0x7d,0xe4}}
#define GPT_ENT_TYPE_LINUX_RAID \
{0xa19d880f,0x05fc,0x4d3b,0xa0,0x06,{0x74,0x3f,0x0f,0x84,0x91,0x1e}}
#define GPT_ENT_TYPE_LINUX_SWAP \
{0x0657fd6d,0xa4ab,0x43c4,0x84,0xe5,{0x09,0x33,0xc8,0x4b,0x4f,0x4f}}
#define GPT_ENT_TYPE_LINUX_LVM \
{0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}}
#define GPT_ENT_TYPE_APPLE_HFS \
{0x48465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
#define GPT_ENT_TYPE_APPLE_UFS \
{0x55465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
#define GPT_ENT_TYPE_MINIX_MFS \
{0xb7aadf00,0xde27,0x11ca,0xa5,0x74,{0x56,0x72,0x69,0x6a,0x65,0x55}}
/*
* Used by GRUB 2.
*/
#define GPT_ENT_TYPE_BIOS \
{0x21686148,0x6449,0x6e6f,0x74,0x4e,{0x65,0x65,0x64,0x45,0x46,0x49}}
#endif /* _SYS_DISKLABEL_GPT_H_ */

View file

@ -7,6 +7,7 @@ PROG?= boot
NEWVERSWHAT?= "BIOS Boot"
VERSIONFILE?= ${.CURDIR}/../version
ACTIVE_CC?= ${CC}
AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c
@ -57,6 +58,10 @@ COPTS+= -ffreestanding
CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
CPPFLAGS+= -nostdinc -D_STANDALONE
CPPFLAGS+= -I$S
.if defined(__MINIX)
CPPFLAGS+= -I${DESTDIR}/usr/include
CPPFLAGS+= -I${.CURDIR}/../../../../../../
.endif
CPPFLAGS+= -DSUPPORT_PS2
CPPFLAGS+= -DDIRECT_SERIAL
@ -119,15 +124,21 @@ SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
.include "${S}/lib/libsa/Makefile.inc"
LIBSA= ${SALIB}
.ifndef __MINIX
### find out what to use for libkern
KERN_AS= library
.include "${S}/lib/libkern/Makefile.inc"
LIBKERN= ${KERNLIB}
.else
# MINIX
LIBKERN= # use MINIX minc
.endif
### find out what to use for libz
Z_AS= library
.include "${S}/lib/libz/Makefile.inc"
LIBZ= ${ZLIB}
## XXX ??? LIBZ is set up as usual, we use the regular one
cleandir distclean: .WAIT cleanlibdir
@ -149,7 +160,7 @@ vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot
${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
${_MKTARGET_LINK}
bb="$$( ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 -Wl,-cref \
${OBJS} ${LIBLIST} | ( \
${OBJS} ${LIBLIST} ${LDADD} | ( \
while read symbol file; do \
[ -z "$$file" ] && continue; \
[ "$$symbol" = real_to_prot ] && break; \
@ -165,7 +176,11 @@ ${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
done; \
) )"; \
${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 \
-Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST}
-Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST} ${LDADD}
${OBJCOPY} -O binary ${PROG}.syms ${PROG}
.ifndef __MINIX
.include <bsd.prog.mk>
.else
.include <minix.service.mk>
.endif

View file

@ -1,13 +1,20 @@
# $NetBSD: Makefile,v 1.14 2010/12/29 17:44:03 jakllsch Exp $
SUBDIR=
#SUBDIR= bootxx_ffsv1 .WAIT bootxx_ffsv2 bootxx_lfsv1 bootxx_lfsv2
#SUBDIR+=bootxx_msdos bootxx_ustarfs
# Ext2fs doesn't have enough free space (it has only 1KB)
# to store this primary bootloader, but we can put it into
# an independent small 'boot' partition as NetBSD/hp300 does.
#SUBDIR+=bootxx_ext2fs
SUBDIR=bootxx_minixfs3
#
# However MINIX implements a solution using the empty space before subpartition
.if !empty(CC:M*pcc)
# PCC cannot compile bootxx_ext2fs because it lacks regparm aka compactcall
SUBDIR+=bootxx_minixfs3
.else
SUBDIR+=bootxx_ext2fs bootxx_minixfs3
.endif
LIBOBJ= ${.OBJDIR}
.MAKEOVERRIDES+= LIBOBJ

View file

@ -2,6 +2,7 @@
S= ${.CURDIR}/../../../../..
ACTIVE_CC?= ${CC}
AFLAGS.bootxx.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
AFLAGS.label.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
AFLAGS.pbr.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
@ -79,6 +80,10 @@ CPUFLAGS= -march=i386 -mtune=i386
CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
CPPFLAGS+= -nostdinc -D_STANDALONE
CPPFLAGS+= -I$S
.if defined(__MINIX)
CPPFLAGS+= -I${DESTDIR}/usr/include
CPPFLAGS+= -I${.CURDIR}/../../../../../../
.endif
CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
-DLIBSA_NO_TWIDDLE \
@ -119,14 +124,21 @@ LIBI386= ${I386LIB}
### find out what to use for libsa
SA_AS= library
SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
.if defined(__MINIX)
SAMISCMAKEFLAGS+="SA_INCLUDE_NET=no"
.endif
.include "${S}/lib/libsa/Makefile.inc"
LIBSA= ${SALIB}
.if !defined(__MINIX)
### find out what to use for libkern
KERN_AS= library
.include "${S}/lib/libkern/Makefile.inc"
LIBKERN= ${KERNLIB}
.else
# MINIX
LIBKERN= # use MINIX minc
.endif
cleandir distclean: .WAIT cleanlibdir
@ -140,7 +152,7 @@ CLEANFILES+= ${PROG}.sym ${PROG}.map
${PROG}: ${OBJS} ${LIBLIST}
${_MKTARGET_LINK}
${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
-Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
-Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST} ${LDADD}
${OBJCOPY} -O binary ${PROG}.sym ${PROG}
@ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
@ -155,4 +167,8 @@ ${PROG}: ${OBJS} ${LIBLIST}
echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
fi
.ifndef __MINIX
.include <bsd.prog.mk>
.else
.include <minix.service.mk>
.endif

View file

@ -39,7 +39,11 @@ __RCSID("$NetBSD: boot1.c,v 1.20 2011/01/06 01:08:48 jakllsch Exp $");
#include <sys/param.h>
#include <sys/bootblock.h>
#include <sys/disklabel.h>
#ifndef __minix
#include <dev/raidframe/raidframevar.h> /* For RF_PROTECTED_SECTORS */
#else
#define RF_PROTECTED_SECTORS 64
#endif
#define XSTR(x) #x
#define STR(x) XSTR(x)
@ -72,7 +76,11 @@ boot1(uint32_t biosdev, uint64_t *sector)
bios_sector = *sector;
d.dev = biosdev;
#ifdef __minix
putstr("\r\nMINIX/x86 " STR(FS) " Primary Bootstrap\r\n");
#else
putstr("\r\nNetBSD/x86 " STR(FS) " Primary Bootstrap\r\n");
#endif
if (set_geometry(&d, NULL))
return "set_geometry\r\n";

View file

@ -1,13 +1,13 @@
# $NetBSD: Makefile,v 1.12 2011/05/20 22:29:55 joerg Exp $
S= ${.CURDIR}/../../../..
AFLAGS.cdboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
NOMAN= # defined
.include <bsd.own.mk>
STRIPFLAG= # nothing
TOOL_SED?= sed
NM?= nm
LIBCRT0= # nothing
LIBCRTBEGIN= # nothing
@ -26,7 +26,7 @@ BINMODE= 444
.PATH: ${.CURDIR}/..
LDFLAGS+= -nostdlib -Wl,-e,start
CPPFLAGS+= -I. -I${.CURDIR}/../lib -I${S}
CPPFLAGS+= -I. -I${.CURDIR}/../lib # -I${S}
CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
CPPFLAGS+= -DDISABLE_KEYPRESS
@ -36,12 +36,18 @@ LDFLAGS+= -Wl,-m,elf_i386
AFLAGS+= -m32
.endif
AFLAGS+= -Wa,--divide
.if defined(_NetBSD_)
# NetBSD can be compiled from a foreign host, MINIX do not. So commented out.
# Make sys/ a local thing for benefit of cross-compilers
S= ${.CURDIR}/../../../../..
CPPFLAGS+= -I${S}
# And same for machine/; need a bit more work because of symlink
BUILDSYMLINKS+= $S/arch/i386/include machine \
$S/arch/x86/include x86
DPSRCS+= machine x86
.endif
AFLAGS+= -Wa,--divide
CLEANFILES+= ${PROG}.tmp
@ -49,7 +55,7 @@ ${PROG}: ${OBJS}
${_MKTARGET_LINK}
${CC} -o ${PROG}.tmp ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
${OBJS}
@ set -- $$( ${NM} -t d ${PROG}.tmp | grep '\<free_space\>' \
@ set -- $$( ${NM} -t d ${PROG}.tmp | grep 'free_space' \
| ${TOOL_SED} 's/^0*//' ); \
echo "#### There are $$1 free bytes in ${PROG}"
${OBJCOPY} -O binary ${PROG}.tmp ${PROG}

View file

@ -11,6 +11,7 @@ I386_INCLUDE_DOS?= no
I386_INCLUDE_BUS?= no
I386_INCLUDE_PS2?= yes
ACTIVE_CC?= ${CC}
AFLAGS.biosdelay.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
AFLAGS.biosgetrtc.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
AFLAGS.biosgetsystime.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}

View file

@ -0,0 +1,241 @@
/* $NetBSD: bootinfo.h,v 1.19 2011/11/28 07:56:54 tls Exp $ */
/*
* Copyright (c) 1997
* Matthias Drochner. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
*/
#define BTINFO_BOOTPATH 0
#define BTINFO_ROOTDEVICE 1
#define BTINFO_BOOTDISK 3
#define BTINFO_NETIF 4
#define BTINFO_CONSOLE 6
#define BTINFO_BIOSGEOM 7
#define BTINFO_SYMTAB 8
#define BTINFO_MEMMAP 9
#define BTINFO_BOOTWEDGE 10
#define BTINFO_MODULELIST 11
#define BTINFO_FRAMEBUFFER 12
#define BTINFO_USERCONFCOMMANDS 13
#ifndef _LOCORE
struct btinfo_common {
int len;
int type;
};
struct btinfo_bootpath {
struct btinfo_common common;
char bootpath[80];
};
struct btinfo_rootdevice {
struct btinfo_common common;
char devname[16];
};
struct btinfo_bootdisk {
struct btinfo_common common;
int labelsector; /* label valid if != -1 */
struct {
uint16_t type, checksum;
char packname[16];
} label;
int biosdev;
int partition;
};
struct btinfo_bootwedge {
struct btinfo_common common;
int biosdev;
daddr_t startblk;
uint64_t nblks;
daddr_t matchblk;
uint64_t matchnblks;
uint8_t matchhash[16]; /* MD5 hash */
} __packed;
struct btinfo_netif {
struct btinfo_common common;
char ifname[16];
int bus;
#define BI_BUS_ISA 0
#define BI_BUS_PCI 1
union {
unsigned int iobase; /* ISA */
unsigned int tag; /* PCI, BIOS format */
} addr;
};
struct btinfo_console {
struct btinfo_common common;
char devname[16];
int addr;
int speed;
};
struct btinfo_symtab {
struct btinfo_common common;
int nsym;
int ssym;
int esym;
};
struct bi_memmap_entry {
uint64_t addr; /* beginning of block */ /* 8 */
uint64_t size; /* size of block */ /* 8 */
uint32_t type; /* type of block */ /* 4 */
} __packed; /* == 20 */
#define BIM_Memory 1 /* available RAM usable by OS */
#define BIM_Reserved 2 /* in use or reserved by the system */
#define BIM_ACPI 3 /* ACPI Reclaim memory */
#define BIM_NVS 4 /* ACPI NVS memory */
struct btinfo_memmap {
struct btinfo_common common;
int num;
struct bi_memmap_entry entry[1]; /* var len */
};
#if HAVE_NBTOOL_CONFIG_H
#include <nbinclude/sys/bootblock.h>
#else
#include <sys/bootblock.h>
#endif /* HAVE_NBTOOL_CONFIG_H */
/*
* Structure describing disk info as seen by the BIOS.
*/
struct bi_biosgeom_entry {
int sec, head, cyl; /* geometry */
uint64_t totsec; /* LBA sectors from ext int13 */
int flags, dev; /* flags, BIOS device # */
#define BI_GEOM_INVALID 0x000001
#define BI_GEOM_EXTINT13 0x000002
#ifdef BIOSDISK_EXTINFO_V3
#define BI_GEOM_BADCKSUM 0x000004 /* v3.x checksum invalid */
#define BI_GEOM_BUS_MASK 0x00ff00 /* connecting bus type */
#define BI_GEOM_BUS_ISA 0x000100
#define BI_GEOM_BUS_PCI 0x000200
#define BI_GEOM_BUS_OTHER 0x00ff00
#define BI_GEOM_IFACE_MASK 0xff0000 /* interface type */
#define BI_GEOM_IFACE_ATA 0x010000
#define BI_GEOM_IFACE_ATAPI 0x020000
#define BI_GEOM_IFACE_SCSI 0x030000
#define BI_GEOM_IFACE_USB 0x040000
#define BI_GEOM_IFACE_1394 0x050000 /* Firewire */
#define BI_GEOM_IFACE_FIBRE 0x060000 /* Fibre channel */
#define BI_GEOM_IFACE_OTHER 0xff0000
unsigned int cksum; /* MBR checksum */
unsigned int interface_path; /* ISA iobase PCI bus/dev/fun */
uint64_t device_path;
int res0; /* future expansion; 0 now */
#else
unsigned int cksum; /* MBR checksum */
int res0, res1, res2, res3; /* future expansion; 0 now */
#endif
struct mbr_partition dosparts[MBR_PART_COUNT]; /* MBR itself */
} __packed;
struct btinfo_biosgeom {
struct btinfo_common common;
int num;
struct bi_biosgeom_entry disk[1]; /* var len */
};
struct bi_modulelist_entry {
char path[80];
int type;
int len;
uint32_t base;
};
#define BI_MODULE_NONE 0x00
#define BI_MODULE_ELF 0x01
#define BI_MODULE_IMAGE 0x02
#define BI_MODULE_RND 0x03
struct btinfo_modulelist {
struct btinfo_common common;
int num;
uint32_t endpa;
/* bi_modulelist_entry list follows */
};
struct btinfo_framebuffer {
struct btinfo_common common;
uint64_t physaddr;
uint32_t flags;
uint32_t width;
uint32_t height;
uint16_t stride;
uint8_t depth;
uint8_t rnum;
uint8_t gnum;
uint8_t bnum;
uint8_t rpos;
uint8_t gpos;
uint8_t bpos;
uint16_t vbemode;
uint8_t reserved[14];
};
struct bi_userconfcommand {
char text[80];
};
struct btinfo_userconfcommands {
struct btinfo_common common;
int num;
/* bi_userconfcommand list follows */
};
#endif /* _LOCORE */
#ifdef _KERNEL
#define BOOTINFO_MAXSIZE 4096
#ifndef _LOCORE
/*
* Structure that holds the information passed by the boot loader.
*/
struct bootinfo {
/* Number of bootinfo_* entries in bi_data. */
uint32_t bi_nentries;
/* Raw data of bootinfo entries. The first one (if any) is
* found at bi_data[0] and can be casted to (bootinfo_common *).
* Once this is done, the following entry is found at 'len'
* offset as specified by the previous entry. */
uint8_t bi_data[BOOTINFO_MAXSIZE - sizeof(uint32_t)];
};
extern struct bootinfo bootinfo;
void *lookup_bootinfo(int);
#endif /* _LOCORE */
#endif /* _KERNEL */

516
sys/arch/x86/include/cpu.h Normal file
View file

@ -0,0 +1,516 @@
/* $NetBSD: cpu.h,v 1.45 2011/12/30 17:57:49 cherry Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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. 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.
*
* @(#)cpu.h 5.4 (Berkeley) 5/9/91
*/
#ifndef _X86_CPU_H_
#define _X86_CPU_H_
#if defined(_KERNEL) || defined(_STANDALONE)
#include <sys/types.h>
#else
#include <stdbool.h>
#endif /* _KERNEL || _STANDALONE */
#if defined(_KERNEL) || defined(_KMEMUSER)
#if defined(_KERNEL_OPT)
#include "opt_xen.h"
#ifdef i386
#include "opt_user_ldt.h"
#include "opt_vm86.h"
#endif
#endif
/*
* Definitions unique to x86 cpu support.
*/
#include <machine/frame.h>
#include <machine/pte.h>
#include <machine/segments.h>
#include <machine/tss.h>
#include <machine/intrdefs.h>
#include <x86/cacheinfo.h>
#include <sys/cpu_data.h>
#include <sys/evcnt.h>
#include <sys/device_if.h> /* for device_t */
#ifdef XEN
#include <xen/xen-public/xen.h>
#include <xen/xen-public/event_channel.h>
#endif /* XEN */
struct intrsource;
struct pmap;
struct device;
#ifdef __x86_64__
#define i386tss x86_64_tss
#endif
#define NIOPORTS 1024 /* # of ports we allow to be mapped */
#define IOMAPSIZE (NIOPORTS / 8) /* I/O bitmap size in bytes */
/*
* a bunch of this belongs in cpuvar.h; move it later..
*/
struct cpu_info {
struct cpu_data ci_data; /* MI per-cpu data */
device_t ci_dev; /* pointer to our device */
struct cpu_info *ci_self; /* self-pointer */
volatile struct vcpu_info *ci_vcpu; /* for XEN */
void *ci_tlog_base; /* Trap log base */
int32_t ci_tlog_offset; /* Trap log current offset */
/*
* Will be accessed by other CPUs.
*/
struct cpu_info *ci_next; /* next cpu */
struct lwp *ci_curlwp; /* current owner of the processor */
struct lwp *ci_fpcurlwp; /* current owner of the FPU */
int ci_fpsaving; /* save in progress */
int ci_fpused; /* XEN: FPU was used by curlwp */
cpuid_t ci_cpuid; /* our CPU ID */
int ci_cpumask; /* (1 << CPU ID) */
uint32_t ci_acpiid; /* our ACPI/MADT ID */
uint32_t ci_initapicid; /* our intitial APIC ID */
/*
* Private members.
*/
struct evcnt ci_tlb_evcnt; /* tlb shootdown counter */
struct pmap *ci_pmap; /* current pmap */
int ci_need_tlbwait; /* need to wait for TLB invalidations */
int ci_want_pmapload; /* pmap_load() is needed */
volatile int ci_tlbstate; /* one of TLBSTATE_ states. see below */
#define TLBSTATE_VALID 0 /* all user tlbs are valid */
#define TLBSTATE_LAZY 1 /* tlbs are valid but won't be kept uptodate */
#define TLBSTATE_STALE 2 /* we might have stale user tlbs */
int ci_curldt; /* current LDT descriptor */
int ci_nintrhand; /* number of H/W interrupt handlers */
uint64_t ci_scratch;
uintptr_t ci_pmap_data[128 / sizeof(uintptr_t)];
#ifdef XEN
struct iplsource *ci_isources[NIPL];
u_long ci_evtmask[NR_EVENT_CHANNELS]; /* events allowed on this CPU */
#else
struct intrsource *ci_isources[MAX_INTR_SOURCES];
#endif
volatile int ci_mtx_count; /* Negative count of spin mutexes */
volatile int ci_mtx_oldspl; /* Old SPL at this ci_idepth */
/* The following must be aligned for cmpxchg8b. */
struct {
uint32_t ipending;
int ilevel;
} ci_istate __aligned(8);
#define ci_ipending ci_istate.ipending
#define ci_ilevel ci_istate.ilevel
int ci_idepth;
void * ci_intrstack;
uint32_t ci_imask[NIPL];
uint32_t ci_iunmask[NIPL];
uint32_t ci_flags; /* flags; see below */
uint32_t ci_ipis; /* interprocessor interrupts pending */
uint32_t sc_apic_version; /* local APIC version */
uint32_t ci_signature; /* X86 cpuid type */
uint32_t ci_vendor[4]; /* vendor string */
uint32_t ci_cpu_serial[3]; /* PIII serial number */
volatile uint32_t ci_lapic_counter;
uint32_t ci_feat_val[5]; /* X86 CPUID feature bits
* [0] basic features %edx
* [1] basic features %ecx
* [2] extended features %edx
* [3] extended features %ecx
* [4] VIA padlock features
*/
const struct cpu_functions *ci_func; /* start/stop functions */
struct trapframe *ci_ddb_regs;
u_int ci_cflush_lsize; /* CFLUSH insn line size */
struct x86_cache_info ci_cinfo[CAI_COUNT];
union descriptor *ci_gdt;
#ifdef i386
struct i386tss ci_doubleflt_tss;
struct i386tss ci_ddbipi_tss;
#endif
#ifdef PAE
uint32_t ci_pae_l3_pdirpa; /* PA of L3 PD */
pd_entry_t * ci_pae_l3_pdir; /* VA pointer to L3 PD */
#endif
#if defined(XEN) && (defined(PAE) || defined(__x86_64__))
/* Currently active user PGD (can't use rcr3() with Xen) */
pd_entry_t * ci_kpm_pdir; /* per-cpu PMD (va) */
paddr_t ci_kpm_pdirpa; /* per-cpu PMD (pa) */
#if defined(__x86_64__)
paddr_t ci_xen_current_user_pgd;
#endif /* __x86_64__ */
#endif /* XEN et.al */
char *ci_doubleflt_stack;
char *ci_ddbipi_stack;
#ifndef XEN
struct evcnt ci_ipi_events[X86_NIPI];
#else /* XEN */
struct evcnt ci_ipi_events[XEN_NIPIS];
evtchn_port_t ci_ipi_evtchn;
#endif /* XEN */
device_t ci_frequency; /* Frequency scaling technology */
device_t ci_padlock; /* VIA PadLock private storage */
device_t ci_temperature; /* Intel coretemp(4) or equivalent */
device_t ci_vm; /* Virtual machine guest driver */
struct i386tss ci_tss; /* Per-cpu TSS; shared among LWPs */
char ci_iomap[IOMAPSIZE]; /* I/O Bitmap */
int ci_tss_sel; /* TSS selector of this cpu */
/*
* The following two are actually region_descriptors,
* but that would pollute the namespace.
*/
uintptr_t ci_suspend_gdt;
uint16_t ci_suspend_gdt_padding;
uintptr_t ci_suspend_idt;
uint16_t ci_suspend_idt_padding;
uint16_t ci_suspend_tr;
uint16_t ci_suspend_ldt;
uintptr_t ci_suspend_fs;
uintptr_t ci_suspend_gs;
uintptr_t ci_suspend_kgs;
uintptr_t ci_suspend_efer;
uintptr_t ci_suspend_reg[12];
uintptr_t ci_suspend_cr0;
uintptr_t ci_suspend_cr2;
uintptr_t ci_suspend_cr3;
uintptr_t ci_suspend_cr4;
uintptr_t ci_suspend_cr8;
/* The following must be in a single cache line. */
int ci_want_resched __aligned(64);
int ci_padout __aligned(64);
};
/*
* Macros to handle (some) trapframe registers for common x86 code.
*/
#ifdef __x86_64__
#define X86_TF_RAX(tf) tf->tf_rax
#define X86_TF_RDX(tf) tf->tf_rdx
#define X86_TF_RSP(tf) tf->tf_rsp
#define X86_TF_RIP(tf) tf->tf_rip
#define X86_TF_RFLAGS(tf) tf->tf_rflags
#else
#define X86_TF_RAX(tf) tf->tf_eax
#define X86_TF_RDX(tf) tf->tf_edx
#define X86_TF_RSP(tf) tf->tf_esp
#define X86_TF_RIP(tf) tf->tf_eip
#define X86_TF_RFLAGS(tf) tf->tf_eflags
#endif
/*
* Processor flag notes: The "primary" CPU has certain MI-defined
* roles (mostly relating to hardclock handling); we distinguish
* betwen the processor which booted us, and the processor currently
* holding the "primary" role just to give us the flexibility later to
* change primaries should we be sufficiently twisted.
*/
#define CPUF_BSP 0x0001 /* CPU is the original BSP */
#define CPUF_AP 0x0002 /* CPU is an AP */
#define CPUF_SP 0x0004 /* CPU is only processor */
#define CPUF_PRIMARY 0x0008 /* CPU is active primary processor */
#define CPUF_SYNCTSC 0x0800 /* Synchronize TSC */
#define CPUF_PRESENT 0x1000 /* CPU is present */
#define CPUF_RUNNING 0x2000 /* CPU is running */
#define CPUF_PAUSE 0x4000 /* CPU is paused in DDB */
#define CPUF_GO 0x8000 /* CPU should start running */
#endif /* _KERNEL || __KMEMUSER */
#ifdef _KERNEL
/*
* We statically allocate the CPU info for the primary CPU (or,
* the only CPU on uniprocessors), and the primary CPU is the
* first CPU on the CPU info list.
*/
extern struct cpu_info cpu_info_primary;
extern struct cpu_info *cpu_info_list;
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = cpu_info_list; \
ci != NULL; ci = ci->ci_next
#define CPU_STARTUP(_ci, _target) ((_ci)->ci_func->start(_ci, _target))
#define CPU_STOP(_ci) ((_ci)->ci_func->stop(_ci))
#define CPU_START_CLEANUP(_ci) ((_ci)->ci_func->cleanup(_ci))
#if !defined(__GNUC__) || defined(_MODULE)
/* For non-GCC and modules */
struct cpu_info *x86_curcpu(void);
void cpu_set_curpri(int);
# ifdef __GNUC__
lwp_t *x86_curlwp(void) __attribute__ ((const));
# else
lwp_t *x86_curlwp(void);
# endif
#endif
#define cpu_number() (cpu_index(curcpu()))
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY)
#define X86_AST_GENERIC 0x01
#define X86_AST_PREEMPT 0x02
#define aston(l, why) ((l)->l_md.md_astpending |= (why))
#define cpu_did_resched(l) ((l)->l_md.md_astpending &= ~X86_AST_PREEMPT)
void cpu_boot_secondary_processors(void);
void cpu_init_idle_lwps(void);
void cpu_init_msrs(struct cpu_info *, bool);
void cpu_load_pmap(struct pmap *);
void cpu_broadcast_halt(void);
void cpu_kick(struct cpu_info *);
extern uint32_t cpus_attached;
#define curcpu() x86_curcpu()
#define curlwp x86_curlwp()
#define curpcb ((struct pcb *)lwp_getpcb(curlwp))
/*
* Arguments to hardclock, softclock and statclock
* encapsulate the previous machine state in an opaque
* clockframe; for now, use generic intrframe.
*/
struct clockframe {
struct intrframe cf_if;
};
/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the i386, request an ast to send us
* through trap(), marking the proc as needing a profiling tick.
*/
extern void cpu_need_proftick(struct lwp *l);
/*
* Notify the LWP l that it has a signal pending, process as soon as
* possible.
*/
extern void cpu_signotify(struct lwp *);
/*
* We need a machine-independent name for this.
*/
extern void (*delay_func)(unsigned int);
struct timeval;
#define DELAY(x) (*delay_func)(x)
#define delay(x) (*delay_func)(x)
extern int biosbasemem;
extern int biosextmem;
extern int cpu;
extern int cpuid_level;
extern int cpu_class;
extern char cpu_brand_string[];
extern int use_pae;
extern int i386_use_fxsave;
extern int i386_has_sse;
extern int i386_has_sse2;
extern void (*x86_cpu_idle)(void);
#define cpu_idle() (*x86_cpu_idle)()
/* machdep.c */
void dumpconf(void);
void cpu_reset(void);
void i386_proc0_tss_ldt_init(void);
void dumpconf(void);
void cpu_reset(void);
void x86_64_proc0_tss_ldt_init(void);
void x86_64_init_pcb_tss_ldt(struct cpu_info *);
/* longrun.c */
u_int tmx86_get_longrun_mode(void);
void tmx86_get_longrun_status(u_int *, u_int *, u_int *);
void tmx86_init_longrun(void);
/* identcpu.c */
void cpu_probe(struct cpu_info *);
void cpu_identify(struct cpu_info *);
/* cpu_topology.c */
void x86_cpu_topology(struct cpu_info *);
/* vm_machdep.c */
void cpu_proc_fork(struct proc *, struct proc *);
/* locore.s */
struct region_descriptor;
void lgdt(struct region_descriptor *);
#ifdef XEN
void lgdt_finish(void);
void i386_switch_context(lwp_t *);
#endif
struct pcb;
void savectx(struct pcb *);
void lwp_trampoline(void);
void child_trampoline(void);
#ifdef XEN
void startrtclock(void);
void xen_delay(unsigned int);
void xen_initclocks(void);
void xen_suspendclocks(void);
void xen_resumeclocks(void);
#else
/* clock.c */
void initrtclock(u_long);
void startrtclock(void);
void i8254_delay(unsigned int);
void i8254_microtime(struct timeval *);
void i8254_initclocks(void);
#endif
/* cpu.c */
void cpu_probe_features(struct cpu_info *);
/* npx.c */
void npxsave_lwp(struct lwp *, bool);
void npxsave_cpu(bool);
/* vm_machdep.c */
paddr_t kvtop(void *);
#ifdef USER_LDT
/* sys_machdep.h */
int x86_get_ldt(struct lwp *, void *, register_t *);
int x86_set_ldt(struct lwp *, void *, register_t *);
#endif
/* isa_machdep.c */
void isa_defaultirq(void);
int isa_nmi(void);
#ifdef VM86
/* vm86.c */
void vm86_gpfault(struct lwp *, int);
#endif /* VM86 */
/* consinit.c */
void kgdb_port_init(void);
/* bus_machdep.c */
void x86_bus_space_init(void);
void x86_bus_space_mallocok(void);
#endif /* _KERNEL */
#if defined(_KERNEL) || defined(_KMEMUSER)
#include <machine/psl.h> /* Must be after struct cpu_info declaration */
#endif /* _KERNEL || __KMEMUSER */
/*
* CTL_MACHDEP definitions.
*/
#define CPU_CONSDEV 1 /* dev_t: console terminal device */
#define CPU_BIOSBASEMEM 2 /* int: bios-reported base mem (K) */
#define CPU_BIOSEXTMEM 3 /* int: bios-reported ext. mem (K) */
/* CPU_NKPDE 4 obsolete: int: number of kernel PDEs */
#define CPU_BOOTED_KERNEL 5 /* string: booted kernel name */
#define CPU_DISKINFO 6 /* struct disklist *:
* disk geometry information */
#define CPU_FPU_PRESENT 7 /* int: FPU is present */
#define CPU_OSFXSR 8 /* int: OS uses FXSAVE/FXRSTOR */
#define CPU_SSE 9 /* int: OS/CPU supports SSE */
#define CPU_SSE2 10 /* int: OS/CPU supports SSE2 */
#define CPU_TMLR_MODE 11 /* int: longrun mode
* 0: minimum frequency
* 1: economy
* 2: performance
* 3: maximum frequency
*/
#define CPU_TMLR_FREQUENCY 12 /* int: current frequency */
#define CPU_TMLR_VOLTAGE 13 /* int: curret voltage */
#define CPU_TMLR_PERCENTAGE 14 /* int: current clock percentage */
#define CPU_MAXID 15 /* number of valid machdep ids */
/*
* Structure for CPU_DISKINFO sysctl call.
* XXX this should be somewhere else.
*/
#define MAX_BIOSDISKS 16
struct disklist {
int dl_nbiosdisks; /* number of bios disks */
struct biosdisk_info {
int bi_dev; /* BIOS device # (0x80 ..) */
int bi_cyl; /* cylinders on disk */
int bi_head; /* heads per track */
int bi_sec; /* sectors per track */
uint64_t bi_lbasecs; /* total sec. (iff ext13) */
#define BIFLAG_INVALID 0x01
#define BIFLAG_EXTINT13 0x02
int bi_flags;
} dl_biosdisks[MAX_BIOSDISKS];
int dl_nnativedisks; /* number of native disks */
struct nativedisk_info {
char ni_devname[16]; /* native device name */
int ni_nmatches; /* # of matches w/ BIOS */
int ni_biosmatches[MAX_BIOSDISKS]; /* indices in dl_biosdisks */
} dl_nativedisks[1]; /* actually longer */
};
#endif /* !_X86_CPU_H_ */

View file

@ -0,0 +1,82 @@
/* $NetBSD: loadfile_machdep.h,v 1.4 2009/03/21 15:01:56 ad Exp $ */
/*-
* Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#define BOOT_ELF32
#define BOOT_ELF64
#define LOAD_KERNEL (LOAD_ALL & ~LOAD_TEXTA)
#define COUNT_KERNEL (COUNT_ALL & ~COUNT_TEXTA)
#ifdef _STANDALONE
#define LOADADDR(a) ((((u_long)(a)) & 0x07ffffff) + offset)
#define ALIGNENTRY(a) ((u_long)(a) & 0x00100000)
#define READ(f, b, c) pread((f), (void *)LOADADDR(b), (c))
#define BCOPY(s, d, c) vpbcopy((s), (void *)LOADADDR(d), (c))
#define BZERO(d, c) pbzero((void *)LOADADDR(d), (c))
#define WARN(a) (void)(printf a, \
printf((errno ? ": %s\n" : "\n"), \
strerror(errno)))
#define PROGRESS(a) x86_progress a
#define ALLOC(a) alloc(a)
#define DEALLOC(a, b) dealloc(a, b)
#define OKMAGIC(a) ((a) == ZMAGIC)
void x86_progress(const char *, ...);
void vpbcopy(const void *, void *, size_t);
void pbzero(void *, size_t);
ssize_t pread(int, void *, size_t);
#else
#ifdef TEST
#define LOADADDR(a) offset
#define READ(f, b, c) c
#define BCOPY(s, d, c)
#define BZERO(d, c)
#define PROGRESS(a) (void) printf a
#else
#define LOADADDR(a) (((u_long)(a)) + offset)
#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c))
#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c))
#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c))
#define PROGRESS(a) /* nothing */
#endif
#define WARN(a) warn a
#define ALIGNENTRY(a) ((u_long)(a))
#define ALLOC(a) malloc(a)
#define DEALLOC(a, b) free(a)
#define OKMAGIC(a) ((a) == OMAGIC)
ssize_t vread(int, u_long, u_long *, size_t);
void vcopy(u_long, u_long, u_long *, size_t);
void vzero(u_long, u_long *, size_t);
#endif

View file

@ -1,4 +1,4 @@
/* $NetBSD: skpc.S,v 1.2 2008/04/28 20:24:06 martin Exp $ */
/* $NetBSD: pio.h,v 1.9 2011/05/22 16:01:43 christos Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -29,21 +29,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _X86_PIO_H_
#define _X86_PIO_H_
/*
* Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
* Functions to provide access to x86 programmed I/O instructions.
*/
#include <machine/asm.h>
uint8_t inb(unsigned);
void insb(unsigned, void *, int);
uint16_t inw(unsigned);
void insw(unsigned, void *, int);
uint32_t inl(unsigned);
void insl(unsigned, void *, int);
ENTRY(skpc)
movl %edi,%eax
movq %rsi,%rcx
movq %rdx,%rdi
cld
repe
scasb
je 1f
incq %rcx
1:
movl %ecx,%eax
ret
void outb(unsigned, uint8_t);
void outsb(unsigned, void *, int);
void outw(unsigned, uint16_t);
void outsw(unsigned, void *, int);
void outl(unsigned, uint32_t);
void outsl(unsigned, void *, int);
#endif /* _X86_PIO_H_ */

View file

@ -1,11 +1,11 @@
/* $NetBSD: scanc.S,v 1.9 2008/04/28 20:24:06 martin Exp $ */
/* $NetBSD: rwlock.h,v 1.5 2008/04/28 20:23:40 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
* by Jason R. Thorpe and Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -29,28 +29,34 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#ifndef _X86_RWLOCK_H_
#define _X86_RWLOCK_H_
ENTRY(scanc)
movl 4(%esp),%ecx
testl %ecx,%ecx
jz 3f
pushl %esi
pushl %edi
movl 16(%esp),%esi
movl 20(%esp),%edi
movb 24(%esp),%dl
xorl %eax,%eax
cld
1:
lodsb
testb %dl,(%eax,%edi)
jnz 2f
decl %ecx
jnz 1b
2:
popl %edi
popl %esi
3:
movl %ecx,%eax
ret
struct krwlock {
volatile uintptr_t rw_owner;
};
#ifdef __RWLOCK_PRIVATE
#define __HAVE_SIMPLE_RW_LOCKS 1
#define __HAVE_RW_STUBS 1
/*
* RW_RECEIVE: no memory barrier required, as 'ret' implies a load fence.
*/
#define RW_RECEIVE(rw) /* nothing */
/*
* RW_GIVE: no memory barrier required, as _lock_cas() will take care of it.
*/
#define RW_GIVE(rw) /* nothing */
#define RW_CAS(p, o, n) \
(_atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o))
unsigned long _atomic_cas_ulong(volatile unsigned long *,
unsigned long, unsigned long);
#endif /* __RWLOCK_PRIVATE */
#endif /* _X86_RWLOCK_H_ */

76
sys/conf/newvers_stand.sh Normal file
View file

@ -0,0 +1,76 @@
#!/bin/sh -
#
# $NetBSD: newvers_stand.sh,v 1.8 2011/01/22 19:19:25 joerg Exp $
#
# Copyright (c) 2000 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Jaromir Dolecek.
#
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
# Script for generating of vers.c file from given template. Used in
# bootblock build on various architectures.
#
# Called as:
# sh ${S}/conf/newvers_stand.sh [-N] VERSION_FILE ARCH [EXTRA_MSG]
cwd=$(dirname $0)
add_name=yes
add_date=no
add_kernrev=yes
# parse command args
while getopts "DKN?" OPT; do
case $OPT in
D) add_date=yes;;
K) add_kernrev=no;;
N) add_name=no;;
?) echo "Syntax: newvers_stand.sh [-NDMK] VERSION_TEMPLATE ARCH EXTRA_COMMENT" >&2
exit 1;;
esac
done
shift `expr $OPTIND - 1`
r=`awk -F: '$1 ~ /^[0-9.]*$/ { it = $1; } END { print it }' $1`
t=`LC_ALL=C date`
if [ $add_date = yes ]; then
echo "const char bootprog_rev[] = \"${r} (${t})\";" > vers.c
else
echo "const char bootprog_rev[] = \"${r}\";" > vers.c
fi
if [ $add_name = yes ]; then
a="$2" # architecture name
extra=${3:+" $3"}
echo "const char bootprog_name[] = \"NetBSD/${a}${extra}\";" >> vers.c
fi
if [ $add_kernrev = yes ]; then
osr=$(sh ${cwd}/osrelease.sh)
echo "const char bootprog_kernrev[] = \"${osr}\";" >> vers.c
fi

89
sys/conf/osrelease.sh Normal file
View file

@ -0,0 +1,89 @@
#!/bin/sh
#
# $NetBSD: osrelease.sh,v 1.120 2009/11/15 18:41:08 dsl Exp $
#
# Copyright (c) 1997 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Luke Mewburn.
#
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
#
# We use the number specified in <sys/param.h>
path="$0"
[ "${path#/*}" = "$path" ] && path="./$path"
exec < ${path%/*}/../sys/param.h
# Search for line
# #define __NetBSD_Version__ <ver_num> /* NetBSD <ver_text> */
#
# <ver_num> and <ver_text> should match!
while
read define ver_tag rel_num comment_start NetBSD rel_text rest || exit 1
do
[ "$define" = "#define" ] || continue;
[ "$ver_tag" = "__NetBSD_Version__" ] || continue
break
done
# default: return MM.mm.pp
# -m: return MM, representing only the major number; however, for -current,
# return the next major number (e.g. for 5.99.nn, return 6)
# -n: return MM.mm
# -s: return MMmmpp (no dots)
option="$1"
# ${rel_num} is [M]Mmm00pp00
rel_num=${rel_num%??}
rel_MMmm=${rel_num%????}
rel_MM=${rel_MMmm%??}
rel_mm=${rel_MMmm#${rel_MM}}
# rel_pp=${rel_num#${rel_MMmm}00}
# Get patch from text version
IFS=.
set -- - $rel_text
shift 3
IFS=' '
set -- $rel_MM ${rel_mm#0} $*
case "$option" in
-m)
echo "$(((${rel_MMmm}+1)/100))"
;;
-n)
echo "${rel_MM}.${rel_mm#0}"
;;
-s)
IFS=
echo "$*"
;;
*)
IFS=.
echo "$*"
;;
esac

155
sys/dev/ic/comreg.h Normal file
View file

@ -0,0 +1,155 @@
/* $NetBSD: comreg.h,v 1.17 2011/05/28 19:30:19 matt Exp $ */
/*-
* Copyright (c) 1991 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. 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.
*
* @(#)comreg.h 7.2 (Berkeley) 5/9/91
*/
#include <dev/ic/ns16550reg.h>
#ifdef _KERNEL_OPT
#include "opt_com.h"
#endif
#define COM_FREQ 1843200 /* 16-bit baud rate divisor */
#ifndef COM_TOLERANCE
#define COM_TOLERANCE 30 /* baud rate tolerance, in 0.1% units */
#endif
/* interrupt enable register */
#define IER_ERXRDY 0x1 /* Enable receiver interrupt */
#define IER_ETXRDY 0x2 /* Enable transmitter empty interrupt */
#define IER_ERLS 0x4 /* Enable line status interrupt */
#define IER_EMSC 0x8 /* Enable modem status interrupt */
#define IER_ERTS 0x40 /* Enable RTS interrupt */
#define IER_ECTS 0x80 /* Enable CTS interrupt */
/* PXA2X0's ns16550 ports have extra bits in this register */
#define IER_ERXTOUT 0x10 /* Enable rx timeout interrupt */
#define IER_EUART 0x40 /* Enable UART */
/* interrupt identification register */
#define IIR_IMASK 0xf
#define IIR_RXTOUT 0xc
#define IIR_RLS 0x6 /* Line status change */
#define IIR_RXRDY 0x4 /* Receiver ready */
#define IIR_TXRDY 0x2 /* Transmitter ready */
#define IIR_MLSC 0x0 /* Modem status */
#define IIR_NOPEND 0x1 /* No pending interrupts */
#define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */
/* fifo control register */
#define FIFO_ENABLE 0x01 /* Turn the FIFO on */
#define FIFO_RCV_RST 0x02 /* Reset RX FIFO */
#define FIFO_XMT_RST 0x04 /* Reset TX FIFO */
#define FIFO_DMA_MODE 0x08
#define FIFO_TRIGGER_1 0x00 /* Trigger RXRDY intr on 1 character */
#define FIFO_TRIGGER_4 0x40 /* ibid 4 */
#define FIFO_TRIGGER_8 0x80 /* ibid 8 */
#define FIFO_TRIGGER_14 0xc0 /* ibid 14 */
/* enhanced feature register */
#define EFR_AUTOCTS 0x80 /* Automatic CTS flow control */
#define EFR_AUTORTS 0x40 /* Automatic RTS flow control */
#define EFR_SPECIAL 0x20 /* Special char detect */
#define EFR_EFCR 0x10 /* Enhanced function control bit */
#define EFR_TXFLOWBOTH 0x0c /* Automatic transmit XON/XOFF 1 and 2 */
#define EFR_TXFLOW1 0x08 /* Automatic transmit XON/XOFF 1 */
#define EFR_TXFLOW2 0x04 /* Automatic transmit XON/XOFF 2 */
#define EFR_TXFLOWNONE 0x00 /* No automatic XON/XOFF transmit */
#define EFR_RXFLOWBOTH 0x03 /* Automatic receive XON/XOFF 1 and 2 */
#define EFR_RXFLOW1 0x02 /* Automatic receive XON/XOFF 1 */
#define EFR_RXFLOW2 0x01 /* Automatic receive XON/XOFF 2 */
#define EFR_RXFLOWNONE 0x00 /* No automatic XON/XOFF receive */
/* line control register */
#define LCR_EERS 0xBF /* Enable access to Enhanced Register Set */
#define LCR_DLAB 0x80 /* Divisor latch access enable */
#define LCR_SBREAK 0x40 /* Break Control */
#define LCR_PZERO 0x38 /* Space parity */
#define LCR_PONE 0x28 /* Mark parity */
#define LCR_PEVEN 0x18 /* Even parity */
#define LCR_PODD 0x08 /* Odd parity */
#define LCR_PNONE 0x00 /* No parity */
#define LCR_PENAB 0x08 /* XXX - low order bit of all parity */
#define LCR_STOPB 0x04 /* 2 stop bits per serial word */
#define LCR_8BITS 0x03 /* 8 bits per serial word */
#define LCR_7BITS 0x02 /* 7 bits */
#define LCR_6BITS 0x01 /* 6 bits */
#define LCR_5BITS 0x00 /* 5 bits */
/* modem control register */
#define MCR_PRESCALE 0x80 /* 16650/16950: Baud rate prescaler select */
#define MCR_TCR_TLR 0x40 /* OMAP: enables access to the TCR & TLR regs */
#define MCR_XONENABLE 0x20 /* OMAP XON_EN */
#define MCR_LOOPBACK 0x10 /* Loop test: echos from TX to RX */
#define MCR_IENABLE 0x08 /* Out2: enables UART interrupts */
#define MCR_DRS 0x04 /* Out1: resets some internal modems */
#define MCR_RTS 0x02 /* Request To Send */
#define MCR_DTR 0x01 /* Data Terminal Ready */
/* line status register */
#define LSR_RCV_FIFO 0x80
#define LSR_TSRE 0x40 /* Transmitter empty: byte sent */
#define LSR_TXRDY 0x20 /* Transmitter buffer empty */
#define LSR_BI 0x10 /* Break detected */
#define LSR_FE 0x08 /* Framing error: bad stop bit */
#define LSR_PE 0x04 /* Parity error */
#define LSR_OE 0x02 /* Overrun, lost incoming byte */
#define LSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
#define LSR_RCV_MASK 0x1f /* Mask for incoming data or error */
/* modem status register */
/* All deltas are from the last read of the MSR. */
#define MSR_DCD 0x80 /* Current Data Carrier Detect */
#define MSR_RI 0x40 /* Current Ring Indicator */
#define MSR_DSR 0x20 /* Current Data Set Ready */
#define MSR_CTS 0x10 /* Current Clear to Send */
#define MSR_DDCD 0x08 /* DCD has changed state */
#define MSR_TERI 0x04 /* RI has toggled low to high */
#define MSR_DDSR 0x02 /* DSR has changed state */
#define MSR_DCTS 0x01 /* CTS has changed state */
/* OMAP mode definition register 1 */
#define MDR1_FRAME_END_MODE 0x80
#define MDR1_SIP_MODE 0x40
#define MDR1_SCT 0x20
#define MDR1_SET_TXIR 0x10
#define MDR1_IR_SLEEP 0x08
#define MDR1_MODE_DISABLE 0x07
#define MDR1_MODE_FIR 0x05
#define MDR1_MODE_MIR 0x04
#define MDR1_MODE_UART_13X 0x03
#define MDR1_MODE_UART_16X_AUTOBAUD 0x02
#define MDR1_MODE_SIR 0x01
#define MDR1_MODE_UART_16X 0x00
#define MDR1_MODE_MASK 0x07
/* XXX ISA-specific. */
#define COM_NPORTS 8

View file

@ -1,7 +1,7 @@
/* $NetBSD: lmin.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */
/* $NetBSD: ns16550reg.h,v 1.7 2005/12/11 12:21:28 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1991 Regents of the University of California.
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,14 +28,22 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91
* @(#)ns16550.h 7.1 (Berkeley) 5/9/91
*/
#define LIBKERN_INLINE
#include <lib/libkern/libkern.h>
/*
* NS16550 UART registers
*/
long
lmin(long a, long b)
{
return (a < b ? a : b);
}
#define com_data 0 /* data register (R/W) */
#define com_dlbl 0 /* divisor latch low (W) */
#define com_dlbh 1 /* divisor latch high (W) */
#define com_ier 1 /* interrupt enable (W) */
#define com_iir 2 /* interrupt identification (R) */
#define com_fifo 2 /* FIFO control (W) */
#define com_lctl 3 /* line control register (R/W) */
#define com_cfcr 3 /* line control register (R/W) */
#define com_mcr 4 /* modem control register (R/W) */
#define com_lsr 5 /* line status register (R/W) */
#define com_msr 6 /* modem status register (R/W) */
#define com_scratch 7 /* scratch register (R/W) */

245
sys/fs/cd9660/iso.h Normal file
View file

@ -0,0 +1,245 @@
/* $NetBSD: iso.h,v 1.10 2011/09/27 01:01:44 christos Exp $ */
/*-
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley
* by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
* Support code is derived from software contributed to Berkeley
* by Atsushi Murai (amurai@spec.co.jp).
*
* 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. 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.
*
* @(#)iso.h 8.6 (Berkeley) 5/10/95
*/
/*
* Definitions describing ISO9660 file system structure, as well as
* the functions necessary to access fields of ISO9660 file system
* structures.
*/
#ifndef _ISOFS_CD9660_ISO_H_
#define _ISOFS_CD9660_ISO_H_
#define ISODCL(from, to) (to - from + 1)
struct iso_volume_descriptor {
char type[ISODCL(1,1)]; /* 711 */
char id[ISODCL(2,6)];
char version[ISODCL(7,7)];
char data[ISODCL(8,2048)];
};
/* volume descriptor types */
#define ISO_VD_PRIMARY 1
#define ISO_VD_SUPPLEMENTARY 2
#define ISO_VD_END 255
#define ISO_STANDARD_ID "CD001"
#define ISO_ECMA_ID "CDW01"
#define ISO_MAXNAMLEN 255
struct iso_primary_descriptor {
char type [ISODCL ( 1, 1)]; /* 711 */
char id [ISODCL ( 2, 6)];
char version [ISODCL ( 7, 7)]; /* 711 */
char unused1 [ISODCL ( 8, 8)];
char system_id [ISODCL ( 9, 40)]; /* achars */
char volume_id [ISODCL ( 41, 72)]; /* dchars */
char unused2 [ISODCL ( 73, 80)];
char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
char unused3 [ISODCL ( 89, 120)];
char volume_set_size [ISODCL (121, 124)]; /* 723 */
char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
char logical_block_size [ISODCL (129, 132)]; /* 723 */
char path_table_size [ISODCL (133, 140)]; /* 733 */
char type_l_path_table [ISODCL (141, 144)]; /* 731 */
char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
char type_m_path_table [ISODCL (149, 152)]; /* 732 */
char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
char volume_set_id [ISODCL (191, 318)]; /* dchars */
char publisher_id [ISODCL (319, 446)]; /* achars */
char preparer_id [ISODCL (447, 574)]; /* achars */
char application_id [ISODCL (575, 702)]; /* achars */
char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
char file_structure_version [ISODCL (882, 882)]; /* 711 */
char unused4 [ISODCL (883, 883)];
char application_data [ISODCL (884, 1395)];
char unused5 [ISODCL (1396, 2048)];
};
#define ISO_DEFAULT_BLOCK_SIZE 2048
struct iso_supplementary_descriptor {
char type [ISODCL ( 1, 1)]; /* 711 */
char id [ISODCL ( 2, 6)];
char version [ISODCL ( 7, 7)]; /* 711 */
char flags [ISODCL ( 8, 8)]; /* 711? */
char system_id [ISODCL ( 9, 40)]; /* achars */
char volume_id [ISODCL ( 41, 72)]; /* dchars */
char unused2 [ISODCL ( 73, 80)];
char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
char escape [ISODCL ( 89, 120)];
char volume_set_size [ISODCL (121, 124)]; /* 723 */
char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
char logical_block_size [ISODCL (129, 132)]; /* 723 */
char path_table_size [ISODCL (133, 140)]; /* 733 */
char type_l_path_table [ISODCL (141, 144)]; /* 731 */
char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
char type_m_path_table [ISODCL (149, 152)]; /* 732 */
char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
char volume_set_id [ISODCL (191, 318)]; /* dchars */
char publisher_id [ISODCL (319, 446)]; /* achars */
char preparer_id [ISODCL (447, 574)]; /* achars */
char application_id [ISODCL (575, 702)]; /* achars */
char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
char file_structure_version [ISODCL (882, 882)]; /* 711 */
char unused4 [ISODCL (883, 883)];
char application_data [ISODCL (884, 1395)];
char unused5 [ISODCL (1396, 2048)];
};
struct iso_directory_record {
char length [ISODCL (1, 1)]; /* 711 */
char ext_attr_length [ISODCL (2, 2)]; /* 711 */
u_char extent [ISODCL (3, 10)]; /* 733 */
u_char size [ISODCL (11, 18)]; /* 733 */
char date [ISODCL (19, 25)]; /* 7 by 711 */
char flags [ISODCL (26, 26)];
char file_unit_size [ISODCL (27, 27)]; /* 711 */
char interleave [ISODCL (28, 28)]; /* 711 */
char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
char name_len [ISODCL (33, 33)]; /* 711 */
char name [1]; /* XXX */
};
/* can't take sizeof(iso_directory_record), because of possible alignment
of the last entry (34 instead of 33) */
#define ISO_DIRECTORY_RECORD_SIZE 33
struct iso_extended_attributes {
u_char owner [ISODCL (1, 4)]; /* 723 */
u_char group [ISODCL (5, 8)]; /* 723 */
u_char perm [ISODCL (9, 10)]; /* 9.5.3 */
char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */
char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */
char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */
char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */
char recfmt [ISODCL (79, 79)]; /* 711 */
char recattr [ISODCL (80, 80)]; /* 711 */
u_char reclen [ISODCL (81, 84)]; /* 723 */
char system_id [ISODCL (85, 116)]; /* achars */
char system_use [ISODCL (117, 180)];
char version [ISODCL (181, 181)]; /* 711 */
char len_esc [ISODCL (182, 182)]; /* 711 */
char reserved [ISODCL (183, 246)];
u_char len_au [ISODCL (247, 250)]; /* 723 */
};
/* 7.1.1: unsigned char */
static __inline __unused int
isonum_711(const u_char *p)
{
return *p;
}
/* 7.1.2: signed char */
static __inline __unused int
isonum_712(const u_char *p)
{
return (signed char) *p;
}
/* 7.2.1: unsigned little-endian 16-bit value. NOT USED IN KERNEL. */
static __inline __unused uint16_t
isonum_721(const u_char *p)
{
return le16dec(p);
}
/* 7.2.2: unsigned big-endian 16-bit value. NOT USED IN KERNEL. */
static __inline __unused uint16_t
isonum_722(const u_char *p)
{
return be16dec(p);
}
/* 7.2.3: unsigned both-endian (little, then big) 16-bit value */
static __inline __unused uint16_t
isonum_723(const u_char *p)
{
#if BYTE_ORDER == BIG_ENDIAN
return be16dec(p + 2);
#else
return le16dec(p);
#endif
}
/* 7.3.1: unsigned little-endian 32-bit value. NOT USED IN KERNEL. */
static __inline __unused uint32_t
isonum_731(const u_char *p)
{
return le32dec(p);
}
/* 7.3.2: unsigned big-endian 32-bit value. NOT USED IN KERNEL. */
static __inline __unused uint32_t
isonum_732(const u_char *p)
{
return be32dec(p);
}
/* 7.3.3: unsigned both-endian (little, then big) 32-bit value */
static __inline __unused uint32_t
isonum_733(const u_char *p)
{
#if BYTE_ORDER == BIG_ENDIAN
return be32dec(p + 4);
#else
return le32dec(p);
#endif
}
/*
* Associated files have a leading '='.
*/
#define ASSOCCHAR '='
#endif /* _ISOFS_CD9660_ISO_H_ */

197
sys/fs/msdosfs/bpb.h Normal file
View file

@ -0,0 +1,197 @@
/* $NetBSD: bpb.h,v 1.6 2007/01/27 07:18:10 cbiere Exp $ */
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
*
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
*
* This software is provided "as is".
*
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
*
* October 1992
*/
#ifndef _MSDOSFS_BPB_H_
#define _MSDOSFS_BPB_H_
/*
* BIOS Parameter Block (BPB) for DOS 3.3
*/
struct bpb33 {
u_int16_t bpbBytesPerSec; /* bytes per sector */
u_int8_t bpbSecPerClust; /* sectors per cluster */
u_int16_t bpbResSectors; /* number of reserved sectors */
u_int8_t bpbFATs; /* number of FATs */
u_int16_t bpbRootDirEnts; /* number of root directory entries */
u_int16_t bpbSectors; /* total number of sectors */
u_int8_t bpbMedia; /* media descriptor */
u_int16_t bpbFATsecs; /* number of sectors per FAT */
u_int16_t bpbSecPerTrack; /* sectors per track */
u_int16_t bpbHeads; /* number of heads */
u_int16_t bpbHiddenSecs; /* number of hidden sectors */
};
/*
* BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
* and bpbHugeSectors is not in the 3.3 bpb.
*/
struct bpb50 {
u_int16_t bpbBytesPerSec; /* bytes per sector */
u_int8_t bpbSecPerClust; /* sectors per cluster */
u_int16_t bpbResSectors; /* number of reserved sectors */
u_int8_t bpbFATs; /* number of FATs */
u_int16_t bpbRootDirEnts; /* number of root directory entries */
u_int16_t bpbSectors; /* total number of sectors */
u_int8_t bpbMedia; /* media descriptor */
u_int16_t bpbFATsecs; /* number of sectors per FAT */
u_int16_t bpbSecPerTrack; /* sectors per track */
u_int16_t bpbHeads; /* number of heads */
u_int32_t bpbHiddenSecs; /* # of hidden sectors */
u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
};
/*
* BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
*/
struct bpb710 {
u_int16_t bpbBytesPerSec; /* bytes per sector */
u_int8_t bpbSecPerClust; /* sectors per cluster */
u_int16_t bpbResSectors; /* number of reserved sectors */
u_int8_t bpbFATs; /* number of FATs */
u_int16_t bpbRootDirEnts; /* number of root directory entries */
u_int16_t bpbSectors; /* total number of sectors */
u_int8_t bpbMedia; /* media descriptor */
u_int16_t bpbFATsecs; /* number of sectors per FAT */
u_int16_t bpbSecPerTrack; /* sectors per track */
u_int16_t bpbHeads; /* number of heads */
u_int32_t bpbHiddenSecs; /* # of hidden sectors */
u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
u_int32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */
u_int16_t bpbExtFlags; /* extended flags: */
#define FATNUM 0xf /* mask for numbering active FAT */
#define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */
u_int16_t bpbFSVers; /* filesystem version */
#define FSVERS 0 /* currently only 0 is understood */
u_int32_t bpbRootClust; /* start cluster for root directory */
u_int16_t bpbFSInfo; /* filesystem info structure sector */
u_int16_t bpbBackup; /* backup boot sector */
u_int8_t bpbReserved[12]; /* Reserved for future expansion */
};
#ifdef atari
/*
* BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined.
* Currently there is no need for a separate BPB structure.
*/
#if 0
struct bpb_a {
u_int16_t bpbBytesPerSec; /* bytes per sector */
u_int8_t bpbSecPerClust; /* sectors per cluster */
u_int16_t bpbResSectors; /* number of reserved sectors */
u_int8_t bpbFATs; /* number of FATs */
u_int16_t bpbRootDirEnts; /* number of root directory entries */
u_int16_t bpbSectors; /* total number of sectors */
u_int8_t bpbUseless1; /* meaningless on gemdos fs */
u_int16_t bpbFATsecs; /* number of sectors per FAT */
u_int16_t bpbUseless2; /* meaningless for harddisk fs */
u_int16_t bpbUseless3; /* meaningless for harddisk fs */
u_int16_t bpbHiddenSecs; /* the TOS-BIOS ignores this */
};
#endif
#endif /* atari */
/*
* The following structures represent how the bpb's look on disk. shorts
* and longs are just character arrays of the appropriate length. This is
* because the compiler forces shorts and longs to align on word or
* halfword boundaries.
*/
#include <sys/endian.h>
#define getushort(p) le16dec(p)
#define getulong(p) le32dec(p)
#define putushort(p, v) le16enc((p), (v))
#define putulong(p, v) le32enc((p), (v))
/*
* BIOS Parameter Block (BPB) for DOS 3.3
*/
struct byte_bpb33 {
int8_t bpbBytesPerSec[2]; /* bytes per sector */
int8_t bpbSecPerClust; /* sectors per cluster */
int8_t bpbResSectors[2]; /* number of reserved sectors */
int8_t bpbFATs; /* number of FATs */
int8_t bpbRootDirEnts[2]; /* number of root directory entries */
int8_t bpbSectors[2]; /* total number of sectors */
int8_t bpbMedia; /* media descriptor */
int8_t bpbFATsecs[2]; /* number of sectors per FAT */
int8_t bpbSecPerTrack[2]; /* sectors per track */
int8_t bpbHeads[2]; /* number of heads */
int8_t bpbHiddenSecs[2]; /* number of hidden sectors */
};
/*
* BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
* and bpbHugeSectors is not in the 3.3 bpb.
*/
struct byte_bpb50 {
int8_t bpbBytesPerSec[2]; /* bytes per sector */
int8_t bpbSecPerClust; /* sectors per cluster */
int8_t bpbResSectors[2]; /* number of reserved sectors */
int8_t bpbFATs; /* number of FATs */
int8_t bpbRootDirEnts[2]; /* number of root directory entries */
int8_t bpbSectors[2]; /* total number of sectors */
int8_t bpbMedia; /* media descriptor */
int8_t bpbFATsecs[2]; /* number of sectors per FAT */
int8_t bpbSecPerTrack[2]; /* sectors per track */
int8_t bpbHeads[2]; /* number of heads */
int8_t bpbHiddenSecs[4]; /* number of hidden sectors */
int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
};
/*
* BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
*/
struct byte_bpb710 {
u_int8_t bpbBytesPerSec[2]; /* bytes per sector */
u_int8_t bpbSecPerClust; /* sectors per cluster */
u_int8_t bpbResSectors[2]; /* number of reserved sectors */
u_int8_t bpbFATs; /* number of FATs */
u_int8_t bpbRootDirEnts[2]; /* number of root directory entries */
u_int8_t bpbSectors[2]; /* total number of sectors */
u_int8_t bpbMedia; /* media descriptor */
u_int8_t bpbFATsecs[2]; /* number of sectors per FAT */
u_int8_t bpbSecPerTrack[2]; /* sectors per track */
u_int8_t bpbHeads[2]; /* number of heads */
u_int8_t bpbHiddenSecs[4]; /* # of hidden sectors */
u_int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
u_int8_t bpbBigFATsecs[4]; /* like bpbFATsecs for FAT32 */
u_int8_t bpbExtFlags[2]; /* extended flags: */
u_int8_t bpbFSVers[2]; /* filesystem version */
u_int8_t bpbRootClust[4]; /* start cluster for root directory */
u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */
u_int8_t bpbBackup[2]; /* backup boot sector */
u_int8_t bpbReserved[12]; /* Reserved for future expansion */
};
/*
* FAT32 FSInfo block.
*/
struct fsinfo {
u_int8_t fsisig1[4];
u_int8_t fsifill1[480];
u_int8_t fsisig2[4];
u_int8_t fsinfree[4];
u_int8_t fsinxtfree[4];
u_int8_t fsifill2[12];
u_int8_t fsisig3[4];
u_int8_t fsifill3[508];
u_int8_t fsisig4[4];
};
#endif /* _MSDOSFS_BPB_H_ */

139
sys/fs/msdosfs/direntry.h Normal file
View file

@ -0,0 +1,139 @@
/* $NetBSD: direntry.h,v 1.5 2005/12/03 17:34:43 christos Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
* Copyright (C) 1994, 1995, 1997 TooLs GmbH.
* All rights reserved.
* Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
*
* 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 TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
*/
/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
*
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
*
* This software is provided "as is".
*
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
*
* October 1992
*/
#ifndef _MSDOSFS_DIRENTRY_H_
#define _MSDOSFS_DIRENTRY_H_
/*
* Structure of a dos directory entry.
*/
struct direntry {
u_int8_t deName[8]; /* filename, blank filled */
#define SLOT_EMPTY 0x00 /* slot has never been used */
#define SLOT_E5 0x05 /* the real value is 0xe5 */
#define SLOT_DELETED 0xe5 /* file in this slot deleted */
u_int8_t deExtension[3]; /* extension, blank filled */
u_int8_t deAttributes; /* file attributes */
#define ATTR_NORMAL 0x00 /* normal file */
#define ATTR_READONLY 0x01 /* file is readonly */
#define ATTR_HIDDEN 0x02 /* file is hidden */
#define ATTR_SYSTEM 0x04 /* file is a system file */
#define ATTR_VOLUME 0x08 /* entry is a volume label */
#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
#define ATTR_ARCHIVE 0x20 /* file is new or modified */
u_int8_t deReserved; /* reserved */
u_int8_t deCHundredth; /* hundredth of seconds in CTime */
u_int8_t deCTime[2]; /* create time */
u_int8_t deCDate[2]; /* create date */
u_int8_t deADate[2]; /* access date */
u_int8_t deHighClust[2]; /* high bytes of cluster number */
u_int8_t deMTime[2]; /* last update time */
u_int8_t deMDate[2]; /* last update date */
u_int8_t deStartCluster[2]; /* starting cluster of file */
u_int8_t deFileSize[4]; /* size of file in bytes */
};
/*
* Structure of a Win95 long name directory entry
*/
struct winentry {
u_int8_t weCnt;
#define WIN_LAST 0x40
#define WIN_CNT 0x3f
u_int8_t wePart1[10];
u_int8_t weAttributes;
#define ATTR_WIN95 0x0f
u_int8_t weReserved1;
u_int8_t weChksum;
u_int8_t wePart2[12];
u_int16_t weReserved2;
u_int8_t wePart3[4];
};
#define WIN_CHARS 13 /* Number of chars per winentry */
/*
* This is the format of the contents of the deTime field in the direntry
* structure.
* We don't use bitfields because we don't know how compilers for
* arbitrary machines will lay them out.
*/
#define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */
#define DT_2SECONDS_SHIFT 0
#define DT_MINUTES_MASK 0x7E0 /* minutes */
#define DT_MINUTES_SHIFT 5
#define DT_HOURS_MASK 0xF800 /* hours */
#define DT_HOURS_SHIFT 11
/*
* This is the format of the contents of the deDate field in the direntry
* structure.
*/
#define DD_DAY_MASK 0x1F /* day of month */
#define DD_DAY_SHIFT 0
#define DD_MONTH_MASK 0x1E0 /* month */
#define DD_MONTH_SHIFT 5
#define DD_YEAR_MASK 0xFE00 /* year - 1980 */
#define DD_YEAR_SHIFT 9
#ifdef _KERNEL
void unix2dostime(const struct timespec *tsp, int gmtoff, u_int16_t *ddp,
u_int16_t *dtp, u_int8_t *dhp);
void dos2unixtime(u_int dd, u_int dt, u_int dh, int gmtoff,
struct timespec *tsp);
int dos2unixfn(u_char dn[11], u_char *un, int lower);
int unix2dosfn(const u_char *un, u_char dn[12], int unlen,
u_int gen);
int unix2winfn(const u_char *un, int unlen, struct winentry *wep,
int cnt, int chksum);
int winChkName(const u_char *un, int unlen, struct winentry *wep,
int chksum);
int win2unixfn(struct winentry *wep, struct dirent *dp, int chksum);
u_int8_t winChksum(u_int8_t *name);
int winSlotCnt(const u_char *un, int unlen);
#endif /* _KERNEL */
#endif /* _MSDOSFS_DIRENTRY_H_ */

View file

@ -1,31 +0,0 @@
# $NetBSD: Makefile,v 1.95 2009/01/18 20:42:11 he Exp $
LIB= kern
NOPIC= # defined
LLIBS= # defined
.include "Makefile.libkern"
.ifndef ARCHSUBDIR
.BEGIN:
@echo no ARCHSUBDIR for ${MACHINE_ARCH} nor ${MACHINE_CPU}
@false
.endif
# only needed during build
libinstall::
.undef DESTDIR
.include <bsd.lib.mk>
lib${LIB}.o:: ${OBJS}
@echo building standard ${LIB} library
@rm -f lib${LIB}.o
@${LD} -r -o lib${LIB}.o `NM=${NM} ${LORDER} ${OBJS} | ${TSORT}`
lib${LIB}.po:: ${POBJS}
@echo building profiled ${LIB} library
@rm -f lib${LIB}.po
@${LD} -r -o lib${LIB}.po `NM=${NM} ${LORDER} ${POBJS} | ${TSORT}`
showsources: ${SRCS}
@echo ${.ALLSRC}

View file

@ -1,93 +0,0 @@
# $NetBSD: Makefile.inc,v 1.40 2005/12/20 19:35:26 christos Exp $
#
# Configuration variables (default values are below):
#
# S must be set to the top of the 'sys' tree.
# KERNDST may be set to the location of the directory where library
# objects are to be built. Defaults to ${.OBJDIR}/lib/kern.
# KERN_AS may be set to 'obj' to build a object from the library's
# object files. (Otherwise, a library will be built.)
# Defaults to 'library'.
# KERNMISCCPPFLAGS
# Miscellaneous cpp flags to be passed to the library's Makefile
# when building.
# KERNMISCMAKEFLAGS
# Miscellaneous flags to be passed to the library's Makefile when
# building. See library's Makefile for more details about
# supported flags and their default values.
# Default values:
KERNDST?= ${.OBJDIR}/lib/kern
KERN_AS?= library
KERNDOTDIR?= ../../.
KERNDIR= ${S:S@^.@${KERNDOTDIR}@:Q}/lib/libkern
.if (${KERN_AS} == "obj")
KERNLIB= ${KERNDST}/libkern.o
KERNLIB_PROF= ${KERNDST}/libkern.po
.else
KERNLIB= ${KERNDST}/libkern.a
KERNLIB_PROF= ${KERNDST}/libkern_p.a
.endif
LIBKERNLNBN= llib-lkern.ln
KERNLIBLN= ${KERNDST}/${LIBKERNLNBN}
KERNMAKE= \
cd ${KERNDST} && ${MAKE} -f ${KERNDIR:Q}/Makefile \
KERNDIR=${KERNDIR:Q} \
CC=${CC:Q} CFLAGS=${CFLAGS:Q} \
AS=${AS:Q} AFLAGS=${AFLAGS:Q} \
LORDER=${LORDER:Q} \
TSORT=${TSORT:Q} \
LD=${LD:Q} STRIP=${STRIP:Q} \
AR=${AR:Q} NM=${NM:Q} \
RANLIB=${RANLIB:Q} SIZE=${SIZE:Q} \
MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH:Q} \
KERNCPPFLAGS=${CPPFLAGS:S@^-I.@-I${KERNDOTDIR}@g:Q} \
KERNMISCCPPFLAGS=${KERNMISCCPPFLAGS:Q} \
LINTFLAGS=${KERNLINTFLAGS:Q} \
${KERNMISCMAKEFLAGS}
${KERNLIB}: .NOTMAIN .MAKE __always_make_kernlib
@echo making sure the kern library is up to date...
.if (${KERN_AS} == "library")
@${KERNMAKE} libkern.a
.else
@${KERNMAKE} libkern.o
.endif
${KERNLIB_PROF}: .NOTMAIN .MAKE __always_make_kernlib
@echo making sure the profiled kern library is up to date...
.if (${KERN_AS} == "library")
@${KERNMAKE} libkern_p.a
.else
@${KERNMAKE} libkern.po
.endif
${KERNLIBLN}: .NOTMAIN .MAKE __always_make_kernlib
@echo making sure the kern lint library is up to date...
@${KERNMAKE} ${LIBKERNLNBN}
clean: .NOTMAIN cleankernlib
cleankernlib: .NOTMAIN
@echo cleaning the kern library objects
@if [ -d "${KERNDST}" ]; then ${KERNMAKE} clean; fi
cleandir distclean: .NOTMAIN cleandirkernlib
cleandirkernlib: .NOTMAIN
@echo cleandiring the kern library objects
@if [ -d "${KERNDST}" ]; then ${KERNMAKE} cleandir; fi
dependall depend: .NOTMAIN dependkernlib
dependkernlib: .NOTMAIN .MAKE __always_make_kernlib
@echo depending the kern library objects
@${KERNMAKE} depend
__always_make_kernlib: .NOTMAIN
@(mkdir -p ${KERNDST})
.PHONY: __always_make_kernlib
.PHONY: cleankernlib cleandirkernlib dependkernlib
.include "${.PARSEDIR}/../../../common/lib/libc/Makefile.inc"

View file

@ -1,108 +0,0 @@
# $NetBSD: Makefile.libkern,v 1.15 2011/11/19 22:51:25 tls Exp $
#
# Variable definitions for libkern.
#
# Before including this, you _must_ set
# KERNDIR: location of sys/lib/libkern
#
# You *may* set:
# LIBKERN_ARCH: architecture subdir to be used
# KERNCPPFLAGS: see Makefile.inc
# KERNMISCCPPFLAGS: see Makefile.inc
#
.include <bsd.own.mk>
.if defined(LIBKERN_ARCH) && !empty(LIBKERN_ARCH) && \
exists(${KERNDIR}/arch/${LIBKERN_ARCH})
ARCHSUBDIR= ${LIBKERN_ARCH}
.elif defined(MACHINE_ARCH) && !empty(MACHINE_ARCH) && \
exists(${KERNDIR}/arch/${MACHINE_ARCH})
ARCHSUBDIR= ${MACHINE_ARCH}
.elif defined(MACHINE_CPU) && !empty(MACHINE_CPU) && \
exists(${KERNDIR}/arch/${MACHINE_CPU})
ARCHSUBDIR= ${MACHINE_CPU}
.endif
M= ${KERNDIR}/arch/${ARCHSUBDIR}
CPPFLAGS+= -I$M ${KERNCPPFLAGS} ${KERNMISCCPPFLAGS}
.include "${.PARSEDIR}/../../../common/lib/libc/Makefile.inc"
.include "${.PARSEDIR}/../../../common/lib/libutil/Makefile.inc"
.include "${.PARSEDIR}/../../../common/lib/libprop/Makefile.inc"
.include "${.PARSEDIR}/../../../common/lib/libppath/Makefile.inc"
.include "${.PARSEDIR}/../../../common/lib/libquota/Makefile.inc"
CPPFLAGS+= -I${KERNDIR}/../../../common/include
.PATH.c: ${KERNDIR}
.if exists ($M/Makefile.inc)
.PATH.c: $M
.PATH.S: $M
.include "$M/Makefile.inc"
.endif
.if (${MACHINE_ARCH} != "alpha") && \
(${MACHINE_ARCH} != "mips64eb" || !empty(CFLAGS:M-mabi=32)) && \
(${MACHINE_ARCH} != "mips64el" || !empty(CFLAGS:M-mabi=32)) && \
(${MACHINE_ARCH} != "powerpc64") && \
(${MACHINE_ARCH} != "sparc64") && \
(${MACHINE_ARCH} != "x86_64" || !empty(CFLAGS:M-m32))
# Quad support
SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
.endif
# Other stuff
SRCS+= kern_assert.c __main.c
SRCS+= __cmsg_alignbytes.c cpuset.c inet_addr.c intoa.c
.if empty(SRCS:Mbyte_swap_8.*)
SRCS+= bswap64.c
.endif
SRCS+= md4c.c md5c.c rmd160.c sha1.c sha2.c
SRCS+= pmatch.c arc4random.c bcd.c mcount.c mertwist.c crc32.c
SRCS+= ppath_kmem_alloc.c
SRCS+= strsep.c strstr.c
SRCS+= strlcpy.c strlcat.c
SRCS+= imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c
SRCS+= memcpy.c memmove.c
SRCS+= strchr.c strrchr.c
SRCS+= memcmp.c
.if empty(SRCS:Mmemset2.*)
SRCS+= memset.c
.endif
SRCS+= popcount32.c popcount64.c
SRCS+= strtoul.c strtoll.c strtoull.c strtoumax.c
SRCS+= scanc.c skpc.c
SRCS+= random.c
SRCS+= rngtest.c
SRCS+= memchr.c
SRCS+= strcat.c strcmp.c strcpy.c strlen.c
SRCS+= strncmp.c strncpy.c
SRCS+= strcasecmp.c strncasecmp.c
SRCS+= xlat_mbr_fstype.c
SRCS+= heapsort.c ptree.c rb.c
# Files to clean up
CLEANFILES+= lib${LIB}.o lib${LIB}.po
# Remove from SRCS the .c files for any .S files added by the MD makefiles,
# also remove from SRCS the .c files for the .c files in NO_SRCS.
# (Unlike libc, we don't worry about lint)
.for check_file in ${SRCS:M*.S} ${NO_SRCS}
unwanted_file := ${SRCS:M${check_file:.S=.c}}
.if "${unwanted_file}" != ""
SRCS := ${SRCS:N${unwanted_file}}
.endif
.endfor

View file

@ -1,40 +0,0 @@
/* $NetBSD: __main.c,v 1.6 2009/03/15 21:33:51 cegger Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* 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 Christopher G. Demetriou.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <sys/types.h>
void __main(void);
void
__main(void)
{
}

View file

@ -1,327 +0,0 @@
/* $NetBSD: arc4random.c,v 1.29 2011/11/29 13:16:27 drochner Exp $ */
/*-
* Copyright (c) 2002, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Thor Lancelot Simon.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*-
* THE BEER-WARE LICENSE
*
* <dan@FreeBSD.ORG> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you
* think this stuff is worth it, you can buy me a beer in return.
*
* Dan Moschuk
*
* $FreeBSD: src/sys/libkern/arc4random.c,v 1.9 2001/08/30 12:30:58 bde Exp $
*/
#include <sys/cdefs.h>
#ifdef _KERNEL
#include "rnd.h"
#else
#define NRND 0
#endif
#include <sys/types.h>
#include <sys/time.h>
#include <sys/param.h>
#ifdef _KERNEL
#include <sys/kernel.h>
#endif
#include <sys/systm.h>
#ifdef _KERNEL
#include <sys/mutex.h>
#include <sys/rngtest.h>
#else
#define mutex_spin_enter(x) ;
#define mutex_spin_exit(x) ;
#define mutex_init(x, y, z) ;
#endif
#include <lib/libkern/libkern.h>
#if NRND > 0
#include <sys/rnd.h>
#include <dev/rnd_private.h>
static rndsink_t rs;
#endif
/*
* The best known attack that distinguishes RC4 output from a random
* bitstream requires 2^25 bytes. (see Paul and Preneel, Analysis of
* Non-fortuitous Predictive States of the RC4 Keystream Generator.
* INDOCRYPT 2003, pp52 67).
*
* However, we discard the first 1024 bytes of output, avoiding the
* biases detected in this paper. The best current attack that
* can distinguish this "RC4[drop]" output seems to be Fleuhrer &
* McGrew's attack which requires 2^30.6 bytes of output:
* Fluhrer and McGrew, Statistical Analysis of the Alleged RC4
* Keystream Generator. FSE 2000, pp19 30
*
* We begin trying to rekey at 2^24 bytes, and forcibly rekey at 2^29 bytes
* even if the resulting key cannot be guaranteed to have full entropy.
*/
#define ARC4_MAXBYTES (16 * 1024 * 1024)
#define ARC4_HARDMAX (512 * 1024 * 1024)
#define ARC4_RESEED_SECONDS 300
#define ARC4_KEYBYTES 16 /* 128 bit key */
#ifdef _STANDALONE
#define time_uptime 1 /* XXX ugly! */
#endif /* _STANDALONE */
static u_int8_t arc4_i, arc4_j;
static int arc4_initialized = 0;
static int arc4_numbytes = 0;
static u_int8_t arc4_sbox[256];
static time_t arc4_nextreseed;
#ifdef _KERNEL
kmutex_t arc4_mtx;
#endif
static inline u_int8_t arc4_randbyte(void);
static inline void arc4randbytes_unlocked(void *, size_t);
void _arc4randbytes(void *, size_t);
uint32_t _arc4random(void);
static inline void
arc4_swap(u_int8_t *a, u_int8_t *b)
{
u_int8_t c;
c = *a;
*a = *b;
*b = c;
}
/*
* Stir our S-box.
*/
static void
arc4_randrekey(void *arg)
{
u_int8_t key[256];
int n, ask_for_more = 0;
#ifdef _KERNEL
#ifdef DIAGNOSTIC
#if 0 /* XXX rngtest_t is too large and could cause stack overflow */
rngtest_t rt;
#endif
#endif
#endif
#if NRND > 0
static int callback_pending;
int r;
#endif
/*
* The first time through, we must take what we can get,
* so schedule ourselves for callback no matter what.
*/
if (__predict_true(arc4_initialized)) {
mutex_spin_enter(&arc4_mtx);
}
#if NRND > 0 /* XXX without rnd, we will key from the stack, ouch! */
else {
ask_for_more = 1;
r = rnd_extract_data(key, ARC4_KEYBYTES, RND_EXTRACT_ANY);
goto got_entropy;
}
if (arg == NULL) {
if (callback_pending) {
if (arc4_numbytes > ARC4_HARDMAX) {
printf("arc4random: WARNING, hit 2^29 bytes, "
"forcibly rekeying.\n");
r = rnd_extract_data(key, ARC4_KEYBYTES,
RND_EXTRACT_ANY);
rndsink_detach(&rs);
callback_pending = 0;
goto got_entropy;
} else {
mutex_spin_exit(&arc4_mtx);
return;
}
}
r = rnd_extract_data(key, ARC4_KEYBYTES, RND_EXTRACT_GOOD);
if (r < ARC4_KEYBYTES) {
ask_for_more = 1;
}
} else {
ask_for_more = 0;
callback_pending = 0;
if (rs.len != ARC4_KEYBYTES) {
panic("arc4_randrekey: rekey callback bad length");
}
memcpy(key, rs.data, rs.len);
memset(rs.data, 0, rs.len);
}
got_entropy:
if (!ask_for_more) {
callback_pending = 0;
} else if (!callback_pending) {
callback_pending = 1;
strlcpy(rs.name, "arc4random", sizeof(rs.name));
rs.cb = arc4_randrekey;
rs.arg = &rs;
rs.len = ARC4_KEYBYTES;
rndsink_attach(&rs);
}
#endif
/*
* If it's the first time, or we got a good key, actually rekey.
*/
if (!ask_for_more || !arc4_initialized) {
for (n = ARC4_KEYBYTES; n < sizeof(key); n++)
key[n] = key[n % ARC4_KEYBYTES];
for (n = 0; n < 256; n++) {
arc4_j = (arc4_j + arc4_sbox[n] + key[n]) % 256;
arc4_swap(&arc4_sbox[n], &arc4_sbox[arc4_j]);
}
arc4_i = arc4_j;
memset(key, 0, sizeof(key));
/*
* Throw away the first N words of output, as suggested in the
* paper "Weaknesses in the Key Scheduling Algorithm of RC4"
* by Fluher, Mantin, and Shamir. (N = 256 in our case.)
*/
for (n = 0; n < 256 * 4; n++)
arc4_randbyte();
/* Reset for next reseed cycle. */
arc4_nextreseed = time_uptime + ARC4_RESEED_SECONDS;
arc4_numbytes = 0;
#ifdef _KERNEL
#ifdef DIAGNOSTIC
#if 0 /* XXX rngtest_t is too large and could cause stack overflow */
/*
* Perform the FIPS 140-2 statistical RNG test; warn if our
* output has such poor quality as to fail the test.
*/
arc4randbytes_unlocked(rt.rt_b, sizeof(rt.rt_b));
strlcpy(rt.rt_name, "arc4random", sizeof(rt.rt_name));
if (rngtest(&rt)) {
/* rngtest will scream to the console. */
arc4_nextreseed = time_uptime;
arc4_numbytes = ARC4_MAXBYTES;
/* XXX should keep old context around, *NOT* use new */
}
#endif
#endif
#endif
}
if (__predict_true(arc4_initialized)) {
mutex_spin_exit(&arc4_mtx);
}
}
/*
* Initialize our S-box to its beginning defaults.
*/
static void
arc4_init(void)
{
int n;
mutex_init(&arc4_mtx, MUTEX_DEFAULT, IPL_VM);
arc4_i = arc4_j = 0;
for (n = 0; n < 256; n++)
arc4_sbox[n] = (u_int8_t) n;
arc4_randrekey(NULL);
arc4_initialized = 1;
}
/*
* Generate a random byte.
*/
static inline u_int8_t
arc4_randbyte(void)
{
u_int8_t arc4_t;
arc4_i = (arc4_i + 1) % 256;
arc4_j = (arc4_j + arc4_sbox[arc4_i]) % 256;
arc4_swap(&arc4_sbox[arc4_i], &arc4_sbox[arc4_j]);
arc4_t = (arc4_sbox[arc4_i] + arc4_sbox[arc4_j]) % 256;
return arc4_sbox[arc4_t];
}
static inline void
arc4randbytes_unlocked(void *p, size_t len)
{
u_int8_t *buf = (u_int8_t *)p;
size_t i;
for (i = 0; i < len; buf[i] = arc4_randbyte(), i++)
continue;
}
void
_arc4randbytes(void *p, size_t len)
{
/* Initialize array if needed. */
if (!arc4_initialized) {
arc4_init();
/* avoid conditionalizing locking */
return arc4randbytes_unlocked(p, len);
}
mutex_spin_enter(&arc4_mtx);
arc4randbytes_unlocked(p, len);
arc4_numbytes += len;
mutex_spin_exit(&arc4_mtx);
if ((arc4_numbytes > ARC4_MAXBYTES) ||
(time_uptime > arc4_nextreseed)) {
arc4_randrekey(NULL);
}
}
u_int32_t
_arc4random(void)
{
u_int32_t ret;
u_int8_t *retc;
retc = (u_int8_t *)&ret;
_arc4randbytes(retc, sizeof(u_int32_t));
return ret;
}

View file

@ -1,54 +0,0 @@
# $NetBSD: Makefile.inc,v 1.28 2009/08/14 19:23:53 dsl Exp $
SRCS+= _mcount.S
SRCS+= byte_swap_2.S byte_swap_4.S
SRCS+= ffs.S
SRCS+= memcpy.S memmove.S
SRCS+= softfloat.c
# `source' files built from m4 source
SRCS+= __divqu.S __divq.S __divlu.S __divl.S
SRCS+= __remqu.S __remq.S __remlu.S __reml.S
CLEANFILES+= __divqu.S __divq.S __divlu.S __divl.S
CLEANFILES+= __remqu.S __remq.S __remlu.S __reml.S
__divqu.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__divqu')define(OP,\`div')define(S,\`false')"; \
echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
__divq.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__divq')define(OP,\`div')define(S,\`true')"; \
echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
__divlu.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__divlu')define(OP,\`div')define(S,\`false')"; \
echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
__divl.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__divl')define(OP,\`div')define(S,\`true')"; \
echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
__remqu.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__remqu')define(OP,\`rem')define(S,\`false')"; \
echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
__remq.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__remq')define(OP,\`rem')define(S,\`true')"; \
echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
__remlu.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__remlu')define(OP,\`rem')define(S,\`false')"; \
echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
__reml.S: ${M}/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`__reml')define(OP,\`rem')define(S,\`true')"; \
echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}

View file

@ -1,197 +0,0 @@
/* $NetBSD: divrem.m4,v 1.8 2005/12/11 12:24:42 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* Division and remainder.
*
* The use of m4 is modeled after the sparc code, but the algorithm is
* simple binary long division.
*
* Note that the loops could probably benefit from unrolling.
*/
/*
* M4 Parameters
* NAME name of function to generate
* OP OP=div: t10 / t11 -> t12; OP=rem: t10 % t11 -> t12
* S S=true: signed; S=false: unsigned
* WORDSIZE total number of bits
*/
define(A, `t10')
define(B, `t11')
define(RESULT, `t12')
define(BIT, `t0')
define(I, `t1')
define(CC, `t2')
define(T_0, `t3')
ifelse(S, `true', `define(NEG, `t4')')
#include <machine/asm.h>
LEAF(NAME, 0) /* XXX */
lda sp, -64(sp)
stq BIT, 0(sp)
stq I, 8(sp)
stq CC, 16(sp)
stq T_0, 24(sp)
ifelse(S, `true',
` stq NEG, 32(sp)')
stq A, 40(sp)
stq B, 48(sp)
mov zero, RESULT /* Initialize result to zero */
ifelse(S, `true',
`
/* Compute sign of result. If either is negative, this is easy. */
or A, B, NEG /* not the sign, but... */
srl NEG, WORDSIZE - 1, NEG /* rather, or of high bits */
blbc NEG, Ldoit /* neither negative? do it! */
ifelse(OP, `div',
` xor A, B, NEG /* THIS is the sign! */
', ` mov A, NEG /* sign follows A. */
')
srl NEG, WORDSIZE - 1, NEG /* make negation the low bit. */
srl A, WORDSIZE - 1, I /* is A negative? */
blbc I, LnegB /* no. */
/* A is negative; flip it. */
ifelse(WORDSIZE, `32', `
/* top 32 bits may be random junk */
zap A, 0xf0, A
')
subq zero, A, A
srl B, WORDSIZE - 1, I /* is B negative? */
blbc I, Ldoit /* no. */
LnegB:
/* B is definitely negative, no matter how we got here. */
ifelse(WORDSIZE, `32', `
/* top 32 bits may be random junk */
zap B, 0xf0, B
')
subq zero, B, B
Ldoit:
')
ifelse(WORDSIZE, `32', `
/*
* Clear the top 32 bits of each operand, as they may
* sign extension (if negated above), or random junk.
*/
zap A, 0xf0, A
zap B, 0xf0, B
')
/* kill the special cases. */
beq B, Ldotrap /* division by zero! */
cmpult A, B, CC /* A < B? */
/* RESULT is already zero, from above. A is untouched. */
bne CC, Lret_result
cmpeq A, B, CC /* A == B? */
cmovne CC, 1, RESULT
cmovne CC, zero, A
bne CC, Lret_result
/*
* Find out how many bits of zeros are at the beginning of the divisor.
*/
LBbits:
ldiq T_0, 1 /* I = 0; BIT = 1<<WORDSIZE-1 */
mov zero, I
sll T_0, WORDSIZE-1, BIT
LBloop:
and B, BIT, CC /* if bit in B is set, done. */
bne CC, LAbits
addq I, 1, I /* increment I, shift bit */
srl BIT, 1, BIT
cmplt I, WORDSIZE-1, CC /* if I leaves one bit, done. */
bne CC, LBloop
LAbits:
beq I, Ldodiv /* If I = 0, divide now. */
ldiq T_0, 1 /* BIT = 1<<WORDSIZE-1 */
sll T_0, WORDSIZE-1, BIT
LAloop:
and A, BIT, CC /* if bit in A is set, done. */
bne CC, Ldodiv
subq I, 1, I /* decrement I, shift bit */
srl BIT, 1, BIT
bne I, LAloop /* If I != 0, loop again */
Ldodiv:
sll B, I, B /* B <<= i */
ldiq T_0, 1
sll T_0, I, BIT
Ldivloop:
cmpult A, B, CC
or RESULT, BIT, T_0
cmoveq CC, T_0, RESULT
subq A, B, T_0
cmoveq CC, T_0, A
srl BIT, 1, BIT
srl B, 1, B
beq A, Lret_result
bne BIT, Ldivloop
Lret_result:
ifelse(OP, `div',
`', ` mov A, RESULT
')
ifelse(S, `true',
`
/* Check to see if we should negate it. */
subq zero, RESULT, T_0
cmovlbs NEG, T_0, RESULT
')
ldq BIT, 0(sp)
ldq I, 8(sp)
ldq CC, 16(sp)
ldq T_0, 24(sp)
ifelse(S, `true',
` ldq NEG, 32(sp)')
ldq A, 40(sp)
ldq B, 48(sp)
lda sp, 64(sp)
ret zero, (t9), 1
Ldotrap:
ldiq a0, -2 /* This is the signal to SIGFPE! */
call_pal PAL_gentrap
ifelse(OP, `div',
`', ` mov zero, A /* so that zero will be returned */
')
br zero, Lret_result
END(NAME)

View file

@ -1,32 +0,0 @@
/* $NetBSD: htonl.S,v 1.1 1996/04/17 22:46:41 cgd Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#define NAME htonl
#include "byte_swap_4.S"

View file

@ -1,32 +0,0 @@
/* $NetBSD: htons.S,v 1.1 1996/04/17 22:46:43 cgd Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#define NAME htons
#include "byte_swap_2.S"

View file

@ -1,32 +0,0 @@
/* $NetBSD: ntohl.S,v 1.1 1996/04/17 22:46:45 cgd Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#define NAME ntohl
#include "byte_swap_4.S"

View file

@ -1,32 +0,0 @@
/* $NetBSD: ntohs.S,v 1.1 1996/04/17 22:46:46 cgd Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#define NAME ntohs
#include "byte_swap_2.S"

View file

@ -1,6 +0,0 @@
# $NetBSD: Makefile.inc,v 1.9 2009/08/14 19:23:53 dsl Exp $
SRCS+= byte_swap_2.S byte_swap_4.S
SRCS+= ffs.S
SRCS+= divsi3.S clzsi2.S
SRCS+= memcmp.S memcpy.S memset.S memmove.S strcmp.S strncmp.S

View file

@ -1,88 +0,0 @@
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas <matt@3am-software.com>
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <machine/asm.h>
.text
ENTRY(__clzdi2)
movs r3, r0
movne r0, #31
bne .L_clz
movs r3, r1
movne r0, #63
bne .L_clz
mov r0, #64
RET
END(__clzdi2)
ENTRY(__clzsi2)
movs r3, r0
moveq r0, #32
RETc(eq)
mov r0, #31
.L_clz:
mvn r1, #0
#ifndef __OPTIMIZE_SIZE__
eor r1, r1, r1, lsr #16 /* 0xFFFFFFFF -> 0xFFFF0000 */
ands r2, r3, r1
eorne r0, r0, #16
movne r3, r2
eor r1, r1, r1, lsr #8 /* 0xFFFF0000 -> 0xFF00FF00 */
ands r2, r3, r1
eorne r0, r0, #8
movne r3, r2
eor r1, r1, r1, lsr #4 /* 0xFF00FF00 -> 0xF0F0F0F0 */
ands r2, r3, r1
eorne r0, r0, #4
movne r3, r2
eor r1, r1, r1, lsr #2 /* 0xF0F0F0F0 -> 0xCCCCCCCC */
ands r2, r3, r1
eorne r0, r0, #2
movne r3, r2
eor r1, r1, r1, lsr #1 /* 0xCCCCCCCC -> 0xAAAAAAAA */
ands r2, r3, r1
eorne r0, r0, #1
#if 0
teqeq r3, #0
addeq r0, r0, #1
#endif
#else
mov r2, #16
1: eor r1, r1, r1, lsr r2
ands ip, r3, r1
movne r3, ip
eorne r0, r0, r2
movs r2, r2, lsr #1
bne 1b
#if 0
teq r3, #0
addeq r0, r0, #1
#endif
#endif /* __OPTIMIZE_SIZE__ */
RET
END(__clzsi2)

View file

@ -1,12 +0,0 @@
# $NetBSD: Makefile.inc,v 1.11 2009/09/22 09:57:16 pooka Exp $
SRCS+= milli.S
SRCS+= bcopy.S memcpy.S memmove.S
# XXX: spcopy does not really belong in libkern in the first place
.ifndef RUMPKERNEL
SRCS+= spcopy.S
.endif
SRCS+= ashrdi3.c divdi3.c
SRCS+= ffs.c bswap16.c bswap32.c

View file

@ -1,618 +0,0 @@
/* $NetBSD: bcopy.S,v 1.14 2011/01/31 12:10:58 skrll Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matthew Fredette.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Copy routines for NetBSD/hppa.
*/
#undef _LOCORE
#define _LOCORE /* XXX fredette - unfortunate */
#if defined(SPCOPY) && !defined(_STANDALONE)
#include "opt_multiprocessor.h"
#include <machine/cpu.h>
#endif
#include <machine/asm.h>
#include <machine/frame.h>
#include <machine/reg.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: bcopy.S,v 1.14 2011/01/31 12:10:58 skrll Exp $")
#endif /* LIBC_SCCS and not lint */
/*
* The stbys instruction is a little asymmetric. When (%r2 & 3)
* is zero, stbys,b,m %r1, 4(%r2) works like stws,ma. You
* might then wish that when (%r2 & 3) == 0, stbys,e,m %r1, -4(%r2)
* worked like stws,mb. But it doesn't.
*
* This macro works around this problem. It requires that %t2
* hold the number of bytes that will be written by this store
* (meaning that it ranges from one to four).
*
* Watch the delay-slot trickery here. The comib is used to set
* up which instruction, either the stws or the stbys, is run
* in the delay slot of the b instruction.
*/
#define _STBYS_E_M(r, dst_spc, dst_off) \
comib,<> 4, %t2, 4 ! \
b 4 ! \
stws,mb r, -4(dst_spc, dst_off) ! \
stbys,e,m r, 0(dst_spc, dst_off)
/*
* This macro does a bulk copy with no shifting. cmplt and m are
* the completer and displacement multiplier, respectively, for
* the load and store instructions.
*/
#define _COPY(src_spc, src_off, dst_spc, dst_off, count, cmplt, m) \
! \
/* ! \
* Loop storing 16 bytes at a time. Since count ! \
* may be > INT_MAX, we have to be careful and ! \
* avoid comparisons that treat it as a signed ! \
* quantity, until after this loop, when count ! \
* is guaranteed to be less than 16. ! \
*/ ! \
comib,>>=,n 15, count, _LABEL(_skip16) ! \
.label _LABEL(_loop16) ! \
addi -16, count, count ! \
ldws,cmplt m*4(src_spc, src_off), %t1 ! \
ldws,cmplt m*4(src_spc, src_off), %t2 ! \
ldws,cmplt m*4(src_spc, src_off), %t3 ! \
ldws,cmplt m*4(src_spc, src_off), %t4 ! \
stws,cmplt %t1, m*4(dst_spc, dst_off) ! \
stws,cmplt %t2, m*4(dst_spc, dst_off) ! \
stws,cmplt %t3, m*4(dst_spc, dst_off) ! \
comib,<< 15, count, _LABEL(_loop16) ! \
stws,cmplt %t4, m*4(dst_spc, dst_off) ! \
.label _LABEL(_skip16) ! \
! \
/* Loop storing 4 bytes at a time. */ ! \
addib,<,n -4, count, _LABEL(_skip4) ! \
.label _LABEL(_loop4) ! \
ldws,cmplt m*4(src_spc, src_off), %t1 ! \
addib,>= -4, count, _LABEL(_loop4) ! \
stws,cmplt %t1, m*4(dst_spc, dst_off) ! \
.label _LABEL(_skip4) ! \
/* Restore the correct count. */ ! \
addi 4, count, count ! \
! \
.label _LABEL(_do1) ! \
! \
/* Loop storing 1 byte at a time. */ ! \
addib,<,n -1, count, _LABEL(_skip1) ! \
.label _LABEL(_loop1) ! \
ldbs,cmplt m*1(src_spc, src_off), %t1 ! \
addib,>= -1, count, _LABEL(_loop1) ! \
stbs,cmplt %t1, m*1(dst_spc, dst_off) ! \
.label _LABEL(_skip1) ! \
/* Restore the correct count. */ ! \
b _LABEL(_done) ! \
addi 1, count, count
/*
* This macro is definitely strange. It exists purely to
* allow the _COPYS macro to be reused, but because it
* requires this long attempt to explain it, I'm starting
* to doubt the value of that.
*
* Part of the expansion of the _COPYS macro below are loops
* that copy four words or one word at a time, performing shifts
* to get data to line up correctly in the destination buffer.
*
* The _COPYS macro is used when copying backwards, as well
* as forwards. The 4-word loop always loads into %t1, %t2, %t3,
* and %t4 in that order. This means that when copying forward,
* %t1 will have the word from the lowest address, and %t4 will
* have the word from the highest address. When copying
* backwards, the opposite is true.
*
* The shift instructions need pairs of registers with adjacent
* words, with the register containing the word from the lowest
* address *always* coming first. It is this assymetry that
* gives rise to this macro - depending on which direction
* we're copying in, these ordered pairs are different.
*
* Fortunately, we can compute those register numbers at compile
* time, and assemble them manually into a shift instruction.
* That's what this macro does.
*
* This macro takes two arguments. n ranges from 0 to 3 and
* is the "shift number", i.e., n = 0 means we're doing the
* shift for what will be the first store.
*
* m is the displacement multiplier from the _COPYS macro call.
* This is 1 for a forward copy and -1 for a backwards copy.
* So, the ((m + 1) / 2) term yields 0 for a backwards copy and
* 1 for a forward copy, and the ((m - 1) / 2) term yields
* 0 for a forward copy, and -1 for a backwards copy.
* These terms are used to discriminate the register computations
* below.
*
* When copying forward, then, the first register used with
* the first vshd will be 19 + (3 - ((0 - 1) & 3)), or %t4,
* which matches _COPYS' requirement that the word last loaded
* be in %t4. The first register used for the second vshd
* will then "wrap" around to 19 + (3 - ((1 - 1) & 3)), or %t1.
* And so on to %t2 and %t3.
*
* When copying forward, the second register used with the first
* vshd will be (19 + (3 - ((n + 0) & 3)), or %t1. It will
* continue to be %t2, then %t3, and finally %t4.
*
* When copying backwards, the values for the first and second
* register for each vshd are reversed from the forwards case.
* (Symmetry reclaimed!) Proving this is "left as an exercise
* for the reader" (remember the different discriminating values!)
*/
#define _VSHD(n, m, t) \
.word (0xd0000000 | \
((19 + (3 - ((n - 1 * ((m + 1) / 2)) & 3))) << 16) | \
((19 + (3 - ((n + 1 * ((m - 1) / 2)) & 3))) << 21) | \
(t))
/*
* This macro does a bulk copy with shifting. cmplt and m are
* the completer and displacement multiplier, respectively, for
* the load and store instructions. It is assumed that the
* word last loaded is already in %t4.
*/
#define _COPYS(src_spc, src_off, dst_spc, dst_off, count, cmplt, m) \
! \
/* ! \
* Loop storing 16 bytes at a time. Since count ! \
* may be > INT_MAX, we have to be careful and ! \
* avoid comparisons that treat it as a signed ! \
* quantity, until after this loop, when count ! \
* is guaranteed to be less than 16. ! \
*/ ! \
comib,>>=,n 15, count, _LABEL(S_skip16) ! \
.label _LABEL(S_loop16) ! \
addi -16, count, count ! \
ldws,cmplt m*4(src_spc, src_off), %t1 ! \
ldws,cmplt m*4(src_spc, src_off), %t2 ! \
ldws,cmplt m*4(src_spc, src_off), %t3 ! \
_VSHD(0, m, 1) /* vshd %t4, %t1, %r1 */ ! \
ldws,cmplt m*4(src_spc, src_off), %t4 ! \
_VSHD(1, m, 22) /* vshd %t1, %t2, %t1 */ ! \
_VSHD(2, m, 21) /* vshd %t2, %t3, %t2 */ ! \
_VSHD(3, m, 20) /* vshd %t3, %t4, %t3 */ ! \
stws,cmplt %r1, m*4(dst_spc, dst_off) ! \
stws,cmplt %t1, m*4(dst_spc, dst_off) ! \
stws,cmplt %t2, m*4(dst_spc, dst_off) ! \
comib,<< 15, count, _LABEL(S_loop16) ! \
stws,cmplt %t3, m*4(dst_spc, dst_off) ! \
.label _LABEL(S_skip16) ! \
! \
/* Loop storing 4 bytes at a time. */ ! \
addib,<,n -4, count, _LABEL(S_skip4) ! \
.label _LABEL(S_loop4) ! \
ldws,cmplt m*4(src_spc, src_off), %t1 ! \
_VSHD(0, m, 1) /* into %r1 (1) */ ! \
copy %t1, %t4 ! \
addib,>= -4, count, _LABEL(S_loop4) ! \
stws,cmplt %r1, m*4(dst_spc, dst_off) ! \
.label _LABEL(S_skip4) ! \
! \
/* ! \
* We now need to "back up" src_off by the ! \
* number of bytes remaining in the FIFO ! \
* (i.e., the number of bytes remaining in %t4), ! \
* because (the correct) count still includes ! \
* these bytes, and we intent to keep it that ! \
* way, and finish with the single-byte copier. ! \
* ! \
* The number of bytes remaining in the FIFO is ! \
* related to the shift count, so recover it, ! \
* restoring the correct count at the same time. ! \
*/ ! \
mfctl %cr11, %t1 ! \
addi 4, count, count ! \
shd %r0, %t1, 3, %t1 ! \
! \
/* ! \
* If we're copying forward, the shift count ! \
* is the number of bytes remaining in the ! \
* FIFO, and we want to subtract it from src_off. ! \
* If we're copying backwards, (4 - shift count) ! \
* is the number of bytes remaining in the FIFO, ! \
* and we want to add it to src_off. ! \
* ! \
* We observe that x + (4 - y) = x - (y - 4), ! \
* and introduce this instruction to add -4 when ! \
* m is -1, although this does mean one extra ! \
* instruction in the forward case. ! \
*/ ! \
addi 4*((m - 1) / 2), %t1, %t1 ! \
! \
/* Now branch to the byte-at-a-time loop. */ ! \
b _LABEL(_do1) ! \
sub src_off, %t1, src_off
/*
* This macro copies a region in the forward direction.
*/
#define _COPY_FORWARD(src_spc, src_off, dst_spc, dst_off, count) \
! \
/* ! \
* Since in the shifting-left case we will ! \
* load 8 bytes before checking count, to ! \
* keep things simple, branch to the byte ! \
* copier unless we're copying at least 8. ! \
*/ ! \
comib,>>,n 8, count, _LABEL(_do1) ! \
! \
/* ! \
* Once we 4-byte align the source offset, ! \
* figure out how many bytes from the region ! \
* will be in the first 4-byte word we read. ! \
* Ditto for writing the destination offset. ! \
*/ ! \
extru src_off, 31, 2, %t1 ! \
extru dst_off, 31, 2, %t2 ! \
subi 4, %t1, %t1 ! \
subi 4, %t2, %t2 ! \
! \
/* ! \
* Calculate the byte shift required. A ! \
* positive value means a source 4-byte word ! \
* has to be shifted to the right to line up ! \
* as a destination 4-byte word. ! \
*/ ! \
sub %t1, %t2, %t1 ! \
! \
/* 4-byte align src_off. */ ! \
depi 0, 31, 2, src_off ! \
! \
/* ! \
* It's somewhat important to note that this ! \
* code thinks of count as "the number of bytes ! \
* that haven't been stored yet", as opposed to ! \
* "the number of bytes that haven't been copied ! \
* yet". The distinction is subtle, but becomes ! \
* apparent at the end of the shifting code, where ! \
* we "back up" src_off to correspond to count, ! \
* as opposed to flushing the FIFO. ! \
* ! \
* We calculated above how many bytes our first ! \
* store will store, so update count now. ! \
* ! \
* If the shift is zero, strictly as an optimization ! \
* we use a copy loop that does no shifting. ! \
*/ ! \
comb,<> %r0, %t1, _LABEL(_shifting) ! \
sub count, %t2, count ! \
! \
/* Load and store the first word. */ ! \
ldws,ma 4(src_spc, src_off), %t4 ! \
stbys,b,m %t4, 4(dst_spc, dst_off) ! \
! \
/* Do the rest of the copy. */ ! \
_COPY(src_spc,src_off,dst_spc,dst_off,count,ma,1) ! \
! \
.label _LABEL(_shifting) ! \
! \
/* ! \
* If shift < 0, we need to shift words to the ! \
* left. Since we can't do this directly, we ! \
* adjust the shift so it's a shift to the right ! \
* and load the first word into the high word of ! \
* the FIFO. Otherwise, we load a zero into the ! \
* high word of the FIFO. ! \
*/ ! \
comb,<= %r0, %t1, _LABEL(_shiftingrt) ! \
copy %r0, %t3 ! \
addi 4, %t1, %t1 ! \
ldws,ma 4(src_spc, src_off), %t3 ! \
.label _LABEL(_shiftingrt) ! \
! \
/* ! \
* Turn the shift byte count into a bit count, ! \
* load the next word, set the Shift Amount ! \
* Register, and form and store the first word. ! \
*/ ! \
sh3add %t1, %r0, %t1 ! \
ldws,ma 4(src_spc, src_off), %t4 ! \
mtctl %t1, %cr11 ! \
vshd %t3, %t4, %r1 ! \
stbys,b,m %r1, 4(dst_spc, dst_off) ! \
! \
/* Do the rest of the copy. */ ! \
_COPYS(src_spc,src_off,dst_spc,dst_off,count,ma,1)
/* This macro copies a region in the reverse direction. */
#define _COPY_REVERSE(src_spc, src_off, dst_spc, dst_off, count) \
! \
/* Immediately add count to both offsets. */ ! \
add src_off, count, src_off ! \
add dst_off, count, dst_off ! \
! \
/* ! \
* Since in the shifting-right case we ! \
* will load 8 bytes before checking ! \
* count, to keep things simple, branch ! \
* to the byte copier unless we're ! \
* copying at least 8 bytes. ! \
*/ ! \
comib,>>,n 8, count, _LABEL(_do1) ! \
! \
/* ! \
* Once we 4-byte align the source offset, ! \
* figure out how many bytes from the region ! \
* will be in the first 4-byte word we read. ! \
* Ditto for writing the destination offset. ! \
*/ ! \
extru,<> src_off, 31, 2, %t1 ! \
ldi 4, %t1 ! \
extru,<> dst_off, 31, 2, %t2 ! \
ldi 4, %t2 ! \
! \
/* ! \
* Calculate the byte shift required. A ! \
* positive value means a source 4-byte ! \
* word has to be shifted to the right to ! \
* line up as a destination 4-byte word. ! \
*/ ! \
sub %t2, %t1, %t1 ! \
! \
/* ! \
* 4-byte align src_off, leaving it pointing ! \
* to the 4-byte word *after* the next word ! \
* we intend to load. ! \
* ! \
* It's somewhat important to note that this ! \
* code thinks of count as "the number of bytes ! \
* that haven't been stored yet", as opposed to ! \
* "the number of bytes that haven't been copied ! \
* yet". The distinction is subtle, but becomes ! \
* apparent at the end of the shifting code, where ! \
* we "back up" src_off to correspond to count, ! \
* as opposed to flushing the FIFO. ! \
* ! \
* We calculated above how many bytes our first ! \
* store will store, so update count now. ! \
* ! \
* If the shift is zero, we use a copy loop that ! \
* does no shifting. NB: unlike the forward case, ! \
* this is NOT strictly an optimization. If the ! \
* SAR is zero the vshds do NOT do the right thing. ! \
* This is another assymetry more or less the "fault" ! \
* of vshd. ! \
*/ ! \
addi 3, src_off, src_off ! \
sub count, %t2, count ! \
comb,<> %r0, %t1, _LABEL(_shifting) ! \
depi 0, 31, 2, src_off ! \
! \
/* Load and store the first word. */ ! \
ldws,mb -4(src_spc, src_off), %t4 ! \
_STBYS_E_M(%t4, dst_spc, dst_off) ! \
! \
/* Do the rest of the copy. */ ! \
_COPY(src_spc,src_off,dst_spc,dst_off,count,mb,-1) ! \
! \
.label _LABEL(_shifting) ! \
! \
/* ! \
* If shift < 0, we need to shift words to the ! \
* left. Since we can't do this directly, we ! \
* adjust the shift so it's a shift to the right ! \
* and load a zero in to the low word of the FIFO. ! \
* Otherwise, we load the first word into the ! \
* low word of the FIFO. ! \
* ! \
* Note the nullification trickery here. We ! \
* assume that we're shifting to the left, and ! \
* load zero into the low word of the FIFO. Then ! \
* we nullify the addi if we're shifting to the ! \
* right. If the addi is not nullified, we are ! \
* shifting to the left, so we nullify the load. ! \
* we branch if we're shifting to the ! \
*/ ! \
copy %r0, %t3 ! \
comb,<=,n %r0, %t1, 0 ! \
addi,tr 4, %t1, %t1 ! \
ldws,mb -4(src_spc, src_off), %t3 ! \
! \
/* ! \
* Turn the shift byte count into a bit count, ! \
* load the next word, set the Shift Amount ! \
* Register, and form and store the first word. ! \
*/ ! \
sh3add %t1, %r0, %t1 ! \
ldws,mb -4(src_spc, src_off), %t4 ! \
mtctl %t1, %cr11 ! \
vshd %t4, %t3, %r1 ! \
_STBYS_E_M(%r1, dst_spc, dst_off) ! \
! \
/* Do the rest of the copy. */ ! \
_COPYS(src_spc,src_off,dst_spc,dst_off,count,mb,-1)
/*
* For paranoia, when things aren't going well, enable this
* code to assemble byte-at-a-time-only copying.
*/
#if 1
#undef _COPY_FORWARD
#define _COPY_FORWARD(src_spc, src_off, dst_spc, dst_off, count) \
comb,=,n %r0, count, _LABEL(_done) ! \
ldbs,ma 1(src_spc, src_off), %r1 ! \
addib,<> -1, count, -12 ! \
stbs,ma %r1, 1(dst_spc, dst_off) ! \
b,n _LABEL(_done)
#undef _COPY_REVERSE
#define _COPY_REVERSE(src_spc, src_off, dst_spc, dst_off, count) \
comb,= %r0, count, _LABEL(_done) ! \
add src_off, count, src_off ! \
add dst_off, count, dst_off ! \
ldbs,mb -1(src_spc, src_off), %r1 ! \
addib,<> -1, count, -12 ! \
stbs,mb %r1, -1(dst_spc, dst_off) ! \
b,n _LABEL(_done)
#endif
/*
* If none of the following are defined, define BCOPY.
*/
#if !(defined(SPCOPY) || defined(MEMCPY) || defined(MEMMOVE))
#define BCOPY
#endif
#if defined(SPCOPY) && !defined(_STANDALONE)
#include <sys/errno.h>
#include "assym.h"
/*
* int spcopy(pa_space_t ssp, const void *src, pa_space_t dsp, void *dst,
* size_t len)
*
* We assume that the regions do not overlap.
*/
LEAF_ENTRY(spcopy)
/*
* Setup the fault handler, which will fill in %ret0 if triggered.
*/
GET_CURLWP(%r31)
#ifdef DIAGNOSTIC
comb,<>,n %r0, %r31, Lspcopy_curlwp_ok
ldil L%panic, %r1
ldil L%Lspcopy_curlwp_bad, %arg0
ldo R%panic(%r1), %r1
ldo R%Lspcopy_curlwp_bad(%arg0), %arg0
.call
bv,n %r0(%r1)
nop
Lspcopy_curlwp_bad:
.asciz "spcopy: curlwp == NULL\n"
.align 8
Lspcopy_curlwp_ok:
#endif /* DIAGNOSTIC */
ldil L%spcopy_fault, %r1
ldw L_PCB(%r31), %r31
ldo R%spcopy_fault(%r1), %r1
stw %r1, PCB_ONFAULT(%r31)
/* Setup the space registers. */
mfsp %sr2, %ret1
mtsp %arg0, %sr1
mtsp %arg2, %sr2
/* Get the len argument and do the copy. */
ldw HPPA_FRAME_ARG(4)(%sp), %arg0
#define _LABEL(l) __CONCAT(spcopy,l)
_COPY_FORWARD(%sr1,%arg1,%sr2,%arg3,%arg0)
_LABEL(_done):
/* Return. */
copy %r0, %ret0
ALTENTRY(spcopy_fault)
stw %r0, PCB_ONFAULT(%r31)
bv %r0(%rp)
mtsp %ret1, %sr2
EXIT(spcopy)
#endif /* SPCOPY && !_STANDALONE */
#ifdef MEMCPY
/*
* void *memcpy(void *restrict dst, const void *restrict src, size_t len);
*
* memcpy is specifically restricted to working on
* non-overlapping regions, so we can just copy forward.
*/
LEAF_ENTRY(memcpy)
copy %arg0, %ret0
#define _LABEL(l) __CONCAT(memcpy,l)
_COPY_FORWARD(%sr0,%arg1,%sr0,%arg0,%arg2)
_LABEL(_done):
bv,n %r0(%rp)
nop
EXIT(memcpy)
#endif /* MEMCPY */
#ifdef BCOPY
/*
* void bcopy(const void *src, void *dst, size_t len);
*/
LEAF_ENTRY(bcopy)
copy %arg0, %r1
copy %arg1, %arg0
copy %r1, %arg1
/* FALLTHROUGH */
#define _LABEL_F(l) __CONCAT(bcopy_F,l)
#define _LABEL_R(l) __CONCAT(bcopy_R,l)
#endif
#ifdef MEMMOVE
/*
* void *memmove(void *dst, const void *src, size_t len);
*/
LEAF_ENTRY(memmove)
#define _LABEL_F(l) __CONCAT(memmove_F,l)
#define _LABEL_R(l) __CONCAT(memmove_R,l)
copy %arg0, %ret0
#endif /* MEMMOVE */
#if defined(BCOPY) || defined(MEMMOVE)
/*
* If src >= dst or src + len <= dst, we copy
* forward, else we copy in reverse.
*/
add %arg1, %arg2, %r1
comb,>>=,n %arg1, %arg0, 0
comb,>>,n %r1, %arg0, _LABEL_R(_go)
#define _LABEL _LABEL_F
_COPY_FORWARD(%sr0,%arg1,%sr0,%arg0,%arg2)
#undef _LABEL
_LABEL_R(_go):
#define _LABEL _LABEL_R
_COPY_REVERSE(%sr0,%arg1,%sr0,%arg0,%arg2)
#undef _LABEL
_LABEL_F(_done):
_LABEL_R(_done):
bv,n %r0(%rp)
nop
#ifdef BCOPY
EXIT(bcopy)
#else
EXIT(memmove)
#endif
#endif /* BCOPY || MEMMOVE */

View file

@ -1,4 +0,0 @@
/* $NetBSD: memcpy.S,v 1.1 2002/06/06 20:03:38 fredette Exp $ */
#define MEMCPY
#include "bcopy.S"

View file

@ -1,4 +0,0 @@
/* $NetBSD: memmove.S,v 1.1 2002/06/06 20:03:38 fredette Exp $ */
#define MEMMOVE
#include "bcopy.S"

File diff suppressed because it is too large Load diff

View file

@ -1,85 +0,0 @@
/* $NetBSD: prefix.h,v 1.1 2002/06/06 20:03:39 fredette Exp $ */
/* $OpenBSD: prefix.h,v 1.2 2001/03/29 04:08:21 mickey Exp $ */
/*
* (c) Copyright 1985 HEWLETT-PACKARD COMPANY
*
* To anyone who acknowledges that this file is provided "AS IS"
* without any express or implied warranty:
* permission to use, copy, modify, and distribute this file
* for any purpose is hereby granted without fee, provided that
* the above copyright notice and this notice appears in all
* copies, and that the name of Hewlett-Packard Company not be
* used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission.
* Hewlett-Packard Company makes no representations about the
* suitability of this software for any purpose.
*/
/*
* STANDARD INCLUDE FILE FOR MILLICODE
* Every source file must include this file.
*
* Hardware General Registers
*
* Frame Offsets (millicode convention!)
* Used when calling other millicode routines.
* Stack unwinding is dependent upon these definitions.
* r31_slot .equ -20
* sr0_slot .equ -16
*/
#include <machine/asm.h>
#define DEFINE(name, value)name: .EQU value
#ifdef milliext
#ifdef PIC
#define MILLI_BE(lbl) \
BL .+8,r1\
! ADDIL L%lbl-labl/**/lbl,r1\
! .LABEL labl/**/lbl\
! BE R%lbl-labl/**/lbl(sr7,r1)
#define MILLI_BEN(lbl) \
BL .+8,r1\
! ADDIL L%lbl-labl/**/lbl,r1\
! .LABEL labl/**/lbl\
! BE,N R%lbl-labl/**/lbl(sr7,r1)
#define MILLI_BLE(lbl) \
BL .+8,r1\
! ADDIL L%lbl-labl/**/lbl,r1\
! .LABEL labl/**/lbl \
! BLE R%lbl-labl/**/lbl(sr7,r1)
#define MILLI_BLEN(lbl) \
BL .+8,r1\
! ADDIL L%lbl-labl/**/lbl,r1\
! .LABEL labl/**/lbl\
! BLE,N R%lbl-labl/**/lbl(sr7,r1)
#else
#define MILLI_BE(lbl) BE lbl(sr7,r0)
#define MILLI_BEN(lbl) BE,n lbl(sr7,r0)
#define MILLI_BLE(lbl) BLE lbl(sr7,r0)
#define MILLI_BLEN(lbl) BLE,n lbl(sr7,r0)
#endif
#define MILLIRETN BE,n 0(sr0,r31)
#define MILLIRET BE 0(sr0,r31)
#define MILLI_RETN BE,n 0(sr0,r31)
#define MILLI_RET BE 0(sr0,r31)
#else
#define MILLI_BE(lbl) B lbl
#define MILLI_BEN(lbl) B,n lbl
#define MILLI_BLE(lbl) BL lbl,r31
#define MILLI_BLEN(lbl) BL,n lbl,r31
#define MILLIRETN BV,n 0(r31)
#define MILLIRET BV 0(r31)
#define MILLI_RETN BV,n 0(r31)
#define MILLI_RET BV 0(r31)
#endif
; VERSION is used wherever ".version" can appear in a routine
;#define VERSION .version
#define VERSION ;

View file

@ -1,4 +0,0 @@
/* $NetBSD: spcopy.S,v 1.1 2002/06/06 20:03:39 fredette Exp $ */
#define SPCOPY
#include "bcopy.S"

View file

@ -1,11 +0,0 @@
# $NetBSD: Makefile.inc,v 1.31 2009/08/14 19:23:53 dsl Exp $
SRCS+= byte_swap_2.S byte_swap_4.S ffs.S
SRCS+= memchr.S memcmp.S memcpy.S memmove.S memset.S
SRCS+= random.S
SRCS+= strcat.S strchr.S strcmp.S
SRCS+= strcpy.S strlen.S
SRCS+= strrchr.S
SRCS+= scanc.S skpc.S
SRCS+= crc32.c

View file

@ -1,96 +0,0 @@
/* $NetBSD: random.S,v 1.6 2010/09/07 20:35:50 pooka Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Copyright (c) 1990,1993 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: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Here is a very good random number generator. This implementation is
* based on ``Two Fast Implementations of the "Minimal Standard" Random
* Number Generator'', David G. Carta, Communications of the ACM, Jan 1990,
* Vol 33 No 1. Do NOT modify this code unless you have a very thorough
* understanding of the algorithm. It's trickier than you think. If
* you do change it, make sure that its 10,000'th invocation returns
* 1043618065.
*
* Here is easier-to-decipher pseudocode:
*
* p = (16807*seed)<30:0> # e.g., the low 31 bits of the product
* q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32
* if (p + q < 2^31)
* seed = p + q
* else
* seed = ((p + q) & (2^31 - 1)) + 1
* return (seed);
*
* The result is in (0,2^31), e.g., it's always positive.
*/
#include <machine/asm.h>
.data
randseed:
.long 1
.text
ENTRY(random)
movl $16807,%eax
PIC_PROLOGUE
imull PIC_GOTOFF(randseed)
PIC_EPILOGUE
shld $1,%eax,%edx
andl $0x7fffffff,%eax
addl %edx,%eax
js neg
PIC_PROLOGUE
movl %eax,PIC_GOTOFF(randseed)
PIC_EPILOGUE
ret
neg:
subl $0x7fffffff,%eax
PIC_PROLOGUE
movl %eax,PIC_GOTOFF(randseed)
PIC_EPILOGUE
ret

View file

@ -1,8 +0,0 @@
# $NetBSD: Makefile.inc,v 1.4 2009/08/14 19:23:54 dsl Exp $
#
SRCS+= ffs.c
SRCS+= divdi3.S divsi3.S modsi3.S moddi3.S udivdi3.S udivsi3.S
SRCS+= umoddi3.S umodsi3.S bswap64.S bswap32.S bswap16.S ntohl.S htonl.S
SRCS+= memcpy.S

View file

@ -1,37 +0,0 @@
/* $NetBSD: bswap16.S,v 1.2 2006/04/07 14:27:33 cherry Exp $ */
/*-
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* from: NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd
* from: src/sys/libkern/ia64/htons.S,v 1.2 2002/02/18 20:35:21
*
* $FreeBSD$
*/
#define NAME bswap16
#include "byte_swap_2.S"

View file

@ -1,37 +0,0 @@
/* $NetBSD: bswap32.S,v 1.2 2006/04/07 14:27:33 cherry Exp $ */
/*-
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* from: NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd
* from: src/sys/libkern/ia64/htonl.S,v 1.2 2002/02/18 20:35:21
*
* $FreeBSD$
*/
#define NAME bswap32
#include "byte_swap_4.S"

View file

@ -1,37 +0,0 @@
/* $NetBSD: bswap64.S,v 1.1 2009/07/20 11:23:04 kiyohara Exp $ */
/*-
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* from: NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd
* from: src/sys/libkern/ia64/htonl.S,v 1.2 2002/02/18 20:35:21
*
* $FreeBSD$
*/
#define NAME bswap64
#include "byte_swap_8.S"

View file

@ -1,46 +0,0 @@
/* $NetBSD: byte_swap_2.S,v 1.2 2006/04/07 14:27:33 cherry Exp $ */
/*-
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <machine/asm.h>
#ifndef NAME
#error NAME not defined
#endif
/*
* Byte-swap a 2-byte quantity. (Convert 0x0123 to 0x2301.)
*
* Argument is an unsigned 2-byte integer (u_int16_t).
*/
ENTRY(NAME, 1)
mux1 r16=in0,@rev
;;
extr.u r8=r16,48,16
br.ret.sptk.few rp
END(NAME)

View file

@ -1,46 +0,0 @@
/* $NetBSD: byte_swap_4.S,v 1.2 2006/04/07 14:27:33 cherry Exp $ */
/*-
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <machine/asm.h>
#ifndef NAME
#error NAME not defined
#endif
/*
* Byte-swap a 4-byte quantity. (Convert 0x01234567 to 0x67452301.)
*
* Argument is an unsigned 4-byte integer (u_int32_t).
*/
ENTRY(NAME, 1)
mux1 r16=in0,@rev
;;
extr.u r8=r16,32,32
br.ret.sptk.few rp
END(NAME)

View file

@ -1,45 +0,0 @@
/* $NetBSD: byte_swap_8.S,v 1.1 2009/07/20 11:23:04 kiyohara Exp $ */
/*-
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <machine/asm.h>
#ifndef NAME
#error NAME not defined
#endif
/*
* Byte-swap a 8-byte quantity.
* (Convert 0x0123456789012345 to 0x4523018967452301.)
*
* Argument is an unsigned 8-byte integer (u_int64_t).
*/
ENTRY(NAME, 1)
mux1 r8=in0,@rev
br.ret.sptk.few rp
END(NAME)

View file

@ -1,142 +0,0 @@
.file "__divdi3.s"
// $NetBSD: divdi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
.proc __divdi3#
.align 32
.global __divdi3#
.align 32
// 64-bit signed integer divide
__divdi3:
{ .mii
alloc r31=ar.pfs,2,0,0,0
nop.i 0
nop.i 0;;
} { .mmi
// 64-BIT SIGNED INTEGER DIVIDE BEGINS HERE
setf.sig f8=r32
setf.sig f9=r33
nop.i 0;;
} { .mfb
nop.m 0
fcvt.xf f6=f8
nop.b 0
} { .mfb
nop.m 0
fcvt.xf f7=f9
nop.b 0;;
} { .mfi
nop.m 0
// Step (1)
// y0 = 1 / b in f8
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// Step (2)
// e0 = 1 - b * y0 in f9
(p6) fnma.s1 f9=f7,f8,f1
nop.i 0
} { .mfi
nop.m 0
// Step (3)
// q0 = a * y0 in f10
(p6) fma.s1 f10=f6,f8,f0
nop.i 0;;
} { .mfi
nop.m 0
// Step (4)
// e1 = e0 * e0 in f11
(p6) fma.s1 f11=f9,f9,f0
nop.i 0
} { .mfi
nop.m 0
// Step (5)
// q1 = q0 + e0 * q0 in f10
(p6) fma.s1 f10=f9,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// Step (6)
// y1 = y0 + e0 * y0 in f8
(p6) fma.s1 f8=f9,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (7)
// q2 = q1 + e1 * q1 in f9
(p6) fma.s1 f9=f11,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// Step (8)
// y2 = y1 + e1 * y1 in f8
(p6) fma.s1 f8=f11,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (9)
// r2 = a - b * q2 in f10
(p6) fnma.s1 f10=f7,f9,f6
nop.i 0;;
} { .mfi
nop.m 0
// Step (10)
// q3 = q2 + r2 * y2 in f8
(p6) fma.s1 f8=f10,f8,f9
nop.i 0;;
} { .mfb
nop.m 0
// Step (11)
// q = trunc (q3)
fcvt.fx.trunc.s1 f8=f8
nop.b 0;;
} { .mmi
// quotient will be in r8 (if b != 0)
getf.sig r8=f8
nop.m 0
nop.i 0;;
}
// 64-BIT SIGNED INTEGER DIVIDE ENDS HERE
{ .mmb
nop.m 0
nop.m 0
br.ret.sptk b0;;
}
.endp __divdi3

View file

@ -1,124 +0,0 @@
.file "__divsi3.s"
// $NetBSD: divsi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
// 32-bit signed integer divide
.proc __divsi3#
.align 32
.global __divsi3#
.align 32
__divsi3:
{ .mii
alloc r31=ar.pfs,2,0,0,0
nop.i 0
nop.i 0;;
} { .mii
nop.m 0
// 32-BIT SIGNED INTEGER DIVIDE BEGINS HERE
// general register used:
// r32 - 32-bit signed integer dividend
// r33 - 32-bit signed integer divisor
// r8 - 32-bit signed integer result
// r2 - scratch register
// floating-point registers used: f6, f7, f8, f9
// predicate registers used: p6
sxt4 r32=r32
sxt4 r33=r33;;
} { .mmb
setf.sig f6=r32
setf.sig f7=r33
nop.b 0;;
} { .mfi
nop.m 0
fcvt.xf f6=f6
nop.i 0
} { .mfi
nop.m 0
fcvt.xf f7=f7
mov r2 = 0x0ffdd;;
} { .mfi
setf.exp f9 = r2
// (1) y0
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// (2) q0 = a * y0
(p6) fma.s1 f6=f6,f8,f0
nop.i 0
} { .mfi
nop.m 0
// (3) e0 = 1 - b * y0
(p6) fnma.s1 f7=f7,f8,f1
nop.i 0;;
} { .mfi
nop.m 0
// (4) q1 = q0 + e0 * q0
(p6) fma.s1 f6=f7,f6,f6
nop.i 0
} { .mfi
nop.m 0
// (5) e1 = e0 * e0 + 2^-34
(p6) fma.s1 f7=f7,f7,f9
nop.i 0;;
} { .mfi
nop.m 0
// (6) q2 = q1 + e1 * q1
(p6) fma.s1 f8=f7,f6,f6
nop.i 0;;
} { .mfi
nop.m 0
// (7) q = trunc(q2)
fcvt.fx.trunc.s1 f8=f8
nop.i 0;;
} { .mmi
// quotient will be in the least significant 32 bits of r8 (if b != 0)
getf.sig r8=f8
nop.m 0
nop.i 0;;
}
// 32-BIT SIGNED INTEGER DIVIDE ENDS HERE
{ .mmb
nop.m 0
nop.m 0
br.ret.sptk b0;;
}
.endp __divsi3

View file

@ -1,32 +0,0 @@
/* $NetBSD: htonl.S,v 1.1 2006/04/07 13:57:43 cherry Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#define NAME htonl
#include "byte_swap_4.S"

View file

@ -1,4 +0,0 @@
/* $NetBSD: memcpy.S,v 1.1 2006/04/07 13:57:43 cherry Exp $ */
#include <machine/asm.h>

View file

@ -1,159 +0,0 @@
.file "__moddi3.s"
// $NetBSD: moddi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
// 64-bit signed integer remainder
.proc __moddi3#
.align 32
.global __moddi3#
.align 32
__moddi3:
{ .mii
alloc r31=ar.pfs,3,0,0,0
nop.i 0
nop.i 0
} { .mmb
// 64-BIT SIGNED INTEGER REMAINDER BEGINS HERE
// general register used:
// r32 - 64-bit signed integer dividend, called a below
// r33 - 64-bit signed integer divisor, called b below
// r8 - 64-bit signed integer result
// r2 - scratch register
// floating-point registers used: f6, f7, f8, f9, f10, f11, f12
// predicate registers used: p6
setf.sig f12=r32 // holds a in integer form
setf.sig f7=r33
nop.b 0
} { .mlx
nop.m 0
//movl r2=0x8000000000000000;;
movl r2=0xffffffffffffffff;;
} { .mfi
// get the 2's complement of b
sub r33=r0,r33
fcvt.xf f6=f12
nop.i 0
} { .mfi
nop.m 0
fcvt.xf f7=f7
nop.i 0;;
} { .mfi
nop.m 0
// Step (1)
// y0 = 1 / b in f8
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// Step (2)
// q0 = a * y0 in f10
(p6) fma.s1 f10=f6,f8,f0
nop.i 0
} { .mfi
nop.m 0
// Step (3)
// e0 = 1 - b * y0 in f9
(p6) fnma.s1 f9=f7,f8,f1
nop.i 0;;
} { .mfi
nop.m 0
// Step (4)
// q1 = q0 + e0 * q0 in f10
(p6) fma.s1 f10=f9,f10,f10
nop.i 0
} { .mfi
nop.m 0
// Step (5)
// e1 = e0 * e0 in f11
(p6) fma.s1 f11=f9,f9,f0
nop.i 0;;
} { .mfi
nop.m 0
// Step (6)
// y1 = y0 + e0 * y0 in f8
(p6) fma.s1 f8=f9,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (7)
// q2 = q1 + e1 * q1 in f9
(p6) fma.s1 f9=f11,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// Step (8)
// y2 = y1 + e1 * y1 in f8
(p6) fma.s1 f8=f11,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (9)
// r2 = a - b * q2 in f10
(p6) fnma.s1 f10=f7,f9,f6
nop.i 0;;
} { .mfi
setf.sig f7=r33
// Step (10)
// q3 = q2 + r2 * y2 in f8
(p6) fma.s1 f8=f10,f8,f9
nop.i 0;;
} { .mfi
nop.m 0
// (11) q = trunc(q3)
fcvt.fx.trunc.s1 f8=f8
nop.i 0;;
} { .mfi
nop.m 0
// (12) r = a + (-b) * q
xma.l f8=f8,f7,f12
nop.i 0;;
} { .mib
getf.sig r8=f8
nop.i 0
nop.b 0
}
// 64-BIT SIGNED INTEGER REMAINDER ENDS HERE
{ .mib
nop.m 0
nop.i 0
br.ret.sptk b0;;
}
.endp __moddi3

View file

@ -1,131 +0,0 @@
.file "__modsi3.s"
// $NetBSD: modsi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
// 32-bit signed integer remainder
.proc __modsi3#
.align 32
.global __modsi3#
.align 32
__modsi3:
{ .mii
alloc r31=ar.pfs,2,0,0,0
nop.i 0
nop.i 0;;
} { .mii
nop.m 0
// 32-BIT SIGNED INTEGER REMAINDER BEGINS HERE
// general register used:
// r32 - 32-bit signed integer dividend
// r33 - 32-bit signed integer divisor
// r8 - 32-bit signed integer result
// r2 - scratch register
// floating-point registers used: f6, f7, f8, f9, f10, f11
// predicate registers used: p6
sxt4 r32=r32
sxt4 r33=r33;;
} { .mmb
setf.sig f11=r32
setf.sig f7=r33
nop.b 0;;
} { .mfi
// get 2's complement of b
sub r33=r0,r33
fcvt.xf f6=f11
nop.i 0
} { .mfi
nop.m 0
fcvt.xf f7=f7
mov r2 = 0x0ffdd;;
} { .mfi
setf.exp f9 = r2
// (1) y0
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// (2) q0 = a * y0
(p6) fma.s1 f10=f6,f8,f0
nop.i 0
} { .mfi
nop.m 0
// (3) e0 = 1 - b * y0
(p6) fnma.s1 f8=f7,f8,f1
nop.i 0;;
} { .mfi
// 2's complement of b
setf.sig f7=r33
// (4) q1 = q0 + e0 * q0
(p6) fma.s1 f10=f8,f10,f10
nop.i 0
} { .mfi
nop.m 0
// (5) e1 = e0 * e0 + 2^-34
(p6) fma.s1 f8=f8,f8,f9
nop.i 0;;
} { .mfi
nop.m 0
// (6) q2 = q1 + e1 * q1
(p6) fma.s1 f8=f8,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// (7) q = trunc(q2)
fcvt.fx.trunc.s1 f8=f8
nop.i 0;;
} { .mfi
nop.m 0
// (8) r = a + (-b) * q
xma.l f8=f8,f7,f11
nop.i 0;;
} { .mmi
// remainder will be in the least significant 32 bits of r8 (if b != 0)
getf.sig r8=f8
nop.m 0
nop.i 0;;
}
// 32-BIT SIGNED INTEGER REMAINDER ENDS HERE
{ .mmb
nop.m 0
nop.m 0
br.ret.sptk b0;;
}
.endp __modsi3

View file

@ -1,32 +0,0 @@
/* $NetBSD: ntohl.S,v 1.1 2006/04/07 13:57:43 cherry Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#define NAME ntohl
#include "byte_swap_4.S"

View file

@ -1,143 +0,0 @@
.file "__udivdi3.s"
// $NetBSD: udivdi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
.proc __udivdi3#
.align 32
.global __udivdi3#
.align 32
// 64-bit unsigned integer divide
__udivdi3:
{ .mii
alloc r31=ar.pfs,2,0,0,0
nop.i 0
nop.i 0;;
}
{ .mmi
// 64-BIT UNSIGNED INTEGER DIVIDE BEGINS HERE
setf.sig f8=r32
setf.sig f9=r33
nop.i 0;;
} { .mfb
nop.m 0
fma.s1 f6=f8,f1,f0
nop.b 0
} { .mfb
nop.m 0
fma.s1 f7=f9,f1,f0
nop.b 0;;
} { .mfi
nop.m 0
// Step (1)
// y0 = 1 / b in f8
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// Step (2)
// e0 = 1 - b * y0 in f9
(p6) fnma.s1 f9=f7,f8,f1
nop.i 0
} { .mfi
nop.m 0
// Step (3)
// q0 = a * y0 in f10
(p6) fma.s1 f10=f6,f8,f0
nop.i 0;;
} { .mfi
nop.m 0
// Step (4)
// e1 = e0 * e0 in f11
(p6) fma.s1 f11=f9,f9,f0
nop.i 0
} { .mfi
nop.m 0
// Step (5)
// q1 = q0 + e0 * q0 in f10
(p6) fma.s1 f10=f9,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// Step (6)
// y1 = y0 + e0 * y0 in f8
(p6) fma.s1 f8=f9,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (7)
// q2 = q1 + e1 * q1 in f9
(p6) fma.s1 f9=f11,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// Step (8)
// y2 = y1 + e1 * y1 in f8
(p6) fma.s1 f8=f11,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (9)
// r2 = a - b * q2 in f10
(p6) fnma.s1 f10=f7,f9,f6
nop.i 0;;
} { .mfi
nop.m 0
// Step (10)
// q3 = q2 + r2 * y2 in f8
(p6) fma.s1 f8=f10,f8,f9
nop.i 0;;
} { .mfb
nop.m 0
// (11) q = trunc(q3)
fcvt.fxu.trunc.s1 f8=f8
nop.b 0;;
} { .mmi
// quotient will be in r8 (if b != 0)
getf.sig r8=f8
nop.m 0
nop.i 0;;
}
// 64-BIT UNSIGNED INTEGER DIVIDE ENDS HERE
{ .mmb
nop.m 0
nop.m 0
br.ret.sptk b0;;
}
.endp __udivdi3

View file

@ -1,124 +0,0 @@
.file "__udivsi3.s"
// $NetBSD: udivsi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
// 32-bit unsigned integer divide
.proc __udivsi3#
.align 32
.global __udivsi3#
.align 32
__udivsi3:
{ .mii
alloc r31=ar.pfs,2,0,0,0
nop.i 0
nop.i 0;;
} { .mii
nop.m 0
// 32-BIT UNSIGNED INTEGER DIVIDE BEGINS HERE
// general register used:
// r32 - 32-bit unsigned integer dividend
// r33 - 32-bit unsigned integer divisor
// r8 - 32-bit unsigned integer result
// r2 - scratch register
// floating-point registers used: f6, f7, f8, f9
// predicate registers used: p6
zxt4 r32=r32
zxt4 r33=r33;;
} { .mmb
setf.sig f6=r32
setf.sig f7=r33
nop.b 0;;
} { .mfi
nop.m 0
fcvt.xf f6=f6
nop.i 0
} { .mfi
nop.m 0
fcvt.xf f7=f7
mov r2 = 0x0ffdd;;
} { .mfi
setf.exp f9 = r2
// (1) y0
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// (2) q0 = a * y0
(p6) fma.s1 f6=f6,f8,f0
nop.i 0
} { .mfi
nop.m 0
// (3) e0 = 1 - b * y0
(p6) fnma.s1 f7=f7,f8,f1
nop.i 0;;
} { .mfi
nop.m 0
// (4) q1 = q0 + e0 * q0
(p6) fma.s1 f6=f7,f6,f6
nop.i 0
} { .mfi
nop.m 0
// (5) e1 = e0 * e0 + 2^-34
(p6) fma.s1 f7=f7,f7,f9
nop.i 0;;
} { .mfi
nop.m 0
// (6) q2 = q1 + e1 * q1
(p6) fma.s1 f8=f7,f6,f6
nop.i 0;;
} { .mfi
nop.m 0
// (7) q = trunc(q2)
fcvt.fxu.trunc.s1 f8=f8
nop.i 0;;
} { .mmi
// quotient will be in the least significant 32 bits of r8 (if b != 0)
getf.sig r8=f8
nop.m 0
nop.i 0;;
}
// 32-BIT UNSIGNED INTEGER DIVIDE ENDS HERE
{ .mmb
nop.m 0
nop.m 0
br.ret.sptk b0;;
}
.endp __udivsi3

View file

@ -1,155 +0,0 @@
.file "__umoddi3.s"
// $NetBSD: umoddi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
// 64-bit unsigned integer remainder
.proc __umoddi3#
.align 32
.global __umoddi3#
.align 32
__umoddi3:
{ .mii
alloc r31=ar.pfs,3,0,0,0
nop.i 0
nop.i 0
} { .mmb
// 64-BIT UNSIGNED INTEGER REMAINDER BEGINS HERE
// general register used:
// r32 - 64-bit unsigned integer dividend, called a below
// r33 - 64-bit unsigned integer divisor, called b below
// r8 - 64-bit unsigned integer result
// floating-point registers used: f6, f7, f8, f9, f10, f11, f12
// predicate registers used: p6
setf.sig f12=r32 // holds a in integer form
setf.sig f7=r33
nop.b 0;;
} { .mfi
// get 2's complement of b
sub r33=r0,r33
fcvt.xuf.s1 f6=f12
nop.i 0
} { .mfi
nop.m 0
fcvt.xuf.s1 f7=f7
nop.i 0;;
} { .mfi
nop.m 0
// Step (1)
// y0 = 1 / b in f8
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// Step (2)
// q0 = a * y0 in f10
(p6) fma.s1 f10=f6,f8,f0
nop.i 0
} { .mfi
nop.m 0
// Step (3)
// e0 = 1 - b * y0 in f9
(p6) fnma.s1 f9=f7,f8,f1
nop.i 0;;
} { .mfi
nop.m 0
// Step (4)
// q1 = q0 + e0 * q0 in f10
(p6) fma.s1 f10=f9,f10,f10
nop.i 0
} { .mfi
nop.m 0
// Step (5)
// e1 = e0 * e0 in f11
(p6) fma.s1 f11=f9,f9,f0
nop.i 0;;
} { .mfi
nop.m 0
// Step (6)
// y1 = y0 + e0 * y0 in f8
(p6) fma.s1 f8=f9,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (7)
// q2 = q1 + e1 * q1 in f9
(p6) fma.s1 f9=f11,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// Step (8)
// y2 = y1 + e1 * y1 in f8
(p6) fma.s1 f8=f11,f8,f8
nop.i 0;;
} { .mfi
nop.m 0
// Step (9)
// r2 = a - b * q2 in f10
(p6) fnma.s1 f10=f7,f9,f6
nop.i 0;;
} { .mfi
// f7=-b
setf.sig f7=r33
// Step (10)
// q3 = q2 + r2 * y2 in f8
(p6) fma.s1 f8=f10,f8,f9
nop.i 0;;
} { .mfi
nop.m 0
// (11) q = trunc(q3)
fcvt.fxu.trunc.s1 f8=f8
nop.i 0;;
} { .mfi
nop.m 0
// (12) r = a + (-b) * q
xma.l f8=f8,f7,f12
nop.i 0;;
} { .mib
getf.sig r8=f8
nop.i 0
nop.b 0
}
// 64-BIT UNSIGNED INTEGER REMAINDER ENDS HERE
{ .mib
nop.m 0
nop.i 0
br.ret.sptk b0;;
}
.endp __umoddi3

View file

@ -1,131 +0,0 @@
.file "__umodsi3.s"
// $NetBSD: umodsi3.S,v 1.2 2006/04/07 14:27:33 cherry Exp $
//-
// Copyright (c) 2000, Intel Corporation
// All rights reserved.
//
// Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache,
// Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab,
// Intel Corporation.
//
// WARRANTY DISCLAIMER
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 INTEL OR ITS
// 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.
//
// Intel Corporation is the author of this code, and requests that all
// problem reports or change requests be submitted to it directly at
// http://developer.intel.com/opensource.
//
.section .text
// 32-bit unsigned integer remainder
.proc __umodsi3#
.align 32
.global __umodsi3#
.align 32
__umodsi3:
{ .mii
alloc r31=ar.pfs,2,0,0,0
nop.i 0
nop.i 0;;
} { .mii
nop.m 0
// 32-BIT UNSIGNED INTEGER REMAINDER BEGINS HERE
// general register used:
// r32 - 32-bit unsigned integer dividend
// r33 - 32-bit unsigned integer divisor
// r8 - 32-bit unsigned integer result
// r2 - scratch register
// floating-point registers used: f6, f7, f8, f9, f10, f11
// predicate registers used: p6
zxt4 r32=r32
zxt4 r33=r33;;
} { .mmb
setf.sig f11=r32
setf.sig f7=r33
nop.b 0;;
} { .mfi
nop.m 0
fcvt.xf f6=f11
nop.i 0
} { .mfi
// get 2's complement of b
sub r33=r0,r33
fcvt.xf f7=f7
mov r2 = 0x0ffdd;;
} { .mfi
setf.exp f9 = r2
// (1) y0
frcpa.s1 f8,p6=f6,f7
nop.i 0;;
} { .mfi
nop.m 0
// (2) q0 = a * y0
(p6) fma.s1 f10=f6,f8,f0
nop.i 0
} { .mfi
nop.m 0
// (3) e0 = 1 - b * y0
(p6) fnma.s1 f8=f7,f8,f1
nop.i 0;;
} { .mfi
nop.m 0
// (4) q1 = q0 + e0 * q0
(p6) fma.s1 f10=f8,f10,f10
nop.i 0
} { .mfi
// get 2's complement of b
setf.sig f7=r33
// (5) e1 = e0 * e0 + 2^-34
(p6) fma.s1 f8=f8,f8,f9
nop.i 0;;
} { .mfi
nop.m 0
// (6) q2 = q1 + e1 * q1
(p6) fma.s1 f8=f8,f10,f10
nop.i 0;;
} { .mfi
nop.m 0
// (7) q = trunc(q2)
fcvt.fxu.trunc.s1 f8=f8
nop.i 0;;
} { .mfi
nop.m 0
// (8) r = a + (-b) * q
xma.l f8=f8,f7,f11
nop.i 0;;
} { .mmi
// remainder will be in the least significant 32 bits of r8 (if b != 0)
getf.sig r8=f8
nop.m 0
nop.i 0;;
}
// 32-BIT UNSIGNED INTEGER REMAINDER ENDS HERE
{ .mmb
nop.m 0
nop.m 0
br.ret.sptk b0;;
}
.endp __umodsi3

View file

@ -1,3 +0,0 @@
/* $NetBSD: DEFS.h,v 1.4 1999/11/11 01:32:10 thorpej Exp $ */
#include <machine/asm.h>

View file

@ -1,16 +0,0 @@
# $NetBSD: Makefile.inc,v 1.30 2009/08/14 19:23:54 dsl Exp $
SRCS+= bswap16.S bswap32.S bswap64.S
SRCS+= memcmp.S memcpy.S memmove.S memset.S
SRCS+= strcat.S strchr.S strcmp.S
SRCS+= strcpy.S strlen.S strncmp.S strncpy.S strrchr.S
SRCS+= scanc.S skpc.S
SRCS+= htonl.S htons.S ntohl.S ntohs.S
SRCS+= ffs.S
.if defined(MACHINE_ARCH) && (${MACHINE_ARCH} == "m68000")
SRCS+= mulsi3.S divsi3.S udivsi3.S modsi3.S umodsi3.S
random.o random.d: random.c
.else
SRCS+= random.S
.endif

View file

@ -1,69 +0,0 @@
/* $NetBSD: random.S,v 1.4 2009/01/06 01:24:56 pooka Exp $ */
/*
* Copyright (c) 1990,1993 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: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Here is a very good random number generator. This implementation is
* based on ``Two Fast Implementations of the "Minimal Standard" Random
* Number Generator'', David G. Carta, Communications of the ACM, Jan 1990,
* Vol 33 No 1. Do NOT modify this code unless you have a very thorough
* understanding of the algorithm. It's trickier than you think. If
* you do change it, make sure that its 10,000'th invocation returns
* 1043618065.
*
* Here is easier-to-decipher pseudocode:
*
* p = (16807*seed)<30:0> # e.g., the low 31 bits of the product
* q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32
* if (p + q < 2^31)
* seed = p + q
* else
* seed = ((p + q) & (2^31 - 1)) + 1
* return (seed);
*
* The result is in (0,2^31), e.g., it's always positive.
*/
#include <machine/asm.h>
.data
ASLOCAL(randseed)
.long 1
ENTRY(random)
movl #16807, %d0
#ifdef PIC
lea %pc@(_GLOBAL_OFFSET_TABLE_@GOTPC), %a0
movl _ASM_LABEL(randseed)@GOT(%a0), %d2
mulsl (%d2), %d1:%d0
#else
mulsl _ASM_LABEL(randseed), %d1:%d0
#endif
lsll #1, %d0
roxll #2, %d1
addl %d1, %d0
moveql #1, %d1
addxl %d1, %d0
lsrl #1, %d0
#ifdef PIC
movl %d0, (%d2)
#else
movl %d0, _ASM_LABEL(randseed)
#endif
rts

View file

@ -1,63 +0,0 @@
/* $NetBSD: scanc.S,v 1.6 2011/02/08 20:20:27 rmind Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1980, 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* 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. 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: Utah Hdr: locore.s 1.58 91/04/22
* @(#)locore.s 7.11 (Berkeley) 5/9/91
*/
#include "DEFS.h"
/*
* Emulate fancy VAX string operations:
* scanc(count, startc, table, mask)
*/
ENTRY(scanc)
movl %sp@(4),%d0 | get length
jeq Lscdone | nothing to do, return
movl %sp@(8),%a0 | start of scan
movl %sp@(12),%a1 | table to compare with
movb %sp@(19),%d1 | and mask to use
movw %d2,%sp@- | need a scratch register
clrw %d2 | clear it out
subqw #1,%d0 | adjust for dbra
Lscloop:
movb %a0@+,%d2 | get character
movb %a1@(0,%d2:w),%d2 | get table entry
andb %d1,%d2 | mask it
dbne %d0,Lscloop | keep going til no more or non-zero
addqw #1,%d0 | overshot by one
movw %sp@+,%d2 | restore scratch
Lscdone:
rts

View file

@ -1,57 +0,0 @@
/* $NetBSD: skpc.S,v 1.6 2011/02/08 20:20:27 rmind Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1980, 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* 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. 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: Utah Hdr: locore.s 1.58 91/04/22
* @(#)locore.s 7.11 (Berkeley) 5/9/91
*/
#include "DEFS.h"
/*
* Emulate fancy VAX string operations:
* skpc(mask, count, startc)
*/
ENTRY(skpc)
movl %sp@(8),%d0 | get length
jeq Lskdone | nothing to do, return
movb %sp@(7),%d1 | mask to use
movl %sp@(12),%a0 | where to start
subqw #1,%d0 | adjust for dbcc
Lskloop:
cmpb %a0@+,%d1 | compate with mask
dbne %d0,Lskloop | keep going til no more or zero
addqw #1,%d0 | overshot by one
Lskdone:
rts

View file

@ -1,14 +0,0 @@
# $NetBSD: Makefile.inc,v 1.23 2010/01/20 18:13:40 pgoyette Exp $
#
# There are likely more that we will notice when we go native
NO_SRCS+= imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c
NO_SRCS+= __main.c
SRCS+= memchr.c memcmp.c random.c scanc.c \
skpc.c strcat.c strcpy.c strcasecmp.c \
strncasecmp.c strncmp.c strncpy.c strtoul.c
SRCS+= byte_swap_2.S byte_swap_4.S byte_swap_8.S \
ffs.S memcpy.S memset2.c memmove.S \
strlen.S strcmp.S

View file

@ -1,15 +0,0 @@
# $NetBSD: Makefile.inc,v 1.31 2011/07/02 03:35:03 matt Exp $
SRCS+= bswap16.c bswap32.c
SRCS+= htonl.c htons.c ntohl.c ntohs.c
SRCS+= syncicache.c
SRCS+= ffs.S memset.S strlen.S
SRCS+= gprsavrest.S
# Disable the asm versions on evbppc because they break the Explora
.if ${MACHINE} == "evbppc"
memcpy.o: memcpy.c
memcmp.o: memcmp.c
memmove.o: memmove.c
.endif

View file

@ -1,132 +0,0 @@
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <powerpc/asm.h>
__RCSID("$NetBSD: gprsavrest.S,v 1.4 2011/10/28 02:00:50 christos Exp $")
#ifndef RESTGPR
# define RESTGPR(n) RESTOREXGPR(_restgpr_,n,_x)
# define RESTGPR_END(n) RESTOREXGPR_END(_restgpr_,n,_x)
# define SAVEGPR(n) SAVEXGPR(_savegpr_,n,)
# define SAVEGPR_END(n) SAVEXGPR_END(_savegpr_,n,)
#endif
#define RESTOREXGPR(a,n,b) \
.hidden a##n##b; ENTRY_NOPROFILE(a##n##b); lwz n,(-4*(32-n))(11)
#define SAVEXGPR(a,n,b) \
.hidden a##n##b; ENTRY_NOPROFILE(a##n##b); stw n,(-4*(32-n))(11)
#ifdef _LP64
# define SAVEXGPR_END(a,n,b)
# define RESTOREXGPR_END(a,n,b)
#else
# define SAVEXGPR_END(a,n,b) \
.size a##n##b,.-a##n##b
# define RESTOREXGPR_END(a,n,b) \
.size a##n##b,.-a##n##b
#endif
RESTGPR(14)
RESTGPR(15)
RESTGPR(16)
RESTGPR(17)
RESTGPR(18)
RESTGPR(19)
RESTGPR(20)
RESTGPR(21)
RESTGPR(22)
RESTGPR(23)
RESTGPR(24)
RESTGPR(25)
RESTGPR(26)
RESTGPR(27)
RESTGPR(28)
RESTGPR(29)
RESTGPR(30)
RESTGPR(31)
lwz 0,4(11)
mtlr 0
mr 1,11
blr
RESTGPR_END(14)
RESTGPR_END(15)
RESTGPR_END(16)
RESTGPR_END(17)
RESTGPR_END(18)
RESTGPR_END(19)
RESTGPR_END(20)
RESTGPR_END(21)
RESTGPR_END(22)
RESTGPR_END(23)
RESTGPR_END(24)
RESTGPR_END(25)
RESTGPR_END(26)
RESTGPR_END(27)
RESTGPR_END(28)
RESTGPR_END(29)
RESTGPR_END(30)
RESTGPR_END(31)
SAVEGPR(14)
SAVEGPR(15)
SAVEGPR(16)
SAVEGPR(17)
SAVEGPR(18)
SAVEGPR(19)
SAVEGPR(20)
SAVEGPR(21)
SAVEGPR(22)
SAVEGPR(23)
SAVEGPR(24)
SAVEGPR(25)
SAVEGPR(26)
SAVEGPR(27)
SAVEGPR(28)
SAVEGPR(29)
SAVEGPR(30)
SAVEGPR(31)
blr
SAVEGPR_END(14)
SAVEGPR_END(15)
SAVEGPR_END(16)
SAVEGPR_END(17)
SAVEGPR_END(18)
SAVEGPR_END(19)
SAVEGPR_END(20)
SAVEGPR_END(21)
SAVEGPR_END(22)
SAVEGPR_END(23)
SAVEGPR_END(24)
SAVEGPR_END(25)
SAVEGPR_END(26)
SAVEGPR_END(27)
SAVEGPR_END(28)
SAVEGPR_END(29)
SAVEGPR_END(30)
SAVEGPR_END(31)

View file

@ -1,99 +0,0 @@
/* $NetBSD: memset.S,v 1.7 2011/01/17 07:07:36 matt Exp $ */
/*-
* Copyright (C) 2003 Matt Thomas <matt@3am-software.com>
* Copyright (C) 2001 Martin J. Laubach <mjl@NetBSD.org>
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*----------------------------------------------------------------------*/
#include <machine/asm.h>
/*----------------------------------------------------------------------*/
/*
void bzero(void *b r3, size_t len r4);
void *memset(void *b r3, int c r4, size_t len r5);
*/
/*----------------------------------------------------------------------*/
#define r_dst %r4
#define r_len %r5
#define r_tmp %r6
#define r_val %r0
ENTRY(bzero)
li r_val, 0 /* Value to fill with */
mr r_len, %r4
b cb_memset
ENTRY(memset)
mr r_val, %r4 /* Value to fill with */
cb_memset:
cmplwi r_len, 0 /* is the length 0? */
beqlr- /* nothing to do */
mr r_dst, %r3
/*
* r3=start, r4=dstptr, r5=length, r0=fill-val
*/
cmplwi r_len, 6 /* more than 6 bytes? */
bgt complex_fill /* do it the complex way */
subi r_dst, r_dst, 1 /* presubtract for stbu */
simple_fill: mtctr r_len /* set CTR */
1: stbu r_val, 1(r_dst) /* update memory */
bdnz+ 1b /* until CTR is 0 */
blr /* return */
complex_fill:
rlwimi r_val, r_val, 8, 16, 23 /* word extend fill value */
rlwimi r_val, r_val, 16, 0, 15
andi. r_tmp, r_dst, 0x03
beq+ word_fill /* already aligned to word? */
andi. r_tmp, r_dst, 0x01
beq half_fill /* aligned to halfword? */
stb r_val, 0(r_dst)
addi r_dst, r_dst, 1
subi r_len, r_len, 1 /* subtract byte */
andi. r_tmp, r_dst, 0x02
beq word_fill /* aligned to word? */
half_fill:
sth r_val, 0(r_dst)
addi r_dst, r_dst, 2
subi r_len, r_len, 2 /* subtract halfword */
word_fill:
cmplwi r_len, 4 /* we have more than 4 bytes? */
blt- trailing_bytes /* no? finish writing */
srwi r_tmp, r_len, 2 /* get word count */
mtctr r_tmp
subi r_dst, r_dst, 4
1: stwu r_val, 4(r_dst)
bdnz+ 1b
trailing_bytes:
andi. r_len, r_len, 0x03 /* how much left? */
beqlr+ /* nothing? return */
addi r_dst, r_dst, 3
b simple_fill

View file

@ -1,132 +0,0 @@
/* $NetBSD: syncicache.c,v 1.14 2008/03/18 20:11:43 he Exp $ */
/*
* Copyright (C) 1995-1997, 1999 Wolfgang Solfrank.
* Copyright (C) 1995-1997, 1999 TooLs GmbH.
* 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 TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
*/
#include <sys/param.h>
#if defined(_KERNEL)
#include <sys/time.h>
#include <sys/proc.h>
#include <uvm/uvm_extern.h>
#endif
#if !defined(_STANDALONE)
#include <sys/sysctl.h>
#endif
#include <machine/cpu.h>
#if defined(_STANDALONE)
#ifndef CACHELINESIZE
#error "Must know the size of a cache line"
#endif
static struct cache_info _cache_info = {
CACHELINESIZE,
CACHELINESIZE,
CACHELINESIZE,
CACHELINESIZE
};
#define CACHEINFO _cache_info
#elif defined(_KERNEL)
#define CACHEINFO (curcpu()->ci_ci)
#else
static void getcachelinesize (void);
static int _cachelinesize = 0;
static struct cache_info _cache_info;
#define CACHEINFO _cache_info
static void
getcachelinesize(void)
{
static int cachemib[] = { CTL_MACHDEP, CPU_CACHELINE };
static int cacheinfomib[] = { CTL_MACHDEP, CPU_CACHEINFO };
size_t clen = sizeof(_cache_info);
if (sysctl(cacheinfomib, sizeof(cacheinfomib) / sizeof(cacheinfomib[0]),
&_cache_info, &clen, NULL, 0) == 0) {
_cachelinesize = _cache_info.dcache_line_size;
return;
}
/* Try older deprecated sysctl */
clen = sizeof(_cachelinesize);
if (sysctl(cachemib, sizeof(cachemib) / sizeof(cachemib[0]),
&_cachelinesize, &clen, NULL, 0) < 0
|| !_cachelinesize)
abort();
_cache_info.dcache_size = _cachelinesize;
_cache_info.dcache_line_size = _cachelinesize;
_cache_info.icache_size = _cachelinesize;
_cache_info.icache_line_size = _cachelinesize;
/* If there is no cache, indicate we have issued the sysctl. */
if (!_cachelinesize)
_cachelinesize = 1;
}
#endif
void
__syncicache(void *from, size_t len)
{
size_t l, off;
size_t linesz;
char *p;
#if !defined(_KERNEL) && !defined(_STANDALONE)
if (!_cachelinesize)
getcachelinesize();
#endif
if (CACHEINFO.dcache_size > 0) {
linesz = CACHEINFO.dcache_line_size;
off = (uintptr_t)from & (linesz - 1);
l = (len + off + linesz - 1) & ~(linesz - 1);
p = (char *)from - off;
do {
__asm volatile ("dcbst 0,%0" :: "r"(p));
p += linesz;
} while ((l -= linesz) != 0);
}
__asm volatile ("sync");
if (CACHEINFO.icache_size > 0 ) {
linesz = CACHEINFO.icache_line_size;
off = (uintptr_t)from & (linesz - 1);
l = (len + off + linesz - 1) & ~(linesz - 1);
p = (char *)from - off;
do {
__asm volatile ("icbi 0,%0" :: "r"(p));
p += linesz;
} while ((l -= linesz) != 0);
}
__asm volatile ("sync; isync");
}

View file

@ -1,12 +0,0 @@
# $NetBSD: Makefile.inc,v 1.19 2011/08/04 03:20:09 uwe Exp $
SRCS+= ffs.S
SRCS+= memset.S
SRCS+= memmove.S memcpy.S byte_swap_2.S byte_swap_4.S byte_swap_8.S
SRCS+= ashiftrt.S ashlsi3.S ashrsi3.S lshrsi3.S movstr.S movstr_i4.S
SRCS+= movstrSI.S movstrSI12_i4.S mulsi3.S sdivsi3.S udivsi3.S
# newer gcc uses different integer division millicode by default
SRCS+= sdivsi3_i4i.S udivsi3_i4i.S
NO_SRCS+= bswap64.c

View file

@ -1,180 +0,0 @@
/* $NetBSD: ashiftrt.S,v 1.7 2009/01/07 22:15:18 uwe Exp $ */
/*-
* Copyright (C) 1999 Tsubai Masanari. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __ashiftrt_r4_0
.hidden __ashiftrt_r4_1
.hidden __ashiftrt_r4_2
.hidden __ashiftrt_r4_3
.hidden __ashiftrt_r4_4
.hidden __ashiftrt_r4_5
.hidden __ashiftrt_r4_6
.hidden __ashiftrt_r4_7
.hidden __ashiftrt_r4_8
.hidden __ashiftrt_r4_9
.hidden __ashiftrt_r4_10
.hidden __ashiftrt_r4_11
.hidden __ashiftrt_r4_12
.hidden __ashiftrt_r4_13
.hidden __ashiftrt_r4_14
.hidden __ashiftrt_r4_15
.hidden __ashiftrt_r4_16
.hidden __ashiftrt_r4_17
.hidden __ashiftrt_r4_18
.hidden __ashiftrt_r4_19
.hidden __ashiftrt_r4_20
.hidden __ashiftrt_r4_21
.hidden __ashiftrt_r4_22
.hidden __ashiftrt_r4_23
.hidden __ashiftrt_r4_24
.hidden __ashiftrt_r4_25
.hidden __ashiftrt_r4_26
.hidden __ashiftrt_r4_27
.hidden __ashiftrt_r4_28
.hidden __ashiftrt_r4_29
.hidden __ashiftrt_r4_30
.hidden __ashiftrt_r4_31
#endif /* __ELF__ */
NENTRY(__ashiftrt_r4_31)
shll r4
rts
subc r4, r4
ALTENTRY(__ashiftrt_r4_30)
shar r4
ALTENTRY(__ashiftrt_r4_29)
shar r4
ALTENTRY(__ashiftrt_r4_28)
shar r4
ALTENTRY(__ashiftrt_r4_27)
shar r4
ALTENTRY(__ashiftrt_r4_26)
shar r4
ALTENTRY(__ashiftrt_r4_25)
shar r4
ALTENTRY(__ashiftrt_r4_24)
shlr16 r4
shlr8 r4
rts
exts.b r4, r4
ALTENTRY(__ashiftrt_r4_23)
shar r4
ALTENTRY(__ashiftrt_r4_22)
shar r4
ALTENTRY(__ashiftrt_r4_21)
shar r4
ALTENTRY(__ashiftrt_r4_20)
shar r4
ALTENTRY(__ashiftrt_r4_19)
shar r4
ALTENTRY(__ashiftrt_r4_18)
shar r4
ALTENTRY(__ashiftrt_r4_17)
shar r4
ALTENTRY(__ashiftrt_r4_16)
shlr16 r4
rts
exts.w r4, r4
ALTENTRY(__ashiftrt_r4_15)
swap.w r4, r4
cmp/pz r4
bf/s 1f
exts.w r4, r4
rts
shll r4
1:
sett
rts
rotcl r4
ALTENTRY(__ashiftrt_r4_14)
shar r4
ALTENTRY(__ashiftrt_r4_13)
shar r4
ALTENTRY(__ashiftrt_r4_12)
shar r4
ALTENTRY(__ashiftrt_r4_11)
shar r4
ALTENTRY(__ashiftrt_r4_10)
shar r4
ALTENTRY(__ashiftrt_r4_9)
shar r4
ALTENTRY(__ashiftrt_r4_8)
shar r4
ALTENTRY(__ashiftrt_r4_7)
shar r4
ALTENTRY(__ashiftrt_r4_6)
shar r4
ALTENTRY(__ashiftrt_r4_5)
shar r4
ALTENTRY(__ashiftrt_r4_4)
shar r4
ALTENTRY(__ashiftrt_r4_3)
shar r4
ALTENTRY(__ashiftrt_r4_2)
shar r4
ALTENTRY(__ashiftrt_r4_1)
rts
shar r4
ALTENTRY(__ashiftrt_r4_0)
rts
nop

View file

@ -1,40 +0,0 @@
/* $NetBSD: ashlsi3.S,v 1.6 2009/01/07 22:15:18 uwe Exp $ */
/*-
* Copyright (C) 1999 Tsubai Masanari. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __ashlsi3
#endif
NENTRY(__ashlsi3)
shld r5, r4
rts
mov r4, r0

View file

@ -1,48 +0,0 @@
/* $NetBSD: ashrsi3.S,v 1.6 2009/01/07 22:15:18 uwe Exp $ */
/*-
* Copyright (C) 1999 Tsubai Masanari. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __ashrsi3
#endif
NENTRY(__ashrsi3)
tst r5, r5
bt noshift
neg r5, r5
shad r5, r4
rts
mov r4, r0
noshift:
rts
mov r4, r0

View file

@ -1,49 +0,0 @@
/* $NetBSD: byte_swap_2.S,v 1.6 2006/04/14 09:23:01 nonaka Exp $ */
/*-
* Copyright (C) 1999 SHIMIZU Ryo. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#undef _LOCORE
#define _LOCORE /* XXX not really, just assembly-code source */
#include <machine/endian.h>
ENTRY(bswap16)
#if BYTE_ORDER == LITTLE_ENDIAN
ALTENTRY(ntohs)
ALTENTRY(htons)
#endif
extu.w r4, r4
rts
swap.b r4, r0
#if BYTE_ORDER == BIG_ENDIAN
ENTRY(ntohs)
ALTENTRY(htons)
rts
extu.w r4, r0
#endif

View file

@ -1,50 +0,0 @@
/* $NetBSD: byte_swap_4.S,v 1.5 2006/04/14 09:23:01 nonaka Exp $ */
/*-
* Copyright (C) 1999 SHIMIZU Ryo. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#undef _LOCORE
#define _LOCORE /* XXX not really, just assembly-code source */
#include <machine/endian.h>
ENTRY(bswap32)
#if BYTE_ORDER == LITTLE_ENDIAN
ALTENTRY(ntohl)
ALTENTRY(htonl)
#endif
swap.b r4,r0
swap.w r0,r0
rts
swap.b r0,r0
#if BYTE_ORDER == BIG_ENDIAN
ENTRY(ntohl)
ALTENTRY(htonl)
rts
mov r4, r0
#endif

View file

@ -1,43 +0,0 @@
/* $NetBSD: byte_swap_8.S,v 1.2 2005/12/11 12:24:44 christos Exp $ */
/*
* Copyright (c) 2003 Valeriy E. Ushakov
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: byte_swap_8.S,v 1.2 2005/12/11 12:24:44 christos Exp $")
#endif
ENTRY(bswap64)
swap.b r4,r4
swap.b r5,r5
swap.w r4,r4
swap.w r5,r5
swap.b r4,r1
rts
swap.b r5,r0

View file

@ -1,48 +0,0 @@
/* $NetBSD: lshrsi3.S,v 1.6 2009/01/07 22:15:18 uwe Exp $ */
/*-
* Copyright (C) 1999 Tsubai Masanari. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __lshrsi3
#endif
NENTRY(__lshrsi3)
tst r5, r5
bt noshift
neg r5, r5
shld r5, r4
rts
mov r4, r0
noshift:
rts
mov r4, r0

View file

@ -1,99 +0,0 @@
/* $NetBSD: movstr.S,v 1.9 2009/01/07 22:15:18 uwe Exp $ */
/*-
* Copyright (C) 1999 Tsubai Masanari. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __movstr, __movmem
#endif
NENTRY(__movstr)
mov #16, r0
cmp/gt r0, r6
bf loop2
.align 2
loop1:
mov.l @r5+, r0
mov.l r0, @r4
mov.l @r5+, r0
mov.l r0, @(4, r4)
mov.l @r5+, r0
mov.l r0, @(8, r4)
mov.l @r5+, r0
mov.l r0, @(12, r4)
mov.l @r5+, r0
mov.l r0, @(16, r4)
mov.l @r5+, r0
mov.l r0, @(20, r4)
mov.l @r5+, r0
mov.l r0, @(24, r4)
mov.l @r5+, r0
mov.l r0, @(28, r4)
mov.l @r5+, r0
mov.l r0, @(32, r4)
mov.l @r5+, r0
mov.l r0, @(36, r4)
mov.l @r5+, r0
mov.l r0, @(40, r4)
mov.l @r5+, r0
mov.l r0, @(44, r4)
mov.l @r5+, r0
mov.l r0, @(48, r4)
mov.l @r5+, r0
mov.l r0, @(52, r4)
mov.l @r5+, r0
mov.l r0, @(56, r4)
mov.l @r5+, r0
mov.l r0, @(60, r4)
add #-16, r6
add #64, r4
mov #16, r0
cmp/gt r0, r6
bt loop1
loop2:
add #-32, r6
.align 2
1:
mov.l @r5+, r0
mov.l r0, @r4
add #4, r4
add #1, r6
tst r6, r6
bf 1b
rts
nop
/* gcc4 uses movmem, older versions use movstr */
STRONG_ALIAS(__movmem, __movstr)

View file

@ -1,119 +0,0 @@
/* $NetBSD: movstrSI.S,v 1.8 2009/01/07 22:15:18 uwe Exp $ */
/*
* Copyright (c) 2000 SHIMIZU Ryo. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __movstrSI4, __movmemSI4
.hidden __movstrSI8, __movmemSI8
.hidden __movstrSI12, __movmemSI12
.hidden __movstrSI16, __movmemSI16
.hidden __movstrSI20, __movmemSI20
.hidden __movstrSI24, __movmemSI24
.hidden __movstrSI28, __movmemSI28
.hidden __movstrSI32, __movmemSI32
.hidden __movstrSI36, __movmemSI36
.hidden __movstrSI40, __movmemSI40
.hidden __movstrSI44, __movmemSI44
.hidden __movstrSI48, __movmemSI48
.hidden __movstrSI52, __movmemSI52
.hidden __movstrSI56, __movmemSI56
.hidden __movstrSI60, __movmemSI60
.hidden __movstrSI64, __movmemSI64
#endif
NENTRY(__movstrSI64)
mov.l @(60, r5), r0
mov.l r0, @(60, r4)
ALTENTRY(__movstrSI60)
mov.l @(56, r5), r0
mov.l r0, @(56, r4)
ALTENTRY(__movstrSI56)
mov.l @(52, r5), r0
mov.l r0, @(52, r4)
ALTENTRY(__movstrSI52)
mov.l @(48, r5), r0
mov.l r0, @(48, r4)
ALTENTRY(__movstrSI48)
mov.l @(44, r5), r0
mov.l r0, @(44, r4)
ALTENTRY(__movstrSI44)
mov.l @(40, r5), r0
mov.l r0, @(40, r4)
ALTENTRY(__movstrSI40)
mov.l @(36, r5), r0
mov.l r0, @(36, r4)
ALTENTRY(__movstrSI36)
mov.l @(32, r5), r0
mov.l r0, @(32, r4)
ALTENTRY(__movstrSI32)
mov.l @(28, r5), r0
mov.l r0, @(28, r4)
ALTENTRY(__movstrSI28)
mov.l @(24, r5), r0
mov.l r0, @(24, r4)
ALTENTRY(__movstrSI24)
mov.l @(20, r5), r0
mov.l r0, @(20, r4)
ALTENTRY(__movstrSI20)
mov.l @(16, r5), r0
mov.l r0, @(16, r4)
ALTENTRY(__movstrSI16)
mov.l @(12, r5), r0
mov.l r0, @(12, r4)
ALTENTRY(__movstrSI12)
mov.l @(8, r5), r0
mov.l r0, @(8, r4)
ALTENTRY(__movstrSI8)
mov.l @(4, r5), r0
mov.l r0, @(4, r4)
ALTENTRY(__movstrSI4)
mov.l @r5, r0
rts
mov.l r0, @r4
/* gcc4 uses movmem, older versions use movstr */
STRONG_ALIAS(__movmemSI4, __movstrSI4)
STRONG_ALIAS(__movmemSI8, __movstrSI8)
STRONG_ALIAS(__movmemSI12, __movstrSI12)
STRONG_ALIAS(__movmemSI16, __movstrSI16)
STRONG_ALIAS(__movmemSI20, __movstrSI20)
STRONG_ALIAS(__movmemSI24, __movstrSI24)
STRONG_ALIAS(__movmemSI28, __movstrSI28)
STRONG_ALIAS(__movmemSI32, __movstrSI32)
STRONG_ALIAS(__movmemSI36, __movstrSI36)
STRONG_ALIAS(__movmemSI40, __movstrSI40)
STRONG_ALIAS(__movmemSI44, __movstrSI44)
STRONG_ALIAS(__movmemSI48, __movstrSI48)
STRONG_ALIAS(__movmemSI52, __movstrSI52)
STRONG_ALIAS(__movmemSI56, __movstrSI56)
STRONG_ALIAS(__movmemSI60, __movstrSI60)
STRONG_ALIAS(__movmemSI64, __movstrSI64)

View file

@ -1,21 +0,0 @@
/* $NetBSD: movstrSI12_i4.S,v 1.2 2009/01/07 22:15:18 uwe Exp $ */
#include <machine/asm.h>
#ifdef __ELF__
.hidden __movstrSI12_i4, __movmemSI12_i4
#endif
NENTRY(__movstrSI12_i4)
mov.l @r5, r0
mov.l @(4, r5), r1
mov.l @(8, r5), r2
mov.l r0, @r4
mov.l r1, @(4, r4)
rts
mov.l r2, @(8, r4)
/* gcc4 uses movmem, older versions use movstr */
STRONG_ALIAS(__movmemSI12_i4, __movstrSI12_i4)

View file

@ -1,80 +0,0 @@
/* $NetBSD: movstr_i4.S,v 1.6 2009/01/07 22:15:18 uwe Exp $ */
/*-
* Copyright (C) 2002 SHIMIZU Ryo. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __movstr_i4_odd, __movmem_i4_odd
.hidden __movstr_i4_even, __movmem_i4_even
#endif
NENTRY(__movstr_i4_odd)
add #-8,r4
nop
odd_loop:
mov.l @r5+,r0
add #8,r4
mov.l @r5+,r1
dt r6
mov.l r0,@(0,r4)
bf/s odd_loop
mov.l r1,@(4,r4)
mov.l @r5+,r0
mov.l @r5+,r1
mov.l @r5+,r2
mov.l r0,@(8,r4)
mov.l r1,@(12,r4)
rts
mov.l r2,@(16,r4)
NENTRY(__movstr_i4_even)
add #-8,r4
nop
even_loop:
mov.l @r5+,r0
add #8,r4
mov.l @r5+,r1
dt r6
mov.l r0,@(0,r4)
bf/s even_loop
mov.l r1,@(4,r4)
mov.l @r5+,r0
mov.l @r5+,r1
mov.l r0,@(8,r4)
rts
mov.l r1,@(12,r4)
/* gcc4 uses movmem, older versions use movstr */
STRONG_ALIAS(__movmem_i4_odd, __movstr_i4_odd)
STRONG_ALIAS(__movmem_i4_even, __movstr_i4_even)

View file

@ -1,40 +0,0 @@
/* $NetBSD: mulsi3.S,v 1.6 2009/01/07 22:15:18 uwe Exp $ */
/*-
* Copyright (C) 1999 Tsubai Masanari. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
#ifdef __ELF__
.hidden __mulsi3
#endif
NENTRY(__mulsi3)
mul.l r4, r5
rts
sts macl, r0

View file

@ -1,92 +0,0 @@
/* $NetBSD: sdivsi3.S,v 1.12 2011/08/05 01:59:39 uwe Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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. 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: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: sdivsi3.S,v 1.12 2011/08/05 01:59:39 uwe Exp $")
#endif
/*
* IMPOTANT: This function is special.
*
* This function is an auxiliary "millicode" function that is
* referenced by the code generated by gcc for signed integer
* division. But gcc does NOT treat a call to this function as an
* ordinary function call - it can clobber only R1, R2 and R3.
*
* See the definition of "divsi3_i1" in gcc/config/sh/sh.md
*
* As the consequence this function cannot be called via any
* indirection that assumes normal calling convention:
*
* . cannot have _PROF_PROLOGUE
* . cannot be called via PLT (not relevant for kernel)
*/
#ifdef __ELF__
.hidden __sdivsi3
#endif
/* r0 <= r4 / r5 */
NENTRY(__sdivsi3)
mov r4, r0
mov r5, r1
tst r1, r1
bt .L_div_by_zero
mov #0, r2
div0s r2, r0
subc r3, r3
subc r2, r0
div0s r1, r3
#define DIVSTEP rotcl r0; div1 r1, r3
/* repeat 32 times */
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
#undef DIVSTEP
rotcl r0
rts
addc r2, r0
.L_div_by_zero:
rts
mov #0, r0

View file

@ -1,108 +0,0 @@
/* $NetBSD: sdivsi3_i4i.S,v 1.2 2011/08/05 02:00:25 uwe Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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. 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: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: sdivsi3_i4i.S,v 1.2 2011/08/05 02:00:25 uwe Exp $")
#endif
/*
* IMPOTANT: This function is special.
*
* This function is an auxiliary "millicode" function that is
* referenced by the code generated by gcc for signed integer
* division. But gcc does NOT treat a call to this function as an
* ordinary function call - it can clobber only R1, MACL and MACH.
*
* See the definition of "divsi3_i4_int" in gcc/config/sh/sh.md
*
* As the consequence this function cannot be called via any
* indirection that assumes normal calling convention:
*
* . cannot have _PROF_PROLOGUE
* . cannot be called via PLT (not relevant for kernel)
*
* XXX: uwe: Older gcc used __sdivsi3; newer uses __sdivsi3_i4i - a
* heavily tuned version that is NOT compatible with __sdivsi3 because
* it clobbers different registers. We don't want to link the kernel
* against libgcc and we don't have resources to write heavily tuned
* version ourselves, so clone __sdivsi3 but adjust the code to
* conform to the __sdivsi3_i4i clobber spec.
*/
#ifdef __ELF__
.hidden __sdivsi3_i4i
#endif
/* r0 <= r4 / r5 */
NENTRY(__sdivsi3_i4i)
mov r4, r0
mov r5, r1
tst r1, r1
bt .L_div_by_zero
!! this version cannot clobber r2 and r3, but can clobber macl/mach
lds r2, macl
lds r3, mach
mov #0, r2
div0s r2, r0
subc r3, r3
subc r2, r0
div0s r1, r3
#define DIVSTEP rotcl r0; div1 r1, r3
/* repeat 32 times */
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
#undef DIVSTEP
rotcl r0
addc r2, r0
sts mach, r3
sts macl, r2
rts
nop
.L_div_by_zero:
rts
mov #0, r0

View file

@ -1,94 +0,0 @@
/* $NetBSD: udivsi3_i4i.S,v 1.2 2011/08/05 02:00:25 uwe Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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. 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: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: udivsi3_i4i.S,v 1.2 2011/08/05 02:00:25 uwe Exp $")
#endif
/*
* IMPOTANT: This function is special.
*
* This function is an auxiliary "millicode" function that is
* referenced by the code generated by gcc for unsigned integer
* division. But gcc does NOT treat a call to this function as an
* ordinary function call - it can clobber only R1, MACL and MACH.
*
* See the definition of "udivsi3_i4_int" in gcc/config/sh/sh.md
*
* As the consequence this function cannot be called via any
* indirection that assumes normal calling convention:
*
* . cannot have _PROF_PROLOGUE
* . cannot be called via PLT (not relevant for kernel)
*
* XXX: uwe: Older gcc used __udivsi3; newer uses __udivsi3_i4i - a
* heavily tuned version that is NOT compatible with __udivsi3 because
* it clobbers different registers. We don't want to link the kernel
* against libgcc and we don't have resources to write heavily tuned
* version ourselves, so clone __udivsi3 but adjust the code to
* conform to the __udivsi3_i4i clobber spec.
*/
#ifdef __ELF__
.hidden __udivsi3_i4i
#endif
/* r0 <= r4 / r5 */
NENTRY(__udivsi3_i4i)
tst r5, r5
bt .L_div_by_zero
mov r4, r1 ! cannot clobber r4 in this version
mov #0, r0
div0u
#define DIVSTEP rotcl r1; div1 r5, r0
/* repeat 32 times */
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP; DIVSTEP;
#undef DIVSTEP
rotcl r1
rts
mov r1, r0
.L_div_by_zero:
rts
mov #0, r0

View file

@ -1,40 +0,0 @@
# $NetBSD: Makefile.inc,v 1.34 2009/08/14 19:23:54 dsl Exp $
SRCS+= ffs.S
SRCS+= memset.S
SRCS+= strlen.S
SRCS+= htonl.S htons.S ntohl.S ntohs.S
SRCS+= random.S
SRCS+= bswap16.c bswap32.c
SRCS+= mul.S umul.S saveregs.S
# `source' files built from m4 source
# the name `div.o' is taken for the ANSI C `div' function, hence sdiv here
SRCS+= rem.S sdiv.S udiv.S urem.S
CLEANFILES+=rem.S sdiv.S udiv.S urem.S
.SUFFIXES: .m4
.PATH.m4: ${KERNDIR}/arch/${MACHINE_ARCH}
sdiv.S: divrem.m4
echo 'building ${.TARGET} from ${.ALLSRC}'
(echo "define(NAME,\`.div')define(OP,\`div')define(S,\`true')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
udiv.S: divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`.udiv')define(OP,\`div')define(S,\`false')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
rem.S: divrem.m4
echo 'building ${.TARGET} from ${.ALLSRC}'
(echo "define(NAME,\`.rem')define(OP,\`rem')define(S,\`true')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
urem.S: divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`.urem')define(OP,\`rem')define(S,\`false')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}

View file

@ -1,272 +0,0 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* 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. 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: Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
* $NetBSD: divrem.m4,v 1.9 2011/06/13 03:23:53 mrg Exp $
*/
/*
* Division and remainder, from Appendix E of the Sparc Version 8
* Architecture Manual, with fixes from Gordon Irlam.
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)divrem.m4 8.1 (Berkeley) 6/4/93"
#endif /* LIBC_SCCS and not lint */
/*
* Input: dividend and divisor in %o0 and %o1 respectively.
*
* m4 parameters:
* NAME name of function to generate
* OP OP=div => %o0 / %o1; OP=rem => %o0 % %o1
* S S=true => signed; S=false => unsigned
*
* Algorithm parameters:
* N how many bits per iteration we try to get (4)
* WORDSIZE total number of bits (32)
*
* Derived constants:
* TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
* TOPBITS number of bits in the top `decade' of a number
*
* Important variables:
* Q the partial quotient under development (initially 0)
* R the remainder so far, initially the dividend
* ITER number of main division loop iterations required;
* equal to ceil(log2(quotient) / N). Note that this
* is the log base (2^N) of the quotient.
* V the current comparand, initially divisor*2^(ITER*N-1)
*
* Cost:
* Current estimate for non-large dividend is
* ceil(log2(quotient) / N) * (10 + 7N/2) + C
* A large dividend is one greater than 2^(31-TOPBITS) and takes a
* different path, as the upper bits of the quotient must be developed
* one bit at a time.
*/
define(N, `4')
define(TWOSUPN, `16')
define(WORDSIZE, `32')
define(TOPBITS, eval(WORDSIZE - N*((WORDSIZE-1)/N)))
define(dividend, `%o0')
define(divisor, `%o1')
define(Q, `%o2')
define(R, `%o3')
define(ITER, `%o4')
define(V, `%o5')
/* m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d */
define(T, `%g1')
define(SC, `%g5')
ifelse(S, `true', `define(SIGN, `%g6')')
/*
* This is the recursive definition for developing quotient digits.
*
* Parameters:
* $1 the current depth, 1 <= $1 <= N
* $2 the current accumulation of quotient bits
* N max depth
*
* We add a new bit to $2 and either recurse or insert the bits in
* the quotient. R, Q, and V are inputs and outputs as defined above;
* the condition codes are expected to reflect the input R, and are
* modified to reflect the output R.
*/
define(DEVELOP_QUOTIENT_BITS,
` ! depth $1, accumulated bits $2
bl L.$1.eval(TWOSUPN+$2)
srl V,1,V
! remainder is positive
subcc R,V,R
ifelse($1, N,
` b 9f
add Q, ($2*2+1), Q
', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')')
L.$1.eval(TWOSUPN+$2):
! remainder is negative
addcc R,V,R
ifelse($1, N,
` b 9f
add Q, ($2*2-1), Q
', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2-1)')')
ifelse($1, 1, `9:')')
#include <machine/asm.h>
#include <machine/trap.h>
FUNC(NAME)
ifelse(S, `true',
` ! compute sign of result; if neither is negative, no problem
orcc divisor, dividend, %g0 ! either negative?
bge 2f ! no, go do the divide
ifelse(OP, `div',
`xor divisor, dividend, SIGN',
`mov dividend, SIGN') ! compute sign in any case
tst divisor
bge 1f
tst dividend
! divisor is definitely negative; dividend might also be negative
bge 2f ! if dividend not negative...
neg divisor ! in any case, make divisor nonneg
1: ! dividend is negative, divisor is nonnegative
neg dividend ! make dividend nonnegative
2:
')
! Ready to divide. Compute size of quotient; scale comparand.
orcc divisor, %g0, V
bnz 1f
mov dividend, R
! Divide by zero trap. If it returns, return 0 (about as
! wrong as possible, but that is what SunOS does...).
t ST_DIV0
retl
clr %o0
1:
cmp R, V ! if divisor exceeds dividend, done
blu Lgot_result ! (and algorithm fails otherwise)
clr Q
sethi %hi(1 << (WORDSIZE - TOPBITS - 1)), T
cmp R, T
blu Lnot_really_big
clr ITER
! `Here the dividend is >= 2^(31-N) or so. We must be careful here,
! as our usual N-at-a-shot divide step will cause overflow and havoc.
! The number of bits in the result here is N*ITER+SC, where SC <= N.
! Compute ITER in an unorthodox manner: know we need to shift V into
! the top decade: so do not even bother to compare to R.'
1:
cmp V, T
bgeu 3f
mov 1, SC
sll V, N, V
b 1b
inc ITER
! Now compute SC.
2: addcc V, V, V
bcc Lnot_too_big
inc SC
! We get here if the divisor overflowed while shifting.
! This means that R has the high-order bit set.
! Restore V and subtract from R.
sll T, TOPBITS, T ! high order bit
srl V, 1, V ! rest of V
add V, T, V
b Ldo_single_div
dec SC
Lnot_too_big:
3: cmp V, R
blu 2b
nop
be Ldo_single_div
nop
/* NB: these are commented out in the V8-Sparc manual as well */
/* (I do not understand this) */
! V > R: went too far: back up 1 step
! srl V, 1, V
! dec SC
! do single-bit divide steps
!
! We have to be careful here. We know that R >= V, so we can do the
! first divide step without thinking. BUT, the others are conditional,
! and are only done if R >= 0. Because both R and V may have the high-
! order bit set in the first step, just falling into the regular
! division loop will mess up the first time around.
! So we unroll slightly...
Ldo_single_div:
deccc SC
bl Lend_regular_divide
nop
sub R, V, R
mov 1, Q
b Lend_single_divloop
nop
Lsingle_divloop:
sll Q, 1, Q
bl 1f
srl V, 1, V
! R >= 0
sub R, V, R
b 2f
inc Q
1: ! R < 0
add R, V, R
dec Q
2:
Lend_single_divloop:
deccc SC
bge Lsingle_divloop
tst R
b,a Lend_regular_divide
Lnot_really_big:
1:
sll V, N, V
cmp V, R
bleu 1b
inccc ITER
be Lgot_result
dec ITER
tst R ! set up for initial iteration
Ldivloop:
sll Q, N, Q
DEVELOP_QUOTIENT_BITS(1, 0)
Lend_regular_divide:
deccc ITER
bge Ldivloop
tst R
bl,a Lgot_result
! non-restoring fixup here (one instruction only!)
ifelse(OP, `div',
` dec Q
', ` add R, divisor, R
')
Lgot_result:
ifelse(S, `true',
` ! check to see if answer should be < 0
tst SIGN
bl,a 1f
ifelse(OP, `div', `neg Q', `neg R')
1:')
retl
ifelse(OP, `div', `mov Q, %o0', `mov R, %o0')

View file

@ -1,104 +0,0 @@
/* $NetBSD: random.S,v 1.3 2009/01/05 01:16:09 pooka Exp $ */
/*
* Copyright (c) 1990,1993 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: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Here is a very good random number generator. This implementation is
* based on ``Two Fast Implementations of the "Minimal Standard" Random
* Number Generator'', David G. Carta, Communications of the ACM, Jan 1990,
* Vol 33 No 1. Do NOT modify this code unless you have a very thorough
* understanding of the algorithm. It's trickier than you think. If
* you do change it, make sure that its 10,000'th invocation returns
* 1043618065.
*
* Here is easier-to-decipher pseudocode:
*
* p = (16807*seed)<30:0> # e.g., the low 31 bits of the product
* q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32
* if (p + q < 2^31)
* seed = p + q
* else
* seed = ((p + q) & (2^31 - 1)) + 1
* return (seed);
*
* The result is in (0,2^31), e.g., it's always positive.
*/
#include <machine/asm.h>
.data
randseed:
.long 1
.text
ENTRY(random)
sethi %hi(16807), %o1
wr %o1, %lo(16807), %y
#ifdef PIC
PIC_PROLOGUE(%o5, %o2)
set randseed, %g1
ld [%o5 + %g1], %g1
ld [%g1], %o0
#else
sethi %hi(randseed), %g1
ld [%g1 + %lo(randseed)], %o0
#endif
andcc %g0, 0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %g0, %o2
rd %y, %o3
srl %o2, 16, %o1
set 0xffff, %o4
and %o4, %o2, %o0
sll %o0, 15, %o0
srl %o3, 17, %o3
or %o3, %o0, %o0
addcc %o0, %o1, %o0
bneg 1f
sethi %hi(0x7fffffff), %o1
retl
#ifdef PIC
st %o0, [%g1]
#else
st %o0, [%g1 + %lo(randseed)]
#endif
1:
or %o1, %lo(0x7fffffff), %o1
add %o0, 1, %o0
and %o1, %o0, %o0
retl
#ifdef PIC
st %o0, [%g1]
#else
st %o0, [%g1 + %lo(randseed)]
#endif

View file

@ -1,36 +0,0 @@
# $NetBSD: Makefile.inc,v 1.10 2009/08/14 19:23:55 dsl Exp $
SRCS+= ffs.S
SRCS+= strlen.S
SRCS+= htonl.S htons.S ntohl.S ntohs.S
SRCS+= random.S
SRCS+= bswap16.c bswap32.c
SRCS+= umul.S mul.S rem.S sdiv.S udiv.S umul.S urem.S
SRCS+= mul.S saveregs.S umul.S
# `source' files built from m4 source
# the name `div.o' is taken for the ANSI C `div' function, hence sdiv here
SRCS+= rem.S sdiv.S udiv.S urem.S
CLEANFILES+=rem.S sdiv.S udiv.S urem.S
sdiv.S: $M/divrem.m4
echo 'building ${.TARGET} from ${.ALLSRC}'
(echo "define(NAME,\`.div')define(OP,\`div')define(S,\`true')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
udiv.S: $M/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`.udiv')define(OP,\`div')define(S,\`false')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
rem.S: $M/divrem.m4
echo 'building ${.TARGET} from ${.ALLSRC}'
(echo "define(NAME,\`.rem')define(OP,\`rem')define(S,\`true')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}
urem.S: $M/divrem.m4
@echo 'building ${.TARGET} from ${.ALLSRC}'
@(echo "define(NAME,\`.urem')define(OP,\`rem')define(S,\`false')"; \
cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET}

View file

@ -1,273 +0,0 @@
/* $NetBSD: divrem.m4,v 1.5 2005/12/11 12:24:45 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* 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. 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: Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
*/
#include <machine/asm.h>
#include <machine/trap.h>
/*
* Division and remainder, from Appendix E of the Sparc Version 8
* Architecture Manual, with fixes from Gordon Irlam.
*/
#if defined(LIBC_SCCS)
RCSID("$NetBSD: divrem.m4,v 1.5 2005/12/11 12:24:45 christos Exp $")
#endif
/*
* Input: dividend and divisor in %o0 and %o1 respectively.
*
* m4 parameters:
* NAME name of function to generate
* OP OP=div => %o0 / %o1; OP=rem => %o0 % %o1
* S S=true => signed; S=false => unsigned
*
* Algorithm parameters:
* N how many bits per iteration we try to get (4)
* WORDSIZE total number of bits (32)
*
* Derived constants:
* TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
* TOPBITS number of bits in the top `decade' of a number
*
* Important variables:
* Q the partial quotient under development (initially 0)
* R the remainder so far, initially the dividend
* ITER number of main division loop iterations required;
* equal to ceil(log2(quotient) / N). Note that this
* is the log base (2^N) of the quotient.
* V the current comparand, initially divisor*2^(ITER*N-1)
*
* Cost:
* Current estimate for non-large dividend is
* ceil(log2(quotient) / N) * (10 + 7N/2) + C
* A large dividend is one greater than 2^(31-TOPBITS) and takes a
* different path, as the upper bits of the quotient must be developed
* one bit at a time.
*/
define(N, `4')
define(TWOSUPN, `16')
define(WORDSIZE, `32')
define(TOPBITS, eval(WORDSIZE - N*((WORDSIZE-1)/N)))
define(dividend, `%o0')
define(divisor, `%o1')
define(Q, `%o2')
define(R, `%o3')
define(ITER, `%o4')
define(V, `%o5')
/* m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d */
define(T, `%g1')
define(SC, `%g5')
ifelse(S, `true', `define(SIGN, `%g6')')
/*
* This is the recursive definition for developing quotient digits.
*
* Parameters:
* $1 the current depth, 1 <= $1 <= N
* $2 the current accumulation of quotient bits
* N max depth
*
* We add a new bit to $2 and either recurse or insert the bits in
* the quotient. R, Q, and V are inputs and outputs as defined above;
* the condition codes are expected to reflect the input R, and are
* modified to reflect the output R.
*/
define(DEVELOP_QUOTIENT_BITS,
` ! depth $1, accumulated bits $2
bl L.$1.eval(TWOSUPN+$2)
srl V,1,V
! remainder is positive
subcc R,V,R
ifelse($1, N,
` b 9f
add Q, ($2*2+1), Q
', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')')
L.$1.eval(TWOSUPN+$2):
! remainder is negative
addcc R,V,R
ifelse($1, N,
` b 9f
add Q, ($2*2-1), Q
', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2-1)')')
ifelse($1, 1, `9:')')
FUNC(NAME)
ifelse(S, `true',
` ! compute sign of result; if neither is negative, no problem
orcc divisor, dividend, %g0 ! either negative?
bge 2f ! no, go do the divide
ifelse(OP, `div',
`xor divisor, dividend, SIGN',
`mov dividend, SIGN') ! compute sign in any case
tst divisor
bge 1f
tst dividend
! divisor is definitely negative; dividend might also be negative
bge 2f ! if dividend not negative...
neg divisor ! in any case, make divisor nonneg
1: ! dividend is negative, divisor is nonnegative
neg dividend ! make dividend nonnegative
2:
')
! Ready to divide. Compute size of quotient; scale comparand.
orcc divisor, %g0, V
bnz 1f
mov dividend, R
! Divide by zero trap. If it returns, return 0 (about as
! wrong as possible, but that is what SunOS does...).
t ST_DIV0
retl
clr %o0
1:
cmp R, V ! if divisor exceeds dividend, done
blu Lgot_result ! (and algorithm fails otherwise)
clr Q
sethi %hi(1 << (WORDSIZE - TOPBITS - 1)), T
cmp R, T
blu Lnot_really_big
clr ITER
! `Here the dividend is >= 2^(31-N) or so. We must be careful here,
! as our usual N-at-a-shot divide step will cause overflow and havoc.
! The number of bits in the result here is N*ITER+SC, where SC <= N.
! Compute ITER in an unorthodox manner: know we need to shift V into
! the top decade: so do not even bother to compare to R.'
1:
cmp V, T
bgeu 3f
mov 1, SC
sll V, N, V
b 1b
inc ITER
! Now compute SC.
2: addcc V, V, V
bcc Lnot_too_big
inc SC
! We get here if the divisor overflowed while shifting.
! This means that R has the high-order bit set.
! Restore V and subtract from R.
sll T, TOPBITS, T ! high order bit
srl V, 1, V ! rest of V
add V, T, V
b Ldo_single_div
dec SC
Lnot_too_big:
3: cmp V, R
blu 2b
nop
be Ldo_single_div
nop
/* NB: these are commented out in the V8-Sparc manual as well */
/* (I do not understand this) */
! V > R: went too far: back up 1 step
! srl V, 1, V
! dec SC
! do single-bit divide steps
!
! We have to be careful here. We know that R >= V, so we can do the
! first divide step without thinking. BUT, the others are conditional,
! and are only done if R >= 0. Because both R and V may have the high-
! order bit set in the first step, just falling into the regular
! division loop will mess up the first time around.
! So we unroll slightly...
Ldo_single_div:
deccc SC
bl Lend_regular_divide
nop
sub R, V, R
mov 1, Q
b Lend_single_divloop
nop
Lsingle_divloop:
sll Q, 1, Q
bl 1f
srl V, 1, V
! R >= 0
sub R, V, R
b 2f
inc Q
1: ! R < 0
add R, V, R
dec Q
2:
Lend_single_divloop:
deccc SC
bge Lsingle_divloop
tst R
b,a Lend_regular_divide
Lnot_really_big:
1:
sll V, N, V
cmp V, R
bleu 1b
inccc ITER
be Lgot_result
dec ITER
tst R ! set up for initial iteration
Ldivloop:
sll Q, N, Q
DEVELOP_QUOTIENT_BITS(1, 0)
Lend_regular_divide:
deccc ITER
bge Ldivloop
tst R
bl,a Lgot_result
! non-restoring fixup here (one instruction only!)
ifelse(OP, `div',
` dec Q
', ` add R, divisor, R
')
Lgot_result:
ifelse(S, `true',
` ! check to see if answer should be < 0
tst SIGN
bl,a 1f
ifelse(OP, `div', `neg Q', `neg R')
1:')
retl
ifelse(OP, `div', `mov Q, %o0', `mov R, %o0')

View file

@ -1,104 +0,0 @@
/* $NetBSD: random.S,v 1.3 2009/01/05 01:16:09 pooka Exp $ */
/*
* Copyright (c) 1990,1993 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: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Here is a very good random number generator. This implementation is
* based on ``Two Fast Implementations of the "Minimal Standard" Random
* Number Generator'', David G. Carta, Communications of the ACM, Jan 1990,
* Vol 33 No 1. Do NOT modify this code unless you have a very thorough
* understanding of the algorithm. It's trickier than you think. If
* you do change it, make sure that its 10,000'th invocation returns
* 1043618065.
*
* Here is easier-to-decipher pseudocode:
*
* p = (16807*seed)<30:0> # e.g., the low 31 bits of the product
* q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32
* if (p + q < 2^31)
* seed = p + q
* else
* seed = ((p + q) & (2^31 - 1)) + 1
* return (seed);
*
* The result is in (0,2^31), e.g., it's always positive.
*/
#include <machine/asm.h>
.data
randseed:
.long 1
.text
ENTRY(random)
sethi %hi(16807), %o1
wr %o1, %lo(16807), %y
#ifdef PIC
PIC_PROLOGUE(%o5, %o2)
set randseed, %g1
ldx [%o5 + %g1], %g1
ld [%g1], %o0
#else
sethi %hi(randseed), %g1
ld [%g1 + %lo(randseed)], %o0
#endif
andcc %g0, 0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %o0, %o2
mulscc %o2, %g0, %o2
rd %y, %o3
srl %o2, 16, %o1
set 0xffff, %o4
and %o4, %o2, %o0
sll %o0, 15, %o0
srl %o3, 17, %o3
or %o3, %o0, %o0
addcc %o0, %o1, %o0
bneg 1f
sethi %hi(0x7fffffff), %o1
retl
#ifdef PIC
st %o0, [%g1]
#else
st %o0, [%g1 + %lo(randseed)]
#endif
1:
or %o1, %lo(0x7fffffff), %o1
add %o0, 1, %o0
and %o1, %o0, %o0
retl
#ifdef PIC
st %o0, [%g1]
#else
st %o0, [%g1 + %lo(randseed)]
#endif

View file

@ -1,6 +0,0 @@
# $NetBSD: Makefile.inc,v 1.3 2009/08/14 19:23:55 dsl Exp $
#
# There are likely more that we will notice when we go native
NO_SRCS+= imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c
NO_SRCS+= __main.c strlen.c strcmp.c

View file

@ -1,11 +0,0 @@
# $NetBSD: Makefile.inc,v 1.24 2010/03/15 11:46:49 uwe Exp $
#
# The rest of the lib routines are in machine/macros.h
#
SRCS+= blkcpy.S blkset.S bswap16.S bswap32.S bswap64.S
SRCS+= random.S
SRCS+= udiv.S urem.S
NO_SRCS+= imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c
NO_SRCS+= scanc.c skpc.c

View file

@ -1,49 +0,0 @@
/* $NetBSD: blkset.S,v 1.5 2005/12/11 12:24:45 christos Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* 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 at Ludd, University of Lule}.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <machine/asm.h>
/*
* Set a block of memory larger than 64K.
*/
ENTRY(__blkset,R6|R7)
movl 4(%ap), %r3
movl 8(%ap), %r7
movl 12(%ap), %r6
jbr 2f
1: subl2 %r0, %r6
movc5 $0,(%r3),%r7,%r0,(%r3)
2: movzwl $65535,%r0
cmpl %r6, %r0
jgtr 1b
movc5 $0,(%r3),%r7,%r6,(%r3)
ret

View file

@ -1,104 +0,0 @@
/* $NetBSD: random.S,v 1.4 2007/01/14 13:26:18 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden. 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Copyright (c) 1990,1993 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: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Here is a very good random number generator. This implementation is
* based on ``Two Fast Implementations of the "Minimal Standard" Random
* Number Generator'', David G. Carta, Communications of the ACM, Jan 1990,
* Vol 33 No 1. Do NOT modify this code unless you have a very thorough
* understanding of the algorithm. It's trickier than you think. If
* you do change it, make sure that its 10,000'th invocation returns
* 1043618065.
*
* Here is easier-to-decipher pseudocode:
*
* p = (16807*seed)<30:0> # e.g., the low 31 bits of the product
* q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32
* if (p + q < 2^31)
* seed = p + q
* else
* seed = ((p + q) & (2^31 - 1)) + 1
* return (seed);
*
* The result is in (0,2^31), e.g., it's always positive.
*/
#include <machine/asm.h>
.data
randseed:
.long 1
ENTRY(random, 0)
movl $16807,%r0
movl randseed,%r1 # %r2=16807*loword(randseed)
bicl3 $0xffff0000,%r1,%r2
mull2 %r0,%r2
ashl $-16,%r1,%r1 # %r1=16807*hiword(randseed)
bicl2 $0xffff0000,%r1
mull2 %r0,%r1
bicl3 $0xffff0000,%r2,%r0
ashl $-16,%r2,%r2 # %r1+=(%r2>>16)
bicl2 $0xffff0000,%r2
addl2 %r2,%r1
ashl $16,%r1,%r2 # %r0|=%r1<<16
bisl2 %r2,%r0
ashl $-16,%r1,%r1 # %r1=%r1>>16
ashl $1,%r1,%r1
movl %r0,%r2
rotl $1,%r0,%r0
bicl2 $0xfffffffe,%r0
bisl2 %r0,%r1
movl %r2,%r0
bicl2 $0x80000000,%r0
addl2 %r1,%r0
bgeq L1
subl2 $0x7fffffff,%r0
L1: movl %r0,randseed
ret

View file

@ -1,10 +0,0 @@
# $NetBSD: Makefile.inc,v 1.6 2010/01/14 02:09:46 joerg Exp $
SRCS+= byte_swap_2.S byte_swap_4.S byte_swap_8.S
SRCS+= ffs.S
SRCS+= memchr.S memcmp.S memcpy.S memmove.S memset.S
SRCS+= strcat.S strchr.S strcmp.S
SRCS+= strcpy.S strlen.S
SRCS+= strrchr.S
SRCS+= scanc.S skpc.S
SRCS+= random.S

View file

@ -1,90 +0,0 @@
/* $NetBSD: random.S,v 1.2 2008/04/28 20:24:06 martin Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Copyright (c) 1990,1993 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: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Here is a very good random number generator. This implementation is
* based on ``Two Fast Implementations of the "Minimal Standard" Random
* Number Generator'', David G. Carta, Communications of the ACM, Jan 1990,
* Vol 33 No 1. Do NOT modify this code unless you have a very thorough
* understanding of the algorithm. It's trickier than you think. If
* you do change it, make sure that its 10,000'th invocation returns
* 1043618065.
*
* Here is easier-to-decipher pseudocode:
*
* p = (16807*seed)<30:0> # e.g., the low 31 bits of the product
* q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32
* if (p + q < 2^31)
* seed = p + q
* else
* seed = ((p + q) & (2^31 - 1)) + 1
* return (seed);
*
* The result is in (0,2^31), e.g., it's always positive.
*/
#include <machine/asm.h>
.data
randseed:
.long 1
.text
ENTRY(random)
movl $16807,%eax
imull randseed(%rip)
shld $1,%eax,%edx
andl $0x7fffffff,%eax
addl %edx,%eax
js 1f
movl %eax,randseed(%rip)
ret
1:
subl $0x7fffffff,%eax
movl %eax,randseed(%rip)
ret

View file

@ -1,25 +0,0 @@
/* $NetBSD: bcd.c,v 1.1 2006/03/11 15:40:07 kleink Exp $ */
/*
* Convert a single byte between (unsigned) packed bcd and binary.
* Public domain.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0,"$NetBSD: bcd.c,v 1.1 2006/03/11 15:40:07 kleink Exp $");
#include <lib/libkern/libkern.h>
unsigned int
bcdtobin(unsigned int bcd)
{
return (((bcd >> 4) & 0x0f) * 10 + (bcd & 0x0f));
}
unsigned int
bintobcd(unsigned int bin)
{
return ((((bin / 10) << 4) & 0xf0) | (bin % 10));
}

View file

@ -1,116 +0,0 @@
/* $NetBSD: crc32.c,v 1.4 2009/03/26 22:18:14 he Exp $ */
/* crc32.c -- compute the CRC-32 of a data stream
*
* Adapted from zlib's crc code.
*
* Copyright (C) 1995-2005 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* tables for updating the shift register in one step with three exclusive-ors
* instead of four steps with four exclusive-ors. This results in about a
* factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
/* @(#) Id */
#include <sys/param.h>
#include <machine/endian.h>
typedef uint32_t u4;
/* Definitions for doing the crc four data bytes at a time. */
#define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
/* ========================================================================
* Tables of CRC-32s of all single-byte values, made by make_crc_table().
*/
#include <lib/libkern/libkern.h>
#include "crc32.h"
#if BYTE_ORDER == LITTLE_ENDIAN
/* ========================================================================= */
#define DOLIT4 c ^= *buf4++; \
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
uint32_t crc32(uint32_t crc, const uint8_t *buf, size_t len)
{
register u4 c;
register const u4 *buf4;
if (buf == NULL) return 0UL;
c = (u4)crc;
c = ~c;
while (len && ((uintptr_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--;
}
buf4 = (const u4 *)(const void *)buf;
while (len >= 32) {
DOLIT32;
len -= 32;
}
while (len >= 4) {
DOLIT4;
len -= 4;
}
buf = (const unsigned char *)buf4;
if (len) do {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len);
c = ~c;
return (uint32_t)c;
}
#else /* BIG_ENDIAN */
/* ========================================================================= */
#define DOBIG4 c ^= *++buf4; \
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
uint32_t crc32(uint32_t crc, const uint8_t *buf, size_t len)
{
register u4 c;
register const u4 *buf4;
if (buf == NULL) return 0UL;
c = REV((u4)crc);
c = ~c;
while (len && ((uintptr_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--;
}
buf4 = (const u4 *)(const void *)buf;
buf4--;
while (len >= 32) {
DOBIG32;
len -= 32;
}
while (len >= 4) {
DOBIG4;
len -= 4;
}
buf4++;
buf = (const unsigned char *)buf4;
if (len) do {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len);
c = ~c;
return (uint32_t)(REV(c));
}
#endif

Some files were not shown because too many files have changed in this diff Show more