zephyr/drivers/pinmux/pinmux_handlers.c
Leandro Pereira c200367b68 drivers: Perform a runtime check if a driver is capable of an operation
Driver APIs might not implement all operations, making it possible for
a user thread to get the kernel to execute a function at 0x00000000.

Perform runtime checks in all the driver handlers, checking if they're
capable of performing the requested operation.

Fixes #6907.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30

35 lines
861 B
C

/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <pinmux.h>
#include <syscall_handler.h>
#include <toolchain.h>
_SYSCALL_HANDLER(pinmux_pin_set, dev, pin, func)
{
_SYSCALL_DRIVER_PINMUX(dev, set);
return _impl_pinmux_pin_set((struct device *)dev, pin, func);
}
_SYSCALL_HANDLER(pinmux_pin_get, dev, pin, func)
{
_SYSCALL_DRIVER_PINMUX(dev, get);
_SYSCALL_MEMORY_WRITE(func, sizeof(u32_t));
return _impl_pinmux_pin_get((struct device *)dev, pin,
(u32_t *)func);
}
_SYSCALL_HANDLER(pinmux_pin_pullup, dev, pin, func)
{
_SYSCALL_DRIVER_PINMUX(dev, pullup);
return _impl_pinmux_pin_pullup((struct device *)dev, pin, func);
}
_SYSCALL_HANDLER(pinmux_pin_input_enable, dev, pin, func)
{
_SYSCALL_DRIVER_PINMUX(dev, input);
return _impl_pinmux_pin_input_enable((struct device *)dev, pin, func);
}