diff options
Diffstat (limited to 'cpukit/libdrvmgr/drvmgr_translate_check.c')
-rw-r--r-- | cpukit/libdrvmgr/drvmgr_translate_check.c | 35 |
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; +} |