Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / adf_os_dma.h
1 /**
2  * @ingroup adf_os_public
3  * @file adf_os_dma.h
4  * This file abstracts DMA operations.
5  */
6
7 #ifndef _ADF_OS_DMA_H
8 #define _ADF_OS_DMA_H
9
10 #include <adf_os_types.h>
11 #include <adf_os_dma_pvt.h>
12
13 /*
14  * @brief a dma address representation of a platform
15  */
16
17 /**
18  * @brief Allocate a DMA buffer and map it to local bus address space
19  *
20  * @param[in]  osdev     platform device instance
21  * @param[in]  size      DMA buffer size
22  * @param[in]  coherent  0 => cached.
23  * @param[out] dmap      opaque coherent memory handle
24  * 
25  * @return     returns the virtual address of the memory
26  */
27 static inline void *
28 adf_os_dmamem_alloc(adf_os_device_t     osdev, 
29                     adf_os_size_t       size, 
30                     a_bool_t            coherent, 
31                     adf_os_dma_map_t   *dmap)
32 {
33     return __adf_os_dmamem_alloc(osdev, size, coherent, dmap);
34 }
35
36 /**
37  * @brief Free a previously mapped DMA buffer
38  * 
39  * @param[in] osdev     platform device instance
40  * @param[in] size      DMA buffer size
41  * @param[in] coherent  0 => cached.
42  * @param[in] vaddr     virtual address of DMA buffer
43  * @param[in] dmap      memory handle
44  */
45 static inline void
46 adf_os_dmamem_free(adf_os_device_t    osdev,
47                    adf_os_size_t      size,
48                    a_bool_t           coherent,
49                    void              *vaddr,
50                    adf_os_dma_map_t   dmap)
51 {
52     __adf_os_dmamem_free(osdev, size, coherent, vaddr, dmap);
53 }
54
55 /**
56  * @brief given a dmamem map, returns the (bus) address
57  *
58  * @param[in] dmap      memory handle
59  *
60  * @return the (bus) address
61  */
62 static inline adf_os_dma_addr_t
63 adf_os_dmamem_map2addr(adf_os_dma_map_t dmap)
64 {
65     return(__adf_os_dmamem_map2addr(dmap));
66 }
67
68 /**
69  * @brief Flush and invalidate cache for a given dmamem map
70  *
71  * @param[in] osdev     platform device instance
72  * @param[in] dmap              mem handle
73  * @param[in] op        op code for sync type, (see @ref adf_os_types.h)
74  */
75 static inline void
76 adf_os_dmamem_cache_sync(adf_os_device_t      osdev, 
77                          adf_os_dma_map_t     dmap, 
78                          adf_os_cache_sync_t  op)
79 {
80     __adf_os_dmamem_cache_sync(osdev, dmap, op);
81 }
82
83 /**
84  * @brief Get the cpu cache line size
85  * 
86  * @return The CPU cache line size in bytes.
87  */
88 static inline adf_os_size_t
89 adf_os_cache_line_size(void)
90 {
91     return __adf_os_cache_line_size();
92 }
93
94 #endif