|
| 1 | +/* |
| 2 | + * Copyright (c) 2018 Alexander Wachter |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#include <syscall_handler.h> |
| 8 | +#include <can.h> |
| 9 | + |
| 10 | +_SYSCALL_HANDLER(can_configure, dev, mode, bitrate) { |
| 11 | + |
| 12 | + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN); |
| 13 | + |
| 14 | + return _impl_can_configure((struct device *)dev, mode, bitrate); |
| 15 | +} |
| 16 | + |
| 17 | +_SYSCALL_HANDLER(can_send, dev, msg) { |
| 18 | + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN); |
| 19 | + |
| 20 | + /* We need to be able to read the data */ |
| 21 | + _SYSCALL_MEMORY_ARRAY_READ(msg->data, msg->dlc, sizeof(msg->data)); |
| 22 | + |
| 23 | + return _impl_can_send((struct device *)dev, (struct can_msg *)msg) |
| 24 | +} |
| 25 | + |
| 26 | +_SYSCALL_HANDLER(can_attach_msgq, dev, msgq, filter) { |
| 27 | + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN); |
| 28 | + |
| 29 | + /* We need to be able to write the data */ |
| 30 | + _SYSCALL_MEMORY_WRITE(msgq, sizeof(msgq)); |
| 31 | + _SYSCALL_MEMORY_WRITE(msgq->buffer_start, |
| 32 | + msgq->buffer_end - msgq->buffer_start); |
| 33 | + |
| 34 | + return _impl_can_attach_msgq((struct device *)dev, |
| 35 | + (struct k_msgq *)msgq, |
| 36 | + (const struct can_filter *) filter); |
| 37 | +} |
| 38 | + |
| 39 | +_SYSCALL_HANDLER(can_attach_isr, dev, isr, filter) { |
| 40 | + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN); |
| 41 | + |
| 42 | + return _impl_can_attach_isr((struct device *)dev, |
| 43 | + (can_rx_callback_t)isr, |
| 44 | + (const struct can_filter *) filter); |
| 45 | +} |
| 46 | + |
| 47 | +_SYSCALL_HANDLER(can_detach, dev, filter_id) { |
| 48 | + _SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN); |
| 49 | + |
| 50 | + return _impl_can_detach((struct device *)dev, (int)filter_id); |
| 51 | +} |
0 commit comments