2017-10-26 13:24:34 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 10:25:46 +02:00
|
|
|
#include <zephyr/drivers/uart.h>
|
2023-09-26 22:46:01 +00:00
|
|
|
#include <zephyr/internal/syscall_handler.h>
|
2017-10-26 13:24:34 -07:00
|
|
|
|
2018-04-04 13:50:32 -07:00
|
|
|
#define UART_SIMPLE(op_) \
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_##op_(const struct device *dev) \
|
2019-08-13 12:58:38 -07:00
|
|
|
{ \
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, op_)); \
|
2019-08-13 10:27:12 -07:00
|
|
|
return z_impl_uart_ ## op_(dev); \
|
2018-04-04 13:50:32 -07:00
|
|
|
}
|
2017-10-26 13:24:34 -07:00
|
|
|
|
2018-04-04 13:50:32 -07:00
|
|
|
#define UART_SIMPLE_VOID(op_) \
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline void z_vrfy_uart_##op_(const struct device *dev) \
|
2019-08-13 12:58:38 -07:00
|
|
|
{ \
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, op_)); \
|
2019-08-13 10:27:12 -07:00
|
|
|
z_impl_uart_ ## op_(dev); \
|
2018-04-04 13:50:32 -07:00
|
|
|
}
|
2017-10-26 13:24:34 -07:00
|
|
|
|
2018-04-04 13:50:32 -07:00
|
|
|
UART_SIMPLE(err_check)
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_err_check_mrsh.c>
|
2017-10-26 13:24:34 -07:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_poll_in(const struct device *dev,
|
2019-08-13 10:27:12 -07:00
|
|
|
unsigned char *p_char)
|
2017-10-26 13:24:34 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, poll_in));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(p_char, sizeof(unsigned char)));
|
2019-08-13 10:27:12 -07:00
|
|
|
return z_impl_uart_poll_in(dev, p_char);
|
2017-10-26 13:24:34 -07:00
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_poll_in_mrsh.c>
|
2017-10-26 13:24:34 -07:00
|
|
|
|
2021-09-27 17:06:48 -07:00
|
|
|
static inline int z_vrfy_uart_poll_in_u16(const struct device *dev,
|
|
|
|
uint16_t *p_u16)
|
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, poll_in));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(p_u16, sizeof(uint16_t)));
|
2021-09-27 17:06:48 -07:00
|
|
|
return z_impl_uart_poll_in_u16(dev, p_u16);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_poll_in_u16_mrsh.c>
|
2021-09-27 17:06:48 -07:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline void z_vrfy_uart_poll_out(const struct device *dev,
|
2019-08-13 10:27:12 -07:00
|
|
|
unsigned char out_char)
|
2017-10-26 13:24:34 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, poll_out));
|
2020-04-30 20:33:38 +02:00
|
|
|
z_impl_uart_poll_out((const struct device *)dev, out_char);
|
2017-10-26 13:24:34 -07:00
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_poll_out_mrsh.c>
|
2019-08-13 10:27:12 -07:00
|
|
|
|
2021-09-27 17:06:48 -07:00
|
|
|
static inline void z_vrfy_uart_poll_out_u16(const struct device *dev,
|
|
|
|
uint16_t out_u16)
|
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, poll_out));
|
2021-09-27 17:06:48 -07:00
|
|
|
z_impl_uart_poll_out_u16((const struct device *)dev, out_u16);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_poll_out_u16_mrsh.c>
|
2021-09-27 17:06:48 -07:00
|
|
|
|
2023-07-17 16:47:21 -07:00
|
|
|
#ifdef CONFIG_UART_USE_RUNTIME_CONFIGURE
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_config_get(const struct device *dev,
|
|
|
|
struct uart_config *cfg)
|
2020-03-14 20:28:30 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, config_get));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(cfg, sizeof(struct uart_config)));
|
2020-03-14 20:28:30 -07:00
|
|
|
|
|
|
|
return z_impl_uart_config_get(dev, cfg);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_config_get_mrsh.c>
|
2020-03-14 20:28:30 -07:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_configure(const struct device *dev,
|
|
|
|
const struct uart_config *cfg)
|
2020-03-15 22:36:18 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, config_get));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_READ(cfg, sizeof(struct uart_config)));
|
2020-03-15 22:36:18 -07:00
|
|
|
|
|
|
|
return z_impl_uart_configure(dev, cfg);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_configure_mrsh.c>
|
2023-07-17 16:47:21 -07:00
|
|
|
#endif
|
2020-03-15 22:36:18 -07:00
|
|
|
|
2020-01-13 15:45:36 -08:00
|
|
|
#ifdef CONFIG_UART_ASYNC_API
|
|
|
|
/* callback_set() excluded as we don't allow ISR callback installation from
|
|
|
|
* user mode
|
|
|
|
*
|
|
|
|
* rx_buf_rsp() excluded as it's designed to be called from ISR callbacks
|
|
|
|
*/
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_tx(const struct device *dev, const uint8_t *buf,
|
2020-05-27 11:26:57 -05:00
|
|
|
size_t len, int32_t timeout)
|
2020-01-13 15:45:36 -08:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, tx));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_READ(buf, len));
|
2020-01-13 15:45:36 -08:00
|
|
|
return z_impl_uart_tx(dev, buf, len, timeout);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_tx_mrsh.c>
|
2020-01-13 15:45:36 -08:00
|
|
|
|
2021-09-27 17:06:48 -07:00
|
|
|
#ifdef CONFIG_UART_WIDE_DATA
|
|
|
|
static inline int z_vrfy_uart_tx_u16(const struct device *dev,
|
|
|
|
const uint16_t *buf,
|
|
|
|
size_t len, int32_t timeout)
|
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, tx));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(buf, len, sizeof(uint16_t)));
|
2021-09-27 17:06:48 -07:00
|
|
|
return z_impl_uart_tx_u16(dev, buf, len, timeout);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_tx_u16_mrsh.c>
|
2021-09-27 17:06:48 -07:00
|
|
|
#endif
|
|
|
|
|
2020-01-13 15:45:36 -08:00
|
|
|
UART_SIMPLE(tx_abort);
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_tx_abort_mrsh.c>
|
2020-01-13 15:45:36 -08:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_rx_enable(const struct device *dev,
|
|
|
|
uint8_t *buf,
|
2020-05-27 11:26:57 -05:00
|
|
|
size_t len, int32_t timeout)
|
2020-01-13 15:45:36 -08:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, rx_enable));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(buf, len));
|
2020-01-13 15:45:36 -08:00
|
|
|
return z_impl_uart_rx_enable(dev, buf, len, timeout);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_rx_enable_mrsh.c>
|
2020-01-13 15:45:36 -08:00
|
|
|
|
2021-09-27 17:06:48 -07:00
|
|
|
#ifdef CONFIG_UART_WIDE_DATA
|
|
|
|
static inline int z_vrfy_uart_rx_enable_u16(const struct device *dev,
|
|
|
|
uint16_t *buf,
|
|
|
|
size_t len, int32_t timeout)
|
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, rx_enable));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_ARRAY_WRITE(buf, len, sizeof(uint16_t)));
|
2021-09-27 17:06:48 -07:00
|
|
|
return z_impl_uart_rx_enable_u16(dev, buf, len, timeout);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_rx_enable_u16_mrsh.c>
|
2021-09-27 17:06:48 -07:00
|
|
|
#endif
|
|
|
|
|
2020-01-13 15:45:36 -08:00
|
|
|
UART_SIMPLE(rx_disable);
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_rx_disable_mrsh.c>
|
2020-01-13 15:45:36 -08:00
|
|
|
#endif /* CONFIG_UART_ASYNC_API */
|
2017-10-26 13:24:34 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
2018-04-04 13:50:32 -07:00
|
|
|
UART_SIMPLE_VOID(irq_tx_enable)
|
|
|
|
UART_SIMPLE_VOID(irq_tx_disable)
|
|
|
|
UART_SIMPLE_VOID(irq_rx_enable)
|
|
|
|
UART_SIMPLE_VOID(irq_rx_disable)
|
|
|
|
UART_SIMPLE_VOID(irq_err_enable)
|
|
|
|
UART_SIMPLE_VOID(irq_err_disable)
|
|
|
|
UART_SIMPLE(irq_is_pending)
|
|
|
|
UART_SIMPLE(irq_update)
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_irq_tx_enable_mrsh.c>
|
|
|
|
#include <zephyr/syscalls/uart_irq_tx_disable_mrsh.c>
|
|
|
|
#include <zephyr/syscalls/uart_irq_rx_enable_mrsh.c>
|
|
|
|
#include <zephyr/syscalls/uart_irq_rx_disable_mrsh.c>
|
|
|
|
#include <zephyr/syscalls/uart_irq_err_enable_mrsh.c>
|
|
|
|
#include <zephyr/syscalls/uart_irq_err_disable_mrsh.c>
|
|
|
|
#include <zephyr/syscalls/uart_irq_is_pending_mrsh.c>
|
|
|
|
#include <zephyr/syscalls/uart_irq_update_mrsh.c>
|
2017-10-26 13:24:34 -07:00
|
|
|
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
|
|
|
|
|
|
|
#ifdef CONFIG_UART_LINE_CTRL
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_line_ctrl_set(const struct device *dev,
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t ctrl, uint32_t val)
|
2017-10-26 13:24:34 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, line_ctrl_set));
|
2020-04-30 20:33:38 +02:00
|
|
|
return z_impl_uart_line_ctrl_set((const struct device *)dev, ctrl,
|
|
|
|
val);
|
2017-10-26 13:24:34 -07:00
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_line_ctrl_set_mrsh.c>
|
2017-10-26 13:24:34 -07:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_line_ctrl_get(const struct device *dev,
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t ctrl, uint32_t *val)
|
2017-10-26 13:24:34 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, line_ctrl_get));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(val, sizeof(uint32_t)));
|
2020-04-30 20:33:38 +02:00
|
|
|
return z_impl_uart_line_ctrl_get((const struct device *)dev, ctrl,
|
|
|
|
(uint32_t *)val);
|
2017-10-26 13:24:34 -07:00
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_line_ctrl_get_mrsh.c>
|
2017-10-26 13:24:34 -07:00
|
|
|
#endif /* CONFIG_UART_LINE_CTRL */
|
|
|
|
|
|
|
|
#ifdef CONFIG_UART_DRV_CMD
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_uart_drv_cmd(const struct device *dev, uint32_t cmd,
|
|
|
|
uint32_t p)
|
2017-10-26 13:24:34 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_UART(dev, drv_cmd));
|
2020-04-30 20:33:38 +02:00
|
|
|
return z_impl_uart_drv_cmd((const struct device *)dev, cmd, p);
|
2017-10-26 13:24:34 -07:00
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/uart_drv_cmd_mrsh.c>
|
2017-10-26 13:24:34 -07:00
|
|
|
#endif /* CONFIG_UART_DRV_CMD */
|