1/*
2 * Copyright (c) 2014 ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#ifndef LIB_DMA_CLIENT_DEVICE_H
11#define LIB_DMA_CLIENT_DEVICE_H
12
13#include <dma/dma_device.h>
14
15/// forward declaration of the device
16struct dma_client_device;
17struct dma_client_channel;
18
19/// describes the information stored in the DMA device information structure
20typedef enum dma_client_info_type {
21    DMA_CLIENT_INFO_TYPE_INVALID,
22    DMA_CLIENT_INFO_TYPE_IREF,
23    DMA_CLIENT_INFO_TYPE_NAME,
24    DMA_CLIENT_INFO_TYPE_ADDR
25} dma_client_dev_info_type_t;
26
27/**
28 * supplies information about the DMA driver this client device connects to
29 */
30struct dma_client_info
31{
32    dma_client_dev_info_type_t type;
33    dma_dev_type_t device_type;
34    union {
35        char *name;
36        iref_t iref;
37        struct  {
38            lpaddr_t low;
39            lpaddr_t high;
40        } addr;
41    } args;
42};
43
44
45#define DMA_CLIENT_DEVICE_CONNECTIONS 1
46
47/**
48 * \brief pointer type conversion
49 */
50static inline struct dma_client_device *dma_device_to_client(struct dma_device *dev)
51{
52    return (struct dma_client_device *)dev;
53}
54
55
56/*
57 * ----------------------------------------------------------------------------
58 * device initialization / termination
59 * ----------------------------------------------------------------------------
60 */
61
62/**
63 * \brief initializes a DMA client device with the giving capability
64 *
65 * \param info stores information how to find the device driver service
66 * \param dev  returns a pointer to the device structure
67 *
68 * \returns SYS_ERR_OK on success
69 *          errval on error
70 */
71errval_t dma_client_device_init(struct dma_client_info *info,
72                                struct dma_client_device **dev);
73
74/**
75 * \brief terminates the device operation and frees up the allocated resources
76 *
77 * \param dev IOAT DMA device to shutdown
78 *
79 * \returns SYS_ERR_OK on success
80 *          errval on error
81 */
82errval_t dma_client_device_shutdown(struct dma_client_device *dev);
83
84/*
85 * ----------------------------------------------------------------------------
86 * Device Status Queries
87 * ----------------------------------------------------------------------------
88 */
89
90/**
91 * \brief gets the device type of the connected device
92 *
93 * \param dev DMA client device
94 *
95 * \returns DMA device type
96 */
97dma_dev_type_t dma_client_get_device_type(struct dma_client_device *dev);
98
99/**
100 * \brief returns the supported range of a connection
101 *
102 * \param conn      DMA client connection
103 * \param mem_low   minimum physical address supported
104 * \param mem_high  maximum physical address supported
105 */
106void dma_client_device_get_mem_range(struct dma_client_device *dev,
107                                     lpaddr_t *mem_low,
108                                     lpaddr_t *mem_high);
109
110
111
112#endif  /* LIB_DMA_CLIENT_DEVICE_H */
113