Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / wlan / ah_osdep.c
1 #include <stdarg.h>
2 #include <adf_os_types.h>
3 #include <adf_os_dma.h>
4 #include <adf_os_timer.h>
5 #include <adf_os_lock.h>
6 #include <adf_os_io.h>
7 #include <adf_os_mem.h>
8 #include <adf_os_module.h>
9 #include <adf_os_pci.h>
10 #include <adf_os_util.h>
11 #include <adf_os_stdtypes.h>
12 #include <adf_os_defer.h>
13 #include <adf_os_atomic.h>
14 #include <adf_nbuf.h>
15 #include <adf_net.h>
16 #include <adf_net_types.h>
17
18 #include "ah.h"
19 #include<ah_internal.h>
20 #include "ah_osdep.h"
21
22 a_uint32_t __ahdecl
23 ath_hal_getuptime(struct ath_hal *ah)
24 {
25         return adf_os_getuptime();
26 }
27
28 struct ath_hal *
29 _ath_hal_attach_tgt(a_uint32_t devid, HAL_SOFTC sc,
30                     adf_os_device_t dev,HAL_BUS_HANDLE sh, a_uint32_t flags, void* s)
31 {
32         HAL_STATUS status;
33         struct ath_hal *ah = ath_hal_attach_tgt(devid,sc,dev,sh, flags, &status);
34         adf_os_print(" ath_hal = %p \n",ah);
35         *(HAL_STATUS *)s = status;
36         return ah;
37 }
38
39 void
40 ath_hal_detach(struct ath_hal *ah)
41 {
42         (*ah->ah_detach)(ah);
43 }
44
45 extern void *global_hdl;
46
47 /*
48  * Memory-mapped device register read/write.  These are here
49  * as routines when debugging support is enabled and/or when
50  * explicitly configured to use function calls.  The latter is
51  * for architectures that might need to do something before
52  * referencing memory (e.g. remap an i/o window).
53  *
54  * NB: see the comments in ah_osdep.h about byte-swapping register
55  *     reads and writes to understand what's going on below.
56  */
57 void __ahdecl
58 ath_hal_reg_write_target(struct ath_hal *ah, a_uint32_t reg, a_uint32_t val)
59
60         adf_os_reg_write32(ah->ah_dev, reg, val); 
61 }
62
63 a_uint32_t __ahdecl
64 ath_hal_reg_read_target(struct ath_hal *ah, a_uint32_t reg)
65 {
66         a_uint32_t val;
67
68         val = adf_os_reg_read32(ah->ah_dev, reg);
69
70         return val;
71 }
72
73 /*
74  * Delay n microseconds.
75  */
76 void __ahdecl
77 ath_hal_delay(a_int32_t n)
78 {
79         adf_os_udelay(n);
80 }
81
82 /*
83  * Allocate/free memory.
84  */
85 void * __ahdecl
86 ath_hal_malloc(adf_os_size_t size)
87 {
88         void *p;
89
90         p = adf_os_mem_alloc(size);
91         if (p)
92                 adf_os_mem_zero(p, size);
93
94         return p;
95 }
96
97 void __ahdecl
98 ath_hal_free(void* p)
99 {
100         adf_os_mem_free(p);
101 }
102
103 void __ahdecl
104 ath_hal_memzero(void *dst, adf_os_size_t n)
105 {
106         adf_os_mem_set(dst, 0, n);
107 }
108
109 void * __ahdecl
110 ath_hal_memcpy(void *dst, void *src, adf_os_size_t n)
111 {
112         adf_os_mem_copy(dst, src, n);
113         return 0;
114 }
115
116 /*
117  * Print/log message support.
118  */
119 void __ahdecl
120 ath_hal_vprintf(struct ath_hal *ah, const char* fmt, va_list ap)
121 {
122 }
123
124 enum {
125         DEV_ATH     = 9,            /* XXX must match driver */
126 };
127
128 adf_os_module_dep(hal, adf_net);
129 adf_os_module_dep(hal, hal);
130 adf_os_virt_module_name(hal);