summaryrefslogtreecommitdiffstats
path: root/tools/bus_space/Python/lang.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2015-06-06 16:14:03 +0000
committermarcel <marcel@FreeBSD.org>2015-06-06 16:14:03 +0000
commit9d7393a25cad6018b12d73a6304241272dc1ffb4 (patch)
treee8dd5a23810c7542cf1d51522936bc172bbfe980 /tools/bus_space/Python/lang.c
parent58f25d3df4c4b55a3af3128ba66239f1ed92efcd (diff)
downloadFreeBSD-src-9d7393a25cad6018b12d73a6304241272dc1ffb4.zip
FreeBSD-src-9d7393a25cad6018b12d73a6304241272dc1ffb4.tar.gz
Add DMA tag management to the C library and Python binding.
Diffstat (limited to 'tools/bus_space/Python/lang.c')
-rw-r--r--tools/bus_space/Python/lang.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/bus_space/Python/lang.c b/tools/bus_space/Python/lang.c
index f328a77..a515549 100644
--- a/tools/bus_space/Python/lang.c
+++ b/tools/bus_space/Python/lang.c
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
#include <Python.h>
#include "bus_space.h"
+#include "busdma.h"
static PyObject *
bus_read_1(PyObject *self, PyObject *args)
@@ -173,6 +174,58 @@ bus_subregion(PyObject *self, PyObject *args)
return (Py_BuildValue("i", rid));
}
+static PyObject *
+busdma_tag_create(PyObject *self, PyObject *args)
+{
+ char *dev;
+ long align, bndry, maxaddr, maxsz, maxsegsz;
+ int tid, nsegs, datarate, flags;
+
+ if (!PyArg_ParseTuple(args, "sllllilii", &dev, &align, &bndry,
+ &maxaddr, &maxsz, &nsegs, &maxsegsz, &datarate, &flags))
+ return (NULL);
+ tid = bd_tag_create(dev, align, bndry, maxaddr, maxsz, nsegs,
+ maxsegsz, datarate, flags);
+ if (tid == -1) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ return (Py_BuildValue("i", tid));
+}
+
+static PyObject *
+busdma_tag_derive(PyObject *self, PyObject *args)
+{
+ long align, bndry, maxaddr, maxsz, maxsegsz;
+ int ptid, tid, nsegs, datarate, flags;
+
+ if (!PyArg_ParseTuple(args, "illllilii", &ptid, &align, &bndry,
+ &maxaddr, &maxsz, &nsegs, &maxsegsz, &datarate, &flags))
+ return (NULL);
+ tid = bd_tag_derive(ptid, align, bndry, maxaddr, maxsz, nsegs,
+ maxsegsz, datarate, flags);
+ if (tid == -1) {
+ PyErr_SetString(PyExc_IOError, strerror(errno));
+ return (NULL);
+ }
+ return (Py_BuildValue("i", tid));
+}
+
+static PyObject *
+busdma_tag_destroy(PyObject *self, PyObject *args)
+{
+ int error, tid;
+
+ if (!PyArg_ParseTuple(args, "i", &tid))
+ return (NULL);
+ error = bd_tag_destroy(tid);
+ if (error) {
+ PyErr_SetString(PyExc_IOError, strerror(error));
+ return (NULL);
+ }
+ Py_RETURN_NONE;
+}
+
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." },
@@ -192,9 +245,17 @@ static PyMethodDef bus_space_methods[] = {
{ NULL, NULL, 0, NULL }
};
+static PyMethodDef busdma_methods[] = {
+ { "tag_create", busdma_tag_create, METH_VARARGS, "Create a root tag." },
+ { "tag_derive", busdma_tag_derive, METH_VARARGS, "Derive a child tag." },
+ { "tag_destroy", busdma_tag_destroy, METH_VARARGS, "Destroy a tag." },
+ { NULL, NULL, 0, NULL }
+};
+
PyMODINIT_FUNC
initbus_space(void)
{
Py_InitModule("bus_space", bus_space_methods);
+ Py_InitModule("busdma", busdma_methods);
}
OpenPOWER on IntegriCloud