kernel: Port remaining buildable syscalls to new API
These calls are buildable on common sanitycheck platforms, but are not invoked at runtime in any tests accessible to CI. The changes are mostly mechanical, so the risk is low, but this commit is separated from the main API change to allow for more careful review. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
4723def90d
commit
346cce31d8
8 changed files with 102 additions and 41 deletions
|
@ -7,39 +7,50 @@
|
|||
#include <drivers/gpio.h>
|
||||
#include <syscall_handler.h>
|
||||
|
||||
Z_SYSCALL_HANDLER(gpio_config, port, access_op, pin, flags)
|
||||
static inline int z_vrfy_gpio_config(struct device *port, int access_op,
|
||||
u32_t pin, int flags)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, config));
|
||||
return z_impl_gpio_config((struct device *)port, access_op, pin, flags);
|
||||
}
|
||||
#include <syscalls/gpio_config_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(gpio_write, port, access_op, pin, value)
|
||||
static inline int z_vrfy_gpio_write(struct device *port, int access_op,
|
||||
u32_t pin, u32_t value)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, write));
|
||||
return z_impl_gpio_write((struct device *)port, access_op, pin, value);
|
||||
}
|
||||
#include <syscalls/gpio_write_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(gpio_read, port, access_op, pin, value)
|
||||
static inline int z_vrfy_gpio_read(struct device *port, int access_op,
|
||||
u32_t pin, u32_t *value)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, read));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(value, sizeof(u32_t)));
|
||||
return z_impl_gpio_read((struct device *)port, access_op, pin,
|
||||
(u32_t *)value);
|
||||
}
|
||||
#include <syscalls/gpio_read_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(gpio_enable_callback, port, access_op, pin)
|
||||
static inline int z_vrfy_gpio_enable_callback(struct device *port,
|
||||
int access_op, u32_t pin)
|
||||
{
|
||||
return z_impl_gpio_enable_callback((struct device *)port, access_op,
|
||||
pin);
|
||||
}
|
||||
#include <syscalls/gpio_enable_callback_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(gpio_disable_callback, port, access_op, pin)
|
||||
static inline int z_vrfy_gpio_disable_callback(struct device *port,
|
||||
int access_op, u32_t pin)
|
||||
{
|
||||
return z_impl_gpio_disable_callback((struct device *)port, access_op,
|
||||
pin);
|
||||
}
|
||||
#include <syscalls/gpio_disable_callback_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(gpio_get_pending_int, port)
|
||||
static inline int z_vrfy_gpio_get_pending_int(struct device *dev)
|
||||
{
|
||||
return z_impl_gpio_get_pending_int((struct device *)port);
|
||||
return z_impl_gpio_get_pending_int((struct device *)dev);
|
||||
}
|
||||
#include <syscalls/gpio_get_pending_int_mrsh.c>
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
#include <string.h>
|
||||
#include <syscall_handler.h>
|
||||
|
||||
Z_SYSCALL_HANDLER(i2c_configure, dev, dev_config)
|
||||
static inline int z_vrfy_i2c_configure(struct device *dev, u32_t dev_config)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_I2C(dev, configure));
|
||||
return z_impl_i2c_configure((struct device *)dev, dev_config);
|
||||
}
|
||||
#include <syscalls/i2c_configure_mrsh.c>
|
||||
|
||||
static u32_t copy_msgs_and_transfer(struct device *dev,
|
||||
const struct i2c_msg *msgs,
|
||||
u8_t num_msgs,
|
||||
u16_t addr,
|
||||
void *ssf)
|
||||
u16_t addr)
|
||||
{
|
||||
struct i2c_msg copy[num_msgs];
|
||||
u8_t i;
|
||||
|
@ -37,7 +37,9 @@ static u32_t copy_msgs_and_transfer(struct device *dev,
|
|||
return z_impl_i2c_transfer(dev, copy, num_msgs, addr);
|
||||
}
|
||||
|
||||
Z_SYSCALL_HANDLER(i2c_transfer, dev, msgs, num_msgs, addr)
|
||||
static inline int z_vrfy_i2c_transfer(struct device *dev,
|
||||
struct i2c_msg *msgs, u8_t num_msgs,
|
||||
u16_t addr)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C));
|
||||
|
||||
|
@ -54,12 +56,20 @@ Z_SYSCALL_HANDLER(i2c_transfer, dev, msgs, num_msgs, addr)
|
|||
|
||||
return copy_msgs_and_transfer((struct device *)dev,
|
||||
(struct i2c_msg *)msgs,
|
||||
(u8_t)num_msgs, (u16_t)addr,
|
||||
ssf);
|
||||
(u8_t)num_msgs, (u16_t)addr);
|
||||
}
|
||||
#include <syscalls/i2c_transfer_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER1_SIMPLE(i2c_slave_driver_register, K_OBJ_DRIVER_I2C,
|
||||
struct device *);
|
||||
static inline int z_vrfy_i2c_slave_driver_register(struct device *dev)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C));
|
||||
return z_impl_i2c_slave_driver_register(dev);
|
||||
}
|
||||
#include <syscalls/i2c_slave_driver_register_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER1_SIMPLE(i2c_slave_driver_unregister, K_OBJ_DRIVER_I2C,
|
||||
struct device *);
|
||||
static inline int z_vrfy_i2c_slave_driver_unregister(struct device *dev)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C));
|
||||
return z_vrfy_i2c_slave_driver_unregister(dev);
|
||||
}
|
||||
#include <syscalls/i2c_slave_driver_unregister_mrsh.c>
|
||||
|
|
|
@ -8,35 +8,37 @@
|
|||
#include <syscall_handler.h>
|
||||
|
||||
#define UART_SIMPLE(op_) \
|
||||
Z_SYSCALL_HANDLER(uart_ ## op_, dev) { \
|
||||
static inline int z_vrfy_uart_##op_(struct device *dev) { \
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, op_)); \
|
||||
return z_impl_uart_ ## op_((struct device *)dev); \
|
||||
return z_impl_uart_ ## op_(dev); \
|
||||
}
|
||||
|
||||
#define UART_SIMPLE_VOID(op_) \
|
||||
Z_SYSCALL_HANDLER(uart_ ## op_, dev) { \
|
||||
static inline void z_vrfy_uart_##op_(struct device *dev) { \
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, op_)); \
|
||||
z_impl_uart_ ## op_((struct device *)dev); \
|
||||
return 0; \
|
||||
z_impl_uart_ ## op_(dev); \
|
||||
}
|
||||
|
||||
UART_SIMPLE(err_check)
|
||||
#include <syscalls/uart_err_check_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(uart_poll_in, dev, p_char)
|
||||
static inline int z_vrfy_uart_poll_in(struct device *dev,
|
||||
unsigned char *p_char)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, poll_in));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(p_char, sizeof(unsigned char)));
|
||||
return z_impl_uart_poll_in((struct device *)dev,
|
||||
(unsigned char *)p_char);
|
||||
return z_impl_uart_poll_in(dev, p_char);
|
||||
}
|
||||
#include <syscalls/uart_poll_in_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(uart_poll_out, dev, out_char)
|
||||
static inline void z_vrfy_uart_poll_out(struct device *dev,
|
||||
unsigned char out_char)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, poll_out));
|
||||
z_impl_uart_poll_out((struct device *)dev, out_char);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include <syscalls/uart_poll_out_mrsh.c>
|
||||
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
UART_SIMPLE_VOID(irq_tx_enable)
|
||||
|
@ -47,28 +49,41 @@ UART_SIMPLE_VOID(irq_err_enable)
|
|||
UART_SIMPLE_VOID(irq_err_disable)
|
||||
UART_SIMPLE(irq_is_pending)
|
||||
UART_SIMPLE(irq_update)
|
||||
#include <syscalls/uart_irq_tx_enable_mrsh.c>
|
||||
#include <syscalls/uart_irq_tx_disable_mrsh.c>
|
||||
#include <syscalls/uart_irq_rx_enable_mrsh.c>
|
||||
#include <syscalls/uart_irq_rx_disable_mrsh.c>
|
||||
#include <syscalls/uart_irq_err_enable_mrsh.c>
|
||||
#include <syscalls/uart_irq_err_disable_mrsh.c>
|
||||
#include <syscalls/uart_irq_is_pending_mrsh.c>
|
||||
#include <syscalls/uart_irq_update_mrsh.c>
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
#ifdef CONFIG_UART_LINE_CTRL
|
||||
Z_SYSCALL_HANDLER(uart_line_ctrl_set, dev, ctrl, val)
|
||||
static inline int z_vrfy_uart_line_ctrl_set(struct device *dev,
|
||||
u32_t ctrl, u32_t val)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, line_ctrl_set));
|
||||
return z_impl_uart_line_ctrl_set((struct device *)dev, ctrl, val);
|
||||
}
|
||||
#include <syscalls/uart_line_ctrl_set_mrsh.c>
|
||||
|
||||
Z_SYSCALL_HANDLER(uart_line_ctrl_get, dev, ctrl, val)
|
||||
static inline int z_vrfy_uart_line_ctrl_get(struct device *dev,
|
||||
u32_t ctrl, u32_t *val)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, line_ctrl_get));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(val, sizeof(u32_t)));
|
||||
return z_impl_uart_line_ctrl_get((struct device *)dev, ctrl,
|
||||
(u32_t *)val);
|
||||
}
|
||||
#include <syscalls/uart_line_ctrl_get_mrsh.c>
|
||||
#endif /* CONFIG_UART_LINE_CTRL */
|
||||
|
||||
#ifdef CONFIG_UART_DRV_CMD
|
||||
Z_SYSCALL_HANDLER(uart_drv_cmd, dev, cmd, p)
|
||||
static inline int z_vrfy_uart_drv_cmd(struct device *dev, u32_t cmd, u32_t p)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, drv_cmd));
|
||||
return z_impl_uart_drv_cmd((struct device *)dev, cmd, p);
|
||||
}
|
||||
#include <syscalls/uart_drv_cmd_mrsh.c>
|
||||
#endif /* CONFIG_UART_DRV_CMD */
|
||||
|
|
|
@ -39,13 +39,13 @@ static struct k_spinlock lock;
|
|||
#include <syscall_handler.h>
|
||||
|
||||
#define ATOMIC_SYSCALL_HANDLER_TARGET(name) \
|
||||
Z_SYSCALL_HANDLER(name, target) { \
|
||||
static inline atomic_val_t z_vrfy_##name(atomic_t target) { \
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(target, sizeof(atomic_t))); \
|
||||
return z_impl_##name((atomic_t *)target); \
|
||||
}
|
||||
|
||||
#define ATOMIC_SYSCALL_HANDLER_TARGET_VALUE(name) \
|
||||
Z_SYSCALL_HANDLER(name, target, value) { \
|
||||
static inline atomic_val_t z_vrfy_##name(atomic_t target, u32_t value) { \
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(target, sizeof(atomic_t))); \
|
||||
return z_impl_##name((atomic_t *)target, value); \
|
||||
}
|
||||
|
@ -93,12 +93,14 @@ int z_impl_atomic_cas(atomic_t *target, atomic_val_t old_value,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(atomic_cas, target, old_value, new_value)
|
||||
int z_vrfy_atomic_cas(atomic_t *target, atomic_val_t old_value,
|
||||
atomic_val_t new_value)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(target, sizeof(atomic_t)));
|
||||
|
||||
return z_impl_atomic_cas((atomic_t *)target, old_value, new_value);
|
||||
}
|
||||
#include <syscalls/atomic_cas_mrsh.c>
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
/**
|
||||
|
@ -326,3 +328,13 @@ atomic_val_t z_impl_atomic_nand(atomic_t *target, atomic_val_t value)
|
|||
}
|
||||
|
||||
ATOMIC_SYSCALL_HANDLER_TARGET_VALUE(atomic_nand);
|
||||
|
||||
#ifdef USERSPACE
|
||||
#include <syscalls/atomic_add_mrsh.c>
|
||||
#include <syscalls/atomic_sub_mrsh.c>
|
||||
#include <syscalls/atomic_set_mrsh.c>
|
||||
#include <syscalls/atomic_or_mrsh.c>
|
||||
#include <syscalls/atomic_xor_mrsh.c>
|
||||
#include <syscalls/atomic_and_mrsh.c>
|
||||
#include <syscalls/atomic_nand_mrsh.c>
|
||||
#endif
|
||||
|
|
|
@ -83,13 +83,16 @@ done:
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(zephyr_fwrite, ptr, size, nitems, stream)
|
||||
static inline size_t z_vrfy_zephyr_fwrite(const void *_MLIBC_RESTRICT ptr,
|
||||
size_t size, size_t nitems,
|
||||
FILE *_MLIBC_RESTRICT stream)
|
||||
{
|
||||
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(ptr, nitems, size));
|
||||
return z_impl_zephyr_fwrite((const void *_MLIBC_RESTRICT)ptr, size,
|
||||
nitems, (FILE *_MLIBC_RESTRICT)stream);
|
||||
}
|
||||
#include <syscalls/zephyr_fwrite_mrsh.c>
|
||||
#endif
|
||||
|
||||
size_t fwrite(const void *_MLIBC_RESTRICT ptr, size_t size, size_t nitems,
|
||||
|
|
|
@ -137,11 +137,12 @@ int z_impl_zephyr_read_stdin(char *buf, int nbytes)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(zephyr_read_stdin, buf, nbytes)
|
||||
static inline int z_vrfy_z_zephyr_read_stdin(char *buf, int nbytes)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buf, nbytes));
|
||||
return z_impl_zephyr_read_stdin((char *)buf, nbytes);
|
||||
}
|
||||
#include <syscalls/z_zephyr_read_stdin_mrsh.c>
|
||||
#endif
|
||||
|
||||
int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
|
||||
|
@ -159,11 +160,12 @@ int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(zephyr_write_stdout, buf, nbytes)
|
||||
static inline int z_vrfy_z_zephyr_write_stdout(const void *buf, int nbytes)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_READ(buf, nbytes));
|
||||
return z_impl_zephyr_write_stdout((const void *)buf, nbytes);
|
||||
}
|
||||
#include <syscalls/z_zephyr_write_stdout_mrsh.c>
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_POSIX_API
|
||||
|
|
|
@ -276,7 +276,10 @@ int z_impl_z_zsock_getaddrinfo_internal(const char *host, const char *service,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(z_zsock_getaddrinfo_internal, host, service, hints, res)
|
||||
static inline int z_vrfy_z_zsock_getaddrinfo_internal(const char *host,
|
||||
const char *service,
|
||||
const struct zsock_addrinfo *hints,
|
||||
struct zsock_addrinfo *res)
|
||||
{
|
||||
struct zsock_addrinfo hints_copy;
|
||||
char *host_copy = NULL, *service_copy = NULL;
|
||||
|
@ -314,6 +317,7 @@ out:
|
|||
|
||||
return ret;
|
||||
}
|
||||
#include <syscalls/z_zsock_getaddrinfo_internal_mrsh.c>
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
int zsock_getaddrinfo(const char *host, const char *service,
|
||||
|
|
|
@ -222,10 +222,11 @@ int z_impl_zsock_shutdown(int sock, int how)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(zsock_shutdown, sock, how)
|
||||
static inline int z_vrfy_zsock_shutdown(int sock, int how)
|
||||
{
|
||||
return z_impl_zsock_shutdown(sock, how);
|
||||
}
|
||||
#include <syscalls/zsock_shutdown_mrsh.c>
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
static void zsock_accepted_cb(struct net_context *new_ctx,
|
||||
|
@ -908,10 +909,11 @@ int z_impl_zsock_fcntl(int sock, int cmd, int flags)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(zsock_fcntl, sock, cmd, flags)
|
||||
static inline int z_vrfy_zsock_fcntl(int sock, int cmd, int flags)
|
||||
{
|
||||
return z_impl_zsock_fcntl(sock, cmd, flags);
|
||||
}
|
||||
#include <syscalls/zsock_fcntl_mrsh.c>
|
||||
#endif
|
||||
|
||||
static int zsock_poll_prepare_ctx(struct net_context *ctx,
|
||||
|
@ -1409,7 +1411,8 @@ int z_impl_zsock_getsockname(int sock, struct sockaddr *addr,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
Z_SYSCALL_HANDLER(zsock_getsockname, sock, addr, addrlen)
|
||||
static inline int z_vrfy_zsock_getsockname(int sock, struct sockaddr *addr,
|
||||
socklen_t *addrlen)
|
||||
{
|
||||
socklen_t addrlen_copy;
|
||||
int ret;
|
||||
|
@ -1434,6 +1437,7 @@ Z_SYSCALL_HANDLER(zsock_getsockname, sock, addr, addrlen)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#include <syscalls/zsock_getsockname_mrsh.c>
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
static ssize_t sock_read_vmeth(void *obj, void *buffer, size_t count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue