summaryrefslogtreecommitdiffstats
path: root/pywrap/pcipywrap.c
diff options
context:
space:
mode:
authorVasilii Chernov <vchernov@inr.ru>2016-02-24 14:57:16 +0100
committerVasilii Chernov <vchernov@inr.ru>2016-02-24 14:57:16 +0100
commit5085fbed88cec0bdc1b339daf9cd888e184cc32c (patch)
tree320738e7c28777620ec51992ee139c9cc246893e /pywrap/pcipywrap.c
parent2c2a714e0615d6aff3773fabfd3b93e8672a40a1 (diff)
downloadpcitool-5085fbed88cec0bdc1b339daf9cd888e184cc32c.tar.gz
pcitool-5085fbed88cec0bdc1b339daf9cd888e184cc32c.tar.bz2
pcitool-5085fbed88cec0bdc1b339daf9cd888e184cc32c.tar.xz
pcitool-5085fbed88cec0bdc1b339daf9cd888e184cc32c.zip
1. Http server add tree view
2. Pcipywrap - add lock function wraps - add dma read wrap 3. Api server implement locking functionality
Diffstat (limited to 'pywrap/pcipywrap.c')
-rw-r--r--pywrap/pcipywrap.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c
index df5f194..a22dea9 100644
--- a/pywrap/pcipywrap.c
+++ b/pywrap/pcipywrap.c
@@ -1,4 +1,5 @@
#include "pcipywrap.h"
+#include "locking.h"
char* full_log = NULL;
@@ -501,3 +502,104 @@ PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch)
return pyList;
}
+
+PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size)
+{
+ int err;
+ void* buf = NULL;
+ size_t real_size;
+
+ err = pcilib_read_dma(self->ctx, dma, (uintptr_t)NULL, size, buf, &real_size);
+ if(err)
+ {
+ set_python_exception("Failed pcilib_read_dma", err);
+ return NULL;
+ }
+
+
+ PyObject* py_buf = PyByteArray_FromStringAndSize((const char*)buf, real_size);
+ if(buf)
+ free(buf);
+
+ return py_buf;
+}
+
+PyObject* Pcipywrap_lock_global(Pcipywrap *self)
+{
+ int err;
+
+ err = pcilib_lock_global(self->ctx);
+ if(err)
+ {
+ set_python_exception("Failed pcilib_lock_global");
+ return NULL;
+ }
+
+ return PyInt_FromLong((long)1);
+}
+
+void Pcipywrap_unlock_global(Pcipywrap *self)
+{
+ pcilib_unlock_global(self->ctx);
+ return;
+}
+
+PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id)
+{
+ pcilib_lock_t* lock = pcilib_get_lock(self->ctx,
+ PCILIB_LOCK_FLAG_PERSISTENT,
+ lock_id);
+ if(!lock)
+ {
+ set_python_exception("Failed pcilib_get_lock");
+ return NULL;
+ }
+
+
+ int err = pcilib_lock(lock);
+ if(err)
+ {
+ set_python_exception("Failed pcilib_lock");
+ return NULL;
+ }
+
+ return PyInt_FromLong((long)1);
+}
+
+PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id)
+{
+ pcilib_lock_t* lock = pcilib_get_lock(self->ctx,
+ PCILIB_LOCK_FLAGS_DEFAULT,
+ lock_id);
+ if(!lock)
+ {
+ set_python_exception("Failed pcilib_get_lock");
+ return NULL;
+ }
+
+ int err = pcilib_try_lock(lock);
+ if(err)
+ {
+ set_python_exception("Failed pcilib_try_lock");
+ return NULL;
+ }
+
+ return PyInt_FromLong((long)1);
+}
+
+PyObject* Pcipywrap_unlock(Pcipywrap *self, const char *lock_id)
+{
+ pcilib_lock_t* lock = pcilib_get_lock(self->ctx,
+ PCILIB_LOCK_FLAGS_DEFAULT,
+ lock_id);
+ if(!lock)
+ {
+ set_python_exception("Failed pcilib_get_lock");
+ return NULL;
+ }
+
+ pcilib_unlock(lock);
+ return PyInt_FromLong((long)1);
+}
+
+