2020-05-13 14:18:48 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2022-05-06 10:25:46 +02:00
|
|
|
#include <zephyr/drivers/peci.h>
|
2023-09-26 22:46:01 +00:00
|
|
|
#include <zephyr/internal/syscall_handler.h>
|
2020-05-13 14:18:48 -07:00
|
|
|
|
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_peci_config(const struct device *dev,
|
|
|
|
|
uint32_t bitrate)
|
2020-05-13 14:18:48 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PECI(dev, config));
|
2020-05-13 14:18:48 -07:00
|
|
|
|
|
|
|
|
return z_impl_peci_config(dev, bitrate);
|
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/peci_config_mrsh.c>
|
2020-05-13 14:18:48 -07:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_peci_enable(const struct device *dev)
|
2020-05-13 14:18:48 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PECI(dev, enable));
|
2020-05-13 14:18:48 -07:00
|
|
|
|
|
|
|
|
return z_impl_peci_enable(dev);
|
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/peci_enable_mrsh.c>
|
2020-05-13 14:18:48 -07:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_peci_disable(const struct device *dev)
|
2020-05-13 14:18:48 -07:00
|
|
|
{
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PECI(dev, disable));
|
2020-05-13 14:18:48 -07:00
|
|
|
|
|
|
|
|
return z_impl_peci_disable(dev);
|
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/peci_disable_mrsh.c>
|
2020-05-13 14:18:48 -07:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline int z_vrfy_peci_transfer(const struct device *dev,
|
2020-05-13 14:18:48 -07:00
|
|
|
struct peci_msg *msg)
|
|
|
|
|
{
|
|
|
|
|
struct peci_msg msg_copy;
|
|
|
|
|
|
2023-09-27 11:20:28 +00:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_PECI(dev, transfer));
|
|
|
|
|
K_OOPS(k_usermode_from_copy(&msg_copy, msg, sizeof(*msg)));
|
2020-05-13 14:18:48 -07:00
|
|
|
|
2026-08-12 23:55:12 -07:00
|
|
|
/**
|
|
|
|
|
* k_usermode_from_copy() only duplicates the outer struct; the buffer
|
|
|
|
|
* pointers it carries are still caller supplied and the driver
|
|
|
|
|
* dereferences them in supervisor mode, so they must be checked here.
|
|
|
|
|
*/
|
|
|
|
|
if ((msg_copy.tx_buffer.buf != NULL) && (msg_copy.tx_buffer.len > 1U)) {
|
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_READ(msg_copy.tx_buffer.buf,
|
|
|
|
|
msg_copy.tx_buffer.len - 1U));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (msg_copy.rx_buffer.buf != NULL) {
|
|
|
|
|
size_t rx_len;
|
|
|
|
|
|
|
|
|
|
K_OOPS(K_SYSCALL_VERIFY_MSG(!size_add_overflow(msg_copy.rx_buffer.len,
|
|
|
|
|
1U, &rx_len),
|
|
|
|
|
"rx_buffer.len overflow"));
|
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(msg_copy.rx_buffer.buf, rx_len));
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-13 14:18:48 -07:00
|
|
|
return z_impl_peci_transfer(dev, &msg_copy);
|
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/peci_transfer_mrsh.c>
|