Page MenuHomeFreeBSD

D4445.id10932.diff
No OneTemporary

D4445.id10932.diff

Index: Makefile.inc1
===================================================================
--- Makefile.inc1
+++ Makefile.inc1
@@ -172,7 +172,7 @@
.export VERSION
.endif
-KNOWN_ARCHES?= aarch64/arm64 amd64 arm armeb/arm armv6/arm armv6hf/arm i386 i386/pc98 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64
+KNOWN_ARCHES?= aarch64/arm64 amd64 arm armeb/arm armv6/arm armv6hf/arm i386 i386/pc98 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc riscv sparc64
.if ${TARGET} == ${TARGET_ARCH}
_t= ${TARGET}
.else
Index: etc/etc.riscv/ttys
===================================================================
--- /dev/null
+++ etc/etc.riscv/ttys
@@ -0,0 +1,51 @@
+#
+# $FreeBSD$
+# @(#)ttys 5.1 (Berkeley) 4/17/89
+#
+# This file specifies various information about terminals on the system.
+# It is used by several different programs. Common entries for the
+# various columns include:
+#
+# name The name of the terminal device.
+#
+# getty The program to start running on the terminal. Typically a
+# getty program, as the name implies. Other common entries
+# include none, when no getty is needed, and xdm, to start the
+# X Window System.
+#
+# type The initial terminal type for this port. For hardwired
+# terminal lines, this will contain the type of terminal used.
+# For virtual consoles, the correct type is typically xterm.
+# Other common values include dialup for incoming modem ports, and
+# unknown when the terminal type cannot be predetermined.
+#
+# status Must be on or off. If on, init will run the getty program on
+# the specified port. If the word "secure" appears, this tty
+# allows root login.
+#
+# name getty type status comments
+#
+# If console is marked "insecure", then init will ask for the root password
+# when going to single-user mode.
+console none unknown off secure
+#
+ttyv0 "/usr/libexec/getty Pc" xterm off secure
+# Virtual terminals
+ttyv1 "/usr/libexec/getty Pc" xterm off secure
+ttyv2 "/usr/libexec/getty Pc" xterm off secure
+ttyv3 "/usr/libexec/getty Pc" xterm off secure
+ttyv4 "/usr/libexec/getty Pc" xterm off secure
+ttyv5 "/usr/libexec/getty Pc" xterm off secure
+ttyv6 "/usr/libexec/getty Pc" xterm off secure
+ttyv7 "/usr/libexec/getty Pc" xterm off secure
+#ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
+# Serial terminals
+# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
+ttyu0 "/usr/libexec/getty std.9600" vt100 off secure
+ttyu1 "/usr/libexec/getty std.9600" dialup off secure
+ttyu2 "/usr/libexec/getty std.9600" dialup off secure
+ttyu3 "/usr/libexec/getty std.9600" dialup off secure
+# Dumb console
+dcons "/usr/libexec/getty std.9600" vt100 off secure
+# RISC-V HTIF console
+rcons "/usr/libexec/getty std.9600" vt100 on secure
Index: lib/csu/riscv/Makefile
===================================================================
--- /dev/null
+++ lib/csu/riscv/Makefile
@@ -0,0 +1,44 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../common
+
+SRCS= crt1.c crti.S crtn.S
+OBJS= ${SRCS:N*.h:R:S/$/.o/g}
+OBJS+= Scrt1.o gcrt1.o
+CFLAGS+= -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
+
+all: ${OBJS}
+
+CLEANFILES= ${OBJS}
+CLEANFILES+= crt1.s gcrt1.s Scrt1.s
+
+# See the comment in lib/csu/common/crtbrand.c for the reason crt1.c is not
+# directly compiled to .o files.
+
+crt1.s: crt1.c
+ ${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c
+ sed ${SED_FIX_NOTE} ${.TARGET}
+
+crt1.o: crt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
+
+gcrt1.s: crt1.c
+ ${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
+ sed ${SED_FIX_NOTE} ${.TARGET}
+
+gcrt1.o: gcrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
+
+Scrt1.s: crt1.c
+ ${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
+ sed ${SED_FIX_NOTE} ${.TARGET}
+
+Scrt1.o: Scrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
+
+realinstall:
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${OBJS} ${DESTDIR}${LIBDIR}
+
+.include <bsd.lib.mk>
Index: lib/csu/riscv/crt1.c
===================================================================
--- /dev/null
+++ lib/csu/riscv/crt1.c
@@ -0,0 +1,105 @@
+/* LINTLIBRARY */
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory as part of the CTSRD Project, with support from the UK Higher
+ * Education Innovation Fund (HEIF).
+ *
+ * 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 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 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifndef lint
+#ifndef __GNUC__
+#error "GCC is needed to compile this file"
+#endif
+#endif /* lint */
+
+#include <stdlib.h>
+
+#include "libc_private.h"
+#include "crtbrand.c"
+#include "ignore_init.c"
+
+#ifdef GCRT
+extern void _mcleanup(void);
+extern void monstartup(void *, void *);
+extern int eprol;
+extern int etext;
+#endif
+
+extern long * _end;
+
+void __start(int, char **, char **, void (*)(void));
+
+/* The entry function. */
+__asm(" .text \n"
+" .align 0 \n"
+" .globl _start \n"
+" _start: \n"
+" mv a3, a2 \n" /* cleanup */
+" addi a1, a0, 8 \n" /* load argv */
+" ld a0, 0(a0) \n" /* load argc */
+" slli t0, a0, 3 \n" /* mult by 8 */
+" add a2, a1, t0 \n" /* env is after argv */
+" addi a2, a2, 8 \n" /* argv is null terminated */
+" lla gp, _gp \n" /* load global pointer */
+" call __start ");
+
+/* The entry function. */
+void
+__start(int argc, char *argv[], char *env[], void (*cleanup)(void))
+{
+
+ handle_argv(argc, argv, env);
+
+ if (&_DYNAMIC != NULL)
+ atexit(cleanup);
+ else {
+ /*
+ * Hack to resolve _end so we read the correct symbol.
+ * Without this it will resolve to the copy in the library
+ * that firsts requests it. We should fix the toolchain,
+ * however this is is needed until this can take place.
+ */
+ *(volatile long *)&_end;
+
+ _init_tls();
+ }
+
+#ifdef GCRT
+ atexit(_mcleanup);
+ monstartup(&eprol, &etext);
+__asm__("eprol:");
+#endif
+
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
+}
Index: lib/csu/riscv/crti.S
===================================================================
--- /dev/null
+++ lib/csu/riscv/crti.S
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory as part of the CTSRD Project, with support from the UK Higher
+ * Education Innovation Fund (HEIF).
+ *
+ * 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 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 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.
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+# this puts _gp into .dynsym, so symlook_obj can now find that (see reloc.c)
+ .weak _gp
+_gp:
+
+ .section .init,"ax",@progbits
+ .align 4
+ .globl _init
+ .type _init,@function
+_init:
+ addi sp, sp, -16
+ sd ra, 0(sp)
+
+ .section .fini,"ax",@progbits
+ .align 4
+ .globl _fini
+ .type _fini,@function
+_fini:
+ addi sp, sp, -16
+ sd ra, 0(sp)
Index: lib/csu/riscv/crtn.S
===================================================================
--- /dev/null
+++ lib/csu/riscv/crtn.S
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory as part of the CTSRD Project, with support from the UK Higher
+ * Education Innovation Fund (HEIF).
+ *
+ * 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 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 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.
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+ .section .init,"ax",@progbits
+ ld ra, 0(sp)
+ addi sp, sp, 16
+ ret
+
+ .section .fini,"ax",@progbits
+ ld ra, 0(sp)
+ addi sp, sp, 16
+ ret
+
+ .section .note.GNU-stack,"",%progbits
Index: lib/libc/riscv/Makefile.inc
===================================================================
--- /dev/null
+++ lib/libc/riscv/Makefile.inc
@@ -0,0 +1,9 @@
+# $FreeBSD$
+#
+# Machine dependent definitions for the arm 64-bit architecture.
+#
+
+# Long double is quad precision
+GDTOASRCS+=strtorQ.c
+MDSRCS+=machdep_ldisQ.c
+SYM_MAPS+=${LIBC_SRCTOP}/riscv/Symbol.map
Index: lib/libthr/arch/riscv/Makefile.inc
===================================================================
--- /dev/null
+++ lib/libthr/arch/riscv/Makefile.inc
@@ -0,0 +1 @@
+# $FreeBSD$
Index: lib/msun/riscv/Makefile.inc
===================================================================
--- /dev/null
+++ lib/msun/riscv/Makefile.inc
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+LDBL_PREC = 53
Index: lib/msun/riscv/fenv.h
===================================================================
--- /dev/null
+++ lib/msun/riscv/fenv.h
@@ -0,0 +1,254 @@
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory as part of the CTSRD Project, with support from the UK Higher
+ * Education Innovation Fund (HEIF).
+ *
+ * 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 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 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.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * RISC-V FPU, Chapter 6, The RISC-V Instruction Set Manual,
+ * Volume I: User-Level ISA, Version 2.0
+ */
+
+#ifndef _FENV_H_
+#define _FENV_H_
+
+#include <sys/_types.h>
+
+#ifndef __fenv_static
+#define __fenv_static static
+#endif
+
+typedef __uint64_t fenv_t;
+typedef __uint64_t fexcept_t;
+
+/* Exception flags */
+#define FE_INVALID 0x00000001
+#define FE_DIVBYZERO 0x00000002
+#define FE_OVERFLOW 0x00000004
+#define FE_UNDERFLOW 0x00000008
+#define FE_INEXACT 0x00000010
+#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
+ FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+
+/*
+ * RISC-V Rounding modes
+ */
+#define FE_TONEAREST 0x0
+#define FE_UPWARD 0x1
+#define FE_DOWNWARD 0x2
+#define FE_TOWARDZERO 0x3
+
+#define FRM_SHIFT 5
+#define FRM_MASK (0x7 << FRM_SHIFT)
+#define FRM_RNE 0 /* Round to Nearest, ties to Even */
+#define FRM_RTZ 1 /* Round towards Zero */
+#define FRM_RDN 2 /* Round Down (towards - infinum) */
+#define FRM_RUP 3 /* Round Up (towards + infinum) */
+#define FRM_RMM 4 /* Round to Nearest, ties to Max Magnitude */
+#define _ROUND_SHIFT 5
+#define _ROUND_MASK (0x7 << _ROUND_SHIFT)
+
+__BEGIN_DECLS
+
+/* Default floating-point environment */
+extern const fenv_t __fe_dfl_env;
+#define FE_DFL_ENV (&__fe_dfl_env)
+
+/* We need to be able to map status flag positions to mask flag positions */
+#define _FPUSW_SHIFT 0
+#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
+
+#define __wr_fcsr(__r) __asm __volatile("csrw fcsr, %0" :: "r" (__r))
+#define __rd_fcsr(__r) __asm __volatile("csrr %0, fcsr" : "=r" (*(__r)))
+#define __set_fcsr(__r) __asm __volatile("csrs fcsr, %0" :: "r" (__r))
+#define __clr_fcsr(__r) __asm __volatile("csrc fcsr, %0" :: "r" (__r))
+
+__fenv_static __inline int
+feclearexcept(int __excepts)
+{
+
+ __clr_fcsr(__excepts);
+
+ return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+ fexcept_t __r;
+
+ __rd_fcsr(&__r);
+ *__flagp = (__r & __excepts);
+ return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+ fexcept_t __r;
+
+ __r = (*__flagp & __excepts);
+ __set_fcsr(__r);
+
+ return (0);
+}
+
+__fenv_static inline int
+feraiseexcept(int __excepts)
+{
+ fexcept_t __r;
+
+ __r = __excepts;
+ __set_fcsr(__r);
+
+ return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+ fexcept_t __r;
+
+ __rd_fcsr(&__r);
+ return (__r & __excepts);
+}
+
+__fenv_static inline int
+fegetround(void)
+{
+ fenv_t __r;
+
+ __rd_fcsr(&__r);
+ return ((__r >> _ROUND_SHIFT) & _ROUND_MASK);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+ fenv_t __r;
+
+ if (__round & ~_ROUND_MASK)
+ return (-1);
+
+ __rd_fcsr(&__r);
+ __r &= ~(_ROUND_MASK << _ROUND_SHIFT);
+ __r |= __round << _ROUND_SHIFT;
+ __wr_fcsr(__r);
+
+ return (0);
+}
+
+__fenv_static inline int
+fegetenv(fenv_t *__envp)
+{
+ fenv_t __r;
+
+ __rd_fcsr(&__r);
+ *__envp = __r & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT));
+
+ return (0);
+}
+
+__fenv_static inline int
+feholdexcept(fenv_t *__envp)
+{
+ fenv_t __r;
+
+ __rd_fcsr(&__r);
+ *__envp |= __r & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT));
+
+ __r &= ~(_ENABLE_MASK);
+ __wr_fcsr(__r);
+
+ return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
+ __wr_fcsr((*__envp) & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT)));
+ return (0);
+}
+
+__fenv_static inline int
+feupdateenv(const fenv_t *__envp)
+{
+ fexcept_t __r;
+
+ __rd_fcsr(&__r);
+ fesetenv(__envp);
+ feraiseexcept(__r & FE_ALL_EXCEPT);
+ return (0);
+}
+
+#if __BSD_VISIBLE
+
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
+feenableexcept(int __mask)
+{
+ fenv_t __old_r, __new_r;
+
+ __rd_fcsr(&__old_r);
+ __new_r = __old_r | ((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+ __wr_fcsr(__new_r);
+ return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fedisableexcept(int __mask)
+{
+ fenv_t __old_r, __new_r;
+
+ __rd_fcsr(&__old_r);
+ __new_r = __old_r & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+ __wr_fcsr(__new_r);
+ return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fegetexcept(void)
+{
+ fenv_t __r;
+
+ __rd_fcsr(&__r);
+ return ((__r & _ENABLE_MASK) >> _FPUSW_SHIFT);
+}
+
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif /* !_FENV_H_ */
Index: share/mk/bsd.cpu.mk
===================================================================
--- share/mk/bsd.cpu.mk
+++ share/mk/bsd.cpu.mk
@@ -18,6 +18,8 @@
MACHINE_CPU = mips
. elif ${MACHINE_CPUARCH} == "powerpc"
MACHINE_CPU = aim
+. elif ${MACHINE_CPUARCH} == "riscv"
+MACHINE_CPU = riscv
. elif ${MACHINE_CPUARCH} == "sparc64"
MACHINE_CPU = ultrasparc
. endif
@@ -308,6 +310,11 @@
.endif
.endif
+.if ${MACHINE_CPUARCH} == "riscv"
+MACHINE_CPU += softfp
+CFLAGS += -msoft-float
+.endif
+
# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
.if !defined(NO_CPU_CFLAGS)
Index: share/mk/bsd.endian.mk
===================================================================
--- share/mk/bsd.endian.mk
+++ share/mk/bsd.endian.mk
@@ -4,6 +4,7 @@
${MACHINE_ARCH} == "amd64" || \
${MACHINE_ARCH} == "i386" || \
(${MACHINE} == "arm" && ${MACHINE_ARCH:Marm*eb*} == "") || \
+ ${MACHINE_ARCH} == "riscv" || \
${MACHINE_ARCH:Mmips*el} != ""
TARGET_ENDIANNESS= 1234
.elif ${MACHINE_ARCH} == "powerpc" || \
Index: share/mk/bsd.sys.mk
===================================================================
--- share/mk/bsd.sys.mk
+++ share/mk/bsd.sys.mk
@@ -109,6 +109,11 @@
CWARNFLAGS+= -Wno-format
.endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE}
+# RISC-V / GCC 5.2.0
+.if ${MACHINE_CPUARCH} == "riscv" && ${COMPILER_TYPE} == "gcc"
+CWARNFLAGS+= -Wno-error=unused-function -Wno-error=enum-compare -Wno-error=logical-not-parentheses -Wno-error=bool-compare -Wno-error=uninitialized -Wno-error=array-bounds -Wno-error=clobbered -Wno-error=cast-align -Wno-error=extra -Wno-error=attributes -Wno-error=inline -Wno-error=unused-but-set-variable -Wno-error=unused-value -Wno-error=strict-aliasing -Wno-error=address
+.endif
+
# How to handle FreeBSD custom printf format specifiers.
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__
Index: share/mk/src.opts.mk
===================================================================
--- share/mk/src.opts.mk
+++ share/mk/src.opts.mk
@@ -228,12 +228,15 @@
__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
.endif
-.if ${__T} == "aarch64"
+.if ${__T} == "aarch64" || ${__T} == "riscv"
BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
__DEFAULT_YES_OPTIONS+=ELFCOPY_AS_OBJCOPY
.else
__DEFAULT_NO_OPTIONS+=ELFCOPY_AS_OBJCOPY
.endif
+.if ${__T} == "riscv"
+BROKEN_OPTIONS+=PROFILE TESTS CXX RESCUE
+.endif
# LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
.if ${__T} == "arm" || ${__T} == "armeb"
BROKEN_OPTIONS+=LLDB

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 18, 9:52 PM (4 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23895678
Default Alt Text
D4445.id10932.diff (21 KB)

Event Timeline