dma: add system calls for dma_start/dma_stop
As per current policy of requiring supervisor mode to register callbacks, dma_config() is omitted. A note added about checking the channel ID for start/stop, current implementations already do this but best make it explicitly documented. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
980c0cf4ac
commit
ce6c8f347b
6 changed files with 43 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
zephyr_sources_ifdef(CONFIG_DMA_QMSI dma_qmsi.c)
|
||||
zephyr_sources_ifdef(CONFIG_DMA_SAM_XDMAC dma_sam_xdmac.c)
|
||||
zephyr_sources_ifdef(CONFIG_DMA_STM32F4X dma_stm32f4x.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_USERSPACE dma_handlers.c)
|
||||
|
|
25
drivers/dma/dma_handlers.c
Normal file
25
drivers/dma/dma_handlers.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <dma.h>
|
||||
#include <syscall_handler.h>
|
||||
|
||||
/* Both of these APIs are assuming that the drive implementations are checking
|
||||
* the validity of the channel ID and returning -errno if it's bogus
|
||||
*/
|
||||
|
||||
_SYSCALL_HANDLER(dma_start, dev, channel)
|
||||
{
|
||||
_SYSCALL_OBJ(dev, K_OBJ_DRIVER_DMA);
|
||||
return _impl_dma_start((struct device *)dev, channel);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER(dma_stop, dev, channel)
|
||||
{
|
||||
_SYSCALL_OBJ(dev, K_OBJ_DRIVER_DMA);
|
||||
return _impl_dma_stop((struct device *)dev, channel);
|
||||
}
|
||||
|
|
@ -190,6 +190,9 @@ static inline int dma_config(struct device *dev, u32_t channel,
|
|||
* @brief Enables DMA channel and starts the transfer, the channel must be
|
||||
* configured beforehand.
|
||||
*
|
||||
* Implementations must check the validity of the channel ID passed in and
|
||||
* return -EINVAL if it is invalid.
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
* @param channel Numeric identification of the channel where the transfer will
|
||||
* be processed
|
||||
|
@ -197,7 +200,9 @@ static inline int dma_config(struct device *dev, u32_t channel,
|
|||
* @retval 0 if successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
static inline int dma_start(struct device *dev, u32_t channel)
|
||||
__syscall int dma_start(struct device *dev, u32_t channel);
|
||||
|
||||
static inline int _impl_dma_start(struct device *dev, u32_t channel)
|
||||
{
|
||||
const struct dma_driver_api *api = dev->driver_api;
|
||||
|
||||
|
@ -207,6 +212,9 @@ static inline int dma_start(struct device *dev, u32_t channel)
|
|||
/**
|
||||
* @brief Stops the DMA transfer and disables the channel.
|
||||
*
|
||||
* Implementations must check the validity of the channel ID passed in and
|
||||
* return -EINVAL if it is invalid.
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
* @param channel Numeric identification of the channel where the transfer was
|
||||
* being processed
|
||||
|
@ -214,7 +222,9 @@ static inline int dma_start(struct device *dev, u32_t channel)
|
|||
* @retval 0 if successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
static inline int dma_stop(struct device *dev, u32_t channel)
|
||||
__syscall int dma_stop(struct device *dev, u32_t channel);
|
||||
|
||||
static inline int _impl_dma_stop(struct device *dev, u32_t channel)
|
||||
{
|
||||
const struct dma_driver_api *api = dev->driver_api;
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ enum k_objects {
|
|||
K_OBJ_DRIVER_AIO_CMP,
|
||||
K_OBJ_DRIVER_COUNTER,
|
||||
K_OBJ_DRIVER_CRYPTO,
|
||||
K_OBJ_DRIVER_DMA,
|
||||
K_OBJ_DRIVER_FLASH,
|
||||
K_OBJ_DRIVER_GPIO,
|
||||
K_OBJ_DRIVER_I2C,
|
||||
|
|
|
@ -53,6 +53,8 @@ const char *otype_to_str(enum k_objects otype)
|
|||
return "counter driver";
|
||||
case K_OBJ_DRIVER_CRYPTO:
|
||||
return "crypto driver";
|
||||
case K_OBJ_DRIVER_DMA:
|
||||
return "dma driver";
|
||||
case K_OBJ_DRIVER_FLASH:
|
||||
return "flash driver";
|
||||
case K_OBJ_DRIVER_GPIO:
|
||||
|
|
|
@ -29,6 +29,7 @@ subsystems = [
|
|||
"aio_cmp_driver_api",
|
||||
"counter_driver_api",
|
||||
"crypto_driver_api",
|
||||
"dma_driver_api",
|
||||
"flash_driver_api",
|
||||
"gpio_driver_api",
|
||||
"i2c_driver_api",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue