Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / adf_os_mem.h
1 /**
2  * @ingroup adf_os_public
3  * @file adf_os_mem.h
4  * This file abstracts memory operations.
5  */
6
7 #ifndef _ADF_OS_MEM_H
8 #define _ADF_OS_MEM_H
9
10 #include <adf_os_types.h>
11 #include <adf_os_mem_pvt.h>
12
13 /**
14  * @brief Allocate a memory buffer. Note this call can block.
15  *
16  * @param[in] size    buffer size
17  *
18  * @return Buffer pointer or NULL if there's not enough memory.
19  */
20 static inline void *
21 adf_os_mem_alloc(adf_os_size_t size)
22 {
23     return __adf_os_mem_alloc(size);
24 }
25
26 /**
27  * @brief Free malloc'ed buffer
28  *
29  * @param[in] buf     buffer pointer allocated by @ref adf_os_mem_alloc
30  */
31 static inline void
32 adf_os_mem_free(void *buf)
33 {
34     __adf_os_mem_free(buf);
35 }
36
37 /**
38  * @brief Move a memory buffer. Overlapping regions are not allowed.
39  *
40  * @param[in] dst     destination address
41  * @param[in] src     source address
42  * @param[in] size    buffer size
43  */
44 static inline void
45 adf_os_mem_copy(void *dst, void *src, adf_os_size_t size)
46 {
47     __adf_os_mem_copy(dst, src, size);
48 }
49
50 /**
51  * @brief Does a non-destructive copy of memory buffer
52  *
53  * @param[in] dst     destination address
54  * @param[in] src     source address
55  * @param[in] size    buffer size
56  */
57 static inline void 
58 adf_os_mem_move(void *dst, void *src, adf_os_size_t size)
59 {
60         __adf_os_mem_move(dst,src,size);
61 }
62
63
64 /**
65  * @brief Fill a memory buffer
66  * 
67  * @param[in] buf   buffer to be filled
68  * @param[in] b     byte to fill
69  * @param[in] size  buffer size
70  */
71 static inline void
72 adf_os_mem_set(void *buf, a_uint8_t b, adf_os_size_t size)
73 {
74     __adf_os_mem_set(buf, b, size);
75 }
76
77
78 /**
79  * @brief Zero a memory buffer
80  * 
81  * @param[in] buf   buffer to be zeroed
82  * @param[in] size  buffer size
83  */
84 static inline void
85 adf_os_mem_zero(void *buf, adf_os_size_t size)
86 {
87     __adf_os_mem_zero(buf, size);
88 }
89
90
91 /**
92  * @brief Compare two memory buffers
93  *
94  * @param[in] buf1  first buffer
95  * @param[in] buf2  second buffer
96  * @param[in] size  buffer size
97  *
98  * @retval    0     equal
99  * @retval    1     not equal
100  */
101 static inline int
102 adf_os_mem_cmp(void *buf1, void *buf2, adf_os_size_t size)
103 {
104     return __adf_os_mem_cmp(buf1, buf2, size);
105 }
106
107 #endif