summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-05-08 23:54:15 +0000
committersjg <sjg@FreeBSD.org>2014-05-08 23:54:15 +0000
commited3fc70bf5a8edaf648093b11acca450802244ef (patch)
tree8ce0ddd0e6f508bd20c77429c448969589170fae /tools
parentd4e443e0426fee44056ba3c1123455666d083aef (diff)
parenta2e6be0add027bf3e713c0d56ba9715b83a01144 (diff)
downloadFreeBSD-src-ed3fc70bf5a8edaf648093b11acca450802244ef.zip
FreeBSD-src-ed3fc70bf5a8edaf648093b11acca450802244ef.tar.gz
Merge from head
Diffstat (limited to 'tools')
-rw-r--r--tools/bus_space/C/Makefile9
-rw-r--r--tools/bus_space/C/lang.c100
-rw-r--r--tools/bus_space/C/libbus_space.h42
-rw-r--r--tools/bus_space/Makefile7
-rw-r--r--tools/bus_space/Makefile.inc4
-rw-r--r--tools/bus_space/Python/Makefile9
-rw-r--r--tools/bus_space/Python/lang.c200
-rw-r--r--tools/bus_space/bus_space.c263
-rw-r--r--tools/bus_space/bus_space.h38
-rw-r--r--tools/kerneldoc/subsys/Doxyfile-dev_lindev21
-rw-r--r--tools/regression/priv/Makefile2
-rw-r--r--tools/tools/nanobsd/nanobsd.sh24
-rw-r--r--tools/tools/net80211/wlanwatch/Makefile2
13 files changed, 686 insertions, 35 deletions
diff --git a/tools/bus_space/C/Makefile b/tools/bus_space/C/Makefile
new file mode 100644
index 0000000..9d767e8
--- /dev/null
+++ b/tools/bus_space/C/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+LIB= bus_space
+SHLIB_MAJOR= 0
+SRCS= lang.c
+
+CFLAGS+= -I${.CURDIR}/..
+
+.include <bsd.lib.mk>
diff --git a/tools/bus_space/C/lang.c b/tools/bus_space/C/lang.c
new file mode 100644
index 0000000..6408343
--- /dev/null
+++ b/tools/bus_space/C/lang.c
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (c) 2014 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <errno.h>
+
+#include "bus_space.h"
+#include "libbus_space.h"
+
+int
+bus_space_read_1(int rid, long ofs)
+{
+ uint8_t val;
+
+ return ((!bs_read(rid, ofs, &val, sizeof(val))) ? -1 : (int)val);
+}
+
+int
+bus_space_read_2(int rid, long ofs)
+{
+ uint16_t val;
+
+ return ((!bs_read(rid, ofs, &val, sizeof(val))) ? -1 : (int)val);
+}
+
+int64_t
+bus_space_read_4(int rid, long ofs)
+{
+ uint32_t val;
+
+ return ((!bs_read(rid, ofs, &val, sizeof(val))) ? -1 : (int64_t)val);
+}
+
+int
+bus_space_write_1(int rid, long ofs, uint8_t val)
+{
+
+ return ((!bs_write(rid, ofs, &val, sizeof(val))) ? errno : 0);
+}
+
+int
+bus_space_write_2(int rid, long ofs, uint16_t val)
+{
+
+ return ((!bs_write(rid, ofs, &val, sizeof(val))) ? errno : 0);
+}
+
+int
+bus_space_write_4(int rid, long ofs, uint32_t val)
+{
+
+ return ((!bs_write(rid, ofs, &val, sizeof(val))) ? errno : 0);
+}
+
+int
+bus_space_map(const char *dev)
+{
+
+ return (bs_map(dev));
+}
+
+int
+bus_space_unmap(int rid)
+{
+
+ return ((!bs_unmap(rid)) ? errno : 0);
+}
+
+int
+bus_space_subregion(int rid, long ofs, long sz)
+{
+
+ return (bs_subregion(rid, ofs, sz));
+}
diff --git a/tools/bus_space/C/libbus_space.h b/tools/bus_space/C/libbus_space.h
new file mode 100644
index 0000000..3e8860f
--- /dev/null
+++ b/tools/bus_space/C/libbus_space.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2014 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$
+ */
+
+#ifndef _LIBBUS_SPACE_H_
+#define _LIBBUS_SPACE_H_
+
+int bus_space_map(const char *dev);
+int bus_space_read_1(int rid, long ofs);
+int bus_space_read_2(int rid, long ofs);
+int64_t bus_space_read_4(int rid, long ofs);
+int bus_space_subregion(int rid, long ofs, long sz);
+int bus_space_unmap(int rid);
+int bus_space_write_1(int rid, long ofs, uint8_t val);
+int bus_space_write_2(int rid, long ofs, uint16_t val);
+int bus_space_write_4(int rid, long ofs, uint32_t val);
+
+#endif /* _LIBBUS_SPACE_H_ */
diff --git a/tools/bus_space/Makefile b/tools/bus_space/Makefile
new file mode 100644
index 0000000..b13e3cf
--- /dev/null
+++ b/tools/bus_space/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+SUBDIR= \
+ C \
+ Python
+
+.include <bsd.subdir.mk>
diff --git a/tools/bus_space/Makefile.inc b/tools/bus_space/Makefile.inc
new file mode 100644
index 0000000..a448e33
--- /dev/null
+++ b/tools/bus_space/Makefile.inc
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/..
+SRCS+= bus_space.c
diff --git a/tools/bus_space/Python/Makefile b/tools/bus_space/Python/Makefile
new file mode 100644
index 0000000..8e38ed3
--- /dev/null
+++ b/tools/bus_space/Python/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+SHLIB_NAME= bus_space.so
+SRCS= lang.c
+
+CFLAGS+= -I${.CURDIR}/.. -I/usr/local/include/python2.7
+LDFLAGS+= -L/usr/local/lib -lpython2.7
+
+.include <bsd.lib.mk>
diff --git a/tools/bus_space/Python/lang.c b/tools/bus_space/Python/lang.c
new file mode 100644
index 0000000..f328a77
--- /dev/null
+++ b/tools/bus_space/Python/lang.c
@@ -0,0 +1,200 @@
+/*-
+ * Copyright (c) 2014 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <Python.h>
+
+#include "bus_space.h"
+
+static PyObject *
+bus_read_1(PyObject *self, PyObject *args)
+{
+ long ofs;
+ int rid;
+ uint8_t val;
+
+ if (!PyArg_ParseTuple(args, "il", &rid, &ofs))
+ return (NULL);
+ if (!bs_read(rid, ofs, &val, sizeof(val))) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ return (Py_BuildValue("B", val));
+}
+
+static PyObject *
+bus_read_2(PyObject *self, PyObject *args)
+{
+ long ofs;
+ int rid;
+ uint16_t val;
+
+ if (!PyArg_ParseTuple(args, "il", &rid, &ofs))
+ return (NULL);
+ if (!bs_read(rid, ofs, &val, sizeof(val))) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ return (Py_BuildValue("H", val));
+}
+
+static PyObject *
+bus_read_4(PyObject *self, PyObject *args)
+{
+ long ofs;
+ int rid;
+ uint32_t val;
+
+ if (!PyArg_ParseTuple(args, "il", &rid, &ofs))
+ return (NULL);
+ if (!bs_read(rid, ofs, &val, sizeof(val))) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ return (Py_BuildValue("I", val));
+}
+
+static PyObject *
+bus_write_1(PyObject *self, PyObject *args)
+{
+ long ofs;
+ int rid;
+ uint8_t val;
+
+ if (!PyArg_ParseTuple(args, "ilB", &rid, &ofs, &val))
+ return (NULL);
+ if (!bs_write(rid, ofs, &val, sizeof(val))) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+bus_write_2(PyObject *self, PyObject *args)
+{
+ long ofs;
+ int rid;
+ uint16_t val;
+
+ if (!PyArg_ParseTuple(args, "ilH", &rid, &ofs, &val))
+ return (NULL);
+ if (!bs_write(rid, ofs, &val, sizeof(val))) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+bus_write_4(PyObject *self, PyObject *args)
+{
+ long ofs;
+ int rid;
+ uint32_t val;
+
+ if (!PyArg_ParseTuple(args, "ilI", &rid, &ofs, &val))
+ return (NULL);
+ if (!bs_write(rid, ofs, &val, sizeof(val))) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+bus_map(PyObject *self, PyObject *args)
+{
+ char *dev;
+ int rid;
+
+ if (!PyArg_ParseTuple(args, "s", &dev))
+ return (NULL);
+ rid = bs_map(dev);
+ if (rid == -1) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ return (Py_BuildValue("i", rid));
+}
+
+static PyObject *
+bus_unmap(PyObject *self, PyObject *args)
+{
+ int rid;
+
+ if (!PyArg_ParseTuple(args, "i", &rid))
+ return (NULL);
+ if (!bs_unmap(rid)) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+bus_subregion(PyObject *self, PyObject *args)
+{
+ long ofs, sz;
+ int rid0, rid;
+
+ if (!PyArg_ParseTuple(args, "ill", &rid0, &ofs, &sz))
+ return (NULL);
+ rid = bs_subregion(rid0, ofs, sz);
+ if (rid == -1) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ return (Py_BuildValue("i", rid));
+}
+
+static PyMethodDef bus_space_methods[] = {
+ { "read_1", bus_read_1, METH_VARARGS, "Read a 1-byte data item." },
+ { "read_2", bus_read_2, METH_VARARGS, "Read a 2-byte data item." },
+ { "read_4", bus_read_4, METH_VARARGS, "Read a 4-byte data item." },
+
+ { "write_1", bus_write_1, METH_VARARGS, "Write a 1-byte data item." },
+ { "write_2", bus_write_2, METH_VARARGS, "Write a 2-byte data item." },
+ { "write_4", bus_write_4, METH_VARARGS, "Write a 4-byte data item." },
+
+ { "map", bus_map, METH_VARARGS,
+ "Return a resource ID for a device file created by proto(4)" },
+ { "unmap", bus_unmap, METH_VARARGS,
+ "Free a resource ID" },
+ { "subregion", bus_subregion, METH_VARARGS,
+ "Return a resource ID for a subregion of another resource ID" },
+
+ { NULL, NULL, 0, NULL }
+};
+
+PyMODINIT_FUNC
+initbus_space(void)
+{
+
+ Py_InitModule("bus_space", bus_space_methods);
+}
diff --git a/tools/bus_space/bus_space.c b/tools/bus_space/bus_space.c
new file mode 100644
index 0000000..260222c
--- /dev/null
+++ b/tools/bus_space/bus_space.c
@@ -0,0 +1,263 @@
+/*-
+ * Copyright (c) 2014 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "bus_space.h"
+
+#include "../../sys/dev/proto/proto_dev.h"
+
+struct resource {
+ int rid;
+ int fd;
+ long addr;
+ long size;
+ off_t ofs;
+ caddr_t ptr;
+};
+
+static struct resource *ridtbl = NULL;
+static int nrids = 0;
+
+static int
+rid_alloc(void)
+{
+ void *newtbl;
+ int rid;
+
+ for (rid = 0; rid < nrids; rid++) {
+ if (ridtbl[rid].fd == -1)
+ break;
+ }
+ if (rid == nrids) {
+ nrids++;
+ newtbl = realloc(ridtbl, sizeof(struct resource) * nrids);
+ if (newtbl == NULL) {
+ nrids--;
+ return (-1);
+ } else
+ ridtbl = newtbl;
+ }
+ ridtbl[rid].fd = INT_MAX;
+ return (rid);
+}
+
+static struct resource *
+rid_lookup(int rid)
+{
+ struct resource *r;
+
+ if (rid < 0 || rid >= nrids) {
+ errno = EINVAL;
+ return (NULL);
+ }
+ r = ridtbl + rid;
+ if (r->fd == -1) {
+ errno = ENXIO;
+ return (NULL);
+ }
+ return (r);
+}
+
+int
+bs_map(const char *dev)
+{
+ struct proto_ioc_region region;
+ struct resource *r;
+ int rid;
+
+ rid = rid_alloc();
+ if (rid == -1)
+ return (-1);
+ r = rid_lookup(rid);
+ if (r == NULL)
+ return (-1);
+ r->fd = open(dev, O_RDWR);
+ if (r->fd == -1)
+ return (-1);
+ r->rid = -1;
+ if (ioctl(r->fd, PROTO_IOC_REGION, &region) == -1) {
+ close(r->fd);
+ r->fd = -1;
+ return (-1);
+ }
+ r->addr = region.address;
+ r->size = region.size;
+ r->ofs = 0;
+ r->ptr = mmap(NULL, r->size, PROT_READ | PROT_WRITE,
+ MAP_NOCORE | MAP_SHARED, r->fd, r->ofs);
+ return (rid);
+}
+
+int
+bs_read(int rid, off_t ofs, void *buf, ssize_t bufsz)
+{
+ struct resource *r;
+ volatile void *ptr;
+ off_t o;
+ ssize_t s;
+
+ r = rid_lookup(rid);
+ if (r == NULL)
+ return (0);
+ if (ofs < 0 || ofs > r->size - bufsz) {
+ errno = ESPIPE;
+ return (0);
+ }
+ ofs += r->ofs;
+ if (r->ptr != MAP_FAILED) {
+ ptr = r->ptr + ofs;
+ switch (bufsz) {
+ case 1:
+ *((uint8_t *)buf) = *((volatile uint8_t *)ptr);
+ break;
+ case 2:
+ *((uint16_t *)buf) = *((volatile uint16_t *)ptr);
+ break;
+ case 4:
+ *((uint32_t *)buf) = *((volatile uint32_t *)ptr);
+ break;
+ default:
+ errno = EIO;
+ return (0);
+ }
+ } else {
+ o = lseek(r->fd, ofs, SEEK_SET);
+ if (o != ofs)
+ return (0);
+ s = read(r->fd, buf, bufsz);
+ if (s != bufsz)
+ return (0);
+ }
+ return (1);
+}
+
+int
+bs_subregion(int rid0, long ofs, long sz)
+{
+ struct resource *r;
+ void *ptr0;
+ long addr0, ofs0;
+ int fd0, rid;
+
+ r = rid_lookup(rid0);
+ if (r == NULL)
+ return (-1);
+ if (ofs < 0 || sz < 1) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if (ofs + sz > r->size) {
+ errno = ENOSPC;
+ return (-1);
+ }
+ fd0 = r->fd;
+ addr0 = r->addr;
+ ofs0 = r->ofs;
+ ptr0 = r->ptr;
+ rid = rid_alloc();
+ if (rid == -1)
+ return (-1);
+ r = rid_lookup(rid);
+ if (r == NULL)
+ return (-1);
+ r->rid = rid0;
+ r->fd = fd0;
+ r->addr = addr0 + ofs;
+ r->size = sz;
+ r->ofs = ofs0 + ofs;
+ r->ptr = ptr0;
+ return (rid);
+}
+
+int
+bs_unmap(int rid)
+{
+ struct resource *r;
+
+ r = rid_lookup(rid);
+ if (r == NULL)
+ return (0);
+ if (r->rid == -1) {
+ if (r->ptr != MAP_FAILED)
+ munmap(r->ptr, r->size);
+ close(r->fd);
+ }
+ r->fd = -1;
+ return (1);
+}
+
+int
+bs_write(int rid, off_t ofs, void *buf, ssize_t bufsz)
+{
+ struct resource *r;
+ volatile void *ptr;
+ off_t o;
+ ssize_t s;
+
+ r = rid_lookup(rid);
+ if (r == NULL)
+ return (0);
+ if (ofs < 0 || ofs > r->size - bufsz) {
+ errno = ESPIPE;
+ return (0);
+ }
+ ofs += r->ofs;
+ if (r->ptr != MAP_FAILED) {
+ ptr = r->ptr + ofs;
+ switch (bufsz) {
+ case 1:
+ *((volatile uint8_t *)ptr) = *((uint8_t *)buf);
+ break;
+ case 2:
+ *((volatile uint16_t *)ptr) = *((uint16_t *)buf);
+ break;
+ case 4:
+ *((volatile uint32_t *)ptr) = *((uint32_t *)buf);
+ break;
+ default:
+ errno = EIO;
+ return (0);
+ }
+ } else {
+ o = lseek(r->fd, ofs, SEEK_SET);
+ if (o != ofs)
+ return (0);
+ s = write(r->fd, buf, bufsz);
+ if (s != bufsz)
+ return (0);
+ }
+ return (1);
+}
diff --git a/tools/bus_space/bus_space.h b/tools/bus_space/bus_space.h
new file mode 100644
index 0000000..d347106
--- /dev/null
+++ b/tools/bus_space/bus_space.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2014 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$
+ */
+
+#ifndef _TOOLS_BUS_SPACE_H_
+#define _TOOLS_BUS_SPACE_H_
+
+int bs_map(const char *dev);
+int bs_read(int rid, off_t ofs, void *buf, ssize_t bufsz);
+int bs_subregion(int rid0, long ofs, long sz);
+int bs_unmap(int rid);
+int bs_write(int rid, off_t ofs, void *buf, ssize_t bufsz);
+
+#endif /* _TOOLS_BUS_SPACE_H_ */
diff --git a/tools/kerneldoc/subsys/Doxyfile-dev_lindev b/tools/kerneldoc/subsys/Doxyfile-dev_lindev
deleted file mode 100644
index 449a23f..0000000
--- a/tools/kerneldoc/subsys/Doxyfile-dev_lindev
+++ /dev/null
@@ -1,21 +0,0 @@
-# Doxyfile 1.5.2
-
-# $FreeBSD$
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = "FreeBSD kernel LINDEV device code"
-OUTPUT_DIRECTORY = $(DOXYGEN_DEST_PATH)/dev_lindev/
-EXTRACT_ALL = YES # for undocumented src, no warnings enabled
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = $(DOXYGEN_SRC_PATH)/dev/lindev/ \
- $(NOTREVIEWED)
-
-GENERATE_TAGFILE = dev_lindev/dev_lindev.tag
-
-@INCLUDE_PATH = $(DOXYGEN_INCLUDE_PATH)
-@INCLUDE = common-Doxyfile
-
diff --git a/tools/regression/priv/Makefile b/tools/regression/priv/Makefile
index 9ed28a7..a1fbcc6 100644
--- a/tools/regression/priv/Makefile
+++ b/tools/regression/priv/Makefile
@@ -2,7 +2,7 @@
# $FreeBSD$
#
-.include <bsd.own.mk>
+.include <src.opts.mk>
PROG= priv
SRCS= main.c \
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh
index 3f7fbe2..274132c 100644
--- a/tools/tools/nanobsd/nanobsd.sh
+++ b/tools/tools/nanobsd/nanobsd.sh
@@ -233,7 +233,7 @@ build_kernel ( ) (
(
if [ -f ${NANO_KERNEL} ] ; then
- extra="KERNCONFDIR=$(realpath $(dirname ${NANO_KERNEL}))"
+ kernconfdir_arg="KERNCONFDIR='$(realpath $(dirname ${NANO_KERNEL}))'"
kernconf=$(basename ${NANO_KERNEL})
else
kernconf=${NANO_KERNEL}
@@ -245,10 +245,10 @@ build_kernel ( ) (
unset TARGET_CPUTYPE
# Note: We intentionally build all modules, not only the ones in
# NANO_MODULES so the built world can be reused by multiple images.
- env TARGET_ARCH=${NANO_ARCH} ${NANO_PMAKE} buildkernel \
- SRCCONF=${SRCCONF} \
- ${extra} __MAKE_CONF=${NANO_MAKE_CONF_BUILD} \
- KERNCONF=${kernconf}
+ eval "TARGET_ARCH=${NANO_ARCH} ${NANO_PMAKE} buildkernel \
+ SRCCONF='${SRCCONF}' \
+ __MAKE_CONF='${NANO_MAKE_CONF_BUILD}' \
+ ${kernconfdir_arg} KERNCONF=${kernconf}"
) > ${MAKEOBJDIRPREFIX}/_.bk 2>&1
)
@@ -315,19 +315,19 @@ install_kernel ( ) (
(
if [ -f ${NANO_KERNEL} ] ; then
- extra="KERNCONFDIR=$(realpath $(dirname ${NANO_KERNEL}))"
+ kernconfdir_arg="KERNCONFDIR='$(realpath $(dirname ${NANO_KERNEL}))'"
kernconf=$(basename ${NANO_KERNEL})
else
kernconf=${NANO_KERNEL}
fi
cd ${NANO_SRC}
- env TARGET_ARCH=${NANO_ARCH} ${NANO_MAKE} installkernel \
- DESTDIR=${NANO_WORLDDIR} \
- SRCCONF=${SRCCONF} \
- ${extra} __MAKE_CONF=${NANO_MAKE_CONF_INSTALL} \
- KERNCONF=${kernconf} \
- MODULES_OVERRIDE="${NANO_MODULES}"
+ eval "TARGET_ARCH=${NANO_ARCH} ${NANO_MAKE} installkernel \
+ DESTDIR='${NANO_WORLDDIR}' \
+ SRCCONF='${SRCCONF}' \
+ __MAKE_CONF='${NANO_MAKE_CONF_INSTALL}' \
+ ${kernconfdir_arg} KERNCONF=${kernconf} \
+ MODULES_OVERRIDE='${NANO_MODULES}'"
) > ${NANO_OBJ}/_.ik 2>&1
)
diff --git a/tools/tools/net80211/wlanwatch/Makefile b/tools/tools/net80211/wlanwatch/Makefile
index 57f2332..7cd0550 100644
--- a/tools/tools/net80211/wlanwatch/Makefile
+++ b/tools/tools/net80211/wlanwatch/Makefile
@@ -4,7 +4,7 @@ PROG= wlanwatch
BINDIR= /usr/local/bin
MAN=
-.include <bsd.own.mk>
+.include <src.opts.mk>
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+= -DINET6
OpenPOWER on IntegriCloud