diff options
author | marcel <marcel@FreeBSD.org> | 2015-06-08 03:23:20 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2015-06-08 03:23:20 +0000 |
commit | 440bb648898820e493ba0291411c6cd04de5c277 (patch) | |
tree | 5f5223455f8675c7e07131edae60a2f0560bad61 /tools/bus_space/Python/lang.c | |
parent | 1698c446dcd301bd89394c4faf4327cdc9537bc2 (diff) | |
download | FreeBSD-src-440bb648898820e493ba0291411c6cd04de5c277.zip FreeBSD-src-440bb648898820e493ba0291411c6cd04de5c277.tar.gz |
Add busdma_mem_alloc & busdma_mem_free.
Diffstat (limited to 'tools/bus_space/Python/lang.c')
-rw-r--r-- | tools/bus_space/Python/lang.c | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/tools/bus_space/Python/lang.c b/tools/bus_space/Python/lang.c index a515549..2247360 100644 --- a/tools/bus_space/Python/lang.c +++ b/tools/bus_space/Python/lang.c @@ -178,12 +178,13 @@ static PyObject * busdma_tag_create(PyObject *self, PyObject *args) { char *dev; - long align, bndry, maxaddr, maxsz, maxsegsz; - int tid, nsegs, datarate, flags; + u_long align, bndry, maxaddr, maxsz, maxsegsz; + u_int nsegs, datarate, flags; + int tid; - if (!PyArg_ParseTuple(args, "sllllilii", &dev, &align, &bndry, + if (!PyArg_ParseTuple(args, "skkkkIkII", &dev, &align, &bndry, &maxaddr, &maxsz, &nsegs, &maxsegsz, &datarate, &flags)) - return (NULL); + return (NULL); tid = bd_tag_create(dev, align, bndry, maxaddr, maxsz, nsegs, maxsegsz, datarate, flags); if (tid == -1) { @@ -196,10 +197,11 @@ busdma_tag_create(PyObject *self, PyObject *args) static PyObject * busdma_tag_derive(PyObject *self, PyObject *args) { - long align, bndry, maxaddr, maxsz, maxsegsz; - int ptid, tid, nsegs, datarate, flags; + u_long align, bndry, maxaddr, maxsz, maxsegsz; + u_int nsegs, datarate, flags; + int ptid, tid; - if (!PyArg_ParseTuple(args, "illllilii", &ptid, &align, &bndry, + if (!PyArg_ParseTuple(args, "ikkkkIkII", &ptid, &align, &bndry, &maxaddr, &maxsz, &nsegs, &maxsegsz, &datarate, &flags)) return (NULL); tid = bd_tag_derive(ptid, align, bndry, maxaddr, maxsz, nsegs, @@ -226,6 +228,37 @@ busdma_tag_destroy(PyObject *self, PyObject *args) Py_RETURN_NONE; } +static PyObject * +busdma_mem_alloc(PyObject *self, PyObject *args) +{ + u_int flags; + int mdid, tid; + + if (!PyArg_ParseTuple(args, "iI", &tid, &flags)) + return (NULL); + mdid = bd_mem_alloc(tid, flags); + if (mdid == -1) { + PyErr_SetString(PyExc_IOError, strerror(errno)); + return (NULL); + } + return (Py_BuildValue("i", mdid)); +} + +static PyObject * +busdma_mem_free(PyObject *self, PyObject *args) +{ + int error, mdid; + + if (!PyArg_ParseTuple(args, "i", &mdid)) + return (NULL); + error = bd_mem_free(mdid); + 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." }, @@ -246,9 +279,16 @@ static PyMethodDef bus_space_methods[] = { }; 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." }, + { "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." }, + { "mem_alloc", busdma_mem_alloc, METH_VARARGS, + "Allocate memory according to the DMA constraints." }, + { "mem_free", busdma_mem_free, METH_VARARGS, + "Free allocated memory." }, { NULL, NULL, 0, NULL } }; |