mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-13 18:49:19 +08:00
Inline copyinstr(), copyin() and copyout()
This commit is contained in:
parent
724d62b427
commit
adaa24668e
1
Makefile
1
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-chunk.c
|
||||||
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-condvar.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-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-delay.c
|
||||||
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-file.c
|
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-file.c
|
||||||
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-init.c
|
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-init.c
|
||||||
|
@ -612,7 +612,6 @@ rtems.addRTEMSSourceFiles(
|
|||||||
'rtems/rtems-bsd-chunk.c',
|
'rtems/rtems-bsd-chunk.c',
|
||||||
'rtems/rtems-bsd-condvar.c',
|
'rtems/rtems-bsd-condvar.c',
|
||||||
'rtems/rtems-bsd-conf.c',
|
'rtems/rtems-bsd-conf.c',
|
||||||
'rtems/rtems-bsd-copyinout.c',
|
|
||||||
'rtems/rtems-bsd-delay.c',
|
'rtems/rtems-bsd-delay.c',
|
||||||
'rtems/rtems-bsd-get-file.c',
|
'rtems/rtems-bsd-get-file.c',
|
||||||
'rtems/rtems-bsd-init.c',
|
'rtems/rtems-bsd-init.c',
|
||||||
|
@ -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,
|
int copystr(const void * __restrict kfaddr, void * __restrict kdaddr,
|
||||||
size_t len, size_t * __restrict lencopied)
|
size_t len, size_t * __restrict lencopied)
|
||||||
__nonnull(1) __nonnull(2);
|
__nonnull(1) __nonnull(2);
|
||||||
|
#ifndef __rtems__
|
||||||
int copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
|
int copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
|
||||||
size_t len, size_t * __restrict lencopied)
|
size_t len, size_t * __restrict lencopied)
|
||||||
__nonnull(1) __nonnull(2);
|
__nonnull(1) __nonnull(2);
|
||||||
@ -234,6 +235,38 @@ int copyin(const void * __restrict udaddr, void * __restrict kaddr,
|
|||||||
size_t len) __nonnull(1) __nonnull(2);
|
size_t len) __nonnull(1) __nonnull(2);
|
||||||
int copyout(const void * __restrict kaddr, void * __restrict udaddr,
|
int copyout(const void * __restrict kaddr, void * __restrict udaddr,
|
||||||
size_t len) __nonnull(1) __nonnull(2);
|
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);
|
int fubyte(const void *base);
|
||||||
long fuword(const void *base);
|
long fuword(const void *base);
|
||||||
|
@ -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 <machine/rtems-bsd-config.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rtems.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done)
|
|
||||||
{
|
|
||||||
memcpy(kaddr, udaddr, len);
|
|
||||||
*done = len;
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -56,43 +56,6 @@ int maxfilesperproc = 27; /* XXX per-proc open files limit */
|
|||||||
uintptr_t dpcpu_off[MAXCPU];
|
uintptr_t dpcpu_off[MAXCPU];
|
||||||
int hogticks = 2; /* hogticks = 2 * sched_quantum */
|
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
|
void
|
||||||
critical_enter(void)
|
critical_enter(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user