Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / adf / adf_os_dma.c
1 #include <adf_os_dma_pvt.h>
2 #include "Magpie_api.h"
3 #include "cmnos_api.h"
4
5 #if 0
6 void __adf_os_dma_load(void *arg, bus_dma_segment_t *dseg, int nseg, int error)
7 {
8         if (error)
9                 return;
10
11         adf_os_assert(nseg == 1);
12
13         ((bus_dma_segment_t *)arg)[0].ds_addr = dseg[0].ds_addr;
14         ((bus_dma_segment_t *)arg)[0].ds_len  = dseg[0].ds_len; 
15 }
16 #endif
17
18 /**
19  * @brief Allocates a DMA region, uses the tag elem to store the
20  *        tag value which constant for all the mappings done
21  *        through this API.
22  * 
23  * @param osdev
24  * @param size
25  * @param coherent
26  * @param dmap
27  * 
28  * @return void* (Virtual address)
29  */
30 inline void*
31 __adf_os_dmamem_alloc(__adf_os_device_t osdev, adf_os_size_t size, 
32                       a_bool_t coherent, __adf_os_dma_map_t *dmap)
33 {    
34     (*dmap) = A_ALLOCRAM(sizeof(struct __adf_dma_map));
35     
36         if((*dmap) == NULL){
37                 goto fail_malloc;
38         }
39             
40     (*dmap)->ds_addr = A_ALLOCRAM(size);
41     (*dmap)->ds_len = size;
42     
43     return (*dmap)->ds_addr;
44     
45 fail_malloc: 
46     return NULL;            
47 }