Skip to content

Commit

Permalink
kernel: Port remaining syscalls to new API
Browse files Browse the repository at this point in the history
These calls are not accessible in CI test, nor do they get built on
common platforms (in at least one case I found a typo which proved the
code was truly unused).  These changes are blind, so live in a
separate commit.  But the nature of the port is mechanical, all other
syscalls in the system work fine, and any errors should be easily
corrected.

Signed-off-by: Andy Ross <[email protected]>
  • Loading branch information
Andy Ross authored and nashif committed Sep 12, 2019
1 parent 346cce3 commit 075c94f
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 67 deletions.
13 changes: 10 additions & 3 deletions drivers/adc/adc_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include <syscall_handler.h>
#include <kernel.h>

Z_SYSCALL_HANDLER(adc_channel_setup, dev, user_channel_cfg)
static inline int z_vrfy_adc_channel_setup(struct device *dev,
const struct adc_channel_cfg *user_channel_cfg)
{
struct adc_channel_cfg channel_cfg;

Expand All @@ -19,6 +20,7 @@ Z_SYSCALL_HANDLER(adc_channel_setup, dev, user_channel_cfg)

return z_impl_adc_channel_setup((struct device *)dev, &channel_cfg);
}
#include <syscalls/adc_channel_setup_mrsh.c>

static bool copy_sequence(struct adc_sequence *dst,
struct adc_sequence_options *options,
Expand All @@ -45,8 +47,9 @@ static bool copy_sequence(struct adc_sequence *dst,
return true;
}

static inline int z_vrfy_adc_read(struct device *dev,
const struct adc_sequence *user_sequence)

Z_SYSCALL_HANDLER(adc_read, dev, user_sequence)
{
struct adc_sequence sequence;
struct adc_sequence_options options;
Expand All @@ -62,9 +65,12 @@ Z_SYSCALL_HANDLER(adc_read, dev, user_sequence)

return z_impl_adc_read((struct device *)dev, &sequence);
}
#include <syscalls/adc_read_mrsh.c>

#ifdef CONFIG_ADC_ASYNC
Z_SYSCALL_HANDLER(adc_read_async, dev, user_sequence, async)
static inline int z_vrfy_adc_read_async(struct device *dev,
const struct adc_sequence *user_sequence,
struct k_poll_signal *async)
{
struct adc_sequence sequence;
struct adc_sequence_options options;
Expand All @@ -82,4 +88,5 @@ Z_SYSCALL_HANDLER(adc_read_async, dev, user_sequence, async)
return z_impl_adc_read_async((struct device *)dev, &sequence,
(struct k_poll_signal *)async);
}
#include <syscalls/adc_read_async_mrsh.c>
#endif /* CONFIG_ADC_ASYNC */
22 changes: 15 additions & 7 deletions drivers/can/can_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@
#include <syscall_handler.h>
#include <drivers/can.h>

Z_SYSCALL_HANDLER(can_configure, dev, mode, bitrate) {
static inline int z_vrfy_can_configure(struct device *dev, enum can_mode mode,
u32_t bitrate) {

Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, configure));

return z_impl_can_configure((struct device *)dev, (enum can_mode)mode,
(u32_t)bitrate);
}
#include <syscalls/can_configure_mrsh.c>

Z_SYSCALL_HANDLER(can_send, dev, msg, timeout, callback_isr, callback_arg) {
static inline int z_vrfy_can_send(struct device *dev,
const struct zcan_frame *msg,
s32_t timeout,
can_tx_callback_t callback_isr,
void *callback_arg) {

Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, send));

Expand All @@ -33,9 +39,11 @@ Z_SYSCALL_HANDLER(can_send, dev, msg, timeout, callback_isr, callback_arg) {
(s32_t)timeout, (can_tx_callback_t) callback_isr,
(void *)callback_arg);
}
#include <syscalls/can_send_mrsh.c>

Z_SYSCALL_HANDLER(can_attach_msgq, dev, msgq, filter) {

static inline int z_vrfy_can_attach_msgq(struct device *dev,
struct k_msgq *msgq,
const struct zcan_filter *filter) {
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));

Z_OOPS(Z_SYSCALL_MEMORY_READ((struct zcan_filter *)filter,
Expand All @@ -46,12 +54,12 @@ Z_SYSCALL_HANDLER(can_attach_msgq, dev, msgq, filter) {
(struct k_msgq *)msgq,
(const struct zcan_filter *) filter);
}
#include <syscalls/can_attach_msgq_mrsh.c>

Z_SYSCALL_HANDLER(can_detach, dev, filter_id) {
static inline void z_vrfy_can_detach(struct device *dev, int filter_id)

Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, detach));

z_impl_can_detach((struct device *)dev, (int)filter_id);

return 0;
}
#include <syscalls/can_detach_mrsh.c>
17 changes: 14 additions & 3 deletions drivers/counter/counter_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* instance and return an integral value
*/
#define COUNTER_HANDLER(name) \
Z_SYSCALL_HANDLER(counter_ ## name, dev) \
static inline int z_vrfy_counter_##name(struct devince *dev) \
{ \
Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, name)); \
return z_impl_counter_ ## name((struct device *)dev); \
Expand All @@ -24,15 +24,26 @@ COUNTER_HANDLER(start)
COUNTER_HANDLER(get_top_value)
COUNTER_HANDLER(get_max_relative_alarm)

Z_SYSCALL_HANDLER(counter_get_guard_period, dev, flags)
#include <syscalls/counter_get_pending_int_mrsh.c>
#include <syscalls/counter_read_mrsh.c>
#include <syscalls/counter_stop_mrsh.c>
#include <syscalls/counter_start_mrsh.c>
#include <syscalls/counter_get_top_value_mrsh.c>
#include <syscalls/counter_get_max_relative_alarm_mrsh.c>

static inline u32_t z_vrfy_counter_get_guard_period(struct device *dev,
u32_t flags)
{
Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, get_guard_period));
return z_impl_counter_get_guard_period((struct device *)dev, flags);
}
#include <syscalls/counter_get_guard_period_mrsh.c>

Z_SYSCALL_HANDLER(counter_set_guard_period, dev, ticks, flags)
static inline int z_vrfy_counter_set_guard_period(struct device *dev,
u32_t ticks, u32_t flags)
{
Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, set_guard_period));
return z_impl_counter_set_guard_period((struct device *)dev, ticks,
flags);
}
#include <syscalls/counter_set_guard_period_mrsh.c>
6 changes: 4 additions & 2 deletions drivers/dma/dma_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
* the validity of the channel ID and returning -errno if it's bogus
*/

Z_SYSCALL_HANDLER(dma_start, dev, channel)
static inline int z_vrfy_dma_start(struct device *dev, u32_t channel)
{
Z_OOPS(Z_SYSCALL_DRIVER_DMA(dev, start));
return z_impl_dma_start((struct device *)dev, channel);
}
#include <syscalls/dma_start_mrsh.c>

Z_SYSCALL_HANDLER(dma_stop, dev, channel)
static inline int z_vrfy_dma_stop(struct device *dev, u32_t channel)
{
Z_OOPS(Z_SYSCALL_DRIVER_DMA(dev, stop));
return z_impl_dma_stop((struct device *)dev, channel);
}
#include <syscalls/dma_stop_mrsh.c>

5 changes: 4 additions & 1 deletion drivers/entropy/entropy_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
#include <drivers/entropy.h>
#include <syscall_handler.h>

Z_SYSCALL_HANDLER(entropy_get_entropy, dev, buffer, len)
static inline int z_vrfy_entropy_get_entropy(struct device *dev,
u8_t *buffer,
u16_t len)
{
Z_OOPS(Z_SYSCALL_DRIVER_ENTROPY(dev, get_entropy));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buffer, len));
return z_impl_entropy_get_entropy((struct device *)dev, (u8_t *)buffer,
len);
}
#include <syscalls/entropy_get_entropy_mrsh.c>
34 changes: 26 additions & 8 deletions drivers/flash/flash_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,69 @@
#include <syscall_handler.h>
#include <drivers/flash.h>

Z_SYSCALL_HANDLER(flash_read, dev, offset, data, len)
static inline int z_vrfy_flash_read(struct device *dev, off_t offset,
void *data, size_t len)
{
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, read));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(data, len));
return z_impl_flash_read((struct device *)dev, offset, (void *)data,
len);
}
#include <syscalls/flash_read_mrsh.c>

Z_SYSCALL_HANDLER(flash_write, dev, offset, data, len)
static inline int z_vrfy_flash_write(struct device *dev, off_t offset,
const void *data, size_t len)
{
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write));
Z_OOPS(Z_SYSCALL_MEMORY_READ(data, len));
return z_impl_flash_write((struct device *)dev, offset,
(const void *)data, len);
}
#include <syscalls/flash_write_mrsh.c>

Z_SYSCALL_HANDLER(flash_write_protection_set, dev, enable)
static inline int z_vrfy_flash_write_protection_set(struct device *dev,
bool enable)
{
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write_protection));
return z_impl_flash_write_protection_set((struct device *)dev, enable);
}
#include <syscalls/flash_write_protection_set_mrsh.c>

Z_SYSCALL_HANDLER1_SIMPLE(flash_get_write_block_size, K_OBJ_DRIVER_FLASH,
struct device *);
static inline size_t z_vrfy_flash_get_write_block_size(struct device *dev)
{
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_FLASH));
return z_impl_flash_get_write_block_size(dev);
}
#include <syscalls/flash_get_write_block_size_mrsh.c>

#ifdef CONFIG_FLASH_PAGE_LAYOUT
Z_SYSCALL_HANDLER(flash_get_page_info_by_offs, dev, offs, info)
static inline int z_vrfy_flash_get_page_info_by_offs(struct device *dev,
off_t offs,
struct flash_pages_info *info)
{
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info)));
return z_impl_flash_get_page_info_by_offs((struct device *)dev, offs,
(struct flash_pages_info *)info);
}
#include <syscalls/flash_get_page_info_by_offs_mrsh.c>

Z_SYSCALL_HANDLER(flash_get_page_info_by_idx, dev, idx, info)
static inline int z_vrfy_flash_get_page_info_by_idx(struct device *dev,
u32_t idx,
struct flash_pages_info *info)
{
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info)));
return z_impl_flash_get_page_info_by_idx((struct device *)dev, idx,
(struct flash_pages_info *)info);
}
#include <syscalls/flash_get_page_info_by_idx_mrsh.c>

Z_SYSCALL_HANDLER(flash_get_page_count, dev)
static inline size_t z_vrfy_flash_get_page_count(struct device *dev);
{
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
return z_impl_flash_get_page_count((struct device *)dev);
}
#include <syscalls/flash_get_page_count_mrsh.c>

#endif
4 changes: 2 additions & 2 deletions drivers/hwinfo/hwinfo_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <syscall_handler.h>
#include <drivers/hwinfo.h>

Z_SYSCALL_HANDLER(hwinfo_get_device_id, buffer, length) {

ssize_t z_vrfy_hwinfo_get_device_id(u8_t *buffer, size_t length) {
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buffer, length));

return z_impl_hwinfo_get_device_id((u8_t *)buffer, (size_t)length);
}
#include <syscalls/hwinfo_get_device_id_mrsh.c>
16 changes: 12 additions & 4 deletions drivers/i2s/i2s_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include <drivers/i2s.h>


Z_SYSCALL_HANDLER(i2s_configure, dev, dir, cfg_ptr)
static inline int z_vrfy_i2s_configure(struct device *dev, enum i2s_dir dir,
struct i2s_config *cfg_ptr)
{
struct i2s_config config;
int ret = -EINVAL;
Expand Down Expand Up @@ -39,8 +40,10 @@ Z_SYSCALL_HANDLER(i2s_configure, dev, dir, cfg_ptr)
out:
return ret;
}
#include <syscalls/i2s_configure_mrsh.c>

Z_SYSCALL_HANDLER(i2s_buf_read, dev, buf, size)
static inline int z_vrfy_i2s_buf_read(struct device *dev,
void *buf, size_t *size);
{
void *mem_block;
size_t data_size;
Expand Down Expand Up @@ -70,8 +73,10 @@ Z_SYSCALL_HANDLER(i2s_buf_read, dev, buf, size)

return ret;
}
#include <syscalls/i2s_buf_read_mrsh.c>

Z_SYSCALL_HANDLER(i2s_buf_write, dev, buf, size)
static inline int z_vrfy_i2s_buf_write(struct device *dev,
void *buf, size_t size)
{
int ret;
struct i2s_config *tx_cfg;
Expand Down Expand Up @@ -105,10 +110,13 @@ Z_SYSCALL_HANDLER(i2s_buf_write, dev, buf, size)

return ret;
}
#include <syscalls/i2s_buf_write_mrsh.c>

Z_SYSCALL_HANDLER(i2s_trigger, dev, dir, cmd)
static inline int z_vrfy_i2s_trigger(struct device *dev, enum i2s_dir dir,
enum i2s_trigger_cmd cmd)
{
Z_OOPS(Z_SYSCALL_DRIVER_I2S(dev, trigger));

return z_impl_i2s_trigger((struct device *)dev, dir, cmd);
}
#include <syscalls/i2s_trigger_mrsh.c>
15 changes: 10 additions & 5 deletions drivers/ipm/ipm_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,33 @@
#include <syscall_handler.h>
#include <drivers/ipm.h>

Z_SYSCALL_HANDLER(ipm_send, dev, wait, id, data, size)
static inline int z_vrfy_ipm_send(struct device *dev, int wait, u32_t id,
const void *data, int size)
{
Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, send));
Z_OOPS(Z_SYSCALL_MEMORY_READ(data, size));
return z_impl_ipm_send((struct device *)dev, wait, id,
(const void *)data, size);
}
#include <syscalls/ipm_send_mrsh.c>

Z_SYSCALL_HANDLER(ipm_max_data_size_get, dev)
static inline int z_vrfy_ipm_max_data_size_get(struct device *dev)
{
Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, max_data_size_get));
return z_impl_max_data_size_get((struct device *)dev);
}
#include <syscalls/ipm_max_data_size_get_mrsh.c>

Z_SYSCALL_HANDLER(ipm_max_id_val_get, dev)
static inline u32_t z_vrfy_ipm_max_id_val_get(struct device *dev)
{
Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, max_id_val_get));
return z_impl_max_id_val_get((struct device *)dev);
return z_impl_ipm_max_id_val_get((struct device *)dev);
}
#include <syscalls/ipm_max_id_val_get_mrsh.c>

Z_SYSCALL_HANDLER(ipm_set_enabled, dev, enable)
static inline int z_vrfy_ipm_set_enabled(struct device *dev, int enable)
{
Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, set_enabled));
return z_impl_ipm_set_enabled((struct device *)dev, enable);
}
#include <syscalls/ipm_set_enabled_mrsh.c>
14 changes: 10 additions & 4 deletions drivers/led/led_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,33 @@
#include <syscall_handler.h>
#include <drivers/led.h>

Z_SYSCALL_HANDLER(led_blink, dev, led, delay_on, delay_off)
static inline int z_vrfy_led_blink(struct device *dev, u32_t led,
u32_t delay_on, u32_t delay_off)
{
Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, blink));
return z_impl_led_blink((struct device *)dev, led, delay_on,
delay_off);
}
#include <syscalls/led_blink_mrsh.c>

Z_SYSCALL_HANDLER(led_set_brightness, dev, led, value)
static inline int z_vrfy_led_set_brightness(struct device *dev, u32_t led,
u8_t value)
{
Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, set_brightness));
return z_impl_led_set_brightness((struct device *)dev, led, value);
}
#include <syscalls/led_set_brightness_mrsh.c>

Z_SYSCALL_HANDLER(led_on, dev, led)
static inline int z_vrfy_led_on(struct device *dev, u32_t led)
{
Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, on));
return z_impl_led_on((struct device *)dev, led);
}
#include <syscalls/led_on_mrsh.c>

Z_SYSCALL_HANDLER(led_off, dev, led)
static inline int z_vrfy_led_off(struct device *dev, u32_t led)
{
Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, off));
return z_impl_led_off((struct device *)dev, led);
}
#include <syscalls/led_off_mrsh.c>
Loading

0 comments on commit 075c94f

Please sign in to comment.