summaryrefslogtreecommitdiffstats
path: root/cpukit/libdrvmgr/drvmgr_translate_check.c
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2011-11-28 09:52:03 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2015-04-17 01:10:16 +0200
commite7fade3ac4559214ab0508dc54a71a3d1f522afb (patch)
tree13e32728a3b6adccd3f435db73091a8233d5dadf /cpukit/libdrvmgr/drvmgr_translate_check.c
parentLIBPCI: added PCI shell command (diff)
downloadrtems-e7fade3ac4559214ab0508dc54a71a3d1f522afb.tar.bz2
DRVMGR: added driver manager to cpukit/libdrvmgr
Diffstat (limited to 'cpukit/libdrvmgr/drvmgr_translate_check.c')
-rw-r--r--cpukit/libdrvmgr/drvmgr_translate_check.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/cpukit/libdrvmgr/drvmgr_translate_check.c b/cpukit/libdrvmgr/drvmgr_translate_check.c
new file mode 100644
index 0000000000..c882b88f27
--- /dev/null
+++ b/cpukit/libdrvmgr/drvmgr_translate_check.c
@@ -0,0 +1,35 @@
+/* Driver Manager Driver Translate Interface Implementation
+ *
+ * COPYRIGHT (c) 2010.
+ * Cobham Gaisler AB.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <drvmgr/drvmgr.h>
+
+/* Calls drvmgr_translate() to translate an address range and check the result,
+ * a printout is generated if the check fails. See paramters of
+ * drvmgr_translate().
+ * If size=0 only the starting address is not checked.
+ */
+int drvmgr_translate_check(
+ struct drvmgr_dev *dev,
+ unsigned int options,
+ void *src_address,
+ void **dst_address,
+ unsigned int size)
+{
+ unsigned int max;
+
+ max = drvmgr_translate(dev, options, src_address, dst_address);
+ if (max == 0 || (max < size && (size != 0))) {
+ printk(" ### dev %p (%s) failed mapping %p\n",
+ dev, dev->name ? dev->name : "unnamed", src_address);
+ return -1;
+ }
+
+ return 0;
+}