From adaa24668e085dc7eff62f674ff3e2d23e68457f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 30 Oct 2013 10:56:59 +0100 Subject: [PATCH] Inline copyinstr(), copyin() and copyout() --- Makefile | 1 - freebsd-to-rtems.py | 1 - freebsd/sys/sys/systm.h | 33 +++++++++++++++++++ rtemsbsd/rtems/rtems-bsd-copyinout.c | 48 ---------------------------- rtemsbsd/rtems/rtems-bsd-support.c | 37 --------------------- 5 files changed, 33 insertions(+), 87 deletions(-) delete mode 100644 rtemsbsd/rtems/rtems-bsd-copyinout.c diff --git a/Makefile b/Makefile index 50d83b5b..d03a4a62 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,6 @@ LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-cam.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-chunk.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-condvar.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-conf.c -LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-copyinout.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-delay.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-file.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-init.c diff --git a/freebsd-to-rtems.py b/freebsd-to-rtems.py index be79f66f..9dd91179 100755 --- a/freebsd-to-rtems.py +++ b/freebsd-to-rtems.py @@ -612,7 +612,6 @@ rtems.addRTEMSSourceFiles( 'rtems/rtems-bsd-chunk.c', 'rtems/rtems-bsd-condvar.c', 'rtems/rtems-bsd-conf.c', - 'rtems/rtems-bsd-copyinout.c', 'rtems/rtems-bsd-delay.c', 'rtems/rtems-bsd-get-file.c', 'rtems/rtems-bsd-init.c', diff --git a/freebsd/sys/sys/systm.h b/freebsd/sys/sys/systm.h index f809174e..4d922392 100644 --- a/freebsd/sys/sys/systm.h +++ b/freebsd/sys/sys/systm.h @@ -227,6 +227,7 @@ void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2); int copystr(const void * __restrict kfaddr, void * __restrict kdaddr, size_t len, size_t * __restrict lencopied) __nonnull(1) __nonnull(2); +#ifndef __rtems__ int copyinstr(const void * __restrict udaddr, void * __restrict kaddr, size_t len, size_t * __restrict lencopied) __nonnull(1) __nonnull(2); @@ -234,6 +235,38 @@ int copyin(const void * __restrict udaddr, void * __restrict kaddr, size_t len) __nonnull(1) __nonnull(2); int copyout(const void * __restrict kaddr, void * __restrict udaddr, size_t len) __nonnull(1) __nonnull(2); +#else /* __rtems__ */ +static inline int __nonnull(1) __nonnull(2) +copyinstr(const void * __restrict udaddr, void * __restrict kaddr, + size_t len, size_t * __restrict lencopied) +{ + if (lencopied != NULL) { + *lencopied = len; + } + + memcpy(kaddr, udaddr, len); + + return (0); +} + +static inline int __nonnull(1) __nonnull(2) +copyin(const void * __restrict udaddr, void * __restrict kaddr, + size_t len) +{ + memcpy(kaddr, udaddr, len); + + return (0); +} + +static inline int __nonnull(1) __nonnull(2) +copyout(const void * __restrict kaddr, void * __restrict udaddr, + size_t len) +{ + memcpy(udaddr, kaddr, len); + + return (0); +} +#endif /* __rtems__ */ int fubyte(const void *base); long fuword(const void *base); diff --git a/rtemsbsd/rtems/rtems-bsd-copyinout.c b/rtemsbsd/rtems/rtems-bsd-copyinout.c deleted file mode 100644 index 3d3707a5..00000000 --- a/rtemsbsd/rtems/rtems-bsd-copyinout.c +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file - * - * @ingroup rtems_bsd_rtems - * - * @brief This file contains the RTEMS implementation of the bsd functions - * from the copyinout.c file. - */ - -/* - * Copyright (c) 2012 On-Line Applications Research Corporation (OAR). - * 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 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 - -#include -#include -#include - -int -copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done) -{ - memcpy(kaddr, udaddr, len); - *done = len; - return 0; -} diff --git a/rtemsbsd/rtems/rtems-bsd-support.c b/rtemsbsd/rtems/rtems-bsd-support.c index 119e974d..739684bd 100644 --- a/rtemsbsd/rtems/rtems-bsd-support.c +++ b/rtemsbsd/rtems/rtems-bsd-support.c @@ -56,43 +56,6 @@ int maxfilesperproc = 27; /* XXX per-proc open files limit */ uintptr_t dpcpu_off[MAXCPU]; int hogticks = 2; /* hogticks = 2 * sched_quantum */ -int -copyout(const void *kaddr, void *udaddr, size_t len) -{ - bcopy(kaddr, udaddr, len); - return (0); -} - -int -copyin(const void *udaddr, void *kaddr, size_t len) -{ - bcopy(udaddr, kaddr, len); - return (0); -} - -#if 0 -/* - * As of 27 March 2012, use version in kern_subr.c - */ -int -copyiniov(struct iovec *iovp, u_int iovcnt, struct iovec **iov, int error) -{ - u_int iovlen; - - *iov = NULL; - if (iovcnt > UIO_MAXIOV) - return (error); - iovlen = iovcnt * sizeof (struct iovec); - *iov = malloc(iovlen, M_IOV, M_WAITOK); - error = copyin(iovp, *iov, iovlen); - if (error) { - free(*iov, M_IOV); - *iov = NULL; - } - return (error); -} -#endif - void critical_enter(void) {