2017-10-26 03:36:51 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <syscall_handler.h>
|
|
|
|
#include <flash.h>
|
|
|
|
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_SYSCALL_HANDLER(flash_read, dev, offset, data, len)
|
2017-10-26 03:36:51 +08:00
|
|
|
{
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, read));
|
|
|
|
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(data, len));
|
2019-03-09 05:19:05 +08:00
|
|
|
return z_impl_flash_read((struct device *)dev, offset, (void *)data,
|
2017-10-26 03:36:51 +08:00
|
|
|
len);
|
|
|
|
}
|
|
|
|
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_SYSCALL_HANDLER(flash_write, dev, offset, data, len)
|
2017-10-26 03:36:51 +08:00
|
|
|
{
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write));
|
|
|
|
Z_OOPS(Z_SYSCALL_MEMORY_READ(data, len));
|
2019-03-09 05:19:05 +08:00
|
|
|
return z_impl_flash_write((struct device *)dev, offset,
|
2017-10-26 03:36:51 +08:00
|
|
|
(const void *)data, len);
|
|
|
|
}
|
|
|
|
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_SYSCALL_HANDLER(flash_write_protection_set, dev, enable)
|
2017-10-26 03:36:51 +08:00
|
|
|
{
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write_protection));
|
2019-03-09 05:19:05 +08:00
|
|
|
return z_impl_flash_write_protection_set((struct device *)dev, enable);
|
2017-10-26 03:36:51 +08:00
|
|
|
}
|
|
|
|
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_SYSCALL_HANDLER1_SIMPLE(flash_get_write_block_size, K_OBJ_DRIVER_FLASH,
|
|
|
|
struct device *);
|
2017-10-26 03:36:51 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_FLASH_PAGE_LAYOUT
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_SYSCALL_HANDLER(flash_get_page_info_by_offs, dev, offs, info)
|
2017-10-26 03:36:51 +08:00
|
|
|
{
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
|
|
|
|
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info)));
|
2019-03-09 05:19:05 +08:00
|
|
|
return z_impl_flash_get_page_info_by_offs((struct device *)dev, offs,
|
2017-10-26 03:36:51 +08:00
|
|
|
(struct flash_pages_info *)info);
|
|
|
|
}
|
|
|
|
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_SYSCALL_HANDLER(flash_get_page_info_by_idx, dev, idx, info)
|
2017-10-26 03:36:51 +08:00
|
|
|
{
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
|
|
|
|
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info)));
|
2019-03-09 05:19:05 +08:00
|
|
|
return z_impl_flash_get_page_info_by_idx((struct device *)dev, idx,
|
2017-10-26 03:36:51 +08:00
|
|
|
(struct flash_pages_info *)info);
|
|
|
|
}
|
|
|
|
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_SYSCALL_HANDLER(flash_get_page_count, dev)
|
2018-04-05 04:50:32 +08:00
|
|
|
{
|
2018-05-05 06:57:57 +08:00
|
|
|
Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout));
|
2019-03-09 05:19:05 +08:00
|
|
|
return z_impl_flash_get_page_count((struct device *)dev);
|
2018-04-05 04:50:32 +08:00
|
|
|
}
|
2017-10-26 03:36:51 +08:00
|
|
|
#endif
|