2022-03-08 17:12:34 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 Thomas Stranger
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2023-09-27 06:46:01 +08:00
|
|
|
#include <zephyr/internal/syscall_handler.h>
|
2022-03-08 17:12:34 +08:00
|
|
|
#include <zephyr/drivers/w1.h>
|
|
|
|
|
|
|
|
static inline int z_vrfy_w1_reset_bus(const struct device *dev)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_W1(dev, reset_bus));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_reset_bus((const struct device *)dev);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_reset_bus_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_read_bit(const struct device *dev)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_W1(dev, read_bit));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_read_bit((const struct device *)dev);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_read_bit_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_write_bit(const struct device *dev, bool bit)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_W1(dev, write_bit));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_write_bit((const struct device *)dev, bit);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_write_bit_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_read_byte(const struct device *dev)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_W1(dev, read_byte));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_read_byte((const struct device *)dev);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_read_byte_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_write_byte(const struct device *dev, uint8_t byte)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_W1(dev, write_byte));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_write_byte((const struct device *)dev, (uint8_t)byte);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_write_byte_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_read_block(const struct device *dev,
|
|
|
|
uint8_t *buffer, size_t len)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_WRITE(buffer, len));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_read_block((const struct device *)dev,
|
|
|
|
(uint8_t *)buffer, (size_t)len);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_read_block_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_write_block(const struct device *dev,
|
|
|
|
const uint8_t *buffer, size_t len)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
|
|
|
|
K_OOPS(K_SYSCALL_MEMORY_READ(buffer, len));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_write_block((const struct device *)dev,
|
|
|
|
(const uint8_t *)buffer, (size_t)len);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_write_block_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_change_bus_lock(const struct device *dev, bool lock)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_change_bus_lock((const struct device *)dev, lock);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_change_bus_lock_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline int z_vrfy_w1_configure(const struct device *dev,
|
|
|
|
enum w1_settings_type type, uint32_t value)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_DRIVER_W1(dev, configure));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_configure(dev, type, value);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_configure_mrsh.c>
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
static inline size_t z_vrfy_w1_get_slave_count(const struct device *dev)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
|
2022-03-08 17:12:34 +08:00
|
|
|
|
|
|
|
return z_impl_w1_get_slave_count((const struct device *)dev);
|
|
|
|
}
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_get_slave_count_mrsh.c>
|
drivers: w1 introduce 1-wire net layer api
This commit introduces a new api for the net layer of Dallas
1-wire protocol.
For single drop configurations w1_read_rom, and w1_skip_rom commands are
provided.
For multidrop configurations w1_match_rom, w1_resume_command,
w1_search_rom, and w1_search_alarm routines are provided as well.
Additionally, the reset_select routine, conditionally depending on the
bus configuration, either executes a match_rom, or a skip rom command.
A w1_write_read command simplifies the typical scenario of addressing
a device, writing a few bytes to the device and reading back the answer.
Additionally w1_crc8, and w1_crc16 are added as wrappers around the
zephyr in-tree crc8 and crc16_reflect implementations.
The former may be used to verify the validity of the rom id, while the
latter is used for integrity checking of many eeprom, and authenticator
commands.
The general search command does not support filtering on
the family code.
Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-07-04 02:00:23 +08:00
|
|
|
|
|
|
|
#if CONFIG_W1_NET
|
|
|
|
static inline int z_vrfy_w1_search_bus(const struct device *dev,
|
|
|
|
uint8_t command, uint8_t family,
|
|
|
|
w1_search_callback_t callback,
|
|
|
|
void *user_data)
|
|
|
|
{
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_W1));
|
drivers: w1 introduce 1-wire net layer api
This commit introduces a new api for the net layer of Dallas
1-wire protocol.
For single drop configurations w1_read_rom, and w1_skip_rom commands are
provided.
For multidrop configurations w1_match_rom, w1_resume_command,
w1_search_rom, and w1_search_alarm routines are provided as well.
Additionally, the reset_select routine, conditionally depending on the
bus configuration, either executes a match_rom, or a skip rom command.
A w1_write_read command simplifies the typical scenario of addressing
a device, writing a few bytes to the device and reading back the answer.
Additionally w1_crc8, and w1_crc16 are added as wrappers around the
zephyr in-tree crc8 and crc16_reflect implementations.
The former may be used to verify the validity of the rom id, while the
latter is used for integrity checking of many eeprom, and authenticator
commands.
The general search command does not support filtering on
the family code.
Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-07-04 02:00:23 +08:00
|
|
|
|
2023-09-27 19:20:28 +08:00
|
|
|
K_OOPS(K_SYSCALL_VERIFY_MSG(callback == 0,
|
drivers: w1 introduce 1-wire net layer api
This commit introduces a new api for the net layer of Dallas
1-wire protocol.
For single drop configurations w1_read_rom, and w1_skip_rom commands are
provided.
For multidrop configurations w1_match_rom, w1_resume_command,
w1_search_rom, and w1_search_alarm routines are provided as well.
Additionally, the reset_select routine, conditionally depending on the
bus configuration, either executes a match_rom, or a skip rom command.
A w1_write_read command simplifies the typical scenario of addressing
a device, writing a few bytes to the device and reading back the answer.
Additionally w1_crc8, and w1_crc16 are added as wrappers around the
zephyr in-tree crc8 and crc16_reflect implementations.
The former may be used to verify the validity of the rom id, while the
latter is used for integrity checking of many eeprom, and authenticator
commands.
The general search command does not support filtering on
the family code.
Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-07-04 02:00:23 +08:00
|
|
|
"callbacks may not be set from user mode"));
|
|
|
|
/* user_data is not dereferenced, no need to check parameter */
|
|
|
|
|
|
|
|
return z_impl_w1_search_bus((const struct device *)dev,
|
|
|
|
(uint8_t)command, (uint8_t)family,
|
|
|
|
(w1_search_callback_t)callback,
|
|
|
|
(void *)user_data);
|
|
|
|
}
|
|
|
|
|
2024-01-24 17:35:04 +08:00
|
|
|
#include <zephyr/syscalls/w1_search_bus_mrsh.c>
|
drivers: w1 introduce 1-wire net layer api
This commit introduces a new api for the net layer of Dallas
1-wire protocol.
For single drop configurations w1_read_rom, and w1_skip_rom commands are
provided.
For multidrop configurations w1_match_rom, w1_resume_command,
w1_search_rom, and w1_search_alarm routines are provided as well.
Additionally, the reset_select routine, conditionally depending on the
bus configuration, either executes a match_rom, or a skip rom command.
A w1_write_read command simplifies the typical scenario of addressing
a device, writing a few bytes to the device and reading back the answer.
Additionally w1_crc8, and w1_crc16 are added as wrappers around the
zephyr in-tree crc8 and crc16_reflect implementations.
The former may be used to verify the validity of the rom id, while the
latter is used for integrity checking of many eeprom, and authenticator
commands.
The general search command does not support filtering on
the family code.
Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-07-04 02:00:23 +08:00
|
|
|
#endif /* CONFIG_W1_NET */
|