From 7f2d47d84ca758d43a9bd9c1a1fefc2c1bcb3375 Mon Sep 17 00:00:00 2001 From: Evgeniy Ivanov Date: Wed, 25 Jan 2012 16:29:07 +0400 Subject: [PATCH] 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. --- common/include/sys/Makefile.inc | 5 +- common/include/sys/disklabel_gpt.h | 170 + sys/arch/i386/stand/boot/Makefile.boot | 19 +- sys/arch/i386/stand/bootxx/Makefile | 11 +- sys/arch/i386/stand/bootxx/Makefile.bootxx | 20 +- sys/arch/i386/stand/bootxx/boot1.c | 8 + sys/arch/i386/stand/cdboot/Makefile | 20 +- sys/arch/i386/stand/lib/Makefile | 1 + sys/arch/x86/include/bootinfo.h | 241 + sys/arch/x86/include/cpu.h | 516 ++ sys/arch/x86/include/loadfile_machdep.h | 82 + .../x86_64/skpc.S => arch/x86/include/pio.h} | 34 +- .../scanc.S => arch/x86/include/rwlock.h} | 60 +- sys/conf/newvers_stand.sh | 76 + sys/conf/osrelease.sh | 89 + sys/dev/ic/comreg.h | 155 + .../libkern/lmin.c => dev/ic/ns16550reg.h} | 30 +- sys/fs/cd9660/iso.h | 245 + sys/fs/msdosfs/bpb.h | 197 + sys/fs/msdosfs/direntry.h | 139 + sys/lib/libkern/Makefile | 31 - sys/lib/libkern/Makefile.inc | 93 - sys/lib/libkern/Makefile.libkern | 108 - sys/lib/libkern/__main.c | 40 - sys/lib/libkern/arc4random.c | 327 - sys/lib/libkern/arch/alpha/Makefile.inc | 54 - sys/lib/libkern/arch/alpha/divrem.m4 | 197 - sys/lib/libkern/arch/alpha/htonl.S | 32 - sys/lib/libkern/arch/alpha/htons.S | 32 - sys/lib/libkern/arch/alpha/ntohl.S | 32 - sys/lib/libkern/arch/alpha/ntohs.S | 32 - sys/lib/libkern/arch/arm/Makefile.inc | 6 - sys/lib/libkern/arch/arm/clzsi2.S | 88 - sys/lib/libkern/arch/hppa/Makefile.inc | 12 - sys/lib/libkern/arch/hppa/bcopy.S | 618 -- sys/lib/libkern/arch/hppa/memcpy.S | 4 - sys/lib/libkern/arch/hppa/memmove.S | 4 - sys/lib/libkern/arch/hppa/milli.S | 1814 ------ sys/lib/libkern/arch/hppa/prefix.h | 85 - sys/lib/libkern/arch/hppa/spcopy.S | 4 - sys/lib/libkern/arch/i386/Makefile.inc | 11 - sys/lib/libkern/arch/i386/random.S | 96 - sys/lib/libkern/arch/ia64/Makefile.inc | 8 - sys/lib/libkern/arch/ia64/bswap16.S | 37 - sys/lib/libkern/arch/ia64/bswap32.S | 37 - sys/lib/libkern/arch/ia64/bswap64.S | 37 - sys/lib/libkern/arch/ia64/byte_swap_2.S | 46 - sys/lib/libkern/arch/ia64/byte_swap_4.S | 46 - sys/lib/libkern/arch/ia64/byte_swap_8.S | 45 - sys/lib/libkern/arch/ia64/divdi3.S | 142 - sys/lib/libkern/arch/ia64/divsi3.S | 124 - sys/lib/libkern/arch/ia64/htonl.S | 32 - sys/lib/libkern/arch/ia64/memcpy.S | 4 - sys/lib/libkern/arch/ia64/moddi3.S | 159 - sys/lib/libkern/arch/ia64/modsi3.S | 131 - sys/lib/libkern/arch/ia64/ntohl.S | 32 - sys/lib/libkern/arch/ia64/udivdi3.S | 143 - sys/lib/libkern/arch/ia64/udivsi3.S | 124 - sys/lib/libkern/arch/ia64/umoddi3.S | 155 - sys/lib/libkern/arch/ia64/umodsi3.S | 131 - sys/lib/libkern/arch/m68k/DEFS.h | 3 - sys/lib/libkern/arch/m68k/Makefile.inc | 16 - sys/lib/libkern/arch/m68k/random.S | 69 - sys/lib/libkern/arch/m68k/scanc.S | 63 - sys/lib/libkern/arch/m68k/skpc.S | 57 - sys/lib/libkern/arch/mips/Makefile.inc | 14 - sys/lib/libkern/arch/powerpc/Makefile.inc | 15 - sys/lib/libkern/arch/powerpc/gprsavrest.S | 132 - sys/lib/libkern/arch/powerpc/memset.S | 99 - sys/lib/libkern/arch/powerpc/syncicache.c | 132 - sys/lib/libkern/arch/sh3/Makefile.inc | 12 - sys/lib/libkern/arch/sh3/ashiftrt.S | 180 - sys/lib/libkern/arch/sh3/ashlsi3.S | 40 - sys/lib/libkern/arch/sh3/ashrsi3.S | 48 - sys/lib/libkern/arch/sh3/byte_swap_2.S | 49 - sys/lib/libkern/arch/sh3/byte_swap_4.S | 50 - sys/lib/libkern/arch/sh3/byte_swap_8.S | 43 - sys/lib/libkern/arch/sh3/lshrsi3.S | 48 - sys/lib/libkern/arch/sh3/movstr.S | 99 - sys/lib/libkern/arch/sh3/movstrSI.S | 119 - sys/lib/libkern/arch/sh3/movstrSI12_i4.S | 21 - sys/lib/libkern/arch/sh3/movstr_i4.S | 80 - sys/lib/libkern/arch/sh3/mulsi3.S | 40 - sys/lib/libkern/arch/sh3/sdivsi3.S | 92 - sys/lib/libkern/arch/sh3/sdivsi3_i4i.S | 108 - sys/lib/libkern/arch/sh3/udivsi3_i4i.S | 94 - sys/lib/libkern/arch/sparc/Makefile.inc | 40 - sys/lib/libkern/arch/sparc/divrem.m4 | 272 - sys/lib/libkern/arch/sparc/random.S | 104 - sys/lib/libkern/arch/sparc64/Makefile.inc | 36 - sys/lib/libkern/arch/sparc64/divrem.m4 | 273 - sys/lib/libkern/arch/sparc64/random.S | 104 - sys/lib/libkern/arch/usermode/Makefile.inc | 6 - sys/lib/libkern/arch/vax/Makefile.inc | 11 - sys/lib/libkern/arch/vax/blkset.S | 49 - sys/lib/libkern/arch/vax/random.S | 104 - sys/lib/libkern/arch/x86_64/Makefile.inc | 10 - sys/lib/libkern/arch/x86_64/random.S | 90 - sys/lib/libkern/bcd.c | 25 - sys/lib/libkern/crc32.c | 116 - sys/lib/libkern/crc32.h | 441 -- sys/lib/libkern/imax.c | 41 - sys/lib/libkern/imin.c | 41 - sys/lib/libkern/intoa.c | 79 - sys/lib/libkern/kern_assert.c | 52 - sys/lib/libkern/libkern.h | 2 + sys/lib/libkern/lmax.c | 41 - sys/lib/libkern/max.c | 41 - sys/lib/libkern/mertwist.c | 222 - sys/lib/libkern/milieu.h | 147 - sys/lib/libkern/min.c | 41 - sys/lib/libkern/pmatch.c | 130 - sys/lib/libkern/rngtest.c | 281 - sys/lib/libkern/scanc.c | 45 - sys/lib/libkern/skpc.c | 45 - sys/lib/libkern/softfloat-macros.h | 745 --- sys/lib/libkern/softfloat-specialize.h | 480 -- sys/lib/libkern/softfloat.c | 5502 ----------------- sys/lib/libkern/softfloat.h | 363 -- sys/lib/libkern/ulmax.c | 41 - sys/lib/libkern/ulmin.c | 41 - sys/lib/libsa/Makefile | 25 +- sys/lib/libsa/cread.c | 4 + sys/lib/libsa/minixfs3.h | 2 + sys/lib/libsa/saerrno.h | 4 + sys/lib/{libkern => libsa}/xlat_mbr_fstype.c | 4 +- sys/lib/libz/Makefile | 38 + sys/lib/libz/Makefile.inc | 87 + sys/lib/libz/libz.h | 6 + .../arch/x86_64/scanc.S => libz/zalloc.c} | 49 +- sys/machine/bootinfo.h | 3 + sys/machine/cdefs.h | 22 + .../arch/sh3/udivsi3.S => machine/cpu.h} | 103 +- sys/machine/loadfile_machdep.h | 3 + sys/machine/multiboot.h | 203 + sys/machine/pio.h | 3 + sys/machine/rwlock.h | 3 + sys/net/radix.h | 157 + sys/net/route.h | 524 ++ sys/netinet/in.h | 601 ++ .../sparc64/DEFS.h => netinet/in_systm.h} | 38 +- sys/netinet/ip.h | 245 + sys/netinet/ip_var.h | 232 + .../arch/vax/blkcpy.S => netinet/udp.h} | 75 +- sys/netinet/udp_var.h | 108 + sys/stdlib.h | 334 + sys/sys/boot_flag.h | 91 + .../arch/i386/skpc.S => sys/condvar.h} | 51 +- sys/sys/disklabel.h | 476 ++ sys/sys/exec.h | 298 + sys/sys/mount.h | 466 ++ sys/sys/mutex.h | 216 + sys/sys/reboot.h | 124 + sys/sys/rwlock.h | 121 + sys/sys/stat.h | 196 + sys/sys/stdarg.h | 1 + 156 files changed, 6819 insertions(+), 17149 deletions(-) create mode 100644 common/include/sys/disklabel_gpt.h create mode 100644 sys/arch/x86/include/bootinfo.h create mode 100644 sys/arch/x86/include/cpu.h create mode 100644 sys/arch/x86/include/loadfile_machdep.h rename sys/{lib/libkern/arch/x86_64/skpc.S => arch/x86/include/pio.h} (72%) rename sys/{lib/libkern/arch/i386/scanc.S => arch/x86/include/rwlock.h} (62%) create mode 100644 sys/conf/newvers_stand.sh create mode 100644 sys/conf/osrelease.sh create mode 100644 sys/dev/ic/comreg.h rename sys/{lib/libkern/lmin.c => dev/ic/ns16550reg.h} (65%) create mode 100644 sys/fs/cd9660/iso.h create mode 100644 sys/fs/msdosfs/bpb.h create mode 100644 sys/fs/msdosfs/direntry.h delete mode 100644 sys/lib/libkern/Makefile delete mode 100644 sys/lib/libkern/Makefile.inc delete mode 100644 sys/lib/libkern/Makefile.libkern delete mode 100644 sys/lib/libkern/__main.c delete mode 100644 sys/lib/libkern/arc4random.c delete mode 100644 sys/lib/libkern/arch/alpha/Makefile.inc delete mode 100644 sys/lib/libkern/arch/alpha/divrem.m4 delete mode 100644 sys/lib/libkern/arch/alpha/htonl.S delete mode 100644 sys/lib/libkern/arch/alpha/htons.S delete mode 100644 sys/lib/libkern/arch/alpha/ntohl.S delete mode 100644 sys/lib/libkern/arch/alpha/ntohs.S delete mode 100644 sys/lib/libkern/arch/arm/Makefile.inc delete mode 100644 sys/lib/libkern/arch/arm/clzsi2.S delete mode 100644 sys/lib/libkern/arch/hppa/Makefile.inc delete mode 100644 sys/lib/libkern/arch/hppa/bcopy.S delete mode 100644 sys/lib/libkern/arch/hppa/memcpy.S delete mode 100644 sys/lib/libkern/arch/hppa/memmove.S delete mode 100644 sys/lib/libkern/arch/hppa/milli.S delete mode 100644 sys/lib/libkern/arch/hppa/prefix.h delete mode 100644 sys/lib/libkern/arch/hppa/spcopy.S delete mode 100644 sys/lib/libkern/arch/i386/Makefile.inc delete mode 100644 sys/lib/libkern/arch/i386/random.S delete mode 100644 sys/lib/libkern/arch/ia64/Makefile.inc delete mode 100644 sys/lib/libkern/arch/ia64/bswap16.S delete mode 100644 sys/lib/libkern/arch/ia64/bswap32.S delete mode 100644 sys/lib/libkern/arch/ia64/bswap64.S delete mode 100644 sys/lib/libkern/arch/ia64/byte_swap_2.S delete mode 100644 sys/lib/libkern/arch/ia64/byte_swap_4.S delete mode 100644 sys/lib/libkern/arch/ia64/byte_swap_8.S delete mode 100644 sys/lib/libkern/arch/ia64/divdi3.S delete mode 100644 sys/lib/libkern/arch/ia64/divsi3.S delete mode 100644 sys/lib/libkern/arch/ia64/htonl.S delete mode 100644 sys/lib/libkern/arch/ia64/memcpy.S delete mode 100644 sys/lib/libkern/arch/ia64/moddi3.S delete mode 100644 sys/lib/libkern/arch/ia64/modsi3.S delete mode 100644 sys/lib/libkern/arch/ia64/ntohl.S delete mode 100644 sys/lib/libkern/arch/ia64/udivdi3.S delete mode 100644 sys/lib/libkern/arch/ia64/udivsi3.S delete mode 100644 sys/lib/libkern/arch/ia64/umoddi3.S delete mode 100644 sys/lib/libkern/arch/ia64/umodsi3.S delete mode 100644 sys/lib/libkern/arch/m68k/DEFS.h delete mode 100644 sys/lib/libkern/arch/m68k/Makefile.inc delete mode 100644 sys/lib/libkern/arch/m68k/random.S delete mode 100644 sys/lib/libkern/arch/m68k/scanc.S delete mode 100644 sys/lib/libkern/arch/m68k/skpc.S delete mode 100644 sys/lib/libkern/arch/mips/Makefile.inc delete mode 100644 sys/lib/libkern/arch/powerpc/Makefile.inc delete mode 100644 sys/lib/libkern/arch/powerpc/gprsavrest.S delete mode 100644 sys/lib/libkern/arch/powerpc/memset.S delete mode 100644 sys/lib/libkern/arch/powerpc/syncicache.c delete mode 100644 sys/lib/libkern/arch/sh3/Makefile.inc delete mode 100644 sys/lib/libkern/arch/sh3/ashiftrt.S delete mode 100644 sys/lib/libkern/arch/sh3/ashlsi3.S delete mode 100644 sys/lib/libkern/arch/sh3/ashrsi3.S delete mode 100644 sys/lib/libkern/arch/sh3/byte_swap_2.S delete mode 100644 sys/lib/libkern/arch/sh3/byte_swap_4.S delete mode 100644 sys/lib/libkern/arch/sh3/byte_swap_8.S delete mode 100644 sys/lib/libkern/arch/sh3/lshrsi3.S delete mode 100644 sys/lib/libkern/arch/sh3/movstr.S delete mode 100644 sys/lib/libkern/arch/sh3/movstrSI.S delete mode 100644 sys/lib/libkern/arch/sh3/movstrSI12_i4.S delete mode 100644 sys/lib/libkern/arch/sh3/movstr_i4.S delete mode 100644 sys/lib/libkern/arch/sh3/mulsi3.S delete mode 100644 sys/lib/libkern/arch/sh3/sdivsi3.S delete mode 100644 sys/lib/libkern/arch/sh3/sdivsi3_i4i.S delete mode 100644 sys/lib/libkern/arch/sh3/udivsi3_i4i.S delete mode 100644 sys/lib/libkern/arch/sparc/Makefile.inc delete mode 100644 sys/lib/libkern/arch/sparc/divrem.m4 delete mode 100644 sys/lib/libkern/arch/sparc/random.S delete mode 100644 sys/lib/libkern/arch/sparc64/Makefile.inc delete mode 100644 sys/lib/libkern/arch/sparc64/divrem.m4 delete mode 100644 sys/lib/libkern/arch/sparc64/random.S delete mode 100644 sys/lib/libkern/arch/usermode/Makefile.inc delete mode 100644 sys/lib/libkern/arch/vax/Makefile.inc delete mode 100644 sys/lib/libkern/arch/vax/blkset.S delete mode 100644 sys/lib/libkern/arch/vax/random.S delete mode 100644 sys/lib/libkern/arch/x86_64/Makefile.inc delete mode 100644 sys/lib/libkern/arch/x86_64/random.S delete mode 100644 sys/lib/libkern/bcd.c delete mode 100644 sys/lib/libkern/crc32.c delete mode 100644 sys/lib/libkern/crc32.h delete mode 100644 sys/lib/libkern/imax.c delete mode 100644 sys/lib/libkern/imin.c delete mode 100644 sys/lib/libkern/intoa.c delete mode 100644 sys/lib/libkern/kern_assert.c delete mode 100644 sys/lib/libkern/lmax.c delete mode 100644 sys/lib/libkern/max.c delete mode 100644 sys/lib/libkern/mertwist.c delete mode 100644 sys/lib/libkern/milieu.h delete mode 100644 sys/lib/libkern/min.c delete mode 100644 sys/lib/libkern/pmatch.c delete mode 100644 sys/lib/libkern/rngtest.c delete mode 100644 sys/lib/libkern/scanc.c delete mode 100644 sys/lib/libkern/skpc.c delete mode 100644 sys/lib/libkern/softfloat-macros.h delete mode 100644 sys/lib/libkern/softfloat-specialize.h delete mode 100644 sys/lib/libkern/softfloat.c delete mode 100644 sys/lib/libkern/softfloat.h delete mode 100644 sys/lib/libkern/ulmax.c delete mode 100644 sys/lib/libkern/ulmin.c rename sys/lib/{libkern => libsa}/xlat_mbr_fstype.c (93%) create mode 100644 sys/lib/libz/Makefile create mode 100644 sys/lib/libz/Makefile.inc create mode 100644 sys/lib/libz/libz.h rename sys/lib/{libkern/arch/x86_64/scanc.S => libz/zalloc.c} (71%) create mode 100644 sys/machine/bootinfo.h create mode 100644 sys/machine/cdefs.h rename sys/{lib/libkern/arch/sh3/udivsi3.S => machine/cpu.h} (55%) create mode 100644 sys/machine/loadfile_machdep.h create mode 100644 sys/machine/multiboot.h create mode 100644 sys/machine/pio.h create mode 100644 sys/machine/rwlock.h create mode 100644 sys/net/radix.h create mode 100644 sys/net/route.h create mode 100644 sys/netinet/in.h rename sys/{lib/libkern/arch/sparc64/DEFS.h => netinet/in_systm.h} (65%) create mode 100644 sys/netinet/ip.h create mode 100644 sys/netinet/ip_var.h rename sys/{lib/libkern/arch/vax/blkcpy.S => netinet/udp.h} (63%) create mode 100644 sys/netinet/udp_var.h create mode 100644 sys/stdlib.h create mode 100644 sys/sys/boot_flag.h rename sys/{lib/libkern/arch/i386/skpc.S => sys/condvar.h} (62%) create mode 100644 sys/sys/disklabel.h create mode 100644 sys/sys/exec.h create mode 100644 sys/sys/mount.h create mode 100644 sys/sys/mutex.h create mode 100644 sys/sys/reboot.h create mode 100644 sys/sys/rwlock.h create mode 100644 sys/sys/stat.h create mode 100644 sys/sys/stdarg.h diff --git a/common/include/sys/Makefile.inc b/common/include/sys/Makefile.inc index b058fb6aa..e670fcbc5 100644 --- a/common/include/sys/Makefile.inc +++ b/common/include/sys/Makefile.inc @@ -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 diff --git a/common/include/sys/disklabel_gpt.h b/common/include/sys/disklabel_gpt.h new file mode 100644 index 000000000..43eba7220 --- /dev/null +++ b/common/include/sys/disklabel_gpt.h @@ -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_ */ diff --git a/sys/arch/i386/stand/boot/Makefile.boot b/sys/arch/i386/stand/boot/Makefile.boot index c6b4d7cce..53727d3dd 100644 --- a/sys/arch/i386/stand/boot/Makefile.boot +++ b/sys/arch/i386/stand/boot/Makefile.boot @@ -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 +.else +.include +.endif diff --git a/sys/arch/i386/stand/bootxx/Makefile b/sys/arch/i386/stand/bootxx/Makefile index 8567456ad..7eb3730f6 100644 --- a/sys/arch/i386/stand/bootxx/Makefile +++ b/sys/arch/i386/stand/bootxx/Makefile @@ -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 diff --git a/sys/arch/i386/stand/bootxx/Makefile.bootxx b/sys/arch/i386/stand/bootxx/Makefile.bootxx index 99da82618..58bcd4342 100644 --- a/sys/arch/i386/stand/bootxx/Makefile.bootxx +++ b/sys/arch/i386/stand/bootxx/Makefile.bootxx @@ -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 +.else +.include +.endif diff --git a/sys/arch/i386/stand/bootxx/boot1.c b/sys/arch/i386/stand/bootxx/boot1.c index 6333f57ca..8e1d73903 100644 --- a/sys/arch/i386/stand/bootxx/boot1.c +++ b/sys/arch/i386/stand/bootxx/boot1.c @@ -39,7 +39,11 @@ __RCSID("$NetBSD: boot1.c,v 1.20 2011/01/06 01:08:48 jakllsch Exp $"); #include #include #include +#ifndef __minix #include /* 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"; diff --git a/sys/arch/i386/stand/cdboot/Makefile b/sys/arch/i386/stand/cdboot/Makefile index 4062fded0..c175af059 100644 --- a/sys/arch/i386/stand/cdboot/Makefile +++ b/sys/arch/i386/stand/cdboot/Makefile @@ -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 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 '\' \ + @ 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} diff --git a/sys/arch/i386/stand/lib/Makefile b/sys/arch/i386/stand/lib/Makefile index a94e0288d..a80b5efb8 100644 --- a/sys/arch/i386/stand/lib/Makefile +++ b/sys/arch/i386/stand/lib/Makefile @@ -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:} diff --git a/sys/arch/x86/include/bootinfo.h b/sys/arch/x86/include/bootinfo.h new file mode 100644 index 000000000..316a57175 --- /dev/null +++ b/sys/arch/x86/include/bootinfo.h @@ -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 +#else +#include +#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 */ diff --git a/sys/arch/x86/include/cpu.h b/sys/arch/x86/include/cpu.h new file mode 100644 index 000000000..e6470c961 --- /dev/null +++ b/sys/arch/x86/include/cpu.h @@ -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 +#else +#include +#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 +#include +#include +#include +#include + +#include + +#include +#include +#include /* for device_t */ + +#ifdef XEN +#include +#include +#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 /* 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_ */ diff --git a/sys/arch/x86/include/loadfile_machdep.h b/sys/arch/x86/include/loadfile_machdep.h new file mode 100644 index 000000000..d9e16e142 --- /dev/null +++ b/sys/arch/x86/include/loadfile_machdep.h @@ -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 diff --git a/sys/lib/libkern/arch/x86_64/skpc.S b/sys/arch/x86/include/pio.h similarity index 72% rename from sys/lib/libkern/arch/x86_64/skpc.S rename to sys/arch/x86/include/pio.h index d183b7f36..ca8e57f5b 100644 --- a/sys/lib/libkern/arch/x86_64/skpc.S +++ b/sys/arch/x86/include/pio.h @@ -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 + * Functions to provide access to x86 programmed I/O instructions. */ -#include +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_ */ diff --git a/sys/lib/libkern/arch/i386/scanc.S b/sys/arch/x86/include/rwlock.h similarity index 62% rename from sys/lib/libkern/arch/i386/scanc.S rename to sys/arch/x86/include/rwlock.h index 6f77e83b7..7f0c60cff 100644 --- a/sys/lib/libkern/arch/i386/scanc.S +++ b/sys/arch/x86/include/rwlock.h @@ -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 +#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_ */ diff --git a/sys/conf/newvers_stand.sh b/sys/conf/newvers_stand.sh new file mode 100644 index 000000000..6ae1be63f --- /dev/null +++ b/sys/conf/newvers_stand.sh @@ -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 diff --git a/sys/conf/osrelease.sh b/sys/conf/osrelease.sh new file mode 100644 index 000000000..cc4f50e01 --- /dev/null +++ b/sys/conf/osrelease.sh @@ -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 + +path="$0" +[ "${path#/*}" = "$path" ] && path="./$path" +exec < ${path%/*}/../sys/param.h + +# Search for line +# #define __NetBSD_Version__ /* NetBSD */ +# +# and 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 diff --git a/sys/dev/ic/comreg.h b/sys/dev/ic/comreg.h new file mode 100644 index 000000000..c028ce4c1 --- /dev/null +++ b/sys/dev/ic/comreg.h @@ -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 + +#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 diff --git a/sys/lib/libkern/lmin.c b/sys/dev/ic/ns16550reg.h similarity index 65% rename from sys/lib/libkern/lmin.c rename to sys/dev/ic/ns16550reg.h index ef49b7773..4295647df 100644 --- a/sys/lib/libkern/lmin.c +++ b/sys/dev/ic/ns16550reg.h @@ -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 +/* + * 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) */ diff --git a/sys/fs/cd9660/iso.h b/sys/fs/cd9660/iso.h new file mode 100644 index 000000000..14dd98616 --- /dev/null +++ b/sys/fs/cd9660/iso.h @@ -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_ */ diff --git a/sys/fs/msdosfs/bpb.h b/sys/fs/msdosfs/bpb.h new file mode 100644 index 000000000..5c1a6c2d0 --- /dev/null +++ b/sys/fs/msdosfs/bpb.h @@ -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 + +#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_ */ diff --git a/sys/fs/msdosfs/direntry.h b/sys/fs/msdosfs/direntry.h new file mode 100644 index 000000000..7c3c66c8a --- /dev/null +++ b/sys/fs/msdosfs/direntry.h @@ -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_ */ diff --git a/sys/lib/libkern/Makefile b/sys/lib/libkern/Makefile deleted file mode 100644 index 09e9b6aef..000000000 --- a/sys/lib/libkern/Makefile +++ /dev/null @@ -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 - -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} diff --git a/sys/lib/libkern/Makefile.inc b/sys/lib/libkern/Makefile.inc deleted file mode 100644 index 9fe2db2b9..000000000 --- a/sys/lib/libkern/Makefile.inc +++ /dev/null @@ -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" diff --git a/sys/lib/libkern/Makefile.libkern b/sys/lib/libkern/Makefile.libkern deleted file mode 100644 index e15c16ca8..000000000 --- a/sys/lib/libkern/Makefile.libkern +++ /dev/null @@ -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 - -.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 diff --git a/sys/lib/libkern/__main.c b/sys/lib/libkern/__main.c deleted file mode 100644 index fc0359cc2..000000000 --- a/sys/lib/libkern/__main.c +++ /dev/null @@ -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 - -void __main(void); - -void -__main(void) -{ -} diff --git a/sys/lib/libkern/arc4random.c b/sys/lib/libkern/arc4random.c deleted file mode 100644 index 279c01648..000000000 --- a/sys/lib/libkern/arc4random.c +++ /dev/null @@ -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 - * - * 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 - -#ifdef _KERNEL -#include "rnd.h" -#else -#define NRND 0 -#endif - -#include -#include -#include -#ifdef _KERNEL -#include -#endif -#include - -#ifdef _KERNEL -#include -#include -#else -#define mutex_spin_enter(x) ; -#define mutex_spin_exit(x) ; -#define mutex_init(x, y, z) ; -#endif - -#include - -#if NRND > 0 -#include -#include - -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; -} diff --git a/sys/lib/libkern/arch/alpha/Makefile.inc b/sys/lib/libkern/arch/alpha/Makefile.inc deleted file mode 100644 index 9372ea4aa..000000000 --- a/sys/lib/libkern/arch/alpha/Makefile.inc +++ /dev/null @@ -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} diff --git a/sys/lib/libkern/arch/alpha/divrem.m4 b/sys/lib/libkern/arch/alpha/divrem.m4 deleted file mode 100644 index 348bbfa75..000000000 --- a/sys/lib/libkern/arch/alpha/divrem.m4 +++ /dev/null @@ -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 - -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< - * - * 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 - - .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) diff --git a/sys/lib/libkern/arch/hppa/Makefile.inc b/sys/lib/libkern/arch/hppa/Makefile.inc deleted file mode 100644 index 570b29f8c..000000000 --- a/sys/lib/libkern/arch/hppa/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/hppa/bcopy.S b/sys/lib/libkern/arch/hppa/bcopy.S deleted file mode 100644 index 98dc80c61..000000000 --- a/sys/lib/libkern/arch/hppa/bcopy.S +++ /dev/null @@ -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 - -#endif - -#include -#include -#include - -#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 -#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 */ diff --git a/sys/lib/libkern/arch/hppa/memcpy.S b/sys/lib/libkern/arch/hppa/memcpy.S deleted file mode 100644 index edb220438..000000000 --- a/sys/lib/libkern/arch/hppa/memcpy.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: memcpy.S,v 1.1 2002/06/06 20:03:38 fredette Exp $ */ - -#define MEMCPY -#include "bcopy.S" diff --git a/sys/lib/libkern/arch/hppa/memmove.S b/sys/lib/libkern/arch/hppa/memmove.S deleted file mode 100644 index 24a2872a5..000000000 --- a/sys/lib/libkern/arch/hppa/memmove.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: memmove.S,v 1.1 2002/06/06 20:03:38 fredette Exp $ */ - -#define MEMMOVE -#include "bcopy.S" diff --git a/sys/lib/libkern/arch/hppa/milli.S b/sys/lib/libkern/arch/hppa/milli.S deleted file mode 100644 index adc7ca13c..000000000 --- a/sys/lib/libkern/arch/hppa/milli.S +++ /dev/null @@ -1,1814 +0,0 @@ -; $NetBSD: milli.S,v 1.1 2002/06/06 20:03:39 fredette Exp $ -; -; $OpenBSD: milli.S,v 1.5 2001/03/29 04:08:20 mickey Exp $ -; -; (c) Copyright 1986 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 Hardware Register Definitions for Use with Assembler -; version A.08.06 -; - fr16-31 added at Utah -;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -; Hardware General Registers -r0: .equ 0 - -r1: .equ 1 - -r2: .equ 2 - -r3: .equ 3 - -r4: .equ 4 - -r5: .equ 5 - -r6: .equ 6 - -r7: .equ 7 - -r8: .equ 8 - -r9: .equ 9 - -r10: .equ 10 - -r11: .equ 11 - -r12: .equ 12 - -r13: .equ 13 - -r14: .equ 14 - -r15: .equ 15 - -r16: .equ 16 - -r17: .equ 17 - -r18: .equ 18 - -r19: .equ 19 - -r20: .equ 20 - -r21: .equ 21 - -r22: .equ 22 - -r23: .equ 23 - -r24: .equ 24 - -r25: .equ 25 - -r26: .equ 26 - -r27: .equ 27 - -r28: .equ 28 - -r29: .equ 29 - -r30: .equ 30 - -r31: .equ 31 - -; Hardware Space Registers -sr0: .equ 0 - -sr1: .equ 1 - -sr2: .equ 2 - -sr3: .equ 3 - -sr4: .equ 4 - -sr5: .equ 5 - -sr6: .equ 6 - -sr7: .equ 7 - -; Hardware Floating Point Registers -fr0: .equ 0 - -fr1: .equ 1 - -fr2: .equ 2 - -fr3: .equ 3 - -fr4: .equ 4 - -fr5: .equ 5 - -fr6: .equ 6 - -fr7: .equ 7 - -fr8: .equ 8 - -fr9: .equ 9 - -fr10: .equ 10 - -fr11: .equ 11 - -fr12: .equ 12 - -fr13: .equ 13 - -fr14: .equ 14 - -fr15: .equ 15 - -fr16: .equ 16 - -fr17: .equ 17 - -fr18: .equ 18 - -fr19: .equ 19 - -fr20: .equ 20 - -fr21: .equ 21 - -fr22: .equ 22 - -fr23: .equ 23 - -fr24: .equ 24 - -fr25: .equ 25 - -fr26: .equ 26 - -fr27: .equ 27 - -fr28: .equ 28 - -fr29: .equ 29 - -fr30: .equ 30 - -fr31: .equ 31 - -; Hardware Control Registers -cr0: .equ 0 - -rctr: .equ 0 ; Recovery Counter Register - -cr8: .equ 8 ; Protection ID 1 - -pidr1: .equ 8 - -cr9: .equ 9 ; Protection ID 2 - -pidr2: .equ 9 - -cr10: .equ 10 - -ccr: .equ 10 ; Coprocessor Confiquration Register - -cr11: .equ 11 - -sar: .equ 11 ; Shift Amount Register - -cr12: .equ 12 - -pidr3: .equ 12 ; Protection ID 3 - -cr13: .equ 13 - -pidr4: .equ 13 ; Protection ID 4 - -cr14: .equ 14 - -iva: .equ 14 ; Interrupt Vector Address - -cr15: .equ 15 - -eiem: .equ 15 ; External Interrupt Enable Mask - -cr16: .equ 16 - -itmr: .equ 16 ; Interval Timer - -cr17: .equ 17 - -pcsq: .equ 17 ; Program Counter Space queue - -cr18: .equ 18 - -pcoq: .equ 18 ; Program Counter Offset queue - -cr19: .equ 19 - -iir: .equ 19 ; Interruption Instruction Register - -cr20: .equ 20 - -isr: .equ 20 ; Interruption Space Register - -cr21: .equ 21 - -ior: .equ 21 ; Interruption Offset Register - -cr22: .equ 22 - -ipsw: .equ 22 ; Interrpution Processor Status Word - -cr23: .equ 23 - -eirr: .equ 23 ; External Interrupt Request - -cr24: .equ 24 - -ppda: .equ 24 ; Physcial Page Directory Address - -tr0: .equ 24 ; Temporary register 0 - -cr25: .equ 25 - -hta: .equ 25 ; Hash Table Address - -tr1: .equ 25 ; Temporary register 1 - -cr26: .equ 26 - -tr2: .equ 26 ; Temporary register 2 - -cr27: .equ 27 - -tr3: .equ 27 ; Temporary register 3 - -cr28: .equ 28 - -tr4: .equ 28 ; Temporary register 4 - -cr29: .equ 29 - -tr5: .equ 29 ; Temporary register 5 - -cr30: .equ 30 - -tr6: .equ 30 ; Temporary register 6 - -cr31: .equ 31 - -tr7: .equ 31 ; Temporary register 7 - -;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -; Procedure Call Convention ~ -; Register Definitions for Use with Assembler ~ -; version A.08.06 ~ -;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -; Software Architecture General Registers -rp: .equ r2 ; return pointer - -mrp: .equ r31 ; millicode return pointer - -ret0: .equ r28 ; return value - -ret1: .equ r29 ; return value (high part of double) - -sl: .equ r29 ; static link - -sp: .equ r30 ; stack pointer - -dp: .equ r27 ; data pointer - -arg0: .equ r26 ; argument - -arg1: .equ r25 ; argument or high part of double argument - -arg2: .equ r24 ; argument - -arg3: .equ r23 ; argument or high part of double argument - -;_____________________________________________________________________________ -; Software Architecture Space Registers -; sr0 ; return link form BLE -sret: .equ sr1 ; return value - -sarg: .equ sr1 ; argument - -; sr4 ; PC SPACE tracker -; sr5 ; process private data -;_____________________________________________________________________________ -; Software Architecture Pseudo Registers -previous_sp: .equ 64 ; old stack pointer (locates previous frame) - -;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -; Standard space and subspace definitions. version A.08.06 -; These are generally suitable for programs on HP_UX and HPE. -; Statements commented out are used when building such things as operating -; system kernels. -;;;;;;;;;;;;;;;; -; Additional code subspaces should have ALIGN=8 for an interspace BV -; and should have SORT=24. -; -; For an incomplete executable (program bound to shared libraries), -; sort keys $GLOBAL$ -1 and $GLOBAL$ -2 are reserved for the $DLT$ -; and $PLT$ subspaces respectively. -;;;;;;;;;;;;;;; - - .text - .EXPORT $$remI,millicode -; .IMPORT cerror -$$remI: - .PROC - .CALLINFO NO_CALLS - .ENTRY - addit,= 0,arg1,r0 - add,>= r0,arg0,ret1 - sub r0,ret1,ret1 - sub r0,arg1,r1 - ds r0,r1,r0 - or r0,r0,r1 - add ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - ds r1,arg1,r1 - addc ret1,ret1,ret1 - movb,>=,n r1,ret1,remI300 - add,< arg1,r0,r0 - add,tr r1,arg1,ret1 - sub r1,arg1,ret1 -remI300: add,>= arg0,r0,r0 - - sub r0,ret1,ret1 - bv r0(r31) - nop - .EXIT - .PROCEND - -bit1: .equ 1 - -bit30: .equ 30 -bit31: .equ 31 - -len2: .equ 2 - -len4: .equ 4 - -#if 0 -$$dyncall: - .proc - .callinfo NO_CALLS - .export $$dyncall,MILLICODE - - bb,>=,n 22,bit30,noshlibs - - depi 0,bit31,len2,22 - ldw 4(22),19 - ldw 0(22),22 -noshlibs: - ldsid (22),r1 - mtsp r1,sr0 - be 0(sr0,r22) - stw rp,-24(sp) - .procend -#endif - -$$sh_func_adrs: - .proc - .callinfo NO_CALLS - .export $$sh_func_adrs, millicode - ldo 0(r26),ret1 - dep r0,30,1,r26 - probew (r26),r31,r22 - extru,= r22,31,1,r22 - bv r0(r31) - ldws 0(r26),ret1 - .procend - -temp: .EQU r1 - -retreg: .EQU ret1 ; r29 - - .export $$divU,millicode - .import $$divU_3,millicode - .import $$divU_5,millicode - .import $$divU_6,millicode - .import $$divU_7,millicode - .import $$divU_9,millicode - .import $$divU_10,millicode - .import $$divU_12,millicode - .import $$divU_14,millicode - .import $$divU_15,millicode -$$divU: - .proc - .callinfo NO_CALLS -; The subtract is not nullified since it does no harm and can be used -; by the two cases that branch back to "normal". - comib,>= 15,arg1,special_divisor - sub r0,arg1,temp ; clear carry, negate the divisor - ds r0,temp,r0 ; set V-bit to 1 -normal: - add arg0,arg0,retreg ; shift msb bit into carry - ds r0,arg1,temp ; 1st divide step, if no carry - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 2nd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 3rd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 4th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 5th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 6th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 7th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 8th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 9th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 10th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 11th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 12th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 13th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 14th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 15th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 16th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 17th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 18th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 19th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 20th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 21st divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 22nd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 23rd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 24th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 25th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 26th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 27th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 28th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 29th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 30th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 31st divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 32nd divide step, - bv 0(r31) - addc retreg,retreg,retreg ; shift last retreg bit into retreg -;_____________________________________________________________________________ -; handle the cases where divisor is a small constant or has high bit on -special_divisor: - blr arg1,r0 - comib,>,n 0,arg1,big_divisor ; nullify previous instruction -zero_divisor: ; this label is here to provide external visibility - - addit,= 0,arg1,0 ; trap for zero dvr - nop - bv 0(r31) ; divisor == 1 - copy arg0,retreg - bv 0(r31) ; divisor == 2 - extru arg0,30,31,retreg - b,n $$divU_3 ; divisor == 3 - nop - bv 0(r31) ; divisor == 4 - extru arg0,29,30,retreg - b,n $$divU_5 ; divisor == 5 - nop - b,n $$divU_6 ; divisor == 6 - nop - b,n $$divU_7 ; divisor == 7 - nop - bv 0(r31) ; divisor == 8 - extru arg0,28,29,retreg - b,n $$divU_9 ; divisor == 9 - nop - b,n $$divU_10 ; divisor == 10 - nop - b normal ; divisor == 11 - ds r0,temp,r0 ; set V-bit to 1 - b,n $$divU_12 ; divisor == 12 - nop - b normal ; divisor == 13 - ds r0,temp,r0 ; set V-bit to 1 - b,n $$divU_14 ; divisor == 14 - nop - b,n $$divU_15 ; divisor == 15 - nop -;_____________________________________________________________________________ -; Handle the case where the high bit is on in the divisor. -; Compute: if( dividend>=divisor) quotient=1; else quotient=0; -; Note: dividend>==divisor iff dividend-divisor does not borrow -; and not borrow iff carry -big_divisor: - sub arg0,arg1,r0 - bv 0(r31) - addc r0,r0,retreg - .procend - .end - -t2: .EQU r1 - -; x2 .EQU arg0 ; r26 -t1: .EQU arg1 ; r25 - -; x1 .EQU ret1 ; r29 -;_____________________________________________________________________________ - -$$divide_by_constant: - .PROC - .CALLINFO NO_CALLS - .export $$divide_by_constant,millicode -; Provides a "nice" label for the code covered by the unwind descriptor -; for things like gprof. - -$$divI_2: - .EXPORT $$divI_2,MILLICODE - COMCLR,>= arg0,0,0 - ADDI 1,arg0,arg0 - bv 0(r31) - EXTRS arg0,30,31,ret1 - -$$divI_4: - .EXPORT $$divI_4,MILLICODE - COMCLR,>= arg0,0,0 - ADDI 3,arg0,arg0 - bv 0(r31) - EXTRS arg0,29,30,ret1 - -$$divI_8: - .EXPORT $$divI_8,MILLICODE - COMCLR,>= arg0,0,0 - ADDI 7,arg0,arg0 - bv 0(r31) - EXTRS arg0,28,29,ret1 - -$$divI_16: - .EXPORT $$divI_16,MILLICODE - COMCLR,>= arg0,0,0 - ADDI 15,arg0,arg0 - bv 0(r31) - EXTRS arg0,27,28,ret1 - -$$divI_3: - .EXPORT $$divI_3,MILLICODE - COMB,<,N arg0,0,$neg3 - - ADDI 1,arg0,arg0 - EXTRU arg0,1,2,ret1 - SH2ADD arg0,arg0,arg0 - B $pos - ADDC ret1,0,ret1 - -$neg3: - SUBI 1,arg0,arg0 - EXTRU arg0,1,2,ret1 - SH2ADD arg0,arg0,arg0 - B $neg - ADDC ret1,0,ret1 - -$$divU_3: - .EXPORT $$divU_3,MILLICODE - ADDI 1,arg0,arg0 - ADDC 0,0,ret1 - SHD ret1,arg0,30,t1 - SH2ADD arg0,arg0,arg0 - B $pos - ADDC ret1,t1,ret1 - -$$divI_5: - .EXPORT $$divI_5,MILLICODE - COMB,<,N arg0,0,$neg5 - ADDI 3,arg0,t1 - SH1ADD arg0,t1,arg0 - B $pos - ADDC 0,0,ret1 - -$neg5: - SUB 0,arg0,arg0 - ADDI 1,arg0,arg0 - SHD 0,arg0,31,ret1 - SH1ADD arg0,arg0,arg0 - B $neg - ADDC ret1,0,ret1 - -$$divU_5: - .EXPORT $$divU_5,MILLICODE - ADDI 1,arg0,arg0 - ADDC 0,0,ret1 - SHD ret1,arg0,31,t1 - SH1ADD arg0,arg0,arg0 - B $pos - ADDC t1,ret1,ret1 - -$$divI_6: - .EXPORT $$divI_6,MILLICODE - COMB,<,N arg0,0,$neg6 - EXTRU arg0,30,31,arg0 - ADDI 5,arg0,t1 - SH2ADD arg0,t1,arg0 - B $pos - ADDC 0,0,ret1 - -$neg6: - SUBI 2,arg0,arg0 - EXTRU arg0,30,31,arg0 - SHD 0,arg0,30,ret1 - SH2ADD arg0,arg0,arg0 - B $neg - ADDC ret1,0,ret1 - -$$divU_6: - .EXPORT $$divU_6,MILLICODE - EXTRU arg0,30,31,arg0 - ADDI 1,arg0,arg0 - SHD 0,arg0,30,ret1 - SH2ADD arg0,arg0,arg0 - B $pos - ADDC ret1,0,ret1 - -$$divU_10: - .EXPORT $$divU_10,MILLICODE - EXTRU arg0,30,31,arg0 - ADDI 3,arg0,t1 - SH1ADD arg0,t1,arg0 - ADDC 0,0,ret1 -$pos: - SHD ret1,arg0,28,t1 - SHD arg0,0,28,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,ret1 -$pos_for_17: - SHD ret1,arg0,24,t1 - SHD arg0,0,24,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,ret1 - - SHD ret1,arg0,16,t1 - SHD arg0,0,16,t2 - ADD arg0,t2,arg0 - bv 0(r31) - ADDC ret1,t1,ret1 - -$$divI_10: - .EXPORT $$divI_10,MILLICODE - COMB,< arg0,0,$neg10 - COPY 0,ret1 - EXTRU arg0,30,31,arg0 - ADDIB,TR 1,arg0,$pos - SH1ADD arg0,arg0,arg0 - -$neg10: - SUBI 2,arg0,arg0 - EXTRU arg0,30,31,arg0 - SH1ADD arg0,arg0,arg0 -$neg: - SHD ret1,arg0,28,t1 - SHD arg0,0,28,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,ret1 -$neg_for_17: - SHD ret1,arg0,24,t1 - SHD arg0,0,24,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,ret1 - - SHD ret1,arg0,16,t1 - SHD arg0,0,16,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,ret1 - bv 0(r31) - SUB 0,ret1,ret1 - -$$divI_12: - .EXPORT $$divI_12,MILLICODE - COMB,< arg0,0,$neg12 - COPY 0,ret1 - EXTRU arg0,29,30,arg0 - ADDIB,TR 1,arg0,$pos - SH2ADD arg0,arg0,arg0 - -$neg12: - SUBI 4,arg0,arg0 - EXTRU arg0,29,30,arg0 - B $neg - SH2ADD arg0,arg0,arg0 - -$$divU_12: - .EXPORT $$divU_12,MILLICODE - EXTRU arg0,29,30,arg0 - ADDI 5,arg0,t1 - SH2ADD arg0,t1,arg0 - B $pos - ADDC 0,0,ret1 - -$$divI_15: - .EXPORT $$divI_15,MILLICODE - COMB,< arg0,0,$neg15 - COPY 0,ret1 - ADDIB,TR 1,arg0,$pos+4 - SHD ret1,arg0,28,t1 - -$neg15: - B $neg - SUBI 1,arg0,arg0 - -$$divU_15: - .EXPORT $$divU_15,MILLICODE - ADDI 1,arg0,arg0 - B $pos - ADDC 0,0,ret1 - -$$divI_17: - .EXPORT $$divI_17,MILLICODE - COMB,<,N arg0,0,$neg17 - ADDI 1,arg0,arg0 - SHD 0,arg0,28,t1 - SHD arg0,0,28,t2 - SUB t2,arg0,arg0 - B $pos_for_17 - SUBB t1,0,ret1 - -$neg17: - SUBI 1,arg0,arg0 - SHD 0,arg0,28,t1 - SHD arg0,0,28,t2 - SUB t2,arg0,arg0 - B $neg_for_17 - SUBB t1,0,ret1 - -$$divU_17: - .EXPORT $$divU_17,MILLICODE - ADDI 1,arg0,arg0 - ADDC 0,0,ret1 - SHD ret1,arg0,28,t1 -$u17: - SHD arg0,0,28,t2 - SUB t2,arg0,arg0 - B $pos_for_17 - SUBB t1,ret1,ret1 - -$$divI_7: - .EXPORT $$divI_7,MILLICODE - COMB,<,N arg0,0,$neg7 -$7: - ADDI 1,arg0,arg0 - SHD 0,arg0,29,ret1 - SH3ADD arg0,arg0,arg0 - ADDC ret1,0,ret1 -$pos7: - SHD ret1,arg0,26,t1 - SHD arg0,0,26,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,ret1 - - SHD ret1,arg0,20,t1 - SHD arg0,0,20,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,t1 - - COPY 0,ret1 - SHD,= t1,arg0,24,t1 -$1: - ADDB,TR t1,ret1,$2 - EXTRU arg0,31,24,arg0 - - bv,n 0(r31) - -$2: - ADDB,TR t1,arg0,$1 - EXTRU,= arg0,7,8,t1 - -$neg7: - SUBI 1,arg0,arg0 -$8: - SHD 0,arg0,29,ret1 - SH3ADD arg0,arg0,arg0 - ADDC ret1,0,ret1 - -$neg7_shift: - SHD ret1,arg0,26,t1 - SHD arg0,0,26,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,ret1 - - SHD ret1,arg0,20,t1 - SHD arg0,0,20,t2 - ADD arg0,t2,arg0 - ADDC ret1,t1,t1 - - COPY 0,ret1 - SHD,= t1,arg0,24,t1 -$3: - ADDB,TR t1,ret1,$4 - EXTRU arg0,31,24,arg0 - - bv 0(r31) - SUB 0,ret1,ret1 - -$4: - ADDB,TR t1,arg0,$3 - EXTRU,= arg0,7,8,t1 - -$$divU_7: - .EXPORT $$divU_7,MILLICODE - ADDI 1,arg0,arg0 - ADDC 0,0,ret1 - SHD ret1,arg0,29,t1 - SH3ADD arg0,arg0,arg0 - B $pos7 - ADDC t1,ret1,ret1 - -$$divI_9: - .EXPORT $$divI_9,MILLICODE - COMB,<,N arg0,0,$neg9 - ADDI 1,arg0,arg0 - SHD 0,arg0,29,t1 - SHD arg0,0,29,t2 - SUB t2,arg0,arg0 - B $pos7 - SUBB t1,0,ret1 - -$neg9: - SUBI 1,arg0,arg0 - SHD 0,arg0,29,t1 - SHD arg0,0,29,t2 - SUB t2,arg0,arg0 - B $neg7_shift - SUBB t1,0,ret1 - -$$divU_9: - .EXPORT $$divU_9,MILLICODE - ADDI 1,arg0,arg0 - ADDC 0,0,ret1 - SHD ret1,arg0,29,t1 - SHD arg0,0,29,t2 - SUB t2,arg0,arg0 - B $pos7 - SUBB t1,ret1,ret1 - -$$divI_14: - .EXPORT $$divI_14,MILLICODE - COMB,<,N arg0,0,$neg14 -$$divU_14: - .EXPORT $$divU_14,MILLICODE - B $7 - EXTRU arg0,30,31,arg0 - -$neg14: - SUBI 2,arg0,arg0 - B $8 - EXTRU arg0,30,31,arg0 - - .PROCEND - .END - -rmndr: .EQU ret1 ; r29 - - .export $$remU,millicode -$$remU: - .proc - .callinfo NO_CALLS - .entry - - comib,>=,n 0,arg1,special_case - sub r0,arg1,rmndr ; clear carry, negate the divisor - ds r0,rmndr,r0 ; set V-bit to 1 - add arg0,arg0,temp ; shift msb bit into carry - ds r0,arg1,rmndr ; 1st divide step, if no carry - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 2nd divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 3rd divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 4th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 5th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 6th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 7th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 8th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 9th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 10th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 11th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 12th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 13th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 14th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 15th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 16th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 17th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 18th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 19th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 20th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 21st divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 22nd divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 23rd divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 24th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 25th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 26th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 27th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 28th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 29th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 30th divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 31st divide step - addc temp,temp,temp ; shift temp with/into carry - ds rmndr,arg1,rmndr ; 32nd divide step, - comiclr,<= 0,rmndr,r0 - add rmndr,arg1,rmndr ; correction -; .exit - bv,n 0(r31) - nop -; Putting >= on the last DS and deleting COMICLR does not work! -;_____________________________________________________________________________ -special_case: - addit,= 0,arg1,r0 ; trap on div by zero - sub,>>= arg0,arg1,rmndr - copy arg0,rmndr - .exit - bv,n 0(r31) - nop - .procend - .end - -; Use bv 0(r31) and bv,n 0(r31) instead. -; #define return bv 0(%mrp) -; #define return_n bv,n 0(%mrp) - - .align 16 -$$mulI: - - .proc - .callinfo NO_CALLS - .export $$mulI, millicode - combt,<<= %r25,%r26,l4 ; swap args if unsigned %r25>%r26 - copy 0,%r29 ; zero out the result - xor %r26,%r25,%r26 ; swap %r26 & %r25 using the - xor %r26,%r25,%r25 ; old xor trick - xor %r26,%r25,%r26 -l4: combt,<= 0,%r26,l3 ; if %r26>=0 then proceed like unsigned - - zdep %r25,30,8,%r1 ; %r1 = (%r25&0xff)<<1 ********* - sub,> 0,%r25,%r1 ; otherwise negate both and - combt,<=,n %r26,%r1,l2 ; swap back if |%r26|<|%r25| - sub 0,%r26,%r25 - movb,tr,n %r1,%r26,l2 ; 10th inst. - -l0: add %r29,%r1,%r29 ; add in this partial product - -l1: zdep %r26,23,24,%r26 ; %r26 <<= 8 ****************** - -l2: zdep %r25,30,8,%r1 ; %r1 = (%r25&0xff)<<1 ********* - -l3: blr %r1,0 ; case on these 8 bits ****** - - extru %r25,23,24,%r25 ; %r25 >>= 8 ****************** - -;16 insts before this. -; %r26 <<= 8 ************************** -x0: comb,<> %r25,0,l2 ! zdep %r26,23,24,%r26 ! bv,n 0(r31) ! nop - -x1: comb,<> %r25,0,l1 ! add %r29,%r26,%r29 ! bv,n 0(r31) ! nop - -x2: comb,<> %r25,0,l1 ! sh1add %r26,%r29,%r29 ! bv,n 0(r31) ! nop - -x3: comb,<> %r25,0,l0 ! sh1add %r26,%r26,%r1 ! bv 0(r31) ! add %r29,%r1,%r29 - -x4: comb,<> %r25,0,l1 ! sh2add %r26,%r29,%r29 ! bv,n 0(r31) ! nop - -x5: comb,<> %r25,0,l0 ! sh2add %r26,%r26,%r1 ! bv 0(r31) ! add %r29,%r1,%r29 - -x6: sh1add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh1add %r1,%r29,%r29 ! bv,n 0(r31) - -x7: sh1add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh2add %r26,%r29,%r29 ! b,n ret_t0 - -x8: comb,<> %r25,0,l1 ! sh3add %r26,%r29,%r29 ! bv,n 0(r31) ! nop - -x9: comb,<> %r25,0,l0 ! sh3add %r26,%r26,%r1 ! bv 0(r31) ! add %r29,%r1,%r29 - -x10: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh1add %r1,%r29,%r29 ! bv,n 0(r31) - -x11: sh1add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh3add %r26,%r29,%r29 ! b,n ret_t0 - -x12: sh1add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh2add %r1,%r29,%r29 ! bv,n 0(r31) - -x13: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh3add %r26,%r29,%r29 ! b,n ret_t0 - -x14: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x15: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh1add %r1,%r1,%r1 ! b,n ret_t0 - -x16: zdep %r26,27,28,%r1 ! comb,<> %r25,0,l1 ! add %r29,%r1,%r29 ! bv,n 0(r31) - -x17: sh3add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh3add %r26,%r1,%r1 ! b,n ret_t0 - -x18: sh3add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh1add %r1,%r29,%r29 ! bv,n 0(r31) - -x19: sh3add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh1add %r1,%r26,%r1 ! b,n ret_t0 - -x20: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh2add %r1,%r29,%r29 ! bv,n 0(r31) - -x21: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh2add %r1,%r26,%r1 ! b,n ret_t0 - -x22: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x23: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x24: sh1add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh3add %r1,%r29,%r29 ! bv,n 0(r31) - -x25: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh2add %r1,%r1,%r1 ! b,n ret_t0 - -x26: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x27: sh1add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh3add %r1,%r1,%r1 ! b,n ret_t0 - -x28: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x29: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x30: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x31: zdep %r26,26,27,%r1 ! comb,<> %r25,0,l0 ! sub %r1,%r26,%r1 ! b,n ret_t0 - -x32: zdep %r26,26,27,%r1 ! comb,<> %r25,0,l1 ! add %r29,%r1,%r29 ! bv,n 0(r31) - -x33: sh3add %r26,0,%r1 ! comb,<> %r25,0,l0 ! sh2add %r1,%r26,%r1 ! b,n ret_t0 - -x34: zdep %r26,27,28,%r1 ! add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x35: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh3add %r26,%r1,%r1 - -x36: sh3add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh2add %r1,%r29,%r29 ! bv,n 0(r31) - -x37: sh3add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh2add %r1,%r26,%r1 ! b,n ret_t0 - -x38: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x39: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x40: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh3add %r1,%r29,%r29 ! bv,n 0(r31) - -x41: sh2add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh3add %r1,%r26,%r1 ! b,n ret_t0 - -x42: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x43: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x44: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x45: sh3add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! sh2add %r1,%r1,%r1 ! b,n ret_t0 - -x46: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! add %r1,%r26,%r1 - -x47: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh1add %r26,%r1,%r1 - -x48: sh1add %r26,%r26,%r1 ! comb,<> %r25,0,l0 ! zdep %r1,27,28,%r1 ! b,n ret_t0 - -x49: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh2add %r26,%r1,%r1 - -x50: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x51: sh3add %r26,%r26,%r1 ! sh3add %r26,%r1,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x52: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x53: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x54: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x55: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x56: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x57: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x58: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x59: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t02a0 ! sh1add %r1,%r1,%r1 - -x60: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x61: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x62: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x63: zdep %r26,25,26,%r1 ! comb,<> %r25,0,l0 ! sub %r1,%r26,%r1 ! b,n ret_t0 - -x64: zdep %r26,25,26,%r1 ! comb,<> %r25,0,l1 ! add %r29,%r1,%r29 ! bv,n 0(r31) - -x65: sh3add %r26,0,%r1 ! comb,<> %r25,0,l0 ! sh3add %r1,%r26,%r1 ! b,n ret_t0 - -x66: zdep %r26,26,27,%r1 ! add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x67: sh3add %r26,0,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x68: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x69: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x70: zdep %r26,25,26,%r1 ! sh2add %r26,%r1,%r1 ! b e_t0 ! sh1add %r26,%r1,%r1 - -x71: sh3add %r26,%r26,%r1 ! sh3add %r1,0,%r1 ! b e_t0 ! sub %r1,%r26,%r1 - -x72: sh3add %r26,%r26,%r1 ! comb,<> %r25,0,l1 ! sh3add %r1,%r29,%r29 ! bv,n 0(r31) - -x73: sh3add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_shift ! add %r29,%r1,%r29 - -x74: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x75: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x76: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x77: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x78: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r26,%r1 - -x79: zdep %r26,27,28,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sub %r1,%r26,%r1 - -x80: zdep %r26,27,28,%r1 ! sh2add %r1,%r1,%r1 ! b e_shift ! add %r29,%r1,%r29 - -x81: sh3add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_shift ! add %r29,%r1,%r29 - -x82: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x83: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x84: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x85: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x86: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r26,%r1 - -x87: sh3add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_t02a0 ! sh2add %r26,%r1,%r1 - -x88: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x89: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x90: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x91: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x92: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0 ! sh1add %r1,%r26,%r1 - -x93: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x94: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0 ! sh1add %r26,%r1,%r1 - -x95: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x96: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x97: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x98: zdep %r26,26,27,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh1add %r26,%r1,%r1 - -x99: sh3add %r26,0,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x100: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x101: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x102: zdep %r26,26,27,%r1 ! sh1add %r26,%r1,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x103: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t02a0 ! sh2add %r1,%r26,%r1 - -x104: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x105: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x106: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x107: sh3add %r26,%r26,%r1 ! sh2add %r26,%r1,%r1 ! b e_t02a0 ! sh3add %r1,%r26,%r1 - -x108: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x109: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x110: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_2t0 ! sh1add %r1,%r26,%r1 - -x111: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x112: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! zdep %r1,27,28,%r1 - -x113: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t02a0 ! sh1add %r1,%r1,%r1 - -x114: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r1,%r1 - -x115: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0a0 ! sh1add %r1,%r1,%r1 - -x116: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0 ! sh2add %r1,%r26,%r1 - -x117: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r1,%r1 - -x118: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0a0 ! sh3add %r1,%r1,%r1 - -x119: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t02a0 ! sh3add %r1,%r1,%r1 - -x120: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x121: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x122: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x123: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x124: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x125: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x126: zdep %r26,25,26,%r1 ! sub %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x127: zdep %r26,24,25,%r1 ! comb,<> %r25,0,l0 ! sub %r1,%r26,%r1 ! b,n ret_t0 - -x128: zdep %r26,24,25,%r1 ! comb,<> %r25,0,l1 ! add %r29,%r1,%r29 ! bv,n 0(r31) - -x129: zdep %r26,24,25,%r1 ! comb,<> %r25,0,l0 ! add %r1,%r26,%r1 ! b,n ret_t0 - -x130: zdep %r26,25,26,%r1 ! add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x131: sh3add %r26,0,%r1 ! sh3add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x132: sh3add %r26,0,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x133: sh3add %r26,0,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x134: sh3add %r26,0,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r26,%r1 - -x135: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x136: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x137: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x138: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x139: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0a0 ! sh2add %r1,%r26,%r1 - -x140: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0 ! sh2add %r1,%r1,%r1 - -x141: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0a0 ! sh1add %r1,%r26,%r1 - -x142: sh3add %r26,%r26,%r1 ! sh3add %r1,0,%r1 ! b e_2t0 ! sub %r1,%r26,%r1 - -x143: zdep %r26,27,28,%r1 ! sh3add %r1,%r1,%r1 ! b e_t0 ! sub %r1,%r26,%r1 - -x144: sh3add %r26,%r26,%r1 ! sh3add %r1,0,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x145: sh3add %r26,%r26,%r1 ! sh3add %r1,0,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x146: sh3add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x147: sh3add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x148: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x149: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x150: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r26,%r1 - -x151: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0a0 ! sh1add %r1,%r26,%r1 - -x152: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x153: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x154: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x155: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x156: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0 ! sh1add %r1,%r26,%r1 - -x157: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_t02a0 ! sh2add %r1,%r1,%r1 - -x158: zdep %r26,27,28,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0 ! sub %r1,%r26,%r1 - -x159: zdep %r26,26,27,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sub %r1,%r26,%r1 - -x160: sh2add %r26,%r26,%r1 ! sh2add %r1,0,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x161: sh3add %r26,0,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x162: sh3add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x163: sh3add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_t0 ! sh1add %r1,%r26,%r1 - -x164: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x165: sh3add %r26,0,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x166: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r26,%r1 - -x167: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_2t0a0 ! sh1add %r1,%r26,%r1 - -x168: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x169: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x170: zdep %r26,26,27,%r1 ! sh1add %r26,%r1,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x171: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r1,%r1 - -x172: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_4t0 ! sh1add %r1,%r26,%r1 - -x173: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t02a0 ! sh3add %r1,%r1,%r1 - -x174: zdep %r26,26,27,%r1 ! sh1add %r26,%r1,%r1 ! b e_t04a0 ! sh2add %r1,%r1,%r1 - -x175: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_5t0 ! sh1add %r1,%r26,%r1 - -x176: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_8t0 ! add %r1,%r26,%r1 - -x177: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_8t0a0 ! add %r1,%r26,%r1 - -x178: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0 ! sh3add %r1,%r26,%r1 - -x179: sh2add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0a0 ! sh3add %r1,%r26,%r1 - -x180: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x181: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x182: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0 ! sh1add %r1,%r26,%r1 - -x183: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0a0 ! sh1add %r1,%r26,%r1 - -x184: sh2add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_4t0 ! add %r1,%r26,%r1 - -x185: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x186: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r1,%r1 - -x187: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t02a0 ! sh2add %r1,%r1,%r1 - -x188: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_4t0 ! sh1add %r26,%r1,%r1 - -x189: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r1,%r1 - -x190: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_2t0 ! sh2add %r1,%r1,%r1 - -x191: zdep %r26,25,26,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sub %r1,%r26,%r1 - -x192: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x193: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x194: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x195: sh3add %r26,0,%r1 ! sh3add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x196: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_4t0 ! sh1add %r1,%r26,%r1 - -x197: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_4t0a0 ! sh1add %r1,%r26,%r1 - -x198: zdep %r26,25,26,%r1 ! sh1add %r26,%r1,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x199: sh3add %r26,0,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0a0 ! sh1add %r1,%r1,%r1 - -x200: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x201: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x202: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x203: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0a0 ! sh2add %r1,%r26,%r1 - -x204: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0 ! sh1add %r1,%r1,%r1 - -x205: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x206: zdep %r26,25,26,%r1 ! sh2add %r26,%r1,%r1 ! b e_t02a0 ! sh1add %r1,%r1,%r1 - -x207: sh3add %r26,0,%r1 ! sh1add %r1,%r26,%r1 ! b e_3t0 ! sh2add %r1,%r26,%r1 - -x208: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_8t0 ! add %r1,%r26,%r1 - -x209: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_8t0a0 ! add %r1,%r26,%r1 - -x210: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0 ! sh2add %r1,%r1,%r1 - -x211: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0a0 ! sh2add %r1,%r1,%r1 - -x212: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_4t0 ! sh2add %r1,%r26,%r1 - -x213: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_4t0a0 ! sh2add %r1,%r26,%r1 - -x214: sh3add %r26,%r26,%r1 ! sh2add %r26,%r1,%r1 ! b e2t04a0 ! sh3add %r1,%r26,%r1 - -x215: sh2add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_5t0 ! sh1add %r1,%r26,%r1 - -x216: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x217: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x218: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_2t0 ! sh2add %r1,%r26,%r1 - -x219: sh3add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x220: sh1add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_4t0 ! sh1add %r1,%r26,%r1 - -x221: sh1add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_4t0a0 ! sh1add %r1,%r26,%r1 - -x222: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r1,%r1 - -x223: sh3add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0a0 ! sh1add %r1,%r1,%r1 - -x224: sh3add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_8t0 ! add %r1,%r26,%r1 - -x225: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0 ! sh2add %r1,%r1,%r1 - -x226: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_t02a0 ! zdep %r1,26,27,%r1 - -x227: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_t02a0 ! sh2add %r1,%r1,%r1 - -x228: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0 ! sh1add %r1,%r1,%r1 - -x229: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_4t0a0 ! sh1add %r1,%r1,%r1 - -x230: sh3add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_5t0 ! add %r1,%r26,%r1 - -x231: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_3t0 ! sh2add %r1,%r26,%r1 - -x232: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_8t0 ! sh2add %r1,%r26,%r1 - -x233: sh1add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e_8t0a0 ! sh2add %r1,%r26,%r1 - -x234: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0 ! sh3add %r1,%r1,%r1 - -x235: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e_2t0a0 ! sh3add %r1,%r1,%r1 - -x236: sh3add %r26,%r26,%r1 ! sh1add %r1,%r26,%r1 ! b e4t08a0 ! sh1add %r1,%r1,%r1 - -x237: zdep %r26,27,28,%r1 ! sh2add %r1,%r1,%r1 ! b e_3t0 ! sub %r1,%r26,%r1 - -x238: sh1add %r26,%r26,%r1 ! sh2add %r1,%r26,%r1 ! b e2t04a0 ! sh3add %r1,%r1,%r1 - -x239: zdep %r26,27,28,%r1 ! sh2add %r1,%r1,%r1 ! b e_t0ma0 ! sh1add %r1,%r1,%r1 - -x240: sh3add %r26,%r26,%r1 ! add %r1,%r26,%r1 ! b e_8t0 ! sh1add %r1,%r1,%r1 - -x241: sh3add %r26,%r26,%r1 ! add %r1,%r26,%r1 ! b e_8t0a0 ! sh1add %r1,%r1,%r1 - -x242: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_2t0 ! sh3add %r1,%r26,%r1 - -x243: sh3add %r26,%r26,%r1 ! sh3add %r1,%r1,%r1 ! b e_t0 ! sh1add %r1,%r1,%r1 - -x244: sh2add %r26,%r26,%r1 ! sh1add %r1,%r1,%r1 ! b e_4t0 ! sh2add %r1,%r26,%r1 - -x245: sh3add %r26,0,%r1 ! sh1add %r1,%r1,%r1 ! b e_5t0 ! sh1add %r1,%r26,%r1 - -x246: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_2t0 ! sh1add %r1,%r1,%r1 - -x247: sh2add %r26,%r26,%r1 ! sh3add %r1,%r26,%r1 ! b e_2t0a0 ! sh1add %r1,%r1,%r1 - -x248: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_shift ! sh3add %r1,%r29,%r29 - -x249: zdep %r26,26,27,%r1 ! sub %r1,%r26,%r1 ! b e_t0 ! sh3add %r1,%r26,%r1 - -x250: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0 ! sh2add %r1,%r1,%r1 - -x251: sh2add %r26,%r26,%r1 ! sh2add %r1,%r1,%r1 ! b e_2t0a0 ! sh2add %r1,%r1,%r1 - -x252: zdep %r26,25,26,%r1 ! sub %r1,%r26,%r1 ! b e_shift ! sh2add %r1,%r29,%r29 - -x253: zdep %r26,25,26,%r1 ! sub %r1,%r26,%r1 ! b e_t0 ! sh2add %r1,%r26,%r1 - -x254: zdep %r26,24,25,%r1 ! sub %r1,%r26,%r1 ! b e_shift ! sh1add %r1,%r29,%r29 - -x255: zdep %r26,23,24,%r1 ! comb,<> %r25,0,l0 ! sub %r1,%r26,%r1 ! b,n ret_t0 - -;1040 insts before this. -ret_t0: bv 0(r31) - -e_t0: add %r29,%r1,%r29 - -e_shift: comb,<> %r25,0,l2 - - zdep %r26,23,24,%r26 ; %r26 <<= 8 *********** - bv,n 0(r31) -e_t0ma0: comb,<> %r25,0,l0 - - sub %r1,%r26,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e_t0a0: comb,<> %r25,0,l0 - - add %r1,%r26,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e_t02a0: comb,<> %r25,0,l0 - - sh1add %r26,%r1,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e_t04a0: comb,<> %r25,0,l0 - - sh2add %r26,%r1,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e_2t0: comb,<> %r25,0,l1 - - sh1add %r1,%r29,%r29 - bv,n 0(r31) -e_2t0a0: comb,<> %r25,0,l0 - - sh1add %r1,%r26,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e2t04a0: sh1add %r26,%r1,%r1 - - comb,<> %r25,0,l1 - sh1add %r1,%r29,%r29 - bv,n 0(r31) -e_3t0: comb,<> %r25,0,l0 - - sh1add %r1,%r1,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e_4t0: comb,<> %r25,0,l1 - - sh2add %r1,%r29,%r29 - bv,n 0(r31) -e_4t0a0: comb,<> %r25,0,l0 - - sh2add %r1,%r26,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e4t08a0: sh1add %r26,%r1,%r1 - - comb,<> %r25,0,l1 - sh2add %r1,%r29,%r29 - bv,n 0(r31) -e_5t0: comb,<> %r25,0,l0 - - sh2add %r1,%r1,%r1 - bv 0(r31) - add %r29,%r1,%r29 -e_8t0: comb,<> %r25,0,l1 - - sh3add %r1,%r29,%r29 - bv,n 0(r31) -e_8t0a0: comb,<> %r25,0,l0 - - sh3add %r1,%r26,%r1 - bv 0(r31) - add %r29,%r1,%r29 - - .procend - .end - - .import $$divI_2,millicode - .import $$divI_3,millicode - .import $$divI_4,millicode - .import $$divI_5,millicode - .import $$divI_6,millicode - .import $$divI_7,millicode - .import $$divI_8,millicode - .import $$divI_9,millicode - .import $$divI_10,millicode - .import $$divI_12,millicode - .import $$divI_14,millicode - .import $$divI_15,millicode - .export $$divI,millicode - .export $$divoI,millicode -$$divoI: - .proc - .callinfo NO_CALLS - comib,=,n -1,arg1,negative1 ; when divisor == -1 -$$divI: - comib,>>=,n 15,arg1,small_divisor - add,>= 0,arg0,retreg ; move dividend, if retreg < 0, -normal1: - sub 0,retreg,retreg ; make it positive - sub 0,arg1,temp ; clear carry, - ; negate the divisor - ds 0,temp,0 ; set V-bit to the comple- - ; ment of the divisor sign - add retreg,retreg,retreg ; shift msb bit into carry - ds r0,arg1,temp ; 1st divide step, if no carry - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 2nd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 3rd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 4th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 5th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 6th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 7th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 8th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 9th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 10th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 11th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 12th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 13th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 14th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 15th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 16th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 17th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 18th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 19th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 20th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 21st divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 22nd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 23rd divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 24th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 25th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 26th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 27th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 28th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 29th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 30th divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 31st divide step - addc retreg,retreg,retreg ; shift retreg with/into carry - ds temp,arg1,temp ; 32nd divide step, - addc retreg,retreg,retreg ; shift last retreg bit into retreg - xor,>= arg0,arg1,0 ; get correct sign of quotient - sub 0,retreg,retreg ; based on operand signs - bv,n 0(r31) - nop -;______________________________________________________________________ -small_divisor: - blr,n arg1,r0 - nop -; table for divisor == 0,1, ... ,15 - addit,= 0,arg1,r0 ; trap if divisor == 0 - nop - bv 0(r31) ; divisor == 1 - copy arg0,retreg - b,n $$divI_2 ; divisor == 2 - nop - b,n $$divI_3 ; divisor == 3 - nop - b,n $$divI_4 ; divisor == 4 - nop - b,n $$divI_5 ; divisor == 5 - nop - b,n $$divI_6 ; divisor == 6 - nop - b,n $$divI_7 ; divisor == 7 - nop - b,n $$divI_8 ; divisor == 8 - nop - b,n $$divI_9 ; divisor == 9 - nop - b,n $$divI_10 ; divisor == 10 - nop - b normal1 ; divisor == 11 - add,>= 0,arg0,retreg - b,n $$divI_12 ; divisor == 12 - nop - b normal1 ; divisor == 13 - add,>= 0,arg0,retreg - b,n $$divI_14 ; divisor == 14 - nop - b,n $$divI_15 ; divisor == 15 - nop -;______________________________________________________________________ -negative1: - sub 0,arg0,retreg ; result is negation of dividend - bv 0(r31) - addo arg0,arg1,r0 ; trap iff dividend==0x80000000 && divisor==-1 - .procend - .end diff --git a/sys/lib/libkern/arch/hppa/prefix.h b/sys/lib/libkern/arch/hppa/prefix.h deleted file mode 100644 index 1c49a8730..000000000 --- a/sys/lib/libkern/arch/hppa/prefix.h +++ /dev/null @@ -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 - -#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 ; diff --git a/sys/lib/libkern/arch/hppa/spcopy.S b/sys/lib/libkern/arch/hppa/spcopy.S deleted file mode 100644 index da462b9ea..000000000 --- a/sys/lib/libkern/arch/hppa/spcopy.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: spcopy.S,v 1.1 2002/06/06 20:03:39 fredette Exp $ */ - -#define SPCOPY -#include "bcopy.S" diff --git a/sys/lib/libkern/arch/i386/Makefile.inc b/sys/lib/libkern/arch/i386/Makefile.inc deleted file mode 100644 index e0c45969c..000000000 --- a/sys/lib/libkern/arch/i386/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/i386/random.S b/sys/lib/libkern/arch/i386/random.S deleted file mode 100644 index 9670ff1aa..000000000 --- a/sys/lib/libkern/arch/i386/random.S +++ /dev/null @@ -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 - - .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 diff --git a/sys/lib/libkern/arch/ia64/Makefile.inc b/sys/lib/libkern/arch/ia64/Makefile.inc deleted file mode 100644 index c55b01e08..000000000 --- a/sys/lib/libkern/arch/ia64/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/bswap16.S b/sys/lib/libkern/arch/ia64/bswap16.S deleted file mode 100644 index 95f0dfef8..000000000 --- a/sys/lib/libkern/arch/ia64/bswap16.S +++ /dev/null @@ -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" diff --git a/sys/lib/libkern/arch/ia64/bswap32.S b/sys/lib/libkern/arch/ia64/bswap32.S deleted file mode 100644 index 7cf66de9e..000000000 --- a/sys/lib/libkern/arch/ia64/bswap32.S +++ /dev/null @@ -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" diff --git a/sys/lib/libkern/arch/ia64/bswap64.S b/sys/lib/libkern/arch/ia64/bswap64.S deleted file mode 100644 index 1214379e5..000000000 --- a/sys/lib/libkern/arch/ia64/bswap64.S +++ /dev/null @@ -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" diff --git a/sys/lib/libkern/arch/ia64/byte_swap_2.S b/sys/lib/libkern/arch/ia64/byte_swap_2.S deleted file mode 100644 index 975bc9c7a..000000000 --- a/sys/lib/libkern/arch/ia64/byte_swap_2.S +++ /dev/null @@ -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 - -#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) diff --git a/sys/lib/libkern/arch/ia64/byte_swap_4.S b/sys/lib/libkern/arch/ia64/byte_swap_4.S deleted file mode 100644 index a600aa4fb..000000000 --- a/sys/lib/libkern/arch/ia64/byte_swap_4.S +++ /dev/null @@ -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 - -#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) diff --git a/sys/lib/libkern/arch/ia64/byte_swap_8.S b/sys/lib/libkern/arch/ia64/byte_swap_8.S deleted file mode 100644 index aee67843e..000000000 --- a/sys/lib/libkern/arch/ia64/byte_swap_8.S +++ /dev/null @@ -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 - -#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) diff --git a/sys/lib/libkern/arch/ia64/divdi3.S b/sys/lib/libkern/arch/ia64/divdi3.S deleted file mode 100644 index 9c518283e..000000000 --- a/sys/lib/libkern/arch/ia64/divdi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/divsi3.S b/sys/lib/libkern/arch/ia64/divsi3.S deleted file mode 100644 index 7cb55d01d..000000000 --- a/sys/lib/libkern/arch/ia64/divsi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/htonl.S b/sys/lib/libkern/arch/ia64/htonl.S deleted file mode 100644 index 3bae41fc1..000000000 --- a/sys/lib/libkern/arch/ia64/htonl.S +++ /dev/null @@ -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" diff --git a/sys/lib/libkern/arch/ia64/memcpy.S b/sys/lib/libkern/arch/ia64/memcpy.S deleted file mode 100644 index 67c83ce41..000000000 --- a/sys/lib/libkern/arch/ia64/memcpy.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: memcpy.S,v 1.1 2006/04/07 13:57:43 cherry Exp $ */ - -#include - diff --git a/sys/lib/libkern/arch/ia64/moddi3.S b/sys/lib/libkern/arch/ia64/moddi3.S deleted file mode 100644 index 32ad0a2d8..000000000 --- a/sys/lib/libkern/arch/ia64/moddi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/modsi3.S b/sys/lib/libkern/arch/ia64/modsi3.S deleted file mode 100644 index 1fa6d6413..000000000 --- a/sys/lib/libkern/arch/ia64/modsi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/ntohl.S b/sys/lib/libkern/arch/ia64/ntohl.S deleted file mode 100644 index 257fb16fd..000000000 --- a/sys/lib/libkern/arch/ia64/ntohl.S +++ /dev/null @@ -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" diff --git a/sys/lib/libkern/arch/ia64/udivdi3.S b/sys/lib/libkern/arch/ia64/udivdi3.S deleted file mode 100644 index 7cb9f6e4c..000000000 --- a/sys/lib/libkern/arch/ia64/udivdi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/udivsi3.S b/sys/lib/libkern/arch/ia64/udivsi3.S deleted file mode 100644 index 51b1f1498..000000000 --- a/sys/lib/libkern/arch/ia64/udivsi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/umoddi3.S b/sys/lib/libkern/arch/ia64/umoddi3.S deleted file mode 100644 index 38e539d59..000000000 --- a/sys/lib/libkern/arch/ia64/umoddi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/ia64/umodsi3.S b/sys/lib/libkern/arch/ia64/umodsi3.S deleted file mode 100644 index ddac05d45..000000000 --- a/sys/lib/libkern/arch/ia64/umodsi3.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/m68k/DEFS.h b/sys/lib/libkern/arch/m68k/DEFS.h deleted file mode 100644 index f5c6689c3..000000000 --- a/sys/lib/libkern/arch/m68k/DEFS.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: DEFS.h,v 1.4 1999/11/11 01:32:10 thorpej Exp $ */ - -#include diff --git a/sys/lib/libkern/arch/m68k/Makefile.inc b/sys/lib/libkern/arch/m68k/Makefile.inc deleted file mode 100644 index 4ab3b5f25..000000000 --- a/sys/lib/libkern/arch/m68k/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/m68k/random.S b/sys/lib/libkern/arch/m68k/random.S deleted file mode 100644 index 96fc68adb..000000000 --- a/sys/lib/libkern/arch/m68k/random.S +++ /dev/null @@ -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 - - .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 diff --git a/sys/lib/libkern/arch/m68k/scanc.S b/sys/lib/libkern/arch/m68k/scanc.S deleted file mode 100644 index 5ca5dcead..000000000 --- a/sys/lib/libkern/arch/m68k/scanc.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/m68k/skpc.S b/sys/lib/libkern/arch/m68k/skpc.S deleted file mode 100644 index 7a73a46ea..000000000 --- a/sys/lib/libkern/arch/m68k/skpc.S +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/mips/Makefile.inc b/sys/lib/libkern/arch/mips/Makefile.inc deleted file mode 100644 index 740ff2265..000000000 --- a/sys/lib/libkern/arch/mips/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/powerpc/Makefile.inc b/sys/lib/libkern/arch/powerpc/Makefile.inc deleted file mode 100644 index 661af3317..000000000 --- a/sys/lib/libkern/arch/powerpc/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/powerpc/gprsavrest.S b/sys/lib/libkern/arch/powerpc/gprsavrest.S deleted file mode 100644 index 739325ec5..000000000 --- a/sys/lib/libkern/arch/powerpc/gprsavrest.S +++ /dev/null @@ -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 - -__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) diff --git a/sys/lib/libkern/arch/powerpc/memset.S b/sys/lib/libkern/arch/powerpc/memset.S deleted file mode 100644 index d6f8a8395..000000000 --- a/sys/lib/libkern/arch/powerpc/memset.S +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: memset.S,v 1.7 2011/01/17 07:07:36 matt Exp $ */ - -/*- - * Copyright (C) 2003 Matt Thomas - * Copyright (C) 2001 Martin J. Laubach - * 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 - -/*----------------------------------------------------------------------*/ -/* - 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 diff --git a/sys/lib/libkern/arch/powerpc/syncicache.c b/sys/lib/libkern/arch/powerpc/syncicache.c deleted file mode 100644 index e36466686..000000000 --- a/sys/lib/libkern/arch/powerpc/syncicache.c +++ /dev/null @@ -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 -#if defined(_KERNEL) -#include -#include -#include -#endif -#if !defined(_STANDALONE) -#include -#endif - -#include - - -#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"); -} diff --git a/sys/lib/libkern/arch/sh3/Makefile.inc b/sys/lib/libkern/arch/sh3/Makefile.inc deleted file mode 100644 index 19a2fa52b..000000000 --- a/sys/lib/libkern/arch/sh3/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/sh3/ashiftrt.S b/sys/lib/libkern/arch/sh3/ashiftrt.S deleted file mode 100644 index ed5b09e0c..000000000 --- a/sys/lib/libkern/arch/sh3/ashiftrt.S +++ /dev/null @@ -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 - - -#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 diff --git a/sys/lib/libkern/arch/sh3/ashlsi3.S b/sys/lib/libkern/arch/sh3/ashlsi3.S deleted file mode 100644 index ea36b8863..000000000 --- a/sys/lib/libkern/arch/sh3/ashlsi3.S +++ /dev/null @@ -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 - - -#ifdef __ELF__ - .hidden __ashlsi3 -#endif - - -NENTRY(__ashlsi3) - shld r5, r4 - rts - mov r4, r0 diff --git a/sys/lib/libkern/arch/sh3/ashrsi3.S b/sys/lib/libkern/arch/sh3/ashrsi3.S deleted file mode 100644 index 3da686a6f..000000000 --- a/sys/lib/libkern/arch/sh3/ashrsi3.S +++ /dev/null @@ -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 - - -#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 diff --git a/sys/lib/libkern/arch/sh3/byte_swap_2.S b/sys/lib/libkern/arch/sh3/byte_swap_2.S deleted file mode 100644 index 5feede060..000000000 --- a/sys/lib/libkern/arch/sh3/byte_swap_2.S +++ /dev/null @@ -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 - -#undef _LOCORE -#define _LOCORE /* XXX not really, just assembly-code source */ -#include - -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 diff --git a/sys/lib/libkern/arch/sh3/byte_swap_4.S b/sys/lib/libkern/arch/sh3/byte_swap_4.S deleted file mode 100644 index c875483d2..000000000 --- a/sys/lib/libkern/arch/sh3/byte_swap_4.S +++ /dev/null @@ -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 - -#undef _LOCORE -#define _LOCORE /* XXX not really, just assembly-code source */ -#include - -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 diff --git a/sys/lib/libkern/arch/sh3/byte_swap_8.S b/sys/lib/libkern/arch/sh3/byte_swap_8.S deleted file mode 100644 index 5714b63be..000000000 --- a/sys/lib/libkern/arch/sh3/byte_swap_8.S +++ /dev/null @@ -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 - -#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 diff --git a/sys/lib/libkern/arch/sh3/lshrsi3.S b/sys/lib/libkern/arch/sh3/lshrsi3.S deleted file mode 100644 index 42c0cab3c..000000000 --- a/sys/lib/libkern/arch/sh3/lshrsi3.S +++ /dev/null @@ -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 - - -#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 diff --git a/sys/lib/libkern/arch/sh3/movstr.S b/sys/lib/libkern/arch/sh3/movstr.S deleted file mode 100644 index 7786b2379..000000000 --- a/sys/lib/libkern/arch/sh3/movstr.S +++ /dev/null @@ -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 - - -#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) diff --git a/sys/lib/libkern/arch/sh3/movstrSI.S b/sys/lib/libkern/arch/sh3/movstrSI.S deleted file mode 100644 index 75b410469..000000000 --- a/sys/lib/libkern/arch/sh3/movstrSI.S +++ /dev/null @@ -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 - - -#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) diff --git a/sys/lib/libkern/arch/sh3/movstrSI12_i4.S b/sys/lib/libkern/arch/sh3/movstrSI12_i4.S deleted file mode 100644 index 2ef09c450..000000000 --- a/sys/lib/libkern/arch/sh3/movstrSI12_i4.S +++ /dev/null @@ -1,21 +0,0 @@ -/* $NetBSD: movstrSI12_i4.S,v 1.2 2009/01/07 22:15:18 uwe Exp $ */ - -#include - - -#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) diff --git a/sys/lib/libkern/arch/sh3/movstr_i4.S b/sys/lib/libkern/arch/sh3/movstr_i4.S deleted file mode 100644 index 24c47e357..000000000 --- a/sys/lib/libkern/arch/sh3/movstr_i4.S +++ /dev/null @@ -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 - - -#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) diff --git a/sys/lib/libkern/arch/sh3/mulsi3.S b/sys/lib/libkern/arch/sh3/mulsi3.S deleted file mode 100644 index 9f6e9c05e..000000000 --- a/sys/lib/libkern/arch/sh3/mulsi3.S +++ /dev/null @@ -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 - - -#ifdef __ELF__ - .hidden __mulsi3 -#endif - - -NENTRY(__mulsi3) - mul.l r4, r5 - rts - sts macl, r0 diff --git a/sys/lib/libkern/arch/sh3/sdivsi3.S b/sys/lib/libkern/arch/sh3/sdivsi3.S deleted file mode 100644 index e9723c9db..000000000 --- a/sys/lib/libkern/arch/sh3/sdivsi3.S +++ /dev/null @@ -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 -#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 diff --git a/sys/lib/libkern/arch/sh3/sdivsi3_i4i.S b/sys/lib/libkern/arch/sh3/sdivsi3_i4i.S deleted file mode 100644 index 3ea32e1dd..000000000 --- a/sys/lib/libkern/arch/sh3/sdivsi3_i4i.S +++ /dev/null @@ -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 -#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 diff --git a/sys/lib/libkern/arch/sh3/udivsi3_i4i.S b/sys/lib/libkern/arch/sh3/udivsi3_i4i.S deleted file mode 100644 index 0e9cb6e1f..000000000 --- a/sys/lib/libkern/arch/sh3/udivsi3_i4i.S +++ /dev/null @@ -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 -#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 diff --git a/sys/lib/libkern/arch/sparc/Makefile.inc b/sys/lib/libkern/arch/sparc/Makefile.inc deleted file mode 100644 index c31bdb79d..000000000 --- a/sys/lib/libkern/arch/sparc/Makefile.inc +++ /dev/null @@ -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} diff --git a/sys/lib/libkern/arch/sparc/divrem.m4 b/sys/lib/libkern/arch/sparc/divrem.m4 deleted file mode 100644 index 26b5fa583..000000000 --- a/sys/lib/libkern/arch/sparc/divrem.m4 +++ /dev/null @@ -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 -#include - -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') diff --git a/sys/lib/libkern/arch/sparc/random.S b/sys/lib/libkern/arch/sparc/random.S deleted file mode 100644 index d4d2bcc91..000000000 --- a/sys/lib/libkern/arch/sparc/random.S +++ /dev/null @@ -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 - - .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 diff --git a/sys/lib/libkern/arch/sparc64/Makefile.inc b/sys/lib/libkern/arch/sparc64/Makefile.inc deleted file mode 100644 index 42094cf03..000000000 --- a/sys/lib/libkern/arch/sparc64/Makefile.inc +++ /dev/null @@ -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} diff --git a/sys/lib/libkern/arch/sparc64/divrem.m4 b/sys/lib/libkern/arch/sparc64/divrem.m4 deleted file mode 100644 index 03063cad2..000000000 --- a/sys/lib/libkern/arch/sparc64/divrem.m4 +++ /dev/null @@ -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 -#include - -/* - * 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') diff --git a/sys/lib/libkern/arch/sparc64/random.S b/sys/lib/libkern/arch/sparc64/random.S deleted file mode 100644 index 86aeeb359..000000000 --- a/sys/lib/libkern/arch/sparc64/random.S +++ /dev/null @@ -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 - - .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 diff --git a/sys/lib/libkern/arch/usermode/Makefile.inc b/sys/lib/libkern/arch/usermode/Makefile.inc deleted file mode 100644 index 26c03168b..000000000 --- a/sys/lib/libkern/arch/usermode/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/vax/Makefile.inc b/sys/lib/libkern/arch/vax/Makefile.inc deleted file mode 100644 index 18e9abc74..000000000 --- a/sys/lib/libkern/arch/vax/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/vax/blkset.S b/sys/lib/libkern/arch/vax/blkset.S deleted file mode 100644 index 6c34b7f93..000000000 --- a/sys/lib/libkern/arch/vax/blkset.S +++ /dev/null @@ -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 - -/* - * 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 diff --git a/sys/lib/libkern/arch/vax/random.S b/sys/lib/libkern/arch/vax/random.S deleted file mode 100644 index b1d9e81e1..000000000 --- a/sys/lib/libkern/arch/vax/random.S +++ /dev/null @@ -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 - - .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 diff --git a/sys/lib/libkern/arch/x86_64/Makefile.inc b/sys/lib/libkern/arch/x86_64/Makefile.inc deleted file mode 100644 index 7a18707a6..000000000 --- a/sys/lib/libkern/arch/x86_64/Makefile.inc +++ /dev/null @@ -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 diff --git a/sys/lib/libkern/arch/x86_64/random.S b/sys/lib/libkern/arch/x86_64/random.S deleted file mode 100644 index cd179e349..000000000 --- a/sys/lib/libkern/arch/x86_64/random.S +++ /dev/null @@ -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 - - .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 diff --git a/sys/lib/libkern/bcd.c b/sys/lib/libkern/bcd.c deleted file mode 100644 index ced51c743..000000000 --- a/sys/lib/libkern/bcd.c +++ /dev/null @@ -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 -__KERNEL_RCSID(0,"$NetBSD: bcd.c,v 1.1 2006/03/11 15:40:07 kleink Exp $"); - -#include - -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)); -} diff --git a/sys/lib/libkern/crc32.c b/sys/lib/libkern/crc32.c deleted file mode 100644 index 490b6fc5f..000000000 --- a/sys/lib/libkern/crc32.c +++ /dev/null @@ -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 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 -#include - -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 -#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 diff --git a/sys/lib/libkern/crc32.h b/sys/lib/libkern/crc32.h deleted file mode 100644 index 22c2f1b64..000000000 --- a/sys/lib/libkern/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* $NetBSD: crc32.h,v 1.1 2009/03/25 01:26:13 darran Exp $ */ - -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -static const uint32_t crc_table[8][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL - } -}; diff --git a/sys/lib/libkern/imax.c b/sys/lib/libkern/imax.c deleted file mode 100644 index 911bfd4df..000000000 --- a/sys/lib/libkern/imax.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: imax.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1991 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. - * - * @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - */ - -#define LIBKERN_INLINE -#include - -int -imax(int a, int b) -{ - return (a > b ? a : b); -} diff --git a/sys/lib/libkern/imin.c b/sys/lib/libkern/imin.c deleted file mode 100644 index 0e73f38c5..000000000 --- a/sys/lib/libkern/imin.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: imin.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1991 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. - * - * @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - */ - -#define LIBKERN_INLINE -#include - -int -imin(int a, int b) -{ - return (a < b ? a : b); -} diff --git a/sys/lib/libkern/intoa.c b/sys/lib/libkern/intoa.c deleted file mode 100644 index 2f781b1e8..000000000 --- a/sys/lib/libkern/intoa.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: intoa.c,v 1.3 2009/03/14 15:36:22 dsl Exp $ */ - -/* - * Copyright (c) 1992 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp (LBL) - */ - -#include - -#if defined(_KERNEL) || defined(_STANDALONE) -#include -#else -char *intoa(u_int32_t); /* XXX */ -#endif - -/* Similar to inet_ntoa() */ -char * -intoa(u_int32_t addr) -{ - char *cp; - u_int byte; - int n; - static char buf[17]; /* strlen(".255.255.255.255") + 1 */ - - addr = ntohl(addr); - cp = &buf[sizeof buf]; - *--cp = '\0'; - - n = 4; - do { - byte = addr & 0xff; - *--cp = byte % 10 + '0'; - byte /= 10; - if (byte > 0) { - *--cp = byte % 10 + '0'; - byte /= 10; - if (byte > 0) - *--cp = byte + '0'; - } - *--cp = '.'; - addr >>= 8; - } while (--n > 0); - - return (cp+1); -} diff --git a/sys/lib/libkern/kern_assert.c b/sys/lib/libkern/kern_assert.c deleted file mode 100644 index 5880a7d82..000000000 --- a/sys/lib/libkern/kern_assert.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: kern_assert.c,v 1.2 2011/09/29 20:50:09 christos Exp $ */ - -/* - * Copyright (c) 1996 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 - * for the NetBSD Project. - * 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 -#include - -#ifdef _STANDALONE -#include -#endif - -void -kern_assert(const char *fmt, ...) -{ - va_list ap; -#ifdef _KERNEL - if (panicstr != NULL) - return; -#endif - va_start(ap, fmt); - vpanic(fmt, ap); - va_end(ap); -} diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h index e6fc8b886..7857cf941 100644 --- a/sys/lib/libkern/libkern.h +++ b/sys/lib/libkern/libkern.h @@ -337,7 +337,9 @@ int snprintb(char *, size_t, const char *, uint64_t); int snprintb_m(char *, size_t, const char *, uint64_t, size_t); int kheapsort(void *, size_t, size_t, int (*)(const void *, const void *), void *); +#ifndef __minix uint32_t crc32(uint32_t, const uint8_t *, size_t); +#endif unsigned int popcount(unsigned int) __constfunc; unsigned int popcountl(unsigned long) __constfunc; unsigned int popcountll(unsigned long long) __constfunc; diff --git a/sys/lib/libkern/lmax.c b/sys/lib/libkern/lmax.c deleted file mode 100644 index cabb7b19a..000000000 --- a/sys/lib/libkern/lmax.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: lmax.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1991 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. - * - * @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - */ - -#define LIBKERN_INLINE -#include - -long -lmax(long a, long b) -{ - return (a > b ? a : b); -} diff --git a/sys/lib/libkern/max.c b/sys/lib/libkern/max.c deleted file mode 100644 index eae7bdc23..000000000 --- a/sys/lib/libkern/max.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: max.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1991 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. - * - * @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - */ - -#define LIBKERN_INLINE -#include - -unsigned int -max(unsigned int a, unsigned int b) -{ - return (a > b ? a : b); -} diff --git a/sys/lib/libkern/mertwist.c b/sys/lib/libkern/mertwist.c deleted file mode 100644 index 3613449d4..000000000 --- a/sys/lib/libkern/mertwist.c +++ /dev/null @@ -1,222 +0,0 @@ -/* $NetBSD: mertwist.c,v 1.8 2008/04/28 20:24:06 martin Exp $ */ -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas . - * - * 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. - */ - -#if defined(_KERNEL) || defined(_STANDALONE) -#include -#include -#include - -#include -#else -#include -#include -#include -#include -#define KASSERT(x) assert(x) -#endif - -/* - * Mersenne Twister. Produces identical output compared to mt19937ar.c - * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html - */ - -#define MATRIX_A(a) (((a) & 1) ? 0x9908b0df : 0) -#define TEMPERING_MASK_B 0x9d2c5680 -#define TEMPERING_MASK_C 0xefc60000 -#define UPPER_MASK 0x80000000 -#define LOWER_MASK 0x7fffffff -#define MIX(u,l) (((u) & UPPER_MASK) | ((l) & LOWER_MASK)) - -#define KNUTH_MULTIPLIER 0x6c078965 - -#ifndef MTPRNG_RLEN -#define MTPRNG_RLEN 624 -#endif -#define MTPRNG_POS1 397 - -static void mtprng_refresh(struct mtprng_state *); - -/* - * Initialize the generator from a seed - */ -void -mtprng_init32(struct mtprng_state *mt, uint32_t seed) -{ - size_t i; - - /* - * Use Knuth's algorithm for expanding this seed over its - * portion of the key space. - */ - mt->mt_elem[0] = seed; - for (i = 1; i < MTPRNG_RLEN; i++) { - mt->mt_elem[i] = KNUTH_MULTIPLIER - * (mt->mt_elem[i-1] ^ (mt->mt_elem[i-1] >> 30)) + i; - } - - mtprng_refresh(mt); -} - -void -mtprng_initarray(struct mtprng_state *mt, const uint32_t *key, size_t keylen) -{ - uint32_t *mp; - size_t i, j, k; - - /* - * Use Knuth's algorithm for expanding this seed over its - * portion of the key space. - */ - mt->mt_elem[0] = 19650218UL; - for (i = 1; i < MTPRNG_RLEN; i++) { - mt->mt_elem[i] = KNUTH_MULTIPLIER - * (mt->mt_elem[i-1] ^ (mt->mt_elem[i-1] >> 30)) + i; - } - - KASSERT(keylen > 0); - - i = 1; - j = 0; - k = (keylen < MTPRNG_RLEN ? MTPRNG_RLEN : keylen); - - mp = &mt->mt_elem[1]; - for (; k-- > 0; mp++) { - mp[0] ^= (mp[-1] ^ (mp[-1] >> 30)) * 1664525UL; - mp[0] += key[j] + j; - if (++i == MTPRNG_RLEN) { - KASSERT(mp == mt->mt_elem + MTPRNG_RLEN - 1); - mt->mt_elem[0] = mp[0]; - i = 1; - mp = mt->mt_elem; - } - if (++j == keylen) - j = 0; - } - for (j = MTPRNG_RLEN; --j > 0; mp++) { - mp[0] ^= (mp[-1] ^ (mp[-1] >> 30)) * 1566083941UL; - mp[0] -= i; - if (++i == MTPRNG_RLEN) { - KASSERT(mp == mt->mt_elem + MTPRNG_RLEN - 1); - mt->mt_elem[0] = mp[0]; - i = 1; - mp = mt->mt_elem; - } - } - mt->mt_elem[0] = 0x80000000; - mtprng_refresh(mt); -} - -/* - * Generate an array of 624 untempered numbers - */ -void -mtprng_refresh(struct mtprng_state *mt) -{ - uint32_t y; - size_t i, j; - /* - * The following has been refactored to avoid the need for 'mod 624' - */ - for (i = 0, j = MTPRNG_POS1; j < MTPRNG_RLEN; i++, j++) { - y = MIX(mt->mt_elem[i], mt->mt_elem[i+1]); - mt->mt_elem[i] = mt->mt_elem[j] ^ (y >> 1) ^ MATRIX_A(y); - } - for (j = 0; i < MTPRNG_RLEN - 1; i++, j++) { - y = MIX(mt->mt_elem[i], mt->mt_elem[i+1]); - mt->mt_elem[i] = mt->mt_elem[j] ^ (y >> 1) ^ MATRIX_A(y); - } - y = MIX(mt->mt_elem[MTPRNG_RLEN - 1], mt->mt_elem[0]); - mt->mt_elem[MTPRNG_RLEN - 1] = - mt->mt_elem[MTPRNG_POS1 - 1] ^ (y >> 1) ^ MATRIX_A(y); -} - -/* - * Extract a tempered PRN based on the current index. Then recompute a - * new value for the index. This avoids having to regenerate the array - * every 624 iterations. We can do this since recomputing only the next - * element and the [(i + 397) % 624] one. - */ -uint32_t -mtprng_rawrandom(struct mtprng_state *mt) -{ - uint32_t x, y; - const size_t i = mt->mt_idx; - size_t j; - - /* - * First generate the random value for the current position. - */ - x = mt->mt_elem[i]; - x ^= x >> 11; - x ^= (x << 7) & TEMPERING_MASK_B; - x ^= (x << 15) & TEMPERING_MASK_C; - x ^= x >> 18; - - /* - * Next recalculate the next sequence for the current position. - */ - y = mt->mt_elem[i]; - if (__predict_true(i < MTPRNG_RLEN - 1)) { - /* - * Avoid doing % since it can be expensive. - * j = (i + MTPRNG_POS1) % MTPRNG_RLEN; - */ - j = i + MTPRNG_POS1; - if (j >= MTPRNG_RLEN) - j -= MTPRNG_RLEN; - mt->mt_idx++; - } else { - j = MTPRNG_POS1 - 1; - mt->mt_idx = 0; - } - y = MIX(y, mt->mt_elem[mt->mt_idx]); - mt->mt_elem[i] = mt->mt_elem[j] ^ (y >> 1) ^ MATRIX_A(y); - - /* - * Return the value calculated in the first step. - */ - return x; -} - -/* - * This is a non-standard routine which attempts to return a cryptographically - * strong random number by collapsing 2 32bit values outputed by the twister - * into one 32bit value. - */ -uint32_t -mtprng_random(struct mtprng_state *mt) -{ - uint32_t a; - - mt->mt_count = (mt->mt_count + 13) & 31; - a = mtprng_rawrandom(mt); - a = (a << mt->mt_count) | (a >> (32 - mt->mt_count)); - return a + mtprng_rawrandom(mt); -} diff --git a/sys/lib/libkern/milieu.h b/sys/lib/libkern/milieu.h deleted file mode 100644 index 863a28cd4..000000000 --- a/sys/lib/libkern/milieu.h +++ /dev/null @@ -1,147 +0,0 @@ -/* $NetBSD: milieu.h,v 1.3 2008/04/28 20:24:06 martin Exp $ */ - -/* This is a derivative work. */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Ross Harvey. - * - * 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. - */ - -/* -=============================================================================== - -This C header file is part of TestFloat, Release 2a, a package of programs -for testing the correctness of floating-point arithmetic complying to the -IEC/IEEE Standard for Floating-Point. - -Written by John R. Hauser. More information is available through the Web -page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -#ifndef MILIEU_H -#define MILIEU_H - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include -#else -#include -#endif - -#include - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ - -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define LITTLEENDIAN -#else -#define BIGENDIAN -#endif - -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef unsigned int uint8; -typedef signed int int8; -typedef unsigned int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef uint64_t uint64; -typedef int64_t int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef uint8_t bits8; -typedef int8_t sbits8; -typedef uint16_t bits16; -typedef int16_t sbits16; -typedef uint32_t bits32; -typedef int32_t sbits32; -#ifdef BITS64 -typedef uint64_t bits64; -typedef int64_t sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -#endif diff --git a/sys/lib/libkern/min.c b/sys/lib/libkern/min.c deleted file mode 100644 index 935c06db8..000000000 --- a/sys/lib/libkern/min.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: min.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1991 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. - * - * @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - */ - -#define LIBKERN_INLINE -#include - -unsigned int -min(unsigned int a, unsigned int b) -{ - return (a < b ? a : b); -} diff --git a/sys/lib/libkern/pmatch.c b/sys/lib/libkern/pmatch.c deleted file mode 100644 index fe7f61904..000000000 --- a/sys/lib/libkern/pmatch.c +++ /dev/null @@ -1,130 +0,0 @@ -/* $NetBSD: pmatch.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/*- - * Copyright (c) 1980, 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. - */ - -#include -#include -/* - * pmatch(): - * Return 2 on exact match. - * Return 1 on substring match. - * Return 0 on no match. - * Return -1 on error. - * *estr will point to the end of thelongest exact or substring match. - */ -int -pmatch(const char *string, const char *pattern, const char **estr) -{ - u_char stringc, patternc, rangec; - int match, negate_range; - const char *oestr, *pestr, *testr; - - if (estr == NULL) - estr = &testr; - - for (;; ++string) { - stringc = *string; - switch (patternc = *pattern++) { - case 0: - *estr = string; - return stringc == '\0' ? 2 : 1; - case '?': - if (stringc == '\0') - return 0; - *estr = string; - break; - case '*': - if (!*pattern) { - while (*string) - string++; - *estr = string; - return 2; - } - oestr = *estr; - pestr = NULL; - - do { - switch (pmatch(string, pattern, estr)) { - case -1: - return -1; - case 0: - break; - case 1: - pestr = *estr; - break; - case 2: - return 2; - default: - return -1; - } - *estr = string; - } - while (*string++); - - if (pestr) { - *estr = pestr; - return 1; - } else { - *estr = oestr; - return 0; - } - - case '[': - match = 0; - if ((negate_range = (*pattern == '^')) != 0) - pattern++; - while ((rangec = *pattern++) != '\0') { - if (rangec == ']') - break; - if (match) - continue; - if (rangec == '-' && *(pattern - 2) != '[' && - *pattern != ']') { - match = - stringc <= (u_char)*pattern && - (u_char)*(pattern - 2) <= stringc; - pattern++; - } else - match = (stringc == rangec); - } - if (rangec == 0) - return -1; - if (match == negate_range) - return 0; - *estr = string; - break; - default: - if (patternc != stringc) - return 0; - *estr = string; - break; - } - } -} diff --git a/sys/lib/libkern/rngtest.c b/sys/lib/libkern/rngtest.c deleted file mode 100644 index c20263e4d..000000000 --- a/sys/lib/libkern/rngtest.c +++ /dev/null @@ -1,281 +0,0 @@ -/* $NetBSD: rngtest.c,v 1.2 2011/11/25 12:45:00 joerg Exp $ */ - -/*- - * Copyright (c) 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. - */ - -/* fips140.c 1.5 (Qualcomm) 02/09/02 */ -/* -This software is free for commercial and non-commercial use -subject to the following conditions. - -Copyright remains vested in QUALCOMM Incorporated, and Copyright -notices in the code are not to be removed. If this package is used in -a product, QUALCOMM should be given attribution as the author this -software. This can be in the form of a textual message at program -startup or in documentation (online or textual) provided with the -package. - -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 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 QUALCOMM Incorporated. - -THIS SOFTWARE IS PROVIDED ``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 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 license and distribution terms for any publically available version -or derivative of this code cannot be changed, that is, this code cannot -simply be copied and put under another distribution license including -the GNU Public License. -*/ - -/* Run FIPS 140 statistical tests on a file */ - -/* written by Greg Rose, Copyright C 2000 QUALCOMM Incorporated */ - -/* - * Modified for in-kernel use (API adjustments, conversion from - * floating to fixed-point chi-sq computation) by Thor Lancelot - * Simon. - * - * A comment on appropriate use of this test and the infamous FIPS 140 - * "continuous output test" (COT): Both tests are very appropriate for - * software interfaces to hardware implementations, and will quickly tell - * you if any number of very bad things have happened to your RNG: perhaps - * it has come disconnected from the rest of the system, somehow, and you - * are getting only unconditioned bus noise (read: clock edges from the - * loudest thing in your system). Perhaps it has ceased to latch a shift - * register and is feeding you the same data over and over again. Perhaps - * it is not really random at all but was sold to you as such. Perhaps it - * is not actually *there* (Intel chipset RNG anyone?) but claims to be, - * and is feeding you 01010101 on every register read. - * - * However, when applied to software RNGs, the situation is quite different. - * Most software RNGs use a modern hash function or cipher as an output - * stage. The resulting bitstream assuredly *should* pass both the - * "continuous output" (no two consecutive samples identical) and - * statistical tests: if it does not, the cryptographic primitive or its - * implementation is terribly broken. - * - * There is still value to this test: it will tell you if you inadvertently - * terribly break your implementation of the software RNG. Which is a thing - * that has in fact happened from time to time, even to the careful (or - * paranoid). But it will not tell you if there is a problem with the - * _input_ to that final cryptographic primitive -- the bits that are hashed - * or the key to the cipher -- and if an adversary can find one, you're - * still toast. - * - * The situation is -- sadly -- similar with hardware RNGs that are - * certified to one of the standards such as X9.31 or SP800-90. In these - * cases the hardware vendor has hidden the actual random bitstream behind - * a hardware cipher/hash implementation that should, indeed, produce good - * quality random numbers that pass will pass this test -- whether the - * underlying bitstream is trustworthy or not. - * - * However, this test (and the COT) will still probably tell you if the - * thing fell off the bus, etc. Which is a thing that has in fact - * happened from time to time, even to the fully certified... - * - * This module does not (yet?) implement the Continuous Output Test. When - * I call that test "infamous", it's because it obviously reduces the - * backtracking resistance of any implementation that includes it -- the - * implementation has to store the entire previous RNG output in order to - * perform the required comparison; not just periodically but all the time - * when operating at all. Nonetheless, it has obvious value for - * hardware implementations where it will quickly and surely detect a - * severe failure; but as of this writing several of the latest comments - * on SP800-90 recommend removing any requirement for the COT and my - * personal tendency is to agree. It's easy to add if you really need it. - * - */ - -#include -#include -#include - -#include - -#include -__KERNEL_RCSID(0, "$NetBSD: rngtest.c,v 1.2 2011/11/25 12:45:00 joerg Exp $"); - -#ifndef _KERNEL -static inline int -printf(const char * __restrict format, ...) -{ - return 0; /* XXX no standard way to do output in libkern? */ -} -#endif - -int bitnum = 0; - -const int minrun[7] = {0, 2315, 1114, 527, 240, 103, 103}; -const int maxrun[7] = {0, 2685, 1386, 723, 384, 209, 209}; -#define LONGRUN 26 -#define MINONES 9725 -#define MAXONES 10275 -#define MINPOKE 2.16 -#define MAXPOKE 46.17 -#define PRECISION 100000 - -const int longrun = LONGRUN; -const int minones = MINONES; -const int maxones = MAXONES; -const long long minpoke = (MINPOKE * PRECISION); -const long long maxpoke = (MAXPOKE * PRECISION); - -/* Population count of 1's in a byte */ -const unsigned char Popcount[] = { - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 -}; - -/* end of run */ -static void -endrun(rngtest_t *const rc, const int last, int run) -{ - if (run >= longrun) { - printf("Kernel RNG \"%s\" long run test FAILURE: " - "Run of %d %ds found\n", rc->rt_name, run, last); - ++rc->rt_nerrs; - } - if (run > 6) - run = 6; - ++rc->rt_runs[last][run]; -} - -int -rngtest(rngtest_t *const rc) -{ - int i; - uint8_t *p; - int c; - long long X; - int last; - int run; - - /* Enforce sanity for most members of the context */ - memset(rc->rt_poker, 0, sizeof(rc->rt_poker)); - memset(rc->rt_runs, 0, sizeof(rc->rt_runs)); - rc->rt_nerrs = 0; - rc->rt_name[sizeof(rc->rt_name) - 1] = '\0'; - - /* monobit test */ - for (p = rc->rt_b, c = 0; p < &rc->rt_b[sizeof rc->rt_b]; ++p) - c += Popcount[*p]; - if (c <= minones || maxones <= c) { - printf("Kernel RNG \"%s\" monobit test FAILURE: %d ones\n", - rc->rt_name, c); - ++rc->rt_nerrs; - } - /* poker test */ - for (p = rc->rt_b; p < &rc->rt_b[sizeof rc->rt_b]; ++p) { - ++rc->rt_poker[*p & 0xF]; - ++rc->rt_poker[(*p >> 4) & 0xF]; - } - for (X = i = 0; i < 16; ++i) { - X += rc->rt_poker[i] * rc->rt_poker[i]; - } - X *= PRECISION; - X = 16 * X / 5000 - 5000 * PRECISION; - if (X <= minpoke || maxpoke <= X) { - printf("Kernel RNG \"%s\" poker test failure: " - "parameter X = %lld.%lld\n", rc->rt_name, - (X / PRECISION), (X % PRECISION)); - ++rc->rt_nerrs; - } - /* runs test */ - last = (rc->rt_b[0] >> 7) & 1; - run = 0; - for (p = rc->rt_b; p < &rc->rt_b[sizeof rc->rt_b]; ++p) { - c = *p; - for (i = 7; i >= 0; --i) { - if (((c >> i) & 1) != last) { - endrun(rc, last, run); - run = 0; - last = (c >> i) & 1; - } - ++run; - } - } - endrun(rc, last, run); - - for (run = 1; run <= 6; ++run) { - for (last = 0; last <= 1; ++last) { - if (rc->rt_runs[last][run] <= minrun[run]) { - printf("Kernel RNG \"%s\" runs test FAILURE: " - "too few runs of %d %ds (%d < %d)\n", - rc->rt_name, run, last, - rc->rt_runs[last][run], minrun[run]); - ++rc->rt_nerrs; - } else if (rc->rt_runs[last][run] >= maxrun[run]) { - printf("Kernel RNG \"%s\" runs test FAILURE: " - "too many runs of %d %ds (%d > %d)\n", - rc->rt_name, run, last, - rc->rt_runs[last][run], maxrun[run]); - ++rc->rt_nerrs; - } - } - } - memset(rc->rt_b, 0, sizeof(rc->rt_b)); - return rc->rt_nerrs; -} diff --git a/sys/lib/libkern/scanc.c b/sys/lib/libkern/scanc.c deleted file mode 100644 index 7c8ebbcba..000000000 --- a/sys/lib/libkern/scanc.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: scanc.c,v 1.8 2005/12/11 12:24:37 christos Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1989 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. - * - * @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 - */ - -#include -#include - -int -scanc(u_int size, const u_char *cp, const u_char table[], int mask) -{ - const u_char *end = &cp[size]; - - while (cp < end && (table[*cp] & mask) == 0) - cp++; - return (end - cp); -} diff --git a/sys/lib/libkern/skpc.c b/sys/lib/libkern/skpc.c deleted file mode 100644 index 36b94ab4a..000000000 --- a/sys/lib/libkern/skpc.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: skpc.c,v 1.7 2009/03/14 15:36:22 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1989 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. - * - * @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 - */ - -#include -#include - -int -skpc(int mask, size_t size, u_char *cp) -{ - u_char *end = &cp[size]; - - while (cp < end && *cp == (u_char) mask) - cp++; - return (end - cp); -} diff --git a/sys/lib/libkern/softfloat-macros.h b/sys/lib/libkern/softfloat-macros.h deleted file mode 100644 index 499a48614..000000000 --- a/sys/lib/libkern/softfloat-macros.h +++ /dev/null @@ -1,745 +0,0 @@ -/* $NetBSD: softfloat-macros.h,v 1.1 2001/04/26 03:10:47 ross Exp $ */ - -/* -=============================================================================== - -This C source fragment is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Shifts `a' right by the number of bits given in `count'. If any nonzero -bits are shifted off, they are ``jammed'' into the least significant bit of -the result by setting the least significant bit to 1. The value of `count' -can be arbitrarily large; in particular, if `count' is greater than 32, the -result will be either 0 or 1, depending on whether `a' is zero or nonzero. -The result is stored in the location pointed to by `zPtr'. -------------------------------------------------------------------------------- -*/ -INLINE void shift32RightJamming( bits32 a, int16 count, bits32 *zPtr ) -{ - bits32 z; - - if ( count == 0 ) { - z = a; - } - else if ( count < 32 ) { - z = ( a>>count ) | ( ( a<<( ( - count ) & 31 ) ) != 0 ); - } - else { - z = ( a != 0 ); - } - *zPtr = z; - -} - -/* -------------------------------------------------------------------------------- -Shifts `a' right by the number of bits given in `count'. If any nonzero -bits are shifted off, they are ``jammed'' into the least significant bit of -the result by setting the least significant bit to 1. The value of `count' -can be arbitrarily large; in particular, if `count' is greater than 64, the -result will be either 0 or 1, depending on whether `a' is zero or nonzero. -The result is stored in the location pointed to by `zPtr'. -------------------------------------------------------------------------------- -*/ -INLINE void shift64RightJamming( bits64 a, int16 count, bits64 *zPtr ) -{ - bits64 z; - - if ( count == 0 ) { - z = a; - } - else if ( count < 64 ) { - z = ( a>>count ) | ( ( a<<( ( - count ) & 63 ) ) != 0 ); - } - else { - z = ( a != 0 ); - } - *zPtr = z; - -} - -/* -------------------------------------------------------------------------------- -Shifts the 128-bit value formed by concatenating `a0' and `a1' right by 64 -_plus_ the number of bits given in `count'. The shifted result is at most -64 nonzero bits; this is stored at the location pointed to by `z0Ptr'. The -bits shifted off form a second 64-bit result as follows: The _last_ bit -shifted off is the most-significant bit of the extra result, and the other -63 bits of the extra result are all zero if and only if _all_but_the_last_ -bits shifted off were all zero. This extra result is stored in the location -pointed to by `z1Ptr'. The value of `count' can be arbitrarily large. - (This routine makes more sense if `a0' and `a1' are considered to form a -fixed-point value with binary point between `a0' and `a1'. This fixed-point -value is shifted right by the number of bits given in `count', and the -integer part of the result is returned at the location pointed to by -`z0Ptr'. The fractional part of the result may be slightly corrupted as -described above, and is returned at the location pointed to by `z1Ptr'.) -------------------------------------------------------------------------------- -*/ -INLINE void - shift64ExtraRightJamming( - bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) -{ - bits64 z0, z1; - int8 negCount = ( - count ) & 63; - - if ( count == 0 ) { - z1 = a1; - z0 = a0; - } - else if ( count < 64 ) { - z1 = ( a0<>count; - } - else { - if ( count == 64 ) { - z1 = a0 | ( a1 != 0 ); - } - else { - z1 = ( ( a0 | a1 ) != 0 ); - } - z0 = 0; - } - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the -number of bits given in `count'. Any bits shifted off are lost. The value -of `count' can be arbitrarily large; in particular, if `count' is greater -than 128, the result will be 0. The result is broken into two 64-bit pieces -which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - shift128Right( - bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) -{ - bits64 z0, z1; - int8 negCount = ( - count ) & 63; - - if ( count == 0 ) { - z1 = a1; - z0 = a0; - } - else if ( count < 64 ) { - z1 = ( a0<>count ); - z0 = a0>>count; - } - else { - z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0; - z0 = 0; - } - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the -number of bits given in `count'. If any nonzero bits are shifted off, they -are ``jammed'' into the least significant bit of the result by setting the -least significant bit to 1. The value of `count' can be arbitrarily large; -in particular, if `count' is greater than 128, the result will be either -0 or 1, depending on whether the concatenation of `a0' and `a1' is zero or -nonzero. The result is broken into two 64-bit pieces which are stored at -the locations pointed to by `z0Ptr' and `z1Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - shift128RightJamming( - bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) -{ - bits64 z0, z1; - int8 negCount = ( - count ) & 63; - - if ( count == 0 ) { - z1 = a1; - z0 = a0; - } - else if ( count < 64 ) { - z1 = ( a0<>count ) | ( ( a1<>count; - } - else { - if ( count == 64 ) { - z1 = a0 | ( a1 != 0 ); - } - else if ( count < 128 ) { - z1 = ( a0>>( count & 63 ) ) | ( ( ( a0<>count ); - z0 = a0>>count; - } - else { - if ( count == 64 ) { - z2 = a1; - z1 = a0; - } - else { - a2 |= a1; - if ( count < 128 ) { - z2 = a0<>( count & 63 ); - } - else { - z2 = ( count == 128 ) ? a0 : ( a0 != 0 ); - z1 = 0; - } - } - z0 = 0; - } - z2 |= ( a2 != 0 ); - } - *z2Ptr = z2; - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Shifts the 128-bit value formed by concatenating `a0' and `a1' left by the -number of bits given in `count'. Any bits shifted off are lost. The value -of `count' must be less than 64. The result is broken into two 64-bit -pieces which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - shortShift128Left( - bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr ) -{ - - *z1Ptr = a1<>( ( - count ) & 63 ) ); - -} - -/* -------------------------------------------------------------------------------- -Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' left -by the number of bits given in `count'. Any bits shifted off are lost. -The value of `count' must be less than 64. The result is broken into three -64-bit pieces which are stored at the locations pointed to by `z0Ptr', -`z1Ptr', and `z2Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - shortShift192Left( - bits64 a0, - bits64 a1, - bits64 a2, - int16 count, - bits64 *z0Ptr, - bits64 *z1Ptr, - bits64 *z2Ptr - ) -{ - bits64 z0, z1, z2; - int8 negCount; - - z2 = a2<>negCount; - z0 |= a1>>negCount; - } - *z2Ptr = z2; - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Adds the 128-bit value formed by concatenating `a0' and `a1' to the 128-bit -value formed by concatenating `b0' and `b1'. Addition is modulo 2^128, so -any carry out is lost. The result is broken into two 64-bit pieces which -are stored at the locations pointed to by `z0Ptr' and `z1Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - add128( - bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr ) -{ - bits64 z1; - - z1 = a1 + b1; - *z1Ptr = z1; - *z0Ptr = a0 + b0 + ( z1 < a1 ); - -} - -/* -------------------------------------------------------------------------------- -Adds the 192-bit value formed by concatenating `a0', `a1', and `a2' to the -192-bit value formed by concatenating `b0', `b1', and `b2'. Addition is -modulo 2^192, so any carry out is lost. The result is broken into three -64-bit pieces which are stored at the locations pointed to by `z0Ptr', -`z1Ptr', and `z2Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - add192( - bits64 a0, - bits64 a1, - bits64 a2, - bits64 b0, - bits64 b1, - bits64 b2, - bits64 *z0Ptr, - bits64 *z1Ptr, - bits64 *z2Ptr - ) -{ - bits64 z0, z1, z2; - int8 carry0, carry1; - - z2 = a2 + b2; - carry1 = ( z2 < a2 ); - z1 = a1 + b1; - carry0 = ( z1 < a1 ); - z0 = a0 + b0; - z1 += carry1; - z0 += ( z1 < carry1 ); - z0 += carry0; - *z2Ptr = z2; - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Subtracts the 128-bit value formed by concatenating `b0' and `b1' from the -128-bit value formed by concatenating `a0' and `a1'. Subtraction is modulo -2^128, so any borrow out (carry out) is lost. The result is broken into two -64-bit pieces which are stored at the locations pointed to by `z0Ptr' and -`z1Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - sub128( - bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr ) -{ - - *z1Ptr = a1 - b1; - *z0Ptr = a0 - b0 - ( a1 < b1 ); - -} - -/* -------------------------------------------------------------------------------- -Subtracts the 192-bit value formed by concatenating `b0', `b1', and `b2' -from the 192-bit value formed by concatenating `a0', `a1', and `a2'. -Subtraction is modulo 2^192, so any borrow out (carry out) is lost. The -result is broken into three 64-bit pieces which are stored at the locations -pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - sub192( - bits64 a0, - bits64 a1, - bits64 a2, - bits64 b0, - bits64 b1, - bits64 b2, - bits64 *z0Ptr, - bits64 *z1Ptr, - bits64 *z2Ptr - ) -{ - bits64 z0, z1, z2; - int8 borrow0, borrow1; - - z2 = a2 - b2; - borrow1 = ( a2 < b2 ); - z1 = a1 - b1; - borrow0 = ( a1 < b1 ); - z0 = a0 - b0; - z0 -= ( z1 < borrow1 ); - z1 -= borrow1; - z0 -= borrow0; - *z2Ptr = z2; - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Multiplies `a' by `b' to obtain a 128-bit product. The product is broken -into two 64-bit pieces which are stored at the locations pointed to by -`z0Ptr' and `z1Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void mul64To128( bits64 a, bits64 b, bits64 *z0Ptr, bits64 *z1Ptr ) -{ - bits32 aHigh, aLow, bHigh, bLow; - bits64 z0, zMiddleA, zMiddleB, z1; - - aLow = a; - aHigh = a>>32; - bLow = b; - bHigh = b>>32; - z1 = ( (bits64) aLow ) * bLow; - zMiddleA = ( (bits64) aLow ) * bHigh; - zMiddleB = ( (bits64) aHigh ) * bLow; - z0 = ( (bits64) aHigh ) * bHigh; - zMiddleA += zMiddleB; - z0 += ( ( (bits64) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 ); - zMiddleA <<= 32; - z1 += zMiddleA; - z0 += ( z1 < zMiddleA ); - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Multiplies the 128-bit value formed by concatenating `a0' and `a1' by -`b' to obtain a 192-bit product. The product is broken into three 64-bit -pieces which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and -`z2Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - mul128By64To192( - bits64 a0, - bits64 a1, - bits64 b, - bits64 *z0Ptr, - bits64 *z1Ptr, - bits64 *z2Ptr - ) -{ - bits64 z0, z1, z2, more1; - - mul64To128( a1, b, &z1, &z2 ); - mul64To128( a0, b, &z0, &more1 ); - add128( z0, more1, 0, z1, &z0, &z1 ); - *z2Ptr = z2; - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Multiplies the 128-bit value formed by concatenating `a0' and `a1' to the -128-bit value formed by concatenating `b0' and `b1' to obtain a 256-bit -product. The product is broken into four 64-bit pieces which are stored at -the locations pointed to by `z0Ptr', `z1Ptr', `z2Ptr', and `z3Ptr'. -------------------------------------------------------------------------------- -*/ -INLINE void - mul128To256( - bits64 a0, - bits64 a1, - bits64 b0, - bits64 b1, - bits64 *z0Ptr, - bits64 *z1Ptr, - bits64 *z2Ptr, - bits64 *z3Ptr - ) -{ - bits64 z0, z1, z2, z3; - bits64 more1, more2; - - mul64To128( a1, b1, &z2, &z3 ); - mul64To128( a1, b0, &z1, &more2 ); - add128( z1, more2, 0, z2, &z1, &z2 ); - mul64To128( a0, b0, &z0, &more1 ); - add128( z0, more1, 0, z1, &z0, &z1 ); - mul64To128( a0, b1, &more1, &more2 ); - add128( more1, more2, 0, z2, &more1, &z2 ); - add128( z0, z1, 0, more1, &z0, &z1 ); - *z3Ptr = z3; - *z2Ptr = z2; - *z1Ptr = z1; - *z0Ptr = z0; - -} - -/* -------------------------------------------------------------------------------- -Returns an approximation to the 64-bit integer quotient obtained by dividing -`b' into the 128-bit value formed by concatenating `a0' and `a1'. The -divisor `b' must be at least 2^63. If q is the exact quotient truncated -toward zero, the approximation returned lies between q and q + 2 inclusive. -If the exact quotient q is larger than 64 bits, the maximum positive 64-bit -unsigned integer is returned. -------------------------------------------------------------------------------- -*/ -static bits64 estimateDiv128To64( bits64 a0, bits64 a1, bits64 b ) -{ - bits64 b0, b1; - bits64 rem0, rem1, term0, term1; - bits64 z; - - if ( b <= a0 ) return LIT64( 0xFFFFFFFFFFFFFFFF ); - b0 = b>>32; - z = ( b0<<32 <= a0 ) ? LIT64( 0xFFFFFFFF00000000 ) : ( a0 / b0 )<<32; - mul64To128( b, z, &term0, &term1 ); - sub128( a0, a1, term0, term1, &rem0, &rem1 ); - while ( ( (sbits64) rem0 ) < 0 ) { - z -= LIT64( 0x100000000 ); - b1 = b<<32; - add128( rem0, rem1, b0, b1, &rem0, &rem1 ); - } - rem0 = ( rem0<<32 ) | ( rem1>>32 ); - z |= ( b0<<32 <= rem0 ) ? 0xFFFFFFFF : rem0 / b0; - return z; - -} - -#ifndef SOFTFLOAT_FOR_GCC /* Not used */ -/* -------------------------------------------------------------------------------- -Returns an approximation to the square root of the 32-bit significand given -by `a'. Considered as an integer, `a' must be at least 2^31. If bit 0 of -`aExp' (the least significant bit) is 1, the integer returned approximates -2^31*sqrt(`a'/2^31), where `a' is considered an integer. If bit 0 of `aExp' -is 0, the integer returned approximates 2^31*sqrt(`a'/2^30). In either -case, the approximation returned lies strictly within +/-2 of the exact -value. -------------------------------------------------------------------------------- -*/ -static bits32 estimateSqrt32( int16 aExp, bits32 a ) -{ - static const bits16 sqrtOddAdjustments[] = { - 0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0, - 0x039C, 0x0468, 0x0545, 0x0631, 0x072B, 0x0832, 0x0946, 0x0A67 - }; - static const bits16 sqrtEvenAdjustments[] = { - 0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E, - 0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002 - }; - int8 index; - bits32 z; - - index = ( a>>27 ) & 15; - if ( aExp & 1 ) { - z = 0x4000 + ( a>>17 ) - sqrtOddAdjustments[ index ]; - z = ( ( a / z )<<14 ) + ( z<<15 ); - a >>= 1; - } - else { - z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ index ]; - z = a / z + z; - z = ( 0x20000 <= z ) ? 0xFFFF8000 : ( z<<15 ); - if ( z <= a ) return (bits32) ( ( (sbits32) a )>>1 ); - } - return ( (bits32) ( ( ( (bits64) a )<<31 ) / z ) ) + ( z>>1 ); - -} -#endif - -/* -------------------------------------------------------------------------------- -Returns the number of leading 0 bits before the most-significant 1 bit of -`a'. If `a' is zero, 32 is returned. -------------------------------------------------------------------------------- -*/ -static int8 countLeadingZeros32( bits32 a ) -{ - static const int8 countLeadingZerosHigh[] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - int8 shiftCount; - - shiftCount = 0; - if ( a < 0x10000 ) { - shiftCount += 16; - a <<= 16; - } - if ( a < 0x1000000 ) { - shiftCount += 8; - a <<= 8; - } - shiftCount += countLeadingZerosHigh[ a>>24 ]; - return shiftCount; - -} - -/* -------------------------------------------------------------------------------- -Returns the number of leading 0 bits before the most-significant 1 bit of -`a'. If `a' is zero, 64 is returned. -------------------------------------------------------------------------------- -*/ -static int8 countLeadingZeros64( bits64 a ) -{ - int8 shiftCount; - - shiftCount = 0; - if ( a < ( (bits64) 1 )<<32 ) { - shiftCount += 32; - } - else { - a >>= 32; - } - shiftCount += countLeadingZeros32( a ); - return shiftCount; - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' -is equal to the 128-bit value formed by concatenating `b0' and `b1'. -Otherwise, returns 0. -------------------------------------------------------------------------------- -*/ -INLINE flag eq128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) -{ - - return ( a0 == b0 ) && ( a1 == b1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less -than or equal to the 128-bit value formed by concatenating `b0' and `b1'. -Otherwise, returns 0. -------------------------------------------------------------------------------- -*/ -INLINE flag le128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) -{ - - return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less -than the 128-bit value formed by concatenating `b0' and `b1'. Otherwise, -returns 0. -------------------------------------------------------------------------------- -*/ -INLINE flag lt128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) -{ - - return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is -not equal to the 128-bit value formed by concatenating `b0' and `b1'. -Otherwise, returns 0. -------------------------------------------------------------------------------- -*/ -INLINE flag ne128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 ) -{ - - return ( a0 != b0 ) || ( a1 != b1 ); - -} - diff --git a/sys/lib/libkern/softfloat-specialize.h b/sys/lib/libkern/softfloat-specialize.h deleted file mode 100644 index 2efb8ffa7..000000000 --- a/sys/lib/libkern/softfloat-specialize.h +++ /dev/null @@ -1,480 +0,0 @@ -/* $NetBSD: softfloat-specialize.h,v 1.2 2008/04/28 20:24:06 martin Exp $ */ - -/* This is a derivative work. */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Ross Harvey. - * - * 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. - */ - -/* -=============================================================================== - -This C source fragment is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Underflow tininess-detection mode, statically initialized to default value. -------------------------------------------------------------------------------- -*/ - -/* [ MP safe, does not change dynamically ] */ -int float_detect_tininess = float_tininess_after_rounding; - -/* -------------------------------------------------------------------------------- -Internal canonical NaN format. -------------------------------------------------------------------------------- -*/ -typedef struct { - flag sign; - bits64 high, low; -} commonNaNT; - -/* -------------------------------------------------------------------------------- -The pattern for a default generated single-precision NaN. -------------------------------------------------------------------------------- -*/ -#define float32_default_nan 0xFFC00000 - -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is a NaN; -otherwise returns 0. -------------------------------------------------------------------------------- -*/ -static flag float32_is_nan( float32 a ) -{ - - return ( 0xFF000000 < (bits32) ( a<<1 ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is a signaling -NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ -flag float32_is_signaling_nan( float32 a ) -{ - - return ( ( ( a>>22 ) & 0x1FF ) == 0x1FE ) && ( a & 0x003FFFFF ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the single-precision floating-point NaN -`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -exception is raised. -------------------------------------------------------------------------------- -*/ -static commonNaNT float32ToCommonNaN( float32 a ) -{ - commonNaNT z; - - if ( float32_is_signaling_nan( a ) ) float_raise( float_flag_invalid ); - z.sign = a>>31; - z.low = 0; - z.high = ( (bits64) a )<<41; - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the single- -precision floating-point format. -------------------------------------------------------------------------------- -*/ -static float32 commonNaNToFloat32( commonNaNT a ) -{ - - return ( ( (bits32) a.sign )<<31 ) | 0x7FC00000 | ( a.high>>41 ); - -} - -/* -------------------------------------------------------------------------------- -Takes two single-precision floating-point values `a' and `b', one of which -is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a -signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ -static float32 propagateFloat32NaN( float32 a, float32 b ) -{ - flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; - - aIsNaN = float32_is_nan( a ); - aIsSignalingNaN = float32_is_signaling_nan( a ); - bIsNaN = float32_is_nan( b ); - bIsSignalingNaN = float32_is_signaling_nan( b ); - a |= 0x00400000; - b |= 0x00400000; - if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid ); - if ( aIsSignalingNaN ) { - if ( bIsSignalingNaN ) goto returnLargerSignificand; - return bIsNaN ? b : a; - } - else if ( aIsNaN ) { - if ( bIsSignalingNaN | ! bIsNaN ) return a; - returnLargerSignificand: - if ( (bits32) ( a<<1 ) < (bits32) ( b<<1 ) ) return b; - if ( (bits32) ( b<<1 ) < (bits32) ( a<<1 ) ) return a; - return ( a < b ) ? a : b; - } - else { - return b; - } - -} - - -/* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point NaN -`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -exception is raised. -------------------------------------------------------------------------------- -*/ -static commonNaNT float64ToCommonNaN( float64 a ) -{ - commonNaNT z; - - if ( float64_is_signaling_nan( a ) ) float_raise( float_flag_invalid ); - z.sign = a>>63; - z.low = 0; - z.high = a<<12; - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the double- -precision floating-point format. -------------------------------------------------------------------------------- -*/ -static float64 commonNaNToFloat64( commonNaNT a ) -{ - - return - ( ( (bits64) a.sign )<<63 ) - | LIT64( 0x7FF8000000000000 ) - | ( a.high>>12 ); - -} - -/* -------------------------------------------------------------------------------- -Takes two double-precision floating-point values `a' and `b', one of which -is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a -signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ -static float64 propagateFloat64NaN( float64 a, float64 b ) -{ - flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; - - aIsNaN = float64_is_nan( a ); - aIsSignalingNaN = float64_is_signaling_nan( a ); - bIsNaN = float64_is_nan( b ); - bIsSignalingNaN = float64_is_signaling_nan( b ); - a |= LIT64( 0x0008000000000000 ); - b |= LIT64( 0x0008000000000000 ); - if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid ); - if ( aIsSignalingNaN ) { - if ( bIsSignalingNaN ) goto returnLargerSignificand; - return bIsNaN ? b : a; - } - else if ( aIsNaN ) { - if ( bIsSignalingNaN | ! bIsNaN ) return a; - returnLargerSignificand: - if ( (bits64) ( a<<1 ) < (bits64) ( b<<1 ) ) return b; - if ( (bits64) ( b<<1 ) < (bits64) ( a<<1 ) ) return a; - return ( a < b ) ? a : b; - } - else { - return b; - } - -} - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -The pattern for a default generated extended double-precision NaN. The -`high' and `low' values hold the most- and least-significant bits, -respectively. -------------------------------------------------------------------------------- -*/ -#define floatx80_default_nan_high 0xFFFF -#define floatx80_default_nan_low LIT64( 0xC000000000000000 ) - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is a -NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ -static flag floatx80_is_nan( floatx80 a ) -{ - - return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( a.low<<1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is a -signaling NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ -flag floatx80_is_signaling_nan( floatx80 a ) -{ - bits64 aLow; - - aLow = a.low & ~ LIT64( 0x4000000000000000 ); - return - ( ( a.high & 0x7FFF ) == 0x7FFF ) - && (bits64) ( aLow<<1 ) - && ( a.low == aLow ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the extended double-precision floating- -point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, the -invalid exception is raised. -------------------------------------------------------------------------------- -*/ -static commonNaNT floatx80ToCommonNaN( floatx80 a ) -{ - commonNaNT z; - - if ( floatx80_is_signaling_nan( a ) ) float_raise( float_flag_invalid ); - z.sign = a.high>>15; - z.low = 0; - z.high = a.low<<1; - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the extended -double-precision floating-point format. -------------------------------------------------------------------------------- -*/ -static floatx80 commonNaNToFloatx80( commonNaNT a ) -{ - floatx80 z; - - z.low = LIT64( 0xC000000000000000 ) | ( a.high>>1 ); - z.high = ( ( (bits16) a.sign )<<15 ) | 0x7FFF; - return z; - -} - -/* -------------------------------------------------------------------------------- -Takes two extended double-precision floating-point values `a' and `b', one -of which is a NaN, and returns the appropriate NaN result. If either `a' or -`b' is a signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ -static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b ) -{ - flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; - - aIsNaN = floatx80_is_nan( a ); - aIsSignalingNaN = floatx80_is_signaling_nan( a ); - bIsNaN = floatx80_is_nan( b ); - bIsSignalingNaN = floatx80_is_signaling_nan( b ); - a.low |= LIT64( 0xC000000000000000 ); - b.low |= LIT64( 0xC000000000000000 ); - if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid ); - if ( aIsSignalingNaN ) { - if ( bIsSignalingNaN ) goto returnLargerSignificand; - return bIsNaN ? b : a; - } - else if ( aIsNaN ) { - if ( bIsSignalingNaN | ! bIsNaN ) return a; - returnLargerSignificand: - if ( a.low < b.low ) return b; - if ( b.low < a.low ) return a; - return ( a.high < b.high ) ? a : b; - } - else { - return b; - } - -} - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -The pattern for a default generated quadruple-precision NaN. The `high' and -`low' values hold the most- and least-significant bits, respectively. -------------------------------------------------------------------------------- -*/ -#define float128_default_nan_high LIT64( 0xFFFF800000000000 ) -#define float128_default_nan_low LIT64( 0x0000000000000000 ) - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is a NaN; -otherwise returns 0. -------------------------------------------------------------------------------- -*/ -flag float128_is_nan( float128 a ) -{ - - return - ( LIT64( 0xFFFE000000000000 ) <= (bits64) ( a.high<<1 ) ) - && ( a.low || ( a.high & LIT64( 0x0000FFFFFFFFFFFF ) ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is a -signaling NaN; otherwise returns 0. -------------------------------------------------------------------------------- -*/ -flag float128_is_signaling_nan( float128 a ) -{ - - return - ( ( ( a.high>>47 ) & 0xFFFF ) == 0xFFFE ) - && ( a.low || ( a.high & LIT64( 0x00007FFFFFFFFFFF ) ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the quadruple-precision floating-point NaN -`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -exception is raised. -------------------------------------------------------------------------------- -*/ -static commonNaNT float128ToCommonNaN( float128 a ) -{ - commonNaNT z; - - if ( float128_is_signaling_nan( a ) ) float_raise( float_flag_invalid ); - z.sign = a.high>>63; - shortShift128Left( a.high, a.low, 16, &z.high, &z.low ); - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the canonical NaN `a' to the quadruple- -precision floating-point format. -------------------------------------------------------------------------------- -*/ -static float128 commonNaNToFloat128( commonNaNT a ) -{ - float128 z; - - shift128Right( a.high, a.low, 16, &z.high, &z.low ); - z.high |= ( ( (bits64) a.sign )<<63 ) | LIT64( 0x7FFF800000000000 ); - return z; - -} - -/* -------------------------------------------------------------------------------- -Takes two quadruple-precision floating-point values `a' and `b', one of -which is a NaN, and returns the appropriate NaN result. If either `a' or -`b' is a signaling NaN, the invalid exception is raised. -------------------------------------------------------------------------------- -*/ -static float128 propagateFloat128NaN( float128 a, float128 b ) -{ - flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN; - - aIsNaN = float128_is_nan( a ); - aIsSignalingNaN = float128_is_signaling_nan( a ); - bIsNaN = float128_is_nan( b ); - bIsSignalingNaN = float128_is_signaling_nan( b ); - a.high |= LIT64( 0x0000800000000000 ); - b.high |= LIT64( 0x0000800000000000 ); - if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid ); - if ( aIsSignalingNaN ) { - if ( bIsSignalingNaN ) goto returnLargerSignificand; - return bIsNaN ? b : a; - } - else if ( aIsNaN ) { - if ( bIsSignalingNaN | ! bIsNaN ) return a; - returnLargerSignificand: - if ( lt128( a.high<<1, a.low, b.high<<1, b.low ) ) return b; - if ( lt128( b.high<<1, b.low, a.high<<1, a.low ) ) return a; - return ( a.high < b.high ) ? a : b; - } - else { - return b; - } - -} - -#endif - diff --git a/sys/lib/libkern/softfloat.c b/sys/lib/libkern/softfloat.c deleted file mode 100644 index 43f64f385..000000000 --- a/sys/lib/libkern/softfloat.c +++ /dev/null @@ -1,5502 +0,0 @@ -/* $NetBSD: softfloat.c,v 1.4 2005/12/11 12:24:37 christos Exp $ */ - -/* - * This version hacked for use with gcc -msoft-float by bjh21. - * (Mostly a case of #ifdefing out things GCC doesn't need or provides - * itself). - */ - -/* - * Things you may want to define: - * - * SOFTFLOAT_FOR_GCC - build only those functions necessary for GCC (with - * -msoft-float) to work. Include "softfloat-for-gcc.h" to get them - * properly renamed. - */ - -/* -=============================================================================== - -This C source file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* If you need this in a boot program, you have bigger problems... */ -#ifndef _STANDALONE - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: softfloat.c,v 1.4 2005/12/11 12:24:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifdef SOFTFLOAT_FOR_GCC -#include "softfloat-for-gcc.h" -#endif - -#include "milieu.h" -#include "softfloat.h" - -/* - * Conversions between floats as stored in memory and floats as - * SoftFloat uses them - */ -#ifndef FLOAT64_DEMANGLE -#define FLOAT64_DEMANGLE(a) (a) -#endif -#ifndef FLOAT64_MANGLE -#define FLOAT64_MANGLE(a) (a) -#endif - -/* -------------------------------------------------------------------------------- -Floating-point rounding mode, extended double-precision rounding precision, -and exception flags. -------------------------------------------------------------------------------- -*/ - -/* - * XXX: This may cause options-MULTIPROCESSOR or thread problems someday. - * Right now, it does not. I've removed all other dynamic global - * variables. [ross] - */ -#ifdef FLOATX80 -int8 floatx80_rounding_precision = 80; -#endif - -/* -------------------------------------------------------------------------------- -Primitive arithmetic functions, including multi-word arithmetic, and -division and square root approximations. (Can be specialized to target if -desired.) -------------------------------------------------------------------------------- -*/ -#include "softfloat-macros.h" - -/* -------------------------------------------------------------------------------- -Functions and definitions to determine: (1) whether tininess for underflow -is detected before or after rounding by default, (2) what (if anything) -happens when exceptions are raised, (3) how signaling NaNs are distinguished -from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs -are propagated from function inputs to output. These details are target- -specific. -------------------------------------------------------------------------------- -*/ -#include "softfloat-specialize.h" - -#ifndef SOFTFLOAT_FOR_GCC /* Not used */ -/* -------------------------------------------------------------------------------- -Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 -and 7, and returns the properly rounded 32-bit integer corresponding to the -input. If `zSign' is 1, the input is negated before being converted to an -integer. Bit 63 of `absZ' must be zero. Ordinarily, the fixed-point input -is simply rounded to an integer, with the inexact exception raised if the -input cannot be represented exactly as an integer. However, if the fixed- -point input is too large, the invalid exception is raised and the largest -positive or negative integer is returned. -------------------------------------------------------------------------------- -*/ -static int32 roundAndPackInt32( flag zSign, bits64 absZ ) -{ - int8 roundingMode; - flag roundNearestEven; - int8 roundIncrement, roundBits; - int32 z; - - roundingMode = float_rounding_mode(); - roundNearestEven = ( roundingMode == float_round_nearest_even ); - roundIncrement = 0x40; - if ( ! roundNearestEven ) { - if ( roundingMode == float_round_to_zero ) { - roundIncrement = 0; - } - else { - roundIncrement = 0x7F; - if ( zSign ) { - if ( roundingMode == float_round_up ) roundIncrement = 0; - } - else { - if ( roundingMode == float_round_down ) roundIncrement = 0; - } - } - } - roundBits = absZ & 0x7F; - absZ = ( absZ + roundIncrement )>>7; - absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven ); - z = absZ; - if ( zSign ) z = - z; - if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) { - float_raise( float_flag_invalid ); - return zSign ? (sbits32) 0x80000000 : 0x7FFFFFFF; - } - if ( roundBits ) float_set_inexact(); - return z; - -} - -/* -------------------------------------------------------------------------------- -Takes the 128-bit fixed-point value formed by concatenating `absZ0' and -`absZ1', with binary point between bits 63 and 64 (between the input words), -and returns the properly rounded 64-bit integer corresponding to the input. -If `zSign' is 1, the input is negated before being converted to an integer. -Ordinarily, the fixed-point input is simply rounded to an integer, with -the inexact exception raised if the input cannot be represented exactly as -an integer. However, if the fixed-point input is too large, the invalid -exception is raised and the largest positive or negative integer is -returned. -------------------------------------------------------------------------------- -*/ -static int64 roundAndPackInt64( flag zSign, bits64 absZ0, bits64 absZ1 ) -{ - int8 roundingMode; - flag roundNearestEven, increment; - int64 z; - - roundingMode = float_rounding_mode(); - roundNearestEven = ( roundingMode == float_round_nearest_even ); - increment = ( (sbits64) absZ1 < 0 ); - if ( ! roundNearestEven ) { - if ( roundingMode == float_round_to_zero ) { - increment = 0; - } - else { - if ( zSign ) { - increment = ( roundingMode == float_round_down ) && absZ1; - } - else { - increment = ( roundingMode == float_round_up ) && absZ1; - } - } - } - if ( increment ) { - ++absZ0; - if ( absZ0 == 0 ) goto overflow; - absZ0 &= ~ ( ( (bits64) ( absZ1<<1 ) == 0 ) & roundNearestEven ); - } - z = absZ0; - if ( zSign ) z = - z; - if ( z && ( ( z < 0 ) ^ zSign ) ) { - overflow: - float_raise( float_flag_invalid ); - return - zSign ? (sbits64) LIT64( 0x8000000000000000 ) - : LIT64( 0x7FFFFFFFFFFFFFFF ); - } - if ( absZ1 ) float_set_inexact(); - return z; - -} -#endif - -/* -------------------------------------------------------------------------------- -Returns the fraction bits of the single-precision floating-point value `a'. -------------------------------------------------------------------------------- -*/ -INLINE bits32 extractFloat32Frac( float32 a ) -{ - - return a & 0x007FFFFF; - -} - -/* -------------------------------------------------------------------------------- -Returns the exponent bits of the single-precision floating-point value `a'. -------------------------------------------------------------------------------- -*/ -INLINE int16 extractFloat32Exp( float32 a ) -{ - - return ( a>>23 ) & 0xFF; - -} - -/* -------------------------------------------------------------------------------- -Returns the sign bit of the single-precision floating-point value `a'. -------------------------------------------------------------------------------- -*/ -INLINE flag extractFloat32Sign( float32 a ) -{ - - return a>>31; - -} - -/* -------------------------------------------------------------------------------- -Normalizes the subnormal single-precision floating-point value represented -by the denormalized significand `aSig'. The normalized exponent and -significand are stored at the locations pointed to by `zExpPtr' and -`zSigPtr', respectively. -------------------------------------------------------------------------------- -*/ -static void - normalizeFloat32Subnormal( bits32 aSig, int16 *zExpPtr, bits32 *zSigPtr ) -{ - int8 shiftCount; - - shiftCount = countLeadingZeros32( aSig ) - 8; - *zSigPtr = aSig<>7; - zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven ); - if ( zSig == 0 ) zExp = 0; - return packFloat32( zSign, zExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Takes an abstract floating-point value having sign `zSign', exponent `zExp', -and significand `zSig', and returns the proper single-precision floating- -point value corresponding to the abstract input. This routine is just like -`roundAndPackFloat32' except that `zSig' does not have to be normalized. -Bit 31 of `zSig' must be zero, and `zExp' must be 1 less than the ``true'' -floating-point exponent. -------------------------------------------------------------------------------- -*/ -static float32 - normalizeRoundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig ) -{ - int8 shiftCount; - - shiftCount = countLeadingZeros32( zSig ) - 1; - return roundAndPackFloat32( zSign, zExp - shiftCount, zSig<>52 ) & 0x7FF; - -} - -/* -------------------------------------------------------------------------------- -Returns the sign bit of the double-precision floating-point value `a'. -------------------------------------------------------------------------------- -*/ -INLINE flag extractFloat64Sign( float64 a ) -{ - - return FLOAT64_DEMANGLE(a)>>63; - -} - -/* -------------------------------------------------------------------------------- -Normalizes the subnormal double-precision floating-point value represented -by the denormalized significand `aSig'. The normalized exponent and -significand are stored at the locations pointed to by `zExpPtr' and -`zSigPtr', respectively. -------------------------------------------------------------------------------- -*/ -static void - normalizeFloat64Subnormal( bits64 aSig, int16 *zExpPtr, bits64 *zSigPtr ) -{ - int8 shiftCount; - - shiftCount = countLeadingZeros64( aSig ) - 11; - *zSigPtr = aSig<>10; - zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven ); - if ( zSig == 0 ) zExp = 0; - return packFloat64( zSign, zExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Takes an abstract floating-point value having sign `zSign', exponent `zExp', -and significand `zSig', and returns the proper double-precision floating- -point value corresponding to the abstract input. This routine is just like -`roundAndPackFloat64' except that `zSig' does not have to be normalized. -Bit 63 of `zSig' must be zero, and `zExp' must be 1 less than the ``true'' -floating-point exponent. -------------------------------------------------------------------------------- -*/ -static float64 - normalizeRoundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig ) -{ - int8 shiftCount; - - shiftCount = countLeadingZeros64( zSig ) - 1; - return roundAndPackFloat64( zSign, zExp - shiftCount, zSig<>15; - -} - -/* -------------------------------------------------------------------------------- -Normalizes the subnormal extended double-precision floating-point value -represented by the denormalized significand `aSig'. The normalized exponent -and significand are stored at the locations pointed to by `zExpPtr' and -`zSigPtr', respectively. -------------------------------------------------------------------------------- -*/ -static void - normalizeFloatx80Subnormal( bits64 aSig, int32 *zExpPtr, bits64 *zSigPtr ) -{ - int8 shiftCount; - - shiftCount = countLeadingZeros64( aSig ); - *zSigPtr = aSig<>48 ) & 0x7FFF; - -} - -/* -------------------------------------------------------------------------------- -Returns the sign bit of the quadruple-precision floating-point value `a'. -------------------------------------------------------------------------------- -*/ -INLINE flag extractFloat128Sign( float128 a ) -{ - - return a.high>>63; - -} - -/* -------------------------------------------------------------------------------- -Normalizes the subnormal quadruple-precision floating-point value -represented by the denormalized significand formed by the concatenation of -`aSig0' and `aSig1'. The normalized exponent is stored at the location -pointed to by `zExpPtr'. The most significant 49 bits of the normalized -significand are stored at the location pointed to by `zSig0Ptr', and the -least significant 64 bits of the normalized significand are stored at the -location pointed to by `zSig1Ptr'. -------------------------------------------------------------------------------- -*/ -static void - normalizeFloat128Subnormal( - bits64 aSig0, - bits64 aSig1, - int32 *zExpPtr, - bits64 *zSig0Ptr, - bits64 *zSig1Ptr - ) -{ - int8 shiftCount; - - if ( aSig0 == 0 ) { - shiftCount = countLeadingZeros64( aSig1 ) - 15; - if ( shiftCount < 0 ) { - *zSig0Ptr = aSig1>>( - shiftCount ); - *zSig1Ptr = aSig1<<( shiftCount & 63 ); - } - else { - *zSig0Ptr = aSig1<>( - shiftCount ); - if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) { - float_set_inexact(); - } - if ( aSign ) z = - z; - return z; - -} - -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -/* -------------------------------------------------------------------------------- -Returns the result of converting the single-precision floating-point value -`a' to the 64-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic---which means in particular that the conversion is rounded -according to the current rounding mode. If `a' is a NaN, the largest -positive integer is returned. Otherwise, if the conversion overflows, the -largest integer with the same sign as `a' is returned. -------------------------------------------------------------------------------- -*/ -int64 float32_to_int64( float32 a ) -{ - flag aSign; - int16 aExp, shiftCount; - bits32 aSig; - bits64 aSig64, aSigExtra; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - shiftCount = 0xBE - aExp; - if ( shiftCount < 0 ) { - float_raise( float_flag_invalid ); - if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) { - return LIT64( 0x7FFFFFFFFFFFFFFF ); - } - return (sbits64) LIT64( 0x8000000000000000 ); - } - if ( aExp ) aSig |= 0x00800000; - aSig64 = aSig; - aSig64 <<= 40; - shift64ExtraRightJamming( aSig64, 0, shiftCount, &aSig64, &aSigExtra ); - return roundAndPackInt64( aSign, aSig64, aSigExtra ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the single-precision floating-point value -`a' to the 64-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic, except that the conversion is always rounded toward zero. If -`a' is a NaN, the largest positive integer is returned. Otherwise, if the -conversion overflows, the largest integer with the same sign as `a' is -returned. -------------------------------------------------------------------------------- -*/ -int64 float32_to_int64_round_to_zero( float32 a ) -{ - flag aSign; - int16 aExp, shiftCount; - bits32 aSig; - bits64 aSig64; - int64 z; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - shiftCount = aExp - 0xBE; - if ( 0 <= shiftCount ) { - if ( a != 0xDF000000 ) { - float_raise( float_flag_invalid ); - if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) { - return LIT64( 0x7FFFFFFFFFFFFFFF ); - } - } - return (sbits64) LIT64( 0x8000000000000000 ); - } - else if ( aExp <= 0x7E ) { - if ( aExp | aSig ) float_set_inexact(); - return 0; - } - aSig64 = aSig | 0x00800000; - aSig64 <<= 40; - z = aSig64>>( - shiftCount ); - if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) { - float_set_inexact(); - } - if ( aSign ) z = - z; - return z; - -} -#endif /* !SOFTFLOAT_FOR_GCC */ - -/* -------------------------------------------------------------------------------- -Returns the result of converting the single-precision floating-point value -`a' to the double-precision floating-point format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float32_to_float64( float32 a ) -{ - flag aSign; - int16 aExp; - bits32 aSig; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - if ( aExp == 0xFF ) { - if ( aSig ) return commonNaNToFloat64( float32ToCommonNaN( a ) ); - return packFloat64( aSign, 0x7FF, 0 ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat64( aSign, 0, 0 ); - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - --aExp; - } - return packFloat64( aSign, aExp + 0x380, ( (bits64) aSig )<<29 ); - -} - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the single-precision floating-point value -`a' to the extended double-precision floating-point format. The conversion -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 float32_to_floatx80( float32 a ) -{ - flag aSign; - int16 aExp; - bits32 aSig; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - if ( aExp == 0xFF ) { - if ( aSig ) return commonNaNToFloatx80( float32ToCommonNaN( a ) ); - return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 ); - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - } - aSig |= 0x00800000; - return packFloatx80( aSign, aExp + 0x3F80, ( (bits64) aSig )<<40 ); - -} - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the single-precision floating-point value -`a' to the double-precision floating-point format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float32_to_float128( float32 a ) -{ - flag aSign; - int16 aExp; - bits32 aSig; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - if ( aExp == 0xFF ) { - if ( aSig ) return commonNaNToFloat128( float32ToCommonNaN( a ) ); - return packFloat128( aSign, 0x7FFF, 0, 0 ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat128( aSign, 0, 0, 0 ); - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - --aExp; - } - return packFloat128( aSign, aExp + 0x3F80, ( (bits64) aSig )<<25, 0 ); - -} - -#endif - -#ifndef SOFTFLOAT_FOR_GCC /* Not needed */ -/* -------------------------------------------------------------------------------- -Rounds the single-precision floating-point value `a' to an integer, and -returns the result as a single-precision floating-point value. The -operation is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 a ) -{ - flag aSign; - int16 aExp; - bits32 lastBitMask, roundBitsMask; - int8 roundingMode; - float32 z; - - aExp = extractFloat32Exp( a ); - if ( 0x96 <= aExp ) { - if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) { - return propagateFloat32NaN( a, a ); - } - return a; - } - if ( aExp <= 0x7E ) { - if ( (bits32) ( a<<1 ) == 0 ) return a; - float_set_inexact(); - aSign = extractFloat32Sign( a ); - switch ( float_rounding_mode() ) { - case float_round_nearest_even: - if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) { - return packFloat32( aSign, 0x7F, 0 ); - } - break; - case float_round_down: - return aSign ? 0xBF800000 : 0; - case float_round_up: - return aSign ? 0x80000000 : 0x3F800000; - } - return packFloat32( aSign, 0, 0 ); - } - lastBitMask = 1; - lastBitMask <<= 0x96 - aExp; - roundBitsMask = lastBitMask - 1; - z = a; - roundingMode = float_rounding_mode(); - if ( roundingMode == float_round_nearest_even ) { - z += lastBitMask>>1; - if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask; - } - else if ( roundingMode != float_round_to_zero ) { - if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) { - z += roundBitsMask; - } - } - z &= ~ roundBitsMask; - if ( z != a ) float_set_inexact(); - return z; - -} -#endif /* !SOFTFLOAT_FOR_GCC */ - -/* -------------------------------------------------------------------------------- -Returns the result of adding the absolute values of the single-precision -floating-point values `a' and `b'. If `zSign' is 1, the sum is negated -before being returned. `zSign' is ignored if the result is a NaN. -The addition is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static float32 addFloat32Sigs( float32 a, float32 b, flag zSign ) -{ - int16 aExp, bExp, zExp; - bits32 aSig, bSig, zSig; - int16 expDiff; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - bSig = extractFloat32Frac( b ); - bExp = extractFloat32Exp( b ); - expDiff = aExp - bExp; - aSig <<= 6; - bSig <<= 6; - if ( 0 < expDiff ) { - if ( aExp == 0xFF ) { - if ( aSig ) return propagateFloat32NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - --expDiff; - } - else { - bSig |= 0x20000000; - } - shift32RightJamming( bSig, expDiff, &bSig ); - zExp = aExp; - } - else if ( expDiff < 0 ) { - if ( bExp == 0xFF ) { - if ( bSig ) return propagateFloat32NaN( a, b ); - return packFloat32( zSign, 0xFF, 0 ); - } - if ( aExp == 0 ) { - ++expDiff; - } - else { - aSig |= 0x20000000; - } - shift32RightJamming( aSig, - expDiff, &aSig ); - zExp = bExp; - } - else { - if ( aExp == 0xFF ) { - if ( aSig | bSig ) return propagateFloat32NaN( a, b ); - return a; - } - if ( aExp == 0 ) return packFloat32( zSign, 0, ( aSig + bSig )>>6 ); - zSig = 0x40000000 + aSig + bSig; - zExp = aExp; - goto roundAndPack; - } - aSig |= 0x20000000; - zSig = ( aSig + bSig )<<1; - --zExp; - if ( (sbits32) zSig < 0 ) { - zSig = aSig + bSig; - ++zExp; - } - roundAndPack: - return roundAndPackFloat32( zSign, zExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the absolute values of the single- -precision floating-point values `a' and `b'. If `zSign' is 1, the -difference is negated before being returned. `zSign' is ignored if the -result is a NaN. The subtraction is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static float32 subFloat32Sigs( float32 a, float32 b, flag zSign ) -{ - int16 aExp, bExp, zExp; - bits32 aSig, bSig, zSig; - int16 expDiff; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - bSig = extractFloat32Frac( b ); - bExp = extractFloat32Exp( b ); - expDiff = aExp - bExp; - aSig <<= 7; - bSig <<= 7; - if ( 0 < expDiff ) goto aExpBigger; - if ( expDiff < 0 ) goto bExpBigger; - if ( aExp == 0xFF ) { - if ( aSig | bSig ) return propagateFloat32NaN( a, b ); - float_raise( float_flag_invalid ); - return float32_default_nan; - } - if ( aExp == 0 ) { - aExp = 1; - bExp = 1; - } - if ( bSig < aSig ) goto aBigger; - if ( aSig < bSig ) goto bBigger; - return packFloat32( float_rounding_mode() == float_round_down, 0, 0 ); - bExpBigger: - if ( bExp == 0xFF ) { - if ( bSig ) return propagateFloat32NaN( a, b ); - return packFloat32( zSign ^ 1, 0xFF, 0 ); - } - if ( aExp == 0 ) { - ++expDiff; - } - else { - aSig |= 0x40000000; - } - shift32RightJamming( aSig, - expDiff, &aSig ); - bSig |= 0x40000000; - bBigger: - zSig = bSig - aSig; - zExp = bExp; - zSign ^= 1; - goto normalizeRoundAndPack; - aExpBigger: - if ( aExp == 0xFF ) { - if ( aSig ) return propagateFloat32NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - --expDiff; - } - else { - bSig |= 0x40000000; - } - shift32RightJamming( bSig, expDiff, &bSig ); - aSig |= 0x40000000; - aBigger: - zSig = aSig - bSig; - zExp = aExp; - normalizeRoundAndPack: - --zExp; - return normalizeRoundAndPackFloat32( zSign, zExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of adding the single-precision floating-point values `a' -and `b'. The operation is performed according to the IEC/IEEE Standard for -Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float32_add( float32 a, float32 b ) -{ - flag aSign, bSign; - - aSign = extractFloat32Sign( a ); - bSign = extractFloat32Sign( b ); - if ( aSign == bSign ) { - return addFloat32Sigs( a, b, aSign ); - } - else { - return subFloat32Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the single-precision floating-point values -`a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float32_sub( float32 a, float32 b ) -{ - flag aSign, bSign; - - aSign = extractFloat32Sign( a ); - bSign = extractFloat32Sign( b ); - if ( aSign == bSign ) { - return subFloat32Sigs( a, b, aSign ); - } - else { - return addFloat32Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of multiplying the single-precision floating-point values -`a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float32_mul( float32 a, float32 b ) -{ - flag aSign, bSign, zSign; - int16 aExp, bExp, zExp; - bits32 aSig, bSig; - bits64 zSig64; - bits32 zSig; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - bSig = extractFloat32Frac( b ); - bExp = extractFloat32Exp( b ); - bSign = extractFloat32Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0xFF ) { - if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) { - return propagateFloat32NaN( a, b ); - } - if ( ( bExp | bSig ) == 0 ) { - float_raise( float_flag_invalid ); - return float32_default_nan; - } - return packFloat32( zSign, 0xFF, 0 ); - } - if ( bExp == 0xFF ) { - if ( bSig ) return propagateFloat32NaN( a, b ); - if ( ( aExp | aSig ) == 0 ) { - float_raise( float_flag_invalid ); - return float32_default_nan; - } - return packFloat32( zSign, 0xFF, 0 ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat32( zSign, 0, 0 ); - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - } - if ( bExp == 0 ) { - if ( bSig == 0 ) return packFloat32( zSign, 0, 0 ); - normalizeFloat32Subnormal( bSig, &bExp, &bSig ); - } - zExp = aExp + bExp - 0x7F; - aSig = ( aSig | 0x00800000 )<<7; - bSig = ( bSig | 0x00800000 )<<8; - shift64RightJamming( ( (bits64) aSig ) * bSig, 32, &zSig64 ); - zSig = zSig64; - if ( 0 <= (sbits32) ( zSig<<1 ) ) { - zSig <<= 1; - --zExp; - } - return roundAndPackFloat32( zSign, zExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of dividing the single-precision floating-point value `a' -by the corresponding value `b'. The operation is performed according to the -IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float32_div( float32 a, float32 b ) -{ - flag aSign, bSign, zSign; - int16 aExp, bExp, zExp; - bits32 aSig, bSig, zSig; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - bSig = extractFloat32Frac( b ); - bExp = extractFloat32Exp( b ); - bSign = extractFloat32Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0xFF ) { - if ( aSig ) return propagateFloat32NaN( a, b ); - if ( bExp == 0xFF ) { - if ( bSig ) return propagateFloat32NaN( a, b ); - float_raise( float_flag_invalid ); - return float32_default_nan; - } - return packFloat32( zSign, 0xFF, 0 ); - } - if ( bExp == 0xFF ) { - if ( bSig ) return propagateFloat32NaN( a, b ); - return packFloat32( zSign, 0, 0 ); - } - if ( bExp == 0 ) { - if ( bSig == 0 ) { - if ( ( aExp | aSig ) == 0 ) { - float_raise( float_flag_invalid ); - return float32_default_nan; - } - float_raise( float_flag_divbyzero ); - return packFloat32( zSign, 0xFF, 0 ); - } - normalizeFloat32Subnormal( bSig, &bExp, &bSig ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat32( zSign, 0, 0 ); - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - } - zExp = aExp - bExp + 0x7D; - aSig = ( aSig | 0x00800000 )<<7; - bSig = ( bSig | 0x00800000 )<<8; - if ( bSig <= ( aSig + aSig ) ) { - aSig >>= 1; - ++zExp; - } - zSig = ( ( (bits64) aSig )<<32 ) / bSig; - if ( ( zSig & 0x3F ) == 0 ) { - zSig |= ( (bits64) bSig * zSig != ( (bits64) aSig )<<32 ); - } - return roundAndPackFloat32( zSign, zExp, zSig ); - -} - -#ifndef SOFTFLOAT_FOR_GCC /* Not needed */ -/* -------------------------------------------------------------------------------- -Returns the remainder of the single-precision floating-point value `a' -with respect to the corresponding value `b'. The operation is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float32_rem( float32 a, float32 b ) -{ - flag aSign, bSign, zSign; - int16 aExp, bExp, expDiff; - bits32 aSig, bSig; - bits32 q; - bits64 aSig64, bSig64, q64; - bits32 alternateASig; - sbits32 sigMean; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - bSig = extractFloat32Frac( b ); - bExp = extractFloat32Exp( b ); - bSign = extractFloat32Sign( b ); - if ( aExp == 0xFF ) { - if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) { - return propagateFloat32NaN( a, b ); - } - float_raise( float_flag_invalid ); - return float32_default_nan; - } - if ( bExp == 0xFF ) { - if ( bSig ) return propagateFloat32NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - if ( bSig == 0 ) { - float_raise( float_flag_invalid ); - return float32_default_nan; - } - normalizeFloat32Subnormal( bSig, &bExp, &bSig ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return a; - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - } - expDiff = aExp - bExp; - aSig |= 0x00800000; - bSig |= 0x00800000; - if ( expDiff < 32 ) { - aSig <<= 8; - bSig <<= 8; - if ( expDiff < 0 ) { - if ( expDiff < -1 ) return a; - aSig >>= 1; - } - q = ( bSig <= aSig ); - if ( q ) aSig -= bSig; - if ( 0 < expDiff ) { - q = ( ( (bits64) aSig )<<32 ) / bSig; - q >>= 32 - expDiff; - bSig >>= 2; - aSig = ( ( aSig>>1 )<<( expDiff - 1 ) ) - bSig * q; - } - else { - aSig >>= 2; - bSig >>= 2; - } - } - else { - if ( bSig <= aSig ) aSig -= bSig; - aSig64 = ( (bits64) aSig )<<40; - bSig64 = ( (bits64) bSig )<<40; - expDiff -= 64; - while ( 0 < expDiff ) { - q64 = estimateDiv128To64( aSig64, 0, bSig64 ); - q64 = ( 2 < q64 ) ? q64 - 2 : 0; - aSig64 = - ( ( bSig * q64 )<<38 ); - expDiff -= 62; - } - expDiff += 64; - q64 = estimateDiv128To64( aSig64, 0, bSig64 ); - q64 = ( 2 < q64 ) ? q64 - 2 : 0; - q = q64>>( 64 - expDiff ); - bSig <<= 6; - aSig = ( ( aSig64>>33 )<<( expDiff - 1 ) ) - bSig * q; - } - do { - alternateASig = aSig; - ++q; - aSig -= bSig; - } while ( 0 <= (sbits32) aSig ); - sigMean = aSig + alternateASig; - if ( ( sigMean < 0 ) || ( ( sigMean == 0 ) && ( q & 1 ) ) ) { - aSig = alternateASig; - } - zSign = ( (sbits32) aSig < 0 ); - if ( zSign ) aSig = - aSig; - return normalizeRoundAndPackFloat32( aSign ^ zSign, bExp, aSig ); - -} -#endif /* !SOFTFLOAT_FOR_GCC */ - -#ifndef SOFTFLOAT_FOR_GCC /* Not needed */ -/* -------------------------------------------------------------------------------- -Returns the square root of the single-precision floating-point value `a'. -The operation is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float32_sqrt( float32 a ) -{ - flag aSign; - int16 aExp, zExp; - bits32 aSig, zSig; - bits64 rem, term; - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - if ( aExp == 0xFF ) { - if ( aSig ) return propagateFloat32NaN( a, 0 ); - if ( ! aSign ) return a; - float_raise( float_flag_invalid ); - return float32_default_nan; - } - if ( aSign ) { - if ( ( aExp | aSig ) == 0 ) return a; - float_raise( float_flag_invalid ); - return float32_default_nan; - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return 0; - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - } - zExp = ( ( aExp - 0x7F )>>1 ) + 0x7E; - aSig = ( aSig | 0x00800000 )<<8; - zSig = estimateSqrt32( aExp, aSig ) + 2; - if ( ( zSig & 0x7F ) <= 5 ) { - if ( zSig < 2 ) { - zSig = 0x7FFFFFFF; - goto roundAndPack; - } - aSig >>= aExp & 1; - term = ( (bits64) zSig ) * zSig; - rem = ( ( (bits64) aSig )<<32 ) - term; - while ( (sbits64) rem < 0 ) { - --zSig; - rem += ( ( (bits64) zSig )<<1 ) | 1; - } - zSig |= ( rem != 0 ); - } - shift32RightJamming( zSig, 1, &zSig ); - roundAndPack: - return roundAndPackFloat32( 0, zExp, zSig ); - -} -#endif /* !SOFTFLOAT_FOR_GCC */ - -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is equal to -the corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float32_eq( float32 a, float32 b ) -{ - - if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) - || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) - ) { - if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - return ( a == b ) || ( (bits32) ( ( a | b )<<1 ) == 0 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is less than -or equal to the corresponding value `b', and 0 otherwise. The comparison -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float32_le( float32 a, float32 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) - || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloat32Sign( a ); - bSign = extractFloat32Sign( b ); - if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 ); - return ( a == b ) || ( aSign ^ ( a < b ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is less than -the corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float32_lt( float32 a, float32 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) - || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloat32Sign( a ); - bSign = extractFloat32Sign( b ); - if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 ); - return ( a != b ) && ( aSign ^ ( a < b ) ); - -} - -#ifndef SOFTFLOAT_FOR_GCC /* Not needed */ -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is equal to -the corresponding value `b', and 0 otherwise. The invalid exception is -raised if either operand is a NaN. Otherwise, the comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float32_eq_signaling( float32 a, float32 b ) -{ - - if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) - || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - return ( a == b ) || ( (bits32) ( ( a | b )<<1 ) == 0 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is less than or -equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not -cause an exception. Otherwise, the comparison is performed according to the -IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float32_le_quiet( float32 a, float32 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) - || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) - ) { - if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloat32Sign( a ); - bSign = extractFloat32Sign( b ); - if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 ); - return ( a == b ) || ( aSign ^ ( a < b ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the single-precision floating-point value `a' is less than -the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an -exception. Otherwise, the comparison is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float32_lt_quiet( float32 a, float32 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) ) - || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) ) - ) { - if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloat32Sign( a ); - bSign = extractFloat32Sign( b ); - if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 ); - return ( a != b ) && ( aSign ^ ( a < b ) ); - -} -#endif /* !SOFTFLOAT_FOR_GCC */ - -#ifndef SOFTFLOAT_FOR_GCC /* Not needed */ -/* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point value -`a' to the 32-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic---which means in particular that the conversion is rounded -according to the current rounding mode. If `a' is a NaN, the largest -positive integer is returned. Otherwise, if the conversion overflows, the -largest integer with the same sign as `a' is returned. -------------------------------------------------------------------------------- -*/ -int32 float64_to_int32( float64 a ) -{ - flag aSign; - int16 aExp, shiftCount; - bits64 aSig; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - if ( ( aExp == 0x7FF ) && aSig ) aSign = 0; - if ( aExp ) aSig |= LIT64( 0x0010000000000000 ); - shiftCount = 0x42C - aExp; - if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig ); - return roundAndPackInt32( aSign, aSig ); - -} -#endif /* !SOFTFLOAT_FOR_GCC */ - -/* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point value -`a' to the 32-bit two's complement integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic, except that the conversion is always rounded toward zero. -If `a' is a NaN, the largest positive integer is returned. Otherwise, if -the conversion overflows, the largest integer with the same sign as `a' is -returned. -------------------------------------------------------------------------------- -*/ -int32 float64_to_int32_round_to_zero( float64 a ) -{ - flag aSign; - int16 aExp, shiftCount; - bits64 aSig, savedASig; - int32 z; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - if ( 0x41E < aExp ) { - if ( ( aExp == 0x7FF ) && aSig ) aSign = 0; - goto invalid; - } - else if ( aExp < 0x3FF ) { - if ( aExp || aSig ) float_set_inexact(); - return 0; - } - aSig |= LIT64( 0x0010000000000000 ); - shiftCount = 0x433 - aExp; - savedASig = aSig; - aSig >>= shiftCount; - z = aSig; - if ( aSign ) z = - z; - if ( ( z < 0 ) ^ aSign ) { - invalid: - float_raise( float_flag_invalid ); - return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF; - } - if ( ( aSig<>( - shiftCount ); - if ( (bits64) ( aSig<<( shiftCount & 63 ) ) ) { - float_set_inexact(); - } - } - if ( aSign ) z = - z; - return z; - -} -#endif /* !SOFTFLOAT_FOR_GCC */ - -/* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point value -`a' to the single-precision floating-point format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float64_to_float32( float64 a ) -{ - flag aSign; - int16 aExp; - bits64 aSig; - bits32 zSig; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - if ( aExp == 0x7FF ) { - if ( aSig ) return commonNaNToFloat32( float64ToCommonNaN( a ) ); - return packFloat32( aSign, 0xFF, 0 ); - } - shift64RightJamming( aSig, 22, &aSig ); - zSig = aSig; - if ( aExp || zSig ) { - zSig |= 0x40000000; - aExp -= 0x381; - } - return roundAndPackFloat32( aSign, aExp, zSig ); - -} - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point value -`a' to the extended double-precision floating-point format. The conversion -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 float64_to_floatx80( float64 a ) -{ - flag aSign; - int16 aExp; - bits64 aSig; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - if ( aExp == 0x7FF ) { - if ( aSig ) return commonNaNToFloatx80( float64ToCommonNaN( a ) ); - return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 ); - normalizeFloat64Subnormal( aSig, &aExp, &aSig ); - } - return - packFloatx80( - aSign, aExp + 0x3C00, ( aSig | LIT64( 0x0010000000000000 ) )<<11 ); - -} - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point value -`a' to the quadruple-precision floating-point format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float64_to_float128( float64 a ) -{ - flag aSign; - int16 aExp; - bits64 aSig, zSig0, zSig1; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - if ( aExp == 0x7FF ) { - if ( aSig ) return commonNaNToFloat128( float64ToCommonNaN( a ) ); - return packFloat128( aSign, 0x7FFF, 0, 0 ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat128( aSign, 0, 0, 0 ); - normalizeFloat64Subnormal( aSig, &aExp, &aSig ); - --aExp; - } - shift128Right( aSig, 0, 4, &zSig0, &zSig1 ); - return packFloat128( aSign, aExp + 0x3C00, zSig0, zSig1 ); - -} - -#endif - -#ifndef SOFTFLOAT_FOR_GCC -/* -------------------------------------------------------------------------------- -Rounds the double-precision floating-point value `a' to an integer, and -returns the result as a double-precision floating-point value. The -operation is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 a ) -{ - flag aSign; - int16 aExp; - bits64 lastBitMask, roundBitsMask; - int8 roundingMode; - float64 z; - - aExp = extractFloat64Exp( a ); - if ( 0x433 <= aExp ) { - if ( ( aExp == 0x7FF ) && extractFloat64Frac( a ) ) { - return propagateFloat64NaN( a, a ); - } - return a; - } - if ( aExp < 0x3FF ) { - if ( (bits64) ( a<<1 ) == 0 ) return a; - float_set_inexact(); - aSign = extractFloat64Sign( a ); - switch ( float_rounding_mode() ) { - case float_round_nearest_even: - if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) { - return packFloat64( aSign, 0x3FF, 0 ); - } - break; - case float_round_down: - return aSign ? LIT64( 0xBFF0000000000000 ) : 0; - case float_round_up: - return - aSign ? LIT64( 0x8000000000000000 ) : LIT64( 0x3FF0000000000000 ); - } - return packFloat64( aSign, 0, 0 ); - } - lastBitMask = 1; - lastBitMask <<= 0x433 - aExp; - roundBitsMask = lastBitMask - 1; - z = a; - roundingMode = float_rounding_mode(); - if ( roundingMode == float_round_nearest_even ) { - z += lastBitMask>>1; - if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask; - } - else if ( roundingMode != float_round_to_zero ) { - if ( extractFloat64Sign( z ) ^ ( roundingMode == float_round_up ) ) { - z += roundBitsMask; - } - } - z &= ~ roundBitsMask; - if ( z != a ) float_set_inexact(); - return z; - -} -#endif - -/* -------------------------------------------------------------------------------- -Returns the result of adding the absolute values of the double-precision -floating-point values `a' and `b'. If `zSign' is 1, the sum is negated -before being returned. `zSign' is ignored if the result is a NaN. -The addition is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static float64 addFloat64Sigs( float64 a, float64 b, flag zSign ) -{ - int16 aExp, bExp, zExp; - bits64 aSig, bSig, zSig; - int16 expDiff; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - bSig = extractFloat64Frac( b ); - bExp = extractFloat64Exp( b ); - expDiff = aExp - bExp; - aSig <<= 9; - bSig <<= 9; - if ( 0 < expDiff ) { - if ( aExp == 0x7FF ) { - if ( aSig ) return propagateFloat64NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - --expDiff; - } - else { - bSig |= LIT64( 0x2000000000000000 ); - } - shift64RightJamming( bSig, expDiff, &bSig ); - zExp = aExp; - } - else if ( expDiff < 0 ) { - if ( bExp == 0x7FF ) { - if ( bSig ) return propagateFloat64NaN( a, b ); - return packFloat64( zSign, 0x7FF, 0 ); - } - if ( aExp == 0 ) { - ++expDiff; - } - else { - aSig |= LIT64( 0x2000000000000000 ); - } - shift64RightJamming( aSig, - expDiff, &aSig ); - zExp = bExp; - } - else { - if ( aExp == 0x7FF ) { - if ( aSig | bSig ) return propagateFloat64NaN( a, b ); - return a; - } - if ( aExp == 0 ) return packFloat64( zSign, 0, ( aSig + bSig )>>9 ); - zSig = LIT64( 0x4000000000000000 ) + aSig + bSig; - zExp = aExp; - goto roundAndPack; - } - aSig |= LIT64( 0x2000000000000000 ); - zSig = ( aSig + bSig )<<1; - --zExp; - if ( (sbits64) zSig < 0 ) { - zSig = aSig + bSig; - ++zExp; - } - roundAndPack: - return roundAndPackFloat64( zSign, zExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the absolute values of the double- -precision floating-point values `a' and `b'. If `zSign' is 1, the -difference is negated before being returned. `zSign' is ignored if the -result is a NaN. The subtraction is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static float64 subFloat64Sigs( float64 a, float64 b, flag zSign ) -{ - int16 aExp, bExp, zExp; - bits64 aSig, bSig, zSig; - int16 expDiff; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - bSig = extractFloat64Frac( b ); - bExp = extractFloat64Exp( b ); - expDiff = aExp - bExp; - aSig <<= 10; - bSig <<= 10; - if ( 0 < expDiff ) goto aExpBigger; - if ( expDiff < 0 ) goto bExpBigger; - if ( aExp == 0x7FF ) { - if ( aSig | bSig ) return propagateFloat64NaN( a, b ); - float_raise( float_flag_invalid ); - return float64_default_nan; - } - if ( aExp == 0 ) { - aExp = 1; - bExp = 1; - } - if ( bSig < aSig ) goto aBigger; - if ( aSig < bSig ) goto bBigger; - return packFloat64( float_rounding_mode() == float_round_down, 0, 0 ); - bExpBigger: - if ( bExp == 0x7FF ) { - if ( bSig ) return propagateFloat64NaN( a, b ); - return packFloat64( zSign ^ 1, 0x7FF, 0 ); - } - if ( aExp == 0 ) { - ++expDiff; - } - else { - aSig |= LIT64( 0x4000000000000000 ); - } - shift64RightJamming( aSig, - expDiff, &aSig ); - bSig |= LIT64( 0x4000000000000000 ); - bBigger: - zSig = bSig - aSig; - zExp = bExp; - zSign ^= 1; - goto normalizeRoundAndPack; - aExpBigger: - if ( aExp == 0x7FF ) { - if ( aSig ) return propagateFloat64NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - --expDiff; - } - else { - bSig |= LIT64( 0x4000000000000000 ); - } - shift64RightJamming( bSig, expDiff, &bSig ); - aSig |= LIT64( 0x4000000000000000 ); - aBigger: - zSig = aSig - bSig; - zExp = aExp; - normalizeRoundAndPack: - --zExp; - return normalizeRoundAndPackFloat64( zSign, zExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of adding the double-precision floating-point values `a' -and `b'. The operation is performed according to the IEC/IEEE Standard for -Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float64_add( float64 a, float64 b ) -{ - flag aSign, bSign; - - aSign = extractFloat64Sign( a ); - bSign = extractFloat64Sign( b ); - if ( aSign == bSign ) { - return addFloat64Sigs( a, b, aSign ); - } - else { - return subFloat64Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the double-precision floating-point values -`a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float64_sub( float64 a, float64 b ) -{ - flag aSign, bSign; - - aSign = extractFloat64Sign( a ); - bSign = extractFloat64Sign( b ); - if ( aSign == bSign ) { - return subFloat64Sigs( a, b, aSign ); - } - else { - return addFloat64Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of multiplying the double-precision floating-point values -`a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float64_mul( float64 a, float64 b ) -{ - flag aSign, bSign, zSign; - int16 aExp, bExp, zExp; - bits64 aSig, bSig, zSig0, zSig1; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - bSig = extractFloat64Frac( b ); - bExp = extractFloat64Exp( b ); - bSign = extractFloat64Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0x7FF ) { - if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) { - return propagateFloat64NaN( a, b ); - } - if ( ( bExp | bSig ) == 0 ) { - float_raise( float_flag_invalid ); - return float64_default_nan; - } - return packFloat64( zSign, 0x7FF, 0 ); - } - if ( bExp == 0x7FF ) { - if ( bSig ) return propagateFloat64NaN( a, b ); - if ( ( aExp | aSig ) == 0 ) { - float_raise( float_flag_invalid ); - return float64_default_nan; - } - return packFloat64( zSign, 0x7FF, 0 ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat64( zSign, 0, 0 ); - normalizeFloat64Subnormal( aSig, &aExp, &aSig ); - } - if ( bExp == 0 ) { - if ( bSig == 0 ) return packFloat64( zSign, 0, 0 ); - normalizeFloat64Subnormal( bSig, &bExp, &bSig ); - } - zExp = aExp + bExp - 0x3FF; - aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<10; - bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11; - mul64To128( aSig, bSig, &zSig0, &zSig1 ); - zSig0 |= ( zSig1 != 0 ); - if ( 0 <= (sbits64) ( zSig0<<1 ) ) { - zSig0 <<= 1; - --zExp; - } - return roundAndPackFloat64( zSign, zExp, zSig0 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of dividing the double-precision floating-point value `a' -by the corresponding value `b'. The operation is performed according to -the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float64_div( float64 a, float64 b ) -{ - flag aSign, bSign, zSign; - int16 aExp, bExp, zExp; - bits64 aSig, bSig, zSig; - bits64 rem0, rem1; - bits64 term0, term1; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - bSig = extractFloat64Frac( b ); - bExp = extractFloat64Exp( b ); - bSign = extractFloat64Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0x7FF ) { - if ( aSig ) return propagateFloat64NaN( a, b ); - if ( bExp == 0x7FF ) { - if ( bSig ) return propagateFloat64NaN( a, b ); - float_raise( float_flag_invalid ); - return float64_default_nan; - } - return packFloat64( zSign, 0x7FF, 0 ); - } - if ( bExp == 0x7FF ) { - if ( bSig ) return propagateFloat64NaN( a, b ); - return packFloat64( zSign, 0, 0 ); - } - if ( bExp == 0 ) { - if ( bSig == 0 ) { - if ( ( aExp | aSig ) == 0 ) { - float_raise( float_flag_invalid ); - return float64_default_nan; - } - float_raise( float_flag_divbyzero ); - return packFloat64( zSign, 0x7FF, 0 ); - } - normalizeFloat64Subnormal( bSig, &bExp, &bSig ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat64( zSign, 0, 0 ); - normalizeFloat64Subnormal( aSig, &aExp, &aSig ); - } - zExp = aExp - bExp + 0x3FD; - aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<10; - bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11; - if ( bSig <= ( aSig + aSig ) ) { - aSig >>= 1; - ++zExp; - } - zSig = estimateDiv128To64( aSig, 0, bSig ); - if ( ( zSig & 0x1FF ) <= 2 ) { - mul64To128( bSig, zSig, &term0, &term1 ); - sub128( aSig, 0, term0, term1, &rem0, &rem1 ); - while ( (sbits64) rem0 < 0 ) { - --zSig; - add128( rem0, rem1, 0, bSig, &rem0, &rem1 ); - } - zSig |= ( rem1 != 0 ); - } - return roundAndPackFloat64( zSign, zExp, zSig ); - -} - -#ifndef SOFTFLOAT_FOR_GCC -/* -------------------------------------------------------------------------------- -Returns the remainder of the double-precision floating-point value `a' -with respect to the corresponding value `b'. The operation is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float64_rem( float64 a, float64 b ) -{ - flag aSign, bSign, zSign; - int16 aExp, bExp, expDiff; - bits64 aSig, bSig; - bits64 q, alternateASig; - sbits64 sigMean; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - bSig = extractFloat64Frac( b ); - bExp = extractFloat64Exp( b ); - bSign = extractFloat64Sign( b ); - if ( aExp == 0x7FF ) { - if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) { - return propagateFloat64NaN( a, b ); - } - float_raise( float_flag_invalid ); - return float64_default_nan; - } - if ( bExp == 0x7FF ) { - if ( bSig ) return propagateFloat64NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - if ( bSig == 0 ) { - float_raise( float_flag_invalid ); - return float64_default_nan; - } - normalizeFloat64Subnormal( bSig, &bExp, &bSig ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return a; - normalizeFloat64Subnormal( aSig, &aExp, &aSig ); - } - expDiff = aExp - bExp; - aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<11; - bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11; - if ( expDiff < 0 ) { - if ( expDiff < -1 ) return a; - aSig >>= 1; - } - q = ( bSig <= aSig ); - if ( q ) aSig -= bSig; - expDiff -= 64; - while ( 0 < expDiff ) { - q = estimateDiv128To64( aSig, 0, bSig ); - q = ( 2 < q ) ? q - 2 : 0; - aSig = - ( ( bSig>>2 ) * q ); - expDiff -= 62; - } - expDiff += 64; - if ( 0 < expDiff ) { - q = estimateDiv128To64( aSig, 0, bSig ); - q = ( 2 < q ) ? q - 2 : 0; - q >>= 64 - expDiff; - bSig >>= 2; - aSig = ( ( aSig>>1 )<<( expDiff - 1 ) ) - bSig * q; - } - else { - aSig >>= 2; - bSig >>= 2; - } - do { - alternateASig = aSig; - ++q; - aSig -= bSig; - } while ( 0 <= (sbits64) aSig ); - sigMean = aSig + alternateASig; - if ( ( sigMean < 0 ) || ( ( sigMean == 0 ) && ( q & 1 ) ) ) { - aSig = alternateASig; - } - zSign = ( (sbits64) aSig < 0 ); - if ( zSign ) aSig = - aSig; - return normalizeRoundAndPackFloat64( aSign ^ zSign, bExp, aSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the square root of the double-precision floating-point value `a'. -The operation is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float64_sqrt( float64 a ) -{ - flag aSign; - int16 aExp, zExp; - bits64 aSig, zSig, doubleZSig; - bits64 rem0, rem1, term0, term1; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - if ( aExp == 0x7FF ) { - if ( aSig ) return propagateFloat64NaN( a, a ); - if ( ! aSign ) return a; - float_raise( float_flag_invalid ); - return float64_default_nan; - } - if ( aSign ) { - if ( ( aExp | aSig ) == 0 ) return a; - float_raise( float_flag_invalid ); - return float64_default_nan; - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return 0; - normalizeFloat64Subnormal( aSig, &aExp, &aSig ); - } - zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE; - aSig |= LIT64( 0x0010000000000000 ); - zSig = estimateSqrt32( aExp, aSig>>21 ); - aSig <<= 9 - ( aExp & 1 ); - zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 ); - if ( ( zSig & 0x1FF ) <= 5 ) { - doubleZSig = zSig<<1; - mul64To128( zSig, zSig, &term0, &term1 ); - sub128( aSig, 0, term0, term1, &rem0, &rem1 ); - while ( (sbits64) rem0 < 0 ) { - --zSig; - doubleZSig -= 2; - add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 ); - } - zSig |= ( ( rem0 | rem1 ) != 0 ); - } - return roundAndPackFloat64( 0, zExp, zSig ); - -} -#endif - -/* -------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is equal to the -corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float64_eq( float64 a, float64 b ) -{ - - if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) ) - || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) ) - ) { - if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - return ( a == b ) || - ( (bits64) ( ( FLOAT64_DEMANGLE(a) | FLOAT64_DEMANGLE(b) )<<1 ) == 0 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is less than or -equal to the corresponding value `b', and 0 otherwise. The comparison is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float64_le( float64 a, float64 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) ) - || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloat64Sign( a ); - bSign = extractFloat64Sign( b ); - if ( aSign != bSign ) - return aSign || - ( (bits64) ( ( FLOAT64_DEMANGLE(a) | FLOAT64_DEMANGLE(b) )<<1 ) == - 0 ); - return ( a == b ) || - ( aSign ^ ( FLOAT64_DEMANGLE(a) < FLOAT64_DEMANGLE(b) ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is less than -the corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float64_lt( float64 a, float64 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) ) - || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloat64Sign( a ); - bSign = extractFloat64Sign( b ); - if ( aSign != bSign ) - return aSign && - ( (bits64) ( ( FLOAT64_DEMANGLE(a) | FLOAT64_DEMANGLE(b) )<<1 ) != - 0 ); - return ( a != b ) && - ( aSign ^ ( FLOAT64_DEMANGLE(a) < FLOAT64_DEMANGLE(b) ) ); - -} - -#ifndef SOFTFLOAT_FOR_GCC -/* -------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is equal to the -corresponding value `b', and 0 otherwise. The invalid exception is raised -if either operand is a NaN. Otherwise, the comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float64_eq_signaling( float64 a, float64 b ) -{ - - if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) ) - || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - return ( a == b ) || ( (bits64) ( ( a | b )<<1 ) == 0 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is less than or -equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not -cause an exception. Otherwise, the comparison is performed according to the -IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float64_le_quiet( float64 a, float64 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) ) - || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) ) - ) { - if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloat64Sign( a ); - bSign = extractFloat64Sign( b ); - if ( aSign != bSign ) return aSign || ( (bits64) ( ( a | b )<<1 ) == 0 ); - return ( a == b ) || ( aSign ^ ( a < b ) ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the double-precision floating-point value `a' is less than -the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an -exception. Otherwise, the comparison is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float64_lt_quiet( float64 a, float64 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) ) - || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) ) - ) { - if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloat64Sign( a ); - bSign = extractFloat64Sign( b ); - if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 ); - return ( a != b ) && ( aSign ^ ( a < b ) ); - -} -#endif - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the extended double-precision floating- -point value `a' to the 32-bit two's complement integer format. The -conversion is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic---which means in particular that the conversion -is rounded according to the current rounding mode. If `a' is a NaN, the -largest positive integer is returned. Otherwise, if the conversion -overflows, the largest integer with the same sign as `a' is returned. -------------------------------------------------------------------------------- -*/ -int32 floatx80_to_int32( floatx80 a ) -{ - flag aSign; - int32 aExp, shiftCount; - bits64 aSig; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) aSign = 0; - shiftCount = 0x4037 - aExp; - if ( shiftCount <= 0 ) shiftCount = 1; - shift64RightJamming( aSig, shiftCount, &aSig ); - return roundAndPackInt32( aSign, aSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the extended double-precision floating- -point value `a' to the 32-bit two's complement integer format. The -conversion is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic, except that the conversion is always rounded -toward zero. If `a' is a NaN, the largest positive integer is returned. -Otherwise, if the conversion overflows, the largest integer with the same -sign as `a' is returned. -------------------------------------------------------------------------------- -*/ -int32 floatx80_to_int32_round_to_zero( floatx80 a ) -{ - flag aSign; - int32 aExp, shiftCount; - bits64 aSig, savedASig; - int32 z; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - if ( 0x401E < aExp ) { - if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) aSign = 0; - goto invalid; - } - else if ( aExp < 0x3FFF ) { - if ( aExp || aSig ) float_set_inexact(); - return 0; - } - shiftCount = 0x403E - aExp; - savedASig = aSig; - aSig >>= shiftCount; - z = aSig; - if ( aSign ) z = - z; - if ( ( z < 0 ) ^ aSign ) { - invalid: - float_raise( float_flag_invalid ); - return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF; - } - if ( ( aSig<>( - shiftCount ); - if ( (bits64) ( aSig<<( shiftCount & 63 ) ) ) { - float_set_inexact(); - } - if ( aSign ) z = - z; - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the extended double-precision floating- -point value `a' to the single-precision floating-point format. The -conversion is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 floatx80_to_float32( floatx80 a ) -{ - flag aSign; - int32 aExp; - bits64 aSig; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig<<1 ) ) { - return commonNaNToFloat32( floatx80ToCommonNaN( a ) ); - } - return packFloat32( aSign, 0xFF, 0 ); - } - shift64RightJamming( aSig, 33, &aSig ); - if ( aExp || aSig ) aExp -= 0x3F81; - return roundAndPackFloat32( aSign, aExp, aSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the extended double-precision floating- -point value `a' to the double-precision floating-point format. The -conversion is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 floatx80_to_float64( floatx80 a ) -{ - flag aSign; - int32 aExp; - bits64 aSig, zSig; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig<<1 ) ) { - return commonNaNToFloat64( floatx80ToCommonNaN( a ) ); - } - return packFloat64( aSign, 0x7FF, 0 ); - } - shift64RightJamming( aSig, 1, &zSig ); - if ( aExp || aSig ) aExp -= 0x3C01; - return roundAndPackFloat64( aSign, aExp, zSig ); - -} - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the extended double-precision floating- -point value `a' to the quadruple-precision floating-point format. The -conversion is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 floatx80_to_float128( floatx80 a ) -{ - flag aSign; - int16 aExp; - bits64 aSig, zSig0, zSig1; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) { - return commonNaNToFloat128( floatx80ToCommonNaN( a ) ); - } - shift128Right( aSig<<1, 0, 16, &zSig0, &zSig1 ); - return packFloat128( aSign, aExp, zSig0, zSig1 ); - -} - -#endif - -/* -------------------------------------------------------------------------------- -Rounds the extended double-precision floating-point value `a' to an integer, -and returns the result as an extended quadruple-precision floating-point -value. The operation is performed according to the IEC/IEEE Standard for -Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 a ) -{ - flag aSign; - int32 aExp; - bits64 lastBitMask, roundBitsMask; - int8 roundingMode; - floatx80 z; - - aExp = extractFloatx80Exp( a ); - if ( 0x403E <= aExp ) { - if ( ( aExp == 0x7FFF ) && (bits64) ( extractFloatx80Frac( a )<<1 ) ) { - return propagateFloatx80NaN( a, a ); - } - return a; - } - if ( aExp < 0x3FFF ) { - if ( ( aExp == 0 ) - && ( (bits64) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) { - return a; - } - float_set_inexact(); - aSign = extractFloatx80Sign( a ); - switch ( float_rounding_mode() ) { - case float_round_nearest_even: - if ( ( aExp == 0x3FFE ) && (bits64) ( extractFloatx80Frac( a )<<1 ) - ) { - return - packFloatx80( aSign, 0x3FFF, LIT64( 0x8000000000000000 ) ); - } - break; - case float_round_down: - return - aSign ? - packFloatx80( 1, 0x3FFF, LIT64( 0x8000000000000000 ) ) - : packFloatx80( 0, 0, 0 ); - case float_round_up: - return - aSign ? packFloatx80( 1, 0, 0 ) - : packFloatx80( 0, 0x3FFF, LIT64( 0x8000000000000000 ) ); - } - return packFloatx80( aSign, 0, 0 ); - } - lastBitMask = 1; - lastBitMask <<= 0x403E - aExp; - roundBitsMask = lastBitMask - 1; - z = a; - roundingMode = float_rounding_mode(); - if ( roundingMode == float_round_nearest_even ) { - z.low += lastBitMask>>1; - if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask; - } - else if ( roundingMode != float_round_to_zero ) { - if ( extractFloatx80Sign( z ) ^ ( roundingMode == float_round_up ) ) { - z.low += roundBitsMask; - } - } - z.low &= ~ roundBitsMask; - if ( z.low == 0 ) { - ++z.high; - z.low = LIT64( 0x8000000000000000 ); - } - if ( z.low != a.low ) float_set_inexact(); - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of adding the absolute values of the extended double- -precision floating-point values `a' and `b'. If `zSign' is 1, the sum is -negated before being returned. `zSign' is ignored if the result is a NaN. -The addition is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign ) -{ - int32 aExp, bExp, zExp; - bits64 aSig, bSig, zSig0, zSig1; - int32 expDiff; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - bSig = extractFloatx80Frac( b ); - bExp = extractFloatx80Exp( b ); - expDiff = aExp - bExp; - if ( 0 < expDiff ) { - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b ); - return a; - } - if ( bExp == 0 ) --expDiff; - shift64ExtraRightJamming( bSig, 0, expDiff, &bSig, &zSig1 ); - zExp = aExp; - } - else if ( expDiff < 0 ) { - if ( bExp == 0x7FFF ) { - if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( aExp == 0 ) ++expDiff; - shift64ExtraRightJamming( aSig, 0, - expDiff, &aSig, &zSig1 ); - zExp = bExp; - } - else { - if ( aExp == 0x7FFF ) { - if ( (bits64) ( ( aSig | bSig )<<1 ) ) { - return propagateFloatx80NaN( a, b ); - } - return a; - } - zSig1 = 0; - zSig0 = aSig + bSig; - if ( aExp == 0 ) { - normalizeFloatx80Subnormal( zSig0, &zExp, &zSig0 ); - goto roundAndPack; - } - zExp = aExp; - goto shiftRight1; - } - zSig0 = aSig + bSig; - if ( (sbits64) zSig0 < 0 ) goto roundAndPack; - shiftRight1: - shift64ExtraRightJamming( zSig0, zSig1, 1, &zSig0, &zSig1 ); - zSig0 |= LIT64( 0x8000000000000000 ); - ++zExp; - roundAndPack: - return - roundAndPackFloatx80( - floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the absolute values of the extended -double-precision floating-point values `a' and `b'. If `zSign' is 1, the -difference is negated before being returned. `zSign' is ignored if the -result is a NaN. The subtraction is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign ) -{ - int32 aExp, bExp, zExp; - bits64 aSig, bSig, zSig0, zSig1; - int32 expDiff; - floatx80 z; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - bSig = extractFloatx80Frac( b ); - bExp = extractFloatx80Exp( b ); - expDiff = aExp - bExp; - if ( 0 < expDiff ) goto aExpBigger; - if ( expDiff < 0 ) goto bExpBigger; - if ( aExp == 0x7FFF ) { - if ( (bits64) ( ( aSig | bSig )<<1 ) ) { - return propagateFloatx80NaN( a, b ); - } - float_raise( float_flag_invalid ); - z.low = floatx80_default_nan_low; - z.high = floatx80_default_nan_high; - return z; - } - if ( aExp == 0 ) { - aExp = 1; - bExp = 1; - } - zSig1 = 0; - if ( bSig < aSig ) goto aBigger; - if ( aSig < bSig ) goto bBigger; - return packFloatx80( float_rounding_mode() == float_round_down, 0, 0 ); - bExpBigger: - if ( bExp == 0x7FFF ) { - if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); - return packFloatx80( zSign ^ 1, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( aExp == 0 ) ++expDiff; - shift128RightJamming( aSig, 0, - expDiff, &aSig, &zSig1 ); - bBigger: - sub128( bSig, 0, aSig, zSig1, &zSig0, &zSig1 ); - zExp = bExp; - zSign ^= 1; - goto normalizeRoundAndPack; - aExpBigger: - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b ); - return a; - } - if ( bExp == 0 ) --expDiff; - shift128RightJamming( bSig, 0, expDiff, &bSig, &zSig1 ); - aBigger: - sub128( aSig, 0, bSig, zSig1, &zSig0, &zSig1 ); - zExp = aExp; - normalizeRoundAndPack: - return - normalizeRoundAndPackFloatx80( - floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of adding the extended double-precision floating-point -values `a' and `b'. The operation is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_add( floatx80 a, floatx80 b ) -{ - flag aSign, bSign; - - aSign = extractFloatx80Sign( a ); - bSign = extractFloatx80Sign( b ); - if ( aSign == bSign ) { - return addFloatx80Sigs( a, b, aSign ); - } - else { - return subFloatx80Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the extended double-precision floating- -point values `a' and `b'. The operation is performed according to the -IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_sub( floatx80 a, floatx80 b ) -{ - flag aSign, bSign; - - aSign = extractFloatx80Sign( a ); - bSign = extractFloatx80Sign( b ); - if ( aSign == bSign ) { - return subFloatx80Sigs( a, b, aSign ); - } - else { - return addFloatx80Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of multiplying the extended double-precision floating- -point values `a' and `b'. The operation is performed according to the -IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_mul( floatx80 a, floatx80 b ) -{ - flag aSign, bSign, zSign; - int32 aExp, bExp, zExp; - bits64 aSig, bSig, zSig0, zSig1; - floatx80 z; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - bSig = extractFloatx80Frac( b ); - bExp = extractFloatx80Exp( b ); - bSign = extractFloatx80Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig<<1 ) - || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) { - return propagateFloatx80NaN( a, b ); - } - if ( ( bExp | bSig ) == 0 ) goto invalid; - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( bExp == 0x7FFF ) { - if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); - if ( ( aExp | aSig ) == 0 ) { - invalid: - float_raise( float_flag_invalid ); - z.low = floatx80_default_nan_low; - z.high = floatx80_default_nan_high; - return z; - } - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 ); - normalizeFloatx80Subnormal( aSig, &aExp, &aSig ); - } - if ( bExp == 0 ) { - if ( bSig == 0 ) return packFloatx80( zSign, 0, 0 ); - normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); - } - zExp = aExp + bExp - 0x3FFE; - mul64To128( aSig, bSig, &zSig0, &zSig1 ); - if ( 0 < (sbits64) zSig0 ) { - shortShift128Left( zSig0, zSig1, 1, &zSig0, &zSig1 ); - --zExp; - } - return - roundAndPackFloatx80( - floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of dividing the extended double-precision floating-point -value `a' by the corresponding value `b'. The operation is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_div( floatx80 a, floatx80 b ) -{ - flag aSign, bSign, zSign; - int32 aExp, bExp, zExp; - bits64 aSig, bSig, zSig0, zSig1; - bits64 rem0, rem1, rem2, term0, term1, term2; - floatx80 z; - - aSig = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - bSig = extractFloatx80Frac( b ); - bExp = extractFloatx80Exp( b ); - bSign = extractFloatx80Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b ); - if ( bExp == 0x7FFF ) { - if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); - goto invalid; - } - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( bExp == 0x7FFF ) { - if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); - return packFloatx80( zSign, 0, 0 ); - } - if ( bExp == 0 ) { - if ( bSig == 0 ) { - if ( ( aExp | aSig ) == 0 ) { - invalid: - float_raise( float_flag_invalid ); - z.low = floatx80_default_nan_low; - z.high = floatx80_default_nan_high; - return z; - } - float_raise( float_flag_divbyzero ); - return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 ); - normalizeFloatx80Subnormal( aSig, &aExp, &aSig ); - } - zExp = aExp - bExp + 0x3FFE; - rem1 = 0; - if ( bSig <= aSig ) { - shift128Right( aSig, 0, 1, &aSig, &rem1 ); - ++zExp; - } - zSig0 = estimateDiv128To64( aSig, rem1, bSig ); - mul64To128( bSig, zSig0, &term0, &term1 ); - sub128( aSig, rem1, term0, term1, &rem0, &rem1 ); - while ( (sbits64) rem0 < 0 ) { - --zSig0; - add128( rem0, rem1, 0, bSig, &rem0, &rem1 ); - } - zSig1 = estimateDiv128To64( rem1, 0, bSig ); - if ( (bits64) ( zSig1<<1 ) <= 8 ) { - mul64To128( bSig, zSig1, &term1, &term2 ); - sub128( rem1, 0, term1, term2, &rem1, &rem2 ); - while ( (sbits64) rem1 < 0 ) { - --zSig1; - add128( rem1, rem2, 0, bSig, &rem1, &rem2 ); - } - zSig1 |= ( ( rem1 | rem2 ) != 0 ); - } - return - roundAndPackFloatx80( - floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the remainder of the extended double-precision floating-point value -`a' with respect to the corresponding value `b'. The operation is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_rem( floatx80 a, floatx80 b ) -{ - flag aSign, bSign, zSign; - int32 aExp, bExp, expDiff; - bits64 aSig0, aSig1, bSig; - bits64 q, term0, term1, alternateASig0, alternateASig1; - floatx80 z; - - aSig0 = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - bSig = extractFloatx80Frac( b ); - bExp = extractFloatx80Exp( b ); - bSign = extractFloatx80Sign( b ); - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig0<<1 ) - || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) { - return propagateFloatx80NaN( a, b ); - } - goto invalid; - } - if ( bExp == 0x7FFF ) { - if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - if ( bSig == 0 ) { - invalid: - float_raise( float_flag_invalid ); - z.low = floatx80_default_nan_low; - z.high = floatx80_default_nan_high; - return z; - } - normalizeFloatx80Subnormal( bSig, &bExp, &bSig ); - } - if ( aExp == 0 ) { - if ( (bits64) ( aSig0<<1 ) == 0 ) return a; - normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 ); - } - bSig |= LIT64( 0x8000000000000000 ); - zSign = aSign; - expDiff = aExp - bExp; - aSig1 = 0; - if ( expDiff < 0 ) { - if ( expDiff < -1 ) return a; - shift128Right( aSig0, 0, 1, &aSig0, &aSig1 ); - expDiff = 0; - } - q = ( bSig <= aSig0 ); - if ( q ) aSig0 -= bSig; - expDiff -= 64; - while ( 0 < expDiff ) { - q = estimateDiv128To64( aSig0, aSig1, bSig ); - q = ( 2 < q ) ? q - 2 : 0; - mul64To128( bSig, q, &term0, &term1 ); - sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 ); - shortShift128Left( aSig0, aSig1, 62, &aSig0, &aSig1 ); - expDiff -= 62; - } - expDiff += 64; - if ( 0 < expDiff ) { - q = estimateDiv128To64( aSig0, aSig1, bSig ); - q = ( 2 < q ) ? q - 2 : 0; - q >>= 64 - expDiff; - mul64To128( bSig, q<<( 64 - expDiff ), &term0, &term1 ); - sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 ); - shortShift128Left( 0, bSig, 64 - expDiff, &term0, &term1 ); - while ( le128( term0, term1, aSig0, aSig1 ) ) { - ++q; - sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 ); - } - } - else { - term1 = 0; - term0 = bSig; - } - sub128( term0, term1, aSig0, aSig1, &alternateASig0, &alternateASig1 ); - if ( lt128( alternateASig0, alternateASig1, aSig0, aSig1 ) - || ( eq128( alternateASig0, alternateASig1, aSig0, aSig1 ) - && ( q & 1 ) ) - ) { - aSig0 = alternateASig0; - aSig1 = alternateASig1; - zSign = ! zSign; - } - return - normalizeRoundAndPackFloatx80( - 80, zSign, bExp + expDiff, aSig0, aSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the square root of the extended double-precision floating-point -value `a'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_sqrt( floatx80 a ) -{ - flag aSign; - int32 aExp, zExp; - bits64 aSig0, aSig1, zSig0, zSig1, doubleZSig0; - bits64 rem0, rem1, rem2, rem3, term0, term1, term2, term3; - floatx80 z; - - aSig0 = extractFloatx80Frac( a ); - aExp = extractFloatx80Exp( a ); - aSign = extractFloatx80Sign( a ); - if ( aExp == 0x7FFF ) { - if ( (bits64) ( aSig0<<1 ) ) return propagateFloatx80NaN( a, a ); - if ( ! aSign ) return a; - goto invalid; - } - if ( aSign ) { - if ( ( aExp | aSig0 ) == 0 ) return a; - invalid: - float_raise( float_flag_invalid ); - z.low = floatx80_default_nan_low; - z.high = floatx80_default_nan_high; - return z; - } - if ( aExp == 0 ) { - if ( aSig0 == 0 ) return packFloatx80( 0, 0, 0 ); - normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 ); - } - zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFF; - zSig0 = estimateSqrt32( aExp, aSig0>>32 ); - shift128Right( aSig0, 0, 2 + ( aExp & 1 ), &aSig0, &aSig1 ); - zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0<<32 ) + ( zSig0<<30 ); - doubleZSig0 = zSig0<<1; - mul64To128( zSig0, zSig0, &term0, &term1 ); - sub128( aSig0, aSig1, term0, term1, &rem0, &rem1 ); - while ( (sbits64) rem0 < 0 ) { - --zSig0; - doubleZSig0 -= 2; - add128( rem0, rem1, zSig0>>63, doubleZSig0 | 1, &rem0, &rem1 ); - } - zSig1 = estimateDiv128To64( rem1, 0, doubleZSig0 ); - if ( ( zSig1 & LIT64( 0x3FFFFFFFFFFFFFFF ) ) <= 5 ) { - if ( zSig1 == 0 ) zSig1 = 1; - mul64To128( doubleZSig0, zSig1, &term1, &term2 ); - sub128( rem1, 0, term1, term2, &rem1, &rem2 ); - mul64To128( zSig1, zSig1, &term2, &term3 ); - sub192( rem1, rem2, 0, 0, term2, term3, &rem1, &rem2, &rem3 ); - while ( (sbits64) rem1 < 0 ) { - --zSig1; - shortShift128Left( 0, zSig1, 1, &term2, &term3 ); - term3 |= 1; - term2 |= doubleZSig0; - add192( rem1, rem2, rem3, 0, term2, term3, &rem1, &rem2, &rem3 ); - } - zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 ); - } - shortShift128Left( 0, zSig1, 1, &zSig0, &zSig1 ); - zSig0 |= doubleZSig0; - return - roundAndPackFloatx80( - floatx80_rounding_precision, 0, zExp, zSig0, zSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is -equal to the corresponding value `b', and 0 otherwise. The comparison is -performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -flag floatx80_eq( floatx80 a, floatx80 b ) -{ - - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( b )<<1 ) ) - ) { - if ( floatx80_is_signaling_nan( a ) - || floatx80_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - return - ( a.low == b.low ) - && ( ( a.high == b.high ) - || ( ( a.low == 0 ) - && ( (bits16) ( ( a.high | b.high )<<1 ) == 0 ) ) - ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is -less than or equal to the corresponding value `b', and 0 otherwise. The -comparison is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag floatx80_le( floatx80 a, floatx80 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( b )<<1 ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloatx80Sign( a ); - bSign = extractFloatx80Sign( b ); - if ( aSign != bSign ) { - return - aSign - || ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - == 0 ); - } - return - aSign ? le128( b.high, b.low, a.high, a.low ) - : le128( a.high, a.low, b.high, b.low ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is -less than the corresponding value `b', and 0 otherwise. The comparison -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -flag floatx80_lt( floatx80 a, floatx80 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( b )<<1 ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloatx80Sign( a ); - bSign = extractFloatx80Sign( b ); - if ( aSign != bSign ) { - return - aSign - && ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - != 0 ); - } - return - aSign ? lt128( b.high, b.low, a.high, a.low ) - : lt128( a.high, a.low, b.high, b.low ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is equal -to the corresponding value `b', and 0 otherwise. The invalid exception is -raised if either operand is a NaN. Otherwise, the comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag floatx80_eq_signaling( floatx80 a, floatx80 b ) -{ - - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( b )<<1 ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - return - ( a.low == b.low ) - && ( ( a.high == b.high ) - || ( ( a.low == 0 ) - && ( (bits16) ( ( a.high | b.high )<<1 ) == 0 ) ) - ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is less -than or equal to the corresponding value `b', and 0 otherwise. Quiet NaNs -do not cause an exception. Otherwise, the comparison is performed according -to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag floatx80_le_quiet( floatx80 a, floatx80 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( b )<<1 ) ) - ) { - if ( floatx80_is_signaling_nan( a ) - || floatx80_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloatx80Sign( a ); - bSign = extractFloatx80Sign( b ); - if ( aSign != bSign ) { - return - aSign - || ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - == 0 ); - } - return - aSign ? le128( b.high, b.low, a.high, a.low ) - : le128( a.high, a.low, b.high, b.low ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the extended double-precision floating-point value `a' is less -than the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause -an exception. Otherwise, the comparison is performed according to the -IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag floatx80_lt_quiet( floatx80 a, floatx80 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloatx80Exp( a ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) == 0x7FFF ) - && (bits64) ( extractFloatx80Frac( b )<<1 ) ) - ) { - if ( floatx80_is_signaling_nan( a ) - || floatx80_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloatx80Sign( a ); - bSign = extractFloatx80Sign( b ); - if ( aSign != bSign ) { - return - aSign - && ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - != 0 ); - } - return - aSign ? lt128( b.high, b.low, a.high, a.low ) - : lt128( a.high, a.low, b.high, b.low ); - -} - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the quadruple-precision floating-point -value `a' to the 32-bit two's complement integer format. The conversion -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic---which means in particular that the conversion is rounded -according to the current rounding mode. If `a' is a NaN, the largest -positive integer is returned. Otherwise, if the conversion overflows, the -largest integer with the same sign as `a' is returned. -------------------------------------------------------------------------------- -*/ -int32 float128_to_int32( float128 a ) -{ - flag aSign; - int32 aExp, shiftCount; - bits64 aSig0, aSig1; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - if ( ( aExp == 0x7FFF ) && ( aSig0 | aSig1 ) ) aSign = 0; - if ( aExp ) aSig0 |= LIT64( 0x0001000000000000 ); - aSig0 |= ( aSig1 != 0 ); - shiftCount = 0x4028 - aExp; - if ( 0 < shiftCount ) shift64RightJamming( aSig0, shiftCount, &aSig0 ); - return roundAndPackInt32( aSign, aSig0 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the quadruple-precision floating-point -value `a' to the 32-bit two's complement integer format. The conversion -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic, except that the conversion is always rounded toward zero. If -`a' is a NaN, the largest positive integer is returned. Otherwise, if the -conversion overflows, the largest integer with the same sign as `a' is -returned. -------------------------------------------------------------------------------- -*/ -int32 float128_to_int32_round_to_zero( float128 a ) -{ - flag aSign; - int32 aExp, shiftCount; - bits64 aSig0, aSig1, savedASig; - int32 z; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - aSig0 |= ( aSig1 != 0 ); - if ( 0x401E < aExp ) { - if ( ( aExp == 0x7FFF ) && aSig0 ) aSign = 0; - goto invalid; - } - else if ( aExp < 0x3FFF ) { - if ( aExp || aSig0 ) float_set_inexact(); - return 0; - } - aSig0 |= LIT64( 0x0001000000000000 ); - shiftCount = 0x402F - aExp; - savedASig = aSig0; - aSig0 >>= shiftCount; - z = aSig0; - if ( aSign ) z = - z; - if ( ( z < 0 ) ^ aSign ) { - invalid: - float_raise( float_flag_invalid ); - return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF; - } - if ( ( aSig0<>( ( - shiftCount ) & 63 ) ); - if ( (bits64) ( aSig1<>( - shiftCount ); - if ( aSig1 - || ( shiftCount && (bits64) ( aSig0<<( shiftCount & 63 ) ) ) ) { - float_set_inexact(); - } - } - if ( aSign ) z = - z; - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the quadruple-precision floating-point -value `a' to the single-precision floating-point format. The conversion -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -float32 float128_to_float32( float128 a ) -{ - flag aSign; - int32 aExp; - bits64 aSig0, aSig1; - bits32 zSig; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 ) { - return commonNaNToFloat32( float128ToCommonNaN( a ) ); - } - return packFloat32( aSign, 0xFF, 0 ); - } - aSig0 |= ( aSig1 != 0 ); - shift64RightJamming( aSig0, 18, &aSig0 ); - zSig = aSig0; - if ( aExp || zSig ) { - zSig |= 0x40000000; - aExp -= 0x3F81; - } - return roundAndPackFloat32( aSign, aExp, zSig ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of converting the quadruple-precision floating-point -value `a' to the double-precision floating-point format. The conversion -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -float64 float128_to_float64( float128 a ) -{ - flag aSign; - int32 aExp; - bits64 aSig0, aSig1; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 ) { - return commonNaNToFloat64( float128ToCommonNaN( a ) ); - } - return packFloat64( aSign, 0x7FF, 0 ); - } - shortShift128Left( aSig0, aSig1, 14, &aSig0, &aSig1 ); - aSig0 |= ( aSig1 != 0 ); - if ( aExp || aSig0 ) { - aSig0 |= LIT64( 0x4000000000000000 ); - aExp -= 0x3C01; - } - return roundAndPackFloat64( aSign, aExp, aSig0 ); - -} - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Returns the result of converting the quadruple-precision floating-point -value `a' to the extended double-precision floating-point format. The -conversion is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -floatx80 float128_to_floatx80( float128 a ) -{ - flag aSign; - int32 aExp; - bits64 aSig0, aSig1; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 ) { - return commonNaNToFloatx80( float128ToCommonNaN( a ) ); - } - return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) ); - } - if ( aExp == 0 ) { - if ( ( aSig0 | aSig1 ) == 0 ) return packFloatx80( aSign, 0, 0 ); - normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 ); - } - else { - aSig0 |= LIT64( 0x0001000000000000 ); - } - shortShift128Left( aSig0, aSig1, 15, &aSig0, &aSig1 ); - return roundAndPackFloatx80( 80, aSign, aExp, aSig0, aSig1 ); - -} - -#endif - -/* -------------------------------------------------------------------------------- -Rounds the quadruple-precision floating-point value `a' to an integer, and -returns the result as a quadruple-precision floating-point value. The -operation is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 a ) -{ - flag aSign; - int32 aExp; - bits64 lastBitMask, roundBitsMask; - int8 roundingMode; - float128 z; - - aExp = extractFloat128Exp( a ); - if ( 0x402F <= aExp ) { - if ( 0x406F <= aExp ) { - if ( ( aExp == 0x7FFF ) - && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) - ) { - return propagateFloat128NaN( a, a ); - } - return a; - } - lastBitMask = 1; - lastBitMask = ( lastBitMask<<( 0x406E - aExp ) )<<1; - roundBitsMask = lastBitMask - 1; - z = a; - roundingMode = float_rounding_mode(); - if ( roundingMode == float_round_nearest_even ) { - if ( lastBitMask ) { - add128( z.high, z.low, 0, lastBitMask>>1, &z.high, &z.low ); - if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask; - } - else { - if ( (sbits64) z.low < 0 ) { - ++z.high; - if ( (bits64) ( z.low<<1 ) == 0 ) z.high &= ~1; - } - } - } - else if ( roundingMode != float_round_to_zero ) { - if ( extractFloat128Sign( z ) - ^ ( roundingMode == float_round_up ) ) { - add128( z.high, z.low, 0, roundBitsMask, &z.high, &z.low ); - } - } - z.low &= ~ roundBitsMask; - } - else { - if ( aExp < 0x3FFF ) { - if ( ( ( (bits64) ( a.high<<1 ) ) | a.low ) == 0 ) return a; - float_set_inexact(); - aSign = extractFloat128Sign( a ); - switch ( float_rounding_mode() ) { - case float_round_nearest_even: - if ( ( aExp == 0x3FFE ) - && ( extractFloat128Frac0( a ) - | extractFloat128Frac1( a ) ) - ) { - return packFloat128( aSign, 0x3FFF, 0, 0 ); - } - break; - case float_round_down: - return - aSign ? packFloat128( 1, 0x3FFF, 0, 0 ) - : packFloat128( 0, 0, 0, 0 ); - case float_round_up: - return - aSign ? packFloat128( 1, 0, 0, 0 ) - : packFloat128( 0, 0x3FFF, 0, 0 ); - } - return packFloat128( aSign, 0, 0, 0 ); - } - lastBitMask = 1; - lastBitMask <<= 0x402F - aExp; - roundBitsMask = lastBitMask - 1; - z.low = 0; - z.high = a.high; - roundingMode = float_rounding_mode(); - if ( roundingMode == float_round_nearest_even ) { - z.high += lastBitMask>>1; - if ( ( ( z.high & roundBitsMask ) | a.low ) == 0 ) { - z.high &= ~ lastBitMask; - } - } - else if ( roundingMode != float_round_to_zero ) { - if ( extractFloat128Sign( z ) - ^ ( roundingMode == float_round_up ) ) { - z.high |= ( a.low != 0 ); - z.high += roundBitsMask; - } - } - z.high &= ~ roundBitsMask; - } - if ( ( z.low != a.low ) || ( z.high != a.high ) ) { - float_set_inexact(); - } - return z; - -} - -/* -------------------------------------------------------------------------------- -Returns the result of adding the absolute values of the quadruple-precision -floating-point values `a' and `b'. If `zSign' is 1, the sum is negated -before being returned. `zSign' is ignored if the result is a NaN. -The addition is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static float128 addFloat128Sigs( float128 a, float128 b, flag zSign ) -{ - int32 aExp, bExp, zExp; - bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2; - int32 expDiff; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - bSig1 = extractFloat128Frac1( b ); - bSig0 = extractFloat128Frac0( b ); - bExp = extractFloat128Exp( b ); - expDiff = aExp - bExp; - if ( 0 < expDiff ) { - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - --expDiff; - } - else { - bSig0 |= LIT64( 0x0001000000000000 ); - } - shift128ExtraRightJamming( - bSig0, bSig1, 0, expDiff, &bSig0, &bSig1, &zSig2 ); - zExp = aExp; - } - else if ( expDiff < 0 ) { - if ( bExp == 0x7FFF ) { - if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b ); - return packFloat128( zSign, 0x7FFF, 0, 0 ); - } - if ( aExp == 0 ) { - ++expDiff; - } - else { - aSig0 |= LIT64( 0x0001000000000000 ); - } - shift128ExtraRightJamming( - aSig0, aSig1, 0, - expDiff, &aSig0, &aSig1, &zSig2 ); - zExp = bExp; - } - else { - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 | bSig0 | bSig1 ) { - return propagateFloat128NaN( a, b ); - } - return a; - } - add128( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1 ); - if ( aExp == 0 ) return packFloat128( zSign, 0, zSig0, zSig1 ); - zSig2 = 0; - zSig0 |= LIT64( 0x0002000000000000 ); - zExp = aExp; - goto shiftRight1; - } - aSig0 |= LIT64( 0x0001000000000000 ); - add128( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1 ); - --zExp; - if ( zSig0 < LIT64( 0x0002000000000000 ) ) goto roundAndPack; - ++zExp; - shiftRight1: - shift128ExtraRightJamming( - zSig0, zSig1, zSig2, 1, &zSig0, &zSig1, &zSig2 ); - roundAndPack: - return roundAndPackFloat128( zSign, zExp, zSig0, zSig1, zSig2 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the absolute values of the quadruple- -precision floating-point values `a' and `b'. If `zSign' is 1, the -difference is negated before being returned. `zSign' is ignored if the -result is a NaN. The subtraction is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -static float128 subFloat128Sigs( float128 a, float128 b, flag zSign ) -{ - int32 aExp, bExp, zExp; - bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1; - int32 expDiff; - float128 z; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - bSig1 = extractFloat128Frac1( b ); - bSig0 = extractFloat128Frac0( b ); - bExp = extractFloat128Exp( b ); - expDiff = aExp - bExp; - shortShift128Left( aSig0, aSig1, 14, &aSig0, &aSig1 ); - shortShift128Left( bSig0, bSig1, 14, &bSig0, &bSig1 ); - if ( 0 < expDiff ) goto aExpBigger; - if ( expDiff < 0 ) goto bExpBigger; - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 | bSig0 | bSig1 ) { - return propagateFloat128NaN( a, b ); - } - float_raise( float_flag_invalid ); - z.low = float128_default_nan_low; - z.high = float128_default_nan_high; - return z; - } - if ( aExp == 0 ) { - aExp = 1; - bExp = 1; - } - if ( bSig0 < aSig0 ) goto aBigger; - if ( aSig0 < bSig0 ) goto bBigger; - if ( bSig1 < aSig1 ) goto aBigger; - if ( aSig1 < bSig1 ) goto bBigger; - return packFloat128( float_rounding_mode() == float_round_down, 0, 0, 0 ); - bExpBigger: - if ( bExp == 0x7FFF ) { - if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b ); - return packFloat128( zSign ^ 1, 0x7FFF, 0, 0 ); - } - if ( aExp == 0 ) { - ++expDiff; - } - else { - aSig0 |= LIT64( 0x4000000000000000 ); - } - shift128RightJamming( aSig0, aSig1, - expDiff, &aSig0, &aSig1 ); - bSig0 |= LIT64( 0x4000000000000000 ); - bBigger: - sub128( bSig0, bSig1, aSig0, aSig1, &zSig0, &zSig1 ); - zExp = bExp; - zSign ^= 1; - goto normalizeRoundAndPack; - aExpBigger: - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - --expDiff; - } - else { - bSig0 |= LIT64( 0x4000000000000000 ); - } - shift128RightJamming( bSig0, bSig1, expDiff, &bSig0, &bSig1 ); - aSig0 |= LIT64( 0x4000000000000000 ); - aBigger: - sub128( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1 ); - zExp = aExp; - normalizeRoundAndPack: - --zExp; - return normalizeRoundAndPackFloat128( zSign, zExp - 14, zSig0, zSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of adding the quadruple-precision floating-point values -`a' and `b'. The operation is performed according to the IEC/IEEE Standard -for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float128_add( float128 a, float128 b ) -{ - flag aSign, bSign; - - aSign = extractFloat128Sign( a ); - bSign = extractFloat128Sign( b ); - if ( aSign == bSign ) { - return addFloat128Sigs( a, b, aSign ); - } - else { - return subFloat128Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of subtracting the quadruple-precision floating-point -values `a' and `b'. The operation is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float128_sub( float128 a, float128 b ) -{ - flag aSign, bSign; - - aSign = extractFloat128Sign( a ); - bSign = extractFloat128Sign( b ); - if ( aSign == bSign ) { - return subFloat128Sigs( a, b, aSign ); - } - else { - return addFloat128Sigs( a, b, aSign ); - } - -} - -/* -------------------------------------------------------------------------------- -Returns the result of multiplying the quadruple-precision floating-point -values `a' and `b'. The operation is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float128_mul( float128 a, float128 b ) -{ - flag aSign, bSign, zSign; - int32 aExp, bExp, zExp; - bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2, zSig3; - float128 z; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - bSig1 = extractFloat128Frac1( b ); - bSig0 = extractFloat128Frac0( b ); - bExp = extractFloat128Exp( b ); - bSign = extractFloat128Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0x7FFF ) { - if ( ( aSig0 | aSig1 ) - || ( ( bExp == 0x7FFF ) && ( bSig0 | bSig1 ) ) ) { - return propagateFloat128NaN( a, b ); - } - if ( ( bExp | bSig0 | bSig1 ) == 0 ) goto invalid; - return packFloat128( zSign, 0x7FFF, 0, 0 ); - } - if ( bExp == 0x7FFF ) { - if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b ); - if ( ( aExp | aSig0 | aSig1 ) == 0 ) { - invalid: - float_raise( float_flag_invalid ); - z.low = float128_default_nan_low; - z.high = float128_default_nan_high; - return z; - } - return packFloat128( zSign, 0x7FFF, 0, 0 ); - } - if ( aExp == 0 ) { - if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( zSign, 0, 0, 0 ); - normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 ); - } - if ( bExp == 0 ) { - if ( ( bSig0 | bSig1 ) == 0 ) return packFloat128( zSign, 0, 0, 0 ); - normalizeFloat128Subnormal( bSig0, bSig1, &bExp, &bSig0, &bSig1 ); - } - zExp = aExp + bExp - 0x4000; - aSig0 |= LIT64( 0x0001000000000000 ); - shortShift128Left( bSig0, bSig1, 16, &bSig0, &bSig1 ); - mul128To256( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1, &zSig2, &zSig3 ); - add128( zSig0, zSig1, aSig0, aSig1, &zSig0, &zSig1 ); - zSig2 |= ( zSig3 != 0 ); - if ( LIT64( 0x0002000000000000 ) <= zSig0 ) { - shift128ExtraRightJamming( - zSig0, zSig1, zSig2, 1, &zSig0, &zSig1, &zSig2 ); - ++zExp; - } - return roundAndPackFloat128( zSign, zExp, zSig0, zSig1, zSig2 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the result of dividing the quadruple-precision floating-point value -`a' by the corresponding value `b'. The operation is performed according to -the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float128_div( float128 a, float128 b ) -{ - flag aSign, bSign, zSign; - int32 aExp, bExp, zExp; - bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2; - bits64 rem0, rem1, rem2, rem3, term0, term1, term2, term3; - float128 z; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - bSig1 = extractFloat128Frac1( b ); - bSig0 = extractFloat128Frac0( b ); - bExp = extractFloat128Exp( b ); - bSign = extractFloat128Sign( b ); - zSign = aSign ^ bSign; - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, b ); - if ( bExp == 0x7FFF ) { - if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b ); - goto invalid; - } - return packFloat128( zSign, 0x7FFF, 0, 0 ); - } - if ( bExp == 0x7FFF ) { - if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b ); - return packFloat128( zSign, 0, 0, 0 ); - } - if ( bExp == 0 ) { - if ( ( bSig0 | bSig1 ) == 0 ) { - if ( ( aExp | aSig0 | aSig1 ) == 0 ) { - invalid: - float_raise( float_flag_invalid ); - z.low = float128_default_nan_low; - z.high = float128_default_nan_high; - return z; - } - float_raise( float_flag_divbyzero ); - return packFloat128( zSign, 0x7FFF, 0, 0 ); - } - normalizeFloat128Subnormal( bSig0, bSig1, &bExp, &bSig0, &bSig1 ); - } - if ( aExp == 0 ) { - if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( zSign, 0, 0, 0 ); - normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 ); - } - zExp = aExp - bExp + 0x3FFD; - shortShift128Left( - aSig0 | LIT64( 0x0001000000000000 ), aSig1, 15, &aSig0, &aSig1 ); - shortShift128Left( - bSig0 | LIT64( 0x0001000000000000 ), bSig1, 15, &bSig0, &bSig1 ); - if ( le128( bSig0, bSig1, aSig0, aSig1 ) ) { - shift128Right( aSig0, aSig1, 1, &aSig0, &aSig1 ); - ++zExp; - } - zSig0 = estimateDiv128To64( aSig0, aSig1, bSig0 ); - mul128By64To192( bSig0, bSig1, zSig0, &term0, &term1, &term2 ); - sub192( aSig0, aSig1, 0, term0, term1, term2, &rem0, &rem1, &rem2 ); - while ( (sbits64) rem0 < 0 ) { - --zSig0; - add192( rem0, rem1, rem2, 0, bSig0, bSig1, &rem0, &rem1, &rem2 ); - } - zSig1 = estimateDiv128To64( rem1, rem2, bSig0 ); - if ( ( zSig1 & 0x3FFF ) <= 4 ) { - mul128By64To192( bSig0, bSig1, zSig1, &term1, &term2, &term3 ); - sub192( rem1, rem2, 0, term1, term2, term3, &rem1, &rem2, &rem3 ); - while ( (sbits64) rem1 < 0 ) { - --zSig1; - add192( rem1, rem2, rem3, 0, bSig0, bSig1, &rem1, &rem2, &rem3 ); - } - zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 ); - } - shift128ExtraRightJamming( zSig0, zSig1, 0, 15, &zSig0, &zSig1, &zSig2 ); - return roundAndPackFloat128( zSign, zExp, zSig0, zSig1, zSig2 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the remainder of the quadruple-precision floating-point value `a' -with respect to the corresponding value `b'. The operation is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float128_rem( float128 a, float128 b ) -{ - flag aSign, bSign, zSign; - int32 aExp, bExp, expDiff; - bits64 aSig0, aSig1, bSig0, bSig1, q, term0, term1, term2; - bits64 allZero, alternateASig0, alternateASig1, sigMean1; - sbits64 sigMean0; - float128 z; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - bSig1 = extractFloat128Frac1( b ); - bSig0 = extractFloat128Frac0( b ); - bExp = extractFloat128Exp( b ); - bSign = extractFloat128Sign( b ); - if ( aExp == 0x7FFF ) { - if ( ( aSig0 | aSig1 ) - || ( ( bExp == 0x7FFF ) && ( bSig0 | bSig1 ) ) ) { - return propagateFloat128NaN( a, b ); - } - goto invalid; - } - if ( bExp == 0x7FFF ) { - if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b ); - return a; - } - if ( bExp == 0 ) { - if ( ( bSig0 | bSig1 ) == 0 ) { - invalid: - float_raise( float_flag_invalid ); - z.low = float128_default_nan_low; - z.high = float128_default_nan_high; - return z; - } - normalizeFloat128Subnormal( bSig0, bSig1, &bExp, &bSig0, &bSig1 ); - } - if ( aExp == 0 ) { - if ( ( aSig0 | aSig1 ) == 0 ) return a; - normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 ); - } - expDiff = aExp - bExp; - if ( expDiff < -1 ) return a; - shortShift128Left( - aSig0 | LIT64( 0x0001000000000000 ), - aSig1, - 15 - ( expDiff < 0 ), - &aSig0, - &aSig1 - ); - shortShift128Left( - bSig0 | LIT64( 0x0001000000000000 ), bSig1, 15, &bSig0, &bSig1 ); - q = le128( bSig0, bSig1, aSig0, aSig1 ); - if ( q ) sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 ); - expDiff -= 64; - while ( 0 < expDiff ) { - q = estimateDiv128To64( aSig0, aSig1, bSig0 ); - q = ( 4 < q ) ? q - 4 : 0; - mul128By64To192( bSig0, bSig1, q, &term0, &term1, &term2 ); - shortShift192Left( term0, term1, term2, 61, &term1, &term2, &allZero ); - shortShift128Left( aSig0, aSig1, 61, &aSig0, &allZero ); - sub128( aSig0, 0, term1, term2, &aSig0, &aSig1 ); - expDiff -= 61; - } - if ( -64 < expDiff ) { - q = estimateDiv128To64( aSig0, aSig1, bSig0 ); - q = ( 4 < q ) ? q - 4 : 0; - q >>= - expDiff; - shift128Right( bSig0, bSig1, 12, &bSig0, &bSig1 ); - expDiff += 52; - if ( expDiff < 0 ) { - shift128Right( aSig0, aSig1, - expDiff, &aSig0, &aSig1 ); - } - else { - shortShift128Left( aSig0, aSig1, expDiff, &aSig0, &aSig1 ); - } - mul128By64To192( bSig0, bSig1, q, &term0, &term1, &term2 ); - sub128( aSig0, aSig1, term1, term2, &aSig0, &aSig1 ); - } - else { - shift128Right( aSig0, aSig1, 12, &aSig0, &aSig1 ); - shift128Right( bSig0, bSig1, 12, &bSig0, &bSig1 ); - } - do { - alternateASig0 = aSig0; - alternateASig1 = aSig1; - ++q; - sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 ); - } while ( 0 <= (sbits64) aSig0 ); - add128( - aSig0, aSig1, alternateASig0, alternateASig1, &sigMean0, &sigMean1 ); - if ( ( sigMean0 < 0 ) - || ( ( ( sigMean0 | sigMean1 ) == 0 ) && ( q & 1 ) ) ) { - aSig0 = alternateASig0; - aSig1 = alternateASig1; - } - zSign = ( (sbits64) aSig0 < 0 ); - if ( zSign ) sub128( 0, 0, aSig0, aSig1, &aSig0, &aSig1 ); - return - normalizeRoundAndPackFloat128( aSign ^ zSign, bExp - 4, aSig0, aSig1 ); - -} - -/* -------------------------------------------------------------------------------- -Returns the square root of the quadruple-precision floating-point value `a'. -The operation is performed according to the IEC/IEEE Standard for Binary -Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -float128 float128_sqrt( float128 a ) -{ - flag aSign; - int32 aExp, zExp; - bits64 aSig0, aSig1, zSig0, zSig1, zSig2, doubleZSig0; - bits64 rem0, rem1, rem2, rem3, term0, term1, term2, term3; - float128 z; - - aSig1 = extractFloat128Frac1( a ); - aSig0 = extractFloat128Frac0( a ); - aExp = extractFloat128Exp( a ); - aSign = extractFloat128Sign( a ); - if ( aExp == 0x7FFF ) { - if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, a ); - if ( ! aSign ) return a; - goto invalid; - } - if ( aSign ) { - if ( ( aExp | aSig0 | aSig1 ) == 0 ) return a; - invalid: - float_raise( float_flag_invalid ); - z.low = float128_default_nan_low; - z.high = float128_default_nan_high; - return z; - } - if ( aExp == 0 ) { - if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( 0, 0, 0, 0 ); - normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 ); - } - zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFE; - aSig0 |= LIT64( 0x0001000000000000 ); - zSig0 = estimateSqrt32( aExp, aSig0>>17 ); - shortShift128Left( aSig0, aSig1, 13 - ( aExp & 1 ), &aSig0, &aSig1 ); - zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0<<32 ) + ( zSig0<<30 ); - doubleZSig0 = zSig0<<1; - mul64To128( zSig0, zSig0, &term0, &term1 ); - sub128( aSig0, aSig1, term0, term1, &rem0, &rem1 ); - while ( (sbits64) rem0 < 0 ) { - --zSig0; - doubleZSig0 -= 2; - add128( rem0, rem1, zSig0>>63, doubleZSig0 | 1, &rem0, &rem1 ); - } - zSig1 = estimateDiv128To64( rem1, 0, doubleZSig0 ); - if ( ( zSig1 & 0x1FFF ) <= 5 ) { - if ( zSig1 == 0 ) zSig1 = 1; - mul64To128( doubleZSig0, zSig1, &term1, &term2 ); - sub128( rem1, 0, term1, term2, &rem1, &rem2 ); - mul64To128( zSig1, zSig1, &term2, &term3 ); - sub192( rem1, rem2, 0, 0, term2, term3, &rem1, &rem2, &rem3 ); - while ( (sbits64) rem1 < 0 ) { - --zSig1; - shortShift128Left( 0, zSig1, 1, &term2, &term3 ); - term3 |= 1; - term2 |= doubleZSig0; - add192( rem1, rem2, rem3, 0, term2, term3, &rem1, &rem2, &rem3 ); - } - zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 ); - } - shift128ExtraRightJamming( zSig0, zSig1, 0, 14, &zSig0, &zSig1, &zSig2 ); - return roundAndPackFloat128( 0, zExp, zSig0, zSig1, zSig2 ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is equal to -the corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float128_eq( float128 a, float128 b ) -{ - - if ( ( ( extractFloat128Exp( a ) == 0x7FFF ) - && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) ) - || ( ( extractFloat128Exp( b ) == 0x7FFF ) - && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) ) - ) { - if ( float128_is_signaling_nan( a ) - || float128_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - return - ( a.low == b.low ) - && ( ( a.high == b.high ) - || ( ( a.low == 0 ) - && ( (bits64) ( ( a.high | b.high )<<1 ) == 0 ) ) - ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is less than -or equal to the corresponding value `b', and 0 otherwise. The comparison -is performed according to the IEC/IEEE Standard for Binary Floating-Point -Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float128_le( float128 a, float128 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat128Exp( a ) == 0x7FFF ) - && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) ) - || ( ( extractFloat128Exp( b ) == 0x7FFF ) - && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloat128Sign( a ); - bSign = extractFloat128Sign( b ); - if ( aSign != bSign ) { - return - aSign - || ( ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - == 0 ); - } - return - aSign ? le128( b.high, b.low, a.high, a.low ) - : le128( a.high, a.low, b.high, b.low ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is less than -the corresponding value `b', and 0 otherwise. The comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float128_lt( float128 a, float128 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat128Exp( a ) == 0x7FFF ) - && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) ) - || ( ( extractFloat128Exp( b ) == 0x7FFF ) - && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - aSign = extractFloat128Sign( a ); - bSign = extractFloat128Sign( b ); - if ( aSign != bSign ) { - return - aSign - && ( ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - != 0 ); - } - return - aSign ? lt128( b.high, b.low, a.high, a.low ) - : lt128( a.high, a.low, b.high, b.low ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is equal to -the corresponding value `b', and 0 otherwise. The invalid exception is -raised if either operand is a NaN. Otherwise, the comparison is performed -according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float128_eq_signaling( float128 a, float128 b ) -{ - - if ( ( ( extractFloat128Exp( a ) == 0x7FFF ) - && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) ) - || ( ( extractFloat128Exp( b ) == 0x7FFF ) - && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) ) - ) { - float_raise( float_flag_invalid ); - return 0; - } - return - ( a.low == b.low ) - && ( ( a.high == b.high ) - || ( ( a.low == 0 ) - && ( (bits64) ( ( a.high | b.high )<<1 ) == 0 ) ) - ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is less than -or equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not -cause an exception. Otherwise, the comparison is performed according to the -IEC/IEEE Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float128_le_quiet( float128 a, float128 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat128Exp( a ) == 0x7FFF ) - && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) ) - || ( ( extractFloat128Exp( b ) == 0x7FFF ) - && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) ) - ) { - if ( float128_is_signaling_nan( a ) - || float128_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloat128Sign( a ); - bSign = extractFloat128Sign( b ); - if ( aSign != bSign ) { - return - aSign - || ( ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - == 0 ); - } - return - aSign ? le128( b.high, b.low, a.high, a.low ) - : le128( a.high, a.low, b.high, b.low ); - -} - -/* -------------------------------------------------------------------------------- -Returns 1 if the quadruple-precision floating-point value `a' is less than -the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an -exception. Otherwise, the comparison is performed according to the IEC/IEEE -Standard for Binary Floating-Point Arithmetic. -------------------------------------------------------------------------------- -*/ -flag float128_lt_quiet( float128 a, float128 b ) -{ - flag aSign, bSign; - - if ( ( ( extractFloat128Exp( a ) == 0x7FFF ) - && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) ) - || ( ( extractFloat128Exp( b ) == 0x7FFF ) - && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) ) - ) { - if ( float128_is_signaling_nan( a ) - || float128_is_signaling_nan( b ) ) { - float_raise( float_flag_invalid ); - } - return 0; - } - aSign = extractFloat128Sign( a ); - bSign = extractFloat128Sign( b ); - if ( aSign != bSign ) { - return - aSign - && ( ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low ) - != 0 ); - } - return - aSign ? lt128( b.high, b.low, a.high, a.low ) - : lt128( a.high, a.low, b.high, b.low ); - -} - -#endif - - -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) - -/* - * These two routines are not part of the original softfloat distribution. - * - * They are based on the corresponding conversions to integer but return - * unsigned numbers instead since these functions are required by GCC. - * - * Added by Mark Brinicombe 27/09/97 - * - * float64 version overhauled for SoftFloat 2a [bjh21 2000-07-15] - */ - -/* -------------------------------------------------------------------------------- -Returns the result of converting the double-precision floating-point value -`a' to the 32-bit unsigned integer format. The conversion is -performed according to the IEC/IEEE Standard for Binary Floating-point -Arithmetic, except that the conversion is always rounded toward zero. If -`a' is a NaN, the largest positive integer is returned. If the conversion -overflows, the largest integer positive is returned. -------------------------------------------------------------------------------- -*/ -uint32 float64_to_uint32_round_to_zero( float64 a ) -{ - flag aSign; - int16 aExp, shiftCount; - bits64 aSig, savedASig; - uint32 z; - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - - if (aSign) { - float_raise( float_flag_invalid ); - return(0); - } - - if ( 0x41E < aExp ) { - float_raise( float_flag_invalid ); - return 0xffffffff; - } - else if ( aExp < 0x3FF ) { - if ( aExp || aSig ) float_set_inexact(); - return 0; - } - aSig |= LIT64( 0x0010000000000000 ); - shiftCount = 0x433 - aExp; - savedASig = aSig; - aSig >>= shiftCount; - z = aSig; - if ( ( aSig<>( - shiftCount ); - if ( aSig<<( shiftCount & 31 ) ) { - float_set_inexact(); - } - return z; - -} - -#endif - -#endif /* _STANDALONE */ diff --git a/sys/lib/libkern/softfloat.h b/sys/lib/libkern/softfloat.h deleted file mode 100644 index 94637c9a6..000000000 --- a/sys/lib/libkern/softfloat.h +++ /dev/null @@ -1,363 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.4 2008/04/28 20:24:06 martin Exp $ */ - -/* This is a derivative work. */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Ross Harvey. - * - * 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. - */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -#include - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include -#include -#else -#include "sys/inttypes.h" -#include "machine/ieeefp.h" -#endif -#include - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -/* #define FLOAT128 */ - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef u_int32_t float32; -typedef u_int64_t float64; -#ifdef FLOATX80 -typedef struct { -#if BYTE_ORDER == BIG_ENDIAN - u_int16_t high; - u_int64_t low; -#else - u_int64_t low; - u_int16_t high; -#endif -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - u_int64_t high, low; -} float128; -#endif - -/* - * Some of the global variables that used to be here have been removed for - * fairly obvious (defopt-MULTIPROCESSOR) reasons. The rest (which don't - * change dynamically) will be removed later. [ross] - */ - -#define float_rounding_mode() fpgetround() - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ - -extern int float_detect_tininess; -enum { - float_tininess_after_rounding = 1, - float_tininess_before_rounding = 0 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ - -enum { - float_round_nearest_even = FP_RN, - float_round_to_zero = FP_RZ, - float_round_down = FP_RM, - float_round_up = FP_RP -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ - -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int ); -float64 int32_to_float64( int ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */ -float32 int64_to_float32( int64_t ); -float64 int64_to_float64( int64_t ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( int64_t ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( int64_t ); -#endif -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -int64_t float32_to_int64( float32 ); -int64_t float32_to_int64_round_to_zero( float32 ); -#endif -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -int float32_eq( float32, float32 ); -int float32_le( float32, float32 ); -int float32_lt( float32, float32 ); -int float32_eq_signaling( float32, float32 ); -int float32_le_quiet( float32, float32 ); -int float32_lt_quiet( float32, float32 ); -#ifndef SOFTFLOAT_FOR_GCC -int float32_is_signaling_nan( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -int64_t float64_to_int64( float64 ); -int64_t float64_to_int64_round_to_zero( float64 ); -#endif -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -#define float64_default_nan 0xFFF8000000000000LL - -static __inline int -float64_is_nan(float64 a) -{ - return 0xFFE0000000000000LL < a << 1; -} - -static __inline int -float64_is_signaling_nan(float64 a) -{ - return (a >> 51 & 0xFFF) == 0xFFE && (a & 0x0007FFFFFFFFFFFFLL); -} - -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -int float64_eq( float64, float64 ); -int float64_le( float64, float64 ); -int float64_lt( float64, float64 ); -int float64_eq_signaling( float64, float64 ); -int float64_le_quiet( float64, float64 ); -int float64_lt_quiet( float64, float64 ); -#ifndef SOFTFLOAT_FOR_GCC -int float64_is_signaling_nan( float64 ); -#endif - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -int64_t floatx80_to_int64( floatx80 ); -int64_t floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -int floatx80_eq( floatx80, floatx80 ); -int floatx80_le( floatx80, floatx80 ); -int floatx80_lt( floatx80, floatx80 ); -int floatx80_eq_signaling( floatx80, floatx80 ); -int floatx80_le_quiet( floatx80, floatx80 ); -int floatx80_lt_quiet( floatx80, floatx80 ); -int floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -int64_t float128_to_int64( float128 ); -int64_t float128_to_int64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -int float128_eq( float128, float128 ); -int float128_le( float128, float128 ); -int float128_lt( float128, float128 ); -int float128_eq_signaling( float128, float128 ); -int float128_le_quiet( float128, float128 ); -int float128_lt_quiet( float128, float128 ); -int float128_is_signaling_nan( float128 ); - -#endif - diff --git a/sys/lib/libkern/ulmax.c b/sys/lib/libkern/ulmax.c deleted file mode 100644 index 61f81d2e6..000000000 --- a/sys/lib/libkern/ulmax.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: ulmax.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1991 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. - * - * @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - */ - -#define LIBKERN_INLINE -#include - -unsigned long -ulmax(unsigned long a, unsigned long b) -{ - return (a > b ? a : b); -} diff --git a/sys/lib/libkern/ulmin.c b/sys/lib/libkern/ulmin.c deleted file mode 100644 index c1afddd85..000000000 --- a/sys/lib/libkern/ulmin.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: ulmin.c,v 1.6 2009/03/14 21:04:24 dsl Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1991 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. - * - * @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - */ - -#define LIBKERN_INLINE -#include - -unsigned long -ulmin(unsigned long a, unsigned long b) -{ - return (a < b ? a : b); -} diff --git a/sys/lib/libsa/Makefile b/sys/lib/libsa/Makefile index 0eb99a79f..2d7b7cbd5 100644 --- a/sys/lib/libsa/Makefile +++ b/sys/lib/libsa/Makefile @@ -21,7 +21,11 @@ CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAMISCCPPFLAGS} \ .include +.ifndef __MINIX .PATH.c: ${SADIR} ${.PARSEDIR}/../../../common/lib/libc/string +.else +.PATH.c: ${SADIR} ${.PARSEDIR}/../../../common/lib/libc/md +.endif # stand routines SRCS+= alloc.c errno.c exit.c files.c \ @@ -29,7 +33,7 @@ SRCS+= alloc.c errno.c exit.c files.c \ panic.c printf.c qsort.c snprintf.c sprintf.c strerror.c \ subr_prf.c twiddle.c vsprintf.c checkpasswd.c -.if (${MACHINE_CPU} != "mips") +.if (${MACHINE_CPU} != "mips") && !defined(__MINIX) SRCS+= exec.c .endif @@ -37,7 +41,7 @@ SRCS+= exec.c .if ${MACHINE_ARCH} != "i386" && ${MACHINE_ARCH} != "x86_64" SRCS+= memcmp.c memcpy.c memmove.c memset.c strchr.c .endif -SRCS+= bcopy.c bzero.c # Remove me eventually. +##SRCS+= bcopy.c bzero.c # Remove me eventually. # io routines SRCS+= closeall.c dev.c disklabel.c dkcksum.c ioctl.c nullfs.c stat.c fstat.c @@ -51,9 +55,10 @@ SRCS+= ls.c .endif .if (${SA_USE_LOADFILE} == "yes") -SRCS+= loadfile.c loadfile_ecoff.c loadfile_elf32.c lookup_elf32.c \ - loadfile_elf64.c lookup_elf64.c -.if (${MACHINE_CPU} != "mips") +#SRCS+= loadfile.c loadfile_ecoff.c loadfile_elf32.c lookup_elf32.c \ +# loadfile_elf64.c lookup_elf64.c +SRCS+= loadfile.c loadfile_elf32.c loadfile_elf64.c +.if (${MACHINE_CPU} != "mips") && !defined(__MINIX) SRCS+= loadfile_aout.c .endif .endif @@ -69,8 +74,10 @@ SRCS+= bootp.c rarp.c bootparam.c SRCS+= nfs.c tftp.c .endif +.ifndef __MINIX_w SRCS+= ffsv1.c ffsv2.c SRCS+= lfsv1.c lfsv2.c +.endif SRCS+= cd9660.c SRCS+= ustarfs.c SRCS+= dosfs.c @@ -79,6 +86,14 @@ SRCS+= minixfs3.c # for historic compatibility ufs == ffsv1 SRCS+= ufs.c +.if defined(__MINIX) +# NetBSD has it in libkern, MINIX lacks it +SRCS+= xlat_mbr_fstype.c + +# NetBSD has it in libkern, MINIX has it in libc but not libminc... +SRCS+= md5c.c +.endif + # only needed during build libinstall:: diff --git a/sys/lib/libsa/cread.c b/sys/lib/libsa/cread.c index 808690cef..2eac7b2b1 100644 --- a/sys/lib/libsa/cread.c +++ b/sys/lib/libsa/cread.c @@ -95,8 +95,12 @@ void zmemcpy(unsigned char *, unsigned char *, unsigned int); #ifndef ETHER_CRC_POLY_LE #define ETHER_CRC_POLY_LE 0xedb88320 #endif +#ifndef __minix uint32_t crc32(uint32_t crc, const uint8_t *const buf, size_t len) +#else +uLong crc32(uLong crc, const Bytef *buf, uInt len) +#endif { uint32_t c, carry; size_t i, j; diff --git a/sys/lib/libsa/minixfs3.h b/sys/lib/libsa/minixfs3.h index aef8a54f6..0a9ca0353 100644 --- a/sys/lib/libsa/minixfs3.h +++ b/sys/lib/libsa/minixfs3.h @@ -33,9 +33,11 @@ FS_DEF(minixfs3); +#ifndef __minix typedef uint32_t zone_t; typedef uint16_t zone1_t; typedef uint32_t block_t; +#endif #define NR_DZONES 7 /* # direct zone numbers in an inode */ #define NR_TZONES 10 /* total # zone numbers in an inode */ diff --git a/sys/lib/libsa/saerrno.h b/sys/lib/libsa/saerrno.h index f0a70fb7d..bf305f665 100644 --- a/sys/lib/libsa/saerrno.h +++ b/sys/lib/libsa/saerrno.h @@ -33,6 +33,10 @@ #include +#ifndef ELAST +#define ELAST 256 /* XXX temporary hack... need revisiting! */ +#endif + extern int errno; /* special stand error codes */ diff --git a/sys/lib/libkern/xlat_mbr_fstype.c b/sys/lib/libsa/xlat_mbr_fstype.c similarity index 93% rename from sys/lib/libkern/xlat_mbr_fstype.c rename to sys/lib/libsa/xlat_mbr_fstype.c index 4151770db..847ec867c 100644 --- a/sys/lib/libkern/xlat_mbr_fstype.c +++ b/sys/lib/libsa/xlat_mbr_fstype.c @@ -1,4 +1,4 @@ -/* $NetBSD: xlat_mbr_fstype.c,v 1.7 2008/04/28 20:24:06 martin Exp $ */ +/* $NetBSD: xlat_mbr_fstype.c,v 1.8 2012/01/16 18:47:57 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0,"$NetBSD: xlat_mbr_fstype.c,v 1.7 2008/04/28 20:24:06 martin Exp $"); +__KERNEL_RCSID(0,"$NetBSD: xlat_mbr_fstype.c,v 1.8 2012/01/16 18:47:57 christos Exp $"); #include diff --git a/sys/lib/libz/Makefile b/sys/lib/libz/Makefile new file mode 100644 index 000000000..ebcfe5e52 --- /dev/null +++ b/sys/lib/libz/Makefile @@ -0,0 +1,38 @@ +# $NetBSD: Makefile,v 1.18 2011/10/30 00:28:57 mrg Exp $ + +LIB= z +LIBISPRIVATE= yes + +.ifndef __MINIX +ZDISTDIR:=${.PARSEDIR}/../../../common/dist/zlib +.else +ZDISTDIR:=${.PARSEDIR}/../../../lib/libz +.endif + +CPPFLAGS+= -I${ZDISTDIR} ${ZCPPFLAGS} ${ZMISCCPPFLAGS} + +.PATH.c: ${ZDISTDIR} ${.PARSEDIR} + +# files to be copied down from libz. +LIBZSRCS= adler32.c compress.c deflate.c infback.c inffast.c \ + inflate.c inftrees.c trees.c uncompr.c +LIBZHDRS= deflate.h inffast.h inffixed.h inflate.h inftrees.h \ + trees.h zconf.h zlib.h + +# Other stuff +SRCS= ${LIBZSRCS} zalloc.c + +# Files to clean up +CLEANFILES+= lib${LIB}.o + +.undef DESTDIR +.include + +lib${LIB}.o:: ${OBJS} + @echo building standard ${LIB} library + @rm -f lib${LIB}.o + @${LD} -r -o lib${LIB}.o `lorder ${OBJS} | tsort` + +.if defined(HAVE_GCC) && ${HAVE_GCC} >= 45 && ${MACHINE_ARCH} == "vax" +COPTS.inftrees.c+= -O0 +.endif diff --git a/sys/lib/libz/Makefile.inc b/sys/lib/libz/Makefile.inc new file mode 100644 index 000000000..12e010838 --- /dev/null +++ b/sys/lib/libz/Makefile.inc @@ -0,0 +1,87 @@ +# $NetBSD: Makefile.inc,v 1.13 2005/12/11 12:24:46 christos Exp $ +# +# Configuration variables (default values are below): +# +# S must be set to the top of the 'sys' tree. +# ZDST may be set to the location of the directory where library +# objects are to be built. Defaults to ${.OBJDIR}/lib/z. +# Z_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'. +# ZMISCCPPFLAGS +# Miscellaneous cpp flags to be passed to the library's Makefile +# when building. +# ZMISCMAKEFLAGS +# 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: +ZDST?= ${.OBJDIR}/lib/z +Z_AS?= library +ZDOTDIR?= ../../../../../. + +.ifndef __MINIX +ZDIR= ${S:S@^.@${ZDOTDIR}@:Q}/lib/libz +.else +ZDIR= ${.CURDIR}/${ZDOTDIR}/lib/libz +.endif +.if (${Z_AS} == "obj") +ZLIB= ${ZDST}/libz.o +ZLIB_PROF= ${ZDST}/libz.po +.else +ZLIB= ${ZDST}/libz.a +ZLIB_PROF= ${ZDST}/libz_p.a +.endif + +ZMAKE= \ + cd ${ZDST} && ${MAKE} -f ${ZDIR:Q}/Makefile \ + ZDIR=${ZDIR: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} \ + ZCPPFLAGS=${CPPFLAGS:S@^-I.@-I${ZDOTDIR}@g:Q} \ + ZMISCCPPFLAGS=${ZMISCCPPFLAGS:Q} \ + ${ZMISCMAKEFLAGS} + +${ZLIB}: .NOTMAIN .MAKE __always_make_zlib + @echo making sure the z library is up to date... +.if (${Z_AS} == "library") + @${ZMAKE} libz.a +.else + @${ZMAKE} libz.o +.endif + +${ZLIB_PROF}: .NOTMAIN .MAKE __always_make_zlib + @echo making sure the profiled z library is up to date... +.if (${Z_AS} == "library") + @${ZMAKE} libz_p.a +.else + @${ZMAKE} libz.po +.endif + +clean: .NOTMAIN cleanzlib +cleanzlib: .NOTMAIN + @echo cleaning the z library objects + @if [ -d "${ZDST}" ]; then ${ZMAKE} clean; fi + +cleandir distclean: .NOTMAIN cleandirzlib +cleandirzlib: .NOTMAIN + @echo cleandiring the z library objects + @if [ -d "${ZDST}" ]; then ${ZMAKE} cleandir; fi + +dependall depend: .NOTMAIN dependzlib +dependzlib: .NOTMAIN .MAKE __always_make_zlib + @echo depending the z library objects + @${ZMAKE} depend + +__always_make_zlib: .NOTMAIN + @mkdir -p ${ZDST} + +.PHONY: __always_make_zlib +.PHONY: cleanzlib cleandirzlib dependzlib diff --git a/sys/lib/libz/libz.h b/sys/lib/libz/libz.h new file mode 100644 index 000000000..34497d749 --- /dev/null +++ b/sys/lib/libz/libz.h @@ -0,0 +1,6 @@ +#ifndef _LIB_LIBZ_LIBZ_H_ +#define _LIB_LIBZ_LIBZ_H_ + +#include + +#endif /* _LIB_LIBZ_LIBZ_H_ */ diff --git a/sys/lib/libkern/arch/x86_64/scanc.S b/sys/lib/libz/zalloc.c similarity index 71% rename from sys/lib/libkern/arch/x86_64/scanc.S rename to sys/lib/libz/zalloc.c index 93f4e1254..6cd598ad3 100644 --- a/sys/lib/libkern/arch/x86_64/scanc.S +++ b/sys/lib/libz/zalloc.c @@ -1,11 +1,11 @@ -/* $NetBSD: scanc.S,v 1.2 2008/04/28 20:24:06 martin Exp $ */ +/* $NetBSD: zalloc.c,v 1.7 2009/03/18 16:00:21 cegger Exp $ */ /*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum. + * by Simon Burge. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,27 +29,30 @@ * POSSIBILITY OF SUCH DAMAGE. */ + +#include "zutil.h" +#include + /* - * Adapted for NetBSD/x86_64 by Frank van der Linden + * A simple implementation of zcalloc and zcfree in terms of the libsa + * alloc and free. */ -#include +voidpf +zcalloc(voidpf opaque, unsigned int items, unsigned int size) +{ + unsigned int totalsize; -ENTRY(scanc) - movq %rdx,%r11 - movb %cl,%dl - movl %edi,%ecx - testl %ecx,%ecx - jz 2f - movq %r11,%rdi - xorq %rax,%rax - cld -1: - lodsb - testb %dl,(%rax,%rdi) - jnz 2f - decl %ecx - jnz 1b -2: - movl %ecx,%eax - ret + totalsize = items * size; + opaque = alloc(totalsize); + if (opaque != NULL) + memset(opaque, 0, totalsize); + return opaque; +} + +void +zcfree(voidpf opaque, voidpf ptr) +{ + + dealloc(ptr, 0); /* XXX: size not known */ +} diff --git a/sys/machine/bootinfo.h b/sys/machine/bootinfo.h new file mode 100644 index 000000000..0f1371bfc --- /dev/null +++ b/sys/machine/bootinfo.h @@ -0,0 +1,3 @@ +/* $NetBSD: bootinfo.h,v 1.14 2003/02/26 21:28:59 fvdl Exp $ */ + +#include diff --git a/sys/machine/cdefs.h b/sys/machine/cdefs.h new file mode 100644 index 000000000..3da516304 --- /dev/null +++ b/sys/machine/cdefs.h @@ -0,0 +1,22 @@ +/* $NetBSD: cdefs.h,v 1.8 2011/06/16 13:27:59 joerg Exp $ */ + +#ifndef _I386_CDEFS_H_ +#define _I386_CDEFS_H_ + +#if defined(_STANDALONE) +#ifdef __PCC__ +#define __compactcall +#else +#define __compactcall __attribute__((__regparm__(3))) +#endif +#endif + +#ifdef __minix +#ifndef __ELF__ +#define __LEADING_UNDERSCORE +#endif +#else /* !__minix */ +/* No arch-specific cdefs. */ +#endif + +#endif /* !_I386_CDEFS_H_ */ diff --git a/sys/lib/libkern/arch/sh3/udivsi3.S b/sys/machine/cpu.h similarity index 55% rename from sys/lib/libkern/arch/sh3/udivsi3.S rename to sys/machine/cpu.h index 18a65e5a0..c5864a35f 100644 --- a/sys/lib/libkern/arch/sh3/udivsi3.S +++ b/sys/machine/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: udivsi3.S,v 1.11 2011/08/05 01:59:39 uwe Exp $ */ +/* $NetBSD: cpu.h,v 1.178 2011/12/30 17:57:49 cherry Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -31,56 +31,65 @@ * 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 + * @(#)cpu.h 5.4 (Berkeley) 5/9/91 */ -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: udivsi3.S,v 1.11 2011/08/05 01:59:39 uwe Exp $") +#ifndef _I386_CPU_H_ +#define _I386_CPU_H_ + +#include + +#ifdef _KERNEL + +#if defined(__GNUC__) && !defined(_MODULE) +static struct cpu_info *x86_curcpu(void); +static lwp_t *x86_curlwp(void); + +__inline static struct cpu_info * __unused +x86_curcpu(void) +{ + struct cpu_info *ci; + + __asm volatile("movl %%fs:%1, %0" : + "=r" (ci) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self))); + return ci; +} + +__inline static lwp_t * __attribute__ ((const)) +x86_curlwp(void) +{ + lwp_t *l; + + __asm volatile("movl %%fs:%1, %0" : + "=r" (l) : + "m" + (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp))); + return l; +} + +__inline static void __unused +cpu_set_curpri(int pri) +{ + + __asm volatile( + "movl %1, %%fs:%0" : + "=m" (*(struct cpu_info *)offsetof(struct cpu_info, ci_schedstate.spc_curpriority)) : + "r" (pri) + ); +} #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 R4. - * - * See the definition of "udivsi3_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) - */ +#define CLKF_USERMODE(frame) USERMODE((frame)->cf_if.if_cs, (frame)->cf_if.if_eflags) +#define CLKF_PC(frame) ((frame)->cf_if.if_eip) +#define CLKF_INTR(frame) (curcpu()->ci_idepth > 0) +#define LWP_PC(l) ((l)->l_md.md_regs->tf_eip) +#ifdef PAE +void cpu_alloc_l3_page(struct cpu_info *); +#endif /* PAE */ -#ifdef __ELF__ - .hidden __udivsi3 -#endif +#endif /* _KERNEL */ - -/* r0 <= r4 / r5 */ -NENTRY(__udivsi3) - tst r5, r5 - bt .L_div_by_zero - - mov #0, r0 - div0u -#define DIVSTEP rotcl r4; 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 r4 - - rts - mov r4, r0 - -.L_div_by_zero: - rts - mov #0, r0 +#endif /* !_I386_CPU_H_ */ diff --git a/sys/machine/loadfile_machdep.h b/sys/machine/loadfile_machdep.h new file mode 100644 index 000000000..221d543f8 --- /dev/null +++ b/sys/machine/loadfile_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: loadfile_machdep.h,v 1.9 2007/10/17 19:54:57 garbled Exp $ */ + +#include diff --git a/sys/machine/multiboot.h b/sys/machine/multiboot.h new file mode 100644 index 000000000..4f5d85fdc --- /dev/null +++ b/sys/machine/multiboot.h @@ -0,0 +1,203 @@ +/* $NetBSD: multiboot.h,v 1.8 2009/02/22 18:05:42 ahoka Exp $ */ + +/*- + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal. + * + * 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. + */ + +/* --------------------------------------------------------------------- */ + +/* + * Multiboot header structure. + */ +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001 +#define MULTIBOOT_HEADER_WANT_MEMORY 0x00000002 +#define MULTIBOOT_HEADER_HAS_VBE 0x00000004 +#define MULTIBOOT_HEADER_HAS_ADDR 0x00010000 + +#if !defined(_LOCORE) +struct multiboot_header { + uint32_t mh_magic; + uint32_t mh_flags; + uint32_t mh_checksum; + + /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ + paddr_t mh_header_addr; + paddr_t mh_load_addr; + paddr_t mh_load_end_addr; + paddr_t mh_bss_end_addr; + paddr_t mh_entry_addr; + + /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. */ + uint32_t mh_mode_type; + uint32_t mh_width; + uint32_t mh_height; + uint32_t mh_depth; +}; +#endif /* !defined(_LOCORE) */ + +/* + * Symbols defined in locore.S. + */ +#if !defined(_LOCORE) && defined(_KERNEL) +extern struct multiboot_header *Multiboot_Header; +#endif /* !defined(_LOCORE) && defined(_KERNEL) */ + +/* --------------------------------------------------------------------- */ + +/* + * Multiboot information structure. + */ +#define MULTIBOOT_INFO_MAGIC 0x2BADB002 +#define MULTIBOOT_INFO_HAS_MEMORY 0x00000001 +#define MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002 +#define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004 +#define MULTIBOOT_INFO_HAS_MODS 0x00000008 +#define MULTIBOOT_INFO_HAS_AOUT_SYMS 0x00000010 +#define MULTIBOOT_INFO_HAS_ELF_SYMS 0x00000020 +#define MULTIBOOT_INFO_HAS_MMAP 0x00000040 +#define MULTIBOOT_INFO_HAS_DRIVES 0x00000080 +#define MULTIBOOT_INFO_HAS_CONFIG_TABLE 0x00000100 +#define MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200 +#define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400 +#define MULTIBOOT_INFO_HAS_VBE 0x00000800 + +#if !defined(_LOCORE) +struct multiboot_info { + uint32_t mi_flags; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MEMORY. */ + uint32_t mi_mem_lower; + uint32_t mi_mem_upper; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_BOOT_DEVICE. */ + uint8_t mi_boot_device_part3; + uint8_t mi_boot_device_part2; + uint8_t mi_boot_device_part1; + uint8_t mi_boot_device_drive; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CMDLINE. */ + char * mi_cmdline; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MODS. */ + uint32_t mi_mods_count; + vaddr_t mi_mods_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_{AOUT,ELF}_SYMS. */ + uint32_t mi_elfshdr_num; + uint32_t mi_elfshdr_size; + vaddr_t mi_elfshdr_addr; + uint32_t mi_elfshdr_shndx; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_MMAP. */ + uint32_t mi_mmap_length; + vaddr_t mi_mmap_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_DRIVES. */ + uint32_t mi_drives_length; + vaddr_t mi_drives_addr; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_CONFIG_TABLE. */ + void * unused_mi_config_table; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_LOADER_NAME. */ + char * mi_loader_name; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_APM. */ + void * unused_mi_apm_table; + + /* Valid if mi_flags sets MULTIBOOT_INFO_HAS_VBE. */ + void * unused_mi_vbe_control_info; + void * unused_mi_vbe_mode_info; + paddr_t unused_mi_vbe_interface_seg; + paddr_t unused_mi_vbe_interface_off; + uint32_t unused_mi_vbe_interface_len; +}; + +/* --------------------------------------------------------------------- */ + +/* + * Drive information. This describes an entry in the drives table as + * pointed to by mi_drives_addr. + */ +struct multiboot_drive { + uint32_t md_length; + uint8_t md_number; + uint8_t md_mode; + uint16_t md_cylinders; + uint8_t md_heads; + uint8_t md_sectors; + + /* The variable-sized 'ports' field comes here, so this structure + * can be longer. */ +}; + +/* --------------------------------------------------------------------- */ + +/* + * Memory mapping. This describes an entry in the memory mappings table + * as pointed to by mi_mmap_addr. + * + * Be aware that mm_size specifies the size of all other fields *except* + * for mm_size. In order to jump between two different entries, you + * have to count mm_size + 4 bytes. + */ +struct multiboot_mmap { + uint32_t mm_size; + uint64_t mm_base_addr; + uint64_t mm_length; + uint32_t mm_type; +}; + +/* + * Modules. This describes an entry in the modules table as pointed + * to by mi_mods_addr. + */ + +struct multiboot_module { + uint32_t mmo_start; + uint32_t mmo_end; + char * mmo_string; + uint32_t mmo_reserved; +}; + +#endif /* !defined(_LOCORE) */ + +/* --------------------------------------------------------------------- */ + +/* + * Prototypes for public functions defined in multiboot.c. + */ +#if !defined(_LOCORE) && defined(_KERNEL) +void multiboot_pre_reloc(struct multiboot_info *); +void multiboot_post_reloc(void); +void multiboot_print_info(void); +bool multiboot_ksyms_addsyms_elf(void); +#endif /* !defined(_LOCORE) */ + +/* --------------------------------------------------------------------- */ diff --git a/sys/machine/pio.h b/sys/machine/pio.h new file mode 100644 index 000000000..20b2ebb30 --- /dev/null +++ b/sys/machine/pio.h @@ -0,0 +1,3 @@ +/* $NetBSD: pio.h,v 1.20 2003/02/26 21:29:02 fvdl Exp $ */ + +#include diff --git a/sys/machine/rwlock.h b/sys/machine/rwlock.h new file mode 100644 index 000000000..df5837bfb --- /dev/null +++ b/sys/machine/rwlock.h @@ -0,0 +1,3 @@ +/* $NetBSD: rwlock.h,v 1.2 2007/02/09 21:55:05 ad Exp $ */ + +#include diff --git a/sys/net/radix.h b/sys/net/radix.h new file mode 100644 index 000000000..08d46a00a --- /dev/null +++ b/sys/net/radix.h @@ -0,0 +1,157 @@ +/* $NetBSD: radix.h,v 1.22 2009/05/27 17:46:50 pooka Exp $ */ + +/* + * Copyright (c) 1988, 1989, 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 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. + * + * @(#)radix.h 8.2 (Berkeley) 10/31/94 + */ + +#ifndef _NET_RADIX_H_ +#define _NET_RADIX_H_ + +/* + * Radix search tree node layout. + */ + +struct radix_node { + struct radix_mask *rn_mklist; /* list of masks contained in subtree */ + struct radix_node *rn_p; /* parent */ + short rn_b; /* bit offset; -1-index(netmask) */ + char rn_bmask; /* node: mask for bit test*/ + u_char rn_flags; /* enumerated next */ +#define RNF_NORMAL 1 /* leaf contains normal route */ +#define RNF_ROOT 2 /* leaf is root leaf for tree */ +#define RNF_ACTIVE 4 /* This node is alive (for rtfree) */ + union { + struct { /* leaf only data: */ + const char *rn_Key; /* object of search */ + const char *rn_Mask; /* netmask, if present */ + struct radix_node *rn_Dupedkey; + } rn_leaf; + struct { /* node only data: */ + int rn_Off; /* where to start compare */ + struct radix_node *rn_L;/* progeny */ + struct radix_node *rn_R;/* progeny */ + } rn_node; + } rn_u; +#ifdef RN_DEBUG + int rn_info; + struct radix_node *rn_twin; + struct radix_node *rn_ybro; +#endif +}; + +#define rn_dupedkey rn_u.rn_leaf.rn_Dupedkey +#define rn_key rn_u.rn_leaf.rn_Key +#define rn_mask rn_u.rn_leaf.rn_Mask +#define rn_off rn_u.rn_node.rn_Off +#define rn_l rn_u.rn_node.rn_L +#define rn_r rn_u.rn_node.rn_R + +/* + * Annotations to tree concerning potential routes applying to subtrees. + */ + +struct radix_mask { + short rm_b; /* bit offset; -1-index(netmask) */ + char rm_unused; /* cf. rn_bmask */ + u_char rm_flags; /* cf. rn_flags */ + struct radix_mask *rm_mklist; /* more masks to try */ + union { + const char *rmu_mask; /* the mask */ + struct radix_node *rmu_leaf; /* for normal routes */ + } rm_rmu; + int rm_refs; /* # of references to this struct */ +}; + +#define rm_mask rm_rmu.rmu_mask +#define rm_leaf rm_rmu.rmu_leaf /* extra field would make 32 bytes */ + +#define MKGet(m) {\ + if (rn_mkfreelist) {\ + m = rn_mkfreelist; \ + rn_mkfreelist = (m)->rm_mklist; \ + } else \ + R_Malloc(m, struct radix_mask *, sizeof (*(m))); }\ + +#define MKFree(m) { (m)->rm_mklist = rn_mkfreelist; rn_mkfreelist = (m);} + +struct radix_node_head { + struct radix_node *rnh_treetop; + int rnh_addrsize; /* permit, but not require fixed keys */ + int rnh_pktsize; /* permit, but not require fixed keys */ + struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ + (const void *v, const void *mask, + struct radix_node_head *head, struct radix_node nodes[]); + struct radix_node *(*rnh_addpkt) /* add based on packet hdr */ + (const void *v, const void *mask, + struct radix_node_head *head, struct radix_node nodes[]); + struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */ + (const void *v, const void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */ + (const void *v, const void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */ + (const void *v, struct radix_node_head *head); + struct radix_node *(*rnh_lookup) /* locate based on sockaddr */ + (const void *v, const void *mask, struct radix_node_head *head); + struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */ + (const void *v, struct radix_node_head *head); + struct radix_node rnh_nodes[3]; /* empty tree for common case */ +}; + +#ifdef _KERNEL +extern struct radix_mask *rn_mkfreelist; + +#define R_Malloc(p, t, n) (p = (t) malloc((size_t)(n), M_RTABLE, M_NOWAIT)) +#define Free(p) free(p, M_RTABLE); +#endif /*_KERNEL*/ + +void rn_init(void); +int rn_inithead(void **, int); +void rn_delayedinit(void **, int); +int rn_inithead0(struct radix_node_head *, int); +int rn_refines(const void *, const void *); +int rn_walktree(struct radix_node_head *, + int (*)(struct radix_node *, void *), + void *); +struct radix_node + *rn_addmask(const void *, int, int), + *rn_addroute(const void *, const void *, struct radix_node_head *, + struct radix_node [2]), + *rn_delete1(const void *, const void *, struct radix_node_head *, + struct radix_node *), + *rn_delete(const void *, const void *, struct radix_node_head *), + *rn_insert(const void *, struct radix_node_head *, int *, + struct radix_node [2]), + *rn_lookup(const void *, const void *, struct radix_node_head *), + *rn_match(const void *, struct radix_node_head *), + *rn_newpair(const void *, int, struct radix_node[2]), + *rn_search(const void *, struct radix_node *), + *rn_search_m(const void *, struct radix_node *, const void *); + +#endif /* !_NET_RADIX_H_ */ diff --git a/sys/net/route.h b/sys/net/route.h new file mode 100644 index 000000000..c5c114602 --- /dev/null +++ b/sys/net/route.h @@ -0,0 +1,524 @@ +/* $NetBSD: route.h,v 1.80 2011/11/11 15:09:32 gdt Exp $ */ + +/* + * Copyright (c) 1980, 1986, 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 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. + * + * @(#)route.h 8.5 (Berkeley) 2/8/95 + */ + +#ifndef _NET_ROUTE_H_ +#define _NET_ROUTE_H_ + +#include +#include +#include +#include + +#if !(defined(_KERNEL) || defined(_STANDALONE)) +#include +#endif + +/* + * Kernel resident routing tables. + * + * The routing tables are initialized when interface addresses + * are set by making entries for all directly connected interfaces. + */ + +/* + * A route consists of a destination address and a reference + * to a routing entry. These are often held by protocols + * in their control blocks, e.g. inpcb. + */ +struct route { + struct rtentry *_ro_rt; + struct sockaddr *ro_sa; + LIST_ENTRY(route) ro_rtcache_next; + bool ro_invalid; +}; + +/* + * These numbers are used by reliable protocols for determining + * retransmission behavior and are included in the routing structure. + */ +struct rt_metrics { + uint64_t rmx_locks; /* Kernel must leave these values alone */ + uint64_t rmx_mtu; /* MTU for this path */ + uint64_t rmx_hopcount; /* max hops expected */ + uint64_t rmx_recvpipe; /* inbound delay-bandwidth product */ + uint64_t rmx_sendpipe; /* outbound delay-bandwidth product */ + uint64_t rmx_ssthresh; /* outbound gateway buffer limit */ + uint64_t rmx_rtt; /* estimated round trip time */ + uint64_t rmx_rttvar; /* estimated rtt variance */ + time_t rmx_expire; /* lifetime for route, e.g. redirect */ + time_t rmx_pksent; /* packets sent using this route */ +}; + +/* + * rmx_rtt and rmx_rttvar are stored as microseconds; + * RTTTOPRHZ(rtt) converts to a value suitable for use + * by a protocol slowtimo counter. + */ +#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */ +#define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ)) + +/* + * We distinguish between routes to hosts and routes to networks, + * preferring the former if available. For each route we infer + * the interface to use from the gateway address supplied when + * the route was entered. Routes that forward packets through + * gateways are marked so that the output routines know to address the + * gateway rather than the ultimate destination. + */ +#ifndef RNF_NORMAL +#include +#endif +struct rtentry { + struct radix_node rt_nodes[2]; /* tree glue, and other values */ +#define rt_mask(r) ((const struct sockaddr *)((r)->rt_nodes->rn_mask)) + struct sockaddr *rt_gateway; /* value */ + int rt_flags; /* up/down?, host/net */ + int rt_refcnt; /* # held references */ + uint64_t rt_use; /* raw # packets forwarded */ + struct ifnet *rt_ifp; /* the answer: interface to use */ + struct ifaddr *rt_ifa; /* the answer: interface to use */ + uint32_t rt_ifa_seqno; + void * rt_llinfo; /* pointer to link level info cache */ + struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */ + struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */ + LIST_HEAD(, rttimer) rt_timer; /* queue of timeouts for misc funcs */ + struct rtentry *rt_parent; /* parent of cloned route */ + struct sockaddr *_rt_key; + struct sockaddr *rt_tag; /* route tagging info */ +}; + +static inline const struct sockaddr * +rt_getkey(const struct rtentry *rt) +{ + return rt->_rt_key; +} + +/* + * Following structure necessary for 4.3 compatibility; + * We should eventually move it to a compat file. + */ +struct ortentry { + uint32_t rt_hash; /* to speed lookups */ + struct sockaddr rt_dst; /* key */ + struct sockaddr rt_gateway; /* value */ + int16_t rt_flags; /* up/down?, host/net */ + int16_t rt_refcnt; /* # held references */ + uint32_t rt_use; /* raw # packets forwarded */ + struct ifnet *rt_ifp; /* the answer: interface to use */ +}; + +#define RTF_UP 0x1 /* route usable */ +#define RTF_GATEWAY 0x2 /* destination is a gateway */ +#define RTF_HOST 0x4 /* host entry (net otherwise) */ +#define RTF_REJECT 0x8 /* host or net unreachable */ +#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ +#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ +#define RTF_DONE 0x40 /* message confirmed */ +#define RTF_MASK 0x80 /* subnet mask present */ +#define RTF_CLONING 0x100 /* generate new routes on use */ +#define RTF_XRESOLVE 0x200 /* external daemon resolves name */ +#define RTF_LLINFO 0x400 /* generated by ARP or ESIS */ +#define RTF_STATIC 0x800 /* manually added */ +#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ +#define RTF_CLONED 0x2000 /* this is a cloned route */ +#define RTF_PROTO2 0x4000 /* protocol specific routing flag */ +#define RTF_PROTO1 0x8000 /* protocol specific routing flag */ +#define RTF_SRC 0x10000 /* route has fixed source address */ +#define RTF_ANNOUNCE 0x20000 /* announce new arp or ndp entry */ + + +/* + * Routing statistics. + */ +struct rtstat { + uint64_t rts_badredirect; /* bogus redirect calls */ + uint64_t rts_dynamic; /* routes created by redirects */ + uint64_t rts_newgateway; /* routes modified by redirects */ + uint64_t rts_unreach; /* lookups which failed */ + uint64_t rts_wildcard; /* lookups satisfied by a wildcard */ +}; + +/* + * Structures for routing messages. By forcing the first member to be aligned + * at a 64-bit boundary, we also force the size to be a multiple of 64-bits. + */ + +#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK) +/* + * If we aren't being compiled for backwards compatiblity, enforce 64-bit + * alignment so any routing message is the same regardless if the kernel + * is an ILP32 or LP64 kernel. + */ +#define __align64 __aligned(sizeof(uint64_t)) +#else +#define __align64 +#endif + +struct rt_msghdr { + u_short rtm_msglen __align64; + /* to skip over non-understood messages */ + u_char rtm_version; /* future binary compatibility */ + u_char rtm_type; /* message type */ + u_short rtm_index; /* index for associated ifp */ + int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ + int rtm_addrs; /* bitmask identifying sockaddrs in msg */ + pid_t rtm_pid; /* identify sender */ + int rtm_seq; /* for sender to identify action */ + int rtm_errno; /* why failed */ + int rtm_use; /* from rtentry */ + int rtm_inits; /* which metrics we are initializing */ + struct rt_metrics rtm_rmx __align64; + /* metrics themselves */ +}; + +#undef __align64 + +#define RTM_VERSION 4 /* Up the ante and ignore older versions */ + +#define RTM_ADD 0x1 /* Add Route */ +#define RTM_DELETE 0x2 /* Delete Route */ +#define RTM_CHANGE 0x3 /* Change Metrics or flags */ +#define RTM_GET 0x4 /* Report Metrics */ +#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ +#define RTM_REDIRECT 0x6 /* Told to use different route */ +#define RTM_MISS 0x7 /* Lookup failed on this address */ +#define RTM_LOCK 0x8 /* fix specified metrics */ +#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ +#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ +#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ +#define RTM_NEWADDR 0xc /* address being added to iface */ +#define RTM_DELADDR 0xd /* address being removed from iface */ +#define RTM_OOIFINFO 0xe /* Old (pre-1.5) RTM_IFINFO message */ +#define RTM_OIFINFO 0xf /* Old (pre-64bit time) RTM_IFINFO message */ +#define RTM_IFANNOUNCE 0x10 /* iface arrival/departure */ +#define RTM_IEEE80211 0x11 /* IEEE80211 wireless event */ +#define RTM_SETGATE 0x12 /* set prototype gateway for clones + * (see example in arp_rtrequest). + */ +#define RTM_LLINFO_UPD 0x13 /* indication to ARP/NDP/etc. that link-layer + * address has changed + */ +#define RTM_IFINFO 0x14 /* iface/link going up/down etc. */ +#define RTM_CHGADDR 0x15 /* address properties changed */ + +#define RTV_MTU 0x1 /* init or lock _mtu */ +#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ +#define RTV_EXPIRE 0x4 /* init or lock _expire */ +#define RTV_RPIPE 0x8 /* init or lock _recvpipe */ +#define RTV_SPIPE 0x10 /* init or lock _sendpipe */ +#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ +#define RTV_RTT 0x40 /* init or lock _rtt */ +#define RTV_RTTVAR 0x80 /* init or lock _rttvar */ + +/* + * Bitmask values for rtm_addr. + */ +#define RTA_DST 0x1 /* destination sockaddr present */ +#define RTA_GATEWAY 0x2 /* gateway sockaddr present */ +#define RTA_NETMASK 0x4 /* netmask sockaddr present */ +#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ +#define RTA_IFP 0x10 /* interface name sockaddr present */ +#define RTA_IFA 0x20 /* interface addr sockaddr present */ +#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ +#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTA_TAG 0x100 /* route tag */ + +/* + * Index offsets for sockaddr array for alternate internal encoding. + */ +#define RTAX_DST 0 /* destination sockaddr present */ +#define RTAX_GATEWAY 1 /* gateway sockaddr present */ +#define RTAX_NETMASK 2 /* netmask sockaddr present */ +#define RTAX_GENMASK 3 /* cloning mask sockaddr present */ +#define RTAX_IFP 4 /* interface name sockaddr present */ +#define RTAX_IFA 5 /* interface addr sockaddr present */ +#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ +#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTAX_TAG 8 /* route tag */ +#define RTAX_MAX 9 /* size of array to allocate */ + +#define RT_ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1) | ((n) - 1))) : (n)) +#define RT_ROUNDUP(a) RT_ROUNDUP2((a), sizeof(uint64_t)) +#define RT_ADVANCE(x, n) (x += RT_ROUNDUP((n)->sa_len)) + +struct rt_addrinfo { + int rti_addrs; + const struct sockaddr *rti_info[RTAX_MAX]; + int rti_flags; + struct ifaddr *rti_ifa; + struct ifnet *rti_ifp; +}; + +struct route_cb { + int ip_count; + int ip6_count; + int iso_count; + int mpls_count; + int any_count; +}; + +/* + * This structure, and the prototypes for the rt_timer_{init,remove_all, + * add,timer} functions all used with the kind permission of BSDI. + * These allow functions to be called for routes at specific times. + */ + +struct rttimer { + TAILQ_ENTRY(rttimer) rtt_next; /* entry on timer queue */ + LIST_ENTRY(rttimer) rtt_link; /* multiple timers per rtentry */ + struct rttimer_queue *rtt_queue; /* back pointer to queue */ + struct rtentry *rtt_rt; /* Back pointer to the route */ + void (*rtt_func)(struct rtentry *, struct rttimer *); + time_t rtt_time; /* When this timer was registered */ +}; + +struct rttimer_queue { + long rtq_timeout; + unsigned long rtq_count; + TAILQ_HEAD(, rttimer) rtq_head; + LIST_ENTRY(rttimer_queue) rtq_link; +}; + + +struct rtbl; +typedef struct rtbl rtbl_t; + +#ifdef _KERNEL + +struct rtbl { + struct radix_node_head t_rnh; +}; + +struct rt_walkarg { + int w_op; + int w_arg; + int w_given; + int w_needed; + void * w_where; + int w_tmemsize; + int w_tmemneeded; + void * w_tmem; +}; + +#if 0 +#define RT_DPRINTF(__fmt, ...) do { } while (/*CONSTCOND*/0) +#else +#define RT_DPRINTF(__fmt, ...) /* do nothing */ +#endif + +struct rtwalk { + int (*rw_f)(struct rtentry *, void *); + void *rw_v; +}; + +/* + * Global data specific to the routing socket. + */ +struct route_info { + struct sockaddr ri_dst; + struct sockaddr ri_src; + struct route_cb ri_cb; + int ri_maxqlen; + struct ifqueue ri_intrq; + void *ri_sih; +}; + +extern struct route_info route_info; +extern struct rtstat rtstat; + +struct socket; +struct dom_rtlist; + +void rt_init(void); +void rt_ifannouncemsg(struct ifnet *, int); +void rt_ieee80211msg(struct ifnet *, int, void *, size_t); +void rt_ifmsg(struct ifnet *); +void rt_missmsg(int, const struct rt_addrinfo *, int, int); +struct mbuf *rt_msg1(int, struct rt_addrinfo *, void *, int); +void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *); + +void rt_maskedcopy(const struct sockaddr *, + struct sockaddr *, const struct sockaddr *); +int rt_setgate(struct rtentry *, const struct sockaddr *); +int rt_timer_add(struct rtentry *, + void(*)(struct rtentry *, struct rttimer *), + struct rttimer_queue *); +void rt_timer_init(void); +struct rttimer_queue * + rt_timer_queue_create(u_int); +void rt_timer_queue_change(struct rttimer_queue *, long); +void rt_timer_queue_remove_all(struct rttimer_queue *, int); +void rt_timer_queue_destroy(struct rttimer_queue *, int); +void rt_timer_remove_all(struct rtentry *, int); +unsigned long rt_timer_count(struct rttimer_queue *); +void rt_timer_timer(void *); +void rtcache(struct route *); +void rtflushall(int); +struct rtentry * + rtalloc1(const struct sockaddr *, int); +void rtfree(struct rtentry *); +int rt_getifa(struct rt_addrinfo *); +int rtinit(struct ifaddr *, int, int); +int rtioctl(u_long, void *, struct lwp *); +void rtredirect(const struct sockaddr *, const struct sockaddr *, + const struct sockaddr *, int, const struct sockaddr *, + struct rtentry **); +int rtrequest(int, const struct sockaddr *, + const struct sockaddr *, const struct sockaddr *, int, + struct rtentry **); +int rtrequest1(int, struct rt_addrinfo *, struct rtentry **); + +struct ifaddr *rt_get_ifa(struct rtentry *); +void rt_replace_ifa(struct rtentry *, struct ifaddr *); + +const struct sockaddr *rt_settag(struct rtentry *, const struct sockaddr *); +struct sockaddr *rt_gettag(struct rtentry *); + +static inline void +rt_destroy(struct rtentry *rt) +{ + if (rt->_rt_key != NULL) + sockaddr_free(rt->_rt_key); + if (rt->rt_gateway != NULL) + sockaddr_free(rt->rt_gateway); + if (rt_gettag(rt) != NULL) + sockaddr_free(rt_gettag(rt)); + rt->_rt_key = rt->rt_gateway = rt->rt_tag = NULL; +} + +static inline const struct sockaddr * +rt_setkey(struct rtentry *rt, const struct sockaddr *key, int flags) +{ + if (rt->_rt_key == key) + goto out; + + if (rt->_rt_key != NULL) + sockaddr_free(rt->_rt_key); + rt->_rt_key = sockaddr_dup(key, flags); +out: + KASSERT(rt->_rt_key != NULL); + rt->rt_nodes->rn_key = (const char *)rt->_rt_key; + return rt->_rt_key; +} + +struct rtentry *rtcache_init(struct route *); +struct rtentry *rtcache_init_noclone(struct route *); +void rtcache_copy(struct route *, const struct route *); +void rtcache_invalidate(struct dom_rtlist *); + +struct rtentry *rtcache_lookup2(struct route *, const struct sockaddr *, int, + int *); +void rtcache_clear(struct route *); +struct rtentry *rtcache_update(struct route *, int); +void rtcache_free(struct route *); +int rtcache_setdst(struct route *, const struct sockaddr *); + +static inline void +rtcache_invariants(const struct route *ro) +{ + KASSERT(ro->ro_sa != NULL || ro->_ro_rt == NULL); + KASSERT(!ro->ro_invalid || ro->_ro_rt != NULL); +} + +static inline struct rtentry * +rtcache_lookup1(struct route *ro, const struct sockaddr *dst, int clone) +{ + int hit; + + return rtcache_lookup2(ro, dst, clone, &hit); +} + +static inline struct rtentry * +rtcache_lookup_noclone(struct route *ro, const struct sockaddr *dst) +{ + return rtcache_lookup1(ro, dst, 0); +} + +static inline struct rtentry * +rtcache_lookup(struct route *ro, const struct sockaddr *dst) +{ + return rtcache_lookup1(ro, dst, 1); +} + +static inline const struct sockaddr * +rtcache_getdst(const struct route *ro) +{ + rtcache_invariants(ro); + return ro->ro_sa; +} + +/* If the cache is not empty, and the cached route is still present + * in the routing table, return the cached route. Otherwise, return + * NULL. + */ +static inline struct rtentry * +rtcache_validate(const struct route *ro) +{ + struct rtentry *rt = ro->_ro_rt; + + rtcache_invariants(ro); + + if (ro->ro_invalid) + return NULL; + + if (rt != NULL && (rt->rt_flags & RTF_UP) != 0 && rt->rt_ifp != NULL) + return rt; + return NULL; + +} + +static inline void +RTFREE(struct rtentry *rt) +{ + if (rt->rt_refcnt <= 1) + rtfree(rt); + else + rt->rt_refcnt--; +} + +int rt_walktree(sa_family_t, int (*)(struct rtentry *, void *), void *); +void route_enqueue(struct mbuf *, int); +int rt_inithead(rtbl_t **, int); +struct rtentry *rt_matchaddr(rtbl_t *, const struct sockaddr *); +int rt_addaddr(rtbl_t *, struct rtentry *, const struct sockaddr *); +struct rtentry *rt_lookup(rtbl_t *, const struct sockaddr *, + const struct sockaddr *); +struct rtentry *rt_deladdr(rtbl_t *, const struct sockaddr *, + const struct sockaddr *); +void rtbl_init(void); +rtbl_t *rt_gettable(sa_family_t); +void rt_assert_inactive(const struct rtentry *); + +#endif /* _KERNEL */ + +#endif /* !_NET_ROUTE_H_ */ diff --git a/sys/netinet/in.h b/sys/netinet/in.h new file mode 100644 index 000000000..7b2fb49ca --- /dev/null +++ b/sys/netinet/in.h @@ -0,0 +1,601 @@ +/* $NetBSD: in.h,v 1.86 2009/09/14 10:36:50 degroote Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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 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. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + */ + +/* + * Constants and structures defined by the internet system, + * Per RFC 790, September 1981, and numerous additions. + */ + +#ifndef _NETINET_IN_H_ +#define _NETINET_IN_H_ + +#include + +#ifndef uint8_t +typedef __uint8_t uint8_t; +#define uint8_t __uint8_t +#endif + +#ifndef uint32_t +typedef __uint32_t uint32_t; +#define uint32_t __uint32_t +#endif + +#include + +#ifndef in_addr_t +typedef __in_addr_t in_addr_t; +#define in_addr_t __in_addr_t +#endif + +#ifndef in_port_t +typedef __in_port_t in_port_t; +#define in_port_t __in_port_t +#endif + +#ifndef sa_family_t +typedef __sa_family_t sa_family_t; +#define sa_family_t __sa_family_t +#endif + +/* + * Protocols + */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_IGMP 2 /* group mgmt protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_IPV4 4 /* IP header */ +#define IPPROTO_IPIP 4 /* IP inside IP */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ +#define IPPROTO_IPV6 41 /* IP6 header */ +#define IPPROTO_ROUTING 43 /* IP6 routing header */ +#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ +#define IPPROTO_RSVP 46 /* resource reservation */ +#define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ +#define IPPROTO_ESP 50 /* encap. security payload */ +#define IPPROTO_AH 51 /* authentication header */ +#define IPPROTO_MOBILE 55 /* IP Mobility RFC 2004 */ +#define IPPROTO_IPV6_ICMP 58 /* IPv6 ICMP */ +#define IPPROTO_ICMPV6 58 /* ICMP6 */ +#define IPPROTO_NONE 59 /* IP6 no next header */ +#define IPPROTO_DSTOPTS 60 /* IP6 destination option */ +#define IPPROTO_EON 80 /* ISO cnlp */ +#define IPPROTO_ETHERIP 97 /* Ethernet-in-IP */ +#define IPPROTO_ENCAP 98 /* encapsulation header */ +#define IPPROTO_PIM 103 /* Protocol indep. multicast */ +#define IPPROTO_IPCOMP 108 /* IP Payload Comp. Protocol */ +#define IPPROTO_VRRP 112 /* VRRP RFC 2338 */ +#define IPPROTO_CARP 112 /* Common Address Resolution Protocol */ +#define IPPROTO_PFSYNC 240 /* PFSYNC */ +#define IPPROTO_RAW 255 /* raw IP packet */ +#define IPPROTO_MAX 256 + +/* last return value of *_input(), meaning "all job for this pkt is done". */ +#define IPPROTO_DONE 257 + +/* sysctl placeholder for (FAST_)IPSEC */ +#define CTL_IPPROTO_IPSEC 258 + + +/* + * Local port number conventions: + * + * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), + * unless a kernel is compiled with IPNOPRIVPORTS defined. + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * + * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although + * that is settable by sysctl(3); net.inet.ip.anonportmin and + * net.inet.ip.anonportmax respectively. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, + * and exists only for FreeBSD compatibility purposes. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. + * This convention is based on "vouchsafe" principles only. + * It is only secure if you trust the remote host to restrict these ports. + * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + */ + +#define IPPORT_RESERVED 1024 +#define IPPORT_ANONMIN 49152 +#define IPPORT_ANONMAX 65535 +#define IPPORT_RESERVEDMIN 600 +#define IPPORT_RESERVEDMAX (IPPORT_RESERVED-1) + +/* + * Internet address (a structure for historical reasons) + */ +struct in_addr { + in_addr_t s_addr; +} __packed; + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + * + * By byte-swapping the constants, we avoid ever having to byte-swap IP + * addresses inside the kernel. Unfortunately, user-level programs rely + * on these macros not doing byte-swapping. + */ +#ifdef _KERNEL +#define __IPADDR(x) ((uint32_t) htonl((uint32_t)(x))) +#else +#define __IPADDR(x) ((uint32_t)(x)) +#endif + +#define IN_CLASSA(i) (((uint32_t)(i) & __IPADDR(0x80000000)) == \ + __IPADDR(0x00000000)) +#define IN_CLASSA_NET __IPADDR(0xff000000) +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST __IPADDR(0x00ffffff) +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((uint32_t)(i) & __IPADDR(0xc0000000)) == \ + __IPADDR(0x80000000)) +#define IN_CLASSB_NET __IPADDR(0xffff0000) +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST __IPADDR(0x0000ffff) +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((uint32_t)(i) & __IPADDR(0xe0000000)) == \ + __IPADDR(0xc0000000)) +#define IN_CLASSC_NET __IPADDR(0xffffff00) +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST __IPADDR(0x000000ff) + +#define IN_CLASSD(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \ + __IPADDR(0xe0000000)) +/* These ones aren't really net and host fields, but routing needn't know. */ +#define IN_CLASSD_NET __IPADDR(0xf0000000) +#define IN_CLASSD_NSHIFT 28 +#define IN_CLASSD_HOST __IPADDR(0x0fffffff) +#define IN_MULTICAST(i) IN_CLASSD(i) + +#define IN_EXPERIMENTAL(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \ + __IPADDR(0xf0000000)) +#define IN_BADCLASS(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \ + __IPADDR(0xf0000000)) + +#define IN_LINKLOCAL(i) (((uint32_t)(i) & __IPADDR(0xffff0000)) == \ + __IPADDR(0xa9fe0000)) + +#define IN_PRIVATE(i) ((((uint32_t)(i) & __IPADDR(0xff000000)) == \ + __IPADDR(0x0a000000)) || \ + (((uint32_t)(i) & __IPADDR(0xfff00000)) == \ + __IPADDR(0xac100000)) || \ + (((uint32_t)(i) & __IPADDR(0xffff0000)) == \ + __IPADDR(0xc0a80000))) + +#define IN_LOCAL_GROUP(i) (((uint32_t)(i) & __IPADDR(0xffffff00)) == \ + __IPADDR(0xe0000000)) + +#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) + +#define INADDR_ANY __IPADDR(0x00000000) +#define INADDR_LOOPBACK __IPADDR(0x7f000001) +#define INADDR_BROADCAST __IPADDR(0xffffffff) /* must be masked */ +#define INADDR_NONE __IPADDR(0xffffffff) /* -1 return */ + +#define INADDR_UNSPEC_GROUP __IPADDR(0xe0000000) /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP __IPADDR(0xe0000001) /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP __IPADDR(0xe0000002) /* 224.0.0.2 */ +#define INADDR_CARP_GROUP __IPADDR(0xe0000012) /* 224.0.0.18 */ +#define INADDR_MAX_LOCAL_GROUP __IPADDR(0xe00000ff) /* 224.0.0.255 */ + +#define IN_LOOPBACKNET 127 /* official! */ + +/* + * Socket address, internet style. + */ +struct sockaddr_in { + uint8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + __int8_t sin_zero[8]; +}; + +#define INET_ADDRSTRLEN 16 + +/* + * Structure used to describe IP options. + * Used to store options internally, to pass them to a process, + * or to restore options retrieved earlier. + * The ip_dst is used for the first-hop gateway when using a source route + * (this gets put into the header proper). + */ +struct ip_opts { + struct in_addr ip_dst; /* first hop, 0 w/o src rt */ +#if defined(__cplusplus) + __int8_t Ip_opts[40]; /* actually variable in size */ +#else + __int8_t ip_opts[40]; /* actually variable in size */ +#endif +}; + +/* + * Options for use with [gs]etsockopt at the IP level. + * First word of comment is data type; bool is stored in int. + */ +#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ +#define IP_HDRINCL 2 /* int; header is included with data */ +#define IP_TOS 3 /* int; IP type of service and preced. */ +#define IP_TTL 4 /* int; IP time to live */ +#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ +#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ +#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ +#define IP_RETOPTS 8 /* ip_opts; set/get IP options */ +#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ +#define IP_PORTRANGE 19 /* int; range to use for ephemeral port */ +#define IP_RECVIF 20 /* bool; receive reception if w/dgram */ +#define IP_ERRORMTU 21 /* int; get MTU of last xmit = EMSGSIZE */ +#if 1 /*IPSEC*/ +#define IP_IPSEC_POLICY 22 /* struct; get/set security policy */ +#endif +#define IP_RECVTTL 23 /* bool; receive IP TTL w/dgram */ +#define IP_MINTTL 24 /* minimum TTL for packet or drop */ + +/* + * Defaults and limits for options + */ +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ +#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */ + +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Argument for IP_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IP_PORTRANGE_DEFAULT 0 /* default range */ +#define IP_PORTRANGE_HIGH 1 /* same as DEFAULT (FreeBSD compat) */ +#define IP_PORTRANGE_LOW 2 /* use privileged range */ + +#if defined(_NETBSD_SOURCE) +/* + * Definitions for inet sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ +#define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */ + +#define CTL_IPPROTO_NAMES { \ + { "ip", CTLTYPE_NODE }, \ + { "icmp", CTLTYPE_NODE }, \ + { "igmp", CTLTYPE_NODE }, \ + { "ggp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "tcp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { "egp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "pup", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "udp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "idp", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "ipsec", CTLTYPE_NODE }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { 0, 0 }, \ + { "pim", CTLTYPE_NODE }, \ +} + +/* + * Names for IP sysctl objects + */ +#define IPCTL_FORWARDING 1 /* act as router */ +#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ +#define IPCTL_DEFTTL 3 /* default TTL */ +#ifdef notyet +#define IPCTL_DEFMTU 4 /* default MTU */ +#endif +#define IPCTL_FORWSRCRT 5 /* forward source-routed packets */ +#define IPCTL_DIRECTEDBCAST 6 /* default broadcast behavior */ +#define IPCTL_ALLOWSRCRT 7 /* allow/drop all source-routed pkts */ +#define IPCTL_SUBNETSARELOCAL 8 /* treat subnets as local addresses */ +#define IPCTL_MTUDISC 9 /* allow path MTU discovery */ +#define IPCTL_ANONPORTMIN 10 /* minimum ephemeral port */ +#define IPCTL_ANONPORTMAX 11 /* maximum ephemeral port */ +#define IPCTL_MTUDISCTIMEOUT 12 /* allow path MTU discovery */ +#define IPCTL_MAXFLOWS 13 /* maximum ip flows allowed */ +#define IPCTL_HOSTZEROBROADCAST 14 /* is host zero a broadcast addr? */ +#define IPCTL_GIF_TTL 15 /* default TTL for gif encap packet */ +#define IPCTL_LOWPORTMIN 16 /* minimum reserved port */ +#define IPCTL_LOWPORTMAX 17 /* maximum reserved port */ +#define IPCTL_MAXFRAGPACKETS 18 /* max packets reassembly queue */ +#define IPCTL_GRE_TTL 19 /* default TTL for gre encap packet */ +#define IPCTL_CHECKINTERFACE 20 /* drop pkts in from 'wrong' iface */ +#define IPCTL_IFQ 21 /* ipintrq node */ +#define IPCTL_RANDOMID 22 /* use random IP ids (if configured) */ +#define IPCTL_LOOPBACKCKSUM 23 /* do IP checksum on loopback */ +#define IPCTL_STATS 24 /* IP statistics */ +#define IPCTL_MAXID 25 + +#define IPCTL_NAMES { \ + { 0, 0 }, \ + { "forwarding", CTLTYPE_INT }, \ + { "redirect", CTLTYPE_INT }, \ + { "ttl", CTLTYPE_INT }, \ + { "mtu", CTLTYPE_INT }, \ + { "forwsrcrt", CTLTYPE_INT }, \ + { "directed-broadcast", CTLTYPE_INT }, \ + { "allowsrcrt", CTLTYPE_INT }, \ + { "subnetsarelocal", CTLTYPE_INT }, \ + { "mtudisc", CTLTYPE_INT }, \ + { "anonportmin", CTLTYPE_INT }, \ + { "anonportmax", CTLTYPE_INT }, \ + { "mtudisctimeout", CTLTYPE_INT }, \ + { "maxflows", CTLTYPE_INT }, \ + { "hostzerobroadcast", CTLTYPE_INT }, \ + { "gifttl", CTLTYPE_INT }, \ + { "lowportmin", CTLTYPE_INT }, \ + { "lowportmax", CTLTYPE_INT }, \ + { "maxfragpackets", CTLTYPE_INT }, \ + { "grettl", CTLTYPE_INT }, \ + { "checkinterface", CTLTYPE_INT }, \ + { "ifq", CTLTYPE_NODE }, \ + { "random_id", CTLTYPE_INT }, \ + { "do_loopback_cksum", CTLTYPE_INT }, \ + { "stats", CTLTYPE_STRUCT }, \ +} +#endif /* _NETBSD_SOURCE */ + +/* INET6 stuff */ +#define __KAME_NETINET_IN_H_INCLUDED_ +#include +#undef __KAME_NETINET_IN_H_INCLUDED_ + +#ifdef _KERNEL +/* + * in_cksum_phdr: + * + * Compute significant parts of the IPv4 checksum pseudo-header + * for use in a delayed TCP/UDP checksum calculation. + * + * Args: + * + * src Source IP address + * dst Destination IP address + * lenproto htons(proto-hdr-len + proto-number) + */ +static __inline u_int16_t __unused +in_cksum_phdr(u_int32_t src, u_int32_t dst, u_int32_t lenproto) +{ + u_int32_t sum; + + sum = lenproto + + (u_int16_t)(src >> 16) + + (u_int16_t)(src /*& 0xffff*/) + + (u_int16_t)(dst >> 16) + + (u_int16_t)(dst /*& 0xffff*/); + + sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/); + + if (sum > 0xffff) + sum -= 0xffff; + + return (sum); +} + +/* + * in_cksum_addword: + * + * Add the two 16-bit network-order values, carry, and return. + */ +static __inline u_int16_t __unused +in_cksum_addword(u_int16_t a, u_int16_t b) +{ + u_int32_t sum = a + b; + + if (sum > 0xffff) + sum -= 0xffff; + + return (sum); +} + +extern struct in_addr zeroin_addr; +extern u_char ip_protox[]; +extern const struct sockaddr_in in_any; + +int in_broadcast(struct in_addr, struct ifnet *); +int in_canforward(struct in_addr); +int cpu_in_cksum(struct mbuf *, int, int, uint32_t); +int in_cksum(struct mbuf *, int); +int in4_cksum(struct mbuf *, u_int8_t, int, int); +void in_delayed_cksum(struct mbuf *); +int in_localaddr(struct in_addr); +void in_socktrim(struct sockaddr_in *); + +#define in_hosteq(s,t) ((s).s_addr == (t).s_addr) +#define in_nullhost(x) ((x).s_addr == INADDR_ANY) + +#define satosin(sa) ((struct sockaddr_in *)(sa)) +#define satocsin(sa) ((const struct sockaddr_in *)(sa)) +#define sintosa(sin) ((struct sockaddr *)(sin)) +#define sintocsa(sin) ((const struct sockaddr *)(sin)) +#define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) + +int sockaddr_in_cmp(const struct sockaddr *, const struct sockaddr *); +const void *sockaddr_in_const_addr(const struct sockaddr *, socklen_t *); +void *sockaddr_in_addr(struct sockaddr *, socklen_t *); + +static inline void +sockaddr_in_init1(struct sockaddr_in *sin, const struct in_addr *addr, + in_port_t port) +{ + sin->sin_port = port; + sin->sin_addr = *addr; + memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); +} + +static inline void +sockaddr_in_init(struct sockaddr_in *sin, const struct in_addr *addr, + in_port_t port) +{ + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sockaddr_in_init1(sin, addr, port); +} + +static inline struct sockaddr * +sockaddr_in_alloc(const struct in_addr *addr, in_port_t port, int flags) +{ + struct sockaddr *sa; + + sa = sockaddr_alloc(AF_INET, sizeof(struct sockaddr_in), flags); + + if (sa == NULL) + return NULL; + + sockaddr_in_init1(satosin(sa), addr, port); + + return sa; +} +#endif /* _KERNEL */ + +#endif /* !_NETINET_IN_H_ */ diff --git a/sys/lib/libkern/arch/sparc64/DEFS.h b/sys/netinet/in_systm.h similarity index 65% rename from sys/lib/libkern/arch/sparc64/DEFS.h rename to sys/netinet/in_systm.h index c9686f383..ff53fb7b9 100644 --- a/sys/lib/libkern/arch/sparc64/DEFS.h +++ b/sys/netinet/in_systm.h @@ -1,13 +1,9 @@ -/* $NetBSD: DEFS.h,v 1.3 2005/12/11 12:24:45 christos Exp $ */ +/* $NetBSD: in_systm.h,v 1.13 2005/12/10 23:36:23 elad Exp $ */ -/*- - * Copyright (c) 1992, 1993 +/* + * Copyright (c) 1982, 1986, 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: @@ -32,8 +28,32 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)DEFS.h 8.1 (Berkeley) 6/4/93 + * @(#)in_systm.h 8.1 (Berkeley) 6/10/93 */ -#include +#ifndef _NETINET_IN_SYSTM_H_ +#define _NETINET_IN_SYSTM_H_ +/* + * Miscellaneous internetwork + * definitions for kernel. + */ + +/* + * Network types. + * + * Internally the system keeps counters in the headers with the bytes + * swapped so that VAX instructions will work on them. It reverses + * the bytes before transmission at each protocol level. The n_ types + * represent the types with the bytes in ``high-ender'' order. + */ +typedef u_int16_t n_short; /* short as received from the net */ +typedef u_int32_t n_long; /* long as received from the net */ + +typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ + +#ifdef _KERNEL +n_time iptime (void); +#endif + +#endif /* !_NETINET_IN_SYSTM_H_ */ diff --git a/sys/netinet/ip.h b/sys/netinet/ip.h new file mode 100644 index 000000000..73d442fdd --- /dev/null +++ b/sys/netinet/ip.h @@ -0,0 +1,245 @@ +/* $NetBSD: ip.h,v 1.32 2011/07/24 18:06:08 christos Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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 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. + * + * @(#)ip.h 8.2 (Berkeley) 6/1/94 + */ + +#ifndef _NETINET_IP_H_ +#define _NETINET_IP_H_ + +/* + * Definitions for internet protocol version 4. + * Per RFC 791, September 1981. + */ +#define IPVERSION 4 + +/* + * Structure of an internet header, naked of options. + */ +struct ip { +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned int ip_hl:4, /* header length */ + ip_v:4; /* version */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + unsigned int ip_v:4, /* version */ + ip_hl:4; /* header length */ +#endif + u_int8_t ip_tos; /* type of service */ + u_int16_t ip_len; /* total length */ + u_int16_t ip_id; /* identification */ + u_int16_t ip_off; /* fragment offset field */ +#define IP_RF 0x8000 /* reserved fragment flag */ +#define IP_EF 0x8000 /* evil flag, per RFC 3514 */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_int8_t ip_ttl; /* time to live */ + u_int8_t ip_p; /* protocol */ + u_int16_t ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ +} __packed; + +#define IP_MAXPACKET 65535 /* maximum packet size */ +#define IP_MINFRAGSIZE 69 /* minumum size that can be fraged */ + +/* + * Definitions for IP type of service (ip_tos) + */ + +/* + * Definitions for DiffServ Codepoints as per RFC2474 + */ +#define IPTOS_DSCP_CS0 0x00 +#define IPTOS_DSCP_CS1 0x20 +#define IPTOS_DSCP_AF11 0x28 +#define IPTOS_DSCP_AF12 0x30 +#define IPTOS_DSCP_AF13 0x38 +#define IPTOS_DSCP_CS2 0x40 +#define IPTOS_DSCP_AF21 0x48 +#define IPTOS_DSCP_AF22 0x50 +#define IPTOS_DSCP_AF23 0x58 +#define IPTOS_DSCP_CS3 0x60 +#define IPTOS_DSCP_AF31 0x68 +#define IPTOS_DSCP_AF32 0x70 +#define IPTOS_DSCP_AF33 0x78 +#define IPTOS_DSCP_CS4 0x80 +#define IPTOS_DSCP_AF41 0x88 +#define IPTOS_DSCP_AF42 0x90 +#define IPTOS_DSCP_AF43 0x98 +#define IPTOS_DSCP_CS5 0xa0 +#define IPTOS_DSCP_EF 0xb8 +#define IPTOS_DSCP_CS6 0xc0 +#define IPTOS_DSCP_CS7 0xe0 + +/* + * Definitions for DiffServ Class Selector Codepoints + */ +#define IPTOS_CLASS_CS0 0x00 +#define IPTOS_CLASS_CS1 0x20 +#define IPTOS_CLASS_CS2 0x40 +#define IPTOS_CLASS_CS3 0x60 +#define IPTOS_CLASS_CS4 0x80 +#define IPTOS_CLASS_CS5 0xa0 +#define IPTOS_CLASS_CS6 0xc0 +#define IPTOS_CLASS_CS7 0xe0 +#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0 +#define IPTOS_CLASS_MASK 0xe0 +#define IPTOS_CLASS(cs) ((cs) & IPTOS_CLASS_MASK) +#define IPTOS_DSCP_MASK 0xfc +#define IPTOS_DSCP(cp) ((cp) & IPTOS_DSCP_MASK) + +/* + * ECN (Explicit Congestion Notification) codepoints in RFC3168 + * mapped to the lower 2 bits of the TOS field. + */ +#define IPTOS_ECN_NOTECT 0x00 /* not-ECT */ +#define IPTOS_ECN_ECT1 0x01 /* ECN-capable transport (1) */ +#define IPTOS_ECN_ECT0 0x02 /* ECN-capable transport (0) */ +#define IPTOS_ECN_CE 0x03 /* congestion experienced */ +#define IPTOS_ECN_MASK 0x03 /* ECN field mask */ +#define IPTOS_ECN(cn) ((cn) & IPTOS_ECN_MASK) +#define IPTOS_ECN_NOT_ECT 0x00 + +/* + * Definitions for IP type of service per RFC1349 (ip_tos) + * DEPRECATED + */ +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_MINCOST 0x02 +/* ECN RFC3168 obsoletes RFC2481, and these will be deprecated soon. */ +#define IPTOS_CE 0x01 /* congestion experienced */ +#define IPTOS_ECT 0x02 /* ECN-capable transport */ + +/* + * Definitions for IP precedence per RFC1195 (also in ip_tos) (hopefully unused) + */ +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * Definitions for options. + */ +#define IPOPT_COPIED(o) ((o)&0x80) +#define IPOPT_CLASS(o) ((o)&0x60) +#define IPOPT_NUMBER(o) ((o)&0x1f) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0 /* end of option list */ +#define IPOPT_NOP 1 /* no operation */ + +#define IPOPT_RR 7 /* record packet route */ +#define IPOPT_TS 68 /* timestamp */ +#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#define IPOPT_LSRR 131 /* loose source route */ +#define IPOPT_SATID 136 /* satnet id */ +#define IPOPT_SSRR 137 /* strict source route */ + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_MINOFF 4 /* min value of above */ + +/* + * Time stamp option structure. + */ +struct ip_timestamp { + u_int8_t ipt_code; /* IPOPT_TS */ + u_int8_t ipt_len; /* size of structure (variable) */ + u_int8_t ipt_ptr; /* index of current entry */ +#if BYTE_ORDER == LITTLE_ENDIAN + unsigned int ipt_flg:4, /* flags, see below */ + ipt_oflw:4; /* overflow counter */ +#endif +#if BYTE_ORDER == BIG_ENDIAN + unsigned int ipt_oflw:4, /* overflow counter */ + ipt_flg:4; /* flags, see below */ +#endif + union ipt_timestamp { + n_time ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + n_time ipt_time; + } ipt_ta[1] __packed; + } ipt_timestamp __packed; +} __packed; + +/* flag bits for ipt_flg */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +/* bits for security (not byte swapped) */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ + +#define IP_MSS 576 /* default maximum segment size */ + +/* + * This is the real IPv4 pseudo header, used for computing the TCP and UDP + * checksums. For the Internet checksum, struct ipovly can be used instead. + * For stronger checksums, the real thing must be used. + */ +struct ippseudo { + struct in_addr ippseudo_src; /* source internet address */ + struct in_addr ippseudo_dst; /* destination internet address */ + u_int8_t ippseudo_pad; /* pad, must be zero */ + u_int8_t ippseudo_p; /* protocol */ + u_int16_t ippseudo_len; /* protocol length */ +} __packed; +#endif /* !_NETINET_IP_H_ */ diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h new file mode 100644 index 000000000..8ef9f6ed0 --- /dev/null +++ b/sys/netinet/ip_var.h @@ -0,0 +1,232 @@ +/* $NetBSD: ip_var.h,v 1.97 2011/05/03 17:44:31 dyoung Exp $ */ + +/* + * Copyright (c) 1982, 1986, 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 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. + * + * @(#)ip_var.h 8.2 (Berkeley) 1/9/95 + */ + +#ifndef _NETINET_IP_VAR_H_ +#define _NETINET_IP_VAR_H_ + +#include +#include + +/* + * Overlay for ip header used by other protocols (tcp, udp). + */ +struct ipovly { + u_int8_t ih_x1[9]; /* (unused) */ + u_int8_t ih_pr; /* protocol */ + u_int16_t ih_len; /* protocol length */ + struct in_addr ih_src; /* source internet address */ + struct in_addr ih_dst; /* destination internet address */ +} __packed; + +/* + * IP sequence queue structure. + * + * XXX -- The following explains why the ipqe_m field is here, for TCP's use: + * We want to avoid doing m_pullup on incoming packets but that + * means avoiding dtom on the tcp reassembly code. That in turn means + * keeping an mbuf pointer in the reassembly queue (since we might + * have a cluster). As a quick hack, the source & destination + * port numbers (which are no longer needed once we've located the + * tcpcb) are overlayed with an mbuf pointer. + */ +TAILQ_HEAD(ipqehead, ipqent); +struct ipqent { + TAILQ_ENTRY(ipqent) ipqe_q; + union { + struct ip *_ip; + struct tcpiphdr *_tcp; + } _ipqe_u1; + struct mbuf *ipqe_m; /* point to first mbuf */ + struct mbuf *ipre_mlast; /* point to last mbuf */ + u_int8_t ipqe_mff; /* for IP fragmentation */ + /* + * The following are used in TCP reassembly + */ + TAILQ_ENTRY(ipqent) ipqe_timeq; + u_int32_t ipqe_seq; + u_int32_t ipqe_len; + u_int32_t ipqe_flags; +}; +#define ipqe_tcp _ipqe_u1._tcp + +/* + * Structure stored in mbuf in inpcb.ip_options + * and passed to ip_output when ip options are in use. + * The actual length of the options (including ipopt_dst) + * is in m_len. + */ +#define MAX_IPOPTLEN 40 + +struct ipoption { + struct in_addr ipopt_dst; /* first-hop dst if source routed */ + int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ +}; + +/* + * Structure attached to inpcb.ip_moptions and + * passed to ip_output when IP multicast options are in use. + */ +struct ip_moptions { + struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */ + struct in_addr imo_multicast_addr; /* ifindex/addr on MULTICAST_IF */ + u_int8_t imo_multicast_ttl; /* TTL for outgoing multicasts */ + u_int8_t imo_multicast_loop; /* 1 => hear sends if a member */ + u_int16_t imo_num_memberships; /* no. memberships this socket */ + struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS]; +}; + +/* + * IP statistics. + * Each counter is an unsigned 64-bit value. + */ +#define IP_STAT_TOTAL 0 /* total packets received */ +#define IP_STAT_BADSUM 1 /* checksum bad */ +#define IP_STAT_TOOSHORT 2 /* packet too short */ +#define IP_STAT_TOOSMALL 3 /* not enough data */ +#define IP_STAT_BADHLEN 4 /* ip header length < data size */ +#define IP_STAT_BADLEN 5 /* ip length < ip header length */ +#define IP_STAT_FRAGMENTS 6 /* fragments received */ +#define IP_STAT_FRAGDROPPED 7 /* frags dropped (dups, out of space) */ +#define IP_STAT_FRAGTIMEOUT 8 /* fragments timed out */ +#define IP_STAT_FORWARD 9 /* packets forwarded */ +#define IP_STAT_FASTFORWARD 10 /* packets fast forwarded */ +#define IP_STAT_CANTFORWARD 11 /* packets rcvd for unreachable dest */ +#define IP_STAT_REDIRECTSENT 12 /* packets forwareded on same net */ +#define IP_STAT_NOPROTO 13 /* unknown or unsupported protocol */ +#define IP_STAT_DELIVERED 14 /* datagrams delivered to upper level */ +#define IP_STAT_LOCALOUT 15 /* total ip packets generated here */ +#define IP_STAT_ODROPPED 16 /* lost packets due to nobufs, etc. */ +#define IP_STAT_REASSEMBLED 17 /* total packets reassembled ok */ +#define IP_STAT_FRAGMENTED 18 /* datagrams successfully fragmented */ +#define IP_STAT_OFRAGMENTS 19 /* output fragments created */ +#define IP_STAT_CANTFRAG 20 /* don't fragment flag was set, etc. */ +#define IP_STAT_BADOPTIONS 21 /* error in option processing */ +#define IP_STAT_NOROUTE 22 /* packets discarded due to no route */ +#define IP_STAT_BADVERS 23 /* ip version != 4 */ +#define IP_STAT_RAWOUT 24 /* total raw ip packets generated */ +#define IP_STAT_BADFRAGS 25 /* malformed fragments (bad length) */ +#define IP_STAT_RCVMEMDROP 26 /* frags dropped for lack of memory */ +#define IP_STAT_TOOLONG 27 /* ip length > max ip packet size */ +#define IP_STAT_NOGIF 28 /* no match gif found */ +#define IP_STAT_BADADDR 29 /* invalid address on header */ + +#define IP_NSTATS 30 + +#ifdef _KERNEL + +#ifdef _KERNEL_OPT +#include "opt_gateway.h" +#include "opt_mbuftrace.h" +#endif + +/* flags passed to ip_output as last parameter */ +#define IP_FORWARDING 0x1 /* most of ip header exists */ +#define IP_RAWOUTPUT 0x2 /* raw ip header exists */ +#define IP_RETURNMTU 0x4 /* pass back mtu on EMSGSIZE */ +#define IP_NOIPNEWID 0x8 /* don't fill in ip_id */ +#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ +#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ +#define IP_MTUDISC 0x0400 /* Path MTU Discovery; set DF */ + +extern struct domain inetdomain; + +extern int ip_defttl; /* default IP ttl */ +extern int ipforwarding; /* ip forwarding */ +extern int ip_mtudisc; /* mtu discovery */ +extern int ip_mtudisc_timeout; /* seconds to timeout mtu discovery */ +extern int anonportmin; /* minimum ephemeral port */ +extern int anonportmax; /* maximum ephemeral port */ +extern int lowportmin; /* minimum reserved port */ +extern int lowportmax; /* maximum reserved port */ +extern int ip_do_loopback_cksum; /* do IP checksum on loopback? */ +extern struct rttimer_queue *ip_mtudisc_timeout_q; +#ifdef MBUFTRACE +extern struct mowner ip_rx_mowner; +extern struct mowner ip_tx_mowner; +#endif +#ifdef GATEWAY +extern int ip_maxflows; +extern int ip_hashsize; +#endif +extern struct pool inmulti_pool; +struct inpcb; +struct sockopt; + +int ip_ctloutput(int, struct socket *, struct sockopt *); +int ip_dooptions(struct mbuf *); +void ip_drain(void); +void ip_drainstub(void); +void ip_forward(struct mbuf *, int); +void ip_freemoptions(struct ip_moptions *); +int ip_getmoptions(struct ip_moptions *, struct sockopt *); +void ip_init(void); +int ip_optcopy(struct ip *, struct ip *); +u_int ip_optlen(struct inpcb *); +int ip_output(struct mbuf *, ...); +int ip_fragment(struct mbuf *, struct ifnet *, u_long); +int ip_pcbopts(struct mbuf **, const struct sockopt *); + +void ip_reass_init(void); +int ip_reass_packet(struct mbuf **, struct ip *); +void ip_reass_slowtimo(void); +void ip_reass_drain(void); + +struct in_ifaddr * + ip_rtaddr(struct in_addr); +void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *, + struct mbuf *); +int ip_setmoptions(struct ip_moptions **, const struct sockopt *); +void ip_slowtimo(void); +void ip_fasttimo(void); +struct mbuf * + ip_srcroute(void); +int ip_sysctl(int *, u_int, void *, size_t *, void *, size_t); +void ip_statinc(u_int); +void ipintr(void); +void * rip_ctlinput(int, const struct sockaddr *, void *); +int rip_ctloutput(int, struct socket *, struct sockopt *); +void rip_init(void); +void rip_input(struct mbuf *, ...); +int rip_output(struct mbuf *, ...); +int rip_usrreq(struct socket *, + int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *); +int ipflow_init(int); +void ipflow_poolinit(void); +void ipflow_prune(void); +void ipflow_create(const struct route *, struct mbuf *); +void ipflow_slowtimo(void); +int ipflow_invalidate_all(int); + +#endif /* _KERNEL */ + +#endif /* !_NETINET_IP_VAR_H_ */ diff --git a/sys/lib/libkern/arch/vax/blkcpy.S b/sys/netinet/udp.h similarity index 63% rename from sys/lib/libkern/arch/vax/blkcpy.S rename to sys/netinet/udp.h index c85518a54..ece7d0ed7 100644 --- a/sys/lib/libkern/arch/vax/blkcpy.S +++ b/sys/netinet/udp.h @@ -1,6 +1,7 @@ -/* $NetBSD: blkcpy.S,v 1.4 2005/12/11 12:24:45 christos Exp $ */ +/* $NetBSD: udp.h,v 1.15 2012/01/07 20:20:12 christos Exp $ */ + /* - * Copyright (c) 1983, 1993 + * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,45 +27,37 @@ * 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. + * + * @(#)udp.h 8.1 (Berkeley) 6/10/93 */ -#include -/* __blkcpy(from, to, size) */ +#ifndef _NETINET_UDP_H_ +#define _NETINET_UDP_H_ -ENTRY(__blkcpy, R6) - movl 4(%ap),%r1 - movl 8(%ap),%r3 - movl 12(%ap),%r6 - cmpl %r1,%r3 - bgtr 2f # normal forward case - blss 3f # overlapping, must do backwards - ret # equal, nothing to do -1: - subl2 %r0,%r6 - movc3 %r0,(%r1),(%r3) -2: - movzwl $65535,%r0 - cmpl %r6,%r0 - jgtr 1b - movc3 %r6,(%r1),(%r3) - ret -3: - addl2 %r6,%r1 - addl2 %r6,%r3 - movzwl $65535,%r0 - jbr 5f -4: - subl2 %r0,%r6 - subl2 %r0,%r1 - subl2 %r0,%r3 - movc3 %r0,(%r1),(%r3) - movzwl $65535,%r0 - subl2 %r0,%r1 - subl2 %r0,%r3 -5: - cmpl %r6,%r0 - jgtr 4b - subl2 %r6,%r1 - subl2 %r6,%r3 - movc3 %r6,(%r1),(%r3) - ret +#include +/* + * Udp protocol header. + * Per RFC 768, September, 1981. + */ +struct udphdr { + uint16_t uh_sport; /* source port */ + uint16_t uh_dport; /* destination port */ + uint16_t uh_ulen; /* udp length */ + uint16_t uh_sum; /* udp checksum */ +} __packed; + +/* socket options for UDP */ +#define UDP_ENCAP 100 +#define UDP_RFC6056ALGO 200 + +/* Encapsulation types */ +#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */ +#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */ + +/* Default encapsulation port */ +#define UDP_ENCAP_ESPINUDP_PORT 500 + +/* Maximum UDP fragment size for ESP over UDP */ +#define UDP_ENCAP_ESPINUDP_MAXFRAGLEN 552 + +#endif /* !_NETINET_UDP_H_ */ diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h new file mode 100644 index 000000000..b4e7fabad --- /dev/null +++ b/sys/netinet/udp_var.h @@ -0,0 +1,108 @@ +/* $NetBSD: udp_var.h,v 1.37 2011/09/24 17:18:17 christos Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1989, 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 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. + * + * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_UDP_VAR_H_ +#define _NETINET_UDP_VAR_H_ + +/* + * UDP kernel structures and variables. + */ +struct udpiphdr { + struct ipovly ui_i; /* overlaid ip structure */ + struct udphdr ui_u; /* udp header */ +} __packed; +#define ui_x1 ui_i.ih_x1 +#define ui_pr ui_i.ih_pr +#define ui_len ui_i.ih_len +#define ui_src ui_i.ih_src +#define ui_dst ui_i.ih_dst +#define ui_sport ui_u.uh_sport +#define ui_dport ui_u.uh_dport +#define ui_ulen ui_u.uh_ulen +#define ui_sum ui_u.uh_sum + +/* + * UDP statistics. + * Each counter is an unsigned 64-bit value. + */ +#define UDP_STAT_IPACKETS 0 /* total input packets */ +#define UDP_STAT_HDROPS 1 /* packet shorter than header */ +#define UDP_STAT_BADSUM 2 /* checksum error */ +#define UDP_STAT_BADLEN 3 /* data length larger than packet */ +#define UDP_STAT_NOPORT 4 /* no socket on port */ +#define UDP_STAT_NOPORTBCAST 5 /* of above, arrived as broadcast */ +#define UDP_STAT_FULLSOCK 6 /* not delivered, input socket full */ +#define UDP_STAT_PCBHASHMISS 7 /* input packets missing PCB hash */ +#define UDP_STAT_OPACKETS 8 /* total output packets */ + +#define UDP_NSTATS 9 + +/* + * Names for UDP sysctl objects + */ +#define UDPCTL_CHECKSUM 1 /* checksum UDP packets */ +#define UDPCTL_SENDSPACE 2 /* default send buffer */ +#define UDPCTL_RECVSPACE 3 /* default recv buffer */ +#define UDPCTL_LOOPBACKCKSUM 4 /* do UDP checksum on loopback */ +#define UDPCTL_STATS 5 /* UDP statistics */ +#define UDPCTL_RFC6056 6 /* RFC 6056 algorithm selection */ +#define UDPCTL_MAXID 7 + +#define UDPCTL_NAMES { \ + { 0, 0 }, \ + { "checksum", CTLTYPE_INT }, \ + { "sendspace", CTLTYPE_INT }, \ + { "recvspace", CTLTYPE_INT }, \ + { "do_loopback_cksum", CTLTYPE_INT }, \ + { "stats", CTLTYPE_STRUCT }, \ + { "rfc6056", CTLTYPE_INT }, \ +} + +#ifdef _KERNEL +extern struct inpcbtable udbtable; + +void *udp_ctlinput(int, const struct sockaddr *, void *); +int udp_ctloutput(int, struct socket *, struct sockopt *); +void udp_init(void); +void udp_input(struct mbuf *, ...); +int udp_output(struct mbuf *, ...); +int udp_sysctl(int *, u_int, void *, size_t *, void *, size_t); +int udp_usrreq(struct socket *, + int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *); + +int udp_input_checksum(int af, struct mbuf *, const struct udphdr *, int, + int); +void udp_statinc(u_int); +#endif /* _KERNEL */ + +#endif /* !_NETINET_UDP_VAR_H_ */ diff --git a/sys/stdlib.h b/sys/stdlib.h new file mode 100644 index 000000000..66f86c382 --- /dev/null +++ b/sys/stdlib.h @@ -0,0 +1,334 @@ +/* $NetBSD: stdlib.h,v 1.94 2010/12/22 19:47:56 jruoho 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 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. + * + * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#include +#include + +#if defined(_NETBSD_SOURCE) +#include /* for quad_t, etc. */ +#endif + +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#if defined(_BSD_WCHAR_T_) && !defined(__cplusplus) +typedef _BSD_WCHAR_T_ wchar_t; +#undef _BSD_WCHAR_T_ +#endif + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +#if !defined(_ANSI_SOURCE) && \ + (defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE)) +typedef struct { + /* LONGLONG */ + long long int quot; /* quotient */ + /* LONGLONG */ + long long int rem; /* remainder */ +} lldiv_t; +#endif + +#if defined(_NETBSD_SOURCE) +typedef struct { + quad_t quot; /* quotient */ + quad_t rem; /* remainder */ +} qdiv_t; +#endif + + +#include + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX 0x7fffffff + +extern size_t __mb_cur_max; +#define MB_CUR_MAX __mb_cur_max + +__BEGIN_DECLS +__dead void _Exit(int); +__dead void abort(void); +__pure int abs(int); +int atexit(void (*)(void)); +double atof(const char *); +int atoi(const char *); +long atol(const char *); +#ifndef __BSEARCH_DECLARED +#define __BSEARCH_DECLARED +/* also in search.h */ +void *bsearch(const void *, const void *, size_t, size_t, + int (*)(const void *, const void *)); +#endif /* __BSEARCH_DECLARED */ +void *calloc(size_t, size_t); +div_t div(int, int); +__dead void exit(int); +void free(void *); +__aconst char *getenv(const char *); +__pure long + labs(long); +ldiv_t ldiv(long, long); +void *malloc(size_t); +void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); +int rand(void); +void *realloc(void *, size_t); +void srand(unsigned); +double strtod(const char * __restrict, char ** __restrict); +long strtol(const char * __restrict, char ** __restrict, int); +unsigned long + strtoul(const char * __restrict, char ** __restrict, int); +int system(const char *); + +/* These are currently just stubs. */ +int mblen(const char *, size_t); +size_t mbstowcs(wchar_t * __restrict, const char * __restrict, size_t); +int wctomb(char *, wchar_t); +int mbtowc(wchar_t * __restrict, const char * __restrict, size_t); +size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); + +#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) + + +/* + * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 + */ +#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_REENTRANT) || defined(_NETBSD_SOURCE) +int rand_r(unsigned int *); +#endif + + +/* + * X/Open Portability Guide >= Issue 4 + */ +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +double drand48(void); +double erand48(unsigned short[3]); +long jrand48(unsigned short[3]); +void lcong48(unsigned short[7]); +long lrand48(void); +long mrand48(void); +long nrand48(unsigned short[3]); +unsigned short * + seed48(unsigned short[3]); +void srand48(long); + +int putenv(char *); +#endif + + +/* + * X/Open Portability Guide >= Issue 4 Version 2 + */ +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +long a64l(const char *); +char *l64a(long); + +char *initstate(unsigned long, char *, size_t); +long random(void); +char *setstate(char *); +void srandom(unsigned long); +#ifdef _NETBSD_SOURCE +#define RANDOM_MAX 0x7fffffff /* (((long)1 << 31) - 1) */ +#endif + +char *mkdtemp(char *); +int mkstemp(char *); +char *mktemp(char *) +#ifdef __MKTEMP_OK__ + __RENAME(_mktemp) +#endif + ; + +int setkey(const char *); + +char *realpath(const char *, char *); + +int ttyslot(void); + +void *valloc(size_t); /* obsoleted by malloc() */ + +int grantpt(int); +int unlockpt(int); +char *ptsname(int); +#endif + +/* + * ISO C99 + */ +#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \ + defined(_NETBSD_SOURCE) +/* LONGLONG */ +long long int atoll(const char *); +/* LONGLONG */ +long long int llabs(long long int); +/* LONGLONG */ +lldiv_t lldiv(long long int, long long int); +/* LONGLONG */ +long long int strtoll(const char * __restrict, char ** __restrict, int); +/* LONGLONG */ +unsigned long long int + strtoull(const char * __restrict, char ** __restrict, int); +float strtof(const char * __restrict, char ** __restrict); +long double strtold(const char * __restrict, char ** __restrict); +#endif + +/* + * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX) + */ +#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \ + defined(_NETBSD_SOURCE) +int setenv(const char *, const char *, int); +#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE) +int unsetenv(const char *) __RENAME(__unsetenv13); +#endif + +int posix_openpt(int); +int posix_memalign(void **, size_t, size_t); +#endif + +/* + * Implementation-defined extensions + */ +#if defined(_NETBSD_SOURCE) +#if defined(alloca) && (alloca == __builtin_alloca) && \ + defined(__GNUC__) && (__GNUC__ < 2) +void *alloca(int); /* built-in for gcc */ +#elif defined(__PCC__) && !defined(__GNUC__) +#define alloca(size) __builtin_alloca(size) +#elif (__GNUC__ >= 2) +#define alloca(size) __builtin_alloca(size) +#else +void *alloca(size_t); +#endif /* __GNUC__ */ + +uint32_t arc4random(void); +void arc4random_stir(void); +void arc4random_addrandom(u_char *, int); +char *getbsize(int *, long *); +char *cgetcap(char *, const char *, int); +int cgetclose(void); +int cgetent(char **, const char * const *, const char *); +int cgetfirst(char **, const char * const *); +int cgetmatch(const char *, const char *); +int cgetnext(char **, const char * const *); +int cgetnum(char *, const char *, long *); +int cgetset(const char *); +int cgetstr(char *, const char *, char **); +int cgetustr(char *, const char *, char **); +void csetexpandtc(int); + +int daemon(int, int); +#ifndef __minix +#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE) +__aconst char *devname(dev_t, mode_t) __RENAME(__devname50); +#endif +#endif /* !__minix */ + +#define HN_DECIMAL 0x01 +#define HN_NOSPACE 0x02 +#define HN_B 0x04 +#define HN_DIVISOR_1000 0x08 + +#define HN_GETSCALE 0x10 +#define HN_AUTOSCALE 0x20 + +int humanize_number(char *, size_t, int64_t, const char *, int, int); +int dehumanize_number(const char *, int64_t *); + +#ifndef __minix +devmajor_t getdevmajor(const char *, mode_t); +#endif /* !__minix */ +int getloadavg(double [], int); + +int getenv_r(const char *, char *, size_t); + +void cfree(void *); + +int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); +int mergesort(void *, size_t, size_t, + int (*)(const void *, const void *)); +int radixsort(const unsigned char **, int, const unsigned char *, + unsigned); +int sradixsort(const unsigned char **, int, const unsigned char *, + unsigned); + +void mi_vector_hash(const void * __restrict, size_t, uint32_t, + uint32_t[3]); + +void setproctitle(const char *, ...) + __printflike(1, 2); +const char *getprogname(void) __constfunc; +void setprogname(const char *); + +quad_t qabs(quad_t); +quad_t strtoq(const char * __restrict, char ** __restrict, int); +u_quad_t strtouq(const char * __restrict, char ** __restrict, int); + + /* LONGLONG */ +long long strsuftoll(const char *, const char *, long long, long long); + /* LONGLONG */ +long long strsuftollx(const char *, const char *, long long, long long, + char *, size_t); + +int l64a_r(long, char *, int); + +size_t shquote(const char *, char *, size_t); +size_t shquotev(int, char * const *, char *, size_t); +#endif /* _NETBSD_SOURCE */ +#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ + +#if defined(_NETBSD_SOURCE) +qdiv_t qdiv(quad_t, quad_t); +#endif +__END_DECLS + +#endif /* !_STDLIB_H_ */ diff --git a/sys/sys/boot_flag.h b/sys/sys/boot_flag.h new file mode 100644 index 000000000..c84610acb --- /dev/null +++ b/sys/sys/boot_flag.h @@ -0,0 +1,91 @@ +/* $NetBSD: boot_flag.h,v 1.7 2008/04/29 19:16:08 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * 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 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. + */ + +#ifndef _SYS_BOOT_FLAG_H_ +#define _SYS_BOOT_FLAG_H_ + +#include + +/* + * Recognize standard boot arguments. If the flag is known, appropriate + * value is or'ed to retval, otherwise retval is left intact. + * Note that not all ports use all flags recognized here. This list is mere + * concatenation of all non-conflicting standard boot flags. Individual ports + * might use also other flags (see e.g. alpha). + */ +#define BOOT_FLAG(arg, retval) do { \ + switch (arg) { \ + case '1': /* machine dependent flag */ \ + (retval) |= RB_MD1; \ + break; \ + case '2': /* machine dependent flag */ \ + (retval) |= RB_MD2; \ + break; \ + case '3': /* machine dependent flag */ \ + (retval) |= RB_MD3; \ + break; \ + case '4': /* machine dependent flag */ \ + (retval) |= RB_MD4; \ + break; \ + case 'a': /* ask for file name to boot from */ \ + (retval) |= RB_ASKNAME; \ + break; \ + case 'b': /* always halt, never reboot */ \ + (retval) |= RB_HALT; \ + break; \ + case 'c': /* userconf */ \ + (retval) |= RB_USERCONF; \ + break; \ + case 'd': /* break into the kernel debugger ASAP (if compiled in) */ \ + (retval) |= RB_KDB; \ + break; \ + case 'm': /* mini root present in memory */ \ + (retval) |= RB_MINIROOT; \ + break; \ + case 'q': /* boot quietly */ \ + (retval) |= AB_QUIET; \ + break; \ + case 's': /* boot to single user */ \ + (retval) |= RB_SINGLE; \ + break; \ + case 'v': /* boot verbosely */ \ + (retval) |= AB_VERBOSE; \ + break; \ + case 'x': /* boot with debugging messages */ \ + (retval) |= AB_DEBUG; \ + break; \ + case 'z': /* boot silently */ \ + (retval) |= AB_SILENT; \ + break; \ + default: /* something else, do nothing */ \ + break; \ + } /* switch */ \ + \ + } while (/* CONSTCOND */ 0) + +#endif /* _SYS_BOOT_FLAG_H_ */ diff --git a/sys/lib/libkern/arch/i386/skpc.S b/sys/sys/condvar.h similarity index 62% rename from sys/lib/libkern/arch/i386/skpc.S rename to sys/sys/condvar.h index fddb7b36e..8d41077d3 100644 --- a/sys/lib/libkern/arch/i386/skpc.S +++ b/sys/sys/condvar.h @@ -1,11 +1,11 @@ -/* $NetBSD: skpc.S,v 1.6 2008/04/28 20:24:06 martin Exp $ */ +/* $NetBSD: condvar.h,v 1.12 2009/12/05 22:38:19 pooka Exp $ */ /*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. + * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum. + * by Andrew Doran. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,19 +29,34 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#ifndef _SYS_CONDVAR_H_ +#define _SYS_CONDVAR_H_ -ENTRY(skpc) - pushl %edi - movl 16(%esp),%edi - movl 12(%esp),%ecx - movl 8(%esp),%eax - cld - repe - scasb - je 1f - incl %ecx -1: - movl %ecx,%eax - popl %edi - ret +#include + +typedef struct kcondvar { + void *cv_opaque[3]; +} kcondvar_t; + +#ifdef _KERNEL + +void cv_init(kcondvar_t *, const char *); +void cv_destroy(kcondvar_t *); + +void cv_wait(kcondvar_t *, kmutex_t *); +int cv_wait_sig(kcondvar_t *, kmutex_t *); +int cv_timedwait(kcondvar_t *, kmutex_t *, int); +int cv_timedwait_sig(kcondvar_t *, kmutex_t *, int); + +void cv_signal(kcondvar_t *); +void cv_broadcast(kcondvar_t *); + +bool cv_has_waiters(kcondvar_t *); +bool cv_is_valid(kcondvar_t *); + +/* The "lightning bolt", awoken once per second by the clock interrupt. */ +extern kcondvar_t lbolt; + +#endif /* _KERNEL */ + +#endif /* _SYS_CONDVAR_H_ */ diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h new file mode 100644 index 000000000..42e38f73d --- /dev/null +++ b/sys/sys/disklabel.h @@ -0,0 +1,476 @@ +/* $NetBSD: disklabel.h,v 1.112 2012/01/16 18:47:58 christos Exp $ */ + +/* + * Copyright (c) 1987, 1988, 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 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. + * + * @(#)disklabel.h 8.2 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_DISKLABEL_H_ +#define _SYS_DISKLABEL_H_ + +/* + * We need for __HAVE_OLD_DISKLABEL + */ +#ifndef _LOCORE +#include +#endif + +/* + * Each disk has a label which includes information about the hardware + * disk geometry, filesystem partitions, and drive specific information. + * The location of the label, as well as the number of partitions the + * label can describe and the number of the "whole disk" (raw) + * paritition are machine dependent. + */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +/* + * The absolute maximum number of disk partitions allowed. + * This is the maximum value of MAXPARTITIONS for which 'struct disklabel' + * is <= DEV_BSIZE bytes long. If MAXPARTITIONS is greater than this, beware. + */ +#define MAXMAXPARTITIONS 22 +#if MAXPARTITIONS > MAXMAXPARTITIONS +#warning beware: MAXPARTITIONS bigger than MAXMAXPARTITIONS +#endif + +/* + * Ports can switch their MAXPARTITIONS once, as follows: + * + * - define OLDMAXPARTITIONS in as the old number + * - define MAXPARTITIONS as the new number + * - define DISKUNIT, DISKPART and DISKMINOR macros in + * as appropriate for the port (see the i386 one for an example). + * - define __HAVE_OLD_DISKLABEL in + */ + +#if defined(_KERNEL) && defined(__HAVE_OLD_DISKLABEL) && \ + (MAXPARTITIONS < OLDMAXPARTITIONS) +#error "can only grow disklabel size" +#endif + + +/* + * Translate between device numbers and major/disk unit/disk partition. + */ +#ifndef __HAVE_OLD_DISKLABEL +#if !HAVE_NBTOOL_CONFIG_H +#define DISKUNIT(dev) (minor(dev) / MAXPARTITIONS) +#define DISKPART(dev) (minor(dev) % MAXPARTITIONS) +#define DISKMINOR(unit, part) \ + (((unit) * MAXPARTITIONS) + (part)) +#endif /* !HAVE_NBTOOL_CONFIG_H */ +#endif +#define MAKEDISKDEV(maj, unit, part) \ + (makedev((maj), DISKMINOR((unit), (part)))) + +#define DISKMAGIC ((uint32_t)0x82564557) /* The disk magic number */ + +#ifndef _LOCORE +struct disklabel { + uint32_t d_magic; /* the magic number */ + uint16_t d_type; /* drive type */ + uint16_t d_subtype; /* controller/d_type specific */ + char d_typename[16]; /* type name, e.g. "eagle" */ + + /* + * d_packname contains the pack identifier and is returned when + * the disklabel is read off the disk or in-core copy. + * d_boot0 and d_boot1 are the (optional) names of the + * primary (block 0) and secondary (block 1-15) bootstraps + * as found in /usr/mdec. These are returned when using + * getdiskbyname(3) to retrieve the values from /etc/disktab. + */ + union { + char un_d_packname[16]; /* pack identifier */ + struct { + char *un_d_boot0; /* primary bootstrap name */ + char *un_d_boot1; /* secondary bootstrap name */ + } un_b; + uint64_t un_d_pad; /* force 8 byte alignment */ + } d_un; +#define d_packname d_un.un_d_packname +#define d_boot0 d_un.un_b.un_d_boot0 +#define d_boot1 d_un.un_b.un_d_boot1 + + /* disk geometry: */ + uint32_t d_secsize; /* # of bytes per sector */ + uint32_t d_nsectors; /* # of data sectors per track */ + uint32_t d_ntracks; /* # of tracks per cylinder */ + uint32_t d_ncylinders; /* # of data cylinders per unit */ + uint32_t d_secpercyl; /* # of data sectors per cylinder */ + uint32_t d_secperunit; /* # of data sectors per unit */ + + /* + * Spares (bad sector replacements) below are not counted in + * d_nsectors or d_secpercyl. Spare sectors are assumed to + * be physical sectors which occupy space at the end of each + * track and/or cylinder. + */ + uint16_t d_sparespertrack; /* # of spare sectors per track */ + uint16_t d_sparespercyl; /* # of spare sectors per cylinder */ + /* + * Alternative cylinders include maintenance, replacement, + * configuration description areas, etc. + */ + uint32_t d_acylinders; /* # of alt. cylinders per unit */ + + /* hardware characteristics: */ + /* + * d_interleave, d_trackskew and d_cylskew describe perturbations + * in the media format used to compensate for a slow controller. + * Interleave is physical sector interleave, set up by the + * formatter or controller when formatting. When interleaving is + * in use, logically adjacent sectors are not physically + * contiguous, but instead are separated by some number of + * sectors. It is specified as the ratio of physical sectors + * traversed per logical sector. Thus an interleave of 1:1 + * implies contiguous layout, while 2:1 implies that logical + * sector 0 is separated by one sector from logical sector 1. + * d_trackskew is the offset of sector 0 on track N relative to + * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew + * is the offset of sector 0 on cylinder N relative to sector 0 + * on cylinder N-1. + */ + uint16_t d_rpm; /* rotational speed */ + uint16_t d_interleave; /* hardware sector interleave */ + uint16_t d_trackskew; /* sector 0 skew, per track */ + uint16_t d_cylskew; /* sector 0 skew, per cylinder */ + uint32_t d_headswitch; /* head switch time, usec */ + uint32_t d_trkseek; /* track-to-track seek, usec */ + uint32_t d_flags; /* generic flags */ +#define NDDATA 5 + uint32_t d_drivedata[NDDATA]; /* drive-type specific information */ +#define NSPARE 5 + uint32_t d_spare[NSPARE]; /* reserved for future use */ + uint32_t d_magic2; /* the magic number (again) */ + uint16_t d_checksum; /* xor of data incl. partitions */ + + /* filesystem and partition information: */ + uint16_t d_npartitions; /* number of partitions in following */ + uint32_t d_bbsize; /* size of boot area at sn0, bytes */ + uint32_t d_sbsize; /* max size of fs superblock, bytes */ + struct partition { /* the partition table */ + uint32_t p_size; /* number of sectors in partition */ + uint32_t p_offset; /* starting sector */ + union { + uint32_t fsize; /* FFS, ADOS: + filesystem basic fragment size */ + uint32_t cdsession; /* ISO9660: session offset */ + } __partition_u2; +#define p_fsize __partition_u2.fsize +#define p_cdsession __partition_u2.cdsession + uint8_t p_fstype; /* filesystem type, see below */ + uint8_t p_frag; /* filesystem fragments per block */ + union { + uint16_t cpg; /* UFS: FS cylinders per group */ + uint16_t sgs; /* LFS: FS segment shift */ + } __partition_u1; +#define p_cpg __partition_u1.cpg +#define p_sgs __partition_u1.sgs + } d_partitions[MAXPARTITIONS]; /* actually may be more */ +}; + +#if defined(__HAVE_OLD_DISKLABEL) && !HAVE_NBTOOL_CONFIG_H +/* + * Same as above, but with OLDMAXPARTITIONS partitions. For use in + * the old DIOC* ioctl calls. + */ +struct olddisklabel { + uint32_t d_magic; + uint16_t d_type; + uint16_t d_subtype; + char d_typename[16]; + union { + char un_d_packname[16]; + struct { + char *un_d_boot0; + char *un_d_boot1; + } un_b; + } d_un; + uint32_t d_secsize; + uint32_t d_nsectors; + uint32_t d_ntracks; + uint32_t d_ncylinders; + uint32_t d_secpercyl; + uint32_t d_secperunit; + uint16_t d_sparespertrack; + uint16_t d_sparespercyl; + uint32_t d_acylinders; + uint16_t d_rpm; + uint16_t d_interleave; + uint16_t d_trackskew; + uint16_t d_cylskew; + uint32_t d_headswitch; + uint32_t d_trkseek; + uint32_t d_flags; + uint32_t d_drivedata[NDDATA]; + uint32_t d_spare[NSPARE]; + uint32_t d_magic2; + uint16_t d_checksum; + uint16_t d_npartitions; + uint32_t d_bbsize; + uint32_t d_sbsize; + struct opartition { + uint32_t p_size; + uint32_t p_offset; + union { + uint32_t fsize; + uint32_t cdsession; + } __partition_u2; + uint8_t p_fstype; + uint8_t p_frag; + union { + uint16_t cpg; + uint16_t sgs; + } __partition_u1; + } d_partitions[OLDMAXPARTITIONS]; +}; +#endif /* __HAVE_OLD_DISKLABEL */ +#else /* _LOCORE */ + /* + * offsets for asm boot files. + */ + .set d_secsize,40 + .set d_nsectors,44 + .set d_ntracks,48 + .set d_ncylinders,52 + .set d_secpercyl,56 + .set d_secperunit,60 + .set d_end_,276 /* size of disk label */ +#endif /* _LOCORE */ + +/* + * We normally use C99 initialisers (just in case the lists below are out + * of sequence, or have gaps), but lint doesn't grok them. + * Maybe some host compilers don't either, but many have for quite some time. + */ + +#ifndef lint +#define ARRAY_INIT(element,value) [element]=value +#else +#define ARRAY_INIT(element,value) value +#endif + +/* Use pre-processor magic to get all the parameters one one line... */ + +/* d_type values: */ +#define DKTYPE_DEFN(x) \ +x(UNKNOWN, 0, "unknown") \ +x(SMD, 1, "SMD") /* SMD, XSMD; VAX hp/up */ \ +x(MSCP, 2, "MSCP") /* MSCP */ \ +x(DEC, 3, "old DEC") /* other DEC (rk, rl) */ \ +x(SCSI, 4, "SCSI") /* SCSI */ \ +x(ESDI, 5, "ESDI") /* ESDI interface */ \ +x(ST506, 6, "ST506") /* ST506 etc. */ \ +x(HPIB, 7, "HP-IB") /* CS/80 on HP-IB */ \ +x(HPFL, 8, "HP-FL") /* HP Fiber-link */ \ +x(TYPE_9, 9, "type 9") \ +x(FLOPPY, 10, "floppy") /* floppy */ \ +x(CCD, 11, "ccd") /* concatenated disk device */ \ +x(VND, 12, "vnd") /* uvnode pseudo-disk */ \ +x(ATAPI, 13, "ATAPI") /* ATAPI */ \ +x(RAID, 14, "RAID") /* RAIDframe */ \ +x(LD, 15, "ld") /* logical disk */ \ +x(JFS2, 16, "jfs") /* IBM JFS2 */ \ +x(CGD, 17, "cgd") /* cryptographic pseudo-disk */ \ +x(VINUM, 18, "vinum") /* vinum volume */ \ +x(FLASH, 19, "flash") /* flash memory devices */ \ +x(DM, 20, "dm") /* device-mapper pseudo-disk devices */\ +x(RUMPD, 21, "rumpd") /* rump virtual disk */ \ + +#ifndef _LOCORE +#define DKTYPE_NUMS(tag, number, name) __CONCAT(DTYPE_,tag=number), +#ifndef DKTYPE_ENUMNAME +#define DKTYPE_ENUMNAME +#endif +enum DKTYPE_ENUMNAME { DKTYPE_DEFN(DKTYPE_NUMS) DKMAXTYPES }; +#undef DKTYPE_NUMS +#endif + +#ifdef DKTYPENAMES +#define DKTYPE_NAMES(tag, number, name) ARRAY_INIT(number,name), +static const char *const dktypenames[] = { DKTYPE_DEFN(DKTYPE_NAMES) NULL }; +#undef DKTYPE_NAMES +#endif + +/* + * Partition type names, numbers, label-names, fsck prog, and mount prog + */ +#define FSTYPE_DEFN(x) \ +x(UNUSED, 0, "unused", NULL, NULL) /* unused */ \ +x(SWAP, 1, "swap", NULL, NULL) /* swap */ \ +x(V6, 2, "Version 6", NULL, NULL) /* Sixth Edition */ \ +x(V7, 3, "Version 7", "v7fs", "v7fs") /* Seventh Edition */ \ +x(SYSV, 4, "System V", NULL, NULL) /* System V */ \ +x(V71K, 5, "4.1BSD", NULL, NULL) /* V7, 1K blocks (4.1, 2.9) */ \ +x(V8, 6, "Eighth Edition",NULL, NULL) /* Eighth Edition, 4K blocks */ \ +x(BSDFFS, 7, "4.2BSD", "ffs", "ffs") /* 4.2BSD fast file system */ \ +x(MSDOS, 8, "MSDOS", "msdos", "msdos") /* MSDOS file system */ \ +x(BSDLFS, 9, "4.4LFS", "lfs", "lfs") /* 4.4BSD log-structured FS */ \ +x(OTHER, 10, "unknown", NULL, NULL) /* in use, unknown/unsupported */\ +x(HPFS, 11, "HPFS", NULL, NULL) /* OS/2 high-performance FS */ \ +x(ISO9660, 12, "ISO9660", NULL, "cd9660")/* ISO 9660, normally CD-ROM */ \ +x(BOOT, 13, "boot", NULL, NULL) /* bootstrap code in partition */\ +x(ADOS, 14, "ADOS", NULL, "ados") /* AmigaDOS fast file system */ \ +x(HFS, 15, "HFS", NULL, NULL) /* Macintosh HFS */ \ +x(FILECORE,16, "FILECORE", NULL, "filecore")/* Acorn Filecore FS */ \ +x(EX2FS, 17, "Linux Ext2","ext2fs","ext2fs")/* Linux Extended 2 FS */ \ +x(NTFS, 18, "NTFS", NULL, "ntfs") /* Windows/NT file system */ \ +x(RAID, 19, "RAID", NULL, NULL) /* RAIDframe component */ \ +x(CCD, 20, "ccd", NULL, NULL) /* concatenated disk component */\ +x(JFS2, 21, "jfs", NULL, NULL) /* IBM JFS2 */ \ +x(APPLEUFS,22, "Apple UFS", "ffs", "ffs") /* Apple UFS */ \ +/* XXX this is not the same as FreeBSD. How to solve? */ \ +x(VINUM, 23, "vinum", NULL, NULL) /* Vinum */ \ +x(UDF, 24, "UDF", NULL, "udf") /* UDF */ \ +x(SYSVBFS, 25, "SysVBFS", NULL, "sysvbfs")/* System V boot file system */ \ +x(EFS, 26, "EFS", NULL, "efs") /* SGI's Extent Filesystem */ \ +x(NILFS, 27, "NiLFS", NULL, "nilfs") /* NTT's NiLFS(2) */ \ +x(CGD, 28, "cgd", NULL, NULL) /* Cryptographic disk */ \ +x(MINIXFS3,29, "MINIX FSv3", NULL, NULL) /* MINIX file system v3 */ + + +#ifndef _LOCORE +#define FS_TYPENUMS(tag, number, name, fsck, mount) __CONCAT(FS_,tag=number), +#ifndef FSTYPE_ENUMNAME +#define FSTYPE_ENUMNAME +#endif +enum FSTYPE_ENUMNAME { FSTYPE_DEFN(FS_TYPENUMS) FSMAXTYPES }; +#undef FS_TYPENUMS +#endif + +#ifdef FSTYPENAMES +#define FS_TYPENAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,name), +static const char *const fstypenames[] = { FSTYPE_DEFN(FS_TYPENAMES) NULL }; +#undef FS_TYPENAMES +#endif + +#ifdef FSCKNAMES +/* These are the names MOUNT_XXX from */ +#define FS_FSCKNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,fsck), +static const char *const fscknames[] = { FSTYPE_DEFN(FS_FSCKNAMES) NULL }; +#undef FS_FSCKNAMES +#define FSMAXNAMES FSMAXTYPES +#endif + +#ifdef MOUNTNAMES +/* These are the names MOUNT_XXX from */ +#define FS_MOUNTNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,mount), +static const char *const mountnames[] = { FSTYPE_DEFN(FS_MOUNTNAMES) NULL }; +#undef FS_MOUNTNAMES +#define FSMAXMOUNTNAMES FSMAXTYPES +#endif + +/* + * flags shared by various drives: + */ +#define D_REMOVABLE 0x01 /* removable media */ +#define D_ECC 0x02 /* supports ECC */ +#define D_BADSECT 0x04 /* supports bad sector forw. */ +#define D_RAMDISK 0x08 /* disk emulator */ +#define D_CHAIN 0x10 /* can do back-back transfers */ +#define D_SCSI_MMC 0x20 /* SCSI MMC sessioned media */ + +/* + * Drive data for SMD. + */ +#define d_smdflags d_drivedata[0] +#define D_SSE 0x1 /* supports skip sectoring */ +#define d_mindist d_drivedata[1] +#define d_maxdist d_drivedata[2] +#define d_sdist d_drivedata[3] + +/* + * Drive data for ST506. + */ +#define d_precompcyl d_drivedata[0] +#define d_gap3 d_drivedata[1] /* used only when formatting */ + +/* + * Drive data for SCSI. + */ +#define d_blind d_drivedata[0] + +#ifndef _LOCORE +/* + * Structure used to perform a format or other raw operation, + * returning data and/or register values. Register identification + * and format are device- and driver-dependent. Currently unused. + */ +struct format_op { + char *df_buf; + int df_count; /* value-result */ + daddr_t df_startblk; + int df_reg[8]; /* result */ +}; + +#ifdef _KERNEL +/* + * Structure used internally to retrieve information about a partition + * on a disk. + */ +struct partinfo { + struct disklabel *disklab; + struct partition *part; +}; + +struct disk; + +int disk_read_sectors(void (*)(struct buf *), const struct disklabel *, + struct buf *, unsigned int, int); +void diskerr(const struct buf *, const char *, const char *, int, + int, const struct disklabel *); +u_int dkcksum(struct disklabel *); +u_int dkcksum_sized(struct disklabel *, size_t); +int setdisklabel(struct disklabel *, struct disklabel *, u_long, + struct cpu_disklabel *); +const char *readdisklabel(dev_t, void (*)(struct buf *), + struct disklabel *, struct cpu_disklabel *); +int writedisklabel(dev_t, void (*)(struct buf *), struct disklabel *, + struct cpu_disklabel *); +const char *convertdisklabel(struct disklabel *, void (*)(struct buf *), + struct buf *, uint32_t); +int bounds_check_with_label(struct disk *, struct buf *, int); +int bounds_check_with_mediasize(struct buf *, int, uint64_t); +const char *getfstypename(int); +#endif +#endif /* _LOCORE */ + +#if !defined(_KERNEL) && !defined(_LOCORE) + +#include + +#endif + +#endif /* !_SYS_DISKLABEL_H_ */ diff --git a/sys/sys/exec.h b/sys/sys/exec.h new file mode 100644 index 000000000..9d2ce870e --- /dev/null +++ b/sys/sys/exec.h @@ -0,0 +1,298 @@ +/* $NetBSD: exec.h,v 1.133 2011/03/04 22:25:32 joerg Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. + * + * @(#)exec.h 8.4 (Berkeley) 2/19/95 + */ + +/*- + * Copyright (c) 1993 Theo de Raadt. 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. + */ + +/*- + * Copyright (c) 1994 Christopher G. Demetriou + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)exec.h 8.4 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_EXEC_H_ +#define _SYS_EXEC_H_ + +struct pathbuf; /* from namei.h */ + + +/* + * The following structure is found at the top of the user stack of each + * user process. The ps program uses it to locate argv and environment + * strings. Programs that wish ps to display other information may modify + * it; normally ps_argvstr points to argv[0], and ps_nargvstr is the same + * as the program's argc. The fields ps_envstr and ps_nenvstr are the + * equivalent for the environment. + */ +struct ps_strings { + char **ps_argvstr; /* first of 0 or more argument strings */ + int ps_nargvstr; /* the number of argument strings */ + char **ps_envstr; /* first of 0 or more environment strings */ + int ps_nenvstr; /* the number of environment strings */ +}; + +#ifdef _KERNEL +struct ps_strings32 { + uint32_t ps_argvstr; /* first of 0 or more argument strings */ + int32_t ps_nargvstr; /* the number of argument strings */ + uint32_t ps_envstr; /* first of 0 or more environment strings */ + int32_t ps_nenvstr; /* the number of environment strings */ +}; +#endif + +/* + * the following structures allow execve() to put together processes + * in a more extensible and cleaner way. + * + * the exec_package struct defines an executable being execve()'d. + * it contains the header, the vmspace-building commands, the vnode + * information, and the arguments associated with the newly-execve'd + * process. + * + * the exec_vmcmd struct defines a command description to be used + * in creating the new process's vmspace. + */ + +#include + +struct lwp; +struct proc; +struct exec_package; +struct vnode; + +typedef int (*exec_makecmds_fcn)(struct lwp *, struct exec_package *); + +struct execsw { + u_int es_hdrsz; /* size of header for this format */ + exec_makecmds_fcn es_makecmds; /* function to setup vmcmds */ + union { /* probe function */ + int (*elf_probe_func)(struct lwp *, + struct exec_package *, void *, char *, vaddr_t *); + int (*ecoff_probe_func)(struct lwp *, struct exec_package *); + int (*mach_probe_func)(const char **); + } u; + struct emul *es_emul; /* os emulation */ + int es_prio; /* entry priority */ + int es_arglen; /* Extra argument size in words */ + /* Copy arguments on the new stack */ + int (*es_copyargs)(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + /* Set registers before execution */ + void (*es_setregs)(struct lwp *, struct exec_package *, vaddr_t); + /* Dump core */ + int (*es_coredump)(struct lwp *, void *); + int (*es_setup_stack)(struct lwp *, struct exec_package *); +}; + +#define EXECSW_PRIO_ANY 0x000 /* default, no preference */ +#define EXECSW_PRIO_FIRST 0x001 /* this should be among first */ +#define EXECSW_PRIO_LAST 0x002 /* this should be among last */ + +/* exec vmspace-creation command set; see below */ +struct exec_vmcmd_set { + u_int evs_cnt; + u_int evs_used; + struct exec_vmcmd *evs_cmds; +}; + +#define EXEC_DEFAULT_VMCMD_SETSIZE 9 /* # of cmds in set to start */ + +struct exec_package { + const char *ep_name; /* file's name */ + const char *ep_kname; /* kernel-side copy of file's name */ + char *ep_resolvedname; /* fully resolved path from namei */ + void *ep_hdr; /* file's exec header */ + u_int ep_hdrlen; /* length of ep_hdr */ + u_int ep_hdrvalid; /* bytes of ep_hdr that are valid */ + struct exec_vmcmd_set ep_vmcmds; /* vmcmds used to build vmspace */ + struct vnode *ep_vp; /* executable's vnode */ + struct vattr *ep_vap; /* executable's attributes */ + vaddr_t ep_taddr; /* process's text address */ + vsize_t ep_tsize; /* size of process's text */ + vaddr_t ep_daddr; /* process's data(+bss) address */ + vsize_t ep_dsize; /* size of process's data(+bss) */ + vaddr_t ep_maxsaddr; /* proc's max stack addr ("top") */ + vaddr_t ep_minsaddr; /* proc's min stack addr ("bottom") */ + vsize_t ep_ssize; /* size of process's stack */ + vaddr_t ep_entry; /* process's entry point */ + vaddr_t ep_vm_minaddr; /* bottom of process address space */ + vaddr_t ep_vm_maxaddr; /* top of process address space */ + u_int ep_flags; /* flags; see below. */ + size_t ep_fa_len; /* byte size of ep_fa */ + struct exec_fakearg { + char *fa_arg; + size_t fa_len; + } *ep_fa; /* a fake args vector for scripts */ + int ep_fd; /* a file descriptor we're holding */ + void *ep_emul_arg; /* emulation argument */ + const struct execsw *ep_esch;/* execsw entry */ + struct vnode *ep_emul_root; /* base of emulation filesystem */ + struct vnode *ep_interp; /* vnode of (elf) interpeter */ + uint32_t ep_pax_flags; /* pax flags */ + char *ep_path; /* absolute path of executable */ +}; +#define EXEC_INDIR 0x0001 /* script handling already done */ +#define EXEC_HASFD 0x0002 /* holding a shell script */ +#define EXEC_HASARGL 0x0004 /* has fake args vector */ +#define EXEC_SKIPARG 0x0008 /* don't copy user-supplied argv[0] */ +#define EXEC_DESTR 0x0010 /* destructive ops performed */ +#define EXEC_32 0x0020 /* 32-bit binary emulation */ +#define EXEC_FORCEAUX 0x0040 /* always use ELF AUX vector */ + +struct exec_vmcmd { + int (*ev_proc)(struct lwp *, struct exec_vmcmd *); + /* procedure to run for region of vmspace */ + vsize_t ev_len; /* length of the segment to map */ + vaddr_t ev_addr; /* address in the vmspace to place it at */ + struct vnode *ev_vp; /* vnode pointer for the file w/the data */ + vsize_t ev_offset; /* offset in the file for the data */ + u_int ev_prot; /* protections for segment */ + int ev_flags; +#define VMCMD_RELATIVE 0x0001 /* ev_addr is relative to base entry */ +#define VMCMD_BASE 0x0002 /* marks a base entry */ +#define VMCMD_FIXED 0x0004 /* entry must be mapped at ev_addr */ +#define VMCMD_STACK 0x0008 /* entry is for a stack */ +}; + +#ifdef _KERNEL +/* + * funtions used either by execve() or the various CPU-dependent execve() + * hooks. + */ +void kill_vmcmd (struct exec_vmcmd **); +int exec_makecmds (struct lwp *, struct exec_package *); +int exec_runcmds (struct lwp *, struct exec_package *); +void vmcmdset_extend (struct exec_vmcmd_set *); +void kill_vmcmds (struct exec_vmcmd_set *); +int vmcmd_map_pagedvn (struct lwp *, struct exec_vmcmd *); +int vmcmd_map_readvn (struct lwp *, struct exec_vmcmd *); +int vmcmd_readvn (struct lwp *, struct exec_vmcmd *); +int vmcmd_map_zero (struct lwp *, struct exec_vmcmd *); +int copyargs (struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); +int copyin_psstrings (struct proc *, struct ps_strings *); +int copy_procargs (struct proc *, int, size_t *, + int (*)(void *, const void *, size_t, size_t), void *); +void setregs (struct lwp *, struct exec_package *, vaddr_t); +int check_veriexec (struct lwp *, struct vnode *, + struct exec_package *, int); +int check_exec (struct lwp *, struct exec_package *, + struct pathbuf *); +int exec_init (int); +int exec_read_from (struct lwp *, struct vnode *, u_long off, + void *, size_t); +int exec_setup_stack (struct lwp *, struct exec_package *); + +int coredump_write (void *, enum uio_seg, const void *, size_t); +/* + * Machine dependent functions + */ +struct core; +struct core32; +int cpu_coredump(struct lwp *, void *, struct core *); +int cpu_coredump32(struct lwp *, void *, struct core32 *); + +int exec_add(struct execsw *, int); +int exec_remove(struct execsw *, int); + +void new_vmcmd(struct exec_vmcmd_set *, + int (*)(struct lwp *, struct exec_vmcmd *), + vsize_t, vaddr_t, struct vnode *, u_long, u_int, int); +#define NEW_VMCMD(evsp,lwp,len,addr,vp,offset,prot) \ + new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,0) +#define NEW_VMCMD2(evsp,lwp,len,addr,vp,offset,prot,flags) \ + new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,flags) + +typedef int (*execve_fetch_element_t)(char * const *, size_t, char **); +int execve1(struct lwp *, const char *, char * const *, char * const *, + execve_fetch_element_t); + +extern int maxexec; + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_H_ */ diff --git a/sys/sys/mount.h b/sys/sys/mount.h new file mode 100644 index 000000000..bccf8b158 --- /dev/null +++ b/sys/sys/mount.h @@ -0,0 +1,466 @@ +/* $NetBSD: mount.h,v 1.201 2011/10/12 23:04:22 dholland Exp $ */ + +/* + * Copyright (c) 1989, 1991, 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 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. + * + * @(#)mount.h 8.21 (Berkeley) 5/20/95 + */ + +#ifndef _SYS_MOUNT_H_ +#define _SYS_MOUNT_H_ + +#ifndef _KERNEL +#include +#if defined(_NETBSD_SOURCE) +#include +#endif /* _NETBSD_SOURCE */ +#endif + +#ifndef _STANDALONE +#include /* precautionary upon removal from ucred.h */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* !_STANDALONE */ + +/* + * file system statistics + */ + +#define MNAMELEN 90 /* length of buffer for returned name */ + +/* + * File system types. + */ +#define MOUNT_FFS "ffs" /* UNIX "Fast" Filesystem */ +#define MOUNT_UFS MOUNT_FFS /* for compatibility */ +#define MOUNT_NFS "nfs" /* Network Filesystem */ +#define MOUNT_MFS "mfs" /* Memory Filesystem */ +#define MOUNT_MSDOS "msdos" /* MSDOS Filesystem */ +#define MOUNT_LFS "lfs" /* Log-based Filesystem */ +#define MOUNT_FDESC "fdesc" /* File Descriptor Filesystem */ +#define MOUNT_NULL "null" /* Minimal Filesystem Layer */ +#define MOUNT_OVERLAY "overlay" /* Minimal Overlay Filesystem Layer */ +#define MOUNT_UMAP "umap" /* User/Group Identifier Remapping Filesystem */ +#define MOUNT_KERNFS "kernfs" /* Kernel Information Filesystem */ +#define MOUNT_PROCFS "procfs" /* /proc Filesystem */ +#define MOUNT_AFS "afs" /* Andrew Filesystem */ +#define MOUNT_CD9660 "cd9660" /* ISO9660 (aka CDROM) Filesystem */ +#define MOUNT_UNION "union" /* Union (translucent) Filesystem */ +#define MOUNT_ADOSFS "adosfs" /* AmigaDOS Filesystem */ +#define MOUNT_EXT2FS "ext2fs" /* Second Extended Filesystem */ +#define MOUNT_CFS "coda" /* Coda Filesystem */ +#define MOUNT_CODA MOUNT_CFS /* Coda Filesystem */ +#define MOUNT_FILECORE "filecore" /* Acorn Filecore Filesystem */ +#define MOUNT_NTFS "ntfs" /* Windows/NT Filesystem */ +#define MOUNT_SMBFS "smbfs" /* CIFS (SMB) */ +#define MOUNT_PTYFS "ptyfs" /* Pseudo tty filesystem */ +#define MOUNT_TMPFS "tmpfs" /* Efficient memory file-system */ +#define MOUNT_UDF "udf" /* UDF CD/DVD filesystem */ +#define MOUNT_SYSVBFS "sysvbfs" /* System V Boot Filesystem */ +#define MOUNT_PUFFS "puffs" /* Pass-to-Userspace filesystem */ +#define MOUNT_HFS "hfs" /* Apple HFS+ Filesystem */ +#define MOUNT_EFS "efs" /* SGI's Extent Filesystem */ +#define MOUNT_ZFS "zfs" /* Sun ZFS */ +#define MOUNT_NILFS "nilfs" /* NTT's NiLFS(2) logging file system */ +#define MOUNT_RUMPFS "rumpfs" /* rump virtual file system */ +#define MOUNT_V7FS "v7fs" /* 7th Edition of Unix Filesystem */ + +#ifndef _STANDALONE + +struct vnode; + +/* + * Structure per mounted file system. Each mounted file system has an + * array of operations and an instance record. The file systems are + * put on a doubly linked list. + */ +struct mount { + CIRCLEQ_ENTRY(mount) mnt_list; /* mount list */ + TAILQ_HEAD(, vnode) mnt_vnodelist; /* list of vnodes this mount */ + struct vfsops *mnt_op; /* operations on fs */ + struct vnode *mnt_vnodecovered; /* vnode we mounted on */ + struct vnode *mnt_syncer; /* syncer vnode */ + void *mnt_transinfo; /* for FS-internal use */ + void *mnt_data; /* private data */ + krwlock_t mnt_unmounting; /* to prevent new activity */ + kmutex_t mnt_renamelock; /* per-fs rename lock */ + int mnt_refcnt; /* ref count on this structure */ + int mnt_recursecnt; /* count of write locks */ + int mnt_flag; /* flags */ + int mnt_iflag; /* internal flags */ + int mnt_fs_bshift; /* offset shift for lblkno */ + int mnt_dev_bshift; /* shift for device sectors */ + struct statvfs mnt_stat; /* cache of filesystem stats */ + specificdata_reference + mnt_specdataref; /* subsystem specific data */ + kmutex_t mnt_updating; /* to serialize updates */ + struct wapbl_ops + *mnt_wapbl_op; /* logging ops */ + struct wapbl *mnt_wapbl; /* log info */ + struct wapbl_replay + *mnt_wapbl_replay; /* replay support XXX: what? */ + uint64_t mnt_gen; +}; + +/* + * Sysctl CTL_VFS definitions. + * + * Second level identifier specifies which filesystem. Second level + * identifier VFS_GENERIC returns information about all filesystems. + * + * Note the slightly non-flat nature of these sysctl numbers. Oh for + * a better sysctl interface. + */ +#define VFS_GENERIC 0 /* generic filesystem information */ +#define VFS_MAXTYPENUM 1 /* int: highest defined fs type */ +#define VFS_CONF 2 /* struct: vfsconf for filesystem given + as next argument */ +#define VFS_USERMOUNT 3 /* enable/disable fs mnt by non-root */ +#define VFS_MAGICLINKS 4 /* expand 'magic' symlinks */ +#define VFSGEN_MAXID 5 /* number of valid vfs.generic ids */ + +/* + * USE THE SAME NAMES AS MOUNT_*! + * + * Only need to add new entry here if the filesystem actually supports + * sysctl(2). + */ +#define CTL_VFS_NAMES { \ + { "generic", CTLTYPE_NODE }, \ + { MOUNT_FFS, CTLTYPE_NODE }, \ + { MOUNT_NFS, CTLTYPE_NODE }, \ + { MOUNT_MFS, CTLTYPE_NODE }, \ + { MOUNT_MSDOS, CTLTYPE_NODE }, \ + { MOUNT_LFS, CTLTYPE_NODE }, \ + { 0, 0 }, /* MOUNT_LOFS */ \ + { MOUNT_FDESC, CTLTYPE_NODE }, \ + { MOUNT_NULL, CTLTYPE_NODE }, \ + { MOUNT_UMAP, CTLTYPE_NODE }, \ + { MOUNT_KERNFS, CTLTYPE_NODE }, \ + { MOUNT_PROCFS, CTLTYPE_NODE }, \ + { MOUNT_AFS, CTLTYPE_NODE }, \ + { MOUNT_CD9660, CTLTYPE_NODE }, \ + { MOUNT_UNION, CTLTYPE_NODE }, \ + { MOUNT_ADOSFS, CTLTYPE_NODE }, \ + { MOUNT_EXT2FS, CTLTYPE_NODE }, \ + { MOUNT_CODA, CTLTYPE_NODE }, \ + { MOUNT_FILECORE, CTLTYPE_NODE }, \ + { MOUNT_NTFS, CTLTYPE_NODE }, \ +} + +#define VFS_MAXID 20 /* number of valid vfs ids */ + +#define CTL_VFSGENCTL_NAMES { \ + { 0, 0 }, \ + { "maxtypenum", CTLTYPE_INT }, \ + { "conf", CTLTYPE_NODE }, /* Special */ \ + { "usermount", CTLTYPE_INT }, \ + { "magiclinks", CTLTYPE_INT }, \ +} + +#if defined(_KERNEL) +#include +#if __STDC__ +struct nameidata; +#endif + +/* + * Operations supported on mounted file system. + */ + +struct vfsops { + const char *vfs_name; + size_t vfs_min_mount_data; + int (*vfs_mount) (struct mount *, const char *, void *, + size_t *); + int (*vfs_start) (struct mount *, int); + int (*vfs_unmount) (struct mount *, int); + int (*vfs_root) (struct mount *, struct vnode **); + int (*vfs_quotactl) (struct mount *, prop_dictionary_t); + int (*vfs_statvfs) (struct mount *, struct statvfs *); + int (*vfs_sync) (struct mount *, int, struct kauth_cred *); + int (*vfs_vget) (struct mount *, ino_t, struct vnode **); + int (*vfs_fhtovp) (struct mount *, struct fid *, + struct vnode **); + int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *); + void (*vfs_init) (void); + void (*vfs_reinit) (void); + void (*vfs_done) (void); + int (*vfs_mountroot)(void); + int (*vfs_snapshot) (struct mount *, struct vnode *, + struct timespec *); + int (*vfs_extattrctl) (struct mount *, int, + struct vnode *, int, const char *); + int (*vfs_suspendctl) (struct mount *, int); + int (*vfs_renamelock_enter)(struct mount *); + void (*vfs_renamelock_exit)(struct mount *); + int (*vfs_fsync) (struct vnode *, int); + const struct vnodeopv_desc * const *vfs_opv_descs; + int vfs_refcount; + LIST_ENTRY(vfsops) vfs_list; +}; + +/* XXX vget is actually file system internal. */ +#define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) + +#define VFS_RENAMELOCK_ENTER(MP) (*(MP)->mnt_op->vfs_renamelock_enter)(MP) +#define VFS_RENAMELOCK_EXIT(MP) (*(MP)->mnt_op->vfs_renamelock_exit)(MP) +#define VFS_FSYNC(MP, VP, FLG) (*(MP)->mnt_op->vfs_fsync)(VP, FLG) + +int VFS_MOUNT(struct mount *, const char *, void *, size_t *); +int VFS_START(struct mount *, int); +int VFS_UNMOUNT(struct mount *, int); +int VFS_ROOT(struct mount *, struct vnode **); +int VFS_QUOTACTL(struct mount *, prop_dictionary_t); +int VFS_STATVFS(struct mount *, struct statvfs *); +int VFS_SYNC(struct mount *, int, struct kauth_cred *); +int VFS_FHTOVP(struct mount *, struct fid *, struct vnode **); +int VFS_VPTOFH(struct vnode *, struct fid *, size_t *); +int VFS_SNAPSHOT(struct mount *, struct vnode *, struct timespec *); +int VFS_EXTATTRCTL(struct mount *, int, struct vnode *, int, const char *); +int VFS_SUSPENDCTL(struct mount *, int); + +#endif /* _KERNEL */ + +#ifdef _KERNEL +#if __STDC__ +struct mbuf; +struct vnodeopv_desc; +struct kauth_cred; +#endif + +#define VFS_MAX_MOUNT_DATA 8192 + +#define VFS_PROTOS(fsname) \ +int fsname##_mount(struct mount *, const char *, void *, \ + size_t *); \ +int fsname##_start(struct mount *, int); \ +int fsname##_unmount(struct mount *, int); \ +int fsname##_root(struct mount *, struct vnode **); \ +int fsname##_quotactl(struct mount *, prop_dictionary_t); \ +int fsname##_statvfs(struct mount *, struct statvfs *); \ +int fsname##_sync(struct mount *, int, struct kauth_cred *); \ +int fsname##_vget(struct mount *, ino_t, struct vnode **); \ +int fsname##_fhtovp(struct mount *, struct fid *, struct vnode **); \ +int fsname##_vptofh(struct vnode *, struct fid *, size_t *); \ +void fsname##_init(void); \ +void fsname##_reinit(void); \ +void fsname##_done(void); \ +int fsname##_mountroot(void); \ +int fsname##_snapshot(struct mount *, struct vnode *, \ + struct timespec *); \ +int fsname##_extattrctl(struct mount *, int, struct vnode *, int, \ + const char *); \ +int fsname##_suspendctl(struct mount *, int) + +/* + * This operations vector is so wapbl can be wrapped into a filesystem lkm. + * XXX Eventually, we want to move this functionality + * down into the filesystems themselves so that this isn't needed. + */ +struct wapbl_ops { + void (*wo_wapbl_discard)(struct wapbl *); + int (*wo_wapbl_replay_isopen)(struct wapbl_replay *); + int (*wo_wapbl_replay_can_read)(struct wapbl_replay *, daddr_t, long); + int (*wo_wapbl_replay_read)(struct wapbl_replay *, void *, daddr_t, long); + void (*wo_wapbl_add_buf)(struct wapbl *, struct buf *); + void (*wo_wapbl_remove_buf)(struct wapbl *, struct buf *); + void (*wo_wapbl_resize_buf)(struct wapbl *, struct buf *, long, long); + int (*wo_wapbl_begin)(struct wapbl *, const char *, int); + void (*wo_wapbl_end)(struct wapbl *); + void (*wo_wapbl_junlock_assert)(struct wapbl *); + void (*wo_wapbl_biodone)(struct buf *); +}; +#define WAPBL_DISCARD(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_discard)((MP)->mnt_wapbl) +#define WAPBL_REPLAY_ISOPEN(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_replay_isopen)((MP)->mnt_wapbl_replay) +#define WAPBL_REPLAY_CAN_READ(MP, BLK, LEN) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_replay_can_read)((MP)->mnt_wapbl_replay, \ + (BLK), (LEN)) +#define WAPBL_REPLAY_READ(MP, DATA, BLK, LEN) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_replay_read)((MP)->mnt_wapbl_replay, \ + (DATA), (BLK), (LEN)) +#define WAPBL_ADD_BUF(MP, BP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_add_buf)((MP)->mnt_wapbl, (BP)) +#define WAPBL_REMOVE_BUF(MP, BP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_remove_buf)((MP)->mnt_wapbl, (BP)) +#define WAPBL_RESIZE_BUF(MP, BP, OLDSZ, OLDCNT) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_resize_buf)((MP)->mnt_wapbl, (BP), \ + (OLDSZ), (OLDCNT)) +#define WAPBL_BEGIN(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_begin)((MP)->mnt_wapbl, \ + __FILE__, __LINE__) +#define WAPBL_END(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_end)((MP)->mnt_wapbl) +#define WAPBL_JUNLOCK_ASSERT(MP) \ + (*(MP)->mnt_wapbl_op->wo_wapbl_junlock_assert)((MP)->mnt_wapbl) + +struct vfs_hooks { + LIST_ENTRY(vfs_hooks) vfs_hooks_list; + void (*vh_unmount)(struct mount *); + int (*vh_reexport)(struct mount *, const char *, void *); + void (*vh_future_expansion_1)(void); + void (*vh_future_expansion_2)(void); + void (*vh_future_expansion_3)(void); + void (*vh_future_expansion_4)(void); + void (*vh_future_expansion_5)(void); +}; + +void vfs_hooks_init(void); +int vfs_hooks_attach(struct vfs_hooks *); +int vfs_hooks_detach(struct vfs_hooks *); +void vfs_hooks_unmount(struct mount *); +int vfs_hooks_reexport(struct mount *, const char *, void *); + +#endif /* _KERNEL */ + +/* + * Export arguments for local filesystem mount calls. + * + * This structure is deprecated and is only provided for compatibility + * reasons with old binary utilities; several file systems expose an + * instance of this structure in their mount arguments structure, thus + * needing a padding in place of the old values. This definition cannot + * change in the future due to this reason. + * XXX: This should be moved to the compat subtree but cannot be done + * until we can move the mount args structures themselves. + * + * The current export_args structure can be found in nfs/nfs.h. + */ +struct export_args30 { + int ex_flags; /* export related flags */ + uid_t ex_root; /* mapping for root uid */ + struct uucred ex_anon; /* mapping for anonymous user */ + struct sockaddr *ex_addr; /* net address to which exported */ + int ex_addrlen; /* and the net address length */ + struct sockaddr *ex_mask; /* mask of valid bits in saddr */ + int ex_masklen; /* and the smask length */ + char *ex_indexfile; /* index file for WebNFS URLs */ +}; + +struct mnt_export_args30 { + const char *fspec; /* Always NULL */ + struct export_args30 eargs; +}; + +#ifdef _KERNEL + +/* + * exported VFS interface (see vfssubr(9)) + */ +struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */ +int vfs_composefh(struct vnode *, fhandle_t *, size_t *); +int vfs_composefh_alloc(struct vnode *, fhandle_t **); +void vfs_composefh_free(fhandle_t *); +int vfs_fhtovp(fhandle_t *, struct vnode **); +int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */ +int vfs_mountroot(void); +void vfs_shutdown(void); /* unmount and sync file systems */ +void vfs_sync_all(struct lwp *); +bool vfs_unmountall(struct lwp *); /* unmount file systems */ +bool vfs_unmountall1(struct lwp *, bool, bool); +bool vfs_unmount_forceone(struct lwp *); +int vfs_busy(struct mount *, struct mount **); +int vfs_rootmountalloc(const char *, const char *, struct mount **); +void vfs_unbusy(struct mount *, bool, struct mount **); +int vfs_attach(struct vfsops *); +int vfs_detach(struct vfsops *); +void vfs_reinit(void); +struct vfsops *vfs_getopsbyname(const char *); +void vfs_delref(struct vfsops *); +void vfs_destroy(struct mount *); +void vfs_scrubvnlist(struct mount *); +struct mount *vfs_mountalloc(struct vfsops *, struct vnode *); +int vfs_stdextattrctl(struct mount *, int, struct vnode *, + int, const char *); +void vfs_insmntque(struct vnode *, struct mount *); + +extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ +extern struct vfsops *vfssw[]; /* filesystem type table */ +extern int nvfssw; +extern kmutex_t mountlist_lock; +extern kmutex_t vfs_list_lock; + +void vfs_mount_sysinit(void); +long makefstype(const char *); +int mount_domount(struct lwp *, struct vnode **, struct vfsops *, + const char *, int, void *, size_t *); +int dounmount(struct mount *, int, struct lwp *); +int do_sys_mount(struct lwp *, struct vfsops *, const char *, const char *, + int, void *, enum uio_seg, size_t, register_t *); +void vfsinit(void); +void vfs_opv_init(const struct vnodeopv_desc * const *); +void vfs_opv_free(const struct vnodeopv_desc * const *); +#ifdef DEBUG +void vfs_bufstats(void); +#endif + +int mount_specific_key_create(specificdata_key_t *, specificdata_dtor_t); +void mount_specific_key_delete(specificdata_key_t); +void mount_initspecific(struct mount *); +void mount_finispecific(struct mount *); +void * mount_getspecific(struct mount *, specificdata_key_t); +void mount_setspecific(struct mount *, specificdata_key_t, void *); + +int usermount_common_policy(struct mount *, u_long); + +LIST_HEAD(vfs_list_head, vfsops); +extern struct vfs_list_head vfs_list; + +#else /* _KERNEL */ + +#include + +__BEGIN_DECLS +#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE) +int getfh(const char *, void *, size_t *) + __RENAME(__getfh30); +#endif + +int unmount(const char *, int); +#if defined(_NETBSD_SOURCE) +#ifndef __LIBC12_SOURCE__ +int mount(const char *, const char *, int, void *, size_t) __RENAME(__mount50); +int fhopen(const void *, size_t, int) __RENAME(__fhopen40); +int fhstat(const void *, size_t, struct stat *) __RENAME(__fhstat50); +#endif +#endif /* _NETBSD_SOURCE */ +__END_DECLS + +#endif /* _KERNEL */ +#endif /* !_STANDALONE */ + +#endif /* !_SYS_MOUNT_H_ */ diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h new file mode 100644 index 000000000..d802ad9d0 --- /dev/null +++ b/sys/sys/mutex.h @@ -0,0 +1,216 @@ +/* $NetBSD: mutex.h,v 1.20 2010/02/08 09:54:27 skrll Exp $ */ + +/*- + * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * 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 + * 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. + */ + +#ifndef _SYS_MUTEX_H_ +#define _SYS_MUTEX_H_ + +/* + * There are 2 types of mutexes: + * + * * Adaptive -- If the lock is already held, the thread attempting + * to acquire the lock determines if the thread that holds it is + * currently running. If so, it spins, else it sleeps. + * + * * Spin -- If the lock is already held, the thread attempting to + * acquire the lock spins. The IPL will be raised on entry. + * + * Machine dependent code must provide the following: + * + * struct mutex + * The actual mutex structure. This structure is mostly + * opaque to machine-independent code; most access are done + * through macros. However, machine-independent code must + * be able to access the following members: + * + * uintptr_t mtx_owner + * ipl_cookie_t mtx_ipl + * __cpu_simple_lock_t mtx_lock + * + * If an architecture can be considered 'simple' (no interlock required in + * the MP case, or no MP) it need only define __HAVE_SIMPLE_MUTEXES and + * provide the following: + * + * struct mutex + * + * [additionally:] + * volatile integer mtx_id + * + * MUTEX_RECEIVE(mtx) + * Post a load fence after acquiring the mutex, if necessary. + * + * MUTEX_GIVE(mtx) + * Post a load/store fence after releasing the mutex, if + * necessary. + * + * MUTEX_CAS(ptr, old, new) + * Perform an atomic "compare and swap" operation and + * evaluate to true or false according to the success + * + * Otherwise, the following must be defined: + * + * MUTEX_INITIALIZE_SPIN(mtx, dodebug, minipl) + * Initialize a spin mutex. + * + * MUTEX_INITIALIZE_ADAPTIVE(mtx, dodebug) + * Initialize an adaptive mutex. + * + * MUTEX_DESTROY(mtx) + * Tear down a mutex. + * + * MUTEX_ADAPTIVE_P(mtx) + * Evaluates to true if the mutex is an adaptive mutex. + * + * MUTEX_SPIN_P(mtx) + * Evaluates to true if the mutex is a spin mutex. + * + * MUTEX_OWNER(owner) + * Returns the owner of the adaptive mutex (LWP address). + * + * MUTEX_OWNED(owner) + * Returns non-zero if an adaptive mutex is currently + * held by an LWP. + * + * MUTEX_HAS_WAITERS(mtx) + * Returns true if the mutex has waiters. + * + * MUTEX_SET_WAITERS(mtx) + * Mark the mutex has having waiters. + * + * MUTEX_ACQUIRE(mtx, owner) + * Try to acquire an adaptive mutex such that: + * if (lock held OR waiters) + * return 0; + * else + * return 1; + * Must be MP/interrupt atomic. + * + * MUTEX_RELEASE(mtx) + * Release the lock and clear the "has waiters" indication. + * Must be interrupt atomic, need not be MP safe. + * + * MUTEX_DEBUG_P(mtx) + * Evaluates to true if the mutex is initialized with + * dodebug==true. Only used in the LOCKDEBUG case. + * + * Machine dependent code may optionally provide stubs for the following + * functions to implement the easy (unlocked / no waiters) cases. If + * these stubs are provided, __HAVE_MUTEX_STUBS should be defined. + * + * mutex_enter() + * mutex_exit() + * + * Two additional stubs may be implemented that handle only the spinlock + * case, primarily for the scheduler. __HAVE_SPIN_MUTEX_STUBS should be + * defined if these are provided: + * + * mutex_spin_enter() + * mutex_spin_exit() + */ + +#if defined(_KERNEL_OPT) +#include "opt_lockdebug.h" +#endif + +#if !defined(_KERNEL) +#include +#include +#endif + +typedef enum kmutex_type_t { + MUTEX_SPIN = 0, /* To get a spin mutex at IPL_NONE */ + MUTEX_ADAPTIVE = 1, /* For porting code written for Solaris */ + MUTEX_DEFAULT = 2, /* The only native, endorsed type */ + MUTEX_DRIVER = 3, /* For porting code written for Solaris */ + MUTEX_NODEBUG = 4 /* Disables LOCKDEBUG; use with care */ +} kmutex_type_t; + +typedef struct kmutex kmutex_t; + +#if defined(__MUTEX_PRIVATE) + +#define MUTEX_THREAD ((uintptr_t)-16L) + +#define MUTEX_BIT_SPIN 0x01 +#define MUTEX_BIT_WAITERS 0x02 + +#if defined(LOCKDEBUG) +#define MUTEX_BIT_NODEBUG 0x04 /* LOCKDEBUG disabled */ +#else +#define MUTEX_BIT_NODEBUG 0x00 /* do nothing */ +#endif /* LOCKDEBUG */ + +#define MUTEX_SPIN_IPL(mtx) ((mtx)->mtx_ipl) +#define MUTEX_SPIN_OLDSPL(ci) ((ci)->ci_mtx_oldspl) + +void mutex_vector_enter(kmutex_t *); +void mutex_vector_exit(kmutex_t *); +void mutex_spin_retry(kmutex_t *); +void mutex_wakeup(kmutex_t *); + +#endif /* __MUTEX_PRIVATE */ + +#ifdef _KERNEL +#include +#endif + +#include + +/* + * Return true if no spin mutexes are held by the current CPU. + */ +#ifndef MUTEX_NO_SPIN_ACTIVE_P +#define MUTEX_NO_SPIN_ACTIVE_P(ci) ((ci)->ci_mtx_count == 0) +#endif + +#ifdef _KERNEL + +void mutex_init(kmutex_t *, kmutex_type_t, int); +void mutex_destroy(kmutex_t *); + +void mutex_enter(kmutex_t *); +void mutex_exit(kmutex_t *); + +void mutex_spin_enter(kmutex_t *); +void mutex_spin_exit(kmutex_t *); + +int mutex_tryenter(kmutex_t *); + +int mutex_owned(kmutex_t *); +lwp_t *mutex_owner(kmutex_t *); + +void mutex_obj_init(void); +kmutex_t *mutex_obj_alloc(kmutex_type_t, int); +void mutex_obj_hold(kmutex_t *); +bool mutex_obj_free(kmutex_t *); + +#endif /* _KERNEL */ + +#endif /* _SYS_MUTEX_H_ */ diff --git a/sys/sys/reboot.h b/sys/sys/reboot.h new file mode 100644 index 000000000..93f7a2755 --- /dev/null +++ b/sys/sys/reboot.h @@ -0,0 +1,124 @@ +/* $NetBSD: reboot.h,v 1.25 2007/12/25 18:33:48 perry Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1988, 1993, 1994 + * 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. + * + * @(#)reboot.h 8.3 (Berkeley) 12/13/94 + */ + +#ifndef _SYS_REBOOT_H_ +#define _SYS_REBOOT_H_ + +/* + * Arguments to reboot system call. These are passed to the boot program, + * and then on to init. + */ +#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */ + +#define RB_ASKNAME 0x00000001 /* ask for file name to reboot from */ +#define RB_SINGLE 0x00000002 /* reboot to single user only */ +#define RB_NOSYNC 0x00000004 /* dont sync before reboot */ +#define RB_HALT 0x00000008 /* don't reboot, just halt */ +#define RB_INITNAME 0x00000010 /* name given for /etc/init (unused) */ +#define __RB_UNUSED1 0x00000020 /* was RB_DFLTROOT, obsolete */ +#define RB_KDB 0x00000040 /* give control to kernel debugger */ +#define RB_RDONLY 0x00000080 /* mount root fs read-only */ +#define RB_DUMP 0x00000100 /* dump kernel memory before reboot */ +#define RB_MINIROOT 0x00000200 /* mini-root present in memory */ +#define RB_STRING 0x00000400 /* use provided bootstr */ +#define RB_POWERDOWN (RB_HALT|0x800) /* turn power off (or at least halt) */ +#define RB_USERCONF 0x00001000 /* change configured devices */ + +/* + * Extra autoboot flags (passed by boot prog to kernel). See also + * macros bootverbose, bootquiet in . + */ +#define AB_NORMAL 0x00000000 /* boot normally (default) */ +#define AB_QUIET 0x00010000 /* boot quietly */ +#define AB_VERBOSE 0x00020000 /* boot verbosely */ +#define AB_SILENT 0x00040000 /* boot silently */ +#define AB_DEBUG 0x00080000 /* boot with debug messages */ + +/* + * The top 4 bits are architecture specific and are used to + * pass information between the bootblocks and the machine + * initialization code. + */ +#define RB_MD1 0x10000000 +#define RB_MD2 0x20000000 +#define RB_MD3 0x40000000 +#define RB_MD4 0x80000000 + +/* + * Constants for converting boot-style device number to type, + * adaptor (uba, mba, etc), unit number and partition number. + * Type (== major device number) is in the low byte + * for backward compatibility. Except for that of the "magic + * number", each mask applies to the shifted value. + * Format: + * (4) (4) (4) (4) (8) (8) + * -------------------------------- + * |MA | AD| CT| UN| PART | TYPE | + * -------------------------------- + */ +#define B_ADAPTORSHIFT 24 +#define B_ADAPTORMASK 0x0f +#define B_ADAPTOR(val) (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK) +#define B_CONTROLLERSHIFT 20 +#define B_CONTROLLERMASK 0xf +#define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK) +#define B_UNITSHIFT 16 +#define B_UNITMASK 0xf +#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK) +#define B_PARTITIONSHIFT 8 +#define B_PARTITIONMASK 0xff +#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK) +#define B_TYPESHIFT 0 +#define B_TYPEMASK 0xff +#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK) + +#define B_MAGICMASK 0xf0000000 +#define B_DEVMAGIC 0xa0000000 + +#define MAKEBOOTDEV(type, adaptor, controller, unit, partition) \ + (((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \ + ((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \ + ((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC) + +#ifdef _KERNEL + +__BEGIN_DECLS + +void cpu_reboot(int, char *) + __dead; + +__END_DECLS + +#endif /* _KERNEL */ + +#endif /* !_SYS_REBOOT_H_ */ diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h new file mode 100644 index 000000000..e64a1dca2 --- /dev/null +++ b/sys/sys/rwlock.h @@ -0,0 +1,121 @@ +/* $NetBSD: rwlock.h,v 1.10 2010/02/08 09:54:27 skrll Exp $ */ + +/*- + * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * 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 + * 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. + */ + +#ifndef _SYS_RWLOCK_H_ +#define _SYS_RWLOCK_H_ + +/* + * The rwlock provides exclusive access when held as a "writer", + * and shared access when held as a "reader". + * + * Architectures may optionally provide stubs for the following functions to + * implement the easy (unlocked, no waiters) cases. If these stubs are + * provided, __HAVE_RW_STUBS should be defined. + * + * rw_enter() + * rw_exit() + * rw_tryenter() + */ + +#if defined(_KERNEL_OPT) +#include "opt_lockdebug.h" +#endif + +#if !defined(_KERNEL) +#include +#include +#endif + +typedef enum krw_t { + RW_READER = 0, + RW_WRITER = 1 +} krw_t; + +typedef struct krwlock krwlock_t; + +#ifdef __RWLOCK_PRIVATE +/* + * Bits in the owner field of the lock that indicate lock state. If the + * WRITE_LOCKED bit is clear, then the owner field is actually a count of + * the number of readers. The rw_owner field is laid out like so: + * + * N 4 3 2 1 0 + * +---------------------------------------------------------+ + * | owner or read count | nodbug | wrlock | wrwant | wait | + * +---------------------------------------------------------+ + */ +#define RW_HAS_WAITERS 0x01UL /* lock has waiters */ +#define RW_WRITE_WANTED 0x02UL /* >= 1 waiter is a writer */ +#define RW_WRITE_LOCKED 0x04UL /* lock is currently write locked */ +#if defined(LOCKDEBUG) +#define RW_NODEBUG 0x08UL /* LOCKDEBUG disabled */ +#else +#define RW_NODEBUG 0x00UL /* do nothing */ +#endif /* LOCKDEBUG */ + +#define RW_READ_COUNT_SHIFT 4 +#define RW_READ_INCR (1UL << RW_READ_COUNT_SHIFT) +#define RW_THREAD ((uintptr_t)-RW_READ_INCR) +#define RW_OWNER(rw) ((rw)->rw_owner & RW_THREAD) +#define RW_COUNT(rw) ((rw)->rw_owner & RW_THREAD) +#define RW_FLAGS(rw) ((rw)->rw_owner & ~RW_THREAD) + +void rw_vector_enter(krwlock_t *, const krw_t); +void rw_vector_exit(krwlock_t *); +int rw_vector_tryenter(krwlock_t *, const krw_t); +#endif /* __RWLOCK_PRIVATE */ + +#include + +#ifdef _KERNEL + +void rw_init(krwlock_t *); +void rw_destroy(krwlock_t *); + +int rw_tryenter(krwlock_t *, const krw_t); +int rw_tryupgrade(krwlock_t *); +void rw_downgrade(krwlock_t *); + +int rw_read_held(krwlock_t *); +int rw_write_held(krwlock_t *); +int rw_lock_held(krwlock_t *); + +void rw_enter(krwlock_t *, const krw_t); +void rw_exit(krwlock_t *); + +void rw_obj_init(void); +krwlock_t *rw_obj_alloc(void); +void rw_obj_hold(krwlock_t *); +bool rw_obj_free(krwlock_t *); + +#endif /* _KERNEL */ + +#endif /* _SYS_RWLOCK_H_ */ diff --git a/sys/sys/stat.h b/sys/sys/stat.h new file mode 100644 index 000000000..b16f56e29 --- /dev/null +++ b/sys/sys/stat.h @@ -0,0 +1,196 @@ +#ifndef _SYS_STAT_H_ +#define _SYS_STAT_H_ + +#include +#include /* XXX */ + +#if defined(_NETBSD_SOURCE) +#include +#endif + + +struct stat { + big_dev_t st_dev; /* inode's device */ + big_mode_t st_mode; /* inode protection mode */ + big_ino_t st_ino; /* inode's number */ + big_nlink_t st_nlink; /* number of hard links */ + big_uid_t st_uid; /* user ID of the file's owner */ + big_gid_t st_gid; /* group ID of the file's group */ + big_dev_t st_rdev; /* device type */ +#if defined(_NETBSD_SOURCE) + struct timespec st_atimespec;/* time of last access */ + struct timespec st_mtimespec;/* time of last data modification */ + struct timespec st_ctimespec;/* time of last file status change */ + struct timespec st_birthtimespec; /* time of creation */ +#else + time_t st_atime; /* time of last access */ + long st_atimensec; /* nsec of last access */ + time_t st_mtime; /* time of last data modification */ + long st_mtimensec; /* nsec of last data modification */ + time_t st_ctime; /* time of last file status change */ + long st_ctimensec; /* nsec of last file status change */ + time_t st_birthtime; /* time of creation */ + long st_birthtimensec; /* nsec of time of creation */ +#endif + big_off_t st_size; /* file size, in bytes */ + blkcnt_t st_blocks; /* blocks allocated for file */ + blksize_t st_blksize; /* optimal blocksize for I/O */ + u32_t st_flags; /* user defined flags for file */ + u32_t st_gen; /* file generation number */ + u32_t st_spare[2]; +}; + + +struct minix_prev_stat { + short st_dev; /* major/minor device number */ + ino_t st_ino; /* i-node number */ + mode_t st_mode; /* file mode, protection bits, etc. */ + nlink_t st_nlink; /* # links; */ + short st_uid; /* uid of the file's owner */ + short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */ + short st_rdev; + off_t st_size; /* file size */ + time_t st_atime; /* time of last access */ + time_t st_mtime; /* time of last data modification */ + time_t st_ctime; /* time of last file status change */ +}; + + +#if defined(_NETBSD_SOURCE) +/* XXX after updating stat struct we don't want to update all the code */ +#define st_atime st_atimespec.tv_sec +#define st_mtime st_mtimespec.tv_sec +#define st_ctime st_ctimespec.tv_sec +#define st_birthtime st_birthtimespec.tv_sec +#define st_atimensec st_atimespec.tv_nsec +#define st_mtimensec st_mtimespec.tv_nsec +#define st_ctimensec st_ctimespec.tv_nsec +#define st_birthtimensec st_birthtimespec.tv_nsec +#endif + + +#define S_ISUID 0004000 /* set user id on execution */ +#define S_ISGID 0002000 /* set group id on execution */ +#if defined(_NETBSD_SOURCE) +#define S_ISTXT 0001000 /* sticky bit */ +#endif + +#define S_IRWXU 0000700 /* RWX mask for owner */ +#define S_IRUSR 0000400 /* R for owner */ +#define S_IWUSR 0000200 /* W for owner */ +#define S_IXUSR 0000100 /* X for owner */ + +#if defined(_NETBSD_SOURCE) +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_IEXEC S_IXUSR +#endif + +#define S_IRWXG 0000070 /* RWX mask for group */ +#define S_IRGRP 0000040 /* R for group */ +#define S_IWGRP 0000020 /* W for group */ +#define S_IXGRP 0000010 /* X for group */ + +#define S_IRWXO 0000007 /* RWX mask for other */ +#define S_IROTH 0000004 /* R for other */ +#define S_IWOTH 0000002 /* W for other */ +#define S_IXOTH 0000001 /* X for other */ + +#define _S_IFMT 0170000 /* type of file mask */ +#define _S_IFIFO 0010000 /* named pipe (fifo) */ +#define _S_IFCHR 0020000 /* character special */ +#define _S_IFDIR 0040000 /* directory */ +#define _S_IFBLK 0060000 /* block special */ +#define _S_IFREG 0100000 /* regular */ +#define _S_IFLNK 0120000 /* symbolic link */ +#define _S_IFSOCK 0140000 /* socket */ +#define _S_ISVTX 0001000 /* save swapped text even after use */ + +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +#define S_IFMT _S_IFMT +#define S_IFIFO _S_IFIFO +#define S_IFCHR _S_IFCHR +#define S_IFDIR _S_IFDIR +#define S_IFBLK _S_IFBLK +#define S_IFREG _S_IFREG +#define S_IFLNK _S_IFLNK +#define S_ISVTX _S_ISVTX +#endif +#if ((_XOPEN_SOURCE - 0) >= 600) || defined(_NETBSD_SOURCE) +#define S_IFSOCK _S_IFSOCK +#endif + +#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) /* directory */ +#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) /* char special */ +#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) /* block special */ +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) /* regular file */ +#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) /* fifo */ +#if ((_POSIX_C_SOURCE - 0) >= 200112L) || defined(_XOPEN_SOURCE) || \ + defined(_NETBSD_SOURCE) +#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) /* symbolic link */ +#endif +#if ((_POSIX_C_SOURCE - 0) >= 200112L) || ((_XOPEN_SOURCE - 0) >= 600) || \ + defined(_NETBSD_SOURCE) +#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK) /* socket */ +#endif + +#if defined(_NETBSD_SOURCE) +#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ + /* 7777 */ +#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) + /* 0666 */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) + +#define S_BLKSIZE 512 /* block size used in the stat struct */ + +/* + * Definitions of flags stored in file flags word. + * + * Super-user and owner changeable flags. + */ +#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */ +#define UF_NODUMP 0x00000001 /* do not dump file */ +#define UF_IMMUTABLE 0x00000002 /* file may not be changed */ +#define UF_APPEND 0x00000004 /* writes to file may only append */ +#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */ + +/* + * Super-user changeable flags. + */ +#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */ +#define SF_ARCHIVED 0x00010000 /* file is archived */ +#define SF_IMMUTABLE 0x00020000 /* file may not be changed */ +#define SF_APPEND 0x00040000 /* writes to file may only append */ + +#endif /* _NETBSD_SOURCE */ + +#if defined(__minix) +#include +/* Convenient constant to use when st_blocksize field is required. */ +#define MINIX_ST_BLKSIZE PAGE_SIZE +#endif + +#include + +#if !defined(_KERNEL) && !defined(_STANDALONE) + +__BEGIN_DECLS +int chmod(const char *, mode_t); +int mkdir(const char *, mode_t); +int mkfifo(const char *, mode_t); +#ifndef __LIBC12_SOURCE__ +int stat(const char *, struct stat *) __RENAME(__stat50); +int fstat(int, struct stat *) __RENAME(__fstat50); +#endif +mode_t umask(mode_t); +#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) +int fchmod(int, mode_t); +#ifndef __LIBC12_SOURCE__ +int lstat(const char *, struct stat *) __RENAME(__lstat50); +int mknod(const char *, mode_t, dev_t) __RENAME(__mknod50); +#endif +#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */ +__END_DECLS + +#endif /* !_KERNEL && !_STANDALONE */ +#endif /* !_SYS_STAT_H_ */ diff --git a/sys/sys/stdarg.h b/sys/sys/stdarg.h new file mode 100644 index 000000000..38ade6d9f --- /dev/null +++ b/sys/sys/stdarg.h @@ -0,0 +1 @@ +#include