summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mauderer <Christian.Mauderer@embedded-brains.de>2016-06-28 17:27:08 +0200
committerChristian Mauderer <Christian.Mauderer@embedded-brains.de>2016-08-01 14:02:04 +0200
commit9a01ebf7d746344c22d081c9c8bf2ceb6dc704c3 (patch)
treea9aefd91b7290995129e7bec9752d0537b186e23
parent6c0cfc217332129e6b0b4ca9cb9877f9fb0c7895 (diff)
downloadrtems-libbsd-9a01ebf7d746344c22d081c9c8bf2ceb6dc704c3.tar.bz2
kern_conf.c: Adapt for RTEMS.
-rw-r--r--freebsd/sys/kern/kern_conf.c56
-rw-r--r--freebsd/sys/kern/sys_generic.c2
-rw-r--r--freebsd/sys/sys/conf.h13
-rwxr-xr-xlibbsd.py2
-rw-r--r--libbsd_waf.py2
-rw-r--r--rtemsbsd/rtems/rtems-kernel-conf.c65
6 files changed, 72 insertions, 68 deletions
diff --git a/freebsd/sys/kern/kern_conf.c b/freebsd/sys/kern/kern_conf.c
index a5bd68c0..589e5941 100644
--- a/freebsd/sys/kern/kern_conf.c
+++ b/freebsd/sys/kern/kern_conf.c
@@ -51,12 +51,18 @@ __FBSDID("$FreeBSD$");
#include <fs/devfs/devfs_int.h>
#include <vm/vm.h>
+#ifdef __rtems__
+#define PRIBIO (0)
+#endif /* __rtems__ */
+
static MALLOC_DEFINE(M_DEVT, "cdev", "cdev storage");
struct mtx devmtx;
static void destroy_devl(struct cdev *dev);
+#ifndef __rtems__
static int destroy_dev_sched_cbl(struct cdev *dev,
void (*cb)(void *), void *arg);
+#endif /* __rtems__ */
static int make_dev_credv(int flags, struct cdev **dres, struct cdevsw *devsw,
int unit, struct ucred *cr, uid_t uid, gid_t gid, int mode, const char *fmt,
va_list ap);
@@ -137,6 +143,7 @@ dev_unlock(void)
mtx_unlock(&devmtx);
}
+#ifndef __rtems__
void
dev_ref(struct cdev *dev)
{
@@ -146,6 +153,7 @@ dev_ref(struct cdev *dev)
dev->si_refcount++;
mtx_unlock(&devmtx);
}
+#endif /* __rtems__ */
void
dev_refl(struct cdev *dev)
@@ -155,6 +163,7 @@ dev_refl(struct cdev *dev)
dev->si_refcount++;
}
+#ifndef __rtems__
void
dev_rel(struct cdev *dev)
{
@@ -179,6 +188,7 @@ dev_rel(struct cdev *dev)
if (flag)
devfs_free(dev);
}
+#endif /* __rtems__ */
struct cdevsw *
dev_refthread(struct cdev *dev, int *ref)
@@ -205,6 +215,7 @@ dev_refthread(struct cdev *dev, int *ref)
return (csw);
}
+#ifndef __rtems__
struct cdevsw *
devvn_refthread(struct vnode *vp, struct cdev **devp, int *ref)
{
@@ -246,6 +257,7 @@ devvn_refthread(struct vnode *vp, struct cdev **devp, int *ref)
}
return (csw);
}
+#endif /* __rtems__ */
void
dev_relthread(struct cdev *dev, int ref)
@@ -297,12 +309,14 @@ enodev(void)
#define dead_poll (d_poll_t *)enodev
#define dead_mmap (d_mmap_t *)enodev
+#ifndef __rtems__
static void
dead_strategy(struct bio *bp)
{
biofinish(bp, NULL, ENXIO);
}
+#endif /* __rtems__ */
#define dead_dump (dumper_t *)enxio
#define dead_kqfilter (d_kqfilter_t *)enxio
@@ -316,12 +330,18 @@ static struct cdevsw dead_cdevsw = {
.d_write = dead_write,
.d_ioctl = dead_ioctl,
.d_poll = dead_poll,
+#ifndef __rtems__
.d_mmap = dead_mmap,
.d_strategy = dead_strategy,
+#endif /* __rtems__ */
.d_name = "dead",
+#ifndef __rtems__
.d_dump = dead_dump,
+#endif /* __rtems__ */
.d_kqfilter = dead_kqfilter,
+#ifndef __rtems__
.d_mmap_single = dead_mmap_single
+#endif /* __rtems__ */
};
/* Default methods if driver does not specify method */
@@ -335,12 +355,14 @@ static struct cdevsw dead_cdevsw = {
#define no_kqfilter (d_kqfilter_t *)enodev
#define no_mmap_single (d_mmap_single_t *)enodev
+#ifndef __rtems__
static void
no_strategy(struct bio *bp)
{
biofinish(bp, NULL, ENODEV);
}
+#endif /* __rtems__ */
static int
no_poll(struct cdev *dev __unused, int events, struct thread *td __unused)
@@ -367,6 +389,7 @@ giant_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
return (retval);
}
+#ifndef __rtems__
static int
giant_fdopen(struct cdev *dev, int oflags, struct thread *td, struct file *fp)
{
@@ -382,6 +405,7 @@ giant_fdopen(struct cdev *dev, int oflags, struct thread *td, struct file *fp)
dev_relthread(dev, ref);
return (retval);
}
+#endif /* __rtems__ */
static int
giant_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
@@ -399,6 +423,7 @@ giant_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
return (retval);
}
+#ifndef __rtems__
static void
giant_strategy(struct bio *bp)
{
@@ -417,6 +442,7 @@ giant_strategy(struct bio *bp)
mtx_unlock(&Giant);
dev_relthread(dev, ref);
}
+#endif /* __rtems__ */
static int
giant_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
@@ -498,6 +524,7 @@ giant_kqfilter(struct cdev *dev, struct knote *kn)
return (retval);
}
+#ifndef __rtems__
static int
giant_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
vm_memattr_t *memattr)
@@ -533,6 +560,7 @@ giant_mmap_single(struct cdev *dev, vm_ooffset_t *offset, vm_size_t size,
dev_relthread(dev, ref);
return (retval);
}
+#endif /* __rtems__ */
static void
notify(struct cdev *dev, const char *ev, int flags)
@@ -637,10 +665,12 @@ prep_cdevsw(struct cdevsw *devsw, int flags)
devsw->d_write = dead_write;
devsw->d_ioctl = dead_ioctl;
devsw->d_poll = dead_poll;
+#ifndef __rtems__
devsw->d_mmap = dead_mmap;
devsw->d_mmap_single = dead_mmap_single;
devsw->d_strategy = dead_strategy;
devsw->d_dump = dead_dump;
+#endif /* __rtems__ */
devsw->d_kqfilter = dead_kqfilter;
}
@@ -662,18 +692,24 @@ prep_cdevsw(struct cdevsw *devsw, int flags)
while (0)
FIXUP(d_open, null_open, giant_open);
+#ifndef __rtems__
FIXUP(d_fdopen, NULL, giant_fdopen);
+#endif /* __rtems__ */
FIXUP(d_close, null_close, giant_close);
FIXUP(d_read, no_read, giant_read);
FIXUP(d_write, no_write, giant_write);
FIXUP(d_ioctl, no_ioctl, giant_ioctl);
FIXUP(d_poll, no_poll, giant_poll);
+#ifndef __rtems__
FIXUP(d_mmap, no_mmap, giant_mmap);
FIXUP(d_strategy, no_strategy, giant_strategy);
+#endif /* __rtems__ */
FIXUP(d_kqfilter, no_kqfilter, giant_kqfilter);
+#ifndef __rtems__
FIXUP(d_mmap_single, no_mmap_single, giant_mmap_single);
if (devsw->d_dump == NULL) devsw->d_dump = no_dump;
+#endif /* __rtems__ */
LIST_INIT(&devsw->d_devs);
@@ -791,14 +827,18 @@ make_dev_credv(int flags, struct cdev **dres, struct cdevsw *devsw, int unit,
("make_dev() by driver %s on pre-existing device (min=%x, name=%s)",
devsw->d_name, dev2unit(dev), devtoname(dev)));
dev->si_flags |= SI_NAMED;
+#ifndef __rtems__
if (cr != NULL)
dev->si_cred = crhold(cr);
dev->si_uid = uid;
dev->si_gid = gid;
dev->si_mode = mode;
+#endif /* __rtems__ */
devfs_create(dev);
+#ifndef __rtems__
clean_unrhdrl(devfs_inos);
+#endif /* __rtems__ */
dev_unlock_and_free();
notify_create(dev, flags);
@@ -824,6 +864,7 @@ make_dev(struct cdevsw *devsw, int unit, uid_t uid, gid_t gid, int mode,
return (dev);
}
+#ifndef __rtems__
struct cdev *
make_dev_cred(struct cdevsw *devsw, int unit, struct ucred *cr, uid_t uid,
gid_t gid, int mode, const char *fmt, ...)
@@ -929,7 +970,9 @@ make_dev_alias_v(int flags, struct cdev **cdev, struct cdev *pdev,
dev->si_flags |= SI_NAMED;
devfs_create(dev);
dev_dependsl(pdev, dev);
+#ifndef __rtems__
clean_unrhdrl(devfs_inos);
+#endif /* __rtems__ */
dev_unlock();
notify_create(dev, flags);
@@ -1028,6 +1071,7 @@ out:
free(devfspath, M_DEVBUF);
return (ret);
}
+#endif /* __rtems__ */
static void
destroy_devl(struct cdev *dev)
@@ -1059,6 +1103,7 @@ destroy_devl(struct cdev *dev)
/* Remove name marking */
dev->si_flags &= ~SI_NAMED;
+#ifndef __rtems__
/* If we are a child, remove us from the parents list */
if (dev->si_flags & SI_CHILD) {
LIST_REMOVE(dev, si_siblings);
@@ -1074,9 +1119,11 @@ destroy_devl(struct cdev *dev)
LIST_REMOVE(dev, si_clone);
dev->si_flags &= ~SI_CLONELIST;
}
+#endif /* __rtems__ */
csw = dev->si_devsw;
dev->si_devsw = NULL; /* already NULL for SI_ALIAS */
+#ifndef __rtems__
while (csw != NULL && csw->d_purge != NULL && dev->si_threadcount) {
csw->d_purge(dev);
msleep(csw, &devmtx, PRIBIO, "devprg", hz/10);
@@ -1084,6 +1131,7 @@ destroy_devl(struct cdev *dev)
printf("Still %lu threads in %s\n",
dev->si_threadcount, devtoname(dev));
}
+#endif /* __rtems__ */
while (dev->si_threadcount != 0) {
/* Use unique dummy wait ident */
msleep(&csw, &devmtx, PRIBIO, "devdrn", hz / 10);
@@ -1094,17 +1142,21 @@ destroy_devl(struct cdev *dev)
/* avoid out of order notify events */
notify_destroy(dev);
}
+#ifndef __rtems__
mtx_lock(&cdevpriv_mtx);
while ((p = LIST_FIRST(&cdp->cdp_fdpriv)) != NULL) {
devfs_destroy_cdevpriv(p);
mtx_lock(&cdevpriv_mtx);
}
mtx_unlock(&cdevpriv_mtx);
+#endif /* __rtems__ */
dev_lock();
dev->si_drv1 = 0;
dev->si_drv2 = 0;
+#ifndef __rtems__
bzero(&dev->__si_u, sizeof(dev->__si_u));
+#endif /* __rtems__ */
if (!(dev->si_flags & SI_ALIAS)) {
/* Remove from cdevsw list */
@@ -1126,6 +1178,7 @@ destroy_devl(struct cdev *dev)
dev_free_devlocked(dev);
}
+#ifndef __rtems__
static void
delist_dev_locked(struct cdev *dev)
{
@@ -1164,6 +1217,7 @@ delist_dev(struct cdev *dev)
delist_dev_locked(dev);
dev_unlock();
}
+#endif /* __rtems__ */
void
destroy_dev(struct cdev *dev)
@@ -1175,6 +1229,7 @@ destroy_dev(struct cdev *dev)
dev_unlock_and_free();
}
+#ifndef __rtems__
const char *
devtoname(struct cdev *dev)
{
@@ -1518,3 +1573,4 @@ DB_SHOW_COMMAND(cdev, db_show_cdev)
db_printf("cdp_flags %s\n", buf);
}
#endif
+#endif /* __rtems__ */
diff --git a/freebsd/sys/kern/sys_generic.c b/freebsd/sys/kern/sys_generic.c
index 85b99f94..91733ca3 100644
--- a/freebsd/sys/kern/sys_generic.c
+++ b/freebsd/sys/kern/sys_generic.c
@@ -781,6 +781,7 @@ out:
fdrop(fp, td);
return (error);
}
+#endif /* __rtems__ */
int
poll_no_poll(int events)
@@ -798,6 +799,7 @@ poll_no_poll(int events)
return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
}
+#ifndef __rtems__
int
sys_pselect(struct thread *td, struct pselect_args *uap)
{
diff --git a/freebsd/sys/sys/conf.h b/freebsd/sys/sys/conf.h
index 2abfa4f5..9d8b7dcf 100644
--- a/freebsd/sys/sys/conf.h
+++ b/freebsd/sys/sys/conf.h
@@ -82,9 +82,9 @@ struct cdev {
struct ucred *si_cred; /* cached clone-time credential */
#endif /* __rtems__ */
int si_drv0;
-#ifndef __rtems__
int si_refcount;
LIST_ENTRY(cdev) si_list;
+#ifndef __rtems__
LIST_ENTRY(cdev) si_clone;
LIST_HEAD(, cdev) si_children;
LIST_ENTRY(cdev) si_siblings;
@@ -96,7 +96,9 @@ struct cdev {
#ifndef __rtems__
int si_iosize_max; /* maximum I/O size (for physio &al) */
u_long si_usecount;
+#endif /* __rtems__ */
u_long si_threadcount;
+#ifndef __rtems__
union {
struct snapdata *__sid_snapdata;
} __si_u;
@@ -108,6 +110,7 @@ struct cdev {
char __si_name[SPECNAMELEN + 1];
} __si_pathstruct;
#endif /* __rtems__ */
+ char __si_namebuf[SPECNAMELEN + 1];
};
#ifdef __rtems__
@@ -219,25 +222,33 @@ struct cdevsw {
u_int d_flags;
const char *d_name;
d_open_t *d_open;
+#ifndef __rtems__
d_fdopen_t *d_fdopen;
+#endif /* __rtems__ */
d_close_t *d_close;
d_read_t *d_read;
d_write_t *d_write;
d_ioctl_t *d_ioctl;
d_poll_t *d_poll;
+#ifndef __rtems__
d_mmap_t *d_mmap;
d_strategy_t *d_strategy;
dumper_t *d_dump;
+#endif /* __rtems__ */
d_kqfilter_t *d_kqfilter;
+#ifndef __rtems__
d_purge_t *d_purge;
d_mmap_single_t *d_mmap_single;
int32_t d_spare0[3];
void *d_spare1[3];
+#endif /* __rtems__ */
/* These fields should not be messed with by drivers */
LIST_HEAD(, cdev) d_devs;
+#ifndef __rtems__
int d_spare2;
+#endif /* __rtems__ */
union {
struct cdevsw *gianttrick;
SLIST_ENTRY(cdevsw) postfree_list;
diff --git a/libbsd.py b/libbsd.py
index 0ae58081..7771a4ff 100755
--- a/libbsd.py
+++ b/libbsd.py
@@ -76,7 +76,6 @@ def rtems(mm):
'rtems/rtems-kernel-bus-root.c',
'rtems/rtems-kernel-cam.c',
'rtems/rtems-kernel-chunk.c',
- 'rtems/rtems-kernel-conf.c',
'rtems/rtems-kernel-configintrhook.c',
'rtems/rtems-kernel-delay.c',
'rtems/rtems-kernel-get-file.c',
@@ -303,6 +302,7 @@ def base(mm):
[
'sys/kern/init_main.c',
'sys/kern/kern_condvar.c',
+ 'sys/kern/kern_conf.c',
'sys/kern/kern_event.c',
'sys/kern/kern_hhook.c',
'sys/kern/kern_intr.c',
diff --git a/libbsd_waf.py b/libbsd_waf.py
index caf2538d..b80dad5c 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -785,6 +785,7 @@ def build(bld):
'freebsd/sys/dev/usb/usb_util.c',
'freebsd/sys/kern/init_main.c',
'freebsd/sys/kern/kern_condvar.c',
+ 'freebsd/sys/kern/kern_conf.c',
'freebsd/sys/kern/kern_event.c',
'freebsd/sys/kern/kern_hhook.c',
'freebsd/sys/kern/kern_intr.c',
@@ -1069,7 +1070,6 @@ def build(bld):
'rtemsbsd/rtems/rtems-kernel-bus-root.c',
'rtemsbsd/rtems/rtems-kernel-cam.c',
'rtemsbsd/rtems/rtems-kernel-chunk.c',
- 'rtemsbsd/rtems/rtems-kernel-conf.c',
'rtemsbsd/rtems/rtems-kernel-configintrhook.c',
'rtemsbsd/rtems/rtems-kernel-delay.c',
'rtemsbsd/rtems/rtems-kernel-get-file.c',
diff --git a/rtemsbsd/rtems/rtems-kernel-conf.c b/rtemsbsd/rtems/rtems-kernel-conf.c
deleted file mode 100644
index d52ad198..00000000
--- a/rtemsbsd/rtems/rtems-kernel-conf.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * @file
- *
- * @ingroup rtems_bsd_rtems
- *
- * @brief This file is an rtems representation of needed methods from
- * the FreeBSD file kern_conf.c
- */
-
-/*
- * 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-kernel-space.h>
-#include <stdio.h>
-#include <rtems.h>
-
-__FBSDID("$FreeBSD$");
-
-#include <rtems/bsd/sys/param.h>
-#include <sys/conf.h>
-
-struct cdev *
-make_dev(struct cdevsw *devsw, int unit, uid_t uid, gid_t gid, int mode,
- const char *fmt, ...)
-{
- struct cdev *dev;
- dev = malloc( sizeof(struct cdev) );
-
- /* Initialize the elements that rtems uses. */
- dev->si_flags = 0;
- dev->si_drv0 = unit;
- dev->si_drv1 = NULL;
- dev->si_drv2 = NULL;
-
- return (dev);
-}
-
-void
-destroy_dev(struct cdev *dev)
-{
- free (dev);
-}