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>
This commit is contained in:
parent
e7ded11a2e
commit
c200367b68
20 changed files with 224 additions and 119 deletions
|
@ -9,19 +9,19 @@
|
|||
|
||||
_SYSCALL_HANDLER(gpio_config, port, access_op, pin, flags)
|
||||
{
|
||||
_SYSCALL_OBJ(port, K_OBJ_DRIVER_GPIO);
|
||||
_SYSCALL_DRIVER_GPIO(port, config);
|
||||
return _impl_gpio_config((struct device *)port, access_op, pin, flags);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER(gpio_write, port, access_op, pin, value)
|
||||
{
|
||||
_SYSCALL_OBJ(port, K_OBJ_DRIVER_GPIO);
|
||||
_SYSCALL_DRIVER_GPIO(port, write);
|
||||
return _impl_gpio_write((struct device *)port, access_op, pin, value);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER(gpio_read, port, access_op, pin, value)
|
||||
{
|
||||
_SYSCALL_OBJ(port, K_OBJ_DRIVER_GPIO);
|
||||
_SYSCALL_DRIVER_GPIO(port, read);
|
||||
_SYSCALL_MEMORY_WRITE(value, sizeof(u32_t));
|
||||
return _impl_gpio_read((struct device *)port, access_op, pin,
|
||||
(u32_t *)value);
|
||||
|
@ -29,17 +29,20 @@ _SYSCALL_HANDLER(gpio_read, port, access_op, pin, value)
|
|||
|
||||
_SYSCALL_HANDLER(gpio_enable_callback, port, access_op, pin)
|
||||
{
|
||||
_SYSCALL_OBJ(port, K_OBJ_DRIVER_GPIO);
|
||||
_SYSCALL_DRIVER_GPIO(port, enable_callback);
|
||||
return _impl_gpio_enable_callback((struct device *)port, access_op,
|
||||
pin);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER(gpio_disable_callback, port, access_op, pin)
|
||||
{
|
||||
_SYSCALL_OBJ(port, K_OBJ_DRIVER_GPIO);
|
||||
_SYSCALL_DRIVER_GPIO(port, disable_callback);
|
||||
return _impl_gpio_disable_callback((struct device *)port, access_op,
|
||||
pin);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE(gpio_get_pending_int, K_OBJ_DRIVER_GPIO,
|
||||
struct device *);
|
||||
_SYSCALL_HANDLER(gpio_get_pending_int, port)
|
||||
{
|
||||
_SYSCALL_DRIVER_GPIO(port, get_pending_int);
|
||||
return _impl_gpio_get_pending_int((struct device *)port);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue