mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-01 01:55:51 +00:00
The various macros to do checks in system call handlers all implictly would generate a kernel oops if a check failed. This is undesirable for a few reasons: * System call handlers that acquire resources in the handler have no good recourse for cleanup if a check fails. * In some cases we may want to propagate a return value back to the caller instead of just killing the calling thread, even though the base API doesn't do these checks. These macros now all return a value, if nonzero is returned the check failed. K_OOPS() now wraps these calls to generate a kernel oops. At the moment, the policy for all APIs has not changed. They still all oops upon a failed check/ The macros now use the Z_ notation for private APIs. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
/*
|
|
* Copyright (c) 2017 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <syscall_handler.h>
|
|
#include <flash.h>
|
|
|
|
Z_SYSCALL_HANDLER(flash_read, dev, offset, data, len)
|
|
{
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, read));
|
|
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(data, len));
|
|
return _impl_flash_read((struct device *)dev, offset, (void *)data,
|
|
len);
|
|
}
|
|
|
|
Z_SYSCALL_HANDLER(flash_write, dev, offset, data, len)
|
|
{
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write));
|
|
Z_OOPS(Z_SYSCALL_MEMORY_READ(data, len));
|
|
return _impl_flash_write((struct device *)dev, offset,
|
|
(const void *)data, len);
|
|
}
|
|
|
|
Z_SYSCALL_HANDLER(flash_write_protection_set, dev, enable)
|
|
{
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write_protection));
|
|
return _impl_flash_write_protection_set((struct device *)dev, enable);
|
|
}
|
|
|
|
Z_SYSCALL_HANDLER1_SIMPLE(flash_get_write_block_size, K_OBJ_DRIVER_FLASH,
|
|
struct device *);
|
|
|
|
#ifdef CONFIG_FLASH_PAGE_LAYOUT
|
|
Z_SYSCALL_HANDLER(flash_get_page_info_by_offs, dev, offs, info)
|
|
{
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
|
|
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info)));
|
|
return _impl_flash_get_page_info_by_offs((struct device *)dev, offs,
|
|
(struct flash_pages_info *)info);
|
|
}
|
|
|
|
Z_SYSCALL_HANDLER(flash_get_page_info_by_idx, dev, idx, info)
|
|
{
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
|
|
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info)));
|
|
return _impl_flash_get_page_info_by_idx((struct device *)dev, idx,
|
|
(struct flash_pages_info *)info);
|
|
}
|
|
|
|
Z_SYSCALL_HANDLER(flash_get_page_count, dev)
|
|
{
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
|
|
return _impl_flash_get_page_count((struct device *)dev);
|
|
}
|
|
#endif
|