7#ifndef __OAL_UTIL_HCM_H__
8#define __OAL_UTIL_HCM_H__
12#include "osal_adapt.h"
15#if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
16#include <linux/etherdevice.h>
18#if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
30#ifdef CONTROLLER_CUSTOMIZATION
31#define wifi_printf_always(fmt, ...) \
32 printk(KERN_EMERG KBUILD_MODNAME "[%s:%d]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
34#define wifi_printf_always(fmt, arg...) osal_printk(fmt, ##arg)
37#ifdef _PRE_WIFI_PRINTK
38#ifdef CONTROLLER_CUSTOMIZATION
39#define wifi_printf(fmt, ...) printk(KERN_EMERG KBUILD_MODNAME "[%s:%d]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
41#define wifi_printf(fmt, arg...) osal_printk(fmt, ##arg)
44#define wifi_printf(fmt, arg...)
50#define OAL_DECLARE_PACKED __attribute__((__packed__))
51#define WIFI_ROM_TEXT __attribute__ ((section(".wifi.rom.text")))
52#define WIFI_ROM_RODATA __attribute__ ((section(".wifi.rom.rodata")))
53#define WIFI_ROM_DATA __attribute__ ((section(".wifi.rom.data")))
54#define WIFI_ROM_BSS __attribute__ ((section(".wifi.rom.bss")))
56#if defined(_PRE_WLAN_FEATURE_WS63)
57#define WIFI_TCM_TEXT __attribute__((section(".wifi.tcm.text")))
58#define WIFI_TCM_RODATA __attribute__((section(".wifi.tcm.rodata")))
59#define WIFI_HMAC_TCM_TEXT
60#define WIFI_HMAC_TCM_RODATA
61#elif defined(_PRE_WLAN_FEATURE_WS53)
63#define WIFI_TCM_RODATA __attribute__((section(".wifi.tcm.rodata")))
64#define WIFI_HMAC_TCM_TEXT __attribute__((section(".wifi.tcm.text")))
65#define WIFI_HMAC_TCM_RODATA
68#define WIFI_TCM_RODATA
69#define WIFI_HMAC_TCM_TEXT
70#define WIFI_HMAC_TCM_RODATA
74#define OAL_MAKE_WORD16(lsb, msb) ((((osal_u16)(msb) << 8) & 0xFF00) | (lsb))
75#define OAL_MAKE_WORD32(lsw, msw) ((((osal_u32)(msw) << 16) & 0xFFFF0000) | (lsw))
78#define OAL_MIN(_A, _B) (((_A) < (_B)) ? (_A) : (_B))
81#define OAL_MAX(_A, _B) (((_A) > (_B)) ? (_A) : (_B))
82#define OAL_SUB(_A, _B) (((_A) > (_B)) ? ((_A) - (_B)) : (0))
83#define OAL_ABSOLUTE_SUB(_A, _B) (((_A) > (_B)) ? ((_A) - (_B)) : ((_B) - (_A)))
85#define OAL_ARRAY_SIZE(_ast_array) (sizeof(_ast_array) / sizeof((_ast_array)[0]))
89#if defined(_PRE_BIG_CPU_ENDIAN) && defined(_PRE_CPU_ENDIAN) && (_PRE_BIG_CPU_ENDIAN == _PRE_CPU_ENDIAN)
90#define oal_ntoh_16(_val) (_val)
91#define oal_ntoh_32(_val) (_val)
92#define oal_hton_16(_val) (_val)
93#define oal_hton_32(_val) (_val)
94#define OAL_NTOH_16(_val) (_val)
95#define OAL_NTOH_32(_val) (_val)
96#define OAL_HTON_16(_val) (_val)
97#define OAL_HTON_32(_val) (_val)
100#define oal_ntoh_16(_val) oal_swap_byteorder_16(_val)
101#define oal_ntoh_32(_val) oal_swap_byteorder_32(_val)
102#define oal_hton_16(_val) oal_swap_byteorder_16(_val)
103#define oal_hton_32(_val) oal_swap_byteorder_32(_val)
104#define OAL_NTOH_16(_val) oal_swap_byteorder_16(_val)
105#define OAL_NTOH_32(_val) oal_swap_byteorder_32(_val)
106#define OAL_HTON_16(_val) oal_swap_byteorder_16(_val)
107#define OAL_HTON_32(_val) oal_swap_byteorder_32(_val)
111#define OAL_SIZEOF sizeof
113#define HCC_DATA_LEN_ALIGN 32
115#define osal_array_size(_array) (sizeof(_array) / sizeof((_array)[0]))
118#define OAL_REG_READ32(_addr) \
119 *((OAL_VOLATILE osal_u32 *)(_addr))
121#define OAL_REG_READ16(_addr) \
122 *((OAL_VOLATILE osal_u16 *)(_addr))
125#define OAL_REG_WRITE32(_addr, _val) \
126 (*((OAL_VOLATILE osal_u32 *)(_addr)) = (_val))
127#define OAL_REG_WRITE16(_addr, _val) \
128 (*((OAL_VOLATILE osal_u16 *)(_addr)) = (_val))
131#define round_mask(x, y) ((__typeof__(x))((y) - 1))
135#define round_up(x, y) ((((x) - 1) | round_mask(x, y)) + 1)
137#define OAL_ROUND_UP round_up
140#define round_down(x, y) ((x) & ~round_mask(x, y))
142#define OAL_ROUND_DOWN round_down
144#define OAL_IPV4_ADDR_LEN 6
145#define OAL_IPV6_ADDR_LEN 16
148#define OAL_GET_CORE_ID() (0)
152#define OAL_OFFSET_OF offsetof
157#define OAL_STRLEN osal_strlen
158#define OAL_MEMCMP osal_memcmp
159#define OAL_STRSTR osal_strstr
161#define todigit(c) ((c) - '0')
162#define tochar(n) ((n) + '0')
163#define oal_tolower(x) ((osal_u8)(x) | 0x20)
164#define oal_isdigit(c) ('0' <= (c) && (c) <= '9')
165#define oal_isxdigit(c) (('0' <= (c) && (c) <= '9') || ('a' <= (c) && (c) <= 'f') || ('A' <= (c) && (c) <= 'F'))
167#define oal_is_null_ptr4(ptr1, ptr2, ptr3, ptr4) \
168 ((NULL == (ptr1)) || (NULL == (ptr2)) || (NULL == (ptr3)) || (NULL == (ptr4)))
175static inline osal_u8 oal_bit_find_first_zero_one_byte(
osal_u8 byte)
180 byte =
byte & (-byte);
212 if (*
string >=
'0' && *
string <=
'9') {
213 ret = (
osal_u8)(*
string -
'0');
214 }
else if (*
string >=
'A' && *
string <=
'F') {
215 ret = (
osal_u8)(*
string -
'A' + 10);
216 }
else if (*
string >=
'a' && *
string <=
'f') {
217 ret = (
osal_u8)(*
string -
'a' + 10);
234 for (char_index = 0; char_index < 12; char_index++) {
235 while ((*pc_param ==
':') || (*pc_param ==
'-')) {
242 mac_addr[char_index / 2] = (
osal_u8)(mac_addr[char_index / 2] * 16 * (char_index % 2) +
243 oal_strtohex((
const osal_s8 *)pc_param));
260 if ((*pc_param ==
':')) {
262 if (char_index != 0) {
268 ipv6_addr[char_index >> 1] = (
osal_u8)(((ipv6_addr[char_index>>1]) << 4) * (char_index % 2) +
269 oal_strtohex(pc_param));
301 rand = rand * 1664525L + 1013904223L;
321 while ((*end !=
' ') && (*end !=
'\0')) {
330static inline void oal_random_ether_addr(
osal_u8 *addr,
osal_u8 len)
332#if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
338 gettimeofday(&tv1,
NULL);
347 addr[0] = ((
td_u32)tv2.tv_sec & 0xff) & 0xfe;
354#if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
356 random_ether_addr(addr);
398 ret = 10 * ret + (*string -
'0');
408 return ((flag == 0) ? ret : (-ret));
413static inline unsigned int simple_guess_base(
const char *cp)
429static inline unsigned long long oal_simple_strtoull(
const osal_s8 *cp,
osal_s8 **endp,
unsigned int base)
431 unsigned long long result = 0;
434 base = simple_guess_base((
const char *)cp);
437 if (base == 16 && cp[0] ==
'0' &&
oal_tolower(cp[1]) ==
'x') {
448 result = result * base + value;
460 while ((*pc_nptr) ==
' ') {
464 if (*pc_nptr ==
'-') {
470#if defined(_PRE_OS_VERSION_LITEOS) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
471#ifdef _PRE_WIFI_PRINTK
477 for (
td_s32 i = 0; i < len; i++) {
478 if (((
td_u32)i & 0x000f) == 0) {
488#if defined(_PRE_OS_VERSION_LINUX) && defined(_PRE_OS_VERSION) && (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
#define NULL
Definition common_def.h:21
#define unref_param(P)
Definition dmac_misc_type.h:33
INT32 ssize_t
Definition los_typedef.h:77
#define OAL_CONST
Definition oal_types.h:45
#define OAL_PTR_NULL
Definition oal_types_device_rom.h:30
#define OAL_IPV6_ADDR_LEN
Definition oal_util_hcm.h:144
#define oal_tolower(x)
Definition oal_util_hcm.h:162
#define oal_hton_32(_val)
Definition oal_util_hcm.h:102
size_t oal_size_t
Definition oal_util_hcm.h:154
#define oal_isxdigit(c)
Definition oal_util_hcm.h:164
#define oal_ntoh_16(_val)
Definition oal_util_hcm.h:99
#define oal_isdigit(c)
Definition oal_util_hcm.h:163
osal_ulong oal_bitops
Definition oal_util_hcm.h:149
#define wifi_printf(fmt, arg...)
Definition oal_util_hcm.h:44
ssize_t oal_ssize_t
Definition oal_util_hcm.h:153
int osal_s32
Definition osal_types.h:19
long osal_slong
Definition osal_types.h:21
unsigned char osal_u8
Definition osal_types.h:11
signed char osal_s8
Definition osal_types.h:17
char osal_char
Definition osal_types.h:16
void osal_void
Definition osal_types.h:29
unsigned int osal_u32
Definition osal_types.h:13
unsigned short osal_u16
Definition osal_types.h:12
unsigned long osal_ulong
Definition osal_types.h:15
errno_t memset_s(void *dest, size_t destMax, int c, size_t count)
char * strtok_s(char *strToken, const char *strDelimit, char **context)
#define OAL_STATIC
Definition soc_wifi_service_api.c:30
unsigned int td_u32
Definition td_type.h:38
int td_s32
Definition td_type.h:44
unsigned long long td_u64
Definition td_type.h:39