A59项目初版工程 1.电压+光感adc采样优化 2.串口逻辑优化
This commit is contained in:
2385
lib/wlan/RTL8189FTV/api/wifi/wifi_conf.c
Normal file
2385
lib/wlan/RTL8189FTV/api/wifi/wifi_conf.c
Normal file
File diff suppressed because it is too large
Load Diff
1050
lib/wlan/RTL8189FTV/api/wifi/wifi_conf.h
Normal file
1050
lib/wlan/RTL8189FTV/api/wifi/wifi_conf.h
Normal file
File diff suppressed because it is too large
Load Diff
285
lib/wlan/RTL8189FTV/api/wifi/wifi_ind.c
Normal file
285
lib/wlan/RTL8189FTV/api/wifi/wifi_ind.c
Normal file
@ -0,0 +1,285 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
#include <stdint.h>
|
||||
#include "wifi/wifi_ind.h"
|
||||
#include "wifi/wifi_conf.h"
|
||||
#include "osdep_service.h"
|
||||
#include "basic_types.h"
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
#define WIFI_INDICATE_MSG 0
|
||||
#define WIFI_MANAGER_STACKSIZE 1300
|
||||
#define WIFI_MANAGER_PRIORITY (0) //Actual priority is 4 since calling rtw_create_task
|
||||
#define WIFI_MANAGER_Q_SZ 8
|
||||
|
||||
#define WIFI_EVENT_MAX_ROW 3
|
||||
/******************************************************
|
||||
* Globals
|
||||
******************************************************/
|
||||
|
||||
static event_list_elem_t event_callback_list[WIFI_EVENT_MAX][WIFI_EVENT_MAX_ROW];
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
static rtw_worker_thread_t wifi_worker_thread;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
static rtw_result_t rtw_send_event_to_worker(int event_cmd, char *buf, int buf_len, int flags)
|
||||
{
|
||||
rtw_event_message_t message;
|
||||
int i;
|
||||
rtw_result_t ret = RTW_SUCCESS;
|
||||
char *local_buf = NULL;
|
||||
|
||||
if(event_cmd >= WIFI_EVENT_MAX)
|
||||
return RTW_BADARG;
|
||||
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmd][i].handler == NULL)
|
||||
continue;
|
||||
|
||||
message.function = (event_handler_t)event_callback_list[event_cmd][i].handler;
|
||||
message.buf_len = buf_len;
|
||||
if(buf_len){
|
||||
local_buf = (char*)pvPortMalloc(buf_len);
|
||||
if(local_buf == NULL)
|
||||
return RTW_NOMEM;
|
||||
memcpy(local_buf, buf, buf_len);
|
||||
//DBG_INFO("!!!!!Allocate %p(%d) for evcmd %d\n", local_buf, buf_len, event_cmd);
|
||||
}
|
||||
message.buf = local_buf;
|
||||
message.flags = flags;
|
||||
message.user_data = event_callback_list[event_cmd][i].handler_user_data;
|
||||
|
||||
ret = rtw_push_to_xqueue(&wifi_worker_thread.event_queue, &message, 0);
|
||||
if(ret != RTW_SUCCESS){
|
||||
if(local_buf){
|
||||
DBG_INFO("rtw_send_event_to_worker: enqueue cmd %d failed and free %p(%d)\n", event_cmd, local_buf, buf_len);
|
||||
vPortFree(local_buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
static rtw_result_t rtw_indicate_event_handle(int event_cmd, char *buf, int buf_len, int flags)
|
||||
{
|
||||
rtw_event_handler_t handle = NULL;
|
||||
int i;
|
||||
|
||||
if(event_cmd >= WIFI_EVENT_MAX)
|
||||
return (rtw_result_t)RTW_BADARG;
|
||||
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
handle = event_callback_list[event_cmd][i].handler;
|
||||
if(handle == NULL)
|
||||
continue;
|
||||
handle(buf, buf_len, flags, event_callback_list[event_cmd][i].handler_user_data);
|
||||
}
|
||||
|
||||
return RTW_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
void wifi_indication( rtw_event_indicate_t event, char *buf, int buf_len, int flags)
|
||||
{
|
||||
//
|
||||
// If upper layer application triggers additional operations on receiving of wext_wlan_indicate,
|
||||
// please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() )
|
||||
// , and tries not to share the same stack with wlan driver if remaining stack space is
|
||||
// not available for the following operations.
|
||||
// ex: using semaphore to notice another thread.
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
switch(event)
|
||||
{
|
||||
case WIFI_EVENT_DISCONNECT:
|
||||
DBG_INFO("%s():Disconnection indication received", __FUNCTION__);
|
||||
break;
|
||||
case WIFI_EVENT_CONNECT:
|
||||
// For WPA/WPA2 mode, indication of connection does not mean data can be
|
||||
// correctly transmitted or received. Data can be correctly transmitted or
|
||||
// received only when 4-way handshake is done.
|
||||
// Please check WIFI_EVENT_FOURWAY_HANDSHAKE_DONE event
|
||||
// Sample: return mac address
|
||||
if(buf != NULL && buf_len == 6)
|
||||
{
|
||||
DBG_INFO("%s():Connect indication received: %02x:%02x:%02x:%02x:%02x:%02x", __FUNCTION__,
|
||||
buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_FOURWAY_HANDSHAKE_DONE:
|
||||
if(buf != NULL)
|
||||
{
|
||||
if(buf_len == strlen(IW_EXT_STR_FOURWAY_DONE))
|
||||
DBG_INFO("%s():%s", __FUNCTION__, buf);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_RESULT_REPORT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_RESULT_REPORT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_DONE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_RECONNECTION_FAIL:
|
||||
if(buf != NULL){
|
||||
if(buf_len == strlen(IW_EXT_STR_RECONNECTION_FAIL))
|
||||
DBG_INFO("%s", buf);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_NO_NETWORK:
|
||||
DBG_INFO("%s(): WIFI_EVENT_NO_NETWORK\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_RX_MGNT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_RX_MGNT\n", __func__);
|
||||
break;
|
||||
#if CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_SEND_ACTION_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SEND_ACTION_DONE\n", __func__);
|
||||
break;
|
||||
#endif //CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_STA_ASSOC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_ASSOC\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISASSOC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_DISASSOC\n", __func__);
|
||||
break;
|
||||
#if CONFIG_WPS
|
||||
case WIFI_EVENT_STA_WPS_START:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_WPS_START\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_WPS_FINISH:
|
||||
DBG_INFO("%s(): WIFI_EVENT_WPS_FINISH\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_EAPOL_RECVD:
|
||||
DBG_INFO("%s(): WIFI_EVENT_EAPOL_RECVD\n", __func__);
|
||||
break;
|
||||
#endif
|
||||
case WIFI_EVENT_BEACON_AFTER_DHCP:
|
||||
DBG_INFO("%s(): WIFI_EVENT_BEACON_AFTER_DHCP\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_IP_CHANGED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_IP_CHANNGED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ICV_ERROR:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ICV_ERROR\n", __func__);
|
||||
case WIFI_EVENT_CHALLENGE_FAIL:
|
||||
DBG_INFO("%s(): WIFI_EVENT_CHALLENGE_FAIL\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_START:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_START\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_FAILED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_FAILED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_AUTHENTICATION:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTHENTICATION\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_AUTH_REJECT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTH_REJECT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_DEAUTH:
|
||||
DBG_INFO("%s(): WIFI_EVENT_DEAUTH\n", __func__);
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_AUTH_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTH_TIMEOUT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOCIATING:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOCIATING\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOCIATED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOCIATED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOC_REJECT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOC_REJECT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOC_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOC_TIMEOUT\n", __func__);
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_HANDSHAKE_FAILED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_HANDSHAKE_FAILED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_4WAY_HANDSHAKE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_4WAY_HANDSHAKE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_GROUP_HANDSHAKE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_GROUP_HANDSHAKE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_GROUP_HANDSHAKE_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_GROUP_HANDSHAKE_DONE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_CONN_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_CONN_TIMEOUT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_LEAVE_BUSY_TRAFFIC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_LEAVE_BUSY_TRAFFIC\n", __func__);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_send_event_to_worker(event, buf, buf_len, flags);
|
||||
#else
|
||||
rtw_indicate_event_handle(event, buf, buf_len, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wifi_reg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
if(event_cmds < WIFI_EVENT_MAX){
|
||||
for(i=0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmds][i].handler == NULL){
|
||||
for(j=0; j<WIFI_EVENT_MAX_ROW; j++){
|
||||
if(event_callback_list[event_cmds][j].handler == handler_func){
|
||||
return;
|
||||
}
|
||||
}
|
||||
event_callback_list[event_cmds][i].handler = handler_func;
|
||||
event_callback_list[event_cmds][i].handler_user_data = handler_user_data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_unreg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func)
|
||||
{
|
||||
int i;
|
||||
if(event_cmds < WIFI_EVENT_MAX){
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmds][i].handler == handler_func){
|
||||
event_callback_list[event_cmds][i].handler = NULL;
|
||||
event_callback_list[event_cmds][i].handler_user_data = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_event_callback_list(){
|
||||
memset(event_callback_list, 0, sizeof(event_callback_list));
|
||||
}
|
||||
|
||||
int wifi_manager_init()
|
||||
{
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_create_worker_thread(&wifi_worker_thread,
|
||||
WIFI_MANAGER_PRIORITY,
|
||||
WIFI_MANAGER_STACKSIZE,
|
||||
WIFI_MANAGER_Q_SZ);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtw_wifi_manager_deinit()
|
||||
{
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_delete_worker_thread(&wifi_worker_thread);
|
||||
#endif
|
||||
}
|
||||
|
104
lib/wlan/RTL8189FTV/api/wifi/wifi_ind.h
Normal file
104
lib/wlan/RTL8189FTV/api/wifi/wifi_ind.h
Normal file
@ -0,0 +1,104 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
* @file wifi_ind.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the functions related to event handler mechanism.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_INDICATE_H
|
||||
#define _WIFI_INDICATE_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "wifi_conf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*rtw_event_handler_t)(char *buf, int buf_len, int flags, void* handler_user_data );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// rtw_event_indicate_t event_cmd;
|
||||
rtw_event_handler_t handler;
|
||||
void* handler_user_data;
|
||||
} event_list_elem_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the event callback list.
|
||||
* @warning Please make sure this function has been invoked before
|
||||
* using the event handler related mechanism.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void init_event_callback_list(void);
|
||||
|
||||
/**
|
||||
* @brief Wlan driver indicate event to upper layer through wifi_indication.
|
||||
* @param[in] event: An event reported from driver to upper layer application. Please refer to rtw_event_indicate_t enum.
|
||||
* @param[in] buf: If it is not NUL, buf is a pointer to the buffer for message string.
|
||||
* @param[in] buf_len: The length of the buffer.
|
||||
* @param[in] flags: Indicate some extra information, sometimes it is 0.
|
||||
* @retval None
|
||||
* @note If upper layer application triggers additional operations on receiving of wext_wlan_indicate,
|
||||
* please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() ),
|
||||
* and tries not to share the same stack with wlan driver if remaining stack space is not available
|
||||
* for the following operations.
|
||||
* ex: using semaphore to notice another thread instead of handing event directly in wifi_indication().
|
||||
*/
|
||||
extern void wifi_indication( rtw_event_indicate_t event, char *buf, int buf_len, int flags);
|
||||
|
||||
/**
|
||||
* @brief Register the event listener.
|
||||
* @param[in] event_cmds : The event command number indicated.
|
||||
* @param[in] handler_func : the callback function which will
|
||||
* receive and process the event.
|
||||
* @param[in] handler_user_data : user specific data that will be
|
||||
* passed directly to the callback function.
|
||||
* @return RTW_SUCCESS : if successfully registers the event.
|
||||
* @return RTW_ERROR : if an error occurred.
|
||||
* @note Set the same event_cmds with empty handler_func will
|
||||
* unregister the event_cmds.
|
||||
*/
|
||||
extern void wifi_reg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data);
|
||||
|
||||
/**
|
||||
* @brief Un-register the event listener.
|
||||
* @param[in] event_cmds : The event command number indicated.
|
||||
* @param[in] handler_func : the callback function which will
|
||||
* receive and process the event.
|
||||
*
|
||||
* @return RTW_SUCCESS : if successfully un-registers the event .
|
||||
* @return RTW_ERROR : if an error occurred.
|
||||
*/
|
||||
extern void wifi_unreg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif //_WIFI_INDICATE_H
|
||||
|
445
lib/wlan/RTL8189FTV/api/wifi/wifi_promisc.c
Normal file
445
lib/wlan/RTL8189FTV/api/wifi/wifi_promisc.c
Normal file
@ -0,0 +1,445 @@
|
||||
#include <osdep_service.h>
|
||||
#include "wifi/wifi_conf.h"
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_WLAN
|
||||
#include <basic_types.h>
|
||||
|
||||
extern void _promisc_deinit(void *padapter);
|
||||
extern int _promisc_recv_func(void *padapter, void *rframe);
|
||||
extern int _promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used);
|
||||
extern unsigned char _is_promisc_enabled(void);
|
||||
extern int _promisc_get_fixed_channel(void * fixed_bssid, u8 *ssid, int * ssid_length);
|
||||
extern void _promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac);
|
||||
// Add extra interfaces to make release sdk able to determine promisc API linking
|
||||
void promisc_deinit(void *padapter)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
_promisc_deinit(padapter);
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_recv_func(void *padapter, void *rframe)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_recv_func(padapter, rframe);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_recv_lens_func(void *padapter, u8 *payload, u8 plen)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
return _promisc_recv_lens_func(padapter, payload, plen);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_filter_with_len(u16 len)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
return _promisc_filter_with_len(len);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_set(enabled, callback, len_used);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char is_promisc_enabled(void)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _is_promisc_enabled();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_get_fixed_channel(void *fixed_bssid, u8 *ssid, int *ssid_length)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_get_fixed_channel(fixed_bssid, ssid, ssid_length);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
_promisc_filter_by_ap_and_phone_mac(enable, ap_mac, phone_mac);
|
||||
#endif
|
||||
}
|
||||
|
||||
// End of Add extra interfaces
|
||||
|
||||
struct eth_frame {
|
||||
struct eth_frame *prev;
|
||||
struct eth_frame *next;
|
||||
unsigned char da[6];
|
||||
unsigned char sa[6];
|
||||
unsigned int len;
|
||||
unsigned char type;
|
||||
signed char rssi;
|
||||
};
|
||||
|
||||
struct eth_buffer {
|
||||
struct eth_frame *head;
|
||||
struct eth_frame *tail;
|
||||
};
|
||||
|
||||
static struct eth_buffer eth_buffer;
|
||||
|
||||
#if CONFIG_PROMISC
|
||||
#define MAX_PACKET_FILTER_INFO 5
|
||||
#define FILTER_ID_INIT_VALUE 10
|
||||
rtw_packet_filter_info_t paff_array[MAX_PACKET_FILTER_INFO]={0, 0, 0, 0, 0};
|
||||
static u8 packet_filter_enable_num = 0;
|
||||
|
||||
void promisc_init_packet_filter()
|
||||
{
|
||||
int i = 0;
|
||||
for(i=0; i<MAX_PACKET_FILTER_INFO; i++){
|
||||
paff_array[i].filter_id = FILTER_ID_INIT_VALUE;
|
||||
paff_array[i].enable = 0;
|
||||
paff_array[i].patt.mask_size = 0;
|
||||
paff_array[i].rule = RTW_POSITIVE_MATCHING;
|
||||
paff_array[i].patt.mask = NULL;
|
||||
paff_array[i].patt.pattern = NULL;
|
||||
}
|
||||
packet_filter_enable_num = 0;
|
||||
}
|
||||
|
||||
int promisc_add_packet_filter(u8 filter_id, rtw_packet_filter_pattern_t *patt, rtw_packet_filter_rule_t rule)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == FILTER_ID_INIT_VALUE){
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].filter_id = filter_id;
|
||||
|
||||
paff_array[i].patt.offset= patt->offset;
|
||||
paff_array[i].patt.mask_size = patt->mask_size;
|
||||
paff_array[i].patt.mask = rtw_malloc(patt->mask_size);
|
||||
memcpy(paff_array[i].patt.mask, patt->mask, patt->mask_size);
|
||||
paff_array[i].patt.pattern= rtw_malloc(patt->mask_size);
|
||||
memcpy(paff_array[i].patt.pattern, patt->pattern, patt->mask_size);
|
||||
|
||||
paff_array[i].rule = rule;
|
||||
paff_array[i].enable = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_enable_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].enable = 1;
|
||||
packet_filter_enable_num++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_disable_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].enable = 0;
|
||||
packet_filter_enable_num--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_remove_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].filter_id = FILTER_ID_INIT_VALUE;
|
||||
paff_array[i].enable = 0;
|
||||
paff_array[i].patt.mask_size = 0;
|
||||
paff_array[i].rule = 0;
|
||||
if(paff_array[i].patt.mask){
|
||||
rtw_free(paff_array[i].patt.mask);
|
||||
paff_array[i].patt.mask = NULL;
|
||||
}
|
||||
|
||||
if(paff_array[i].patt.pattern){
|
||||
rtw_free(paff_array[i].patt.pattern);
|
||||
paff_array[i].patt.pattern = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make callback simple to prevent latency to wlan rx when promiscuous mode */
|
||||
static void promisc_callback(unsigned char *buf, unsigned int len, void* userdata)
|
||||
{
|
||||
struct eth_frame *frame = (struct eth_frame *) rtw_malloc(sizeof(struct eth_frame));
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
if(frame) {
|
||||
frame->prev = NULL;
|
||||
frame->next = NULL;
|
||||
memcpy(frame->da, buf, 6);
|
||||
memcpy(frame->sa, buf+6, 6);
|
||||
frame->len = len;
|
||||
frame->rssi = ((ieee80211_frame_info_t *)userdata)->rssi;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
if(eth_buffer.tail) {
|
||||
eth_buffer.tail->next = frame;
|
||||
frame->prev = eth_buffer.tail;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = frame;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
|
||||
struct eth_frame* retrieve_frame(void)
|
||||
{
|
||||
struct eth_frame *frame = NULL;
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
if(eth_buffer.head) {
|
||||
frame = eth_buffer.head;
|
||||
|
||||
if(eth_buffer.head->next) {
|
||||
eth_buffer.head = eth_buffer.head->next;
|
||||
eth_buffer.head->prev = NULL;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
static void promisc_test(int duration, unsigned char len_used)
|
||||
{
|
||||
int ch;
|
||||
unsigned int start_time;
|
||||
struct eth_frame *frame;
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
|
||||
wifi_enter_promisc_mode();
|
||||
wifi_set_promisc(RTW_PROMISC_ENABLE, promisc_callback, len_used);
|
||||
|
||||
for(ch = 1; ch <= 13; ch ++) {
|
||||
if(wifi_set_channel(ch) == 0)
|
||||
DBG_INFO("Switch to channel(%d)", ch);
|
||||
|
||||
start_time = rtw_get_current_time();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = rtw_get_current_time();
|
||||
|
||||
if(rtw_systime_to_ms(current_time - start_time) < duration) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
DBG_INFO("DA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->da[i]);
|
||||
printk(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->sa[i]);
|
||||
printk(", len=%d", frame->len);
|
||||
printk(", RSSI=%d", frame->rssi);
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
else
|
||||
rtw_mdelay_os(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
|
||||
static void promisc_callback_all(unsigned char *buf, unsigned int len, void* userdata)
|
||||
{
|
||||
struct eth_frame *frame = (struct eth_frame *) rtw_malloc(sizeof(struct eth_frame));
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
if(frame) {
|
||||
frame->prev = NULL;
|
||||
frame->next = NULL;
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
if(((ieee80211_frame_info_t *)userdata)->type == RTW_RX_UNSUPPORT){
|
||||
//NOTICE: buf structure now is rtw_rx_info_t.
|
||||
frame->type = 0xFF;
|
||||
memset(frame->da, 0, 6);
|
||||
memset(frame->sa, 0, 6);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
memcpy(frame->da, buf+4, 6);
|
||||
memcpy(frame->sa, buf+10, 6);
|
||||
frame->type = *buf;
|
||||
}
|
||||
|
||||
frame->len = len;
|
||||
/*
|
||||
* type is the first byte of Frame Control Field of 802.11 frame
|
||||
* If the from/to ds information is needed, type could be reused as follows:
|
||||
* frame->type = ((((ieee80211_frame_info_t *)userdata)->i_fc & 0x0100) == 0x0100) ? 2 : 1;
|
||||
* 1: from ds; 2: to ds
|
||||
*/
|
||||
|
||||
frame->rssi = ((ieee80211_frame_info_t *)userdata)->rssi;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
if(eth_buffer.tail) {
|
||||
eth_buffer.tail->next = frame;
|
||||
frame->prev = eth_buffer.tail;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = frame;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
static void promisc_test_all(int duration, unsigned char len_used)
|
||||
{
|
||||
int ch;
|
||||
unsigned int start_time;
|
||||
struct eth_frame *frame;
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
|
||||
wifi_enter_promisc_mode();
|
||||
wifi_set_promisc(RTW_PROMISC_ENABLE_2, promisc_callback_all, len_used);
|
||||
|
||||
for(ch = 1; ch <= 13; ch ++) {
|
||||
if(wifi_set_channel(ch) == 0)
|
||||
DBG_INFO("Switch to channel(%d)", ch);
|
||||
|
||||
start_time = rtw_get_current_time();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = rtw_get_current_time();
|
||||
|
||||
if(rtw_systime_to_ms(current_time - start_time) < duration) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
DBG_INFO("TYPE: 0x%x, ", frame->type);
|
||||
printk("DA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->da[i]);
|
||||
printk(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->sa[i]);
|
||||
printk(", len=%d", frame->len);
|
||||
printk(", RSSI=%d", frame->rssi);
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
else
|
||||
rtw_mdelay_os(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
|
||||
void cmd_promisc(int argc, char **argv)
|
||||
{
|
||||
int duration;
|
||||
#if CONFIG_PROMISC
|
||||
wifi_init_packet_filter();
|
||||
#endif
|
||||
if((argc == 2) && ((duration = atoi(argv[1])) > 0))
|
||||
//promisc_test(duration, 0);
|
||||
promisc_test_all(duration, 0);
|
||||
else if((argc == 3) && ((duration = atoi(argv[1])) > 0) && (strcmp(argv[2], "with_len") == 0))
|
||||
promisc_test(duration, 1);
|
||||
else
|
||||
DBG_INFO("Usage: %s DURATION_SECONDS [with_len]", argv[0]);
|
||||
}
|
||||
#endif //#if CONFIG_WLAN
|
1836
lib/wlan/RTL8189FTV/api/wifi/wifi_util.c
Normal file
1836
lib/wlan/RTL8189FTV/api/wifi/wifi_util.c
Normal file
File diff suppressed because it is too large
Load Diff
121
lib/wlan/RTL8189FTV/api/wifi/wifi_util.h
Normal file
121
lib/wlan/RTL8189FTV/api/wifi/wifi_util.h
Normal file
@ -0,0 +1,121 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef _UTIL_H
|
||||
#define _UTIL_H
|
||||
|
||||
#include <wireless.h>
|
||||
#include <wlan_intf.h>
|
||||
#include <wifi_constants.h>
|
||||
#include "wifi_structures.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int wext_get_ssid(const char *ifname, __u8 *ssid);
|
||||
int wext_set_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||
int wext_set_bssid(const char *ifname, const __u8 *bssid);
|
||||
int wext_get_bssid(const char *ifname, __u8 *bssid);
|
||||
int wext_set_auth_param(const char *ifname, __u16 idx, __u32 value);
|
||||
int wext_set_mfp_support(const char *ifname, __u8 value);
|
||||
int wext_set_key_ext(const char *ifname, __u16 alg, const __u8 *addr, int key_idx, int set_tx, const __u8 *seq, __u16 seq_len, __u8 *key, __u16 key_len);
|
||||
int wext_get_enc_ext(const char *ifname, __u16 *alg, __u8 *key_idx, __u8 *passphrase);
|
||||
int wext_set_passphrase(const char *ifname, const __u8 *passphrase, __u16 passphrase_len);
|
||||
int wext_get_passphrase(const char *ifname, __u8 *passphrase);
|
||||
int wext_set_mode(const char *ifname, int mode);
|
||||
int wext_get_mode(const char *ifname, int *mode);
|
||||
int wext_set_ap_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||
int wext_set_country(const char *ifname, rtw_country_code_t country_code);
|
||||
int wext_get_rssi(const char *ifname, int *rssi);
|
||||
int wext_set_channel(const char *ifname, __u8 ch);
|
||||
int wext_get_channel(const char *ifname, __u8 *ch);
|
||||
#if CONFIG_MULTICAST
|
||||
int wext_register_multicast_address(const char *ifname, rtw_mac_t *mac);
|
||||
int wext_unregister_multicast_address(const char *ifname, rtw_mac_t *mac);
|
||||
int wext_enable_multicast_address_filter(const char *ifname);
|
||||
int wext_disable_multicast_address_filter(const char *ifname);
|
||||
#endif
|
||||
int wext_set_scan(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_get_scan(const char *ifname, char *buf, __u16 buf_len);
|
||||
int wext_set_mac_address(const char *ifname, char * mac);
|
||||
int wext_get_mac_address(const char *ifname, char * mac);
|
||||
int wext_enable_powersave(const char *ifname, __u8 lps_mode, __u8 ips_mode);
|
||||
int wext_disable_powersave(const char *ifname);
|
||||
int wext_set_tdma_param(const char *ifname, __u8 slot_period, __u8 rfon_period_len_1, __u8 rfon_period_len_2, __u8 rfon_period_len_3);
|
||||
int wext_set_lps_dtim(const char *ifname, __u8 lps_dtim);
|
||||
int wext_get_lps_dtim(const char *ifname, __u8 *lps_dtim);
|
||||
int wext_set_lps_level(const char *ifname, __u8 lps_level);
|
||||
int wext_get_tx_power(const char *ifname, __u8 *poweridx);
|
||||
int wext_set_txpower(const char *ifname, int poweridx);
|
||||
int wext_get_associated_client_list(const char *ifname, void * client_list_buffer, __u16 buffer_length);
|
||||
int wext_get_ap_info(const char *ifname, rtw_bss_info_t * ap_info, rtw_security_t* security);
|
||||
int wext_mp_command(const char *ifname, char *cmd, int show_msg);
|
||||
int wext_private_command(const char *ifname, char *cmd, int show_msg);
|
||||
int wext_private_command_with_retval(const char *ifname, char *cmd, char *ret_buf, int ret_len);
|
||||
void wext_wlan_indicate(unsigned int cmd, union iwreq_data *wrqu, char *extra);
|
||||
int wext_set_pscan_channel(const char *ifname, __u8 *ch, __u8 *pscan_config, __u8 length);
|
||||
int wext_set_autoreconnect(const char *ifname, __u8 mode, __u8 retry_times, __u16 timeout);
|
||||
int wext_get_autoreconnect(const char *ifname, __u8 *mode);
|
||||
int wext_set_adaptivity(rtw_adaptivity_mode_t adaptivity_mode);
|
||||
int wext_set_adaptivity_th_l2h_ini(__u8 l2h_threshold);
|
||||
int wext_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned char channel_num);
|
||||
int wext_set_sta_num(unsigned char ap_sta_num);
|
||||
int wext_del_station(const char *ifname, unsigned char* hwaddr);
|
||||
int wext_init_mac_filter(void);
|
||||
int wext_deinit_mac_filter(void);
|
||||
int wext_add_mac_filter(unsigned char* hwaddr);
|
||||
int wext_del_mac_filter(unsigned char* hwaddr);
|
||||
void wext_set_indicate_mgnt(int enable);
|
||||
#ifdef CONFIG_SW_MAILBOX_EN
|
||||
int wext_mailbox_to_wifi(const char *ifname, char *buf, __u16 buf_len);
|
||||
#endif
|
||||
#if CONFIG_CUSTOM_IE
|
||||
int wext_add_custom_ie(const char *ifname, void * cus_ie, int ie_num);
|
||||
int wext_update_custom_ie(const char *ifname, void * cus_ie, int ie_index);
|
||||
int wext_del_custom_ie(const char *ifname);
|
||||
#endif
|
||||
|
||||
#define wext_handshake_done rltk_wlan_handshake_done
|
||||
|
||||
int wext_send_mgnt(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_send_eapol(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_set_gen_ie(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_get_drv_ability(const char *ifname, __u32 *ability);
|
||||
int wext_enable_forwarding(const char *ifname);
|
||||
int wext_disable_forwarding(const char *ifname);
|
||||
int wext_set_ch_deauth(const char *ifname, __u8 enable);
|
||||
|
||||
#if CONFIG_WOWLAN
|
||||
int wext_wowlan_ctrl(const char *ifname, int enable);
|
||||
int wext_wowlan_set_pattern(const char *ifname, wowlan_pattern_t pattern);
|
||||
int wext_wowlan_unicast_wake_ctrl(const char *ifname, unsigned char enable);
|
||||
#endif
|
||||
int wext_enable_rawdata_recv(const char *ifname, void *fun);
|
||||
int wext_disable_rawdata_recv(const char *ifname);
|
||||
int wext_send_rawdata(const char *ifname,const unsigned char* frame_buf, unsigned int frame_len);
|
||||
int wext_enable_adaptivity(const char *ifname);
|
||||
int wext_disable_adaptivity(const char *ifname);
|
||||
int wext_get_real_time_data_rate_info(const char *ifname, unsigned char *prate, unsigned char *pshort_gi, unsigned char *pbandwidth);
|
||||
int wext_get_snr(const char *ifname, unsigned char *ofdm_snr, unsigned char *ht_snr);
|
||||
int wext_set_retry_limit(const char *ifname, unsigned char retry_limit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UTIL_H */
|
||||
|
1521
lib/wlan/RTL8189FTV/api/wifi_interactive_mode.c
Normal file
1521
lib/wlan/RTL8189FTV/api/wifi_interactive_mode.c
Normal file
File diff suppressed because it is too large
Load Diff
1026
lib/wlan/RTL8189FTV/include/autoconf.h
Normal file
1026
lib/wlan/RTL8189FTV/include/autoconf.h
Normal file
File diff suppressed because it is too large
Load Diff
459
lib/wlan/RTL8189FTV/include/basic_types.h
Normal file
459
lib/wlan/RTL8189FTV/include/basic_types.h
Normal file
@ -0,0 +1,459 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __BASIC_TYPES_H__
|
||||
#define __BASIC_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#undef _FAIL
|
||||
#define _FAIL 0
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
#define _TRUE TRUE
|
||||
#define _FALSE FALSE
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define __weak __attribute__((weak))
|
||||
#define likely(x) __builtin_expect ((x), 1)
|
||||
#define unlikely(x) __builtin_expect ((x), 0)
|
||||
#endif
|
||||
|
||||
typedef unsigned int uint;
|
||||
typedef signed int sint;
|
||||
|
||||
#ifdef __ICCARM__
|
||||
typedef signed long long __int64_t;
|
||||
typedef unsigned long long __uint64_t;
|
||||
#endif
|
||||
|
||||
#define s8 int8_t
|
||||
#define u8 uint8_t
|
||||
#define s16 int16_t
|
||||
#define u16 uint16_t
|
||||
#define s32 int32_t
|
||||
#define u32 uint32_t
|
||||
#define s64 int64_t
|
||||
#define u64 uint64_t
|
||||
|
||||
#ifndef BOOL
|
||||
typedef unsigned char BOOL;
|
||||
#endif
|
||||
#ifndef bool
|
||||
typedef unsigned char bool;
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
#ifndef bool
|
||||
typedef unsigned char bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define UCHAR uint8_t
|
||||
#define USHORT uint16_t
|
||||
#define UINT uint32_t
|
||||
#define ULONG uint32_t
|
||||
|
||||
//typedef struct { volatile int counter; } atomic_t;
|
||||
|
||||
typedef enum _RTK_STATUS_ {
|
||||
_EXIT_SUCCESS = 0,
|
||||
_EXIT_FAILURE = 1
|
||||
}RTK_STATUS, *PRTK_STATUS;
|
||||
|
||||
#define IN
|
||||
#define OUT
|
||||
#define VOID void
|
||||
#define INOUT
|
||||
#define NDIS_OID uint
|
||||
#define NDIS_STATUS uint
|
||||
|
||||
#ifndef PVOID
|
||||
typedef void * PVOID;
|
||||
#endif
|
||||
|
||||
typedef u32 dma_addr_t;
|
||||
|
||||
typedef void (*proc_t)(void*);
|
||||
|
||||
typedef unsigned int __kernel_size_t;
|
||||
typedef int __kernel_ssize_t;
|
||||
|
||||
typedef __kernel_size_t SIZE_T;
|
||||
typedef __kernel_ssize_t SSIZE_T;
|
||||
#define FIELD_OFFSET(s,field) ((SSIZE_T)&((s*)(0))->field)
|
||||
|
||||
#define MEM_ALIGNMENT_OFFSET (sizeof (SIZE_T))
|
||||
#define MEM_ALIGNMENT_PADDING (sizeof(SIZE_T) - 1)
|
||||
|
||||
#define SIZE_PTR SIZE_T
|
||||
#define SSIZE_PTR SSIZE_T
|
||||
|
||||
#ifndef ON
|
||||
#define ON 1
|
||||
#endif
|
||||
|
||||
#ifndef OFF
|
||||
#define OFF 0
|
||||
#endif
|
||||
|
||||
#define BIT0 0x0001
|
||||
#define BIT1 0x0002
|
||||
#define BIT2 0x0004
|
||||
#define BIT3 0x0008
|
||||
#define BIT4 0x0010
|
||||
#define BIT5 0x0020
|
||||
#define BIT6 0x0040
|
||||
#define BIT7 0x0080
|
||||
#define BIT8 0x0100
|
||||
#define BIT9 0x0200
|
||||
#define BIT10 0x0400
|
||||
#define BIT11 0x0800
|
||||
#define BIT12 0x1000
|
||||
#define BIT13 0x2000
|
||||
#define BIT14 0x4000
|
||||
#define BIT15 0x8000
|
||||
#define BIT16 0x00010000
|
||||
#define BIT17 0x00020000
|
||||
#define BIT18 0x00040000
|
||||
#define BIT19 0x00080000
|
||||
#define BIT20 0x00100000
|
||||
#define BIT21 0x00200000
|
||||
#define BIT22 0x00400000
|
||||
#define BIT23 0x00800000
|
||||
#define BIT24 0x01000000
|
||||
#define BIT25 0x02000000
|
||||
#define BIT26 0x04000000
|
||||
#define BIT27 0x08000000
|
||||
#define BIT28 0x10000000
|
||||
#define BIT29 0x20000000
|
||||
#define BIT30 0x40000000
|
||||
#define BIT31 0x80000000
|
||||
|
||||
#define BIT_(__n) (1<<(__n))
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(__n) (1<<(__n))
|
||||
#endif
|
||||
|
||||
#if defined (__ICCARM__)
|
||||
#define STRINGIFY(s) #s
|
||||
#define SECTION(_name) _Pragma( STRINGIFY(location=_name))
|
||||
#define ALIGNMTO(_bound) _Pragma( STRINGIFY(data_alignment=_bound))
|
||||
#define _PACKED_ __packed
|
||||
#define _LONG_CALL_
|
||||
#define _LONG_CALL_ROM_
|
||||
#define _WEAK __weak
|
||||
#else
|
||||
#define SECTION(_name) __attribute__ ((__section__(_name)))
|
||||
#define ALIGNMTO(_bound) __attribute__ ((aligned (_bound)))
|
||||
#define _PACKED_ __attribute__ ((packed))
|
||||
#ifdef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
#define _LONG_CALL_
|
||||
#define _LONG_CALL_ROM_ __attribute__ ((long_call))
|
||||
#ifdef E_CUT_ROM_DOMAIN
|
||||
#undef _LONG_CALL_ROM_
|
||||
#define _LONG_CALL_ROM_
|
||||
#endif
|
||||
#else
|
||||
#define _LONG_CALL_ __attribute__ ((long_call))
|
||||
#define _LONG_CALL_ROM_ _LONG_CALL_
|
||||
#endif
|
||||
#define _WEAK __attribute__ ((weak))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//port from fw by thomas
|
||||
// TODO: Belows are Sync from SD7-Driver. It is necessary to check correctness
|
||||
|
||||
#define SWAP32(x) ((u32)( \
|
||||
(((u32)(x) & (u32)0x000000ff) << 24) | \
|
||||
(((u32)(x) & (u32)0x0000ff00) << 8) | \
|
||||
(((u32)(x) & (u32)0x00ff0000) >> 8) | \
|
||||
(((u32)(x) & (u32)0xff000000) >> 24)))
|
||||
|
||||
#define WAP16(x) ((u16)( \
|
||||
(((u16)(x) & (u16)0x00ff) << 8) | \
|
||||
(((u16)(x) & (u16)0xff00) >> 8)))
|
||||
|
||||
|
||||
/*
|
||||
* Call endian free function when
|
||||
* 1. Read/write packet content.
|
||||
* 2. Before write integer to IO.
|
||||
* 3. After read integer from IO.
|
||||
*/
|
||||
|
||||
//
|
||||
// Byte Swapping routine.
|
||||
//
|
||||
#define EF1Byte (u8)
|
||||
#define EF2Byte le16_to_cpu
|
||||
#define EF4Byte le32_to_cpu
|
||||
|
||||
//
|
||||
// Read LE format data from memory
|
||||
//
|
||||
#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr)))
|
||||
#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr)))
|
||||
#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr)))
|
||||
|
||||
//
|
||||
// Write LE data to memory
|
||||
//
|
||||
#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val)
|
||||
#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val)
|
||||
#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val)
|
||||
|
||||
//
|
||||
// Example:
|
||||
// BIT_LEN_MASK_32(0) => 0x00000000
|
||||
// BIT_LEN_MASK_32(1) => 0x00000001
|
||||
// BIT_LEN_MASK_32(2) => 0x00000003
|
||||
// BIT_LEN_MASK_32(32) => 0xFFFFFFFF
|
||||
//
|
||||
#define BIT_LEN_MASK_32(__BitLen) \
|
||||
(0xFFFFFFFF >> (32 - (__BitLen)))
|
||||
//
|
||||
// Example:
|
||||
// BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
|
||||
// BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
|
||||
//
|
||||
#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_32(__BitLen) << (__BitOffset))
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Return 4-byte value in host byte ordering from
|
||||
// 4-byte pointer in litten-endian system.
|
||||
//
|
||||
#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
|
||||
(EF4Byte(*((u32 *)(__pStart))))
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Translate subfield (continuous bits in little-endian) of 4-byte value in litten byte to
|
||||
// 4-byte value in host byte ordering.
|
||||
//
|
||||
#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_32(__BitLen) \
|
||||
)
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Mask subfield (continuous bits in little-endian) of 4-byte value in litten byte oredering
|
||||
// and return the result in 4-byte value in host byte ordering.
|
||||
//
|
||||
#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
|
||||
& \
|
||||
( ~ BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Set subfield of little-endian 4-byte value to specified value.
|
||||
//
|
||||
#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u32 *)(__pStart)) = \
|
||||
EF4Byte( \
|
||||
LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
|
||||
#define BIT_LEN_MASK_16(__BitLen) \
|
||||
(0xFFFF >> (16 - (__BitLen)))
|
||||
|
||||
#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
|
||||
|
||||
#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
||||
(EF2Byte(*((u16 *)(__pStart))))
|
||||
|
||||
#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_16(__BitLen) \
|
||||
)
|
||||
|
||||
#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
||||
& \
|
||||
( ~ BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u16 *)(__pStart)) = \
|
||||
EF2Byte( \
|
||||
LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
#define BIT_LEN_MASK_8(__BitLen) \
|
||||
(0xFF >> (8 - (__BitLen)))
|
||||
|
||||
#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
|
||||
|
||||
#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
(EF1Byte(*((u8 *)(__pStart))))
|
||||
|
||||
#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_8(__BitLen) \
|
||||
)
|
||||
|
||||
#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
& \
|
||||
( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u8 *)(__pStart)) = \
|
||||
EF1Byte( \
|
||||
LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
//pclint
|
||||
#define LE_BITS_CLEARED_TO_1BYTE_8BIT(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
)
|
||||
|
||||
//pclint
|
||||
#define SET_BITS_TO_LE_1BYTE_8BIT(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
{ \
|
||||
*((pu1Byte)(__pStart)) = \
|
||||
EF1Byte( \
|
||||
LE_BITS_CLEARED_TO_1BYTE_8BIT(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
((u1Byte)__Value) \
|
||||
); \
|
||||
}
|
||||
|
||||
// Get the N-bytes aligment offset from the current length
|
||||
#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment))
|
||||
|
||||
typedef unsigned char BOOLEAN,*PBOOLEAN,boolean;
|
||||
|
||||
#define TEST_FLAG(__Flag,__testFlag) (((__Flag) & (__testFlag)) != 0)
|
||||
#define SET_FLAG(__Flag, __setFlag) ((__Flag) |= __setFlag)
|
||||
#define CLEAR_FLAG(__Flag, __clearFlag) ((__Flag) &= ~(__clearFlag))
|
||||
#define CLEAR_FLAGS(__Flag) ((__Flag) = 0)
|
||||
#define TEST_FLAGS(__Flag, __testFlags) (((__Flag) & (__testFlags)) == (__testFlags))
|
||||
|
||||
/* Define compilor specific symbol */
|
||||
//
|
||||
// inline function
|
||||
//
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#define __inline__ inline
|
||||
#define __inline inline
|
||||
#define __inline_definition //In dialect C99, inline means that a function's definition is provided
|
||||
//only for inlining, and that there is another definition
|
||||
//(without inline) somewhere else in the program.
|
||||
//That means that this program is incomplete, because if
|
||||
//add isn't inlined (for example, when compiling without optimization),
|
||||
//then main will have an unresolved reference to that other definition.
|
||||
|
||||
// Do not inline function is the function body is defined .c file and this
|
||||
// function will be called somewhere else, otherwise there is compile error
|
||||
#elif defined ( __CC_ARM )
|
||||
#define __inline__ __inline //__linine__ is not supported in keil compilor, use __inline instead
|
||||
#define inline __inline
|
||||
#define __inline_definition // for dialect C99
|
||||
#elif defined ( __GNUC__ )
|
||||
#define __inline__ inline
|
||||
#define __inline inline
|
||||
#define __inline_definition inline
|
||||
#endif
|
||||
|
||||
//
|
||||
// pack
|
||||
//
|
||||
|
||||
#if defined (__ICCARM__)
|
||||
|
||||
#define RTW_PACK_STRUCT_BEGIN _Pragma( STRINGIFY(pack(1)))
|
||||
#define RTW_PACK_STRUCT_STRUCT
|
||||
#define RTW_PACK_STRUCT_END _Pragma( STRINGIFY(pack()))
|
||||
//#define RTW_PACK_STRUCT_USE_INCLUDES
|
||||
|
||||
#elif defined (__CC_ARM)
|
||||
|
||||
#define RTW_PACK_STRUCT_BEGIN __packed
|
||||
#define RTW_PACK_STRUCT_STRUCT
|
||||
#define RTW_PACK_STRUCT_END
|
||||
|
||||
#elif defined (__GNUC__)
|
||||
|
||||
#define RTW_PACK_STRUCT_BEGIN
|
||||
#define RTW_PACK_STRUCT_STRUCT __attribute__ ((__packed__))
|
||||
#define RTW_PACK_STRUCT_END
|
||||
|
||||
#endif
|
||||
|
||||
// for standard library
|
||||
#ifdef __ICCARM__
|
||||
#define __extension__ /* Ignore */
|
||||
#define __restrict /* Ignore */
|
||||
#endif
|
||||
|
||||
typedef struct _RAM_START_FUNCTION_ {
|
||||
VOID (*RamStartFun) (VOID);
|
||||
}RAM_START_FUNCTION, *PRAM_START_FUNCTION;
|
||||
|
||||
typedef struct _RAM_FUNCTION_START_TABLE_ {
|
||||
VOID (*RamStartFun) (VOID);
|
||||
VOID (*RamWakeupFun) (VOID);
|
||||
VOID (*RamPatchFun0) (VOID);
|
||||
VOID (*RamPatchFun1) (VOID);
|
||||
VOID (*RamPatchFun2) (VOID);
|
||||
}RAM_FUNCTION_START_TABLE, *PRAM_FUNCTION_START_TABLE;
|
||||
|
||||
#endif// __BASIC_TYPES_H__
|
77
lib/wlan/RTL8189FTV/include/skbuff.h
Normal file
77
lib/wlan/RTL8189FTV/include/skbuff.h
Normal file
@ -0,0 +1,77 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
#ifndef __SKBUFF_H__
|
||||
#define __SKBUFF_H__
|
||||
|
||||
struct sk_buff_head {
|
||||
struct list_head *next, *prev;
|
||||
unsigned int qlen;
|
||||
};
|
||||
|
||||
#if CONFIG_TRACE_SKB
|
||||
#define TRACE_SKB_DEPTH 8
|
||||
#endif
|
||||
|
||||
struct sk_buff {
|
||||
/* These two members must be first. */
|
||||
struct sk_buff *next; /* Next buffer in list */
|
||||
struct sk_buff *prev; /* Previous buffer in list */
|
||||
|
||||
struct sk_buff_head *list; /* List we are on */
|
||||
unsigned char *head; /* Head of buffer */
|
||||
unsigned char *data; /* Data head pointer */
|
||||
unsigned char *tail; /* Tail pointer */
|
||||
unsigned char *end; /* End pointer */
|
||||
void *dev; /* Device we arrived on/are leaving by */
|
||||
unsigned int len; /* Length of actual data */
|
||||
#if CONFIG_TRACE_SKB
|
||||
unsigned int liston[TRACE_SKB_DEPTH]; /* Trace the Lists we went through */
|
||||
const char *funcname[TRACE_SKB_DEPTH];
|
||||
unsigned int list_idx; /* Trace the List we are on */
|
||||
#endif
|
||||
int zerocp_flag;
|
||||
int dyalloc_flag;
|
||||
unsigned char type_flag;
|
||||
};
|
||||
|
||||
unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
|
||||
unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
|
||||
void skb_reserve(struct sk_buff *skb, unsigned int len);
|
||||
void skb_assign_buf(struct sk_buff *skb, unsigned char *buf, unsigned int len);
|
||||
unsigned char *skb_tail_pointer(const struct sk_buff *skb);
|
||||
void skb_set_tail_pointer(struct sk_buff *skb, const int offset);
|
||||
unsigned char *skb_end_pointer(const struct sk_buff *skb);
|
||||
|
||||
void skb_queue_head_init(struct sk_buff_head *list);
|
||||
struct sk_buff *skb_dequeue(struct sk_buff_head *list);
|
||||
void skb_reset_tail_pointer(struct sk_buff *skb);
|
||||
void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
|
||||
signed int skb_queue_len(const struct sk_buff_head *list_);
|
||||
|
||||
void init_skb_pool(void);
|
||||
void init_skb_data_pool(void);
|
||||
|
||||
|
||||
#ifdef CONFIG_TX_ZERO_COPY
|
||||
struct sk_buff *dev_alloc_tx_skb_0copy();
|
||||
#endif
|
||||
struct sk_buff *dev_alloc_tx_skb(unsigned int length, unsigned int reserve_len);
|
||||
struct sk_buff *dev_alloc_rx_skb(unsigned int length, unsigned int reserve_len);
|
||||
void kfree_skb(struct sk_buff *skb);
|
||||
|
||||
|
||||
#endif //__SKBUFF_H__
|
||||
|
605
lib/wlan/RTL8189FTV/include/wifi_constants.h
Normal file
605
lib/wlan/RTL8189FTV/include/wifi_constants.h
Normal file
@ -0,0 +1,605 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************
|
||||
* @file wifi_constants.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the data types used for wlan API.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_CONSTANTS_H
|
||||
#define _WIFI_CONSTANTS_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef WLAN0_NAME
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#endif
|
||||
#ifndef WLAN1_NAME
|
||||
#define WLAN1_NAME "wlan1"
|
||||
#endif
|
||||
|
||||
#define WEP_ENABLED 0x0001
|
||||
#define TKIP_ENABLED 0x0002
|
||||
#define AES_ENABLED 0x0004
|
||||
#define WSEC_SWFLAG 0x0008
|
||||
#define AES_CMAC_ENABLED 0x0010
|
||||
|
||||
#define SHARED_ENABLED 0x00008000
|
||||
#define WPA_SECURITY 0x00200000
|
||||
#define WPA2_SECURITY 0x00400000
|
||||
#define WPS_ENABLED 0x10000000
|
||||
|
||||
#define IEEE_8021X_ENABLED 0x80000000
|
||||
|
||||
#define RTW_MAX_PSK_LEN (64)
|
||||
#define RTW_MIN_PSK_LEN (8)
|
||||
|
||||
#define MCSSET_LEN 16
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the results of the function.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
RTW_SUCCESS = 0, /**< Success */
|
||||
RTW_PENDING = 1, /**< Pending */
|
||||
RTW_TIMEOUT = 2, /**< Timeout */
|
||||
RTW_PARTIAL_RESULTS = 3, /**< Partial results */
|
||||
RTW_INVALID_KEY = 4, /**< Invalid key */
|
||||
RTW_DOES_NOT_EXIST = 5, /**< Does not exist */
|
||||
RTW_NOT_AUTHENTICATED = 6, /**< Not authenticated */
|
||||
RTW_NOT_KEYED = 7, /**< Not keyed */
|
||||
RTW_IOCTL_FAIL = 8, /**< IOCTL fail */
|
||||
RTW_BUFFER_UNAVAILABLE_TEMPORARY = 9, /**< Buffer unavailable temporarily */
|
||||
RTW_BUFFER_UNAVAILABLE_PERMANENT = 10, /**< Buffer unavailable permanently */
|
||||
RTW_WPS_PBC_OVERLAP = 11, /**< WPS PBC overlap */
|
||||
RTW_CONNECTION_LOST = 12, /**< Connection lost */
|
||||
|
||||
RTW_ERROR = -1, /**< Generic Error */
|
||||
RTW_BADARG = -2, /**< Bad Argument */
|
||||
RTW_BADOPTION = -3, /**< Bad option */
|
||||
RTW_NOTUP = -4, /**< Not up */
|
||||
RTW_NOTDOWN = -5, /**< Not down */
|
||||
RTW_NOTAP = -6, /**< Not AP */
|
||||
RTW_NOTSTA = -7, /**< Not STA */
|
||||
RTW_BADKEYIDX = -8, /**< BAD Key Index */
|
||||
RTW_RADIOOFF = -9, /**< Radio Off */
|
||||
RTW_NOTBANDLOCKED = -10, /**< Not band locked */
|
||||
RTW_NOCLK = -11, /**< No Clock */
|
||||
RTW_BADRATESET = -12, /**< BAD Rate valueset */
|
||||
RTW_BADBAND = -13, /**< BAD Band */
|
||||
RTW_BUFTOOSHORT = -14, /**< Buffer too short */
|
||||
RTW_BUFTOOLONG = -15, /**< Buffer too long */
|
||||
RTW_BUSY = -16, /**< Busy */
|
||||
RTW_NOTASSOCIATED = -17, /**< Not Associated */
|
||||
RTW_BADSSIDLEN = -18, /**< Bad SSID len */
|
||||
RTW_OUTOFRANGECHAN = -19, /**< Out of Range Channel */
|
||||
RTW_BADCHAN = -20, /**< Bad Channel */
|
||||
RTW_BADADDR = -21, /**< Bad Address */
|
||||
RTW_NORESOURCE = -22, /**< Not Enough Resources */
|
||||
RTW_UNSUPPORTED = -23, /**< Unsupported */
|
||||
RTW_BADLEN = -24, /**< Bad length */
|
||||
RTW_NOTREADY = -25, /**< Not Ready */
|
||||
RTW_EPERM = -26, /**< Not Permitted */
|
||||
RTW_NOMEM = -27, /**< No Memory */
|
||||
RTW_ASSOCIATED = -28, /**< Associated */
|
||||
RTW_RANGE = -29, /**< Not In Range */
|
||||
RTW_NOTFOUND = -30, /**< Not Found */
|
||||
RTW_WME_NOT_ENABLED = -31, /**< WME Not Enabled */
|
||||
RTW_TSPEC_NOTFOUND = -32, /**< TSPEC Not Found */
|
||||
RTW_ACM_NOTSUPPORTED = -33, /**< ACM Not Supported */
|
||||
RTW_NOT_WME_ASSOCIATION = -34, /**< Not WME Association */
|
||||
RTW_SDIO_ERROR = -35, /**< SDIO Bus Error */
|
||||
RTW_WLAN_DOWN = -36, /**< WLAN Not Accessible */
|
||||
RTW_BAD_VERSION = -37, /**< Incorrect version */
|
||||
RTW_TXFAIL = -38, /**< TX failure */
|
||||
RTW_RXFAIL = -39, /**< RX failure */
|
||||
RTW_NODEVICE = -40, /**< Device not present */
|
||||
RTW_UNFINISHED = -41, /**< To be finished */
|
||||
RTW_NONRESIDENT = -42, /**< access to nonresident overlay */
|
||||
RTW_DISABLED = -43 /**< Disabled in this build */
|
||||
};
|
||||
typedef unsigned long rtw_result_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the possible security types to set when connection.\n
|
||||
* Station mode supports OPEN, WEP, and WPA2.\n
|
||||
* AP mode support OPEN and WPA2.
|
||||
*/
|
||||
enum {
|
||||
RTW_SECURITY_OPEN = 0, /**< Open security */
|
||||
RTW_SECURITY_WEP_PSK = WEP_ENABLED, /**< WEP PSK Security with open authentication */
|
||||
RTW_SECURITY_WEP_SHARED = ( WEP_ENABLED | SHARED_ENABLED ), /**< WEP PSK Security with shared authentication */
|
||||
RTW_SECURITY_WPA_TKIP_PSK = ( WPA_SECURITY | TKIP_ENABLED ), /**< WPA PSK Security with TKIP */
|
||||
RTW_SECURITY_WPA_TKIP_8021X = ( IEEE_8021X_ENABLED | WPA_SECURITY | TKIP_ENABLED ), /**< WPA 8021X Security with TKIP */
|
||||
RTW_SECURITY_WPA_AES_PSK = ( WPA_SECURITY | AES_ENABLED ), /**< WPA PSK Security with AES */
|
||||
RTW_SECURITY_WPA_AES_8021X = ( IEEE_8021X_ENABLED | WPA_SECURITY | AES_ENABLED ), /**< WPA 8021X Security with AES */
|
||||
RTW_SECURITY_WPA2_AES_PSK = ( WPA2_SECURITY | AES_ENABLED ), /**< WPA2 PSK Security with AES */
|
||||
RTW_SECURITY_WPA2_AES_8021X = ( IEEE_8021X_ENABLED | WPA2_SECURITY | WEP_ENABLED ), /**< WPA2 8021X Security with AES */
|
||||
RTW_SECURITY_WPA2_TKIP_PSK = ( WPA2_SECURITY | TKIP_ENABLED ), /**< WPA2 PSK Security with TKIP */
|
||||
RTW_SECURITY_WPA2_TKIP_8021X = ( IEEE_8021X_ENABLED | WPA2_SECURITY | TKIP_ENABLED ), /**< WPA2 8021X Security with TKIP */
|
||||
RTW_SECURITY_WPA2_MIXED_PSK = ( WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED ), /**< WPA2 PSK Security with AES & TKIP */
|
||||
RTW_SECURITY_WPA_WPA2_MIXED_PSK = ( WPA_SECURITY | WPA2_SECURITY ), /**< WPA/WPA2 PSK Security */
|
||||
RTW_SECURITY_WPA_WPA2_MIXED_8021X = ( IEEE_8021X_ENABLED | WPA_SECURITY | WPA2_SECURITY ), /**< WPA/WPA2 8021X Security */
|
||||
RTW_SECURITY_WPA2_AES_CMAC = ( WPA2_SECURITY | AES_CMAC_ENABLED), /**< WPA2 Security with AES and Management Frame Protection */
|
||||
|
||||
RTW_SECURITY_WPS_OPEN = WPS_ENABLED, /**< WPS with open security */
|
||||
RTW_SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), /**< WPS with AES security */
|
||||
|
||||
RTW_SECURITY_UNKNOWN = -1, /**< May be returned by scan function if security is unknown. Do not pass this to the join function! */
|
||||
|
||||
RTW_SECURITY_FORCE_32_BIT = 0x7fffffff /**< Exists only to force rtw_security_t type to 32 bits */
|
||||
};
|
||||
typedef unsigned long rtw_security_t;
|
||||
|
||||
enum {
|
||||
RTW_ENCRYPTION_UNKNOWN = 0,
|
||||
RTW_ENCRYPTION_OPEN = 1,
|
||||
RTW_ENCRYPTION_WEP40 = 2,
|
||||
RTW_ENCRYPTION_WPA_TKIP = 3,
|
||||
RTW_ENCRYPTION_WPA_AES = 4,
|
||||
RTW_ENCRYPTION_WPA2_TKIP = 5,
|
||||
RTW_ENCRYPTION_WPA2_AES = 6,
|
||||
RTW_ENCRYPTION_WPA2_MIXED = 7,
|
||||
RTW_ENCRYPTION_WEP104 = 9,
|
||||
RTW_ENCRYPTION_UNDEF = 0xFF,
|
||||
};
|
||||
typedef unsigned long rtw_encryption_t;
|
||||
|
||||
enum {
|
||||
RTW_FALSE = 0,
|
||||
RTW_TRUE = 1
|
||||
};
|
||||
typedef unsigned long rtw_bool_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the band types.
|
||||
*/
|
||||
enum {
|
||||
RTW_802_11_BAND_5GHZ = 0, /**< Denotes 5GHz radio band */
|
||||
RTW_802_11_BAND_2_4GHZ = 1 /**< Denotes 2.4GHz radio band */
|
||||
};
|
||||
typedef unsigned long rtw_802_11_band_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists all the country codes able to set to Wi-Fi driver.
|
||||
*/
|
||||
enum {
|
||||
/* CHANNEL PLAN */
|
||||
RTW_COUNTRY_WORLD1, // 0x20
|
||||
RTW_COUNTRY_ETSI1, // 0x21
|
||||
RTW_COUNTRY_FCC1, // 0x22
|
||||
RTW_COUNTRY_MKK1, // 0x23
|
||||
RTW_COUNTRY_ETSI2, // 0x24
|
||||
RTW_COUNTRY_FCC2, // 0x2A
|
||||
RTW_COUNTRY_WORLD2, // 0x47
|
||||
RTW_COUNTRY_MKK2, // 0x58
|
||||
RTW_COUNTRY_GLOBAL, // 0x41
|
||||
|
||||
/* SPECIAL */
|
||||
RTW_COUNTRY_WORLD, // WORLD1
|
||||
RTW_COUNTRY_EU, // ETSI1
|
||||
|
||||
/* JAPANESE */
|
||||
RTW_COUNTRY_JP, // MKK1
|
||||
|
||||
/* FCC , 19 countries*/
|
||||
RTW_COUNTRY_AS, // FCC2
|
||||
RTW_COUNTRY_BM,
|
||||
RTW_COUNTRY_CA,
|
||||
RTW_COUNTRY_DM,
|
||||
RTW_COUNTRY_DO,
|
||||
RTW_COUNTRY_FM,
|
||||
RTW_COUNTRY_GD,
|
||||
RTW_COUNTRY_GT,
|
||||
RTW_COUNTRY_GU,
|
||||
RTW_COUNTRY_HT,
|
||||
RTW_COUNTRY_MH,
|
||||
RTW_COUNTRY_MP,
|
||||
RTW_COUNTRY_NI,
|
||||
RTW_COUNTRY_PA,
|
||||
RTW_COUNTRY_PR,
|
||||
RTW_COUNTRY_PW,
|
||||
RTW_COUNTRY_TW,
|
||||
RTW_COUNTRY_US,
|
||||
RTW_COUNTRY_VI,
|
||||
|
||||
/* others, ETSI */
|
||||
RTW_COUNTRY_AD, // ETSI1
|
||||
RTW_COUNTRY_AE,
|
||||
RTW_COUNTRY_AF,
|
||||
RTW_COUNTRY_AI,
|
||||
RTW_COUNTRY_AL,
|
||||
RTW_COUNTRY_AM,
|
||||
RTW_COUNTRY_AN,
|
||||
RTW_COUNTRY_AR,
|
||||
RTW_COUNTRY_AT,
|
||||
RTW_COUNTRY_AU,
|
||||
RTW_COUNTRY_AW,
|
||||
RTW_COUNTRY_AZ,
|
||||
RTW_COUNTRY_BA,
|
||||
RTW_COUNTRY_BB,
|
||||
RTW_COUNTRY_BD,
|
||||
RTW_COUNTRY_BE,
|
||||
RTW_COUNTRY_BF,
|
||||
RTW_COUNTRY_BG,
|
||||
RTW_COUNTRY_BH,
|
||||
RTW_COUNTRY_BL,
|
||||
RTW_COUNTRY_BN,
|
||||
RTW_COUNTRY_BO,
|
||||
RTW_COUNTRY_BR,
|
||||
RTW_COUNTRY_BS,
|
||||
RTW_COUNTRY_BT,
|
||||
RTW_COUNTRY_BY,
|
||||
RTW_COUNTRY_BZ,
|
||||
RTW_COUNTRY_CF,
|
||||
RTW_COUNTRY_CH,
|
||||
RTW_COUNTRY_CI,
|
||||
RTW_COUNTRY_CL,
|
||||
RTW_COUNTRY_CN,
|
||||
RTW_COUNTRY_CO,
|
||||
RTW_COUNTRY_CR,
|
||||
RTW_COUNTRY_CX,
|
||||
RTW_COUNTRY_CY,
|
||||
RTW_COUNTRY_CZ,
|
||||
RTW_COUNTRY_DE,
|
||||
RTW_COUNTRY_DK,
|
||||
RTW_COUNTRY_DZ,
|
||||
RTW_COUNTRY_EC,
|
||||
RTW_COUNTRY_EE,
|
||||
RTW_COUNTRY_EG,
|
||||
RTW_COUNTRY_ES,
|
||||
RTW_COUNTRY_ET,
|
||||
RTW_COUNTRY_FI,
|
||||
RTW_COUNTRY_FR,
|
||||
RTW_COUNTRY_GB,
|
||||
RTW_COUNTRY_GE,
|
||||
RTW_COUNTRY_GF,
|
||||
RTW_COUNTRY_GH,
|
||||
RTW_COUNTRY_GL,
|
||||
RTW_COUNTRY_GP,
|
||||
RTW_COUNTRY_GR,
|
||||
RTW_COUNTRY_GY,
|
||||
RTW_COUNTRY_HK,
|
||||
RTW_COUNTRY_HN,
|
||||
RTW_COUNTRY_HR,
|
||||
RTW_COUNTRY_HU,
|
||||
RTW_COUNTRY_ID,
|
||||
RTW_COUNTRY_IE,
|
||||
RTW_COUNTRY_IL,
|
||||
RTW_COUNTRY_IN,
|
||||
RTW_COUNTRY_IQ,
|
||||
RTW_COUNTRY_IR,
|
||||
RTW_COUNTRY_IS,
|
||||
RTW_COUNTRY_IT,
|
||||
RTW_COUNTRY_JM,
|
||||
RTW_COUNTRY_JO,
|
||||
RTW_COUNTRY_KE,
|
||||
RTW_COUNTRY_KH,
|
||||
RTW_COUNTRY_KN,
|
||||
RTW_COUNTRY_KP,
|
||||
RTW_COUNTRY_KR,
|
||||
RTW_COUNTRY_KW,
|
||||
RTW_COUNTRY_KY,
|
||||
RTW_COUNTRY_KZ,
|
||||
RTW_COUNTRY_LA,
|
||||
RTW_COUNTRY_LB,
|
||||
RTW_COUNTRY_LC,
|
||||
RTW_COUNTRY_LI,
|
||||
RTW_COUNTRY_LK,
|
||||
RTW_COUNTRY_LR,
|
||||
RTW_COUNTRY_LS,
|
||||
RTW_COUNTRY_LT,
|
||||
RTW_COUNTRY_LU,
|
||||
RTW_COUNTRY_LV,
|
||||
RTW_COUNTRY_MA,
|
||||
RTW_COUNTRY_MC,
|
||||
RTW_COUNTRY_MD,
|
||||
RTW_COUNTRY_ME,
|
||||
RTW_COUNTRY_MF,
|
||||
RTW_COUNTRY_MK,
|
||||
RTW_COUNTRY_MN,
|
||||
RTW_COUNTRY_MO,
|
||||
RTW_COUNTRY_MQ,
|
||||
RTW_COUNTRY_MR,
|
||||
RTW_COUNTRY_MT,
|
||||
RTW_COUNTRY_MU,
|
||||
RTW_COUNTRY_MV,
|
||||
RTW_COUNTRY_MW,
|
||||
RTW_COUNTRY_MX,
|
||||
RTW_COUNTRY_MY,
|
||||
RTW_COUNTRY_NG,
|
||||
RTW_COUNTRY_NL,
|
||||
RTW_COUNTRY_NO,
|
||||
RTW_COUNTRY_NP,
|
||||
RTW_COUNTRY_NZ,
|
||||
RTW_COUNTRY_OM,
|
||||
RTW_COUNTRY_PE,
|
||||
RTW_COUNTRY_PF,
|
||||
RTW_COUNTRY_PG,
|
||||
RTW_COUNTRY_PH,
|
||||
RTW_COUNTRY_PK,
|
||||
RTW_COUNTRY_PL,
|
||||
RTW_COUNTRY_PM,
|
||||
RTW_COUNTRY_PT,
|
||||
RTW_COUNTRY_PY,
|
||||
RTW_COUNTRY_QA,
|
||||
RTW_COUNTRY_RS,
|
||||
RTW_COUNTRY_RU,
|
||||
RTW_COUNTRY_RW,
|
||||
RTW_COUNTRY_SA,
|
||||
RTW_COUNTRY_SE,
|
||||
RTW_COUNTRY_SG,
|
||||
RTW_COUNTRY_SI,
|
||||
RTW_COUNTRY_SK,
|
||||
RTW_COUNTRY_SN,
|
||||
RTW_COUNTRY_SR,
|
||||
RTW_COUNTRY_SV,
|
||||
RTW_COUNTRY_SY,
|
||||
RTW_COUNTRY_TC,
|
||||
RTW_COUNTRY_TD,
|
||||
RTW_COUNTRY_TG,
|
||||
RTW_COUNTRY_TH,
|
||||
RTW_COUNTRY_TN,
|
||||
RTW_COUNTRY_TR,
|
||||
RTW_COUNTRY_TT,
|
||||
RTW_COUNTRY_TZ,
|
||||
RTW_COUNTRY_UA,
|
||||
RTW_COUNTRY_UG,
|
||||
RTW_COUNTRY_UY,
|
||||
RTW_COUNTRY_UZ,
|
||||
RTW_COUNTRY_VC,
|
||||
RTW_COUNTRY_VE,
|
||||
RTW_COUNTRY_VN,
|
||||
RTW_COUNTRY_VU,
|
||||
RTW_COUNTRY_WF,
|
||||
RTW_COUNTRY_WS,
|
||||
RTW_COUNTRY_YE,
|
||||
RTW_COUNTRY_YT,
|
||||
RTW_COUNTRY_ZA,
|
||||
RTW_COUNTRY_ZW,
|
||||
|
||||
RTW_COUNTRY_MAX
|
||||
|
||||
};
|
||||
typedef unsigned long rtw_country_code_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the adaptivity types.
|
||||
*/
|
||||
enum {
|
||||
RTW_ADAPTIVITY_DISABLE = 0,
|
||||
RTW_ADAPTIVITY_NORMAL, // CE
|
||||
RTW_ADAPTIVITY_CARRIER_SENSE // MKK
|
||||
};
|
||||
typedef unsigned long rtw_adaptivity_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the supported operation mode by WIFI driver,
|
||||
* including station and AP mode.
|
||||
*/
|
||||
enum {
|
||||
RTW_MODE_NONE = 0,
|
||||
RTW_MODE_STA,
|
||||
RTW_MODE_AP,
|
||||
RTW_MODE_STA_AP,
|
||||
RTW_MODE_PROMISC,
|
||||
RTW_MODE_P2P
|
||||
};
|
||||
typedef unsigned long rtw_mode_t;
|
||||
|
||||
enum {
|
||||
RTW_SCAN_FULL = 0,
|
||||
RTW_SCAN_SOCIAL,
|
||||
RTW_SCAN_ONE
|
||||
};
|
||||
typedef unsigned long rtw_scan_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the supported autoreconnect mode by WIFI driver.
|
||||
*/
|
||||
typedef enum{
|
||||
RTW_AUTORECONNECT_DISABLE,
|
||||
RTW_AUTORECONNECT_FINITE,
|
||||
RTW_AUTORECONNECT_INFINITE
|
||||
} rtw_autoreconnect_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the status to describe the connection link.
|
||||
*/
|
||||
enum {
|
||||
RTW_LINK_DISCONNECTED = 0,
|
||||
RTW_LINK_CONNECTED
|
||||
};
|
||||
typedef unsigned long rtw_link_status_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the scan types.
|
||||
*/
|
||||
enum {
|
||||
RTW_SCAN_TYPE_ACTIVE = 0x00, /**< Actively scan a network by sending 802.11 probe(s) */
|
||||
RTW_SCAN_TYPE_PASSIVE = 0x01, /**< Passively scan a network by listening for beacons from APs */
|
||||
RTW_SCAN_TYPE_PROHIBITED_CHANNELS = 0x04 /**< Passively scan on channels not enabled by the country code */
|
||||
};
|
||||
typedef unsigned long rtw_scan_type_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the bss types.
|
||||
*/
|
||||
enum {
|
||||
RTW_BSS_TYPE_INFRASTRUCTURE = 0, /**< Denotes infrastructure network */
|
||||
RTW_BSS_TYPE_ADHOC = 1, /**< Denotes an 802.11 ad-hoc IBSS network */
|
||||
RTW_BSS_TYPE_ANY = 2, /**< Denotes either infrastructure or ad-hoc network */
|
||||
|
||||
RTW_BSS_TYPE_UNKNOWN = -1 /**< May be returned by scan function if BSS type is unknown. Do not pass this to the Join function */
|
||||
};
|
||||
typedef unsigned long rtw_bss_type_t;
|
||||
|
||||
enum {
|
||||
RTW_SCAN_COMMAMD = 0x01
|
||||
};
|
||||
typedef unsigned long rtw_scan_command_t;
|
||||
|
||||
enum{
|
||||
COMMAND1 = 0x01
|
||||
};
|
||||
typedef unsigned long rtw_command_type;
|
||||
|
||||
enum {
|
||||
RTW_WPS_TYPE_DEFAULT = 0x0000,
|
||||
RTW_WPS_TYPE_USER_SPECIFIED = 0x0001,
|
||||
RTW_WPS_TYPE_MACHINE_SPECIFIED = 0x0002,
|
||||
RTW_WPS_TYPE_REKEY = 0x0003,
|
||||
RTW_WPS_TYPE_PUSHBUTTON = 0x0004,
|
||||
RTW_WPS_TYPE_REGISTRAR_SPECIFIED = 0x0005,
|
||||
RTW_WPS_TYPE_NONE = 0x0006,
|
||||
RTW_WPS_TYPE_WSC = 0x0007
|
||||
};
|
||||
typedef unsigned long rtw_wps_type_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists all the network bgn mode.
|
||||
*/
|
||||
enum {
|
||||
RTW_NETWORK_B = 1,
|
||||
RTW_NETWORK_BG = 3,
|
||||
RTW_NETWORK_BGN = 11
|
||||
};
|
||||
typedef unsigned long rtw_network_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the interfaces.
|
||||
*/
|
||||
enum {
|
||||
RTW_STA_INTERFACE = 0, /**< STA or Client Interface */
|
||||
RTW_AP_INTERFACE = 1, /**< SoftAP Interface */
|
||||
};
|
||||
typedef unsigned long rtw_interface_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the packet filter rules.
|
||||
*/
|
||||
enum {
|
||||
RTW_POSITIVE_MATCHING = 0, /**< Receive the data matching with this pattern and discard the other data */
|
||||
RTW_NEGATIVE_MATCHING = 1 /**< Discard the data matching with this pattern and receive the other data */
|
||||
};
|
||||
typedef unsigned long rtw_packet_filter_rule_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the promisc levels.
|
||||
*/
|
||||
enum {
|
||||
RTW_PROMISC_DISABLE = 0, /**< Disable the promisc */
|
||||
RTW_PROMISC_ENABLE = 1, /**< Fetch all ethernet packets */
|
||||
RTW_PROMISC_ENABLE_1 = 2, /**< Fetch only B/M packets */
|
||||
RTW_PROMISC_ENABLE_2 = 3, /**< Fetch all 802.11 packets*/
|
||||
RTW_PROMISC_ENABLE_3 = 4, /**< Fetch only B/M 802.11 packets*/
|
||||
RTW_PROMISC_ENABLE_4 = 5, /**< Fetch all 802.11 packets & MIMO PLCP headers. Please note that the PLCP header would be struct rtw_rx_info_t defined in wifi_structures.h*/
|
||||
};
|
||||
typedef unsigned long rtw_rcr_level_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the promisc rx type.
|
||||
*/
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
enum {
|
||||
RTW_RX_NORMAL = 0, /**< The supported 802.11 packet*/
|
||||
RTW_RX_UNSUPPORT = 1, /**< Unsupported 802.11 packet info */
|
||||
};
|
||||
typedef unsigned long rtw_rx_type_t;
|
||||
#endif
|
||||
/**
|
||||
* @brief The enumeration lists the disconnect reasons.
|
||||
*/
|
||||
enum{
|
||||
RTW_NO_ERROR = 0,
|
||||
RTW_NONE_NETWORK = 1,
|
||||
RTW_CONNECT_FAIL = 2,
|
||||
RTW_WRONG_PASSWORD = 3 ,
|
||||
RTW_4WAY_HANDSHAKE_TIMEOUT = 4,
|
||||
RTW_DHCP_FAIL = 5,
|
||||
RTW_UNKNOWN,
|
||||
};
|
||||
typedef unsigned long rtw_connect_error_flag_t;
|
||||
|
||||
enum {
|
||||
RTW_TX_PWR_PERCENTAGE_100 = 0, /* 100%, default target output power. */
|
||||
RTW_TX_PWR_PERCENTAGE_75 = 1, /* 75% */
|
||||
RTW_TX_PWR_PERCENTAGE_50 = 2, /* 50% */
|
||||
RTW_TX_PWR_PERCENTAGE_25 = 3, /* 25% */
|
||||
RTW_TX_PWR_PERCENTAGE_12_5 = 4, /* 12.5% */
|
||||
};
|
||||
typedef unsigned long rtw_tx_pwr_percentage_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration is event type indicated from wlan driver.
|
||||
*/
|
||||
enum _WIFI_EVENT_INDICATE{
|
||||
WIFI_EVENT_CONNECT = 0,
|
||||
WIFI_EVENT_DISCONNECT = 1,
|
||||
WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2,
|
||||
WIFI_EVENT_SCAN_RESULT_REPORT = 3,
|
||||
WIFI_EVENT_SCAN_DONE = 4,
|
||||
WIFI_EVENT_RECONNECTION_FAIL = 5,
|
||||
WIFI_EVENT_SEND_ACTION_DONE = 6,
|
||||
WIFI_EVENT_RX_MGNT = 7,
|
||||
WIFI_EVENT_STA_ASSOC = 8,
|
||||
WIFI_EVENT_STA_DISASSOC = 9,
|
||||
WIFI_EVENT_STA_WPS_START = 10,
|
||||
WIFI_EVENT_WPS_FINISH = 11,
|
||||
WIFI_EVENT_EAPOL_START = 12,
|
||||
WIFI_EVENT_EAPOL_RECVD = 13,
|
||||
WIFI_EVENT_NO_NETWORK = 14,
|
||||
WIFI_EVENT_BEACON_AFTER_DHCP = 15,
|
||||
WIFI_EVENT_IP_CHANGED = 16,
|
||||
WIFI_EVENT_ICV_ERROR = 17,
|
||||
WIFI_EVENT_CHALLENGE_FAIL = 18,
|
||||
|
||||
WIFI_EVENT_SCAN_START = 19,
|
||||
WIFI_EVENT_SCAN_FAILED = 20,
|
||||
WIFI_EVENT_AUTHENTICATION = 21,
|
||||
WIFI_EVENT_AUTH_REJECT =22 ,
|
||||
WIFI_EVENT_DEAUTH =23 ,
|
||||
WIFI_EVENT_AUTH_TIMEOUT =24 ,
|
||||
WIFI_EVENT_ASSOCIATING = 25,
|
||||
WIFI_EVENT_ASSOCIATED =26 ,
|
||||
WIFI_EVENT_ASSOC_REJECT =27 ,
|
||||
WIFI_EVENT_ASSOC_TIMEOUT =28 ,
|
||||
WIFI_EVENT_HANDSHAKE_FAILED =29 ,
|
||||
WIFI_EVENT_4WAY_HANDSHAKE = 30,
|
||||
WIFI_EVENT_GROUP_HANDSHAKE = 31,
|
||||
WIFI_EVENT_GROUP_HANDSHAKE_DONE = 32,
|
||||
WIFI_EVENT_CONN_TIMEOUT =33,
|
||||
WIFI_EVENT_LEAVE_BUSY_TRAFFIC =34,
|
||||
WIFI_EVENT_MAX,
|
||||
};
|
||||
typedef unsigned long rtw_event_indicate_t;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif /* _WIFI_CONSTANTS_H */
|
279
lib/wlan/RTL8189FTV/include/wifi_structures.h
Normal file
279
lib/wlan/RTL8189FTV/include/wifi_structures.h
Normal file
@ -0,0 +1,279 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************
|
||||
* @file wifi_structures.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the data structures used for wlan API.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_STRUCTURES_H
|
||||
#define _WIFI_STRUCTURES_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "wifi_constants.h"
|
||||
#include "dlist.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the SSID.
|
||||
*/
|
||||
typedef struct rtw_ssid {
|
||||
unsigned char len; /**< SSID length */
|
||||
unsigned char val[33]; /**< SSID name (AP name) */
|
||||
} rtw_ssid_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the unique 6-byte MAC address.
|
||||
*/
|
||||
typedef struct rtw_mac {
|
||||
unsigned char octet[6]; /**< Unique 6-byte MAC address */
|
||||
} rtw_mac_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the setting about SSID,
|
||||
* security type, password and default channel, used to start AP mode.
|
||||
* @note The data length of string pointed by ssid should not exceed 32,
|
||||
* and the data length of string pointed by password should not exceed 64.
|
||||
*/
|
||||
typedef struct rtw_ap_info {
|
||||
rtw_ssid_t ssid;
|
||||
rtw_security_t security_type;
|
||||
unsigned char *password;
|
||||
int password_len;
|
||||
int channel;
|
||||
}rtw_ap_info_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the station mode setting about SSID,
|
||||
* security type and password, used when connecting to an AP.
|
||||
* @note The data length of string pointed by ssid should not exceed 32,
|
||||
* and the data length of string pointed by password should not exceed 64.
|
||||
*/
|
||||
typedef struct rtw_network_info {
|
||||
rtw_ssid_t ssid;
|
||||
rtw_mac_t bssid;
|
||||
rtw_security_t security_type;
|
||||
unsigned char *password;
|
||||
int password_len;
|
||||
int key_id;
|
||||
}rtw_network_info_t;
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the scan result of the AP.
|
||||
*/
|
||||
typedef struct rtw_scan_result {
|
||||
rtw_ssid_t SSID; /**< Service Set Identification (i.e. Name of Access Point) */
|
||||
rtw_mac_t BSSID; /**< Basic Service Set Identification (i.e. MAC address of Access Point) */
|
||||
signed short signal_strength; /**< Receive Signal Strength Indication in dBm. <-90=Very poor, >-30=Excellent */
|
||||
rtw_bss_type_t bss_type; /**< Network type */
|
||||
rtw_security_t security; /**< Security type */
|
||||
rtw_wps_type_t wps_type; /**< WPS type */
|
||||
unsigned int channel; /**< Radio channel that the AP beacon was received on */
|
||||
rtw_802_11_band_t band; /**< Radio band */
|
||||
} rtw_scan_result_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the data needed by scan result handler function.
|
||||
*/
|
||||
typedef struct rtw_scan_handler_result {
|
||||
rtw_scan_result_t ap_details;
|
||||
rtw_bool_t scan_complete;
|
||||
void* user_data;
|
||||
|
||||
} rtw_scan_handler_result_t;
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to store the WIFI setting gotten from WIFI driver.
|
||||
*/
|
||||
typedef struct rtw_wifi_setting {
|
||||
rtw_mode_t mode;
|
||||
unsigned char ssid[33];
|
||||
unsigned char channel;
|
||||
rtw_security_t security_type;
|
||||
unsigned char password[65];
|
||||
unsigned char key_idx;
|
||||
}rtw_wifi_setting_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the setting when configure the network.
|
||||
*/
|
||||
typedef struct rtw_wifi_config {
|
||||
unsigned int boot_mode;
|
||||
unsigned char ssid[32];
|
||||
unsigned char ssid_len;
|
||||
unsigned char security_type;
|
||||
unsigned char password[65];
|
||||
unsigned char password_len;
|
||||
unsigned char channel;
|
||||
} rtw_wifi_config_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the maclist.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int count; /**< Number of MAC addresses in the list */
|
||||
rtw_mac_t mac_list[1]; /**< Variable length array of MAC addresses */
|
||||
} rtw_maclist_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the bss info of the network.\n
|
||||
* It include the version, BSSID, beacon_period, capability, SSID,
|
||||
* channel, atm_window, dtim_period, RSSI e.g.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version; /**< version field */
|
||||
unsigned int length; /**< byte length of data in this record, */
|
||||
/* starting at version and including IEs */
|
||||
rtw_mac_t BSSID;
|
||||
unsigned short beacon_period; /**< units are Kusec */
|
||||
unsigned short capability; /**< Capability information */
|
||||
unsigned char SSID_len;
|
||||
unsigned char SSID[32];
|
||||
unsigned char channel;
|
||||
// struct {
|
||||
// uint32_t count; /* # rates in this set */
|
||||
// uint8_t rates[16]; /* rates in 500kbps units w/hi bit set if basic */
|
||||
// } rateset; /* supported rates */
|
||||
// rtw_chanspec_t chanspec; /* chanspec for bss */
|
||||
unsigned short atim_window; /**< units are Kusec */
|
||||
unsigned char dtim_period; /**< DTIM period */
|
||||
signed short RSSI; /**< receive signal strength (in dBm) */
|
||||
|
||||
unsigned char n_cap; /**< BSS is 802.11N Capable */
|
||||
unsigned int nbss_cap; /**< 802.11N BSS Capabilities (based on HT_CAP_*) */
|
||||
unsigned char basic_mcs[MCSSET_LEN]; /**< 802.11N BSS required MCS set */
|
||||
|
||||
unsigned short ie_offset; /**< offset at which IEs start, from beginning */
|
||||
unsigned int ie_length; /**< byte length of Information Elements */
|
||||
} rtw_bss_info_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to set WIFI packet filter pattern.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned short offset; /**< Offset in bytes to start filtering (referenced to the start of the ethernet packet) */
|
||||
unsigned short mask_size; /**< Size of the mask in bytes */
|
||||
unsigned char* mask; /**< Pattern mask bytes to be ANDed with the pattern eg. "\xff00" (must be in network byte order) */
|
||||
unsigned char* pattern; /**< Pattern bytes used to filter eg. "\x0800" (must be in network byte order) */
|
||||
} rtw_packet_filter_pattern_t;
|
||||
|
||||
typedef struct ieee80211_frame_info{
|
||||
unsigned short i_fc;
|
||||
unsigned short i_dur;
|
||||
unsigned char i_addr1[6];
|
||||
unsigned char i_addr2[6];
|
||||
unsigned char i_addr3[6];
|
||||
unsigned short i_seq;
|
||||
unsigned char bssid[6];
|
||||
unsigned char encrypt;
|
||||
signed char rssi;
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
rtw_rx_type_t type;
|
||||
#endif
|
||||
}ieee80211_frame_info_t;
|
||||
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
typedef struct rtw_rx_info {
|
||||
uint16_t length; //length without FCS
|
||||
uint8_t filter; // 2: 2T rate pkt; 3: LDPC pkt
|
||||
signed char rssi; //-128~-1
|
||||
}rtw_rx_info_t;
|
||||
|
||||
struct rtw_plcp_info {
|
||||
struct rtw_plcp_info *prev;
|
||||
struct rtw_plcp_info *next;
|
||||
uint16_t length; //length without FCS
|
||||
uint8_t filter; // 1: HT-20 pkt; 2: HT-40 and not LDPC pkt; 3: LDPC pkt
|
||||
signed char rssi; //-128~-1
|
||||
};
|
||||
|
||||
struct rtw_rx_buffer {
|
||||
struct rtw_plcp_info *head;
|
||||
struct rtw_plcp_info *tail;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char filter_id;
|
||||
rtw_packet_filter_pattern_t patt;
|
||||
rtw_packet_filter_rule_t rule;
|
||||
unsigned char enable;
|
||||
}rtw_packet_filter_info_t;
|
||||
|
||||
typedef struct rtw_mac_filter_list{
|
||||
struct list_head node;
|
||||
unsigned char mac_addr[6];
|
||||
}rtw_mac_filter_list_t;
|
||||
|
||||
typedef struct wowlan_pattern {
|
||||
unsigned char eth_da[6];
|
||||
unsigned char eth_sa[6];
|
||||
unsigned char eth_proto_type[2];
|
||||
unsigned char header_len[1];
|
||||
//unsigned char header_content[8];
|
||||
unsigned char ip_proto[1];
|
||||
//unsigned char checksum[2];
|
||||
unsigned char ip_sa[4];
|
||||
unsigned char ip_da[4];
|
||||
unsigned char mask[5]; // 40 bits to match 34-byte pattern
|
||||
} wowlan_pattern_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif /* _WIFI_STRUCTURES_H */
|
1246
lib/wlan/RTL8189FTV/include/wireless.h
Normal file
1246
lib/wlan/RTL8189FTV/include/wireless.h
Normal file
File diff suppressed because it is too large
Load Diff
86
lib/wlan/RTL8189FTV/include/wlan_intf.h
Normal file
86
lib/wlan/RTL8189FTV/include/wlan_intf.h
Normal file
@ -0,0 +1,86 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
#ifndef __WLAN_INTF_H__
|
||||
#define __WLAN_INTF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <autoconf.h>
|
||||
|
||||
#include <wireless.h>
|
||||
#include "wifi_constants.h"
|
||||
|
||||
#ifndef WLAN0_IDX
|
||||
#define WLAN0_IDX 0
|
||||
#endif
|
||||
#ifndef WLAN1_IDX
|
||||
#define WLAN1_IDX 1
|
||||
#endif
|
||||
#ifndef WLAN_UNDEF
|
||||
#define WLAN_UNDEF -1
|
||||
#endif
|
||||
|
||||
/***********************************************************/
|
||||
/*
|
||||
struct sk_buff {
|
||||
// These two members must be first.
|
||||
struct sk_buff *next; // Next buffer in list
|
||||
struct sk_buff *prev; // Previous buffer in list
|
||||
|
||||
struct sk_buff_head *list; // List we are on
|
||||
unsigned char *head; // Head of buffer
|
||||
unsigned char *data; // Data head pointer
|
||||
unsigned char *tail; // Tail pointer
|
||||
unsigned char *end; //End pointer
|
||||
struct net_device *dev; //Device we arrived on/are leaving by
|
||||
unsigned int len; // Length of actual data
|
||||
};
|
||||
*/
|
||||
/************************************************************/
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Wlan Interface opened for upper layer
|
||||
//----- ------------------------------------------------------------------
|
||||
int rltk_wlan_init(int idx_wlan, rtw_mode_t mode); //return 0: success. -1:fail
|
||||
void rltk_wlan_deinit(void);
|
||||
void rltk_wlan_deinit_fastly(void);
|
||||
int rltk_wlan_start(int idx_wlan);
|
||||
void rltk_wlan_statistic(unsigned char idx);
|
||||
unsigned char rltk_wlan_running(unsigned char idx); // interface is up. 0: interface is down
|
||||
int rltk_wlan_control(unsigned long cmd, void *data);
|
||||
int rltk_wlan_handshake_done(void);
|
||||
int rltk_wlan_rf_on(void);
|
||||
int rltk_wlan_rf_off(void);
|
||||
int rltk_wlan_check_bus(void);
|
||||
int rltk_wlan_wireless_mode(unsigned char mode);
|
||||
int rltk_wlan_get_wireless_mode(unsigned char *pmode);
|
||||
int rltk_wlan_set_wps_phase(unsigned char is_trigger_wps);
|
||||
int rtw_ps_enable(int enable);
|
||||
int rltk_wlan_is_connected_to_ap(void);
|
||||
#if CONFIG_IEEE80211W
|
||||
void rltk_wlan_tx_sa_query(unsigned char key_type);
|
||||
void rltk_wlan_tx_deauth(unsigned char b_broadcast, unsigned char key_type);
|
||||
void rltk_wlan_tx_auth(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif //#ifndef __WLAN_INTF_H__
|
834
lib/wlan/RTL8189FTV/os/customer_rtos/customer_rtos_service.c
Normal file
834
lib/wlan/RTL8189FTV/os/customer_rtos/customer_rtos_service.c
Normal file
@ -0,0 +1,834 @@
|
||||
/* FreeRTOS includes */
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <timers.h>
|
||||
#include <semphr.h>
|
||||
//#include <autoconf.h>
|
||||
#include <osdep_service.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
//#include <tcm_heap.h>
|
||||
/********************* os depended utilities ********************/
|
||||
|
||||
#ifndef USE_MUTEX_FOR_SPINLOCK
|
||||
#define USE_MUTEX_FOR_SPINLOCK 1
|
||||
#endif
|
||||
|
||||
//PRIORITIE_OFFSET defined to adjust the priority of threads in wlan_lib
|
||||
unsigned int g_prioritie_offset = 4;
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Misc Function
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
int rtw_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int n = vprintf(format, args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
#if CONFIG_MP_LOG_FUNC_INDEPENDENT
|
||||
int rtw_mplog(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int n = vprintf(format, args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
void save_and_cli()
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
}
|
||||
|
||||
void restore_flags()
|
||||
{
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
void cli()
|
||||
{
|
||||
taskDISABLE_INTERRUPTS();
|
||||
}
|
||||
|
||||
/* Not needed on 64bit architectures */
|
||||
static unsigned int __div64_32(u64 *n, unsigned int base)
|
||||
{
|
||||
u64 rem = *n;
|
||||
u64 b = base;
|
||||
u64 res, d = 1;
|
||||
unsigned int high = rem >> 32;
|
||||
|
||||
/* Reduce the thing a bit first */
|
||||
res = 0;
|
||||
if (high >= base) {
|
||||
high /= base;
|
||||
res = (u64) high << 32;
|
||||
rem -= (u64) (high * base) << 32;
|
||||
}
|
||||
|
||||
while ((u64)b > 0 && b < rem) {
|
||||
b = b+b;
|
||||
d = d+d;
|
||||
}
|
||||
|
||||
do {
|
||||
if (rem >= b) {
|
||||
rem -= b;
|
||||
res += d;
|
||||
}
|
||||
b >>= 1;
|
||||
d >>= 1;
|
||||
} while (d);
|
||||
|
||||
*n = res;
|
||||
return rem;
|
||||
}
|
||||
|
||||
/********************* os depended service ********************/
|
||||
|
||||
u8* _freertos_malloc(u32 sz)
|
||||
{
|
||||
return pvPortMalloc(sz);
|
||||
}
|
||||
|
||||
u8* _freertos_zmalloc(u32 sz)
|
||||
{
|
||||
u8 *pbuf = _freertos_malloc(sz);
|
||||
|
||||
if (pbuf != NULL)
|
||||
memset(pbuf, 0, sz);
|
||||
|
||||
return pbuf;
|
||||
}
|
||||
|
||||
void _freertos_mfree(u8 *pbuf, u32 sz)
|
||||
{
|
||||
vPortFree(pbuf);
|
||||
}
|
||||
|
||||
static void _freertos_memcpy(void* dst, const void* src, u32 sz)
|
||||
{
|
||||
memcpy(dst, src, sz);
|
||||
}
|
||||
|
||||
static int _freertos_memcmp(void *dst, void *src, u32 sz)
|
||||
{
|
||||
//under Linux/GNU/GLibc, the return value of memcmp for two same mem. chunk is 0
|
||||
if (!(memcmp(dst, src, sz)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _freertos_memset(void *pbuf, int c, u32 sz)
|
||||
{
|
||||
memset(pbuf, c, sz);
|
||||
}
|
||||
|
||||
static void _freertos_init_sema(_sema *sema, int init_val)
|
||||
{
|
||||
*sema = xSemaphoreCreateCounting(0xffffffff, init_val); //Set max count 0xffffffff
|
||||
}
|
||||
|
||||
static void _freertos_free_sema(_sema *sema)
|
||||
{
|
||||
if(*sema != NULL)
|
||||
vSemaphoreDelete(*sema);
|
||||
|
||||
*sema = NULL;
|
||||
}
|
||||
|
||||
static void _freertos_up_sema(_sema *sema)
|
||||
{
|
||||
xSemaphoreGive(*sema);
|
||||
}
|
||||
|
||||
static void _freertos_up_sema_from_isr(_sema *sema)
|
||||
{
|
||||
portBASE_TYPE taskWoken = pdFALSE;
|
||||
xSemaphoreGiveFromISR(*sema, &taskWoken);
|
||||
portEND_SWITCHING_ISR(taskWoken);
|
||||
}
|
||||
|
||||
static u32 _freertos_down_sema(_sema *sema, u32 timeout)
|
||||
{
|
||||
if(timeout == RTW_MAX_DELAY) {
|
||||
timeout = portMAX_DELAY;
|
||||
} else {
|
||||
timeout = rtw_ms_to_systime(timeout);
|
||||
}
|
||||
|
||||
if(xSemaphoreTake(*sema, timeout) != pdTRUE) {
|
||||
return pdFALSE;
|
||||
}
|
||||
|
||||
return pdTRUE;
|
||||
}
|
||||
|
||||
static void _freertos_mutex_init(_mutex *pmutex)
|
||||
{
|
||||
*pmutex = xSemaphoreCreateMutex();
|
||||
}
|
||||
|
||||
static void _freertos_mutex_free(_mutex *pmutex)
|
||||
{
|
||||
if(*pmutex != NULL)
|
||||
vSemaphoreDelete(*pmutex);
|
||||
|
||||
*pmutex = NULL;
|
||||
}
|
||||
|
||||
static void _freertos_mutex_get(_lock *plock)
|
||||
{
|
||||
while(xSemaphoreTake(*plock, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
}
|
||||
|
||||
static int _freertos_mutex_get_timeout(_lock *plock, u32 timeout_ms)
|
||||
{
|
||||
if(xSemaphoreTake(*plock, timeout_ms / portTICK_RATE_MS) != pdTRUE){
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _freertos_mutex_put(_lock *plock)
|
||||
{
|
||||
xSemaphoreGive(*plock);
|
||||
}
|
||||
|
||||
static void _freertos_enter_critical(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
}
|
||||
|
||||
static void _freertos_exit_critical(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
static u32 uxSavedInterruptStatus = 0;
|
||||
static void _freertos_enter_critical_from_isr(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||
|
||||
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||
}
|
||||
|
||||
static void _freertos_exit_critical_from_isr(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
|
||||
}
|
||||
|
||||
static int _freertos_enter_critical_mutex(_mutex *pmutex, _irqL *pirqL)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while(xSemaphoreTake(*pmutex, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, pmutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _freertos_exit_critical_mutex(_mutex *pmutex, _irqL *pirqL)
|
||||
{
|
||||
xSemaphoreGive(*pmutex);
|
||||
}
|
||||
|
||||
static void _freertos_cpu_lock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_cpu_unlock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_spinlock_init(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
*plock = xSemaphoreCreateMutex();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinlock_free(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
if(*plock != NULL)
|
||||
vSemaphoreDelete(*plock);
|
||||
|
||||
*plock = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinlock(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
while(xSemaphoreTake(*plock, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinunlock(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
xSemaphoreGive(*plock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinlock_irqsave(_lock *plock, _irqL *irqL)
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
while(xSemaphoreTake(*plock, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinunlock_irqsave(_lock *plock, _irqL *irqL)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
xSemaphoreGive(*plock);
|
||||
#endif
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
static int _freertos_init_xqueue( _xqueue* queue, const char* name, u32 message_size, u32 number_of_messages )
|
||||
{
|
||||
if ( ( *queue = xQueueCreate( number_of_messages, message_size ) ) == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _freertos_push_to_xqueue( _xqueue* queue, void* message, u32 timeout_ms )
|
||||
{
|
||||
if(timeout_ms == RTW_MAX_DELAY) {
|
||||
timeout_ms = portMAX_DELAY;
|
||||
} else {
|
||||
timeout_ms = rtw_ms_to_systime(timeout_ms);
|
||||
}
|
||||
|
||||
if ( xQueueSendToBack( *queue, message, timeout_ms ) != pdPASS )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _freertos_pop_from_xqueue( _xqueue* queue, void* message, u32 timeout_ms )
|
||||
{
|
||||
if(timeout_ms == RTW_WAIT_FOREVER) {
|
||||
timeout_ms = portMAX_DELAY;
|
||||
} else {
|
||||
timeout_ms = rtw_ms_to_systime(timeout_ms);
|
||||
}
|
||||
|
||||
if ( xQueueReceive( *queue, message, timeout_ms ) != pdPASS )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _freertos_deinit_xqueue( _xqueue* queue )
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if( uxQueueMessagesWaiting( *queue ) )
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
vQueueDelete( *queue );
|
||||
return result;
|
||||
}
|
||||
|
||||
static u32 _freertos_get_current_time(void)
|
||||
{
|
||||
return xTaskGetTickCount(); //The count of ticks since vTaskStartScheduler was called.
|
||||
}
|
||||
|
||||
static u32 _freertos_systime_to_ms(u32 systime)
|
||||
{
|
||||
return systime * portTICK_RATE_MS;
|
||||
}
|
||||
|
||||
static u32 _freertos_systime_to_sec(u32 systime)
|
||||
{
|
||||
return systime / configTICK_RATE_HZ;
|
||||
}
|
||||
|
||||
static u32 _freertos_ms_to_systime(u32 ms)
|
||||
{
|
||||
return ms / portTICK_RATE_MS;
|
||||
}
|
||||
|
||||
static u32 _freertos_sec_to_systime(u32 sec)
|
||||
{
|
||||
return sec * configTICK_RATE_HZ;
|
||||
}
|
||||
|
||||
static void _freertos_msleep_os(int ms)
|
||||
{
|
||||
vTaskDelay(ms / portTICK_RATE_MS);
|
||||
}
|
||||
|
||||
static void _freertos_usleep_os(int us)
|
||||
{
|
||||
// FreeRTOS does not provide us level delay. Use busy wait
|
||||
WLAN_BSP_UsLoop(us);
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_mdelay_os(int ms)
|
||||
{
|
||||
vTaskDelay(ms / portTICK_RATE_MS);
|
||||
}
|
||||
|
||||
static void _freertos_udelay_os(int us)
|
||||
{
|
||||
// FreeRTOS does not provide us level delay. Use busy wait
|
||||
WLAN_BSP_UsLoop(us);
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_yield_os(void)
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_SET(ATOMIC_T *v, int i)
|
||||
{
|
||||
atomic_set(v,i);
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_READ(ATOMIC_T *v)
|
||||
{
|
||||
return atomic_read(v);
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_ADD(ATOMIC_T *v, int i)
|
||||
{
|
||||
save_and_cli();
|
||||
v->counter += i;
|
||||
restore_flags();
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_SUB(ATOMIC_T *v, int i)
|
||||
{
|
||||
save_and_cli();
|
||||
v->counter -= i;
|
||||
restore_flags();
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_INC(ATOMIC_T *v)
|
||||
{
|
||||
_freertos_ATOMIC_ADD(v, 1);
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_DEC(ATOMIC_T *v)
|
||||
{
|
||||
_freertos_ATOMIC_SUB(v, 1);
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_ADD_RETURN(ATOMIC_T *v, int i)
|
||||
{
|
||||
int temp;
|
||||
|
||||
save_and_cli();
|
||||
temp = v->counter;
|
||||
temp += i;
|
||||
v->counter = temp;
|
||||
restore_flags();
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_SUB_RETURN(ATOMIC_T *v, int i)
|
||||
{
|
||||
int temp;
|
||||
|
||||
save_and_cli();
|
||||
temp = v->counter;
|
||||
temp -= i;
|
||||
v->counter = temp;
|
||||
restore_flags();
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_INC_RETURN(ATOMIC_T *v)
|
||||
{
|
||||
return _freertos_ATOMIC_ADD_RETURN(v, 1);
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_DEC_RETURN(ATOMIC_T *v)
|
||||
{
|
||||
return _freertos_ATOMIC_SUB_RETURN(v, 1);
|
||||
}
|
||||
|
||||
static u64 _freertos_modular64(u64 n, u64 base)
|
||||
{
|
||||
unsigned int __base = (base);
|
||||
unsigned int __rem;
|
||||
|
||||
if (((n) >> 32) == 0) {
|
||||
__rem = (unsigned int)(n) % __base;
|
||||
(n) = (unsigned int)(n) / __base;
|
||||
}
|
||||
else
|
||||
__rem = __div64_32(&(n), __base);
|
||||
|
||||
return __rem;
|
||||
}
|
||||
|
||||
/* Refer to ecos bsd tcpip codes */
|
||||
static int _freertos_arc4random(void)
|
||||
{
|
||||
u32 res = xTaskGetTickCount();
|
||||
static unsigned long seed = 0xDEADB00B;
|
||||
|
||||
seed = ((seed & 0x007F00FF) << 7) ^
|
||||
((seed & 0x0F80FF00) >> 8) ^ // be sure to stir those low bits
|
||||
(res << 13) ^ (res >> 9); // using the clock too!
|
||||
return (int)seed;
|
||||
}
|
||||
|
||||
static int _freertos_get_random_bytes(void *buf, size_t len)
|
||||
{
|
||||
#if 1 //becuase of 4-byte align, we use the follow code style.
|
||||
unsigned int ranbuf;
|
||||
unsigned int *lp;
|
||||
int i, count;
|
||||
count = len / sizeof(unsigned int);
|
||||
lp = (unsigned int *) buf;
|
||||
|
||||
for(i = 0; i < count; i ++) {
|
||||
lp[i] = _freertos_arc4random();
|
||||
len -= sizeof(unsigned int);
|
||||
}
|
||||
|
||||
if(len > 0) {
|
||||
ranbuf = _freertos_arc4random();
|
||||
_freertos_memcpy(&lp[i], &ranbuf, len);
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
unsigned long ranbuf, *lp;
|
||||
lp = (unsigned long *)buf;
|
||||
while (len > 0) {
|
||||
ranbuf = _freertos_arc4random();
|
||||
*lp++ = ranbuf; //this op need the pointer is 4Byte-align!
|
||||
len -= sizeof(ranbuf);
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static u32 _freertos_GetFreeHeapSize(void)
|
||||
{
|
||||
return (u32)xPortGetFreeHeapSize();
|
||||
}
|
||||
void *tcm_heap_malloc(int size);
|
||||
static int _freertos_create_task(struct task_struct *ptask, const char *name,
|
||||
u32 stack_size, u32 priority, thread_func_t func, void *thctx)
|
||||
{
|
||||
thread_func_t task_func = NULL;
|
||||
void *task_ctx = NULL;
|
||||
int ret = 0;
|
||||
|
||||
ptask->task_name = name;
|
||||
|
||||
if(func){
|
||||
task_func = func;
|
||||
task_ctx = thctx;
|
||||
}
|
||||
|
||||
priority += tskIDLE_PRIORITY;
|
||||
#if defined(CONFIG_WIFI_NORMAL) && defined(CONFIG_NETWORK)
|
||||
if(rtw_if_wifi_thread((char*)name) == 0){
|
||||
|
||||
#if CONFIG_USE_TCM_HEAP
|
||||
void *stack_addr = tcm_heap_malloc(stack_size*sizeof(int));
|
||||
//void *stack_addr = rtw_malloc(stack_size*sizeof(int));
|
||||
if(stack_addr == NULL){
|
||||
DBG_INFO("Out of TCM heap in \"%s\" ", ptask->task_name);
|
||||
}
|
||||
ret = xTaskGenericCreate(
|
||||
task_func,
|
||||
(const char *)name,
|
||||
stack_size,
|
||||
task_ctx,
|
||||
priority,
|
||||
&ptask->task,
|
||||
stack_addr,
|
||||
NULL);
|
||||
#else
|
||||
ret = xTaskCreate(
|
||||
task_func,
|
||||
(const char *)name,
|
||||
stack_size,
|
||||
task_ctx,
|
||||
priority,
|
||||
&ptask->task);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = xTaskCreate(
|
||||
task_func,
|
||||
(const char *)name,
|
||||
stack_size,
|
||||
task_ctx,
|
||||
priority,
|
||||
(TaskHandle_t * const)&ptask->task);
|
||||
|
||||
}
|
||||
if(ret != pdPASS){
|
||||
DBG_INFO("Create Task \"%s\" Failed! ret=%d\n", ptask->task_name, ret);
|
||||
}
|
||||
|
||||
DBG_TRACE("Create Task \"%s\"\n", ptask->task_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _freertos_delete_task(struct task_struct *ptask)
|
||||
{
|
||||
if (!ptask->task){
|
||||
DBG_INFO("_freertos_delete_task(): ptask is NULL!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
vTaskDelete(ptask->task);
|
||||
ptask->task = 0;
|
||||
|
||||
DBG_TRACE("Delete Task \"%s\"\n", ptask->task_name);
|
||||
}
|
||||
static void _freertos_wakeup_task(struct task_struct *ptask)
|
||||
{
|
||||
xSemaphoreGive(ptask->wakeup_sema);
|
||||
}
|
||||
|
||||
static void _freertos_thread_enter(char *name)
|
||||
{
|
||||
DBG_TRACE("RTKTHREAD %s\n", name);
|
||||
}
|
||||
|
||||
static void _freertos_thread_exit(void)
|
||||
{
|
||||
DBG_TRACE("RTKTHREAD exit %s\n", __FUNCTION__);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
_timerHandle _freertos_timerCreate( const signed char *pcTimerName,
|
||||
osdepTickType xTimerPeriodInTicks,
|
||||
u32 uxAutoReload,
|
||||
void * pvTimerID,
|
||||
TIMER_FUN pxCallbackFunction )
|
||||
{
|
||||
if(xTimerPeriodInTicks == TIMER_MAX_DELAY) {
|
||||
xTimerPeriodInTicks = portMAX_DELAY;
|
||||
}
|
||||
return xTimerCreate((const char *)pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, (TimerCallbackFunction_t)pxCallbackFunction);
|
||||
}
|
||||
|
||||
u32 _freertos_timerDelete( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerDelete(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
u32 _freertos_timerIsTimerActive( _timerHandle xTimer )
|
||||
{
|
||||
return (u32)xTimerIsTimerActive(xTimer);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStop( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerStop(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
u32 _freertos_timerChangePeriod( _timerHandle xTimer,
|
||||
osdepTickType xNewPeriod,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
if(xNewPeriod == 0)
|
||||
xNewPeriod += 1;
|
||||
return (u32)xTimerChangePeriod(xTimer, xNewPeriod, xBlockTime);
|
||||
}
|
||||
void *_freertos_timerGetID( _timerHandle xTimer ){
|
||||
|
||||
return pvTimerGetTimerID(xTimer);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStart( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerStart(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStartFromISR( _timerHandle xTimer,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
return (u32)xTimerStartFromISR(xTimer, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStopFromISR( _timerHandle xTimer,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
return (u32)xTimerStopFromISR(xTimer, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerResetFromISR( _timerHandle xTimer,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
return (u32)xTimerResetFromISR(xTimer, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerChangePeriodFromISR( _timerHandle xTimer,
|
||||
osdepTickType xNewPeriod,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
if(xNewPeriod == 0)
|
||||
xNewPeriod += 1;
|
||||
return (u32)xTimerChangePeriodFromISR(xTimer, xNewPeriod, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerReset( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerReset(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
void _freertos_acquire_wakelock()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _freertos_release_wakelock()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _freertos_wakelock_timeout(uint32_t timeout)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
u8 _freertos_get_scheduler_state(void)
|
||||
{
|
||||
u8 state = xTaskGetSchedulerState();
|
||||
switch(state){
|
||||
case taskSCHEDULER_NOT_STARTED: state = OS_SCHEDULER_NOT_STARTED; break;
|
||||
case taskSCHEDULER_RUNNING: state = OS_SCHEDULER_RUNNING; break;
|
||||
case taskSCHEDULER_SUSPENDED: state = OS_SCHEDULER_SUSPENDED; break;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
const struct osdep_service_ops osdep_service = {
|
||||
_freertos_malloc, //rtw_vmalloc
|
||||
_freertos_zmalloc, //rtw_zvmalloc
|
||||
_freertos_mfree, //rtw_vmfree
|
||||
_freertos_malloc, //rtw_malloc
|
||||
_freertos_zmalloc, //rtw_zmalloc
|
||||
_freertos_mfree, //rtw_mfree
|
||||
_freertos_memcpy, //rtw_memcpy
|
||||
_freertos_memcmp, //rtw_memcmp
|
||||
_freertos_memset, //rtw_memset
|
||||
_freertos_init_sema, //rtw_init_sema
|
||||
_freertos_free_sema, //rtw_free_sema
|
||||
_freertos_up_sema, //rtw_up_sema
|
||||
_freertos_up_sema_from_isr, //rtw_up_sema_from_isr
|
||||
_freertos_down_sema, //rtw_down_sema
|
||||
_freertos_mutex_init, //rtw_mutex_init
|
||||
_freertos_mutex_free, //rtw_mutex_free
|
||||
_freertos_mutex_get, //rtw_mutex_get
|
||||
_freertos_mutex_get_timeout,//rtw_mutex_get_timeout
|
||||
_freertos_mutex_put, //rtw_mutex_put
|
||||
_freertos_enter_critical, //rtw_enter_critical
|
||||
_freertos_exit_critical, //rtw_exit_critical
|
||||
_freertos_enter_critical_from_isr, //rtw_enter_critical_from_isr
|
||||
_freertos_exit_critical_from_isr, //rtw_exit_critical_from_isr
|
||||
NULL, //rtw_enter_critical_bh
|
||||
NULL, //rtw_exit_critical_bh
|
||||
_freertos_enter_critical_mutex, //rtw_enter_critical_mutex
|
||||
_freertos_exit_critical_mutex, //rtw_exit_critical_mutex
|
||||
_freertos_cpu_lock,
|
||||
_freertos_cpu_unlock,
|
||||
_freertos_spinlock_init, //rtw_spinlock_init
|
||||
_freertos_spinlock_free, //rtw_spinlock_free
|
||||
_freertos_spinlock, //rtw_spin_lock
|
||||
_freertos_spinunlock, //rtw_spin_unlock
|
||||
_freertos_spinlock_irqsave, //rtw_spinlock_irqsave
|
||||
_freertos_spinunlock_irqsave, //rtw_spinunlock_irqsave
|
||||
_freertos_init_xqueue, //rtw_init_xqueue
|
||||
_freertos_push_to_xqueue, //rtw_push_to_xqueue
|
||||
_freertos_pop_from_xqueue, //rtw_pop_from_xqueue
|
||||
_freertos_deinit_xqueue, //rtw_deinit_xqueue
|
||||
_freertos_get_current_time, //rtw_get_current_time
|
||||
_freertos_systime_to_ms, //rtw_systime_to_ms
|
||||
_freertos_systime_to_sec, //rtw_systime_to_sec
|
||||
_freertos_ms_to_systime, //rtw_ms_to_systime
|
||||
_freertos_sec_to_systime, //rtw_sec_to_systime
|
||||
_freertos_msleep_os, //rtw_msleep_os
|
||||
_freertos_usleep_os, //rtw_usleep_os
|
||||
_freertos_mdelay_os, //rtw_mdelay_os
|
||||
_freertos_udelay_os, //rtw_udelay_os
|
||||
_freertos_yield_os, //rtw_yield_os
|
||||
|
||||
_freertos_ATOMIC_SET, //ATOMIC_SET
|
||||
_freertos_ATOMIC_READ, //ATOMIC_READ
|
||||
_freertos_ATOMIC_ADD, //ATOMIC_ADD
|
||||
_freertos_ATOMIC_SUB, //ATOMIC_SUB
|
||||
_freertos_ATOMIC_INC, //ATOMIC_INC
|
||||
_freertos_ATOMIC_DEC, //ATOMIC_DEC
|
||||
_freertos_ATOMIC_ADD_RETURN, //ATOMIC_ADD_RETURN
|
||||
_freertos_ATOMIC_SUB_RETURN, //ATOMIC_SUB_RETURN
|
||||
_freertos_ATOMIC_INC_RETURN, //ATOMIC_INC_RETURN
|
||||
_freertos_ATOMIC_DEC_RETURN, //ATOMIC_DEC_RETURN
|
||||
|
||||
_freertos_modular64, //rtw_modular64
|
||||
_freertos_get_random_bytes, //rtw_get_random_bytes
|
||||
_freertos_GetFreeHeapSize, //rtw_getFreeHeapSize
|
||||
|
||||
_freertos_create_task, //rtw_create_task
|
||||
_freertos_delete_task, //rtw_delete_task
|
||||
_freertos_wakeup_task, //rtw_wakeup_task
|
||||
|
||||
_freertos_thread_enter, //rtw_thread_enter
|
||||
_freertos_thread_exit, //rtw_thread_exit
|
||||
|
||||
_freertos_timerCreate, //rtw_timerCreate,
|
||||
_freertos_timerDelete, //rtw_timerDelete,
|
||||
_freertos_timerIsTimerActive, //rtw_timerIsTimerActive,
|
||||
_freertos_timerStop, //rtw_timerStop,
|
||||
_freertos_timerChangePeriod, //rtw_timerChangePeriod
|
||||
_freertos_timerGetID, //rtw_timerGetID
|
||||
_freertos_timerStart, //rtw_timerStart
|
||||
_freertos_timerStartFromISR, //rtw_timerStartFromISR
|
||||
_freertos_timerStopFromISR, //rtw_timerStopFromISR
|
||||
_freertos_timerResetFromISR, //rtw_timerResetFromISR
|
||||
_freertos_timerChangePeriodFromISR, //rtw_timerChangePeriodFromISR
|
||||
_freertos_timerReset, //rtw_timerReset
|
||||
|
||||
_freertos_acquire_wakelock, //rtw_acquire_wakelock
|
||||
_freertos_release_wakelock, //rtw_release_wakelock
|
||||
_freertos_wakelock_timeout, //rtw_wakelock_timeout
|
||||
_freertos_get_scheduler_state //rtw_get_scheduler_state
|
||||
};
|
228
lib/wlan/RTL8189FTV/os/customer_rtos/customer_rtos_service.h
Normal file
228
lib/wlan/RTL8189FTV/os/customer_rtos/customer_rtos_service.h
Normal file
@ -0,0 +1,228 @@
|
||||
#ifndef _CUSTOMER_RTOS_SERVICE_H_
|
||||
#define _CUSTOMER_RTOS_SERVICE_H_
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Include Files
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
#include "dlist.h"
|
||||
|
||||
/* For SPI interface transfer and us delay implementation */
|
||||
#include <rtwlan_bsp.h>
|
||||
|
||||
|
||||
#ifdef CONFIG_USB_HCI
|
||||
typedef struct urb * PURB;
|
||||
#endif
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
#include "basic_types.h"
|
||||
//----- ------------------------------------------------------------------
|
||||
// --------------------------------------------
|
||||
// Platform dependent type define
|
||||
// --------------------------------------------
|
||||
|
||||
#define FIELD_OFFSET(s,field) ((SSIZE_T)&((s*)(0))->field)
|
||||
|
||||
// os types
|
||||
typedef char osdepCHAR;
|
||||
typedef float osdepFLOAT;
|
||||
typedef double osdepDOUBLE;
|
||||
typedef long osdepLONG;
|
||||
typedef short osdepSHORT;
|
||||
typedef unsigned long osdepSTACK_TYPE;
|
||||
typedef long osdepBASE_TYPE;
|
||||
typedef unsigned long osdepTickType;
|
||||
|
||||
typedef void* _timerHandle;
|
||||
typedef void* _sema;
|
||||
typedef void* _mutex;
|
||||
typedef void* _lock;
|
||||
typedef void* _queueHandle;
|
||||
typedef void* _xqueue;
|
||||
typedef struct timer_list _timer;
|
||||
|
||||
typedef struct sk_buff _pkt;
|
||||
typedef unsigned char _buffer;
|
||||
typedef unsigned int systime;
|
||||
|
||||
#ifndef __LIST_H
|
||||
#warning "DLIST_NOT_DEFINE!!!!!!"
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct __queue {
|
||||
struct list_head queue;
|
||||
_lock lock;
|
||||
};
|
||||
|
||||
typedef struct __queue _queue;
|
||||
typedef struct list_head _list;
|
||||
typedef unsigned long _irqL;
|
||||
|
||||
typedef void* _thread_hdl_;
|
||||
typedef void thread_return;
|
||||
typedef void* thread_context;
|
||||
|
||||
typedef struct { volatile int counter; } atomic_t;
|
||||
|
||||
#define ATOMIC_T atomic_t
|
||||
#define HZ configTICK_RATE_HZ
|
||||
#define rtw_timer_list timer_list
|
||||
|
||||
|
||||
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
/* emulate a modern version */
|
||||
#define LINUX_VERSION_CODE KERNEL_VERSION(2, 6, 17)
|
||||
|
||||
|
||||
static __inline _list *get_next(_list *list)
|
||||
{
|
||||
return list->next;
|
||||
}
|
||||
|
||||
static __inline _list *get_list_head(_queue *queue)
|
||||
{
|
||||
return (&(queue->queue));
|
||||
}
|
||||
|
||||
#define LIST_CONTAINOR(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(SIZE_T)((char *)&((type *)ptr)->member - (char *)ptr)))
|
||||
//#define container_of(p,t,n) (t*)((p)-&(((t*)0)->n))
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
|
||||
#define TASK_PRORITY_LOW 1
|
||||
#define TASK_PRORITY_MIDDLE 2
|
||||
#define TASK_PRORITY_HIGH 3
|
||||
#define TASK_PRORITY_SUPER 4
|
||||
|
||||
#define TIMER_MAX_DELAY 0xFFFFFFFF
|
||||
extern unsigned int g_prioritie_offset;
|
||||
#ifdef PRIORITIE_OFFSET
|
||||
#undef PRIORITIE_OFFSET
|
||||
#endif
|
||||
#define PRIORITIE_OFFSET (g_prioritie_offset)
|
||||
|
||||
|
||||
void save_and_cli(void);
|
||||
void restore_flags(void);
|
||||
void cli(void);
|
||||
#if 0
|
||||
#ifndef mdelay
|
||||
#define mdelay(t) ((t/portTICK_RATE_MS)>0)?(vTaskDelay(t/portTICK_RATE_MS)):(vTaskDelay(1))
|
||||
#endif
|
||||
|
||||
#ifndef udelay
|
||||
#define udelay(t) ((t/(portTICK_RATE_MS*1000))>0)?vTaskDelay(t/(portTICK_RATE_MS*1000)):(vTaskDelay(1))
|
||||
#endif
|
||||
#endif
|
||||
//----- ------------------------------------------------------------------
|
||||
// Common Definition
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
#define __init
|
||||
#define __exit
|
||||
#define __devinit
|
||||
#define __devexit
|
||||
|
||||
#define KERN_ERR
|
||||
#define KERN_INFO
|
||||
#define KERN_NOTICE
|
||||
|
||||
#undef GFP_KERNEL
|
||||
#define GFP_KERNEL 1
|
||||
#define GFP_ATOMIC 1
|
||||
|
||||
#define SET_MODULE_OWNER(some_struct) do { } while (0)
|
||||
#define SET_NETDEV_DEV(dev, obj) do { } while (0)
|
||||
#define register_netdev(dev) (0)
|
||||
#define unregister_netdev(dev) do { } while (0)
|
||||
#define netif_queue_stopped(dev) (0)
|
||||
#define netif_wake_queue(dev) do { } while (0)
|
||||
|
||||
int rtw_printf(const char *format, ...);
|
||||
#define printk rtw_printf
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#define DBG_INFO(fmt, args...) printk("\n\rRTL871X: " fmt, ## args)
|
||||
#if WLAN_INTF_DBG
|
||||
#define DBG_TRACE(fmt, args...) printk("\n\rRTL871X: [%s] " fmt, __FUNCTION__, ## args)
|
||||
#else
|
||||
#define DBG_TRACE(fmt, args...)
|
||||
#endif
|
||||
#else
|
||||
#define DBG_INFO(...) do {printk("\n\rRTL871X: ");printk(__VA_ARGS__);} while(0)
|
||||
#if WLAN_INTF_DBG
|
||||
#define DBG_TRACE(...) do {printk("\n\rRTL871X: [%s] ", __FUNCTION__);printk(__VA_ARGS__);} while(0)
|
||||
#else
|
||||
#define DBG_TRACE(...)
|
||||
#endif
|
||||
#endif
|
||||
#define HALT() do { cli(); for(;;);} while(0)
|
||||
#undef ASSERT
|
||||
#define ASSERT(x) do { \
|
||||
if((x) == 0){\
|
||||
printk("\n\rRTL871X: Assert(" #x ") failed on line %d in file %s", __LINE__, __FILE__); \
|
||||
HALT();}\
|
||||
} while(0)
|
||||
|
||||
#undef DBG_ASSERT
|
||||
#define DBG_ASSERT(x, msg) do { \
|
||||
if((x) == 0) \
|
||||
printk("\n\rRTL871X: %s, Assert(" #x ") failed on line %d in file %s", msg, __LINE__, __FILE__); \
|
||||
} while(0)
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Atomic Operation
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* atomic_read - read atomic variable
|
||||
* @v: pointer of type atomic_t
|
||||
*
|
||||
* Atomically reads the value of @v. Note that the guaranteed
|
||||
* useful range of an atomic_t is only 24 bits.
|
||||
*/
|
||||
#undef atomic_read
|
||||
#define atomic_read(v) ((v)->counter)
|
||||
|
||||
/*
|
||||
* atomic_set - set atomic variable
|
||||
* @v: pointer of type atomic_t
|
||||
* @i: required value
|
||||
*
|
||||
* Atomically sets the value of @v to @i. Note that the guaranteed
|
||||
* useful range of an atomic_t is only 24 bits.
|
||||
*/
|
||||
#undef atomic_set
|
||||
#define atomic_set(v,i) ((v)->counter = (i))
|
||||
|
||||
/*
|
||||
* These inlines deal with timer wrapping correctly. You are
|
||||
* strongly encouraged to use them
|
||||
* 1. Because people otherwise forget
|
||||
* 2. Because if the timer wrap changes in future you wont have to
|
||||
* alter your driver code.
|
||||
*
|
||||
* time_after(a,b) returns true if the time a is after time b.
|
||||
*
|
||||
* Do this with "<0" and ">=0" to only test the sign of the result. A
|
||||
* good compiler would generate better code (and a really good compiler
|
||||
* wouldn't care). Gcc is currently neither.
|
||||
*/
|
||||
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
|
||||
#define time_before(a,b) time_after(b,a)
|
||||
|
||||
#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
|
||||
#define time_before_eq(a,b) time_after_eq(b,a)
|
||||
|
||||
|
||||
extern void rtw_init_listhead(_list *list);
|
||||
extern u32 rtw_is_list_empty(_list *phead);
|
||||
extern void rtw_list_insert_head(_list *plist, _list *phead);
|
||||
extern void rtw_list_insert_tail(_list *plist, _list *phead);
|
||||
extern void rtw_list_delete(_list *plist);
|
||||
|
||||
#endif /* _CUSTOMER_RTOS_SERVICE_H_ */
|
64
lib/wlan/RTL8189FTV/os/os_dep/device_lock.c
Normal file
64
lib/wlan/RTL8189FTV/os/os_dep/device_lock.c
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is proprietary property of RealTek and
|
||||
* possession or use of this module requires release permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "device_lock.h"
|
||||
|
||||
//------------------------------------------------------
|
||||
#define DEVICE_MUTEX_IS_INIT(device) (mutex_init & (1<<device))
|
||||
#define DEVICE_MUTEX_SET_INIT(device) (mutex_init |= (1<<device))
|
||||
#define DEVICE_MUTEX_CLR_INIT(device) (mutex_init &= (~(1<<device)))
|
||||
|
||||
static u32 mutex_init = 0;
|
||||
static _mutex device_mutex[RT_DEV_LOCK_MAX];
|
||||
|
||||
//======================================================
|
||||
static void device_mutex_init(RT_DEV_LOCK_E device)
|
||||
{
|
||||
if(!DEVICE_MUTEX_IS_INIT(device)){
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
if(!DEVICE_MUTEX_IS_INIT(device)){
|
||||
rtw_mutex_init(&device_mutex[device]);
|
||||
DEVICE_MUTEX_SET_INIT(device);
|
||||
}
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================
|
||||
void device_mutex_free(RT_DEV_LOCK_E device)
|
||||
{
|
||||
if(DEVICE_MUTEX_IS_INIT(device)){
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
if(DEVICE_MUTEX_IS_INIT(device)){
|
||||
rtw_mutex_free(&device_mutex[device]);
|
||||
DEVICE_MUTEX_CLR_INIT(device);
|
||||
}
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================
|
||||
void device_mutex_lock(RT_DEV_LOCK_E device)
|
||||
{
|
||||
device_mutex_init(device);
|
||||
while(rtw_mutex_get_timeout(&device_mutex[device], 10000)<0)
|
||||
DBG_INFO("device lock timeout: %d\n", (int)device);
|
||||
}
|
||||
|
||||
//======================================================
|
||||
void device_mutex_unlock(RT_DEV_LOCK_E device)
|
||||
{
|
||||
device_mutex_init(device);
|
||||
rtw_mutex_put(&device_mutex[device]);
|
||||
}
|
27
lib/wlan/RTL8189FTV/os/os_dep/include/device_lock.h
Normal file
27
lib/wlan/RTL8189FTV/os/os_dep/include/device_lock.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is proprietary property of RealTek and
|
||||
* possession or use of this module requires release permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _DEVICE_LOCK_H_
|
||||
#define _DEVICE_LOCK_H_
|
||||
|
||||
enum _RT_DEV_LOCK_E
|
||||
{
|
||||
RT_DEV_LOCK_EFUSE = 0,
|
||||
RT_DEV_LOCK_FLASH = 1,
|
||||
RT_DEV_LOCK_CRYPTO = 2,
|
||||
RT_DEV_LOCK_PTA = 3,
|
||||
RT_DEV_LOCK_WLAN = 4,
|
||||
RT_DEV_LOCK_MAX = 5
|
||||
};
|
||||
typedef uint32_t RT_DEV_LOCK_E;
|
||||
|
||||
void device_mutex_lock(RT_DEV_LOCK_E device);
|
||||
void device_mutex_unlock(RT_DEV_LOCK_E device);
|
||||
|
||||
#endif //_DEVICE_LOCK_H_
|
83
lib/wlan/RTL8189FTV/os/os_dep/include/net_stack_intf.h
Normal file
83
lib/wlan/RTL8189FTV/os/os_dep/include/net_stack_intf.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __NET_STACK_INTF_H__
|
||||
#define __NET_STACK_INTF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <wireless.h>
|
||||
#include <skbuff.h>
|
||||
|
||||
struct netif;
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Ethernet Buffer
|
||||
//----- ------------------------------------------------------------------
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
#include "ethernetif.h"
|
||||
#else
|
||||
struct eth_drv_sg {
|
||||
unsigned int buf;
|
||||
unsigned int len;
|
||||
};
|
||||
#endif
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Wlan Interface Provided
|
||||
//----- ------------------------------------------------------------------
|
||||
unsigned char rltk_wlan_check_isup(int idx);
|
||||
void rltk_wlan_tx_inc(int idx);
|
||||
void rltk_wlan_tx_dec(int idx);
|
||||
struct sk_buff * rltk_wlan_get_recv_skb(int idx);
|
||||
struct sk_buff * rltk_wlan_alloc_skb(unsigned int total_len);
|
||||
void rltk_wlan_set_netif_info(int idx_wlan, void * dev, unsigned char * dev_addr);
|
||||
void rltk_wlan_send_skb(int idx, struct sk_buff *skb); //struct sk_buff as defined above comment line
|
||||
int rltk_wlan_send(int idx, struct eth_drv_sg *sg_list, int sg_len, int total_len);
|
||||
int rltk_wlan_recv(int idx, struct eth_drv_sg *sg_list, int sg_len);
|
||||
unsigned char rltk_wlan_running(unsigned char idx); // interface is up. 0: interface is down
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Network Interface provided
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
int netif_is_valid_IP(int idx,unsigned char * ip_dest);
|
||||
int netif_get_idx(struct netif *pnetif);
|
||||
unsigned char *netif_get_hwaddr(int idx_wlan);
|
||||
void netif_rx(int idx, unsigned int len);
|
||||
void netif_post_sleep_processing(void);
|
||||
void netif_pre_sleep_processing(void);
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
extern void ethernetif_recv(struct netif *netif, int total_len);
|
||||
extern void lwip_PRE_SLEEP_PROCESSING(void);
|
||||
extern void lwip_POST_SLEEP_PROCESSING(void);
|
||||
#endif //CONFIG_LWIP_LAYER == 1
|
||||
|
||||
#if CONFIG_WOWLAN
|
||||
extern unsigned char *rltk_wlan_get_ip(int idx);
|
||||
extern unsigned char *rltk_wlan_get_gw(int idx);
|
||||
extern unsigned char *rltk_wlan_get_gwmask(int idx);
|
||||
#endif
|
||||
int rltk_wlan_wait_recv_data_ready(uint32_t timeout, uint32_t * recv_len);
|
||||
int rltk_wlan_ctx_init(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //#ifndef __NET_STACK_INTF_H__
|
1481
lib/wlan/RTL8189FTV/os/os_dep/include/osdep_service.h
Normal file
1481
lib/wlan/RTL8189FTV/os/os_dep/include/osdep_service.h
Normal file
File diff suppressed because it is too large
Load Diff
376
lib/wlan/RTL8189FTV/os/os_dep/net_stack_intf.c
Normal file
376
lib/wlan/RTL8189FTV/os/os_dep/net_stack_intf.c
Normal file
@ -0,0 +1,376 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//#define _NET_STACK_INTF_C_
|
||||
#include <stdint.h>
|
||||
#include <autoconf.h>
|
||||
#include <net_stack_intf.h>
|
||||
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
#include <lwip/netif.h>
|
||||
#include <lwip_netconf.h>
|
||||
#include <ethernetif.h>
|
||||
#endif
|
||||
#include <osdep_service.h>
|
||||
#include <wifi/wifi_util.h>
|
||||
//----- ------------------------------------------------------------------
|
||||
// External Reference
|
||||
//----- ------------------------------------------------------------------
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
extern struct netif xnetif[]; //LWIP netif
|
||||
#endif
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
#include "timers.h"
|
||||
#include "semphr.h"
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
/*#include "FreeRTOS_DNS.h" */
|
||||
#include "NetworkBufferManagement.h"
|
||||
#include "NetworkInterface.h"
|
||||
|
||||
//#define DUMP_NETWORK_RX_DATA
|
||||
|
||||
/**
|
||||
* rltk_wlan_set_netif_info - set netif hw address and register dev pointer to netif device
|
||||
* @idx_wlan: netif index
|
||||
* 0 for STA only or SoftAP only or STA in STA+SoftAP concurrent mode,
|
||||
* 1 for SoftAP in STA+SoftAP concurrent mode
|
||||
* @dev: register netdev pointer to LWIP. Reserved.
|
||||
* @dev_addr: set netif hw address
|
||||
*
|
||||
* Return Value: None
|
||||
*/
|
||||
void rltk_wlan_set_netif_info(int idx_wlan, void * dev, unsigned char * dev_addr)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
rtw_memcpy(xnetif[idx_wlan].hwaddr, dev_addr, 6);
|
||||
xnetif[idx_wlan].state = dev;
|
||||
#endif
|
||||
printf("\r\ndev_addr: %02x:%02x:%02x:%02x:%02x:%02x\r\n", dev_addr[0], dev_addr[1], dev_addr[2], dev_addr[3], dev_addr[4], dev_addr[5]);
|
||||
FreeRTOS_UpdateMACAddress(dev_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* rltk_wlan_send - send IP packets to WLAN. Called by low_level_output().
|
||||
* @idx: netif index
|
||||
* @sg_list: data buffer list
|
||||
* @sg_len: size of each data buffer
|
||||
* @total_len: total data len
|
||||
*
|
||||
* Return Value: None
|
||||
*/
|
||||
int rltk_wlan_send(int idx, struct eth_drv_sg *sg_list, int sg_len, int total_len)
|
||||
{
|
||||
//#if (CONFIG_LWIP_LAYER == 1)
|
||||
struct eth_drv_sg *last_sg;
|
||||
struct sk_buff *skb = NULL;
|
||||
int ret = 0;
|
||||
|
||||
#ifdef CONFIG_TX_ZERO_COPY
|
||||
u8 *data = NULL;
|
||||
u8 *Mac_data = NULL;
|
||||
#endif
|
||||
|
||||
if(idx == -1){
|
||||
DBG_INFO("netif is DOWN");
|
||||
return -1;
|
||||
}
|
||||
DBG_TRACE("%s is called", __FUNCTION__);
|
||||
|
||||
save_and_cli();
|
||||
if (rltk_wlan_check_isup(idx)) {
|
||||
rltk_wlan_tx_inc(idx);
|
||||
} else {
|
||||
DBG_INFO("netif is DOWN");printf("%s is called\r\n", __FUNCTION__);
|
||||
restore_flags();
|
||||
return -1;
|
||||
}
|
||||
restore_flags();
|
||||
|
||||
#ifdef CONFIG_TX_ZERO_COPY
|
||||
data = rtw_malloc(1640);
|
||||
if(data == NULL){
|
||||
DBG_INFO("###########ERR_MEM at %s\r\n",__func__);
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Mac_data = data + 80;
|
||||
|
||||
for (last_sg = &sg_list[sg_len]; sg_list < last_sg; ++sg_list) {
|
||||
rtw_memcpy(Mac_data, (void *)(sg_list->buf), sg_list->len);
|
||||
Mac_data+=sg_list->len;
|
||||
}
|
||||
|
||||
skb = (struct sk_buff *)rltk_wlan_alloc_skb_0copy();
|
||||
if (skb == NULL) {
|
||||
DBG_INFO("rltk_wlan_alloc_skb()failed!\r\n");
|
||||
goto exit;
|
||||
}
|
||||
skb->data = data + 80;
|
||||
skb->head = data;
|
||||
skb->end = data + 1640;
|
||||
skb->tail = data + 80 + total_len;
|
||||
skb->len = total_len;
|
||||
ret = 0;
|
||||
#else
|
||||
skb = rltk_wlan_alloc_skb(total_len);
|
||||
#endif
|
||||
|
||||
if (skb == NULL) {
|
||||
DBG_INFO("rltk_wlan_alloc_skb() for data len=%d failed!", total_len);
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_TX_ZERO_COPY
|
||||
for (last_sg = &sg_list[sg_len]; sg_list < last_sg; ++sg_list) {
|
||||
//printf("sg_list len :%d \r\n", sg_list->len);
|
||||
rtw_memcpy(skb->tail, (void *)(sg_list->buf), sg_list->len);
|
||||
skb_put(skb, sg_list->len);
|
||||
}
|
||||
#endif
|
||||
|
||||
rltk_wlan_send_skb(idx, skb);
|
||||
|
||||
exit:
|
||||
save_and_cli();
|
||||
rltk_wlan_tx_dec(idx);
|
||||
restore_flags();
|
||||
return ret;
|
||||
//#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* rltk_wlan_recv - indicate packets to LWIP. Called by ethernetif_recv().
|
||||
* @idx: netif index
|
||||
* @sg_list: data buffer list
|
||||
* @sg_len: size of each data buffer
|
||||
*
|
||||
* Return Value: None
|
||||
*/
|
||||
int rltk_wlan_recv(int idx, struct eth_drv_sg *sg_list, int sg_len)
|
||||
{
|
||||
//#if (CONFIG_LWIP_LAYER == 1)
|
||||
struct eth_drv_sg *last_sg;
|
||||
struct sk_buff *skb;
|
||||
|
||||
DBG_TRACE("%s is called", __FUNCTION__);
|
||||
if(idx == -1){
|
||||
DBG_INFO("skb is NULL");
|
||||
return 0;
|
||||
}//printf("\r\n%s is called at:%d\r\n", __FUNCTION__, __LINE__);
|
||||
skb = rltk_wlan_get_recv_skb(idx);
|
||||
if (NULL == skb) {printf("\r\n%s is called at:%d\r\n", __FUNCTION__, __LINE__);
|
||||
//mdelay(10);
|
||||
return 0;
|
||||
}
|
||||
DBG_ASSERT(skb, "No pending rx skb");
|
||||
|
||||
for (last_sg = &sg_list[sg_len]; sg_list < last_sg; ++sg_list) {
|
||||
if (sg_list->buf != 0) {
|
||||
rtw_memcpy((void *)(sg_list->buf), skb->data, sg_list->len);
|
||||
skb_pull(skb, sg_list->len);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
//#endif
|
||||
}
|
||||
|
||||
int netif_is_valid_IP(int idx, unsigned char *ip_dest)
|
||||
{
|
||||
#if CONFIG_LWIP_LAYER == 1
|
||||
struct netif * pnetif = &xnetif[idx];
|
||||
|
||||
ip_addr_t addr = { 0 };
|
||||
|
||||
#if CONFIG_MEMORY_ACCESS_ALIGNED
|
||||
unsigned int temp;
|
||||
memcpy(&temp, ip_dest, sizeof(unsigned int));
|
||||
u32_t *ip_dest_addr = &temp;
|
||||
#else
|
||||
u32_t *ip_dest_addr = (u32_t*)ip_dest;
|
||||
#endif
|
||||
|
||||
#if LWIP_VERSION_MAJOR >= 2
|
||||
ip_addr_set_ip4_u32(&addr, *ip_dest_addr);
|
||||
#else
|
||||
addr.addr = *ip_dest_addr;
|
||||
#endif
|
||||
|
||||
#if LWIP_VERSION_MAJOR >= 2
|
||||
if((ip_addr_get_ip4_u32(netif_ip_addr4(pnetif))) == 0)
|
||||
return 1;
|
||||
#else
|
||||
|
||||
if(pnetif->ip_addr.addr == 0)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
if(ip_addr_ismulticast(&addr) || ip_addr_isbroadcast(&addr,pnetif)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
//if(ip_addr_netcmp(&(pnetif->ip_addr), &addr, &(pnetif->netmask))) //addr&netmask
|
||||
// return 1;
|
||||
|
||||
if(ip_addr_cmp(&(pnetif->ip_addr),&addr))
|
||||
return 1;
|
||||
|
||||
DBG_TRACE("invalid IP: %d.%d.%d.%d ",ip_dest[0],ip_dest[1],ip_dest[2],ip_dest[3]);
|
||||
#endif
|
||||
//printf("\r\nnet id:%d IP: %d.%d.%d.%d \r\n", idx, ip_dest[0], ip_dest[1], ip_dest[2], ip_dest[3]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int netif_get_idx(struct netif* pnetif)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
int idx = pnetif - xnetif;
|
||||
|
||||
switch(idx) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char *netif_get_hwaddr(int idx_wlan)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return xnetif[idx_wlan].hwaddr;
|
||||
#else
|
||||
return (unsigned char *)FreeRTOS_GetMACAddress();
|
||||
#endif
|
||||
}
|
||||
|
||||
void netif_rx(int idx, unsigned int len)
|
||||
{
|
||||
//printf("%s idx:%d len:%d\r\n", __func__, idx, len);
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
ethernetif_recv(&xnetif[idx], len);
|
||||
#else
|
||||
|
||||
NetworkBufferDescriptor_t * pxBufferDescriptor;
|
||||
IPStackEvent_t xRxEvent;
|
||||
int32_t xBytesReceived = len;
|
||||
int ret = -1;
|
||||
|
||||
pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( ( size_t ) xBytesReceived, 0 );
|
||||
|
||||
if( pxBufferDescriptor != NULL )
|
||||
{
|
||||
struct eth_drv_sg sg_list = {0};
|
||||
sg_list.buf = (unsigned int)pxBufferDescriptor->pucEthernetBuffer;
|
||||
sg_list.len = (unsigned int)xBytesReceived;
|
||||
ret = rltk_wlan_recv(0, &sg_list, 1);
|
||||
if (ret == 0) {
|
||||
printf("no rcv data\r\n");
|
||||
vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor );
|
||||
return;
|
||||
}
|
||||
#ifdef DUMP_NETWORK_RX_DATA
|
||||
if (1) {
|
||||
int i;
|
||||
char* tmp = (char *)pxBufferDescriptor->pucEthernetBuffer;
|
||||
printf("\r\n recv:");
|
||||
for (i = 0; i < sg_list.len; i++) {
|
||||
printf("%02x ", tmp[i]);
|
||||
}printf("recv end\r\n");
|
||||
}
|
||||
#endif
|
||||
//memcpy( pxBufferDescriptor->pucEthernetBuffer, buffer_pointer, ( size_t ) xBytesReceived );
|
||||
pxBufferDescriptor->xDataLength = ( size_t ) xBytesReceived;
|
||||
if( eConsiderFrameForProcessing( pxBufferDescriptor->pucEthernetBuffer ) == eProcessBuffer )
|
||||
{//printf("send eNetworkRxEvent\r\n");
|
||||
xRxEvent.eEventType = eNetworkRxEvent;
|
||||
xRxEvent.pvData = ( void * ) pxBufferDescriptor;
|
||||
if( xSendEventStructToIPTask( &xRxEvent, 0 ) == pdFALSE )
|
||||
{
|
||||
vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor );
|
||||
iptraceETHERNET_RX_EVENT_LOST();
|
||||
}
|
||||
else
|
||||
{
|
||||
iptraceNETWORK_INTERFACE_RECEIVE();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iptraceETHERNET_RX_EVENT_LOST();
|
||||
FreeRTOS_printf( ( "R_ETHER_Read_ZC2: Cleared descriptors\n" ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void netif_post_sleep_processing(void)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
lwip_POST_SLEEP_PROCESSING(); //For FreeRTOS tickless to enable Lwip ARP timer when leaving IPS - Alex Fang
|
||||
#endif
|
||||
}
|
||||
|
||||
void netif_pre_sleep_processing(void)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
lwip_PRE_SLEEP_PROCESSING();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_WOWLAN
|
||||
unsigned char *rltk_wlan_get_ip(int idx){
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return LwIP_GetIP(&xnetif[idx]);
|
||||
#else
|
||||
printf("rltk_wlan_get_ip\r\n");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
unsigned char *rltk_wlan_get_gw(int idx){
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return LwIP_GetGW(&xnetif[idx]);
|
||||
#else
|
||||
printf("rltk_wlan_get_gw\r\n");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char *rltk_wlan_get_gwmask(int idx){
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return LwIP_GetMASK(&xnetif[idx]);
|
||||
#else
|
||||
printf("rltk_wlan_get_gwmask\r\n");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
1387
lib/wlan/RTL8189FTV/os/os_dep/osdep_service.c
Normal file
1387
lib/wlan/RTL8189FTV/os/os_dep/osdep_service.c
Normal file
File diff suppressed because it is too large
Load Diff
279
lib/wlan/RTL8189FTV/platform/include/dlist.h
Normal file
279
lib/wlan/RTL8189FTV/platform/include/dlist.h
Normal file
@ -0,0 +1,279 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __LIST_H
|
||||
#define __LIST_H
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This file is from Linux Kernel (include/linux/list.h)
|
||||
* and modified by simply removing hardware prefetching of list items.
|
||||
* Here by copyright, credits attributed to wherever they belong.
|
||||
* Kulesh Shanmugasundaram (kulesh [squiggly] isis.poly.edu)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
#define INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_add(struct list_head *newitem,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = newitem;
|
||||
newitem->next = next;
|
||||
newitem->prev = prev;
|
||||
prev->next = newitem;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it after
|
||||
*
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
static inline void list_add(struct list_head *newitem, struct list_head *head)
|
||||
{
|
||||
__list_add(newitem, head, head->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it before
|
||||
*
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
static inline void list_add_tail(struct list_head *newitem, struct list_head *head)
|
||||
{
|
||||
__list_add(newitem, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
|
||||
*/
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = (struct list_head *) 0;
|
||||
entry->prev = (struct list_head *) 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del_init - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
static inline void list_del_init(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
INIT_LIST_HEAD(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move - delete from one list and add as another's head
|
||||
* @list: the entry to move
|
||||
* @head: the head that will precede our entry
|
||||
*/
|
||||
static inline void list_move(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move_tail - delete from one list and add as another's tail
|
||||
* @list: the entry to move
|
||||
* @head: the head that will follow our entry
|
||||
*/
|
||||
static inline void list_move_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add_tail(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
static inline void __list_splice(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice - join two lists
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
static inline void list_splice_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list_entry - get the struct for this entry
|
||||
* @ptr: the &struct list_head pointer.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
|
||||
|
||||
/**
|
||||
* list_first_entry - get the first element from a list
|
||||
* @ptr: the list head to take the element from.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*
|
||||
* Note, that list is expected to be not empty.
|
||||
*/
|
||||
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->next, type, member)
|
||||
|
||||
|
||||
/**
|
||||
* list_for_each - iterate over a list
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); \
|
||||
pos = pos->next)
|
||||
/**
|
||||
* list_for_each_prev - iterate over a list backwards
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); \
|
||||
pos = pos->prev)
|
||||
|
||||
/**
|
||||
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_entry - iterate over list of given type
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, type, member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member), \
|
||||
n = list_entry(pos->member.next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, type, member))
|
||||
|
||||
#endif
|
||||
|
17
lib/wlan/RTL8189FTV/platform/include/rtwlan_config.h
Normal file
17
lib/wlan/RTL8189FTV/platform/include/rtwlan_config.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __RTWLAN_CONFIG_H
|
||||
#define __RTWLAN_CONFIG_H
|
||||
#include "FreeRTOSConfig.h"
|
||||
#define CONFIG_PLATFOMR_CUSTOMER_RTOS
|
||||
#define DRV_NAME "rtl8189ftv"
|
||||
#define DRIVERVERSION "a05b84ef4f982c9b585df42799d158274f604318"
|
||||
|
||||
|
||||
#define CONFIG_DEBUG 1
|
||||
|
||||
#define CONFIG_THROUGHPUT_LEVEL 3
|
||||
#define CONFIG_TX_BUS_AGG_NUM 8
|
||||
#define CONFIG_RX_BUS_AGG_NUM 8
|
||||
#define MAX_TX_SKB_DATA_NUM 150
|
||||
#define CONFIG_ADDRESS_ALIGNMENT 1
|
||||
#define CONFIG_USE_INDEPENDENT_TX_BUS_AGG_DATA 1
|
||||
#endif
|
34
lib/wlan/RTL8189FTV/platform/rtwlan_bsp/rtwlan_bsp.c
Normal file
34
lib/wlan/RTL8189FTV/platform/rtwlan_bsp/rtwlan_bsp.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdint.h>
|
||||
#include "timer.h"
|
||||
|
||||
static inline void sys_ctl_delay(unsigned long ulCount)
|
||||
{
|
||||
while(ulCount--);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer provide us level delay
|
||||
* FreeRTOS does not provide us level delay. Use busy wait
|
||||
* It is CPU platform dependent
|
||||
*/
|
||||
|
||||
void WLAN_BSP_UsLoop(int us)
|
||||
{
|
||||
|
||||
//unsigned long nloops = us * (configCPU_CLOCK_HZ / 3000000);
|
||||
//sys_ctl_delay(nloops);
|
||||
udelay(us);
|
||||
|
||||
}
|
||||
|
||||
/* Customer function to control HW specific wlan gpios */
|
||||
void Set_WLAN_Power_On(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Customer function to control HW specific wlan gpios */
|
||||
void Set_WLAN_Power_Off(void)
|
||||
{
|
||||
|
||||
}
|
21
lib/wlan/RTL8189FTV/platform/rtwlan_bsp/rtwlan_bsp.h
Normal file
21
lib/wlan/RTL8189FTV/platform/rtwlan_bsp/rtwlan_bsp.h
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtwlan_bsp.h
|
||||
* @author Realtek software team
|
||||
* @version V0.1
|
||||
* @date 05-March-2013
|
||||
* @brief Realtek WLAN hardware configuration.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __REALTEK_WLAN_BSP_H__
|
||||
#define __REALTEK_WLAN_BSP_H__
|
||||
/* Includes ---------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void Set_WLAN_Power_On(void);
|
||||
void Set_WLAN_Power_Off(void);
|
||||
void WLAN_BSP_UsLoop(int us);
|
||||
|
||||
#endif// __REALTEK_WLAN_BSP_H__
|
11
lib/wlan/RTL8189FTV/platform/sdio/core/sdio_irq.h
Normal file
11
lib/wlan/RTL8189FTV/platform/sdio/core/sdio_irq.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef _MMC_SDIO_IRQ_H
|
||||
#define _MMC_SDIO_IRQ_H
|
||||
|
||||
//#include "../include/card.h"
|
||||
#include "mmcsd_card.h"
|
||||
|
||||
int sdio_claim_irq(struct sdio_func *func, void(*handler)(struct sdio_func *));
|
||||
int sdio_release_irq(struct sdio_func *func);
|
||||
void sdio_irq_thread(void* exinf);
|
||||
|
||||
#endif
|
76
lib/wlan/RTL8189FTV/platform/sdio/include/card.h
Normal file
76
lib/wlan/RTL8189FTV/platform/sdio/include/card.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef _MMC_SDIO_CARD_H
|
||||
#define _MMC_SDIO_CARD_H
|
||||
|
||||
#ifdef CONFIG_READ_CIS
|
||||
/*
|
||||
* SDIO function CIS tuple (unknown to the core)
|
||||
*/
|
||||
struct sdio_func_tuple {
|
||||
struct sdio_func_tuple *next;
|
||||
unsigned char code;
|
||||
unsigned char size;
|
||||
unsigned char data[0];
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SDIO function devices
|
||||
*/
|
||||
struct sdio_func {
|
||||
struct mmc_card *card; /* the card this device belongs to */
|
||||
void (*irq_handler)(struct sdio_func *); /* IRQ callback */
|
||||
|
||||
unsigned int max_blksize; /* maximum block size */ //add
|
||||
unsigned int cur_blksize; /* current block size */ //add
|
||||
unsigned int enable_timeout; /* max enable timeout in msec */ //add
|
||||
unsigned int num; /* function number *///add
|
||||
unsigned short vendor; /* vendor id */ //add
|
||||
unsigned short device; /* device id */ //add
|
||||
unsigned num_info; /* number of info strings */ //add
|
||||
const char **info; /* info strings */ //add
|
||||
unsigned char class; /* standard interface class *///add
|
||||
|
||||
unsigned int tmpbuf_reserved; //for tmpbuf 4 byte alignment
|
||||
unsigned char tmpbuf[4]; /* DMA:able scratch buffer */
|
||||
|
||||
#ifdef CONFIG_READ_CIS
|
||||
struct sdio_func_tuple *tuples;
|
||||
#endif
|
||||
void *drv_priv;
|
||||
};
|
||||
|
||||
struct sdio_cccr {
|
||||
unsigned int sdio_vsn;
|
||||
unsigned int sd_vsn;
|
||||
unsigned int multi_block:1;
|
||||
unsigned int low_speed:1;
|
||||
unsigned int wide_bus:1;
|
||||
unsigned int high_power:1;
|
||||
unsigned int high_speed:1;
|
||||
unsigned int disable_cd:1;
|
||||
};
|
||||
|
||||
struct sdio_cis {
|
||||
unsigned short vendor;
|
||||
unsigned short device;
|
||||
unsigned short blksize;
|
||||
unsigned int max_dtr;
|
||||
};
|
||||
|
||||
struct mmc_card {
|
||||
struct mmc_host *host; /* the host this device belongs to */
|
||||
struct sdio_cccr cccr; /* common card info */
|
||||
struct sdio_cis cis; /* common tuple info */ //add
|
||||
struct sdio_func *sdio_func[7]; /* SDIO functions (devices) *///add
|
||||
unsigned int sdio_funcs; /* number of SDIO functions *///add
|
||||
|
||||
unsigned int rca; /* relative card address of device */
|
||||
unsigned int type; /* card type */
|
||||
|
||||
unsigned num_info; /* number of info strings *///add
|
||||
const char **info; /* info strings *///add
|
||||
#ifdef CONFIG_READ_CIS
|
||||
struct sdio_func_tuple *tuples; /* unknown common tuples *///add
|
||||
#endif
|
||||
};
|
||||
#endif
|
260
lib/wlan/RTL8189FTV/platform/sdio/wifi_io.c
Normal file
260
lib/wlan/RTL8189FTV/platform/sdio/wifi_io.c
Normal file
@ -0,0 +1,260 @@
|
||||
//#include "include/common.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "board.h"
|
||||
#ifdef SDMMC_SUPPORT
|
||||
#include "sdio.h"
|
||||
#include "wifi_io.h"
|
||||
|
||||
|
||||
/* test wifi driver */
|
||||
#define ADDR_MASK 0x10000
|
||||
#define LOCAL_ADDR_MASK 0x00000
|
||||
|
||||
int sdio_bus_probe(void)
|
||||
{
|
||||
}
|
||||
int sdio_bus_remove(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void sdio_claim_host(struct sdio_func*func)
|
||||
{
|
||||
mmcsd_host_lock(func->card->host);
|
||||
}
|
||||
void sdio_release_host(struct sdio_func *func)
|
||||
{
|
||||
mmcsd_host_unlock(func->card->host);
|
||||
}
|
||||
|
||||
int32_t sdio_claim_irq(struct sdio_func *func,
|
||||
void(*handler)(struct sdio_func *))
|
||||
{
|
||||
return sdio_attach_irq(func, handler);
|
||||
}
|
||||
|
||||
int32_t sdio_release_irq(struct sdio_func *func)
|
||||
{
|
||||
return sdio_detach_irq(func);
|
||||
}
|
||||
|
||||
unsigned char sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret)
|
||||
{
|
||||
unsigned char ret;
|
||||
int32_t err = -1;
|
||||
ret = sdio_io_readb(func, addr, (int32_t *)&err);
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
if (err_ret)
|
||||
*err_ret = (int)err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void sdio_writeb(struct sdio_func *func, unsigned char b, unsigned int addr, int *err_ret)
|
||||
{
|
||||
int err = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
err= sdio_io_writeb(func, addr, b);
|
||||
if (NULL != err_ret)
|
||||
*err_ret = err;
|
||||
}
|
||||
|
||||
uint16_t sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret)
|
||||
{//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
return sdio_io_readw(func, addr, err_ret);
|
||||
}
|
||||
|
||||
void sdio_writew(struct sdio_func *func, uint16_t v, unsigned int addr, int *err_ret)
|
||||
{
|
||||
int err = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
err= sdio_io_writew(func, v, addr);
|
||||
if (NULL != err_ret)
|
||||
*err_ret = err;
|
||||
}
|
||||
|
||||
uint32_t sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret)
|
||||
{//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
return sdio_io_readl(func, addr, err_ret);
|
||||
}
|
||||
|
||||
void sdio_writel(struct sdio_func *func, uint32_t v, unsigned int addr, int *err_ret)
|
||||
{
|
||||
int err = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
err= sdio_io_writel(func, v, addr);
|
||||
if (NULL != err_ret)
|
||||
*err_ret = err;
|
||||
}
|
||||
#include "usb_os_adapter.h"
|
||||
int sdio_memcpy_fromio(struct sdio_func *func, void *dst,
|
||||
unsigned int addr, int count)
|
||||
{//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
return sdio_io_rw_extended_block(func, 0, addr, 1, (uint8_t *)dst, count);
|
||||
}
|
||||
|
||||
int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
|
||||
void *src, int count)
|
||||
{//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
//ALLOC_CACHE_ALIGN_BUFFER(char, dma_buf, 2048);
|
||||
//memcpy(dma_buf, src, count);
|
||||
return sdio_io_rw_extended_block(func, 1, addr, 1, (uint8_t *)src, count);
|
||||
}
|
||||
|
||||
int wifi_read(struct sdio_func *func, u32 addr, u32 cnt, void *pdata)
|
||||
{
|
||||
int err;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
|
||||
err = sdio_memcpy_fromio(func, pdata, (unsigned int)addr, (int)cnt);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL(%d)! ADDR=%#x Size=%d\n", __func__, err, addr, cnt);
|
||||
}
|
||||
|
||||
sdio_release_host(func);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int wifi_write(struct sdio_func *func, u32 addr, u32 cnt, void *pdata)
|
||||
{
|
||||
int err;
|
||||
u32 size;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
|
||||
size = cnt;
|
||||
err = sdio_memcpy_toio(func, addr, pdata, size);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL(%d)! ADDR=%#x Size=%d(%d)\n", __func__, err, addr, cnt, size);
|
||||
}
|
||||
|
||||
sdio_release_host(func);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
u8 wifi_readb(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u8 ret = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
ret = sdio_readb(func, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x\n", __func__, err, addr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
u16 wifi_readw(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u16 v;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
v = sdio_readw(func, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x\n", __func__, err, addr);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
u32 wifi_readl(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u32 v;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
v = sdio_readl(func, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
void wifi_writeb(struct sdio_func *func, u32 addr, u8 val)
|
||||
{
|
||||
int err;
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
sdio_writeb(func, val, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x val=0x%02x\n", __func__, err, addr, val);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_writew(struct sdio_func *func, u32 addr, u16 v)
|
||||
{
|
||||
int err;
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
sdio_writew(func, v, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x val=0x%04x\n", __func__, err, addr, v);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_writel(struct sdio_func *func, u32 addr, u32 v)
|
||||
{
|
||||
int err;
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
sdio_writel(func, v, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
}
|
||||
|
||||
u8 wifi_readb_local(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u8 ret = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
ret = sdio_readb(func, LOCAL_ADDR_MASK | addr, &err);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wifi_writeb_local(struct sdio_func *func, u32 addr, u8 val)
|
||||
{
|
||||
int err;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_writeb(func, val, LOCAL_ADDR_MASK | addr, &err);
|
||||
}
|
||||
extern int rtw_fake_driver_probe(struct sdio_func *func);
|
||||
void wifi_fake_driver_probe_rtlwifi(struct sdio_func *func)
|
||||
{printf("%s:%d\r\n", __func__, __LINE__);
|
||||
rtw_fake_driver_probe(func);//todo1
|
||||
}
|
||||
|
||||
extern int sdio_bus_probe(void);
|
||||
extern int sdio_bus_remove(void);
|
||||
SDIO_BUS_OPS rtw_sdio_bus_ops = {
|
||||
sdio_bus_probe,
|
||||
sdio_bus_remove,
|
||||
sdio_enable_func,
|
||||
sdio_disable_func,
|
||||
NULL,
|
||||
NULL,
|
||||
sdio_claim_irq,
|
||||
sdio_release_irq,
|
||||
sdio_claim_host,
|
||||
sdio_release_host,
|
||||
sdio_readb,
|
||||
sdio_readw,
|
||||
sdio_readl,
|
||||
sdio_writeb,
|
||||
sdio_writew,
|
||||
sdio_writel,
|
||||
sdio_memcpy_fromio,
|
||||
sdio_memcpy_toio
|
||||
};
|
||||
#endif
|
||||
|
62
lib/wlan/RTL8189FTV/platform/sdio/wifi_io.h
Normal file
62
lib/wlan/RTL8189FTV/platform/sdio/wifi_io.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef _WIFI_IO_H
|
||||
#define _WIFI_IO_H
|
||||
|
||||
//#include "core/sdio_irq.h"
|
||||
|
||||
struct sdio_driver {
|
||||
int fake;
|
||||
};
|
||||
|
||||
//#define sdio_func sdio_function
|
||||
#ifndef u32
|
||||
#define u32 uint32_t
|
||||
#endif
|
||||
#ifndef u16
|
||||
#define u16 uint16_t
|
||||
#endif
|
||||
#ifndef u8
|
||||
#define u8 uint8_t
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(_x) (1 << (_x))
|
||||
#endif
|
||||
int wifi_read(struct sdio_func *func, u32 addr, u32 cnt, void *pdata);
|
||||
int wifi_write(struct sdio_func *func, u32 addr, u32 cnt, void *pdata);
|
||||
u8 wifi_readb(struct sdio_func *func, u32 addr);
|
||||
u16 wifi_readw(struct sdio_func *func, u32 addr);
|
||||
u32 wifi_readl(struct sdio_func *func, u32 addr);
|
||||
void wifi_writeb(struct sdio_func *func, u32 addr, u8 val);
|
||||
void wifi_writew(struct sdio_func *func, u32 addr, u16 v);
|
||||
void wifi_writel(struct sdio_func *func, u32 addr, u32 v);
|
||||
u8 wifi_readb_local(struct sdio_func *func, u32 addr);
|
||||
void wifi_writeb_local(struct sdio_func *func, u32 addr, u8 val);
|
||||
|
||||
//typedef unsigned long UINT32;
|
||||
typedef struct _SDIO_BUS_OPS{
|
||||
int (*bus_probe)(void);
|
||||
int (*bus_remove)(void);
|
||||
int (*enable)(struct sdio_func*func); /*enables a SDIO function for usage*/
|
||||
int (*disable)(struct sdio_func *func);
|
||||
int (*reg_driver)(struct sdio_driver*); /*register sdio function device driver callback*/
|
||||
void (*unreg_driver)(struct sdio_driver *);
|
||||
int (*claim_irq)(struct sdio_func *func, void(*handler)(struct sdio_func *));
|
||||
int (*release_irq)(struct sdio_func*func);
|
||||
void (*claim_host)(struct sdio_func*func); /*exclusively claim a bus for a certain SDIO function*/
|
||||
void (*release_host)(struct sdio_func *func);
|
||||
unsigned char (*readb)(struct sdio_func *func, unsigned int addr, int *err_ret);/*read a single byte from a SDIO function*/
|
||||
unsigned short (*readw)(struct sdio_func *func, unsigned int addr, int *err_ret); /*read a 16 bit integer from a SDIO function*/
|
||||
unsigned int (*readl)(struct sdio_func *func, unsigned int addr, int *err_ret); /*read a 32 bit integer from a SDIO function*/
|
||||
void (*writeb)(struct sdio_func *func, unsigned char b,unsigned int addr, int *err_ret); /*write a single byte to a SDIO function*/
|
||||
void (*writew)(struct sdio_func *func, unsigned short b,unsigned int addr, int *err_ret); /*write a 16 bit integer to a SDIO function*/
|
||||
void (*writel)(struct sdio_func *func, unsigned int b,unsigned int addr, int *err_ret); /*write a 32 bit integer to a SDIO function*/
|
||||
int (*memcpy_fromio)(struct sdio_func *func, void *dst,unsigned int addr, int count);/*read a chunk of memory from a SDIO functio*/
|
||||
int (*memcpy_toio)(struct sdio_func *func, unsigned int addr,void *src, int count); /*write a chunk of memory to a SDIO function*/
|
||||
}SDIO_BUS_OPS;
|
||||
|
||||
extern SDIO_BUS_OPS rtw_sdio_bus_ops;
|
||||
extern struct sdio_func *wifi_sdio_func;
|
||||
extern int sdio_bus_probe(void);
|
||||
extern int sdio_bus_remove(void);
|
||||
#endif
|
||||
|
454
lib/wlan/RTL8189FTV/platform/usb/usb_io_realtek.c
Normal file
454
lib/wlan/RTL8189FTV/platform/usb/usb_io_realtek.c
Normal file
@ -0,0 +1,454 @@
|
||||
#include "usb_io_realtek.h"
|
||||
|
||||
#define REALTEK_USB_VENQT_READ 0xC0
|
||||
#define REALTEK_USB_VENQT_WRITE 0x40
|
||||
#define RTW_USB_CONTROL_MSG_TIMEOUT 500//ms
|
||||
|
||||
#define FW_START_ADDRESS 0x1000
|
||||
#define VENDOR_CMD_MAX_DATA_LEN 254
|
||||
|
||||
#define ALIGNMENT_UNIT 32
|
||||
#define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */
|
||||
#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(_x) (1 << (_x))
|
||||
#endif
|
||||
|
||||
struct rtw_urb
|
||||
{
|
||||
struct urb urb;
|
||||
bool is_used;
|
||||
};
|
||||
|
||||
#define MaxurbNum 40
|
||||
static struct rtw_urb rtw_urb_read[MaxurbNum];
|
||||
static struct rtw_urb rtw_urb_write[MaxurbNum];
|
||||
|
||||
int rtw_usb_rcvctrlpipe(struct usb_device *dev, u32 endpoint)
|
||||
{
|
||||
return usb_rcvctrlpipe(dev,endpoint);
|
||||
}
|
||||
int rtw_usb_sndctrlpipe(struct usb_device *dev, u32 endpoint)
|
||||
{
|
||||
return usb_sndctrlpipe(dev,endpoint);
|
||||
}
|
||||
int rtw_usb_get_bulk_in_pipe(void *priv,unsigned char ep_addr)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
return usb_rcvbulkpipe(udev,ep_addr);
|
||||
}
|
||||
int rtw_usb_get_bulk_out_pipe(void *priv,unsigned char ep_addr)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
return usb_sndbulkpipe(udev,ep_addr);
|
||||
}
|
||||
struct urb * rtw_usb_alloc_urb(u16 iso_packets, int mem_flags)
|
||||
{
|
||||
//return usb_alloc_urb(iso_packets,mem_flags);
|
||||
return usb_alloc_urb(iso_packets); //xhl
|
||||
}
|
||||
void rtw_usb_free_urb(struct urb *urb)
|
||||
{
|
||||
usb_free_urb(urb);
|
||||
}
|
||||
void rtw_usb_kill_urb(struct urb *urb)
|
||||
{
|
||||
usb_kill_urb(urb);
|
||||
}
|
||||
int rtw_usb_submit_urb(struct urb *urb, int mem_flags)
|
||||
{
|
||||
// return usb_submit_urb(urb, mem_flags);
|
||||
return usb_submit_urb(urb); //xhl
|
||||
}
|
||||
void rtw_usb_fill_bulk_urb(struct urb *urb,struct usb_device *pDev,u32 Pipe,void *pTransferBuffer,s32 Length,usb_complete_t tCompleteFunc,void *pContext)
|
||||
{
|
||||
usb_fill_bulk_urb(urb,pDev, Pipe,pTransferBuffer,Length, tCompleteFunc,pContext);
|
||||
}
|
||||
int rtw_usb_register(struct usb_driver *driver)
|
||||
{
|
||||
return usb_register_driver(driver);
|
||||
}
|
||||
void rtw_usb_deregister(struct usb_driver *driver)
|
||||
{
|
||||
usb_deregister(driver);
|
||||
}
|
||||
|
||||
int usbctrl_vendorreq(void *priv,unsigned char bdir_in,unsigned short value,unsigned char *buf,unsigned int len)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
unsigned char request = 0x05;
|
||||
unsigned int pipe;
|
||||
int status = 0;
|
||||
unsigned char reqtype;
|
||||
unsigned char *pIo_buf;
|
||||
int vendorreq_times = 0;
|
||||
|
||||
unsigned char tmp_buf[MAX_USB_IO_CTL_SIZE];
|
||||
|
||||
/* Acquire IO memory for vendorreq */
|
||||
|
||||
if (len > MAX_VENDOR_REQ_CMD_SIZE) {
|
||||
printf("[%s] Buffer len error ,vendor request failed\n", __FUNCTION__);
|
||||
status = -22;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Added by Albert 2010/02/09 */
|
||||
/* For mstar platform, mstar suggests the address for USB IO should be 32 bytes alignment. */
|
||||
/* Trying to fix it here. */
|
||||
pIo_buf = tmp_buf + ALIGNMENT_UNIT - ((unsigned int)(tmp_buf) & 0x1f);//32字节对齐
|
||||
|
||||
while (++vendorreq_times <= 10) {
|
||||
rtw_memset(pIo_buf, 0, len);
|
||||
|
||||
if (bdir_in == 0x01) {
|
||||
pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
|
||||
reqtype = REALTEK_USB_VENQT_READ;
|
||||
} else {
|
||||
pipe = usb_sndctrlpipe(udev, 0);/* write_out */
|
||||
reqtype = REALTEK_USB_VENQT_WRITE;
|
||||
rtw_memcpy(pIo_buf, buf, len);
|
||||
}
|
||||
status = usb_control_msg(udev, pipe, request, reqtype, value, 0, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
|
||||
|
||||
if (status == len) { /* Success this control transfer. */
|
||||
if (bdir_in == 0x01) {
|
||||
/* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */
|
||||
rtw_memcpy(buf, pIo_buf, len);
|
||||
}
|
||||
} else { /* error cases */
|
||||
printf("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n"
|
||||
, value, (bdir_in == 0x01) ? "read" : "write" , len, status, *(u32 *)buf, vendorreq_times);
|
||||
}
|
||||
/* firmware download is checksumed, don't retry */
|
||||
if ((value >= FW_START_ADDRESS) || status == len)
|
||||
break;
|
||||
}
|
||||
exit:
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
extern void usb_read_port_complete(void *arg, unsigned int result);
|
||||
static int rtw_usb_read_complete(struct urb* purb)
|
||||
{
|
||||
int i =0;
|
||||
usb_read_port_complete(purb->context, purb->actual_length);
|
||||
if (purb->status != 0){
|
||||
printf("\r\n###=> rtw_usb_read_port_complete => urb.status(%d)\n", purb->status);
|
||||
}
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(&(rtw_urb_read[i].urb) == purb){
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_read[i].urb));
|
||||
rtw_urb_read[i].is_used = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i ==MaxurbNum ){
|
||||
printf("\r\n Error: some urb pointer we want read have not recored!");
|
||||
}
|
||||
usb_free_urb(purb);
|
||||
return purb->status;
|
||||
}
|
||||
|
||||
static int rtw_usb_bulk_in(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete_t callback,void *arg){
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
int status;
|
||||
int i = 0;
|
||||
struct urb *purb;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(!(rtw_urb_read[i].is_used)){
|
||||
rtw_urb_read[i].is_used = 1; //set the used to 1 first then use it
|
||||
purb = &rtw_urb_read[i].urb;
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_read[i].urb));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == MaxurbNum)
|
||||
printf("\r\n Error: something error in urb allocate in %s",__func__);
|
||||
|
||||
usb_fill_bulk_urb(purb,
|
||||
udev,
|
||||
pipe,
|
||||
buf,
|
||||
len,
|
||||
rtw_usb_read_complete,
|
||||
arg);
|
||||
status = usb_submit_urb(purb);
|
||||
return status;
|
||||
}
|
||||
|
||||
extern void usb_write_port_complete(void *arg, unsigned int result);
|
||||
static int rtw_usb_write_complete(struct urb* purb)
|
||||
{
|
||||
int i = 0;
|
||||
if (purb->status == 0){
|
||||
usb_write_port_complete(purb->context, purb->actual_length);
|
||||
}else{
|
||||
printf("\r\n###=> rtw_usb_write_port_complete => urb.status(%d)\n", purb->status);
|
||||
}
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(&(rtw_urb_write[i].urb) == purb){
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_write[i].urb));
|
||||
rtw_urb_write[i].is_used = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i ==MaxurbNum ){
|
||||
printf("\r\n Error: some urb pointer we want write have not recored!");
|
||||
}
|
||||
usb_free_urb(purb);
|
||||
return purb->status;
|
||||
}
|
||||
|
||||
static int rtw_usb_bulk_out(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete callback,void *arg){
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
int status;
|
||||
int i = 0;
|
||||
struct urb *purb;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(!(rtw_urb_write[i].is_used)){
|
||||
rtw_urb_write[i].is_used = 1; //set the used to 1 first then use it
|
||||
purb = &(rtw_urb_write[i].urb);
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_write[i].urb));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == MaxurbNum)
|
||||
printf("\r\n Error: something error in urb allocate in %s",__func__);
|
||||
usb_fill_bulk_urb(purb,
|
||||
udev,
|
||||
pipe,
|
||||
buf,
|
||||
len,
|
||||
rtw_usb_write_complete,
|
||||
arg);
|
||||
status = usb_submit_urb(purb);
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
static int rtw_usb_cancel_bulk_out(void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
int i = 0;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(rtw_urb_write[i].is_used){
|
||||
usb_kill_urb(&(rtw_urb_write[i].urb));
|
||||
rtw_memset(&(rtw_urb_write[i].urb), 0, sizeof(rtw_urb_write[i].urb));
|
||||
rtw_urb_write[i].is_used = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_usb_cancel_bulk_in(void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
int i = 0;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(rtw_urb_read[i].is_used){
|
||||
usb_kill_urb(&(rtw_urb_read[i].urb));
|
||||
rtw_memset(&(rtw_urb_read[i].urb), 0, sizeof(rtw_urb_read[i].urb));
|
||||
rtw_urb_read[i].is_used = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_usb_ctrl_req(void *priv,unsigned char bdir_in,unsigned short wvalue,unsigned char *buf,unsigned int len)
|
||||
{
|
||||
return usbctrl_vendorreq(priv,bdir_in,wvalue,buf,len);
|
||||
}
|
||||
|
||||
enum RTW_USB_SPEED {
|
||||
RTW_USB_SPEED_UNKNOWN = 0,
|
||||
RTW_USB_SPEED_1_1 = 1,
|
||||
RTW_USB_SPEED_2 = 2,
|
||||
RTW_USB_SPEED_3 = 3,
|
||||
};
|
||||
|
||||
static inline int RT_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
static inline u8 RT_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return RT_usb_endpoint_xfer_int(epd) && RT_usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
static inline u8 RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
||||
}
|
||||
|
||||
|
||||
void rtw_usb_disendpoint(u8 nr_endpoint,void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *pusbd = pusb_intf->usb_dev;
|
||||
struct usb_host_interface *phost_iface;
|
||||
struct usb_host_endpoint *phost_endp;
|
||||
int i;
|
||||
phost_iface = &pusb_intf->altsetting[0];
|
||||
for (i = 0; i < nr_endpoint; i++) {
|
||||
phost_endp = phost_iface->endpoint + i;
|
||||
if (phost_endp) {
|
||||
usb_hcd_disable_endpoint(pusbd, phost_endp);
|
||||
}
|
||||
}
|
||||
pusb_intf->user_data = NULL;
|
||||
}
|
||||
|
||||
|
||||
static int rtw_usb_get_speed_info(void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *pusbd;
|
||||
pusbd = pusb_intf->usb_dev;
|
||||
int speed;
|
||||
switch (pusbd->speed) {
|
||||
case 1:
|
||||
printf("Low Speed Case \n");
|
||||
(speed) = RTW_USB_SPEED_1_1;
|
||||
break;
|
||||
case 2:
|
||||
printf("full speed Case \n");
|
||||
(speed) = RTW_USB_SPEED_1_1;
|
||||
break;
|
||||
case 3:
|
||||
printf("high speed Case \n");
|
||||
(speed) = RTW_USB_SPEED_2;
|
||||
break;
|
||||
default:
|
||||
(speed) = RTW_USB_SPEED_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
if ((speed) == RTW_USB_SPEED_UNKNOWN)
|
||||
pusb_intf->user_data = NULL;
|
||||
return speed;
|
||||
}
|
||||
|
||||
static int rtw_usb_get_in_ep_info(void *priv,unsigned char *pipe_num_arrays)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_host_endpoint *phost_endp;
|
||||
struct usb_endpoint_descriptor *pendp_desc;
|
||||
struct usb_host_interface *phost_iface;
|
||||
struct usb_interface_descriptor *piface_desc;
|
||||
int NumInPipes = 0;
|
||||
int nr_endpoint;
|
||||
int i;
|
||||
phost_iface = &pusb_intf->cur_altsetting[0];
|
||||
piface_desc = &phost_iface->desc;
|
||||
nr_endpoint = piface_desc->bNumEndpoints;
|
||||
for (i = 0; i < (nr_endpoint); i++) {
|
||||
phost_endp = phost_iface->endpoint + i;
|
||||
if (phost_endp) {
|
||||
pendp_desc = &phost_endp->desc;
|
||||
printf("\nusb_endpoint_descriptor(%d):\n", i);
|
||||
printf("bLength=%x\n", pendp_desc->bLength);
|
||||
printf("bDescriptorType=%x\n", pendp_desc->bDescriptorType);
|
||||
printf("bEndpointAddress=%x\n", pendp_desc->bEndpointAddress);
|
||||
printf("wMaxPacketSize=%d\n", pendp_desc->wMaxPacketSize);
|
||||
printf("bInterval=%x\n", pendp_desc->bInterval);
|
||||
if (RT_usb_endpoint_is_bulk_in(pendp_desc)) {
|
||||
pipe_num_arrays[NumInPipes] = RT_usb_endpoint_num(pendp_desc);
|
||||
(NumInPipes)++;
|
||||
} else if (RT_usb_endpoint_is_int_in(pendp_desc)) {
|
||||
printf("\r\n RT_usb_endpoint_is_int_in = %x, Interval = %x", RT_usb_endpoint_num(pendp_desc), pendp_desc->bInterval);
|
||||
pipe_num_arrays[NumInPipes] = RT_usb_endpoint_num(pendp_desc);
|
||||
(NumInPipes)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NumInPipes;
|
||||
}
|
||||
static int rtw_usb_get_out_ep_info(void *priv,u8 *pipe_num_array)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_host_endpoint *phost_endp;
|
||||
struct usb_endpoint_descriptor *pendp_desc;
|
||||
struct usb_host_interface *phost_iface;
|
||||
struct usb_interface_descriptor *piface_desc;
|
||||
int NumOutPipes = 0;
|
||||
int nr_endpoint;
|
||||
int i;
|
||||
phost_iface = &pusb_intf->cur_altsetting[0];
|
||||
piface_desc = &phost_iface->desc;
|
||||
nr_endpoint = piface_desc->bNumEndpoints;
|
||||
for (i = 0; i < (nr_endpoint); i++) {
|
||||
phost_endp = phost_iface->endpoint + i;
|
||||
if (phost_endp) {
|
||||
pendp_desc = &phost_endp->desc;
|
||||
if (RT_usb_endpoint_is_bulk_out(pendp_desc)) {
|
||||
printf("\r\n RT_usb_endpoint_is_bulk_out = %x\n", RT_usb_endpoint_num(pendp_desc));
|
||||
pipe_num_array[NumOutPipes] = RT_usb_endpoint_num(pendp_desc);
|
||||
(NumOutPipes)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NumOutPipes;
|
||||
}
|
||||
|
||||
|
||||
extern USB_BUS_OPS rtw_usb_bus_ops= {
|
||||
rtw_usb_register,
|
||||
rtw_usb_deregister,
|
||||
rtw_usb_disendpoint,
|
||||
rtw_usb_ctrl_req,
|
||||
rtw_usb_get_speed_info,
|
||||
rtw_usb_get_in_ep_info,
|
||||
rtw_usb_get_out_ep_info,
|
||||
rtw_usb_get_bulk_in_pipe,
|
||||
rtw_usb_get_bulk_out_pipe,
|
||||
rtw_usb_bulk_in,
|
||||
rtw_usb_bulk_out,
|
||||
rtw_usb_cancel_bulk_in,
|
||||
rtw_usb_cancel_bulk_out,
|
||||
};
|
||||
|
31
lib/wlan/RTL8189FTV/platform/usb/usb_io_realtek.h
Normal file
31
lib/wlan/RTL8189FTV/platform/usb/usb_io_realtek.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef _USB_IO_REALTEK_H
|
||||
#define _USB_IO_REALTEK_H
|
||||
|
||||
#include "customer_rtos_service.h"
|
||||
|
||||
#include <usb.h>
|
||||
typedef struct USB_DATA_S{
|
||||
void *usb_intf;
|
||||
}USB_DATA,*PUSB_DATA;
|
||||
typedef void (*usb_complete)(void *arg, unsigned int result);
|
||||
|
||||
|
||||
typedef struct _USB_BUS_OPS{
|
||||
int (*register_drv)(struct usb_driver *driver);
|
||||
void (*deregister_drv)(struct usb_driver *driver);
|
||||
void (*usb_disendpoint)(u8 nr_endpoint,void *priv);
|
||||
int (*usb_ctrl_req)(void *priv,unsigned char bdir_in,unsigned short wvalue,unsigned char *buf,unsigned int len);
|
||||
int (*usb_get_speed_info)(void *priv);
|
||||
int (*usb_get_in_ep_info)(void *priv,unsigned char *pipe_num_array);
|
||||
int (*usb_get_out_ep_info)(void *priv,unsigned char *pipe_num_array);
|
||||
unsigned char(*usb_get_bulk_in_pipe)(void *priv,unsigned char ep_addr);
|
||||
unsigned char(*usb_get_bulk_out_pipe)(void *priv,unsigned char ep_addr);
|
||||
int (*usb_bulk_in)(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete callback,void *arg);
|
||||
int (*usb_bulk_out)(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete callback,void *arg);
|
||||
int (*usb_cancel_bulk_in)(void *priv);
|
||||
int (*usb_cancel_bulk_out)(void *priv);
|
||||
}USB_BUS_OPS;
|
||||
|
||||
|
||||
extern USB_BUS_OPS rtw_usb_bus_ops;
|
||||
#endif
|
BIN
lib/wlan/RTL8189FTV/wlan_lib/wlan_lib_v1.0.a
Normal file
BIN
lib/wlan/RTL8189FTV/wlan_lib/wlan_lib_v1.0.a
Normal file
Binary file not shown.
592
lib/wlan/rtl8821cs/api/wifi/rtw_wpa_supplicant/src/utils/os.h
Normal file
592
lib/wlan/rtl8821cs/api/wifi/rtw_wpa_supplicant/src/utils/os.h
Normal file
@ -0,0 +1,592 @@
|
||||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef OS_H
|
||||
#define OS_H
|
||||
|
||||
//#include "basic_types.h"
|
||||
#include <autoconf.h>
|
||||
#include "osdep_service.h"
|
||||
//#include "customer_rtos/wrapper.h"
|
||||
#include "utils/rom/rom_wps_os.h"
|
||||
|
||||
|
||||
typedef void* xqueue_handle_t;
|
||||
|
||||
typedef long os_time_t;
|
||||
|
||||
typedef _timer os_timer;
|
||||
|
||||
/**
|
||||
* os_sleep - Sleep (sec, usec)
|
||||
* @sec: Number of seconds to sleep
|
||||
* @usec: Number of microseconds to sleep
|
||||
*/
|
||||
void os_sleep(os_time_t sec, os_time_t usec);
|
||||
|
||||
struct os_time {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
struct os_reltime {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
/**
|
||||
* os_get_time - Get current time (sec, usec)
|
||||
* @t: Pointer to buffer for the time
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_time(struct os_time *t);
|
||||
|
||||
int os_get_reltime(struct os_reltime *t);
|
||||
/* Helper macros for handling struct os_time */
|
||||
/* (&timeout->time, &tmp->time) */
|
||||
#define os_time_before(a, b) \
|
||||
((a)->sec < (b)->sec || \
|
||||
((a)->sec == (b)->sec && (a)->usec < (b)->usec))
|
||||
|
||||
#define os_time_sub(a, b, res) do { \
|
||||
(res)->sec = (a)->sec - (b)->sec; \
|
||||
(res)->usec = (a)->usec - (b)->usec; \
|
||||
if ((res)->usec < 0) { \
|
||||
(res)->sec--; \
|
||||
(res)->usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* os_mktime - Convert broken-down time into seconds since 1970-01-01
|
||||
* @year: Four digit year
|
||||
* @month: Month (1 .. 12)
|
||||
* @day: Day of month (1 .. 31)
|
||||
* @hour: Hour (0 .. 23)
|
||||
* @min: Minute (0 .. 59)
|
||||
* @sec: Second (0 .. 60)
|
||||
* @t: Buffer for returning calendar time representation (seconds since
|
||||
* 1970-01-01 00:00:00)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* Note: The result is in seconds from Epoch, i.e., in UTC, not in local time
|
||||
* which is used by POSIX mktime().
|
||||
*/
|
||||
int os_mktime(int year, int month, int day, int hour, int min, int sec,
|
||||
os_time_t *t);
|
||||
|
||||
struct os_tm {
|
||||
int sec; /* 0..59 or 60 for leap seconds */
|
||||
int min; /* 0..59 */
|
||||
int hour; /* 0..23 */
|
||||
int day; /* 1..31 */
|
||||
int month; /* 1..12 */
|
||||
int year; /* Four digit year */
|
||||
};
|
||||
|
||||
int os_gmtime(os_time_t t, struct os_tm *tm);
|
||||
|
||||
/* Helpers for handling struct os_time */
|
||||
|
||||
/* Helpers for handling struct os_reltime */
|
||||
|
||||
static inline int os_reltime_before(struct os_reltime *a,
|
||||
struct os_reltime *b)
|
||||
{
|
||||
return os_time_before(a,b);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_sub(struct os_reltime *a, struct os_reltime *b,
|
||||
struct os_reltime *res)
|
||||
{
|
||||
os_time_sub(a,b,res);
|
||||
}
|
||||
|
||||
|
||||
static inline void os_reltime_age(struct os_reltime *start,
|
||||
struct os_reltime *age)
|
||||
{
|
||||
struct os_reltime now;
|
||||
|
||||
os_get_time((struct os_time *)&now);
|
||||
os_reltime_sub(&now, start, age);
|
||||
}
|
||||
|
||||
|
||||
static inline int os_reltime_expired(struct os_reltime *now,
|
||||
struct os_reltime *ts,
|
||||
os_time_t timeout_secs)
|
||||
{
|
||||
struct os_reltime age;
|
||||
|
||||
os_reltime_sub(now, ts, &age);
|
||||
return (age.sec > timeout_secs) ||
|
||||
(age.sec == timeout_secs && age.usec > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* os_daemonize - Run in the background (detach from the controlling terminal)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_daemonize(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_daemonize_terminate - Stop running in the background (remove pid file)
|
||||
* @pid_file: File name to write the process ID to or %NULL to skip this
|
||||
*/
|
||||
void os_daemonize_terminate(const char *pid_file);
|
||||
|
||||
/**
|
||||
* os_get_random - Get cryptographically strong pseudo random data
|
||||
* @buf: Buffer for pseudo random data
|
||||
* @len: Length of the buffer
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
int os_get_random(unsigned char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* os_random - Get pseudo random value (not necessarily very strong)
|
||||
* Returns: Pseudo random value
|
||||
*/
|
||||
unsigned long os_random(void);
|
||||
|
||||
/**
|
||||
* os_rel2abs_path - Get an absolute path for a file
|
||||
* @rel_path: Relative path to a file
|
||||
* Returns: Absolute path for the file or %NULL on failure
|
||||
*
|
||||
* This function tries to convert a relative path of a file to an absolute path
|
||||
* in order for the file to be found even if current working directory has
|
||||
* changed. The returned value is allocated and caller is responsible for
|
||||
* freeing it. It is acceptable to just return the same path in an allocated
|
||||
* buffer, e.g., return strdup(rel_path). This function is only used to find
|
||||
* configuration files when os_daemonize() may have changed the current working
|
||||
* directory and relative path would be pointing to a different location.
|
||||
*/
|
||||
char * os_rel2abs_path(const char *rel_path);
|
||||
|
||||
/**
|
||||
* os_program_init - Program initialization (called at start)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
* This function is called when a programs starts. If there are any OS specific
|
||||
* processing that is needed, it can be placed here. It is also acceptable to
|
||||
* just return 0 if not special processing is needed.
|
||||
*/
|
||||
int os_program_init(void);
|
||||
|
||||
/**
|
||||
* os_program_deinit - Program deinitialization (called just before exit)
|
||||
*
|
||||
* This function is called just before a program exists. If there are any OS
|
||||
* specific processing, e.g., freeing resourced allocated in os_program_init(),
|
||||
* it should be done here. It is also acceptable for this function to do
|
||||
* nothing.
|
||||
*/
|
||||
void os_program_deinit(void);
|
||||
|
||||
/**
|
||||
* os_setenv - Set environment variable
|
||||
* @name: Name of the variable
|
||||
* @value: Value to set to the variable
|
||||
* @overwrite: Whether existing variable should be overwritten
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_setenv(const char *name, const char *value, int overwrite);
|
||||
|
||||
/**
|
||||
* os_unsetenv - Delete environent variable
|
||||
* @name: Name of the variable
|
||||
* Returns: 0 on success, -1 on error
|
||||
*
|
||||
* This function is only used for wpa_cli action scripts. OS wrapper does not
|
||||
* need to implement this if such functionality is not needed.
|
||||
*/
|
||||
int os_unsetenv(const char *name);
|
||||
|
||||
/**
|
||||
* os_readfile - Read a file to an allocated memory buffer
|
||||
* @name: Name of the file to read
|
||||
* @len: For returning the length of the allocated buffer
|
||||
* Returns: Pointer to the allocated buffer or %NULL on failure
|
||||
*
|
||||
* This function allocates memory and reads the given file to this buffer. Both
|
||||
* binary and text files can be read with this function. The caller is
|
||||
* responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char * os_readfile(const char *name, size_t *len);
|
||||
|
||||
//#if 0
|
||||
/**
|
||||
* os_zalloc - Allocate and zero memory
|
||||
* @size: Number of bytes to allocate
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_zalloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_calloc - Allocate and zero memory for an array
|
||||
* @nmemb: Number of members in the array
|
||||
* @size: Number of bytes in each member
|
||||
* Returns: Pointer to allocated and zeroed memory or %NULL on failure
|
||||
*
|
||||
* This function can be used as a wrapper for os_zalloc(nmemb * size) when an
|
||||
* allocation is used for an array. The main benefit over os_zalloc() is in
|
||||
* having an extra check to catch integer overflows in multiplication.
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
static inline void * os_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
return os_zalloc(nmemb * size);
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
static inline int os_memcmp_const(const void *a, const void *b, size_t len)
|
||||
{
|
||||
const u8 *aa = a;
|
||||
const u8 *bb = b;
|
||||
size_t i;
|
||||
u8 res;
|
||||
|
||||
for (res = 0, i = 0; i < len; i++)
|
||||
res |= aa[i] ^ bb[i];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following functions are wrapper for standard ANSI C or POSIX functions.
|
||||
* By default, they are just defined to use the standard function name and no
|
||||
* os_*.c implementation is needed for them. This avoids extra function calls
|
||||
* by allowing the C pre-processor take care of the function name mapping.
|
||||
*
|
||||
* If the target system uses a C library that does not provide these functions,
|
||||
* build_config.h can be used to define the wrappers to use a different
|
||||
* function name. This can be done on function-by-function basis since the
|
||||
* defines here are only used if build_config.h does not define the os_* name.
|
||||
* If needed, os_*.c file can be used to implement the functions that are not
|
||||
* included in the C library on the target system. Alternatively,
|
||||
* OS_NO_C_LIB_DEFINES can be defined to skip all defines here in which case
|
||||
* these functions need to be implemented in os_*.c file for the target system.
|
||||
*/
|
||||
|
||||
#ifdef OS_NO_C_LIB_DEFINES
|
||||
|
||||
/**
|
||||
* os_malloc - Allocate dynamic memory
|
||||
* @size: Size of the buffer to allocate
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
void * os_malloc(size_t size);
|
||||
|
||||
/**
|
||||
* os_realloc - Re-allocate dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc()
|
||||
* @size: Size of the new buffer
|
||||
* Returns: Allocated buffer or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
* If re-allocation fails, %NULL is returned and the original buffer (ptr) is
|
||||
* not freed and caller is still responsible for freeing it.
|
||||
*/
|
||||
void * os_realloc(void *ptr, size_t size);
|
||||
|
||||
/**
|
||||
* os_free - Free dynamic memory
|
||||
* @ptr: Old buffer from os_malloc() or os_realloc(); can be %NULL
|
||||
*/
|
||||
void os_free(void *ptr);
|
||||
|
||||
/**
|
||||
* os_memcpy - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst must not overlap. os_memmove() can be used with
|
||||
* overlapping memory.
|
||||
*/
|
||||
void * os_memcpy(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memmove - Copy memory area
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Number of bytes to copy
|
||||
* Returns: dest
|
||||
*
|
||||
* The memory areas src and dst may overlap.
|
||||
*/
|
||||
void *os_memmove(void *dest, const void *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_memset - Fill memory with a constant byte
|
||||
* @s: Memory area to be filled
|
||||
* @c: Constant byte
|
||||
* @n: Number of bytes started from s to fill with c
|
||||
* Returns: s
|
||||
*/
|
||||
void *os_memset(void *s, int c, size_t n);
|
||||
|
||||
/**
|
||||
* os_memcmp - Compare memory areas
|
||||
* @s1: First buffer
|
||||
* @s2: Second buffer
|
||||
* @n: Maximum numbers of octets to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_memcmp(const void *s1, const void *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strdup - Duplicate a string
|
||||
* @s: Source string
|
||||
* Returns: Allocated buffer with the string copied into it or %NULL on failure
|
||||
*
|
||||
* Caller is responsible for freeing the returned buffer with os_free().
|
||||
*/
|
||||
char *os_strdup(const char *s);
|
||||
|
||||
/**
|
||||
* os_strlen - Calculate the length of a string
|
||||
* @s: '\0' terminated string
|
||||
* Returns: Number of characters in s (not counting the '\0' terminator)
|
||||
*/
|
||||
size_t os_strlen(const char *s);
|
||||
|
||||
/**
|
||||
* os_strcasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcasecmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncasecmp - Compare two strings ignoring case
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strchr - Locate the first occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strrchr - Locate the last occurrence of a character in string
|
||||
* @s: String
|
||||
* @c: Character to search for
|
||||
* Returns: Pointer to the matched character or %NULL if not found
|
||||
*/
|
||||
char *os_strrchr(const char *s, int c);
|
||||
|
||||
/**
|
||||
* os_strcmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greatred than s2
|
||||
*/
|
||||
int os_strcmp(const char *s1, const char *s2);
|
||||
|
||||
/**
|
||||
* os_strncmp - Compare two strings
|
||||
* @s1: First string
|
||||
* @s2: Second string
|
||||
* @n: Maximum numbers of characters to compare
|
||||
* Returns: An integer less than, equal to, or greater than zero if s1 is
|
||||
* found to be less than, to match, or be greater than s2. Only first n
|
||||
* characters will be compared.
|
||||
*/
|
||||
int os_strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/**
|
||||
* os_strncpy - Copy a string
|
||||
* @dest: Destination
|
||||
* @src: Source
|
||||
* @n: Maximum number of characters to copy
|
||||
* Returns: dest
|
||||
*/
|
||||
char *os_strncpy(char *dest, const char *src, size_t n);
|
||||
|
||||
/**
|
||||
* os_strstr - Locate a substring
|
||||
* @haystack: String (haystack) to search from
|
||||
* @needle: Needle to search from haystack
|
||||
* Returns: Pointer to the beginning of the substring or %NULL if not found
|
||||
*/
|
||||
char *os_strstr(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* os_snprintf - Print to a memory buffer
|
||||
* @str: Memory buffer to print into
|
||||
* @size: Maximum length of the str buffer
|
||||
* @format: printf format
|
||||
* Returns: Number of characters printed (not including trailing '\0').
|
||||
*
|
||||
* If the output buffer is truncated, number of characters which would have
|
||||
* been written is returned. Since some C libraries return -1 in such a case,
|
||||
* the caller must be prepared on that value, too, to indicate truncation.
|
||||
*
|
||||
* Note: Some C library implementations of snprintf() may not guarantee null
|
||||
* termination in case the output is truncated. The OS wrapper function of
|
||||
* os_snprintf() should provide this guarantee, i.e., to null terminate the
|
||||
* output buffer if a C library version of the function is used and if that
|
||||
* function does not guarantee null termination.
|
||||
*
|
||||
* If the target system does not include snprintf(), see, e.g.,
|
||||
* http://www.ijs.si/software/snprintf/ for an example of a portable
|
||||
* implementation of snprintf.
|
||||
*/
|
||||
int os_snprintf(char *str, size_t size, const char *format, ...);
|
||||
|
||||
#else /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
#ifdef CONFIG_MEM_MONITOR
|
||||
u8* os_malloc(u32 sz);
|
||||
void os_mfree(u8 *pbuf, u32 sz);
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) os_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#else
|
||||
#ifndef os_malloc
|
||||
#define os_malloc(sz) _rtw_malloc(sz)
|
||||
#endif
|
||||
#ifndef os_free
|
||||
#define os_free(p, sz) _rtw_mfree(((u8*)(p)), (sz))
|
||||
#endif
|
||||
#endif
|
||||
extern void *os_zalloc(size_t size);
|
||||
extern char *os_strdup(const char *string_copy_from);
|
||||
|
||||
#ifndef os_sleep
|
||||
#define os_sleep(s, us) rtw_mdelay_os((s)*1000 + (us)/1000)
|
||||
#endif
|
||||
#ifndef os_memcpy
|
||||
#define os_memcpy(d, s, n) rtw_memcpy((void*)(d), ((void*)(s)), (n))
|
||||
#endif
|
||||
#ifndef os_memmove
|
||||
#define os_memmove(d, s, n) memmove((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_memset
|
||||
#define os_memset(pbuf, c, sz) rtw_memset(pbuf, c, sz)
|
||||
#endif
|
||||
#ifndef os_memcmp
|
||||
#define os_memcmp(s1, s2, n) rtw_memcmp(((void*)(s1)), ((void*)(s2)), (n))
|
||||
#endif
|
||||
#ifndef os_memcmp_p2p
|
||||
#define os_memcmp_p2p(s1, s2, n) memcmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_get_random_bytes
|
||||
#define os_get_random_bytes(d,sz) rtw_get_random_bytes(((void*)(d)), (sz))
|
||||
#endif
|
||||
#ifndef os_strlen
|
||||
#define os_strlen(s) strlen(s)
|
||||
#endif
|
||||
#ifndef os_strcasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strcasecmp(s1, s2) _stricmp((s1), (s2))
|
||||
#else
|
||||
#define os_strcasecmp(s1, s2) strcasecmp((s1), (s2))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_strncasecmp
|
||||
#ifdef _MSC_VER
|
||||
#define os_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n))
|
||||
#else
|
||||
#define os_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef os_init_timer
|
||||
#define os_init_timer(t, p, f, x, n) rtw_init_timer((t), (p), (f), (x), (n))
|
||||
#endif
|
||||
#ifndef os_set_timer
|
||||
#define os_set_timer(t, d) rtw_set_timer((t), (d))
|
||||
#endif
|
||||
#ifndef os_cancel_timer
|
||||
#define os_cancel_timer(t) rtw_cancel_timer(t)
|
||||
#endif
|
||||
#ifndef os_del_timer
|
||||
#define os_del_timer(t) rtw_del_timer(t)
|
||||
#endif
|
||||
#ifndef os_atoi
|
||||
#define os_atoi(s) rtw_atoi(s)
|
||||
#endif
|
||||
|
||||
#ifndef os_strchr
|
||||
#define os_strchr(s, c) strchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strcmp
|
||||
#define os_strcmp(s1, s2) strcmp((s1), (s2))
|
||||
#endif
|
||||
#ifndef os_strncmp
|
||||
#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
|
||||
#endif
|
||||
#ifndef os_strncpy
|
||||
#define os_strncpy(d, s, n) strncpy((d), (s), (n))
|
||||
#endif
|
||||
#ifndef os_strrchr
|
||||
#define os_strrchr(s, c) strrchr((s), (c))
|
||||
#endif
|
||||
#ifndef os_strstr
|
||||
#define os_strstr(h, n) strstr((h), (n))
|
||||
#endif
|
||||
|
||||
#ifndef os_snprintf
|
||||
#ifdef _MSC_VER
|
||||
#define os_snprintf _snprintf
|
||||
#else
|
||||
#define os_snprintf snprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* OS_NO_C_LIB_DEFINES */
|
||||
|
||||
|
||||
static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
if (size && nmemb > (~(size_t) 0) / size)
|
||||
return NULL;
|
||||
return os_realloc(ptr, nmemb * size, nmemb * size);
|
||||
}
|
||||
|
||||
void *os_xqueue_create(unsigned long uxQueueLength, unsigned long uxItemSize) ;
|
||||
|
||||
int os_xqueue_receive(xqueue_handle_t xQueue, void * const pvBuffer, unsigned long xSecsToWait);
|
||||
|
||||
void os_xqueue_delete(xqueue_handle_t xQueue );
|
||||
|
||||
int os_xqueue_send(xqueue_handle_t xQueue, const void * const pvItemToQueue, unsigned long xSecsToWait);
|
||||
|
||||
|
||||
#endif /* OS_H */
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* OS specific functions
|
||||
* Copyright (c) 2005-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef ROM_WPS_OS_H
|
||||
#define ROM_WPS_OS_H
|
||||
|
||||
extern u8 *WPS_realloc(u8 *old_buf, u32 old_sz, u32 new_sz);
|
||||
#define os_realloc(p, os, ns) WPS_realloc(((u8*)(p)),(os),(ns))
|
||||
|
||||
#endif /* ROM_WPS_OS_H */
|
@ -0,0 +1,324 @@
|
||||
|
||||
/*
|
||||
* Wi-Fi Protected Setup - message definitions
|
||||
* Copyright (c) 2008, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#ifndef WPS_DEFS_H
|
||||
#define WPS_DEFS_H
|
||||
|
||||
#if CONFIG_WPS2
|
||||
#define WPS_VERSION 0x20
|
||||
#else /* CONFIG_WPS2 */
|
||||
#define WPS_VERSION 0x10
|
||||
#endif /* CONFIG_WPS2 */
|
||||
|
||||
/* Diffie-Hellman 1536-bit MODP Group; RFC 3526, Group 5 */
|
||||
#define WPS_DH_GROUP (5)
|
||||
|
||||
#define WPS_UUID_LEN (16)
|
||||
#define WPS_NONCE_LEN (16)
|
||||
#define WPS_AUTHENTICATOR_LEN (8)
|
||||
#define WPS_AUTHKEY_LEN (32)
|
||||
#define WPS_KEYWRAPKEY_LEN (16)
|
||||
#define WPS_EMSK_LEN (32)
|
||||
#define WPS_PSK_LEN (16)
|
||||
#define WPS_SECRET_NONCE_LEN (16)
|
||||
#define WPS_HASH_LEN (32)
|
||||
#define WPS_KWA_LEN (8)
|
||||
#define WPS_MGMTAUTHKEY_LEN (32)
|
||||
#define WPS_MGMTENCKEY_LEN (16)
|
||||
#define WPS_MGMT_KEY_ID_LEN (16)
|
||||
#define WPS_OOB_DEVICE_PASSWORD_MIN_LEN (16)
|
||||
#define WPS_OOB_DEVICE_PASSWORD_LEN (32)
|
||||
#define WPS_OOB_PUBKEY_HASH_LEN (20)
|
||||
|
||||
/* Attribute Types */
|
||||
enum wps_attribute {
|
||||
ATTR_AP_CHANNEL = 0x1001,
|
||||
ATTR_ASSOC_STATE = 0x1002,
|
||||
ATTR_AUTH_TYPE = 0x1003,
|
||||
ATTR_AUTH_TYPE_FLAGS = 0x1004,
|
||||
ATTR_AUTHENTICATOR = 0x1005,
|
||||
ATTR_CONFIG_METHODS = 0x1008,
|
||||
ATTR_CONFIG_ERROR = 0x1009,
|
||||
ATTR_CONFIRM_URL4 = 0x100a,
|
||||
ATTR_CONFIRM_URL6 = 0x100b,
|
||||
ATTR_CONN_TYPE = 0x100c,
|
||||
ATTR_CONN_TYPE_FLAGS = 0x100d,
|
||||
ATTR_CRED = 0x100e,
|
||||
ATTR_ENCR_TYPE = 0x100f,
|
||||
ATTR_ENCR_TYPE_FLAGS = 0x1010,
|
||||
ATTR_DEV_NAME = 0x1011,
|
||||
ATTR_DEV_PASSWORD_ID = 0x1012,
|
||||
ATTR_E_HASH1 = 0x1014,
|
||||
ATTR_E_HASH2 = 0x1015,
|
||||
ATTR_E_SNONCE1 = 0x1016,
|
||||
ATTR_E_SNONCE2 = 0x1017,
|
||||
ATTR_ENCR_SETTINGS = 0x1018,
|
||||
ATTR_ENROLLEE_NONCE = 0x101a,
|
||||
ATTR_FEATURE_ID = 0x101b,
|
||||
ATTR_IDENTITY = 0x101c,
|
||||
ATTR_IDENTITY_PROOF = 0x101d,
|
||||
ATTR_KEY_WRAP_AUTH = 0x101e,
|
||||
ATTR_KEY_ID = 0x101f,
|
||||
ATTR_MAC_ADDR = 0x1020,
|
||||
ATTR_MANUFACTURER = 0x1021,
|
||||
ATTR_MSG_TYPE = 0x1022,
|
||||
ATTR_MODEL_NAME = 0x1023,
|
||||
ATTR_MODEL_NUMBER = 0x1024,
|
||||
ATTR_NETWORK_INDEX = 0x1026,
|
||||
ATTR_NETWORK_KEY = 0x1027,
|
||||
ATTR_NETWORK_KEY_INDEX = 0x1028,
|
||||
ATTR_NEW_DEVICE_NAME = 0x1029,
|
||||
ATTR_NEW_PASSWORD = 0x102a,
|
||||
ATTR_OOB_DEVICE_PASSWORD = 0x102c,
|
||||
ATTR_OS_VERSION = 0x102d,
|
||||
ATTR_POWER_LEVEL = 0x102f,
|
||||
ATTR_PSK_CURRENT = 0x1030,
|
||||
ATTR_PSK_MAX = 0x1031,
|
||||
ATTR_PUBLIC_KEY = 0x1032,
|
||||
ATTR_RADIO_ENABLE = 0x1033,
|
||||
ATTR_REBOOT = 0x1034,
|
||||
ATTR_REGISTRAR_CURRENT = 0x1035,
|
||||
ATTR_REGISTRAR_ESTABLISHED = 0x1036,
|
||||
ATTR_REGISTRAR_LIST = 0x1037,
|
||||
ATTR_REGISTRAR_MAX = 0x1038,
|
||||
ATTR_REGISTRAR_NONCE = 0x1039,
|
||||
ATTR_REQUEST_TYPE = 0x103a,
|
||||
ATTR_RESPONSE_TYPE = 0x103b,
|
||||
ATTR_RF_BANDS = 0x103c,
|
||||
ATTR_R_HASH1 = 0x103d,
|
||||
ATTR_R_HASH2 = 0x103e,
|
||||
ATTR_R_SNONCE1 = 0x103f,
|
||||
ATTR_R_SNONCE2 = 0x1040,
|
||||
ATTR_SELECTED_REGISTRAR = 0x1041,
|
||||
ATTR_SERIAL_NUMBER = 0x1042,
|
||||
ATTR_WPS_STATE = 0x1044,
|
||||
ATTR_SSID = 0x1045,
|
||||
ATTR_TOTAL_NETWORKS = 0x1046,
|
||||
ATTR_UUID_E = 0x1047,
|
||||
ATTR_UUID_R = 0x1048,
|
||||
ATTR_VENDOR_EXT = 0x1049,
|
||||
ATTR_VERSION = 0x104a,
|
||||
ATTR_X509_CERT_REQ = 0x104b,
|
||||
ATTR_X509_CERT = 0x104c,
|
||||
ATTR_EAP_IDENTITY = 0x104d,
|
||||
ATTR_MSG_COUNTER = 0x104e,
|
||||
ATTR_PUBKEY_HASH = 0x104f,
|
||||
ATTR_REKEY_KEY = 0x1050,
|
||||
ATTR_KEY_LIFETIME = 0x1051,
|
||||
ATTR_PERMITTED_CFG_METHODS = 0x1052,
|
||||
ATTR_SELECTED_REGISTRAR_CONFIG_METHODS = 0x1053,
|
||||
ATTR_PRIMARY_DEV_TYPE = 0x1054,
|
||||
ATTR_SECONDARY_DEV_TYPE_LIST = 0x1055,
|
||||
ATTR_PORTABLE_DEV = 0x1056,
|
||||
ATTR_AP_SETUP_LOCKED = 0x1057,
|
||||
ATTR_APPLICATION_EXT = 0x1058,
|
||||
ATTR_EAP_TYPE = 0x1059,
|
||||
ATTR_IV = 0x1060,
|
||||
ATTR_KEY_PROVIDED_AUTO = 0x1061,
|
||||
ATTR_802_1X_ENABLED = 0x1062,
|
||||
ATTR_APPSESSIONKEY = 0x1063,
|
||||
ATTR_WEPTRANSMITKEY = 0x1064,
|
||||
ATTR_REQUESTED_DEV_TYPE = 0x106a,
|
||||
ATTR_EXTENSIBILITY_TEST = 0x10fa /* _NOT_ defined in the spec */
|
||||
};
|
||||
|
||||
#define WPS_VENDOR_ID_WFA 14122
|
||||
|
||||
/* WFA Vendor Extension subelements */
|
||||
enum {
|
||||
WFA_ELEM_VERSION2 = 0x00,
|
||||
WFA_ELEM_AUTHORIZEDMACS = 0x01,
|
||||
WFA_ELEM_NETWORK_KEY_SHAREABLE = 0x02,
|
||||
WFA_ELEM_REQUEST_TO_ENROLL = 0x03,
|
||||
WFA_ELEM_SETTINGS_DELAY_TIME = 0x04
|
||||
};
|
||||
|
||||
/* Device Password ID */
|
||||
enum wps_dev_password_id {
|
||||
DEV_PW_DEFAULT = 0x0000,
|
||||
DEV_PW_USER_SPECIFIED = 0x0001,
|
||||
DEV_PW_MACHINE_SPECIFIED = 0x0002,
|
||||
DEV_PW_REKEY = 0x0003,
|
||||
DEV_PW_PUSHBUTTON = 0x0004,
|
||||
DEV_PW_REGISTRAR_SPECIFIED = 0x0005
|
||||
};
|
||||
|
||||
/* Message Type */
|
||||
enum wps_msg_type {
|
||||
WPS_START = 0x00,
|
||||
WPS_Beacon = 0x01,
|
||||
WPS_ProbeRequest = 0x02,
|
||||
WPS_ProbeResponse = 0x03,
|
||||
WPS_M1 = 0x04,
|
||||
WPS_M2 = 0x05,
|
||||
WPS_M2D = 0x06,
|
||||
WPS_M3 = 0x07,
|
||||
WPS_M4 = 0x08,
|
||||
WPS_M5 = 0x09,
|
||||
WPS_M6 = 0x0a,
|
||||
WPS_M7 = 0x0b,
|
||||
WPS_M8 = 0x0c,
|
||||
WPS_WSC_ACK = 0x0d,
|
||||
WPS_WSC_NACK = 0x0e,
|
||||
WPS_WSC_DONE = 0x0f
|
||||
};
|
||||
|
||||
/* Authentication Type Flags */
|
||||
#define WPS_AUTH_OPEN 0x0001
|
||||
#define WPS_AUTH_WPAPSK 0x0002
|
||||
#define WPS_AUTH_SHARED 0x0004
|
||||
#define WPS_AUTH_WPA 0x0008
|
||||
#define WPS_AUTH_WPA2 0x0010
|
||||
#define WPS_AUTH_WPA2PSK 0x0020
|
||||
#define WPS_AUTH_TYPES (WPS_AUTH_OPEN | WPS_AUTH_WPAPSK | WPS_AUTH_SHARED | \
|
||||
WPS_AUTH_WPA | WPS_AUTH_WPA2 | WPS_AUTH_WPA2PSK)
|
||||
|
||||
/* Encryption Type Flags */
|
||||
#define WPS_ENCR_NONE 0x0001
|
||||
#define WPS_ENCR_WEP 0x0002
|
||||
#define WPS_ENCR_TKIP 0x0004
|
||||
#define WPS_ENCR_AES 0x0008
|
||||
#define WPS_ENCR_TYPES (WPS_ENCR_NONE | WPS_ENCR_WEP | WPS_ENCR_TKIP | \
|
||||
WPS_ENCR_AES)
|
||||
|
||||
/* Configuration Error */
|
||||
enum wps_config_error {
|
||||
WPS_CFG_NO_ERROR = 0,
|
||||
WPS_CFG_OOB_IFACE_READ_ERROR = 1,
|
||||
WPS_CFG_DECRYPTION_CRC_FAILURE = 2,
|
||||
WPS_CFG_24_CHAN_NOT_SUPPORTED = 3,
|
||||
WPS_CFG_50_CHAN_NOT_SUPPORTED = 4,
|
||||
WPS_CFG_SIGNAL_TOO_WEAK = 5,
|
||||
WPS_CFG_NETWORK_AUTH_FAILURE = 6,
|
||||
WPS_CFG_NETWORK_ASSOC_FAILURE = 7,
|
||||
WPS_CFG_NO_DHCP_RESPONSE = 8,
|
||||
WPS_CFG_FAILED_DHCP_CONFIG = 9,
|
||||
WPS_CFG_IP_ADDR_CONFLICT = 10,
|
||||
WPS_CFG_NO_CONN_TO_REGISTRAR = 11,
|
||||
WPS_CFG_MULTIPLE_PBC_DETECTED = 12,
|
||||
WPS_CFG_ROGUE_SUSPECTED = 13,
|
||||
WPS_CFG_DEVICE_BUSY = 14,
|
||||
WPS_CFG_SETUP_LOCKED = 15,
|
||||
WPS_CFG_MSG_TIMEOUT = 16,
|
||||
WPS_CFG_REG_SESS_TIMEOUT = 17,
|
||||
WPS_CFG_DEV_PASSWORD_AUTH_FAILURE = 18
|
||||
};
|
||||
|
||||
/* RF Bands */
|
||||
#define WPS_RF_24GHZ (0x01)
|
||||
#define WPS_RF_50GHZ (0x02)
|
||||
|
||||
/* Config Methods */
|
||||
#define WPS_CONFIG_USBA (0x0001)
|
||||
#define WPS_CONFIG_ETHERNET (0x0002)
|
||||
#define WPS_CONFIG_LABEL (0x0004)
|
||||
#define WPS_CONFIG_DISPLAY (0x0008)
|
||||
#define WPS_CONFIG_EXT_NFC_TOKEN (0x0010)
|
||||
#define WPS_CONFIG_INT_NFC_TOKEN (0x0020)
|
||||
#define WPS_CONFIG_NFC_INTERFACE (0x0040)
|
||||
#define WPS_CONFIG_PUSHBUTTON (0x0080)
|
||||
#define WPS_CONFIG_KEYPAD (0x0100)
|
||||
|
||||
#if CONFIG_WPS2
|
||||
#define WPS_CONFIG_VIRT_PUSHBUTTON (0x0280)
|
||||
#define WPS_CONFIG_PHY_PUSHBUTTON (0x0480)
|
||||
#define WPS_CONFIG_VIRT_DISPLAY (0x2008)
|
||||
#define WPS_CONFIG_PHY_DISPLAY (0x4008)
|
||||
#endif /* CONFIG_WPS2 */
|
||||
|
||||
/* Connection Type Flags */
|
||||
#define WPS_CONN_ESS (0x01)
|
||||
#define WPS_CONN_IBSS (0x02)
|
||||
|
||||
/* Wi-Fi Protected Setup State */
|
||||
enum wps_state {
|
||||
WPS_STATE_NOT_CONFIGURED = 1,
|
||||
WPS_STATE_CONFIGURED = 2
|
||||
};
|
||||
|
||||
/* Association State */
|
||||
enum wps_assoc_state {
|
||||
WPS_ASSOC_NOT_ASSOC = 0,
|
||||
WPS_ASSOC_CONN_SUCCESS = 1,
|
||||
WPS_ASSOC_CFG_FAILURE = 2,
|
||||
WPS_ASSOC_FAILURE = 3,
|
||||
WPS_ASSOC_IP_FAILURE = 4
|
||||
};
|
||||
|
||||
|
||||
#define WPS_DEV_OUI_WFA (0x0050f204)
|
||||
|
||||
enum wps_dev_categ {
|
||||
WPS_DEV_COMPUTER = 1,
|
||||
WPS_DEV_INPUT = 2,
|
||||
WPS_DEV_PRINTER = 3,
|
||||
WPS_DEV_CAMERA = 4,
|
||||
WPS_DEV_STORAGE = 5,
|
||||
WPS_DEV_NETWORK_INFRA = 6,
|
||||
WPS_DEV_DISPLAY = 7,
|
||||
WPS_DEV_MULTIMEDIA = 8,
|
||||
WPS_DEV_GAMING = 9,
|
||||
WPS_DEV_PHONE = 10
|
||||
};
|
||||
|
||||
enum wps_dev_subcateg {
|
||||
WPS_DEV_COMPUTER_PC = 1,
|
||||
WPS_DEV_COMPUTER_SERVER = 2,
|
||||
WPS_DEV_COMPUTER_MEDIA_CENTER = 3,
|
||||
|
||||
WPS_DEV_PRINTER_PRINTER = 1,
|
||||
WPS_DEV_PRINTER_SCANNER = 2,
|
||||
|
||||
WPS_DEV_CAMERA_DIGITAL_STILL_CAMERA = 1,
|
||||
|
||||
WPS_DEV_STORAGE_NAS = 1,
|
||||
|
||||
WPS_DEV_NETWORK_INFRA_AP = 1,
|
||||
WPS_DEV_NETWORK_INFRA_ROUTER = 2,
|
||||
WPS_DEV_NETWORK_INFRA_SWITCH = 3,
|
||||
|
||||
WPS_DEV_DISPLAY_TV = 1,
|
||||
WPS_DEV_DISPLAY_PICTURE_FRAME = 2,
|
||||
WPS_DEV_DISPLAY_PROJECTOR = 3,
|
||||
|
||||
WPS_DEV_MULTIMEDIA_DAR = 1,
|
||||
WPS_DEV_MULTIMEDIA_PVR = 2,
|
||||
WPS_DEV_MULTIMEDIA_MCX = 3,
|
||||
|
||||
WPS_DEV_GAMING_XBOX = 1,
|
||||
WPS_DEV_GAMING_XBOX360 = 2,
|
||||
WPS_DEV_GAMING_PLAYSTATION = 3,
|
||||
|
||||
WPS_DEV_PHONE_WINDOWS_MOBILE = 1
|
||||
};
|
||||
|
||||
|
||||
/* Request Type */
|
||||
enum wps_request_type {
|
||||
WPS_REQ_ENROLLEE_INFO = 0,
|
||||
WPS_REQ_ENROLLEE = 1,
|
||||
WPS_REQ_REGISTRAR = 2,
|
||||
WPS_REQ_WLAN_MANAGER_REGISTRAR = 3
|
||||
};
|
||||
|
||||
/* Response Type */
|
||||
enum wps_response_type {
|
||||
WPS_RESP_ENROLLEE_INFO = 0,
|
||||
WPS_RESP_ENROLLEE = 1,
|
||||
WPS_RESP_REGISTRAR = 2,
|
||||
WPS_RESP_AP = 3
|
||||
};
|
||||
|
||||
/* Walk Time for push button configuration (in seconds) */
|
||||
#define WPS_PBC_WALK_TIME (120)
|
||||
|
||||
#define WPS_MAX_AUTHORIZED_MACS (5)
|
||||
|
||||
#endif /* WPS_DEFS_H */
|
||||
|
@ -0,0 +1,353 @@
|
||||
//#include "FreeRTOS.h"
|
||||
//#include "task.h"
|
||||
#include <stdint.h>
|
||||
#include <rtwlan_config.h>
|
||||
#include "utils/os.h"
|
||||
//#include <lwip/netif.h>
|
||||
#include <wifi/wifi_conf.h>
|
||||
#include "wps/wps_defs.h"
|
||||
#include "wifi_p2p_config.h"
|
||||
|
||||
#if CONFIG_ENABLE_P2P
|
||||
enum p2p_wps_method {
|
||||
WPS_NOT_READY, WPS_PIN_DISPLAY, WPS_PIN_KEYPAD, WPS_PBC
|
||||
};
|
||||
|
||||
/*NETMASK*/
|
||||
#define P2P_NETMASK_ADDR0 255
|
||||
#define P2P_NETMASK_ADDR1 255
|
||||
#define P2P_NETMASK_ADDR2 255
|
||||
#define P2P_NETMASK_ADDR3 0
|
||||
|
||||
/*Gateway Address*/
|
||||
#define P2P_GW_ADDR0 192
|
||||
#define P2P_GW_ADDR1 168
|
||||
#define P2P_GW_ADDR2 42
|
||||
#define P2P_GW_ADDR3 1
|
||||
|
||||
#define P2P_GO_NEGO_RESULT_SIZE 376//256
|
||||
|
||||
xqueue_handle_t queue_for_p2p_nego;
|
||||
|
||||
//extern void dhcps_init(struct netif * pnetif);
|
||||
|
||||
extern int is_wifi_p2p_initialized();
|
||||
extern int wifi_cmd_p2p_listen(unsigned int timeout);
|
||||
extern void wifi_cmd_p2p_find(void);
|
||||
extern void wifi_cmd_p2p_peers(void);
|
||||
extern u8 wifi_cmd_p2p_info(void);
|
||||
extern int wifi_cmd_p2p_connect(u8 *dest, enum p2p_wps_method config_method, char *pin);
|
||||
extern void wifi_cmd_p2p_disconnect(void);
|
||||
extern void wifi_p2p_set_config_methods(u16 config_methods);
|
||||
extern int wifi_p2p_start_wps(void *res);
|
||||
|
||||
static int hex2num(char c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if (c >= 'a' && c <= 'f')
|
||||
return c - 'a' + 10;
|
||||
if (c >= 'A' && c <= 'F')
|
||||
return c - 'A' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* hwaddr_aton - Convert ASCII string to MAC address (colon-delimited format)
|
||||
* @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
|
||||
* @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
|
||||
* Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
|
||||
*/
|
||||
int hwaddr_aton(const char *txt, u8 *addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
int a, b;
|
||||
|
||||
a = hex2num(*txt++);
|
||||
if (a < 0)
|
||||
return -1;
|
||||
b = hex2num(*txt++);
|
||||
if (b < 0)
|
||||
return -1;
|
||||
*addr++ = (a << 4) | b;
|
||||
if (i < 5 && *txt++ != ':')
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wifi_start_p2p_go(char *ssid, char *passphrase, u8 channel)
|
||||
{
|
||||
/*extern struct netif xnetif[NET_IF_NUM];
|
||||
struct netif * pnetif = &xnetif[0];
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
|
||||
#if LWIP_VERSION_MAJOR >= 2
|
||||
IP4_ADDR(ip_2_ip4(&ipaddr), P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3);
|
||||
IP4_ADDR(ip_2_ip4(&netmask), P2P_NETMASK_ADDR0, P2P_NETMASK_ADDR1 , P2P_NETMASK_ADDR2, P2P_NETMASK_ADDR3);
|
||||
IP4_ADDR(ip_2_ip4(&gw), P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3);
|
||||
netif_set_addr(pnetif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask),ip_2_ip4(&gw));
|
||||
#else
|
||||
IP4_ADDR(&ipaddr, P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3);
|
||||
IP4_ADDR(&netmask, P2P_NETMASK_ADDR0, P2P_NETMASK_ADDR1 , P2P_NETMASK_ADDR2, P2P_NETMASK_ADDR3);
|
||||
IP4_ADDR(&gw, P2P_GW_ADDR0, P2P_GW_ADDR1, P2P_GW_ADDR2, P2P_GW_ADDR3);
|
||||
netif_set_addr(pnetif, &ipaddr, &netmask,&gw);
|
||||
#endif*/
|
||||
|
||||
// start ap
|
||||
if(wifi_start_ap(ssid,
|
||||
RTW_SECURITY_WPA2_AES_PSK,
|
||||
passphrase,
|
||||
strlen(ssid),
|
||||
strlen(passphrase),
|
||||
channel
|
||||
) != RTW_SUCCESS) {
|
||||
printf("\n\rERROR: Operation failed!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//netif_set_default(pnetif);
|
||||
|
||||
// start dhcp server
|
||||
//dhcps_init(pnetif);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void app_callback(char *msg)
|
||||
{
|
||||
//From Application
|
||||
}
|
||||
|
||||
void cmd_wifi_p2p_start(int argc, char **argv)
|
||||
{
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
u8 listen_ch = 1;
|
||||
u8 op_ch = 36;
|
||||
int go_intent = 1;
|
||||
#if 1
|
||||
u32 r = 0;
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
go_intent = r%15+1; /*1-15*/
|
||||
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
listen_ch = 1 + (r % 3) * 5;
|
||||
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
op_ch = 1 + (r % 3) * 5;
|
||||
#endif
|
||||
wifi_off();
|
||||
os_sleep(0, 20000);
|
||||
wifi_on(RTW_MODE_P2P);
|
||||
//wifi_p2p_init(xnetif[0].hwaddr, go_intent, listen_ch, op_ch);
|
||||
wifi_p2p_init((u8*)(argv[1]), go_intent, listen_ch, op_ch);
|
||||
}
|
||||
|
||||
static int p2p_channel = 36;
|
||||
void cmd_wifi_p2p_start_ex(char dev_addr[6])
|
||||
{
|
||||
//extern struct netif xnetif[NET_IF_NUM];
|
||||
int listen_ch = 1;
|
||||
int op_ch = p2p_channel;
|
||||
int go_intent = 1;
|
||||
int ret = -1;
|
||||
char str_mac[32] = {0};
|
||||
char mac[6] = {0};
|
||||
|
||||
(void)dev_addr;
|
||||
|
||||
|
||||
u32 r = 0;
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
go_intent = r%15+1; /*1-15*/
|
||||
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
listen_ch = 1 + (r % 3) * 5;
|
||||
#if 0
|
||||
os_get_random((u8 *) &r, sizeof(r));
|
||||
op_ch = 1 + (r % 3) * 5;
|
||||
#endif
|
||||
wifi_off();
|
||||
os_sleep(0, 20000);
|
||||
wifi_on(RTW_MODE_P2P);
|
||||
//wifi_p2p_init(xnetif[0].hwaddr, go_intent, listen_ch, op_ch);
|
||||
|
||||
ret = wifi_get_mac_address(str_mac);
|
||||
if (ret < 0) {
|
||||
printf("get wlan mac failed\r\n");
|
||||
return;
|
||||
} else {
|
||||
sscanf(str_mac, "%02x:%02x:%02x:%02x:%02x:%02x", (uint32_t *)&mac[0], (uint32_t *)&mac[1], (uint32_t *)&mac[2],
|
||||
(uint32_t *)&mac[3], (uint32_t *)&mac[4], (uint32_t *)&mac[5]);
|
||||
}
|
||||
wifi_p2p_init((u8 *)mac, go_intent, listen_ch, op_ch);
|
||||
}
|
||||
|
||||
|
||||
void cmd_wifi_p2p_auto_go_start(int argc, char **argv)
|
||||
{
|
||||
u8 *passphrase = "12345678";
|
||||
#if CONFIG_CUSTOMER_REQUEST_ITE //for 5G channel
|
||||
u8 channel = 40; // 36, 40, 44, 48
|
||||
#else
|
||||
u8 channel = 1; // 1, 6, 11
|
||||
#endif
|
||||
const char *ssid_in = "DIRECT-34-Ameba";
|
||||
const char *dev_name = "ap630hv100_p2p"; // max strlen 32
|
||||
const char *manufacturer = "by customer"; // max strlen 64
|
||||
const char *model_name = "customer"; // max strlen 32
|
||||
const char *model_number = "v2.0"; // max strlen 32
|
||||
const char *serial_number = "9"; // max strlen 32
|
||||
#if CONFIG_WFD
|
||||
const u8 pri_dev_type[8] = {0x00,0x07,0x00,0x50,0xF2,0x04,0x00,0x01}; // category ID:0x00,0x07; sub category ID:0x00,0x01
|
||||
#else
|
||||
const u8 pri_dev_type[8] = {0x00,0x0A,0x00,0x50,0xF2,0x04,0x00,0x01}; // category ID:0x00,0x0A; sub category ID:0x00,0x01
|
||||
#endif
|
||||
u8 res[P2P_GO_NEGO_RESULT_SIZE];
|
||||
#if CONFIG_WFD
|
||||
u16 config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_PUSHBUTTON;
|
||||
#else
|
||||
u16 config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD | WPS_CONFIG_PUSHBUTTON;
|
||||
#endif
|
||||
if(!is_wifi_p2p_initialized() || argc != 3){
|
||||
printf("\r\n%s(): p2p inital fail\n", __func__);
|
||||
return;
|
||||
}
|
||||
if (argv[0] && strlen(argv[0]) > 0)
|
||||
dev_name = argv[0];
|
||||
if (argv[1] && strlen(argv[1]) > 0)
|
||||
ssid_in = argv[1];
|
||||
if (argv[2] && strlen(argv[2]) > 0)
|
||||
passphrase = (u8*)(argv[2]);
|
||||
wifi_p2p_set_dev_name(dev_name);
|
||||
wifi_p2p_set_manufacturer(manufacturer);
|
||||
wifi_p2p_set_model_name(model_name);
|
||||
wifi_p2p_set_model_number(model_number);
|
||||
wifi_p2p_set_serial_number(serial_number);
|
||||
wifi_p2p_set_pri_dev_type(pri_dev_type);
|
||||
wifi_p2p_set_ssid(ssid_in);
|
||||
wifi_p2p_set_config_methods(config_methods);
|
||||
channel = p2p_channel;
|
||||
wifi_p2p_init_auto_go_params(res, passphrase, channel);
|
||||
wifi_p2p_start_auto_go(res);
|
||||
//return;
|
||||
}
|
||||
void cmd_wifi_p2p_stop(int argc, char **argv)
|
||||
{
|
||||
wifi_p2p_deinit();
|
||||
wifi_off();
|
||||
}
|
||||
|
||||
void cmd_p2p_listen(int argc, char **argv)
|
||||
{
|
||||
u32 timeout = 0;
|
||||
|
||||
if(argc == 2){
|
||||
timeout = os_atoi((u8*)argv[1]);
|
||||
printf("\r\n%s(): timeout=%d\n", __func__, timeout);
|
||||
if(timeout > 3600)
|
||||
timeout = 3600;
|
||||
}
|
||||
wifi_cmd_p2p_listen(timeout);
|
||||
}
|
||||
|
||||
void cmd_p2p_find(int argc, char **argv)
|
||||
{
|
||||
wifi_cmd_p2p_find();
|
||||
}
|
||||
|
||||
void cmd_p2p_peers(int argc, char **argv)
|
||||
{
|
||||
wifi_cmd_p2p_peers();
|
||||
}
|
||||
|
||||
void cmd_p2p_info(int argc, char **argv)
|
||||
{
|
||||
u8 p2p_state;
|
||||
|
||||
p2p_state = wifi_cmd_p2p_info();
|
||||
|
||||
printf("\r\np2p state : %d",p2p_state);
|
||||
}
|
||||
|
||||
void cmd_p2p_disconnect(int argc, char **argv)
|
||||
{
|
||||
wifi_cmd_p2p_disconnect();
|
||||
}
|
||||
|
||||
void cmd_p2p_connect(int argc, char **argv)
|
||||
{
|
||||
enum p2p_wps_method config_method = WPS_PBC;
|
||||
char *pin = NULL;
|
||||
u8 dest[ETH_ALEN] = {0x44, 0x6d, 0x57, 0xd7, 0xce, 0x41};
|
||||
u8 res[P2P_GO_NEGO_RESULT_SIZE];
|
||||
int ret = 0, result = 0;
|
||||
|
||||
#if 1
|
||||
if((argc != 2) && (argc != 3) && (argc != 4)) {
|
||||
printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] [pin code]\n");
|
||||
printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin 12345678\n");
|
||||
return;
|
||||
}
|
||||
if (hwaddr_aton(argv[1], dest)){
|
||||
printf("\r\nP2P_CONNECT: dest address is not correct!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\r\nDEST: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", dest[0], dest[1], dest[2], dest[3], dest[4], dest[5]);
|
||||
config_method = WPS_PBC;
|
||||
if(argc == 3) {
|
||||
if(os_strncmp(argv[2], "pbc", 3) == 0)
|
||||
config_method = WPS_PBC;
|
||||
else if(os_strncmp(argv[2], "pin", 3) == 0){
|
||||
config_method = WPS_PIN_DISPLAY;
|
||||
}else{
|
||||
printf("\n\rUnknown config method!\n");
|
||||
printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] \n");
|
||||
printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(argc == 4) {
|
||||
if(os_strncmp(argv[2], "pin", 3) == 0){
|
||||
config_method = WPS_PIN_KEYPAD;
|
||||
pin = argv[3];
|
||||
}else{
|
||||
printf("\n\rUnknown config method!\n");
|
||||
printf("\n\rUsage: p2p_connect DEST_ADDR [pbc|pin] [pin code]\n");
|
||||
printf("\n\rExample: p2p_connect 00:e0:4c:87:00:15 pin 12345678\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else //For test
|
||||
u8 dest1[ETH_ALEN] = {0xea, 0x92, 0xa4, 0x9b, 0x61, 0xd6}; //NEXUS 4
|
||||
//u8 dest1[ETH_ALEN] = {0x0e, 0x37, 0xdc, 0xfc, 0xc4, 0x12}; //HUAWEI U9508_c001
|
||||
//u8 dest1[ETH_ALEN] = {0x42, 0xcb, 0xa8, 0xd3, 0x2c, 0x50}; //HUAWEI G610-T00
|
||||
os_memcpy(dest, dest1, ETH_ALEN);
|
||||
config_method = WPS_PBC;
|
||||
#endif
|
||||
|
||||
if (queue_for_p2p_nego!= NULL) {
|
||||
os_xqueue_delete(queue_for_p2p_nego);
|
||||
queue_for_p2p_nego = NULL;
|
||||
}
|
||||
queue_for_p2p_nego = os_xqueue_create(1, P2P_GO_NEGO_RESULT_SIZE);
|
||||
if(queue_for_p2p_nego != NULL) {
|
||||
ret = wifi_cmd_p2p_connect(dest, config_method, pin);
|
||||
if(ret == 0)
|
||||
result = os_xqueue_receive(queue_for_p2p_nego, res, 15);
|
||||
|
||||
os_xqueue_delete(queue_for_p2p_nego);
|
||||
queue_for_p2p_nego = NULL;
|
||||
|
||||
if((ret == 0) && (result == 0))
|
||||
wifi_p2p_start_wps(res);
|
||||
}
|
||||
}
|
||||
|
||||
#endif //CONFIG_ENABLE_P2P
|
@ -0,0 +1,195 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file wifi_p2p_config.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides user interfaces for Wi-Fi Direct functionality.
|
||||
* @note To use the APIs in this file, please enable CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P in platform_opts.h.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*
|
||||
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup wpsp2p WPS/P2P
|
||||
* @ingroup wlan
|
||||
* @brief WPS/P2P functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize P2P data.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P).
|
||||
* @param[in] dev_addr: The device address.
|
||||
* @param[in] go_intent: The GO intent.
|
||||
* @param[in] listen_ch: The listen channel.
|
||||
* @param[in] op_ch: The operation channel.
|
||||
* @return 0 on success, otherwise return -1.
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.\n
|
||||
* You can reference @ref cmd_wifi_p2p_start() to understand the process of starting P2P mode.
|
||||
*/
|
||||
int wifi_p2p_init(u8 *dev_addr, int go_intent, u8 listen_ch, u8 op_ch);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize P2P data.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P).
|
||||
* @param None
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_deinit();
|
||||
|
||||
/**
|
||||
* @brief Command to start WiFi Direct mode for commonly use. Can refer to ATWG in atcmd_wifi.c.\n
|
||||
* After executing this command, P2P resource will be allocated and the driver enter P2P mode.
|
||||
* @warning If the started Wi-Fi Direct mode is no longer needed, please make sure to invoke @ref cmd_wifi_p2p_stop() before doing other procedures.
|
||||
* @param[in] argc: Command line argument. Argument count. Just let it be NULL.
|
||||
* @param[in] argv: Command line argument. Argument vector. Just let it be NULL.
|
||||
* @return None
|
||||
* @note Command style:
|
||||
* - cmd_wifi_p2p_start
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void cmd_wifi_p2p_start(int argc, char **argv);
|
||||
void cmd_wifi_p2p_start_ex(char dev_addr[6]);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Command to stop WiFi Direct mode for commonly use. Can refer to ATWH in atcmd_wifi.c.\n
|
||||
* After execute this command, WLAN driver will release P2P resources and turn off Wi-Fi.
|
||||
* @warning This command must be invoked if the enabled Wi-Fi Direct mode is no longer used.
|
||||
* @param[in] argc: Command line argument. Argument count. Just let it be NULL.
|
||||
* @param[in] argv: Command line argument. Argument vector. Just let it be NULL.
|
||||
* @return None
|
||||
* @note Command style:
|
||||
* - cmd_wifi_p2p_stop
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void cmd_wifi_p2p_stop(int argc, char **argv);
|
||||
|
||||
/**
|
||||
* @brief Command to show P2P role, P2P group information, and memory usage. Can refer to ATWN in atcmd_wifi.c.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] argc: Command line argument. Argument count. Just let it be NULL.
|
||||
* @param[in] argv: Command line argument. Argument vector. Just let it be NULL.
|
||||
* @return None
|
||||
* @note Command style:
|
||||
* - cmd_p2p_info
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void cmd_p2p_info(int argc, char **argv);
|
||||
|
||||
/**
|
||||
* @brief Set the device name in WPS ie and P2P ie.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] dev_name: Device name to be set. The max string length is 32 bytes.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_set_dev_name(const char *dev_name);
|
||||
|
||||
/**
|
||||
* @brief Set the manufacturer in WPS ie.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] manufacturer: Manufacturer to be set. The max string length is 64 bytes.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_set_manufacturer(const char *manufacturer);
|
||||
|
||||
/**
|
||||
* @brief Set the model name in WPS ie.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] model_name: Model name to be set. The max string length is 32 bytes.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_set_model_name(const char *model_name);
|
||||
|
||||
/**
|
||||
* @brief Set the model number in WPS ie.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] model_number: Model number to be set. The max string length is 32 bytes.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_set_model_number(const char *model_number);
|
||||
|
||||
/**
|
||||
* @brief Set the serial number in WPS ie.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] serial_number: Serial number to be set. The max string length is 32 bytes.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_set_serial_number(const char *serial_number);
|
||||
|
||||
/**
|
||||
* @brief Set the primary device type in WPS ie and P2P ie.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] pri_dev_type: Primary device type to be set. The string length is 8 bytes.\n
|
||||
* The first two bytes are category ID, and the last two bytes are subcategory ID.
|
||||
* The middle four bytes are 0x 00-50-F2-04.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_set_pri_dev_type(const u8 *pri_dev_type);
|
||||
|
||||
/**
|
||||
* @brief Set the GO SSID.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] ssid_in: Ssid_in will be set as GO SSID. The string length is between 1 byte and 32 bytes.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_set_ssid(const char *ssid_in);
|
||||
|
||||
/**
|
||||
* @brief Initialize the Wi-Fi Direct GO parameters.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[out] res: The location where the set parameters will be stored. (@ref p2p_go_neg_results)
|
||||
* @param[in] passphrase: The GO passphrase.
|
||||
* @param[in] channel: The operation channel.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void wifi_p2p_init_auto_go_params(void *res, u8 *passphrase,u8 channel);
|
||||
|
||||
/**
|
||||
* @brief Start Wi-Fi Direct GO.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] res: The parameters for GO negotiation. (@ref p2p_go_neg_results)
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.\n
|
||||
* You can reference @ref cmd_wifi_p2p_auto_go_start() to understand the process of opening the P2P automatic GO.
|
||||
*/
|
||||
int wifi_p2p_start_auto_go(void *res);
|
||||
|
||||
/**
|
||||
* @brief Command to start WiFi Direct GO mode for commonly use. Can refer to ATWg in atcmd_wifi.c.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on(RTW_MODE_P2P) and P2P be initialized by using @ref wifi_p2p_init().
|
||||
* @warning You can reference @ref cmd_wifi_p2p_start() to initialize them.
|
||||
* @param[in] argc: Command line argument. Argument count. Just let it be NULL.
|
||||
* @param[in] argv: Command line argument. Argument vector. Just let it be NULL.
|
||||
* @return 0 if success, otherwise return -1.
|
||||
* @note Command style:
|
||||
* - cmd_wifi_p2p_auto_go_start
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
|
||||
*/
|
||||
void cmd_wifi_p2p_auto_go_start(int argc, char **argv);
|
||||
|
||||
/*\@}*/
|
@ -0,0 +1,124 @@
|
||||
#ifndef _WIFI_P2P_SUPPLICANT_H_
|
||||
#define _WIFI_P2P_SUPPLICANT_H_
|
||||
|
||||
enum p2p_group_removal_reason {
|
||||
P2P_GROUP_REMOVAL_UNKNOWN,
|
||||
P2P_GROUP_REMOVAL_SILENT,
|
||||
P2P_GROUP_REMOVAL_FORMATION_FAILED,
|
||||
P2P_GROUP_REMOVAL_REQUESTED,
|
||||
P2P_GROUP_REMOVAL_IDLE_TIMEOUT,
|
||||
P2P_GROUP_REMOVAL_UNAVAILABLE,
|
||||
P2P_GROUP_REMOVAL_GO_ENDING_SESSION
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wpa_scan_res - Scan result for an BSS/IBSS
|
||||
* @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
|
||||
* @bssid: BSSID
|
||||
* @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
|
||||
* @beacon_int: beacon interval in TUs (host byte order)
|
||||
* @caps: capability information field in host byte order
|
||||
* @qual: signal quality
|
||||
* @noise: noise level
|
||||
* @level: signal level
|
||||
* @tsf: Timestamp
|
||||
* @age: Age of the information in milliseconds (i.e., how many milliseconds
|
||||
* ago the last Beacon or Probe Response frame was received)
|
||||
* @ie_len: length of the following IE field in octets
|
||||
* @beacon_ie_len: length of the following Beacon IE field in octets
|
||||
*
|
||||
* This structure is used as a generic format for scan results from the
|
||||
* driver. Each driver interface implementation is responsible for converting
|
||||
* the driver or OS specific scan results into this format.
|
||||
*
|
||||
* If the driver does not support reporting all IEs, the IE data structure is
|
||||
* constructed of the IEs that are available. This field will also need to
|
||||
* include SSID in IE format. All drivers are encouraged to be extended to
|
||||
* report all IEs to make it easier to support future additions.
|
||||
*/
|
||||
struct wpa_scan_res {
|
||||
unsigned int flags;
|
||||
u8 bssid[ETH_ALEN];
|
||||
int freq;
|
||||
u16 beacon_int;
|
||||
u16 caps;
|
||||
int qual;
|
||||
int noise;
|
||||
int level;
|
||||
u64 tsf;
|
||||
unsigned int age;
|
||||
size_t ie_len;
|
||||
size_t beacon_ie_len;
|
||||
u8 *ie;
|
||||
/*
|
||||
* Followed by ie_len octets of IEs from Probe Response frame (or if
|
||||
* the driver does not indicate source of IEs, these may also be from
|
||||
* Beacon frame). After the first set of IEs, another set of IEs may
|
||||
* follow (with beacon_ie_len octets of data) if the driver provides
|
||||
* both IE sets.
|
||||
*/
|
||||
};
|
||||
|
||||
/** P2P device scanned (only basic information) */
|
||||
#define P2P_EVENT_DEVICE_SCANNED "P2P-DEVICE-SCANNED "
|
||||
|
||||
/** P2P device found */
|
||||
#define P2P_EVENT_DEVICE_FOUND "P2P-DEVICE-FOUND "
|
||||
|
||||
/** P2P device lost */
|
||||
#define P2P_EVENT_DEVICE_LOST "P2P-DEVICE-LOST "
|
||||
|
||||
/** P2P find stopped */
|
||||
#define P2P_EVENT_FIND_STOPPED "P2P-FIND-STOPPED "
|
||||
|
||||
/** A P2P device requested GO negotiation, but we were not ready to start the
|
||||
* negotiation */
|
||||
#define P2P_EVENT_GO_NEG_REQUEST "P2P-GO-NEG-REQUEST "
|
||||
#define P2P_EVENT_GO_NEG_SUCCESS "P2P-GO-NEG-SUCCESS "
|
||||
#define P2P_EVENT_GO_NEG_FAILURE "P2P-GO-NEG-FAILURE "
|
||||
#define P2P_EVENT_GROUP_FORMATION_SUCCESS "P2P-GROUP-FORMATION-SUCCESS "
|
||||
#define P2P_EVENT_GROUP_FORMATION_FAILURE "P2P-GROUP-FORMATION-FAILURE "
|
||||
|
||||
/* P2P Group started or removed */
|
||||
#define P2P_EVENT_GROUP_STARTED "P2P-GROUP-STARTED "
|
||||
#define P2P_EVENT_GROUP_REMOVED "P2P-GROUP-REMOVED "
|
||||
|
||||
#define AP_STA_CONNECTED "AP-STA-CONNECTED "
|
||||
#define AP_STA_DISCONNECTED "AP-STA-DISCONNECTED "
|
||||
|
||||
int wifi_p2p_rx_mgnt(u8 *data, u16 len, u8 channel);
|
||||
int wifi_p2p_connect(const u8 *peer_addr,
|
||||
const char *pin, enum p2p_wps_method wps_method,
|
||||
int persistent_group, int auto_join, int join, int auth,
|
||||
int go_intent, int freq, int persistent_id, int pd,
|
||||
int ht40);
|
||||
void wifi_p2p_scan_res_handler(void);
|
||||
int wifi_p2p_start_wps(void *res);
|
||||
void wifi_p2p_set_state(u8 p2p_state);
|
||||
int wifi_p2p_group_notify_assoc(u8 *buf, u16 buf_len);
|
||||
int wifi_p2p_group_notify_disassoc(u8 *addr);
|
||||
|
||||
int wifi_cmd_p2p_listen(unsigned int timeout);
|
||||
void wifi_cmd_p2p_find(void);
|
||||
void wifi_cmd_p2p_peers(void);
|
||||
u8 wifi_cmd_p2p_info(void);
|
||||
int wifi_cmd_p2p_connect(u8 *dest, enum p2p_wps_method config_method, char *pin);
|
||||
void wifi_cmd_p2p_disconnect(void);
|
||||
|
||||
int wifi_p2p_init(u8 *dev_addr, int go_intent, u8 listen_ch, u8 op_ch);
|
||||
void wifi_p2p_deinit(void);
|
||||
int is_wifi_p2p_initialized();
|
||||
void wifi_p2p_set_dev_name(const char *dev_name);
|
||||
void wifi_p2p_set_manufacturer(const char *manufacturer);
|
||||
void wifi_p2p_set_model_name(const char *model_name);
|
||||
void wifi_p2p_set_model_number(const char *model_number);
|
||||
void wifi_p2p_set_serial_number(const char *serial_number);
|
||||
void wifi_p2p_set_pri_dev_type(const u8 *pri_dev_type);
|
||||
void wifi_p2p_set_ssid(const char *ssid_in);
|
||||
void wifi_p2p_set_config_methods(u16 config_methods);
|
||||
void wifi_p2p_init_auto_go_params(void *res, u8 *passphrase,u8 channel);
|
||||
int wifi_p2p_start_auto_go(void *res);
|
||||
unsigned int wifi_p2p_group_is_intfaddr_connected(u8 *dev_addr);
|
||||
unsigned int wifi_p2p_group_is_client_connected(u8 *dev_addr);
|
||||
#endif //_WIFI_P2P_SUPPLICANT_H_
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,75 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file wifi_wps_config.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides user interfaces for WPS functionality.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*
|
||||
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup wpsp2p WPS/P2P
|
||||
* @ingroup wlan
|
||||
* @brief WPS/P2P functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Start WPS enrollee process.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on().
|
||||
* @param[in] wps_config: WPS configure method. Options are: WPS_CONFIG_DISPLAY, WPS_CONFIG_KEYPAD, and WPS_CONFIG_PUSHBUTTON.
|
||||
* @param[in] pin: PIN number. Can be set to NULL if using WPS_CONFIG_PUSHBUTTON.
|
||||
* @param[in] channel: Channel. Currently un-used, can be set to 0.
|
||||
* @param[in] ssid: Target network SSID. Can be set to NULL if no target network specified.
|
||||
* @return 0 on success.
|
||||
* @note Please make sure CONFIG_ENABLE_WPS is enabled in platform_opts.h.\n
|
||||
* You can reference @ref cmd_wps() to know how to choose input parameters.
|
||||
*/
|
||||
int wps_start(u16 wps_config, char *pin, u8 channel, char *ssid);
|
||||
|
||||
/**
|
||||
* @brief Command to start WPS enrollee process for commonly use. Can refer to ATWW in atcmd_wifi.c.
|
||||
* @warning Before invoking this function, the Wi-Fi should be enabled by using @ref wifi_on().
|
||||
* @param[in] argc: Command line argument. Argument count.
|
||||
* @param[in] argv: Command line argument. Argument vector.
|
||||
* @return 0 on success.
|
||||
* @note Command style for example:
|
||||
* - cmd_wps pbc
|
||||
* - cmd_wps pin
|
||||
* - cmd_wps pin 12345678
|
||||
* @note Please make sure CONFIG_ENABLE_WPS is enabled in platform_opts.h.
|
||||
*/
|
||||
void cmd_wps(int argc, char **argv);
|
||||
|
||||
/**
|
||||
* @brief Start a WPS registrar thread.
|
||||
* @warning Before invoking this function, the Wi-Fi should be in SoftAP mode.
|
||||
* @param[in] config_methods: WPS configure method. Options are: WPS_CONFIG_DISPLAY, WPS_CONFIG_KEYPAD, and WPS_CONFIG_PUSHBUTTON.
|
||||
* @param[in] pin: PIN number. Can be set to NULL.
|
||||
* @return None
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_WPS_AP are enabled in platform_opts.h.\n
|
||||
* You can reference @ref cmd_ap_wps() to know how to choose input parameters.
|
||||
*/
|
||||
void wifi_start_ap_wps_thread(u16 config_methods, char *pin);
|
||||
|
||||
/**
|
||||
* @brief Command to start WPS registrar process for commonly use. Can refer to ATWw in atcmd_wifi.c.
|
||||
* @warning Before invoking this function, the Wi-Fi should be in SoftAP mode.
|
||||
* @param[in] argc: Command line argument. Argument count.
|
||||
* @param[in] argv: Command line argument. Argument vector.
|
||||
* @return 0 on success
|
||||
* @note Command style for example:
|
||||
* - cmd_ap_wps pbc
|
||||
* - cmd_ap_wps pin
|
||||
* - cmd_ap_wps pin 12345678
|
||||
* @note Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_WPS_AP are enabled in platform_opts.h.
|
||||
*/
|
||||
void cmd_ap_wps(int argc, char **argv);
|
||||
|
||||
/*\@}*/
|
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Header files of wps_protocol_handler
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _WPS_PROTOCOL_HANDLER_H_
|
||||
#define _WPS_PROTOCOL_HANDLER_H_
|
||||
|
||||
#define KEY_NONCE_LEN 32
|
||||
#define KEY_RC_LEN 8
|
||||
#define KEY_IV_LEN 16
|
||||
#define KEY_RSC_LEN 8
|
||||
#define KEY_ID_LEN 8
|
||||
#define KEY_MIC_LEN 16
|
||||
#define KEY_MATERIAL_LEN 2
|
||||
|
||||
#define ETHER_HDRLEN 14
|
||||
#define LIB1X_EAPOL_HDRLEN 4
|
||||
#define LIB1X_EAPOL_MESSAGE_HDRLEN 5
|
||||
|
||||
#define LIB1X_ETHER_EAPOL_TYPE 0x888E
|
||||
|
||||
#define LIB1X_EAPOL_VER 1 //0000 0001B
|
||||
#define LIB1X_EAPOL_EAPPKT 0 //0000 0000B
|
||||
#define LIB1X_EAPOL_START 1 //0000 0001B
|
||||
#define LIB1X_EAPOL_LOGOFF 2 //0000 0010B
|
||||
#define LIB1X_EAPOL_KEY 3 //0000 0011B
|
||||
#define LIB1X_EAPOL_ENCASFALERT 4 //0000 0100B
|
||||
|
||||
#define LIB1X_EAP_CODE_REQUEST (1)
|
||||
#define LIB1X_EAP_CODE_RESPONSE (2)
|
||||
#define LIB1X_EAP_CODE_FAIL (4)
|
||||
|
||||
#define LIB1X_EAP_TYPE_IDENTITY (1)
|
||||
#define LIB1X_EAP_TYPE_NOTIFICATION (2)
|
||||
#define LIB1X_EAP_TYPE_NAK (3)
|
||||
#define LIB1X_EAP_TYPE_EXPANDED (254) /* Wi-Fi Simple Configuation(WSC) */
|
||||
|
||||
#define LIB1X_EAP_OPCODE_WSC_START (0x01)
|
||||
#define LIB1X_EAP_OPCODE_WSC_ACK (0x02)
|
||||
#define LIB1X_EAP_OPCODE_WSC_NACK (0x03)
|
||||
#define LIB1X_EAP_OPCODE_WSC_MSG (0x04)
|
||||
#define LIB1X_EAP_OPCODE_WSC_DONE (0x05)
|
||||
#define LIB1X_EAP_OPCODE_WSC_FRAG_ACK (0x06)
|
||||
|
||||
#define WPS_START_DELAY_TIME 1000
|
||||
#define WPS_START_RESEND_TIME 10000
|
||||
|
||||
struct rtw_wps_context
|
||||
{
|
||||
/* WPS State Machine */
|
||||
unsigned char clientWpsDone;
|
||||
unsigned char clientWpsProcessing;
|
||||
|
||||
/* Avoid handle duplicated message */
|
||||
unsigned char record_last_message_type;
|
||||
|
||||
/* For handling fragmented messages */
|
||||
unsigned char last_message_has_more_frag;
|
||||
|
||||
unsigned char pad_aligned;
|
||||
unsigned char identifier;
|
||||
|
||||
/* AP passphrase */
|
||||
char passphrase[65];
|
||||
|
||||
/* Keep wps process info */
|
||||
struct eap_wsc_data *wsc_data;
|
||||
struct wps_context * wps;
|
||||
|
||||
/* timer to delay send eapol start */
|
||||
_timer wps_start_timer;
|
||||
};
|
||||
|
||||
struct _LIB1X_EAPOL_WSC
|
||||
{
|
||||
unsigned char Code;
|
||||
unsigned char Identifier;
|
||||
unsigned short Length;
|
||||
|
||||
unsigned char Type;
|
||||
unsigned char Vendor_Id[3];
|
||||
|
||||
unsigned int Vendor_Type;
|
||||
|
||||
unsigned char OpCode;
|
||||
unsigned char Flags;
|
||||
unsigned short Message_Length;
|
||||
|
||||
unsigned char *Message_Data;
|
||||
};
|
||||
|
||||
struct lib1x_eapol_message_hdr
|
||||
{
|
||||
unsigned char Code;
|
||||
unsigned char Identifier;
|
||||
unsigned short Length;
|
||||
unsigned char Type;
|
||||
};
|
||||
|
||||
typedef struct _LIB1X_EAPOL_KEY
|
||||
{
|
||||
unsigned char key_desc_ver;
|
||||
unsigned char key_info[2];
|
||||
unsigned char key_len[2];
|
||||
unsigned char key_replay_counter[KEY_RC_LEN];
|
||||
unsigned char key_nounce[KEY_NONCE_LEN];
|
||||
unsigned char key_iv[KEY_IV_LEN];
|
||||
unsigned char key_rsc[KEY_RSC_LEN];
|
||||
unsigned char key_id[KEY_ID_LEN];
|
||||
unsigned char key_mic[KEY_MIC_LEN];
|
||||
unsigned char key_data_len[KEY_MATERIAL_LEN];
|
||||
unsigned char *key_data;
|
||||
} lib1x_eapol_key;
|
||||
|
||||
struct lib1x_eapol
|
||||
{
|
||||
unsigned char protocol_version;
|
||||
unsigned char packet_type; // This makes it odd in number !
|
||||
unsigned short packet_body_length;
|
||||
};
|
||||
|
||||
struct wlan_ethhdr_t
|
||||
{
|
||||
unsigned char daddr[ETH_ALEN];
|
||||
unsigned char saddr[ETH_ALEN];
|
||||
unsigned short type;
|
||||
};
|
||||
|
||||
extern struct rtw_wps_context g_wps_context;
|
||||
|
||||
extern xqueue_handle_t queue_for_credential;
|
||||
|
||||
int wpas_wps_dev_config(u8 *dev_addr, u8 bregistrar);
|
||||
int wpas_wps_init(const char* ifname);
|
||||
void wpas_wps_deinit(void);
|
||||
int wpas_wps_registrar_button_pushed(void);
|
||||
int wpas_wps_registrar_check_done(void);
|
||||
int wpas_wps_registrar_add_pin(const u8 *pin, size_t pin_len);
|
||||
int wpas_wps_registrar_wps_cancel(void);
|
||||
int wpas_wps_enrollee_init_assoc_ie(void);
|
||||
int wpas_wps_enrollee_init_probe_ie(u16 config_methods);
|
||||
void wpas_wsc_sta_wps_start_hdl(char *buf, int buf_len, int flags, void *userdata);
|
||||
void wpas_wsc_wps_finish_hdl(char *buf, int buf_len, int flags, void *userdata);
|
||||
void wpas_wsc_eapol_recvd_hdl(char *buf, int buf_len, int flags, void *userdata);
|
||||
|
||||
unsigned int wps_pin_valid(unsigned int pin);
|
||||
unsigned int wps_generate_pin(void);
|
||||
//#endif //CONFIG_WPS
|
||||
#endif //_WPS_PROTOCOL_HANDLER_H_
|
2451
lib/wlan/rtl8821cs/api/wifi/wifi_conf.c
Normal file
2451
lib/wlan/rtl8821cs/api/wifi/wifi_conf.c
Normal file
File diff suppressed because it is too large
Load Diff
1061
lib/wlan/rtl8821cs/api/wifi/wifi_conf.h
Normal file
1061
lib/wlan/rtl8821cs/api/wifi/wifi_conf.h
Normal file
File diff suppressed because it is too large
Load Diff
285
lib/wlan/rtl8821cs/api/wifi/wifi_ind.c
Normal file
285
lib/wlan/rtl8821cs/api/wifi/wifi_ind.c
Normal file
@ -0,0 +1,285 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
#include <stdint.h>
|
||||
#include "wifi/wifi_ind.h"
|
||||
#include "wifi/wifi_conf.h"
|
||||
#include "osdep_service.h"
|
||||
#include "basic_types.h"
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
#define WIFI_INDICATE_MSG 0
|
||||
#define WIFI_MANAGER_STACKSIZE 1300
|
||||
#define WIFI_MANAGER_PRIORITY (0) //Actual priority is 4 since calling rtw_create_task
|
||||
#define WIFI_MANAGER_Q_SZ 8
|
||||
|
||||
#define WIFI_EVENT_MAX_ROW 3
|
||||
/******************************************************
|
||||
* Globals
|
||||
******************************************************/
|
||||
|
||||
static event_list_elem_t event_callback_list[WIFI_EVENT_MAX][WIFI_EVENT_MAX_ROW];
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
static rtw_worker_thread_t wifi_worker_thread;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
static rtw_result_t rtw_send_event_to_worker(int event_cmd, char *buf, int buf_len, int flags)
|
||||
{
|
||||
rtw_event_message_t message;
|
||||
int i;
|
||||
rtw_result_t ret = RTW_SUCCESS;
|
||||
char *local_buf = NULL;
|
||||
|
||||
if(event_cmd >= WIFI_EVENT_MAX)
|
||||
return RTW_BADARG;
|
||||
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmd][i].handler == NULL)
|
||||
continue;
|
||||
|
||||
message.function = (event_handler_t)event_callback_list[event_cmd][i].handler;
|
||||
message.buf_len = buf_len;
|
||||
if(buf_len){
|
||||
local_buf = (char*)pvPortMalloc(buf_len);
|
||||
if(local_buf == NULL)
|
||||
return RTW_NOMEM;
|
||||
memcpy(local_buf, buf, buf_len);
|
||||
//DBG_INFO("!!!!!Allocate %p(%d) for evcmd %d\n", local_buf, buf_len, event_cmd);
|
||||
}
|
||||
message.buf = local_buf;
|
||||
message.flags = flags;
|
||||
message.user_data = event_callback_list[event_cmd][i].handler_user_data;
|
||||
|
||||
ret = rtw_push_to_xqueue(&wifi_worker_thread.event_queue, &message, 0);
|
||||
if(ret != RTW_SUCCESS){
|
||||
if(local_buf){
|
||||
DBG_INFO("rtw_send_event_to_worker: enqueue cmd %d failed and free %p(%d)\n", event_cmd, local_buf, buf_len);
|
||||
vPortFree(local_buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
static rtw_result_t rtw_indicate_event_handle(int event_cmd, char *buf, int buf_len, int flags)
|
||||
{
|
||||
rtw_event_handler_t handle = NULL;
|
||||
int i;
|
||||
|
||||
if(event_cmd >= WIFI_EVENT_MAX)
|
||||
return (rtw_result_t)RTW_BADARG;
|
||||
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
handle = event_callback_list[event_cmd][i].handler;
|
||||
if(handle == NULL)
|
||||
continue;
|
||||
handle(buf, buf_len, flags, event_callback_list[event_cmd][i].handler_user_data);
|
||||
}
|
||||
|
||||
return RTW_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
void wifi_indication( rtw_event_indicate_t event, char *buf, int buf_len, int flags)
|
||||
{
|
||||
//
|
||||
// If upper layer application triggers additional operations on receiving of wext_wlan_indicate,
|
||||
// please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() )
|
||||
// , and tries not to share the same stack with wlan driver if remaining stack space is
|
||||
// not available for the following operations.
|
||||
// ex: using semaphore to notice another thread.
|
||||
#if(WIFI_INDICATE_MSG==1)
|
||||
switch(event)
|
||||
{
|
||||
case WIFI_EVENT_DISCONNECT:
|
||||
DBG_INFO("%s():Disconnection indication received", __FUNCTION__);
|
||||
break;
|
||||
case WIFI_EVENT_CONNECT:
|
||||
// For WPA/WPA2 mode, indication of connection does not mean data can be
|
||||
// correctly transmitted or received. Data can be correctly transmitted or
|
||||
// received only when 4-way handshake is done.
|
||||
// Please check WIFI_EVENT_FOURWAY_HANDSHAKE_DONE event
|
||||
// Sample: return mac address
|
||||
if(buf != NULL && buf_len == 6)
|
||||
{
|
||||
DBG_INFO("%s():Connect indication received: %02x:%02x:%02x:%02x:%02x:%02x", __FUNCTION__,
|
||||
buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_FOURWAY_HANDSHAKE_DONE:
|
||||
if(buf != NULL)
|
||||
{
|
||||
if(buf_len == strlen(IW_EXT_STR_FOURWAY_DONE))
|
||||
DBG_INFO("%s():%s", __FUNCTION__, buf);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_RESULT_REPORT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_RESULT_REPORT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_DONE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_RECONNECTION_FAIL:
|
||||
if(buf != NULL){
|
||||
if(buf_len == strlen(IW_EXT_STR_RECONNECTION_FAIL))
|
||||
DBG_INFO("%s", buf);
|
||||
}
|
||||
break;
|
||||
case WIFI_EVENT_NO_NETWORK:
|
||||
DBG_INFO("%s(): WIFI_EVENT_NO_NETWORK\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_RX_MGNT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_RX_MGNT\n", __func__);
|
||||
break;
|
||||
#if CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_SEND_ACTION_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SEND_ACTION_DONE\n", __func__);
|
||||
break;
|
||||
#endif //CONFIG_ENABLE_P2P
|
||||
case WIFI_EVENT_STA_ASSOC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_ASSOC\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISASSOC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_DISASSOC\n", __func__);
|
||||
break;
|
||||
#if CONFIG_WPS
|
||||
case WIFI_EVENT_STA_WPS_START:
|
||||
DBG_INFO("%s(): WIFI_EVENT_STA_WPS_START\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_WPS_FINISH:
|
||||
DBG_INFO("%s(): WIFI_EVENT_WPS_FINISH\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_EAPOL_RECVD:
|
||||
DBG_INFO("%s(): WIFI_EVENT_EAPOL_RECVD\n", __func__);
|
||||
break;
|
||||
#endif
|
||||
case WIFI_EVENT_BEACON_AFTER_DHCP:
|
||||
DBG_INFO("%s(): WIFI_EVENT_BEACON_AFTER_DHCP\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_IP_CHANGED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_IP_CHANNGED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ICV_ERROR:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ICV_ERROR\n", __func__);
|
||||
case WIFI_EVENT_CHALLENGE_FAIL:
|
||||
DBG_INFO("%s(): WIFI_EVENT_CHALLENGE_FAIL\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_START:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_START\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_SCAN_FAILED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_SCAN_FAILED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_AUTHENTICATION:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTHENTICATION\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_AUTH_REJECT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTH_REJECT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_DEAUTH:
|
||||
DBG_INFO("%s(): WIFI_EVENT_DEAUTH\n", __func__);
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_AUTH_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_AUTH_TIMEOUT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOCIATING:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOCIATING\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOCIATED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOCIATED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOC_REJECT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOC_REJECT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_ASSOC_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_EVENT_ASSOC_TIMEOUT\n", __func__);
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_HANDSHAKE_FAILED:
|
||||
DBG_INFO("%s(): WIFI_EVENT_HANDSHAKE_FAILED\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_4WAY_HANDSHAKE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_4WAY_HANDSHAKE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_GROUP_HANDSHAKE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_GROUP_HANDSHAKE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_GROUP_HANDSHAKE_DONE:
|
||||
DBG_INFO("%s(): WIFI_EVENT_GROUP_HANDSHAKE_DONE\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_CONN_TIMEOUT:
|
||||
DBG_INFO("%s(): WIFI_CONN_TIMEOUT\n", __func__);
|
||||
break;
|
||||
case WIFI_EVENT_LEAVE_BUSY_TRAFFIC:
|
||||
DBG_INFO("%s(): WIFI_EVENT_LEAVE_BUSY_TRAFFIC\n", __func__);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_send_event_to_worker(event, buf, buf_len, flags);
|
||||
#else
|
||||
rtw_indicate_event_handle(event, buf, buf_len, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wifi_reg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
if(event_cmds < WIFI_EVENT_MAX){
|
||||
for(i=0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmds][i].handler == NULL){
|
||||
for(j=0; j<WIFI_EVENT_MAX_ROW; j++){
|
||||
if(event_callback_list[event_cmds][j].handler == handler_func){
|
||||
return;
|
||||
}
|
||||
}
|
||||
event_callback_list[event_cmds][i].handler = handler_func;
|
||||
event_callback_list[event_cmds][i].handler_user_data = handler_user_data;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_unreg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func)
|
||||
{
|
||||
int i;
|
||||
if(event_cmds < WIFI_EVENT_MAX){
|
||||
for(i = 0; i < WIFI_EVENT_MAX_ROW; i++){
|
||||
if(event_callback_list[event_cmds][i].handler == handler_func){
|
||||
event_callback_list[event_cmds][i].handler = NULL;
|
||||
event_callback_list[event_cmds][i].handler_user_data = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_event_callback_list(){
|
||||
memset(event_callback_list, 0, sizeof(event_callback_list));
|
||||
}
|
||||
|
||||
int wifi_manager_init()
|
||||
{
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_create_worker_thread(&wifi_worker_thread,
|
||||
WIFI_MANAGER_PRIORITY,
|
||||
WIFI_MANAGER_STACKSIZE,
|
||||
WIFI_MANAGER_Q_SZ);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtw_wifi_manager_deinit()
|
||||
{
|
||||
#if CONFIG_WIFI_IND_USE_THREAD
|
||||
rtw_delete_worker_thread(&wifi_worker_thread);
|
||||
#endif
|
||||
}
|
||||
|
104
lib/wlan/rtl8821cs/api/wifi/wifi_ind.h
Normal file
104
lib/wlan/rtl8821cs/api/wifi/wifi_ind.h
Normal file
@ -0,0 +1,104 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
* @file wifi_ind.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the functions related to event handler mechanism.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_INDICATE_H
|
||||
#define _WIFI_INDICATE_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "wifi_conf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*rtw_event_handler_t)(char *buf, int buf_len, int flags, void* handler_user_data );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// rtw_event_indicate_t event_cmd;
|
||||
rtw_event_handler_t handler;
|
||||
void* handler_user_data;
|
||||
} event_list_elem_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the event callback list.
|
||||
* @warning Please make sure this function has been invoked before
|
||||
* using the event handler related mechanism.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void init_event_callback_list(void);
|
||||
|
||||
/**
|
||||
* @brief Wlan driver indicate event to upper layer through wifi_indication.
|
||||
* @param[in] event: An event reported from driver to upper layer application. Please refer to rtw_event_indicate_t enum.
|
||||
* @param[in] buf: If it is not NUL, buf is a pointer to the buffer for message string.
|
||||
* @param[in] buf_len: The length of the buffer.
|
||||
* @param[in] flags: Indicate some extra information, sometimes it is 0.
|
||||
* @retval None
|
||||
* @note If upper layer application triggers additional operations on receiving of wext_wlan_indicate,
|
||||
* please strictly check current stack size usage (by using uxTaskGetStackHighWaterMark() ),
|
||||
* and tries not to share the same stack with wlan driver if remaining stack space is not available
|
||||
* for the following operations.
|
||||
* ex: using semaphore to notice another thread instead of handing event directly in wifi_indication().
|
||||
*/
|
||||
extern void wifi_indication( rtw_event_indicate_t event, char *buf, int buf_len, int flags);
|
||||
|
||||
/**
|
||||
* @brief Register the event listener.
|
||||
* @param[in] event_cmds : The event command number indicated.
|
||||
* @param[in] handler_func : the callback function which will
|
||||
* receive and process the event.
|
||||
* @param[in] handler_user_data : user specific data that will be
|
||||
* passed directly to the callback function.
|
||||
* @return RTW_SUCCESS : if successfully registers the event.
|
||||
* @return RTW_ERROR : if an error occurred.
|
||||
* @note Set the same event_cmds with empty handler_func will
|
||||
* unregister the event_cmds.
|
||||
*/
|
||||
extern void wifi_reg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func, void *handler_user_data);
|
||||
|
||||
/**
|
||||
* @brief Un-register the event listener.
|
||||
* @param[in] event_cmds : The event command number indicated.
|
||||
* @param[in] handler_func : the callback function which will
|
||||
* receive and process the event.
|
||||
*
|
||||
* @return RTW_SUCCESS : if successfully un-registers the event .
|
||||
* @return RTW_ERROR : if an error occurred.
|
||||
*/
|
||||
extern void wifi_unreg_event_handler(unsigned int event_cmds, rtw_event_handler_t handler_func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif //_WIFI_INDICATE_H
|
||||
|
445
lib/wlan/rtl8821cs/api/wifi/wifi_promisc.c
Normal file
445
lib/wlan/rtl8821cs/api/wifi/wifi_promisc.c
Normal file
@ -0,0 +1,445 @@
|
||||
#include <osdep_service.h>
|
||||
#include "wifi/wifi_conf.h"
|
||||
#ifndef CONFIG_WLAN
|
||||
#define CONFIG_WLAN 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_WLAN
|
||||
#include <basic_types.h>
|
||||
|
||||
extern void _promisc_deinit(void *padapter);
|
||||
extern int _promisc_recv_func(void *padapter, void *rframe);
|
||||
extern int _promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used);
|
||||
extern unsigned char _is_promisc_enabled(void);
|
||||
extern int _promisc_get_fixed_channel(void * fixed_bssid, u8 *ssid, int * ssid_length);
|
||||
extern void _promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac);
|
||||
// Add extra interfaces to make release sdk able to determine promisc API linking
|
||||
void promisc_deinit(void *padapter)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
_promisc_deinit(padapter);
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_recv_func(void *padapter, void *rframe)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_recv_func(padapter, rframe);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_recv_lens_func(void *padapter, u8 *payload, u8 plen)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
return _promisc_recv_lens_func(padapter, payload, plen);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_filter_with_len(u16 len)
|
||||
{
|
||||
// Never reach here if not define CONFIG_PROMISC
|
||||
#if CONFIG_PROMISC
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
return _promisc_filter_with_len(len);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_set(rtw_rcr_level_t enabled, void (*callback)(unsigned char*, unsigned int, void*), unsigned char len_used)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_set(enabled, callback, len_used);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char is_promisc_enabled(void)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _is_promisc_enabled();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int promisc_get_fixed_channel(void *fixed_bssid, u8 *ssid, int *ssid_length)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
return _promisc_get_fixed_channel(fixed_bssid, ssid, ssid_length);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac, void *phone_mac)
|
||||
{
|
||||
#if CONFIG_PROMISC
|
||||
_promisc_filter_by_ap_and_phone_mac(enable, ap_mac, phone_mac);
|
||||
#endif
|
||||
}
|
||||
|
||||
// End of Add extra interfaces
|
||||
|
||||
struct eth_frame {
|
||||
struct eth_frame *prev;
|
||||
struct eth_frame *next;
|
||||
unsigned char da[6];
|
||||
unsigned char sa[6];
|
||||
unsigned int len;
|
||||
unsigned char type;
|
||||
signed char rssi;
|
||||
};
|
||||
|
||||
struct eth_buffer {
|
||||
struct eth_frame *head;
|
||||
struct eth_frame *tail;
|
||||
};
|
||||
|
||||
static struct eth_buffer eth_buffer;
|
||||
|
||||
#if CONFIG_PROMISC
|
||||
#define MAX_PACKET_FILTER_INFO 5
|
||||
#define FILTER_ID_INIT_VALUE 10
|
||||
rtw_packet_filter_info_t paff_array[MAX_PACKET_FILTER_INFO]={0, 0, 0, 0, 0};
|
||||
static u8 packet_filter_enable_num = 0;
|
||||
|
||||
void promisc_init_packet_filter()
|
||||
{
|
||||
int i = 0;
|
||||
for(i=0; i<MAX_PACKET_FILTER_INFO; i++){
|
||||
paff_array[i].filter_id = FILTER_ID_INIT_VALUE;
|
||||
paff_array[i].enable = 0;
|
||||
paff_array[i].patt.mask_size = 0;
|
||||
paff_array[i].rule = RTW_POSITIVE_MATCHING;
|
||||
paff_array[i].patt.mask = NULL;
|
||||
paff_array[i].patt.pattern = NULL;
|
||||
}
|
||||
packet_filter_enable_num = 0;
|
||||
}
|
||||
|
||||
int promisc_add_packet_filter(u8 filter_id, rtw_packet_filter_pattern_t *patt, rtw_packet_filter_rule_t rule)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == FILTER_ID_INIT_VALUE){
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].filter_id = filter_id;
|
||||
|
||||
paff_array[i].patt.offset= patt->offset;
|
||||
paff_array[i].patt.mask_size = patt->mask_size;
|
||||
paff_array[i].patt.mask = rtw_malloc(patt->mask_size);
|
||||
memcpy(paff_array[i].patt.mask, patt->mask, patt->mask_size);
|
||||
paff_array[i].patt.pattern= rtw_malloc(patt->mask_size);
|
||||
memcpy(paff_array[i].patt.pattern, patt->pattern, patt->mask_size);
|
||||
|
||||
paff_array[i].rule = rule;
|
||||
paff_array[i].enable = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_enable_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].enable = 1;
|
||||
packet_filter_enable_num++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_disable_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].enable = 0;
|
||||
packet_filter_enable_num--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int promisc_remove_packet_filter(u8 filter_id)
|
||||
{
|
||||
int i = 0;
|
||||
while(i < MAX_PACKET_FILTER_INFO){
|
||||
if(paff_array[i].filter_id == filter_id)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(i == MAX_PACKET_FILTER_INFO)
|
||||
return -1;
|
||||
|
||||
paff_array[i].filter_id = FILTER_ID_INIT_VALUE;
|
||||
paff_array[i].enable = 0;
|
||||
paff_array[i].patt.mask_size = 0;
|
||||
paff_array[i].rule = 0;
|
||||
if(paff_array[i].patt.mask){
|
||||
rtw_free(paff_array[i].patt.mask);
|
||||
paff_array[i].patt.mask = NULL;
|
||||
}
|
||||
|
||||
if(paff_array[i].patt.pattern){
|
||||
rtw_free(paff_array[i].patt.pattern);
|
||||
paff_array[i].patt.pattern = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make callback simple to prevent latency to wlan rx when promiscuous mode */
|
||||
static void promisc_callback(unsigned char *buf, unsigned int len, void* userdata)
|
||||
{
|
||||
struct eth_frame *frame = (struct eth_frame *) rtw_malloc(sizeof(struct eth_frame));
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
if(frame) {
|
||||
frame->prev = NULL;
|
||||
frame->next = NULL;
|
||||
memcpy(frame->da, buf, 6);
|
||||
memcpy(frame->sa, buf+6, 6);
|
||||
frame->len = len;
|
||||
frame->rssi = ((ieee80211_frame_info_t *)userdata)->rssi;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
if(eth_buffer.tail) {
|
||||
eth_buffer.tail->next = frame;
|
||||
frame->prev = eth_buffer.tail;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = frame;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
|
||||
struct eth_frame* retrieve_frame(void)
|
||||
{
|
||||
struct eth_frame *frame = NULL;
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
if(eth_buffer.head) {
|
||||
frame = eth_buffer.head;
|
||||
|
||||
if(eth_buffer.head->next) {
|
||||
eth_buffer.head = eth_buffer.head->next;
|
||||
eth_buffer.head->prev = NULL;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
static void promisc_test(int duration, unsigned char len_used)
|
||||
{
|
||||
int ch;
|
||||
unsigned int start_time;
|
||||
struct eth_frame *frame;
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
|
||||
wifi_enter_promisc_mode();
|
||||
wifi_set_promisc(RTW_PROMISC_ENABLE, promisc_callback, len_used);
|
||||
|
||||
for(ch = 1; ch <= 13; ch ++) {
|
||||
if(wifi_set_channel(ch) == 0)
|
||||
DBG_INFO("Switch to channel(%d)", ch);
|
||||
|
||||
start_time = rtw_get_current_time();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = rtw_get_current_time();
|
||||
|
||||
if(rtw_systime_to_ms(current_time - start_time) < duration) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
DBG_INFO("DA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->da[i]);
|
||||
printk(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->sa[i]);
|
||||
printk(", len=%d", frame->len);
|
||||
printk(", RSSI=%d", frame->rssi);
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
else
|
||||
rtw_mdelay_os(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
|
||||
static void promisc_callback_all(unsigned char *buf, unsigned int len, void* userdata)
|
||||
{
|
||||
struct eth_frame *frame = (struct eth_frame *) rtw_malloc(sizeof(struct eth_frame));
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
|
||||
if(frame) {
|
||||
frame->prev = NULL;
|
||||
frame->next = NULL;
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
if(((ieee80211_frame_info_t *)userdata)->type == RTW_RX_UNSUPPORT){
|
||||
//NOTICE: buf structure now is rtw_rx_info_t.
|
||||
frame->type = 0xFF;
|
||||
memset(frame->da, 0, 6);
|
||||
memset(frame->sa, 0, 6);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
memcpy(frame->da, buf+4, 6);
|
||||
memcpy(frame->sa, buf+10, 6);
|
||||
frame->type = *buf;
|
||||
}
|
||||
|
||||
frame->len = len;
|
||||
/*
|
||||
* type is the first byte of Frame Control Field of 802.11 frame
|
||||
* If the from/to ds information is needed, type could be reused as follows:
|
||||
* frame->type = ((((ieee80211_frame_info_t *)userdata)->i_fc & 0x0100) == 0x0100) ? 2 : 1;
|
||||
* 1: from ds; 2: to ds
|
||||
*/
|
||||
|
||||
frame->rssi = ((ieee80211_frame_info_t *)userdata)->rssi;
|
||||
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
|
||||
if(eth_buffer.tail) {
|
||||
eth_buffer.tail->next = frame;
|
||||
frame->prev = eth_buffer.tail;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
else {
|
||||
eth_buffer.head = frame;
|
||||
eth_buffer.tail = frame;
|
||||
}
|
||||
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
static void promisc_test_all(int duration, unsigned char len_used)
|
||||
{
|
||||
int ch;
|
||||
unsigned int start_time;
|
||||
struct eth_frame *frame;
|
||||
eth_buffer.head = NULL;
|
||||
eth_buffer.tail = NULL;
|
||||
|
||||
wifi_enter_promisc_mode();
|
||||
wifi_set_promisc(RTW_PROMISC_ENABLE_2, promisc_callback_all, len_used);
|
||||
|
||||
for(ch = 1; ch <= 13; ch ++) {
|
||||
if(wifi_set_channel(ch) == 0)
|
||||
DBG_INFO("Switch to channel(%d)", ch);
|
||||
|
||||
start_time = rtw_get_current_time();
|
||||
|
||||
while(1) {
|
||||
unsigned int current_time = rtw_get_current_time();
|
||||
|
||||
if(rtw_systime_to_ms(current_time - start_time) < duration) {
|
||||
frame = retrieve_frame();
|
||||
|
||||
if(frame) {
|
||||
int i;
|
||||
DBG_INFO("TYPE: 0x%x, ", frame->type);
|
||||
printk("DA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->da[i]);
|
||||
printk(", SA:");
|
||||
for(i = 0; i < 6; i ++)
|
||||
printk(" %02x", frame->sa[i]);
|
||||
printk(", len=%d", frame->len);
|
||||
printk(", RSSI=%d", frame->rssi);
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
else
|
||||
rtw_mdelay_os(1); //delay 1 tick
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wifi_set_promisc(RTW_PROMISC_DISABLE, NULL, 0);
|
||||
|
||||
while((frame = retrieve_frame()) != NULL)
|
||||
rtw_free((void *) frame);
|
||||
}
|
||||
|
||||
void cmd_promisc(int argc, char **argv)
|
||||
{
|
||||
int duration;
|
||||
#if CONFIG_PROMISC
|
||||
wifi_init_packet_filter();
|
||||
#endif
|
||||
if((argc == 2) && ((duration = atoi(argv[1])) > 0))
|
||||
//promisc_test(duration, 0);
|
||||
promisc_test_all(duration, 0);
|
||||
else if((argc == 3) && ((duration = atoi(argv[1])) > 0) && (strcmp(argv[2], "with_len") == 0))
|
||||
promisc_test(duration, 1);
|
||||
else
|
||||
DBG_INFO("Usage: %s DURATION_SECONDS [with_len]", argv[0]);
|
||||
}
|
||||
#endif //#if CONFIG_WLAN
|
1894
lib/wlan/rtl8821cs/api/wifi/wifi_util.c
Normal file
1894
lib/wlan/rtl8821cs/api/wifi/wifi_util.c
Normal file
File diff suppressed because it is too large
Load Diff
134
lib/wlan/rtl8821cs/api/wifi/wifi_util.h
Normal file
134
lib/wlan/rtl8821cs/api/wifi/wifi_util.h
Normal file
@ -0,0 +1,134 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef _UTIL_H
|
||||
#define _UTIL_H
|
||||
|
||||
#include <wireless.h>
|
||||
#include <wlan_intf.h>
|
||||
#include <wifi_constants.h>
|
||||
#include "wifi_structures.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int wext_get_ssid(const char *ifname, __u8 *ssid);
|
||||
int wext_set_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||
int wext_set_bssid(const char *ifname, const __u8 *bssid);
|
||||
int wext_get_bssid(const char *ifname, __u8 *bssid);
|
||||
int wext_set_auth_param(const char *ifname, __u16 idx, __u32 value);
|
||||
int wext_set_mfp_support(const char *ifname, __u8 value);
|
||||
#if CONFIG_SAE_SUPPORT
|
||||
int wext_set_group_id(const char *ifname, __u8 value);
|
||||
#endif
|
||||
#if CONFIG_PMKSA_CACHING
|
||||
int wext_set_pmk_cache_enable(const char *ifname, __u8 value);
|
||||
#endif
|
||||
int wext_set_key_ext(const char *ifname, __u16 alg, const __u8 *addr, int key_idx, int set_tx, const __u8 *seq, __u16 seq_len, __u8 *key, __u16 key_len);
|
||||
int wext_get_enc_ext(const char *ifname, __u16 *alg, __u8 *key_idx, __u8 *passphrase);
|
||||
int wext_set_passphrase(const char *ifname, const __u8 *passphrase, __u16 passphrase_len);
|
||||
int wext_get_passphrase(const char *ifname, __u8 *passphrase);
|
||||
int wext_set_mode(const char *ifname, int mode);
|
||||
int wext_get_mode(const char *ifname, int *mode);
|
||||
int wext_set_ap_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len);
|
||||
int wext_set_country(const char *ifname, rtw_country_code_t country_code);
|
||||
int wext_get_rssi(const char *ifname, int *rssi);
|
||||
int wext_set_channel(const char *ifname, __u8 ch);
|
||||
int wext_get_channel(const char *ifname, __u8 *ch);
|
||||
#if CONFIG_MULTICAST
|
||||
int wext_register_multicast_address(const char *ifname, rtw_mac_t *mac);
|
||||
int wext_unregister_multicast_address(const char *ifname, rtw_mac_t *mac);
|
||||
int wext_enable_multicast_address_filter(const char *ifname);
|
||||
int wext_disable_multicast_address_filter(const char *ifname);
|
||||
#endif
|
||||
int wext_set_scan(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_get_scan(const char *ifname, char *buf, __u16 buf_len);
|
||||
int wext_set_mac_address(const char *ifname, char * mac);
|
||||
int wext_get_mac_address(const char *ifname, char * mac);
|
||||
int wext_enable_powersave(const char *ifname, __u8 lps_mode, __u8 ips_mode);
|
||||
int wext_disable_powersave(const char *ifname);
|
||||
int wext_set_tdma_param(const char *ifname, __u8 slot_period, __u8 rfon_period_len_1, __u8 rfon_period_len_2, __u8 rfon_period_len_3);
|
||||
int wext_set_lps_dtim(const char *ifname, __u8 lps_dtim);
|
||||
int wext_get_lps_dtim(const char *ifname, __u8 *lps_dtim);
|
||||
int wext_set_lps_level(const char *ifname, __u8 lps_level);
|
||||
int wext_get_tx_power(const char *ifname, __u8 *poweridx);
|
||||
int wext_set_txpower(const char *ifname, int poweridx);
|
||||
int wext_get_associated_client_list(const char *ifname, void * client_list_buffer, __u16 buffer_length);
|
||||
int wext_get_ap_info(const char *ifname, rtw_bss_info_t * ap_info, rtw_security_t* security);
|
||||
int wext_mp_command(const char *ifname, char *cmd, int show_msg);
|
||||
int wext_private_command(const char *ifname, char *cmd, int show_msg);
|
||||
int wext_private_command_with_retval(const char *ifname, char *cmd, char *ret_buf, int ret_len);
|
||||
void wext_wlan_indicate(unsigned int cmd, union iwreq_data *wrqu, char *extra);
|
||||
int wext_set_pscan_channel(const char *ifname, __u8 *ch, __u8 *pscan_config, __u8 length);
|
||||
int wext_set_autoreconnect(const char *ifname, __u8 mode, __u8 retry_times, __u16 timeout);
|
||||
int wext_get_autoreconnect(const char *ifname, __u8 *mode);
|
||||
int wext_set_adaptivity(rtw_adaptivity_mode_t adaptivity_mode);
|
||||
int wext_set_adaptivity_th_l2h_ini(__u8 l2h_threshold);
|
||||
int wext_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned char channel_num);
|
||||
int wext_set_sta_num(unsigned char ap_sta_num);
|
||||
int wext_set_expire_time(unsigned char ap_expire_time);
|
||||
int wext_del_station(const char *ifname, unsigned char* hwaddr);
|
||||
int wext_init_mac_filter(void);
|
||||
int wext_deinit_mac_filter(void);
|
||||
int wext_add_mac_filter(unsigned char* hwaddr);
|
||||
int wext_del_mac_filter(unsigned char* hwaddr);
|
||||
void wext_set_indicate_mgnt(int enable);
|
||||
#ifdef CONFIG_SW_MAILBOX_EN
|
||||
int wext_mailbox_to_wifi(const char *ifname, char *buf, __u16 buf_len);
|
||||
#endif
|
||||
#if CONFIG_CUSTOM_IE
|
||||
int wext_add_custom_ie(const char *ifname, void * cus_ie, int ie_num);
|
||||
int wext_update_custom_ie(const char *ifname, void * cus_ie, int ie_index);
|
||||
int wext_del_custom_ie(const char *ifname);
|
||||
#endif
|
||||
|
||||
#define wext_handshake_done rltk_wlan_handshake_done
|
||||
|
||||
int wext_send_mgnt(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_send_eapol(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_set_gen_ie(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_get_drv_ability(const char *ifname, __u32 *ability);
|
||||
int wext_enable_forwarding(const char *ifname);
|
||||
int wext_disable_forwarding(const char *ifname);
|
||||
int wext_set_ch_deauth(const char *ifname, __u8 enable);
|
||||
|
||||
#if CONFIG_WOWLAN
|
||||
int wext_wowlan_ctrl(const char *ifname, int enable);
|
||||
int wext_wowlan_set_pattern(const char *ifname, wowlan_pattern_t pattern);
|
||||
int wext_wowlan_unicast_wake_ctrl(const char *ifname, unsigned char enable);
|
||||
#endif
|
||||
int wext_enable_rawdata_recv(const char *ifname, void *fun);
|
||||
int wext_disable_rawdata_recv(const char *ifname);
|
||||
int wext_send_rawdata(const char *ifname,const unsigned char* frame_buf, unsigned int frame_len);
|
||||
int wext_enable_adaptivity(const char *ifname);
|
||||
int wext_disable_adaptivity(const char *ifname);
|
||||
int wext_get_real_time_data_rate_info(const char *ifname, unsigned char *prate, unsigned char *pshort_gi, unsigned char *pbandwidth);
|
||||
int wext_get_snr(const char *ifname, unsigned char *ofdm_snr, unsigned char *ht_snr);
|
||||
int wext_set_retry_limit(const char *ifname, unsigned char retry_limit);
|
||||
#ifndef u8
|
||||
#define u8 uint8_t
|
||||
#endif
|
||||
int wext_set_lps_thresh(const char *ifname, u8 low_thresh);
|
||||
int wext_set_beacon_mode(const char *ifname, __u8 mode);
|
||||
int wext_set_multiscan(const char *ifname, char *buf, __u16 buf_len, __u16 flags);
|
||||
int wext_set_scan_reorderchannel(const char *ifname, __u8 *ch, __u8 length);
|
||||
int wext_set_countrycode(const char *ifname, u8 *country_code);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UTIL_H */
|
||||
|
1559
lib/wlan/rtl8821cs/api/wifi_interactive_mode.c
Normal file
1559
lib/wlan/rtl8821cs/api/wifi_interactive_mode.c
Normal file
File diff suppressed because it is too large
Load Diff
1082
lib/wlan/rtl8821cs/include/autoconf.h
Normal file
1082
lib/wlan/rtl8821cs/include/autoconf.h
Normal file
File diff suppressed because it is too large
Load Diff
459
lib/wlan/rtl8821cs/include/basic_types.h
Normal file
459
lib/wlan/rtl8821cs/include/basic_types.h
Normal file
@ -0,0 +1,459 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __BASIC_TYPES_H__
|
||||
#define __BASIC_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#undef _FAIL
|
||||
#define _FAIL 0
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
#define _TRUE TRUE
|
||||
#define _FALSE FALSE
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define __weak __attribute__((weak))
|
||||
#define likely(x) __builtin_expect ((x), 1)
|
||||
#define unlikely(x) __builtin_expect ((x), 0)
|
||||
#endif
|
||||
|
||||
typedef unsigned int uint;
|
||||
typedef signed int sint;
|
||||
|
||||
#ifdef __ICCARM__
|
||||
typedef signed long long __int64_t;
|
||||
typedef unsigned long long __uint64_t;
|
||||
#endif
|
||||
|
||||
#define s8 int8_t
|
||||
#define u8 uint8_t
|
||||
#define s16 int16_t
|
||||
#define u16 uint16_t
|
||||
#define s32 int32_t
|
||||
#define u32 uint32_t
|
||||
#define s64 int64_t
|
||||
#define u64 uint64_t
|
||||
|
||||
#ifndef BOOL
|
||||
typedef unsigned char BOOL;
|
||||
#endif
|
||||
#ifndef bool
|
||||
typedef unsigned char bool;
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
#ifndef bool
|
||||
typedef unsigned char bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define UCHAR uint8_t
|
||||
#define USHORT uint16_t
|
||||
#define UINT uint32_t
|
||||
#define ULONG uint32_t
|
||||
|
||||
//typedef struct { volatile int counter; } atomic_t;
|
||||
|
||||
typedef enum _RTK_STATUS_ {
|
||||
_EXIT_SUCCESS = 0,
|
||||
_EXIT_FAILURE = 1
|
||||
}RTK_STATUS, *PRTK_STATUS;
|
||||
|
||||
#define IN
|
||||
#define OUT
|
||||
#define VOID void
|
||||
#define INOUT
|
||||
#define NDIS_OID uint
|
||||
#define NDIS_STATUS uint
|
||||
|
||||
#ifndef PVOID
|
||||
typedef void * PVOID;
|
||||
#endif
|
||||
|
||||
typedef u32 dma_addr_t;
|
||||
|
||||
typedef void (*proc_t)(void*);
|
||||
|
||||
typedef unsigned int __kernel_size_t;
|
||||
typedef int __kernel_ssize_t;
|
||||
|
||||
typedef __kernel_size_t SIZE_T;
|
||||
typedef __kernel_ssize_t SSIZE_T;
|
||||
#define FIELD_OFFSET(s,field) ((SSIZE_T)&((s*)(0))->field)
|
||||
|
||||
#define MEM_ALIGNMENT_OFFSET (sizeof (SIZE_T))
|
||||
#define MEM_ALIGNMENT_PADDING (sizeof(SIZE_T) - 1)
|
||||
|
||||
#define SIZE_PTR SIZE_T
|
||||
#define SSIZE_PTR SSIZE_T
|
||||
|
||||
#ifndef ON
|
||||
#define ON 1
|
||||
#endif
|
||||
|
||||
#ifndef OFF
|
||||
#define OFF 0
|
||||
#endif
|
||||
#if 0
|
||||
#define BIT0 0x0001
|
||||
#define BIT1 0x0002
|
||||
#define BIT2 0x0004
|
||||
#define BIT3 0x0008
|
||||
#define BIT4 0x0010
|
||||
#define BIT5 0x0020
|
||||
#define BIT6 0x0040
|
||||
#define BIT7 0x0080
|
||||
#define BIT8 0x0100
|
||||
#define BIT9 0x0200
|
||||
#define BIT10 0x0400
|
||||
#define BIT11 0x0800
|
||||
#define BIT12 0x1000
|
||||
#define BIT13 0x2000
|
||||
#define BIT14 0x4000
|
||||
#define BIT15 0x8000
|
||||
#define BIT16 0x00010000
|
||||
#define BIT17 0x00020000
|
||||
#define BIT18 0x00040000
|
||||
#define BIT19 0x00080000
|
||||
#define BIT20 0x00100000
|
||||
#define BIT21 0x00200000
|
||||
#define BIT22 0x00400000
|
||||
#define BIT23 0x00800000
|
||||
#define BIT24 0x01000000
|
||||
#define BIT25 0x02000000
|
||||
#define BIT26 0x04000000
|
||||
#define BIT27 0x08000000
|
||||
#define BIT28 0x10000000
|
||||
#define BIT29 0x20000000
|
||||
#define BIT30 0x40000000
|
||||
#define BIT31 0x80000000
|
||||
#endif
|
||||
#define BIT_(__n) (1<<(__n))
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(__n) (1<<(__n))
|
||||
#endif
|
||||
|
||||
#if defined (__ICCARM__)
|
||||
#define STRINGIFY(s) #s
|
||||
#define SECTION(_name) _Pragma( STRINGIFY(location=_name))
|
||||
#define ALIGNMTO(_bound) _Pragma( STRINGIFY(data_alignment=_bound))
|
||||
#define _PACKED_ __packed
|
||||
#define _LONG_CALL_
|
||||
#define _LONG_CALL_ROM_
|
||||
#define _WEAK __weak
|
||||
#else
|
||||
#define SECTION(_name) __attribute__ ((__section__(_name)))
|
||||
#define ALIGNMTO(_bound) __attribute__ ((aligned (_bound)))
|
||||
#define _PACKED_ __attribute__ ((packed))
|
||||
#ifdef CONFIG_RELEASE_BUILD_LIBRARIES
|
||||
#define _LONG_CALL_
|
||||
#define _LONG_CALL_ROM_ __attribute__ ((long_call))
|
||||
#ifdef E_CUT_ROM_DOMAIN
|
||||
#undef _LONG_CALL_ROM_
|
||||
#define _LONG_CALL_ROM_
|
||||
#endif
|
||||
#else
|
||||
#define _LONG_CALL_ __attribute__ ((long_call))
|
||||
#define _LONG_CALL_ROM_ _LONG_CALL_
|
||||
#endif
|
||||
#define _WEAK __attribute__ ((weak))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//port from fw by thomas
|
||||
// TODO: Belows are Sync from SD7-Driver. It is necessary to check correctness
|
||||
|
||||
#define SWAP32(x) ((u32)( \
|
||||
(((u32)(x) & (u32)0x000000ff) << 24) | \
|
||||
(((u32)(x) & (u32)0x0000ff00) << 8) | \
|
||||
(((u32)(x) & (u32)0x00ff0000) >> 8) | \
|
||||
(((u32)(x) & (u32)0xff000000) >> 24)))
|
||||
|
||||
#define WAP16(x) ((u16)( \
|
||||
(((u16)(x) & (u16)0x00ff) << 8) | \
|
||||
(((u16)(x) & (u16)0xff00) >> 8)))
|
||||
|
||||
|
||||
/*
|
||||
* Call endian free function when
|
||||
* 1. Read/write packet content.
|
||||
* 2. Before write integer to IO.
|
||||
* 3. After read integer from IO.
|
||||
*/
|
||||
|
||||
//
|
||||
// Byte Swapping routine.
|
||||
//
|
||||
#define EF1Byte (u8)
|
||||
#define EF2Byte le16_to_cpu
|
||||
#define EF4Byte le32_to_cpu
|
||||
|
||||
//
|
||||
// Read LE format data from memory
|
||||
//
|
||||
#define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr)))
|
||||
#define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr)))
|
||||
#define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr)))
|
||||
|
||||
//
|
||||
// Write LE data to memory
|
||||
//
|
||||
#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val)
|
||||
#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val)
|
||||
#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val)
|
||||
|
||||
//
|
||||
// Example:
|
||||
// BIT_LEN_MASK_32(0) => 0x00000000
|
||||
// BIT_LEN_MASK_32(1) => 0x00000001
|
||||
// BIT_LEN_MASK_32(2) => 0x00000003
|
||||
// BIT_LEN_MASK_32(32) => 0xFFFFFFFF
|
||||
//
|
||||
#define BIT_LEN_MASK_32(__BitLen) \
|
||||
(0xFFFFFFFF >> (32 - (__BitLen)))
|
||||
//
|
||||
// Example:
|
||||
// BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003
|
||||
// BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000
|
||||
//
|
||||
#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_32(__BitLen) << (__BitOffset))
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Return 4-byte value in host byte ordering from
|
||||
// 4-byte pointer in litten-endian system.
|
||||
//
|
||||
#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
|
||||
(EF4Byte(*((u32 *)(__pStart))))
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Translate subfield (continuous bits in little-endian) of 4-byte value in litten byte to
|
||||
// 4-byte value in host byte ordering.
|
||||
//
|
||||
#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_32(__BitLen) \
|
||||
)
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Mask subfield (continuous bits in little-endian) of 4-byte value in litten byte oredering
|
||||
// and return the result in 4-byte value in host byte ordering.
|
||||
//
|
||||
#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
|
||||
& \
|
||||
( ~ BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
//
|
||||
// Description:
|
||||
// Set subfield of little-endian 4-byte value to specified value.
|
||||
//
|
||||
#define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u32 *)(__pStart)) = \
|
||||
EF4Byte( \
|
||||
LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
|
||||
#define BIT_LEN_MASK_16(__BitLen) \
|
||||
(0xFFFF >> (16 - (__BitLen)))
|
||||
|
||||
#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
|
||||
|
||||
#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
||||
(EF2Byte(*((u16 *)(__pStart))))
|
||||
|
||||
#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_16(__BitLen) \
|
||||
)
|
||||
|
||||
#define LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
|
||||
& \
|
||||
( ~ BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
#define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u16 *)(__pStart)) = \
|
||||
EF2Byte( \
|
||||
LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
#define BIT_LEN_MASK_8(__BitLen) \
|
||||
(0xFF >> (8 - (__BitLen)))
|
||||
|
||||
#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
|
||||
(BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
|
||||
|
||||
#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
(EF1Byte(*((u8 *)(__pStart))))
|
||||
|
||||
#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \
|
||||
& \
|
||||
BIT_LEN_MASK_8(__BitLen) \
|
||||
)
|
||||
|
||||
#define LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
& \
|
||||
( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \
|
||||
)
|
||||
|
||||
#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
*((u8 *)(__pStart)) = \
|
||||
EF1Byte( \
|
||||
LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \
|
||||
);
|
||||
|
||||
//pclint
|
||||
#define LE_BITS_CLEARED_TO_1BYTE_8BIT(__pStart, __BitOffset, __BitLen) \
|
||||
( \
|
||||
LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
|
||||
)
|
||||
|
||||
//pclint
|
||||
#define SET_BITS_TO_LE_1BYTE_8BIT(__pStart, __BitOffset, __BitLen, __Value) \
|
||||
{ \
|
||||
*((pu1Byte)(__pStart)) = \
|
||||
EF1Byte( \
|
||||
LE_BITS_CLEARED_TO_1BYTE_8BIT(__pStart, __BitOffset, __BitLen) \
|
||||
| \
|
||||
((u1Byte)__Value) \
|
||||
); \
|
||||
}
|
||||
|
||||
// Get the N-bytes aligment offset from the current length
|
||||
#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment))
|
||||
|
||||
typedef unsigned char BOOLEAN,*PBOOLEAN,boolean;
|
||||
|
||||
#define TEST_FLAG(__Flag,__testFlag) (((__Flag) & (__testFlag)) != 0)
|
||||
#define SET_FLAG(__Flag, __setFlag) ((__Flag) |= __setFlag)
|
||||
#define CLEAR_FLAG(__Flag, __clearFlag) ((__Flag) &= ~(__clearFlag))
|
||||
#define CLEAR_FLAGS(__Flag) ((__Flag) = 0)
|
||||
#define TEST_FLAGS(__Flag, __testFlags) (((__Flag) & (__testFlags)) == (__testFlags))
|
||||
|
||||
/* Define compilor specific symbol */
|
||||
//
|
||||
// inline function
|
||||
//
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#define __inline__ inline
|
||||
#define __inline inline
|
||||
#define __inline_definition //In dialect C99, inline means that a function's definition is provided
|
||||
//only for inlining, and that there is another definition
|
||||
//(without inline) somewhere else in the program.
|
||||
//That means that this program is incomplete, because if
|
||||
//add isn't inlined (for example, when compiling without optimization),
|
||||
//then main will have an unresolved reference to that other definition.
|
||||
|
||||
// Do not inline function is the function body is defined .c file and this
|
||||
// function will be called somewhere else, otherwise there is compile error
|
||||
#elif defined ( __CC_ARM )
|
||||
#define __inline__ __inline //__linine__ is not supported in keil compilor, use __inline instead
|
||||
#define inline __inline
|
||||
#define __inline_definition // for dialect C99
|
||||
#elif defined ( __GNUC__ )
|
||||
#define __inline__ inline
|
||||
#define __inline inline
|
||||
#define __inline_definition inline
|
||||
#endif
|
||||
|
||||
//
|
||||
// pack
|
||||
//
|
||||
|
||||
#if defined (__ICCARM__)
|
||||
|
||||
#define RTW_PACK_STRUCT_BEGIN _Pragma( STRINGIFY(pack(1)))
|
||||
#define RTW_PACK_STRUCT_STRUCT
|
||||
#define RTW_PACK_STRUCT_END _Pragma( STRINGIFY(pack()))
|
||||
//#define RTW_PACK_STRUCT_USE_INCLUDES
|
||||
|
||||
#elif defined (__CC_ARM)
|
||||
|
||||
#define RTW_PACK_STRUCT_BEGIN __packed
|
||||
#define RTW_PACK_STRUCT_STRUCT
|
||||
#define RTW_PACK_STRUCT_END
|
||||
|
||||
#elif defined (__GNUC__)
|
||||
|
||||
#define RTW_PACK_STRUCT_BEGIN
|
||||
#define RTW_PACK_STRUCT_STRUCT __attribute__ ((__packed__))
|
||||
#define RTW_PACK_STRUCT_END
|
||||
|
||||
#endif
|
||||
|
||||
// for standard library
|
||||
#ifdef __ICCARM__
|
||||
#define __extension__ /* Ignore */
|
||||
#define __restrict /* Ignore */
|
||||
#endif
|
||||
|
||||
typedef struct _RAM_START_FUNCTION_ {
|
||||
VOID (*RamStartFun) (VOID);
|
||||
}RAM_START_FUNCTION, *PRAM_START_FUNCTION;
|
||||
|
||||
typedef struct _RAM_FUNCTION_START_TABLE_ {
|
||||
VOID (*RamStartFun) (VOID);
|
||||
VOID (*RamWakeupFun) (VOID);
|
||||
VOID (*RamPatchFun0) (VOID);
|
||||
VOID (*RamPatchFun1) (VOID);
|
||||
VOID (*RamPatchFun2) (VOID);
|
||||
}RAM_FUNCTION_START_TABLE, *PRAM_FUNCTION_START_TABLE;
|
||||
|
||||
#endif// __BASIC_TYPES_H__
|
77
lib/wlan/rtl8821cs/include/skbuff.h
Normal file
77
lib/wlan/rtl8821cs/include/skbuff.h
Normal file
@ -0,0 +1,77 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
#ifndef __SKBUFF_H__
|
||||
#define __SKBUFF_H__
|
||||
|
||||
struct sk_buff_head {
|
||||
struct list_head *next, *prev;
|
||||
unsigned int qlen;
|
||||
};
|
||||
|
||||
#if CONFIG_TRACE_SKB
|
||||
#define TRACE_SKB_DEPTH 8
|
||||
#endif
|
||||
|
||||
struct sk_buff {
|
||||
/* These two members must be first. */
|
||||
struct sk_buff *next; /* Next buffer in list */
|
||||
struct sk_buff *prev; /* Previous buffer in list */
|
||||
|
||||
struct sk_buff_head *list; /* List we are on */
|
||||
unsigned char *head; /* Head of buffer */
|
||||
unsigned char *data; /* Data head pointer */
|
||||
unsigned char *tail; /* Tail pointer */
|
||||
unsigned char *end; /* End pointer */
|
||||
void *dev; /* Device we arrived on/are leaving by */
|
||||
unsigned int len; /* Length of actual data */
|
||||
#if CONFIG_TRACE_SKB
|
||||
unsigned int liston[TRACE_SKB_DEPTH]; /* Trace the Lists we went through */
|
||||
const char *funcname[TRACE_SKB_DEPTH];
|
||||
unsigned int list_idx; /* Trace the List we are on */
|
||||
#endif
|
||||
int zerocp_flag;
|
||||
int dyalloc_flag;
|
||||
unsigned char type_flag;
|
||||
};
|
||||
|
||||
unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
|
||||
unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
|
||||
void skb_reserve(struct sk_buff *skb, unsigned int len);
|
||||
void skb_assign_buf(struct sk_buff *skb, unsigned char *buf, unsigned int len);
|
||||
unsigned char *skb_tail_pointer(const struct sk_buff *skb);
|
||||
void skb_set_tail_pointer(struct sk_buff *skb, const int offset);
|
||||
unsigned char *skb_end_pointer(const struct sk_buff *skb);
|
||||
|
||||
void skb_queue_head_init(struct sk_buff_head *list);
|
||||
struct sk_buff *skb_dequeue(struct sk_buff_head *list);
|
||||
void skb_reset_tail_pointer(struct sk_buff *skb);
|
||||
void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
|
||||
signed int skb_queue_len(const struct sk_buff_head *list_);
|
||||
|
||||
void init_skb_pool(void);
|
||||
void init_skb_data_pool(void);
|
||||
|
||||
|
||||
#ifdef CONFIG_TX_ZERO_COPY
|
||||
struct sk_buff *dev_alloc_tx_skb_0copy();
|
||||
#endif
|
||||
struct sk_buff *dev_alloc_tx_skb(unsigned int length, unsigned int reserve_len);
|
||||
struct sk_buff *dev_alloc_rx_skb(unsigned int length, unsigned int reserve_len);
|
||||
void kfree_skb(struct sk_buff *skb);
|
||||
|
||||
|
||||
#endif //__SKBUFF_H__
|
||||
|
608
lib/wlan/rtl8821cs/include/wifi_constants.h
Normal file
608
lib/wlan/rtl8821cs/include/wifi_constants.h
Normal file
@ -0,0 +1,608 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************
|
||||
* @file wifi_constants.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the data types used for wlan API.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_CONSTANTS_H
|
||||
#define _WIFI_CONSTANTS_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef WLAN0_NAME
|
||||
#define WLAN0_NAME "wlan0"
|
||||
#endif
|
||||
#ifndef WLAN1_NAME
|
||||
#define WLAN1_NAME "wlan1"
|
||||
#endif
|
||||
|
||||
#define WEP_ENABLED 0x0001
|
||||
#define TKIP_ENABLED 0x0002
|
||||
#define AES_ENABLED 0x0004
|
||||
#define WSEC_SWFLAG 0x0008
|
||||
#define AES_CMAC_ENABLED 0x0010
|
||||
|
||||
#define SHARED_ENABLED 0x00008000
|
||||
#define WPA_SECURITY 0x00200000
|
||||
#define WPA2_SECURITY 0x00400000
|
||||
#define WPA3_SECURITY 0x00800000
|
||||
#define WPS_ENABLED 0x10000000
|
||||
|
||||
#define IEEE_8021X_ENABLED 0x80000000
|
||||
|
||||
#define RTW_MAX_PSK_LEN (64)
|
||||
#define RTW_MIN_PSK_LEN (8)
|
||||
|
||||
#define MCSSET_LEN 16
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the results of the function.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
RTW_SUCCESS = 0, /**< Success */
|
||||
RTW_PENDING = 1, /**< Pending */
|
||||
RTW_TIMEOUT = 2, /**< Timeout */
|
||||
RTW_PARTIAL_RESULTS = 3, /**< Partial results */
|
||||
RTW_INVALID_KEY = 4, /**< Invalid key */
|
||||
RTW_DOES_NOT_EXIST = 5, /**< Does not exist */
|
||||
RTW_NOT_AUTHENTICATED = 6, /**< Not authenticated */
|
||||
RTW_NOT_KEYED = 7, /**< Not keyed */
|
||||
RTW_IOCTL_FAIL = 8, /**< IOCTL fail */
|
||||
RTW_BUFFER_UNAVAILABLE_TEMPORARY = 9, /**< Buffer unavailable temporarily */
|
||||
RTW_BUFFER_UNAVAILABLE_PERMANENT = 10, /**< Buffer unavailable permanently */
|
||||
RTW_WPS_PBC_OVERLAP = 11, /**< WPS PBC overlap */
|
||||
RTW_CONNECTION_LOST = 12, /**< Connection lost */
|
||||
|
||||
RTW_ERROR = -1, /**< Generic Error */
|
||||
RTW_BADARG = -2, /**< Bad Argument */
|
||||
RTW_BADOPTION = -3, /**< Bad option */
|
||||
RTW_NOTUP = -4, /**< Not up */
|
||||
RTW_NOTDOWN = -5, /**< Not down */
|
||||
RTW_NOTAP = -6, /**< Not AP */
|
||||
RTW_NOTSTA = -7, /**< Not STA */
|
||||
RTW_BADKEYIDX = -8, /**< BAD Key Index */
|
||||
RTW_RADIOOFF = -9, /**< Radio Off */
|
||||
RTW_NOTBANDLOCKED = -10, /**< Not band locked */
|
||||
RTW_NOCLK = -11, /**< No Clock */
|
||||
RTW_BADRATESET = -12, /**< BAD Rate valueset */
|
||||
RTW_BADBAND = -13, /**< BAD Band */
|
||||
RTW_BUFTOOSHORT = -14, /**< Buffer too short */
|
||||
RTW_BUFTOOLONG = -15, /**< Buffer too long */
|
||||
RTW_BUSY = -16, /**< Busy */
|
||||
RTW_NOTASSOCIATED = -17, /**< Not Associated */
|
||||
RTW_BADSSIDLEN = -18, /**< Bad SSID len */
|
||||
RTW_OUTOFRANGECHAN = -19, /**< Out of Range Channel */
|
||||
RTW_BADCHAN = -20, /**< Bad Channel */
|
||||
RTW_BADADDR = -21, /**< Bad Address */
|
||||
RTW_NORESOURCE = -22, /**< Not Enough Resources */
|
||||
RTW_UNSUPPORTED = -23, /**< Unsupported */
|
||||
RTW_BADLEN = -24, /**< Bad length */
|
||||
RTW_NOTREADY = -25, /**< Not Ready */
|
||||
RTW_EPERM = -26, /**< Not Permitted */
|
||||
RTW_NOMEM = -27, /**< No Memory */
|
||||
RTW_ASSOCIATED = -28, /**< Associated */
|
||||
RTW_RANGE = -29, /**< Not In Range */
|
||||
RTW_NOTFOUND = -30, /**< Not Found */
|
||||
RTW_WME_NOT_ENABLED = -31, /**< WME Not Enabled */
|
||||
RTW_TSPEC_NOTFOUND = -32, /**< TSPEC Not Found */
|
||||
RTW_ACM_NOTSUPPORTED = -33, /**< ACM Not Supported */
|
||||
RTW_NOT_WME_ASSOCIATION = -34, /**< Not WME Association */
|
||||
RTW_SDIO_ERROR = -35, /**< SDIO Bus Error */
|
||||
RTW_WLAN_DOWN = -36, /**< WLAN Not Accessible */
|
||||
RTW_BAD_VERSION = -37, /**< Incorrect version */
|
||||
RTW_TXFAIL = -38, /**< TX failure */
|
||||
RTW_RXFAIL = -39, /**< RX failure */
|
||||
RTW_NODEVICE = -40, /**< Device not present */
|
||||
RTW_UNFINISHED = -41, /**< To be finished */
|
||||
RTW_NONRESIDENT = -42, /**< access to nonresident overlay */
|
||||
RTW_DISABLED = -43 /**< Disabled in this build */
|
||||
};
|
||||
typedef unsigned long rtw_result_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the possible security types to set when connection.\n
|
||||
* Station mode supports OPEN, WEP, and WPA2.\n
|
||||
* AP mode support OPEN and WPA2.
|
||||
*/
|
||||
enum {
|
||||
RTW_SECURITY_OPEN = 0, /**< Open security */
|
||||
RTW_SECURITY_WEP_PSK = WEP_ENABLED, /**< WEP PSK Security with open authentication */
|
||||
RTW_SECURITY_WEP_SHARED = ( WEP_ENABLED | SHARED_ENABLED ), /**< WEP PSK Security with shared authentication */
|
||||
RTW_SECURITY_WPA_TKIP_PSK = ( WPA_SECURITY | TKIP_ENABLED ), /**< WPA PSK Security with TKIP */
|
||||
RTW_SECURITY_WPA_TKIP_8021X = ( IEEE_8021X_ENABLED | WPA_SECURITY | TKIP_ENABLED ), /**< WPA 8021X Security with TKIP */
|
||||
RTW_SECURITY_WPA_AES_PSK = ( WPA_SECURITY | AES_ENABLED ), /**< WPA PSK Security with AES */
|
||||
RTW_SECURITY_WPA_AES_8021X = ( IEEE_8021X_ENABLED | WPA_SECURITY | AES_ENABLED ), /**< WPA 8021X Security with AES */
|
||||
RTW_SECURITY_WPA2_AES_PSK = ( WPA2_SECURITY | AES_ENABLED ), /**< WPA2 PSK Security with AES */
|
||||
RTW_SECURITY_WPA2_AES_8021X = ( IEEE_8021X_ENABLED | WPA2_SECURITY | WEP_ENABLED ), /**< WPA2 8021X Security with AES */
|
||||
RTW_SECURITY_WPA2_TKIP_PSK = ( WPA2_SECURITY | TKIP_ENABLED ), /**< WPA2 PSK Security with TKIP */
|
||||
RTW_SECURITY_WPA2_TKIP_8021X = ( IEEE_8021X_ENABLED | WPA2_SECURITY | TKIP_ENABLED ), /**< WPA2 8021X Security with TKIP */
|
||||
RTW_SECURITY_WPA2_MIXED_PSK = ( WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED ), /**< WPA2 PSK Security with AES & TKIP */
|
||||
RTW_SECURITY_WPA_WPA2_MIXED_PSK = ( WPA_SECURITY | WPA2_SECURITY ), /**< WPA/WPA2 PSK Security */
|
||||
RTW_SECURITY_WPA_WPA2_MIXED_8021X = ( IEEE_8021X_ENABLED | WPA_SECURITY | WPA2_SECURITY ), /**< WPA/WPA2 8021X Security */
|
||||
RTW_SECURITY_WPA2_AES_CMAC = ( WPA2_SECURITY | AES_CMAC_ENABLED), /**< WPA2 Security with AES and Management Frame Protection */
|
||||
|
||||
RTW_SECURITY_WPS_OPEN = WPS_ENABLED, /**< WPS with open security */
|
||||
RTW_SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), /**< WPS with AES security */
|
||||
|
||||
RTW_SECURITY_WPA3_AES_PSK = (WPA3_SECURITY | AES_ENABLED), /**< WPA3-AES with AES security */
|
||||
|
||||
RTW_SECURITY_UNKNOWN = -1, /**< May be returned by scan function if security is unknown. Do not pass this to the join function! */
|
||||
|
||||
RTW_SECURITY_FORCE_32_BIT = 0x7fffffff /**< Exists only to force rtw_security_t type to 32 bits */
|
||||
};
|
||||
typedef unsigned long rtw_security_t;
|
||||
|
||||
enum {
|
||||
RTW_ENCRYPTION_UNKNOWN = 0,
|
||||
RTW_ENCRYPTION_OPEN = 1,
|
||||
RTW_ENCRYPTION_WEP40 = 2,
|
||||
RTW_ENCRYPTION_WPA_TKIP = 3,
|
||||
RTW_ENCRYPTION_WPA_AES = 4,
|
||||
RTW_ENCRYPTION_WPA2_TKIP = 5,
|
||||
RTW_ENCRYPTION_WPA2_AES = 6,
|
||||
RTW_ENCRYPTION_WPA2_MIXED = 7,
|
||||
RTW_ENCRYPTION_WEP104 = 9,
|
||||
RTW_ENCRYPTION_UNDEF = 0xFF,
|
||||
};
|
||||
typedef unsigned long rtw_encryption_t;
|
||||
|
||||
enum {
|
||||
RTW_FALSE = 0,
|
||||
RTW_TRUE = 1
|
||||
};
|
||||
typedef unsigned long rtw_bool_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the band types.
|
||||
*/
|
||||
enum {
|
||||
RTW_802_11_BAND_5GHZ = 0, /**< Denotes 5GHz radio band */
|
||||
RTW_802_11_BAND_2_4GHZ = 1 /**< Denotes 2.4GHz radio band */
|
||||
};
|
||||
typedef unsigned long rtw_802_11_band_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists all the country codes able to set to Wi-Fi driver.
|
||||
*/
|
||||
enum {
|
||||
/* CHANNEL PLAN */
|
||||
RTW_COUNTRY_WORLD1, // 0x20
|
||||
RTW_COUNTRY_ETSI1, // 0x21
|
||||
RTW_COUNTRY_FCC1, // 0x22
|
||||
RTW_COUNTRY_MKK1, // 0x23
|
||||
RTW_COUNTRY_ETSI2, // 0x24
|
||||
RTW_COUNTRY_FCC2, // 0x2A
|
||||
RTW_COUNTRY_WORLD2, // 0x47
|
||||
RTW_COUNTRY_MKK2, // 0x58
|
||||
RTW_COUNTRY_GLOBAL, // 0x41
|
||||
|
||||
/* SPECIAL */
|
||||
RTW_COUNTRY_WORLD, // WORLD1
|
||||
RTW_COUNTRY_EU, // ETSI1
|
||||
|
||||
/* JAPANESE */
|
||||
RTW_COUNTRY_JP, // MKK1
|
||||
|
||||
/* FCC , 19 countries*/
|
||||
RTW_COUNTRY_AS, // FCC2
|
||||
RTW_COUNTRY_BM,
|
||||
RTW_COUNTRY_CA,
|
||||
RTW_COUNTRY_DM,
|
||||
RTW_COUNTRY_DO,
|
||||
RTW_COUNTRY_FM,
|
||||
RTW_COUNTRY_GD,
|
||||
RTW_COUNTRY_GT,
|
||||
RTW_COUNTRY_GU,
|
||||
RTW_COUNTRY_HT,
|
||||
RTW_COUNTRY_MH,
|
||||
RTW_COUNTRY_MP,
|
||||
RTW_COUNTRY_NI,
|
||||
RTW_COUNTRY_PA,
|
||||
RTW_COUNTRY_PR,
|
||||
RTW_COUNTRY_PW,
|
||||
RTW_COUNTRY_TW,
|
||||
RTW_COUNTRY_US,
|
||||
RTW_COUNTRY_VI,
|
||||
|
||||
/* others, ETSI */
|
||||
RTW_COUNTRY_AD, // ETSI1
|
||||
RTW_COUNTRY_AE,
|
||||
RTW_COUNTRY_AF,
|
||||
RTW_COUNTRY_AI,
|
||||
RTW_COUNTRY_AL,
|
||||
RTW_COUNTRY_AM,
|
||||
RTW_COUNTRY_AN,
|
||||
RTW_COUNTRY_AR,
|
||||
RTW_COUNTRY_AT,
|
||||
RTW_COUNTRY_AU,
|
||||
RTW_COUNTRY_AW,
|
||||
RTW_COUNTRY_AZ,
|
||||
RTW_COUNTRY_BA,
|
||||
RTW_COUNTRY_BB,
|
||||
RTW_COUNTRY_BD,
|
||||
RTW_COUNTRY_BE,
|
||||
RTW_COUNTRY_BF,
|
||||
RTW_COUNTRY_BG,
|
||||
RTW_COUNTRY_BH,
|
||||
RTW_COUNTRY_BL,
|
||||
RTW_COUNTRY_BN,
|
||||
RTW_COUNTRY_BO,
|
||||
RTW_COUNTRY_BR,
|
||||
RTW_COUNTRY_BS,
|
||||
RTW_COUNTRY_BT,
|
||||
RTW_COUNTRY_BY,
|
||||
RTW_COUNTRY_BZ,
|
||||
RTW_COUNTRY_CF,
|
||||
RTW_COUNTRY_CH,
|
||||
RTW_COUNTRY_CI,
|
||||
RTW_COUNTRY_CL,
|
||||
RTW_COUNTRY_CN,
|
||||
RTW_COUNTRY_CO,
|
||||
RTW_COUNTRY_CR,
|
||||
RTW_COUNTRY_CX,
|
||||
RTW_COUNTRY_CY,
|
||||
RTW_COUNTRY_CZ,
|
||||
RTW_COUNTRY_DE,
|
||||
RTW_COUNTRY_DK,
|
||||
RTW_COUNTRY_DZ,
|
||||
RTW_COUNTRY_EC,
|
||||
RTW_COUNTRY_EE,
|
||||
RTW_COUNTRY_EG,
|
||||
RTW_COUNTRY_ES,
|
||||
RTW_COUNTRY_ET,
|
||||
RTW_COUNTRY_FI,
|
||||
RTW_COUNTRY_FR,
|
||||
RTW_COUNTRY_GB,
|
||||
RTW_COUNTRY_GE,
|
||||
RTW_COUNTRY_GF,
|
||||
RTW_COUNTRY_GH,
|
||||
RTW_COUNTRY_GL,
|
||||
RTW_COUNTRY_GP,
|
||||
RTW_COUNTRY_GR,
|
||||
RTW_COUNTRY_GY,
|
||||
RTW_COUNTRY_HK,
|
||||
RTW_COUNTRY_HN,
|
||||
RTW_COUNTRY_HR,
|
||||
RTW_COUNTRY_HU,
|
||||
RTW_COUNTRY_ID,
|
||||
RTW_COUNTRY_IE,
|
||||
RTW_COUNTRY_IL,
|
||||
RTW_COUNTRY_IN,
|
||||
RTW_COUNTRY_IQ,
|
||||
RTW_COUNTRY_IR,
|
||||
RTW_COUNTRY_IS,
|
||||
RTW_COUNTRY_IT,
|
||||
RTW_COUNTRY_JM,
|
||||
RTW_COUNTRY_JO,
|
||||
RTW_COUNTRY_KE,
|
||||
RTW_COUNTRY_KH,
|
||||
RTW_COUNTRY_KN,
|
||||
RTW_COUNTRY_KP,
|
||||
RTW_COUNTRY_KR,
|
||||
RTW_COUNTRY_KW,
|
||||
RTW_COUNTRY_KY,
|
||||
RTW_COUNTRY_KZ,
|
||||
RTW_COUNTRY_LA,
|
||||
RTW_COUNTRY_LB,
|
||||
RTW_COUNTRY_LC,
|
||||
RTW_COUNTRY_LI,
|
||||
RTW_COUNTRY_LK,
|
||||
RTW_COUNTRY_LR,
|
||||
RTW_COUNTRY_LS,
|
||||
RTW_COUNTRY_LT,
|
||||
RTW_COUNTRY_LU,
|
||||
RTW_COUNTRY_LV,
|
||||
RTW_COUNTRY_MA,
|
||||
RTW_COUNTRY_MC,
|
||||
RTW_COUNTRY_MD,
|
||||
RTW_COUNTRY_ME,
|
||||
RTW_COUNTRY_MF,
|
||||
RTW_COUNTRY_MK,
|
||||
RTW_COUNTRY_MN,
|
||||
RTW_COUNTRY_MO,
|
||||
RTW_COUNTRY_MQ,
|
||||
RTW_COUNTRY_MR,
|
||||
RTW_COUNTRY_MT,
|
||||
RTW_COUNTRY_MU,
|
||||
RTW_COUNTRY_MV,
|
||||
RTW_COUNTRY_MW,
|
||||
RTW_COUNTRY_MX,
|
||||
RTW_COUNTRY_MY,
|
||||
RTW_COUNTRY_NG,
|
||||
RTW_COUNTRY_NL,
|
||||
RTW_COUNTRY_NO,
|
||||
RTW_COUNTRY_NP,
|
||||
RTW_COUNTRY_NZ,
|
||||
RTW_COUNTRY_OM,
|
||||
RTW_COUNTRY_PE,
|
||||
RTW_COUNTRY_PF,
|
||||
RTW_COUNTRY_PG,
|
||||
RTW_COUNTRY_PH,
|
||||
RTW_COUNTRY_PK,
|
||||
RTW_COUNTRY_PL,
|
||||
RTW_COUNTRY_PM,
|
||||
RTW_COUNTRY_PT,
|
||||
RTW_COUNTRY_PY,
|
||||
RTW_COUNTRY_QA,
|
||||
RTW_COUNTRY_RS,
|
||||
RTW_COUNTRY_RU,
|
||||
RTW_COUNTRY_RW,
|
||||
RTW_COUNTRY_SA,
|
||||
RTW_COUNTRY_SE,
|
||||
RTW_COUNTRY_SG,
|
||||
RTW_COUNTRY_SI,
|
||||
RTW_COUNTRY_SK,
|
||||
RTW_COUNTRY_SN,
|
||||
RTW_COUNTRY_SR,
|
||||
RTW_COUNTRY_SV,
|
||||
RTW_COUNTRY_SY,
|
||||
RTW_COUNTRY_TC,
|
||||
RTW_COUNTRY_TD,
|
||||
RTW_COUNTRY_TG,
|
||||
RTW_COUNTRY_TH,
|
||||
RTW_COUNTRY_TN,
|
||||
RTW_COUNTRY_TR,
|
||||
RTW_COUNTRY_TT,
|
||||
RTW_COUNTRY_TZ,
|
||||
RTW_COUNTRY_UA,
|
||||
RTW_COUNTRY_UG,
|
||||
RTW_COUNTRY_UY,
|
||||
RTW_COUNTRY_UZ,
|
||||
RTW_COUNTRY_VC,
|
||||
RTW_COUNTRY_VE,
|
||||
RTW_COUNTRY_VN,
|
||||
RTW_COUNTRY_VU,
|
||||
RTW_COUNTRY_WF,
|
||||
RTW_COUNTRY_WS,
|
||||
RTW_COUNTRY_YE,
|
||||
RTW_COUNTRY_YT,
|
||||
RTW_COUNTRY_ZA,
|
||||
RTW_COUNTRY_ZW,
|
||||
|
||||
RTW_COUNTRY_MAX
|
||||
|
||||
};
|
||||
typedef unsigned long rtw_country_code_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the adaptivity types.
|
||||
*/
|
||||
enum {
|
||||
RTW_ADAPTIVITY_DISABLE = 0,
|
||||
RTW_ADAPTIVITY_NORMAL, // CE
|
||||
RTW_ADAPTIVITY_CARRIER_SENSE // MKK
|
||||
};
|
||||
typedef unsigned long rtw_adaptivity_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the supported operation mode by WIFI driver,
|
||||
* including station and AP mode.
|
||||
*/
|
||||
enum {
|
||||
RTW_MODE_NONE = 0,
|
||||
RTW_MODE_STA,
|
||||
RTW_MODE_AP,
|
||||
RTW_MODE_STA_AP,
|
||||
RTW_MODE_PROMISC,
|
||||
RTW_MODE_P2P
|
||||
};
|
||||
typedef unsigned long rtw_mode_t;
|
||||
|
||||
enum {
|
||||
RTW_SCAN_FULL = 0,
|
||||
RTW_SCAN_SOCIAL,
|
||||
RTW_SCAN_ONE
|
||||
};
|
||||
typedef unsigned long rtw_scan_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the supported autoreconnect mode by WIFI driver.
|
||||
*/
|
||||
typedef enum{
|
||||
RTW_AUTORECONNECT_DISABLE,
|
||||
RTW_AUTORECONNECT_FINITE,
|
||||
RTW_AUTORECONNECT_INFINITE
|
||||
} rtw_autoreconnect_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the status to describe the connection link.
|
||||
*/
|
||||
enum {
|
||||
RTW_LINK_DISCONNECTED = 0,
|
||||
RTW_LINK_CONNECTED
|
||||
};
|
||||
typedef unsigned long rtw_link_status_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the scan types.
|
||||
*/
|
||||
enum {
|
||||
RTW_SCAN_TYPE_ACTIVE = 0x00, /**< Actively scan a network by sending 802.11 probe(s) */
|
||||
RTW_SCAN_TYPE_PASSIVE = 0x01, /**< Passively scan a network by listening for beacons from APs */
|
||||
RTW_SCAN_TYPE_PROHIBITED_CHANNELS = 0x04 /**< Passively scan on channels not enabled by the country code */
|
||||
};
|
||||
typedef unsigned long rtw_scan_type_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the bss types.
|
||||
*/
|
||||
enum {
|
||||
RTW_BSS_TYPE_INFRASTRUCTURE = 0, /**< Denotes infrastructure network */
|
||||
RTW_BSS_TYPE_ADHOC = 1, /**< Denotes an 802.11 ad-hoc IBSS network */
|
||||
RTW_BSS_TYPE_ANY = 2, /**< Denotes either infrastructure or ad-hoc network */
|
||||
|
||||
RTW_BSS_TYPE_UNKNOWN = -1 /**< May be returned by scan function if BSS type is unknown. Do not pass this to the Join function */
|
||||
};
|
||||
typedef unsigned long rtw_bss_type_t;
|
||||
|
||||
enum {
|
||||
RTW_SCAN_COMMAMD = 0x01
|
||||
};
|
||||
typedef unsigned long rtw_scan_command_t;
|
||||
|
||||
enum{
|
||||
COMMAND1 = 0x01
|
||||
};
|
||||
typedef unsigned long rtw_command_type;
|
||||
|
||||
enum {
|
||||
RTW_WPS_TYPE_DEFAULT = 0x0000,
|
||||
RTW_WPS_TYPE_USER_SPECIFIED = 0x0001,
|
||||
RTW_WPS_TYPE_MACHINE_SPECIFIED = 0x0002,
|
||||
RTW_WPS_TYPE_REKEY = 0x0003,
|
||||
RTW_WPS_TYPE_PUSHBUTTON = 0x0004,
|
||||
RTW_WPS_TYPE_REGISTRAR_SPECIFIED = 0x0005,
|
||||
RTW_WPS_TYPE_NONE = 0x0006,
|
||||
RTW_WPS_TYPE_WSC = 0x0007
|
||||
};
|
||||
typedef unsigned long rtw_wps_type_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists all the network bgn mode.
|
||||
*/
|
||||
enum {
|
||||
RTW_NETWORK_B = 1,
|
||||
RTW_NETWORK_BG = 3,
|
||||
RTW_NETWORK_BGN = 11
|
||||
};
|
||||
typedef unsigned long rtw_network_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the interfaces.
|
||||
*/
|
||||
enum {
|
||||
RTW_STA_INTERFACE = 0, /**< STA or Client Interface */
|
||||
RTW_AP_INTERFACE = 1, /**< SoftAP Interface */
|
||||
};
|
||||
typedef unsigned long rtw_interface_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the packet filter rules.
|
||||
*/
|
||||
enum {
|
||||
RTW_POSITIVE_MATCHING = 0, /**< Receive the data matching with this pattern and discard the other data */
|
||||
RTW_NEGATIVE_MATCHING = 1 /**< Discard the data matching with this pattern and receive the other data */
|
||||
};
|
||||
typedef unsigned long rtw_packet_filter_rule_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the promisc levels.
|
||||
*/
|
||||
enum {
|
||||
RTW_PROMISC_DISABLE = 0, /**< Disable the promisc */
|
||||
RTW_PROMISC_ENABLE = 1, /**< Fetch all ethernet packets */
|
||||
RTW_PROMISC_ENABLE_1 = 2, /**< Fetch only B/M packets */
|
||||
RTW_PROMISC_ENABLE_2 = 3, /**< Fetch all 802.11 packets*/
|
||||
RTW_PROMISC_ENABLE_3 = 4, /**< Fetch only B/M 802.11 packets*/
|
||||
RTW_PROMISC_ENABLE_4 = 5, /**< Fetch all 802.11 packets & MIMO PLCP headers. Please note that the PLCP header would be struct rtw_rx_info_t defined in wifi_structures.h*/
|
||||
};
|
||||
typedef unsigned long rtw_rcr_level_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration lists the promisc rx type.
|
||||
*/
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
enum {
|
||||
RTW_RX_NORMAL = 0, /**< The supported 802.11 packet*/
|
||||
RTW_RX_UNSUPPORT = 1, /**< Unsupported 802.11 packet info */
|
||||
};
|
||||
typedef unsigned long rtw_rx_type_t;
|
||||
#endif
|
||||
/**
|
||||
* @brief The enumeration lists the disconnect reasons.
|
||||
*/
|
||||
enum{
|
||||
RTW_NO_ERROR = 0,
|
||||
RTW_NONE_NETWORK = 1,
|
||||
RTW_CONNECT_FAIL = 2,
|
||||
RTW_WRONG_PASSWORD = 3 ,
|
||||
RTW_4WAY_HANDSHAKE_TIMEOUT = 4,
|
||||
RTW_DHCP_FAIL = 5,
|
||||
RTW_UNKNOWN,
|
||||
};
|
||||
typedef unsigned long rtw_connect_error_flag_t;
|
||||
|
||||
enum {
|
||||
RTW_TX_PWR_PERCENTAGE_100 = 0, /* 100%, default target output power. */
|
||||
RTW_TX_PWR_PERCENTAGE_75 = 1, /* 75% */
|
||||
RTW_TX_PWR_PERCENTAGE_50 = 2, /* 50% */
|
||||
RTW_TX_PWR_PERCENTAGE_25 = 3, /* 25% */
|
||||
RTW_TX_PWR_PERCENTAGE_12_5 = 4, /* 12.5% */
|
||||
};
|
||||
typedef unsigned long rtw_tx_pwr_percentage_t;
|
||||
|
||||
/**
|
||||
* @brief The enumeration is event type indicated from wlan driver.
|
||||
*/
|
||||
enum _WIFI_EVENT_INDICATE{
|
||||
WIFI_EVENT_CONNECT = 0,
|
||||
WIFI_EVENT_DISCONNECT = 1,
|
||||
WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2,
|
||||
WIFI_EVENT_SCAN_RESULT_REPORT = 3,
|
||||
WIFI_EVENT_SCAN_DONE = 4,
|
||||
WIFI_EVENT_RECONNECTION_FAIL = 5,
|
||||
WIFI_EVENT_SEND_ACTION_DONE = 6,
|
||||
WIFI_EVENT_RX_MGNT = 7,
|
||||
WIFI_EVENT_STA_ASSOC = 8,
|
||||
WIFI_EVENT_STA_DISASSOC = 9,
|
||||
WIFI_EVENT_STA_WPS_START = 10,
|
||||
WIFI_EVENT_WPS_FINISH = 11,
|
||||
WIFI_EVENT_EAPOL_START = 12,
|
||||
WIFI_EVENT_EAPOL_RECVD = 13,
|
||||
WIFI_EVENT_NO_NETWORK = 14,
|
||||
WIFI_EVENT_BEACON_AFTER_DHCP = 15,
|
||||
WIFI_EVENT_IP_CHANGED = 16,
|
||||
WIFI_EVENT_ICV_ERROR = 17,
|
||||
WIFI_EVENT_CHALLENGE_FAIL = 18,
|
||||
|
||||
WIFI_EVENT_SCAN_START = 19,
|
||||
WIFI_EVENT_SCAN_FAILED = 20,
|
||||
WIFI_EVENT_AUTHENTICATION = 21,
|
||||
WIFI_EVENT_AUTH_REJECT =22 ,
|
||||
WIFI_EVENT_DEAUTH =23 ,
|
||||
WIFI_EVENT_AUTH_TIMEOUT =24 ,
|
||||
WIFI_EVENT_ASSOCIATING = 25,
|
||||
WIFI_EVENT_ASSOCIATED =26 ,
|
||||
WIFI_EVENT_ASSOC_REJECT =27 ,
|
||||
WIFI_EVENT_ASSOC_TIMEOUT =28 ,
|
||||
WIFI_EVENT_HANDSHAKE_FAILED =29 ,
|
||||
WIFI_EVENT_4WAY_HANDSHAKE = 30,
|
||||
WIFI_EVENT_GROUP_HANDSHAKE = 31,
|
||||
WIFI_EVENT_GROUP_HANDSHAKE_DONE = 32,
|
||||
WIFI_EVENT_CONN_TIMEOUT =33,
|
||||
WIFI_EVENT_LEAVE_BUSY_TRAFFIC =34,
|
||||
WIFI_EVENT_MAX,
|
||||
};
|
||||
typedef unsigned long rtw_event_indicate_t;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif /* _WIFI_CONSTANTS_H */
|
279
lib/wlan/rtl8821cs/include/wifi_structures.h
Normal file
279
lib/wlan/rtl8821cs/include/wifi_structures.h
Normal file
@ -0,0 +1,279 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************
|
||||
* @file wifi_structures.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides the data structures used for wlan API.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_STRUCTURES_H
|
||||
#define _WIFI_STRUCTURES_H
|
||||
|
||||
/** @addtogroup nic NIC
|
||||
* @ingroup wlan
|
||||
* @brief NIC functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "wifi_constants.h"
|
||||
#include "dlist.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the SSID.
|
||||
*/
|
||||
typedef struct rtw_ssid {
|
||||
unsigned char len; /**< SSID length */
|
||||
unsigned char val[33]; /**< SSID name (AP name) */
|
||||
} rtw_ssid_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the unique 6-byte MAC address.
|
||||
*/
|
||||
typedef struct rtw_mac {
|
||||
unsigned char octet[6]; /**< Unique 6-byte MAC address */
|
||||
} rtw_mac_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined (__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the setting about SSID,
|
||||
* security type, password and default channel, used to start AP mode.
|
||||
* @note The data length of string pointed by ssid should not exceed 32,
|
||||
* and the data length of string pointed by password should not exceed 64.
|
||||
*/
|
||||
typedef struct rtw_ap_info {
|
||||
rtw_ssid_t ssid;
|
||||
rtw_security_t security_type;
|
||||
unsigned char *password;
|
||||
int password_len;
|
||||
int channel;
|
||||
}rtw_ap_info_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the station mode setting about SSID,
|
||||
* security type and password, used when connecting to an AP.
|
||||
* @note The data length of string pointed by ssid should not exceed 32,
|
||||
* and the data length of string pointed by password should not exceed 64.
|
||||
*/
|
||||
typedef struct rtw_network_info {
|
||||
rtw_ssid_t ssid;
|
||||
rtw_mac_t bssid;
|
||||
rtw_security_t security_type;
|
||||
unsigned char *password;
|
||||
int password_len;
|
||||
int key_id;
|
||||
}rtw_network_info_t;
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the scan result of the AP.
|
||||
*/
|
||||
typedef struct rtw_scan_result {
|
||||
rtw_ssid_t SSID; /**< Service Set Identification (i.e. Name of Access Point) */
|
||||
rtw_mac_t BSSID; /**< Basic Service Set Identification (i.e. MAC address of Access Point) */
|
||||
signed short signal_strength; /**< Receive Signal Strength Indication in dBm. <-90=Very poor, >-30=Excellent */
|
||||
rtw_bss_type_t bss_type; /**< Network type */
|
||||
rtw_security_t security; /**< Security type */
|
||||
rtw_wps_type_t wps_type; /**< WPS type */
|
||||
unsigned int channel; /**< Radio channel that the AP beacon was received on */
|
||||
rtw_802_11_band_t band; /**< Radio band */
|
||||
} rtw_scan_result_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the data needed by scan result handler function.
|
||||
*/
|
||||
typedef struct rtw_scan_handler_result {
|
||||
rtw_scan_result_t ap_details;
|
||||
rtw_bool_t scan_complete;
|
||||
void* user_data;
|
||||
|
||||
} rtw_scan_handler_result_t;
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to store the WIFI setting gotten from WIFI driver.
|
||||
*/
|
||||
typedef struct rtw_wifi_setting {
|
||||
rtw_mode_t mode;
|
||||
unsigned char ssid[33];
|
||||
unsigned char channel;
|
||||
rtw_security_t security_type;
|
||||
unsigned char password[65];
|
||||
unsigned char key_idx;
|
||||
}rtw_wifi_setting_t;
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__) || defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the setting when configure the network.
|
||||
*/
|
||||
typedef struct rtw_wifi_config {
|
||||
unsigned int boot_mode;
|
||||
unsigned char ssid[32];
|
||||
unsigned char ssid_len;
|
||||
unsigned char security_type;
|
||||
unsigned char password[65];
|
||||
unsigned char password_len;
|
||||
unsigned char channel;
|
||||
} rtw_wifi_config_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the maclist.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned int count; /**< Number of MAC addresses in the list */
|
||||
rtw_mac_t mac_list[1]; /**< Variable length array of MAC addresses */
|
||||
} rtw_maclist_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to describe the bss info of the network.\n
|
||||
* It include the version, BSSID, beacon_period, capability, SSID,
|
||||
* channel, atm_window, dtim_period, RSSI e.g.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int version; /**< version field */
|
||||
unsigned int length; /**< byte length of data in this record, */
|
||||
/* starting at version and including IEs */
|
||||
rtw_mac_t BSSID;
|
||||
unsigned short beacon_period; /**< units are Kusec */
|
||||
unsigned short capability; /**< Capability information */
|
||||
unsigned char SSID_len;
|
||||
unsigned char SSID[32];
|
||||
unsigned char channel;
|
||||
// struct {
|
||||
// uint32_t count; /* # rates in this set */
|
||||
// uint8_t rates[16]; /* rates in 500kbps units w/hi bit set if basic */
|
||||
// } rateset; /* supported rates */
|
||||
// rtw_chanspec_t chanspec; /* chanspec for bss */
|
||||
unsigned short atim_window; /**< units are Kusec */
|
||||
unsigned char dtim_period; /**< DTIM period */
|
||||
signed short RSSI; /**< receive signal strength (in dBm) */
|
||||
|
||||
unsigned char n_cap; /**< BSS is 802.11N Capable */
|
||||
unsigned int nbss_cap; /**< 802.11N BSS Capabilities (based on HT_CAP_*) */
|
||||
unsigned char basic_mcs[MCSSET_LEN]; /**< 802.11N BSS required MCS set */
|
||||
|
||||
unsigned short ie_offset; /**< offset at which IEs start, from beginning */
|
||||
unsigned int ie_length; /**< byte length of Information Elements */
|
||||
} rtw_bss_info_t;
|
||||
|
||||
/**
|
||||
* @brief The structure is used to set WIFI packet filter pattern.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned short offset; /**< Offset in bytes to start filtering (referenced to the start of the ethernet packet) */
|
||||
unsigned short mask_size; /**< Size of the mask in bytes */
|
||||
unsigned char* mask; /**< Pattern mask bytes to be ANDed with the pattern eg. "\xff00" (must be in network byte order) */
|
||||
unsigned char* pattern; /**< Pattern bytes used to filter eg. "\x0800" (must be in network byte order) */
|
||||
} rtw_packet_filter_pattern_t;
|
||||
|
||||
typedef struct ieee80211_frame_info{
|
||||
unsigned short i_fc;
|
||||
unsigned short i_dur;
|
||||
unsigned char i_addr1[6];
|
||||
unsigned char i_addr2[6];
|
||||
unsigned char i_addr3[6];
|
||||
unsigned short i_seq;
|
||||
unsigned char bssid[6];
|
||||
unsigned char encrypt;
|
||||
signed char rssi;
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
rtw_rx_type_t type;
|
||||
#endif
|
||||
}ieee80211_frame_info_t;
|
||||
|
||||
#if CONFIG_UNSUPPORT_PLCPHDR_RPT
|
||||
typedef struct rtw_rx_info {
|
||||
uint16_t length; //length without FCS
|
||||
uint8_t filter; // 2: 2T rate pkt; 3: LDPC pkt
|
||||
signed char rssi; //-128~-1
|
||||
}rtw_rx_info_t;
|
||||
|
||||
struct rtw_plcp_info {
|
||||
struct rtw_plcp_info *prev;
|
||||
struct rtw_plcp_info *next;
|
||||
uint16_t length; //length without FCS
|
||||
uint8_t filter; // 1: HT-20 pkt; 2: HT-40 and not LDPC pkt; 3: LDPC pkt
|
||||
signed char rssi; //-128~-1
|
||||
};
|
||||
|
||||
struct rtw_rx_buffer {
|
||||
struct rtw_plcp_info *head;
|
||||
struct rtw_plcp_info *tail;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char filter_id;
|
||||
rtw_packet_filter_pattern_t patt;
|
||||
rtw_packet_filter_rule_t rule;
|
||||
unsigned char enable;
|
||||
}rtw_packet_filter_info_t;
|
||||
|
||||
typedef struct rtw_mac_filter_list{
|
||||
struct list_head node;
|
||||
unsigned char mac_addr[6];
|
||||
}rtw_mac_filter_list_t;
|
||||
|
||||
typedef struct wowlan_pattern {
|
||||
unsigned char eth_da[6];
|
||||
unsigned char eth_sa[6];
|
||||
unsigned char eth_proto_type[2];
|
||||
unsigned char header_len[1];
|
||||
//unsigned char header_content[8];
|
||||
unsigned char ip_proto[1];
|
||||
//unsigned char checksum[2];
|
||||
unsigned char ip_sa[4];
|
||||
unsigned char ip_da[4];
|
||||
unsigned char mask[5]; // 40 bits to match 34-byte pattern
|
||||
} wowlan_pattern_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif /* _WIFI_STRUCTURES_H */
|
1249
lib/wlan/rtl8821cs/include/wireless.h
Normal file
1249
lib/wlan/rtl8821cs/include/wireless.h
Normal file
File diff suppressed because it is too large
Load Diff
89
lib/wlan/rtl8821cs/include/wlan_intf.h
Normal file
89
lib/wlan/rtl8821cs/include/wlan_intf.h
Normal file
@ -0,0 +1,89 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
#ifndef __WLAN_INTF_H__
|
||||
#define __WLAN_INTF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <autoconf.h>
|
||||
|
||||
#include <wireless.h>
|
||||
#include "wifi_constants.h"
|
||||
|
||||
#ifndef WLAN0_IDX
|
||||
#define WLAN0_IDX 0
|
||||
#endif
|
||||
#ifndef WLAN1_IDX
|
||||
#define WLAN1_IDX 1
|
||||
#endif
|
||||
#ifndef WLAN_UNDEF
|
||||
#define WLAN_UNDEF -1
|
||||
#endif
|
||||
|
||||
/***********************************************************/
|
||||
/*
|
||||
struct sk_buff {
|
||||
// These two members must be first.
|
||||
struct sk_buff *next; // Next buffer in list
|
||||
struct sk_buff *prev; // Previous buffer in list
|
||||
|
||||
struct sk_buff_head *list; // List we are on
|
||||
unsigned char *head; // Head of buffer
|
||||
unsigned char *data; // Data head pointer
|
||||
unsigned char *tail; // Tail pointer
|
||||
unsigned char *end; //End pointer
|
||||
struct net_device *dev; //Device we arrived on/are leaving by
|
||||
unsigned int len; // Length of actual data
|
||||
};
|
||||
*/
|
||||
/************************************************************/
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Wlan Interface opened for upper layer
|
||||
//----- ------------------------------------------------------------------
|
||||
int rltk_wlan_init(int idx_wlan, rtw_mode_t mode); //return 0: success. -1:fail
|
||||
void rltk_wlan_deinit(void);
|
||||
void rltk_wlan_deinit_fastly(void);
|
||||
int rltk_wlan_start(int idx_wlan);
|
||||
void rltk_wlan_statistic(unsigned char idx);
|
||||
unsigned char rltk_wlan_running(unsigned char idx); // interface is up. 0: interface is down
|
||||
int rltk_wlan_control(unsigned long cmd, void *data);
|
||||
int rltk_wlan_handshake_done(void);
|
||||
int rltk_wlan_rf_on(void);
|
||||
int rltk_wlan_rf_off(void);
|
||||
int rltk_wlan_check_bus(void);
|
||||
int rltk_wlan_wireless_mode(unsigned char mode);
|
||||
int rltk_wlan_get_wireless_mode(unsigned char *pmode);
|
||||
int rltk_wlan_set_wps_phase(unsigned char is_trigger_wps);
|
||||
int rtw_ps_enable(int enable);
|
||||
int rltk_wlan_is_connected_to_ap(void);
|
||||
#if CONFIG_IEEE80211W
|
||||
void rltk_wlan_tx_sa_query(unsigned char key_type);
|
||||
void rltk_wlan_tx_deauth(unsigned char b_broadcast, unsigned char key_type);
|
||||
void rltk_wlan_tx_auth(void);
|
||||
#endif
|
||||
#if CONFIG_SET_PRIORITY
|
||||
int rltk_wlan_set_priority(int priority);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif //#ifndef __WLAN_INTF_H__
|
834
lib/wlan/rtl8821cs/os/customer_rtos/customer_rtos_service.c
Normal file
834
lib/wlan/rtl8821cs/os/customer_rtos/customer_rtos_service.c
Normal file
@ -0,0 +1,834 @@
|
||||
/* FreeRTOS includes */
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <timers.h>
|
||||
#include <semphr.h>
|
||||
//#include <autoconf.h>
|
||||
#include <osdep_service.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
//#include <tcm_heap.h>
|
||||
/********************* os depended utilities ********************/
|
||||
|
||||
#ifndef USE_MUTEX_FOR_SPINLOCK
|
||||
#define USE_MUTEX_FOR_SPINLOCK 1
|
||||
#endif
|
||||
|
||||
//PRIORITIE_OFFSET defined to adjust the priority of threads in wlan_lib
|
||||
unsigned int g_prioritie_offset = 4;
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Misc Function
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
int rtw_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int n = vprintf(format, args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
#if CONFIG_MP_LOG_FUNC_INDEPENDENT
|
||||
int rtw_mplog(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int n = vprintf(format, args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
void save_and_cli()
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
}
|
||||
|
||||
void restore_flags()
|
||||
{
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
void cli()
|
||||
{
|
||||
taskDISABLE_INTERRUPTS();
|
||||
}
|
||||
|
||||
/* Not needed on 64bit architectures */
|
||||
static unsigned int __div64_32(u64 *n, unsigned int base)
|
||||
{
|
||||
u64 rem = *n;
|
||||
u64 b = base;
|
||||
u64 res, d = 1;
|
||||
unsigned int high = rem >> 32;
|
||||
|
||||
/* Reduce the thing a bit first */
|
||||
res = 0;
|
||||
if (high >= base) {
|
||||
high /= base;
|
||||
res = (u64) high << 32;
|
||||
rem -= (u64) (high * base) << 32;
|
||||
}
|
||||
|
||||
while ((u64)b > 0 && b < rem) {
|
||||
b = b+b;
|
||||
d = d+d;
|
||||
}
|
||||
|
||||
do {
|
||||
if (rem >= b) {
|
||||
rem -= b;
|
||||
res += d;
|
||||
}
|
||||
b >>= 1;
|
||||
d >>= 1;
|
||||
} while (d);
|
||||
|
||||
*n = res;
|
||||
return rem;
|
||||
}
|
||||
|
||||
/********************* os depended service ********************/
|
||||
|
||||
u8* _freertos_malloc(u32 sz)
|
||||
{
|
||||
return pvPortMalloc(sz);
|
||||
}
|
||||
|
||||
u8* _freertos_zmalloc(u32 sz)
|
||||
{
|
||||
u8 *pbuf = _freertos_malloc(sz);
|
||||
|
||||
if (pbuf != NULL)
|
||||
memset(pbuf, 0, sz);
|
||||
|
||||
return pbuf;
|
||||
}
|
||||
|
||||
void _freertos_mfree(u8 *pbuf, u32 sz)
|
||||
{
|
||||
vPortFree(pbuf);
|
||||
}
|
||||
|
||||
static void _freertos_memcpy(void* dst, const void* src, u32 sz)
|
||||
{
|
||||
memcpy(dst, src, sz);
|
||||
}
|
||||
|
||||
static int _freertos_memcmp(void *dst, void *src, u32 sz)
|
||||
{
|
||||
//under Linux/GNU/GLibc, the return value of memcmp for two same mem. chunk is 0
|
||||
if (!(memcmp(dst, src, sz)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _freertos_memset(void *pbuf, int c, u32 sz)
|
||||
{
|
||||
memset(pbuf, c, sz);
|
||||
}
|
||||
|
||||
static void _freertos_init_sema(_sema *sema, int init_val)
|
||||
{
|
||||
*sema = xSemaphoreCreateCounting(0xffffffff, init_val); //Set max count 0xffffffff
|
||||
}
|
||||
|
||||
static void _freertos_free_sema(_sema *sema)
|
||||
{
|
||||
if(*sema != NULL)
|
||||
vSemaphoreDelete(*sema);
|
||||
|
||||
*sema = NULL;
|
||||
}
|
||||
|
||||
static void _freertos_up_sema(_sema *sema)
|
||||
{
|
||||
xSemaphoreGive(*sema);
|
||||
}
|
||||
|
||||
static void _freertos_up_sema_from_isr(_sema *sema)
|
||||
{
|
||||
portBASE_TYPE taskWoken = pdFALSE;
|
||||
xSemaphoreGiveFromISR(*sema, &taskWoken);
|
||||
portEND_SWITCHING_ISR(taskWoken);
|
||||
}
|
||||
|
||||
static u32 _freertos_down_sema(_sema *sema, u32 timeout)
|
||||
{
|
||||
if(timeout == RTW_MAX_DELAY) {
|
||||
timeout = portMAX_DELAY;
|
||||
} else {
|
||||
timeout = rtw_ms_to_systime(timeout);
|
||||
}
|
||||
|
||||
if(xSemaphoreTake(*sema, timeout) != pdTRUE) {
|
||||
return pdFALSE;
|
||||
}
|
||||
|
||||
return pdTRUE;
|
||||
}
|
||||
|
||||
static void _freertos_mutex_init(_mutex *pmutex)
|
||||
{
|
||||
*pmutex = xSemaphoreCreateMutex();
|
||||
}
|
||||
|
||||
static void _freertos_mutex_free(_mutex *pmutex)
|
||||
{
|
||||
if(*pmutex != NULL)
|
||||
vSemaphoreDelete(*pmutex);
|
||||
|
||||
*pmutex = NULL;
|
||||
}
|
||||
|
||||
static void _freertos_mutex_get(_lock *plock)
|
||||
{
|
||||
while(xSemaphoreTake(*plock, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
}
|
||||
|
||||
static int _freertos_mutex_get_timeout(_lock *plock, u32 timeout_ms)
|
||||
{
|
||||
if(xSemaphoreTake(*plock, timeout_ms / portTICK_RATE_MS) != pdTRUE){
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _freertos_mutex_put(_lock *plock)
|
||||
{
|
||||
xSemaphoreGive(*plock);
|
||||
}
|
||||
|
||||
static void _freertos_enter_critical(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
}
|
||||
|
||||
static void _freertos_exit_critical(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
static u32 uxSavedInterruptStatus = 0;
|
||||
static void _freertos_enter_critical_from_isr(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||
|
||||
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||
}
|
||||
|
||||
static void _freertos_exit_critical_from_isr(_lock *plock, _irqL *pirqL)
|
||||
{
|
||||
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
|
||||
}
|
||||
|
||||
static int _freertos_enter_critical_mutex(_mutex *pmutex, _irqL *pirqL)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while(xSemaphoreTake(*pmutex, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, pmutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _freertos_exit_critical_mutex(_mutex *pmutex, _irqL *pirqL)
|
||||
{
|
||||
xSemaphoreGive(*pmutex);
|
||||
}
|
||||
|
||||
static void _freertos_cpu_lock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_cpu_unlock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_spinlock_init(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
*plock = xSemaphoreCreateMutex();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinlock_free(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
if(*plock != NULL)
|
||||
vSemaphoreDelete(*plock);
|
||||
|
||||
*plock = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinlock(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
while(xSemaphoreTake(*plock, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinunlock(_lock *plock)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
xSemaphoreGive(*plock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinlock_irqsave(_lock *plock, _irqL *irqL)
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
while(xSemaphoreTake(*plock, 60 * 1000 / portTICK_RATE_MS) != pdTRUE)
|
||||
DBG_INFO("[%s] %s(%p) failed, retry\n", pcTaskGetTaskName(NULL), __FUNCTION__, plock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _freertos_spinunlock_irqsave(_lock *plock, _irqL *irqL)
|
||||
{
|
||||
#if USE_MUTEX_FOR_SPINLOCK
|
||||
xSemaphoreGive(*plock);
|
||||
#endif
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
static int _freertos_init_xqueue( _xqueue* queue, const char* name, u32 message_size, u32 number_of_messages )
|
||||
{
|
||||
if ( ( *queue = xQueueCreate( number_of_messages, message_size ) ) == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _freertos_push_to_xqueue( _xqueue* queue, void* message, u32 timeout_ms )
|
||||
{
|
||||
if(timeout_ms == RTW_MAX_DELAY) {
|
||||
timeout_ms = portMAX_DELAY;
|
||||
} else {
|
||||
timeout_ms = rtw_ms_to_systime(timeout_ms);
|
||||
}
|
||||
|
||||
if ( xQueueSendToBack( *queue, message, timeout_ms ) != pdPASS )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _freertos_pop_from_xqueue( _xqueue* queue, void* message, u32 timeout_ms )
|
||||
{
|
||||
if(timeout_ms == RTW_WAIT_FOREVER) {
|
||||
timeout_ms = portMAX_DELAY;
|
||||
} else {
|
||||
timeout_ms = rtw_ms_to_systime(timeout_ms);
|
||||
}
|
||||
|
||||
if ( xQueueReceive( *queue, message, timeout_ms ) != pdPASS )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _freertos_deinit_xqueue( _xqueue* queue )
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if( uxQueueMessagesWaiting( *queue ) )
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
vQueueDelete( *queue );
|
||||
return result;
|
||||
}
|
||||
|
||||
static u32 _freertos_get_current_time(void)
|
||||
{
|
||||
return xTaskGetTickCount(); //The count of ticks since vTaskStartScheduler was called.
|
||||
}
|
||||
|
||||
static u32 _freertos_systime_to_ms(u32 systime)
|
||||
{
|
||||
return systime * portTICK_RATE_MS;
|
||||
}
|
||||
|
||||
static u32 _freertos_systime_to_sec(u32 systime)
|
||||
{
|
||||
return systime / configTICK_RATE_HZ;
|
||||
}
|
||||
|
||||
static u32 _freertos_ms_to_systime(u32 ms)
|
||||
{
|
||||
return ms / portTICK_RATE_MS;
|
||||
}
|
||||
|
||||
static u32 _freertos_sec_to_systime(u32 sec)
|
||||
{
|
||||
return sec * configTICK_RATE_HZ;
|
||||
}
|
||||
|
||||
static void _freertos_msleep_os(int ms)
|
||||
{
|
||||
vTaskDelay(ms / portTICK_RATE_MS);
|
||||
}
|
||||
|
||||
static void _freertos_usleep_os(int us)
|
||||
{
|
||||
// FreeRTOS does not provide us level delay. Use busy wait
|
||||
WLAN_BSP_UsLoop(us);
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_mdelay_os(int ms)
|
||||
{
|
||||
vTaskDelay(ms / portTICK_RATE_MS);
|
||||
}
|
||||
|
||||
static void _freertos_udelay_os(int us)
|
||||
{
|
||||
// FreeRTOS does not provide us level delay. Use busy wait
|
||||
WLAN_BSP_UsLoop(us);
|
||||
|
||||
}
|
||||
|
||||
static void _freertos_yield_os(void)
|
||||
{
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_SET(ATOMIC_T *v, int i)
|
||||
{
|
||||
atomic_set(v,i);
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_READ(ATOMIC_T *v)
|
||||
{
|
||||
return atomic_read(v);
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_ADD(ATOMIC_T *v, int i)
|
||||
{
|
||||
save_and_cli();
|
||||
v->counter += i;
|
||||
restore_flags();
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_SUB(ATOMIC_T *v, int i)
|
||||
{
|
||||
save_and_cli();
|
||||
v->counter -= i;
|
||||
restore_flags();
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_INC(ATOMIC_T *v)
|
||||
{
|
||||
_freertos_ATOMIC_ADD(v, 1);
|
||||
}
|
||||
|
||||
static void _freertos_ATOMIC_DEC(ATOMIC_T *v)
|
||||
{
|
||||
_freertos_ATOMIC_SUB(v, 1);
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_ADD_RETURN(ATOMIC_T *v, int i)
|
||||
{
|
||||
int temp;
|
||||
|
||||
save_and_cli();
|
||||
temp = v->counter;
|
||||
temp += i;
|
||||
v->counter = temp;
|
||||
restore_flags();
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_SUB_RETURN(ATOMIC_T *v, int i)
|
||||
{
|
||||
int temp;
|
||||
|
||||
save_and_cli();
|
||||
temp = v->counter;
|
||||
temp -= i;
|
||||
v->counter = temp;
|
||||
restore_flags();
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_INC_RETURN(ATOMIC_T *v)
|
||||
{
|
||||
return _freertos_ATOMIC_ADD_RETURN(v, 1);
|
||||
}
|
||||
|
||||
static int _freertos_ATOMIC_DEC_RETURN(ATOMIC_T *v)
|
||||
{
|
||||
return _freertos_ATOMIC_SUB_RETURN(v, 1);
|
||||
}
|
||||
|
||||
static u64 _freertos_modular64(u64 n, u64 base)
|
||||
{
|
||||
unsigned int __base = (base);
|
||||
unsigned int __rem;
|
||||
|
||||
if (((n) >> 32) == 0) {
|
||||
__rem = (unsigned int)(n) % __base;
|
||||
(n) = (unsigned int)(n) / __base;
|
||||
}
|
||||
else
|
||||
__rem = __div64_32(&(n), __base);
|
||||
|
||||
return __rem;
|
||||
}
|
||||
|
||||
/* Refer to ecos bsd tcpip codes */
|
||||
static int _freertos_arc4random(void)
|
||||
{
|
||||
u32 res = xTaskGetTickCount();
|
||||
static unsigned long seed = 0xDEADB00B;
|
||||
|
||||
seed = ((seed & 0x007F00FF) << 7) ^
|
||||
((seed & 0x0F80FF00) >> 8) ^ // be sure to stir those low bits
|
||||
(res << 13) ^ (res >> 9); // using the clock too!
|
||||
return (int)seed;
|
||||
}
|
||||
|
||||
static int _freertos_get_random_bytes(void *buf, size_t len)
|
||||
{
|
||||
#if 1 //becuase of 4-byte align, we use the follow code style.
|
||||
unsigned int ranbuf;
|
||||
unsigned int *lp;
|
||||
int i, count;
|
||||
count = len / sizeof(unsigned int);
|
||||
lp = (unsigned int *) buf;
|
||||
|
||||
for(i = 0; i < count; i ++) {
|
||||
lp[i] = _freertos_arc4random();
|
||||
len -= sizeof(unsigned int);
|
||||
}
|
||||
|
||||
if(len > 0) {
|
||||
ranbuf = _freertos_arc4random();
|
||||
_freertos_memcpy(&lp[i], &ranbuf, len);
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
unsigned long ranbuf, *lp;
|
||||
lp = (unsigned long *)buf;
|
||||
while (len > 0) {
|
||||
ranbuf = _freertos_arc4random();
|
||||
*lp++ = ranbuf; //this op need the pointer is 4Byte-align!
|
||||
len -= sizeof(ranbuf);
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static u32 _freertos_GetFreeHeapSize(void)
|
||||
{
|
||||
return (u32)xPortGetFreeHeapSize();
|
||||
}
|
||||
void *tcm_heap_malloc(int size);
|
||||
static int _freertos_create_task(struct task_struct *ptask, const char *name,
|
||||
u32 stack_size, u32 priority, thread_func_t func, void *thctx)
|
||||
{
|
||||
thread_func_t task_func = NULL;
|
||||
void *task_ctx = NULL;
|
||||
int ret = 0;
|
||||
|
||||
ptask->task_name = name;
|
||||
|
||||
if(func){
|
||||
task_func = func;
|
||||
task_ctx = thctx;
|
||||
}
|
||||
|
||||
priority += tskIDLE_PRIORITY;
|
||||
#if defined(CONFIG_WIFI_NORMAL) && defined(CONFIG_NETWORK)
|
||||
if(rtw_if_wifi_thread((char*)name) == 0){
|
||||
|
||||
#if CONFIG_USE_TCM_HEAP
|
||||
void *stack_addr = tcm_heap_malloc(stack_size*sizeof(int));
|
||||
//void *stack_addr = rtw_malloc(stack_size*sizeof(int));
|
||||
if(stack_addr == NULL){
|
||||
DBG_INFO("Out of TCM heap in \"%s\" ", ptask->task_name);
|
||||
}
|
||||
ret = xTaskGenericCreate(
|
||||
task_func,
|
||||
(const char *)name,
|
||||
stack_size,
|
||||
task_ctx,
|
||||
priority,
|
||||
&ptask->task,
|
||||
stack_addr,
|
||||
NULL);
|
||||
#else
|
||||
ret = xTaskCreate(
|
||||
task_func,
|
||||
(const char *)name,
|
||||
stack_size,
|
||||
task_ctx,
|
||||
priority,
|
||||
&ptask->task);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = xTaskCreate(
|
||||
task_func,
|
||||
(const char *)name,
|
||||
stack_size,
|
||||
task_ctx,
|
||||
priority,
|
||||
(TaskHandle_t * const)&ptask->task);
|
||||
|
||||
}
|
||||
if(ret != pdPASS){
|
||||
DBG_INFO("Create Task \"%s\" Failed! ret=%d\n", ptask->task_name, ret);
|
||||
}
|
||||
|
||||
DBG_TRACE("Create Task \"%s\"\n", ptask->task_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _freertos_delete_task(struct task_struct *ptask)
|
||||
{
|
||||
if (!ptask->task){
|
||||
DBG_INFO("_freertos_delete_task(): ptask is NULL!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
vTaskDelete(ptask->task);
|
||||
ptask->task = 0;
|
||||
|
||||
DBG_TRACE("Delete Task \"%s\"\n", ptask->task_name);
|
||||
}
|
||||
static void _freertos_wakeup_task(struct task_struct *ptask)
|
||||
{
|
||||
xSemaphoreGive(ptask->wakeup_sema);
|
||||
}
|
||||
|
||||
static void _freertos_thread_enter(char *name)
|
||||
{
|
||||
DBG_TRACE("RTKTHREAD %s\n", name);
|
||||
}
|
||||
|
||||
static void _freertos_thread_exit(void)
|
||||
{
|
||||
DBG_TRACE("RTKTHREAD exit %s\n", __FUNCTION__);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
_timerHandle _freertos_timerCreate( const signed char *pcTimerName,
|
||||
osdepTickType xTimerPeriodInTicks,
|
||||
u32 uxAutoReload,
|
||||
void * pvTimerID,
|
||||
TIMER_FUN pxCallbackFunction )
|
||||
{
|
||||
if(xTimerPeriodInTicks == TIMER_MAX_DELAY) {
|
||||
xTimerPeriodInTicks = portMAX_DELAY;
|
||||
}
|
||||
return xTimerCreate((const char *)pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, (TimerCallbackFunction_t)pxCallbackFunction);
|
||||
}
|
||||
|
||||
u32 _freertos_timerDelete( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerDelete(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
u32 _freertos_timerIsTimerActive( _timerHandle xTimer )
|
||||
{
|
||||
return (u32)xTimerIsTimerActive(xTimer);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStop( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerStop(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
u32 _freertos_timerChangePeriod( _timerHandle xTimer,
|
||||
osdepTickType xNewPeriod,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
if(xNewPeriod == 0)
|
||||
xNewPeriod += 1;
|
||||
return (u32)xTimerChangePeriod(xTimer, xNewPeriod, xBlockTime);
|
||||
}
|
||||
void *_freertos_timerGetID( _timerHandle xTimer ){
|
||||
|
||||
return pvTimerGetTimerID(xTimer);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStart( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerStart(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStartFromISR( _timerHandle xTimer,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
return (u32)xTimerStartFromISR(xTimer, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerStopFromISR( _timerHandle xTimer,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
return (u32)xTimerStopFromISR(xTimer, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerResetFromISR( _timerHandle xTimer,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
return (u32)xTimerResetFromISR(xTimer, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerChangePeriodFromISR( _timerHandle xTimer,
|
||||
osdepTickType xNewPeriod,
|
||||
osdepBASE_TYPE *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
if(xNewPeriod == 0)
|
||||
xNewPeriod += 1;
|
||||
return (u32)xTimerChangePeriodFromISR(xTimer, xNewPeriod, pxHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
u32 _freertos_timerReset( _timerHandle xTimer,
|
||||
osdepTickType xBlockTime )
|
||||
{
|
||||
return (u32)xTimerReset(xTimer, xBlockTime);
|
||||
}
|
||||
|
||||
void _freertos_acquire_wakelock()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _freertos_release_wakelock()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _freertos_wakelock_timeout(uint32_t timeout)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
u8 _freertos_get_scheduler_state(void)
|
||||
{
|
||||
u8 state = xTaskGetSchedulerState();
|
||||
switch(state){
|
||||
case taskSCHEDULER_NOT_STARTED: state = OS_SCHEDULER_NOT_STARTED; break;
|
||||
case taskSCHEDULER_RUNNING: state = OS_SCHEDULER_RUNNING; break;
|
||||
case taskSCHEDULER_SUSPENDED: state = OS_SCHEDULER_SUSPENDED; break;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
const struct osdep_service_ops osdep_service = {
|
||||
_freertos_malloc, //rtw_vmalloc
|
||||
_freertos_zmalloc, //rtw_zvmalloc
|
||||
_freertos_mfree, //rtw_vmfree
|
||||
_freertos_malloc, //rtw_malloc
|
||||
_freertos_zmalloc, //rtw_zmalloc
|
||||
_freertos_mfree, //rtw_mfree
|
||||
_freertos_memcpy, //rtw_memcpy
|
||||
_freertos_memcmp, //rtw_memcmp
|
||||
_freertos_memset, //rtw_memset
|
||||
_freertos_init_sema, //rtw_init_sema
|
||||
_freertos_free_sema, //rtw_free_sema
|
||||
_freertos_up_sema, //rtw_up_sema
|
||||
_freertos_up_sema_from_isr, //rtw_up_sema_from_isr
|
||||
_freertos_down_sema, //rtw_down_sema
|
||||
_freertos_mutex_init, //rtw_mutex_init
|
||||
_freertos_mutex_free, //rtw_mutex_free
|
||||
_freertos_mutex_get, //rtw_mutex_get
|
||||
_freertos_mutex_get_timeout,//rtw_mutex_get_timeout
|
||||
_freertos_mutex_put, //rtw_mutex_put
|
||||
_freertos_enter_critical, //rtw_enter_critical
|
||||
_freertos_exit_critical, //rtw_exit_critical
|
||||
_freertos_enter_critical_from_isr, //rtw_enter_critical_from_isr
|
||||
_freertos_exit_critical_from_isr, //rtw_exit_critical_from_isr
|
||||
NULL, //rtw_enter_critical_bh
|
||||
NULL, //rtw_exit_critical_bh
|
||||
_freertos_enter_critical_mutex, //rtw_enter_critical_mutex
|
||||
_freertos_exit_critical_mutex, //rtw_exit_critical_mutex
|
||||
_freertos_cpu_lock,
|
||||
_freertos_cpu_unlock,
|
||||
_freertos_spinlock_init, //rtw_spinlock_init
|
||||
_freertos_spinlock_free, //rtw_spinlock_free
|
||||
_freertos_spinlock, //rtw_spin_lock
|
||||
_freertos_spinunlock, //rtw_spin_unlock
|
||||
_freertos_spinlock_irqsave, //rtw_spinlock_irqsave
|
||||
_freertos_spinunlock_irqsave, //rtw_spinunlock_irqsave
|
||||
_freertos_init_xqueue, //rtw_init_xqueue
|
||||
_freertos_push_to_xqueue, //rtw_push_to_xqueue
|
||||
_freertos_pop_from_xqueue, //rtw_pop_from_xqueue
|
||||
_freertos_deinit_xqueue, //rtw_deinit_xqueue
|
||||
_freertos_get_current_time, //rtw_get_current_time
|
||||
_freertos_systime_to_ms, //rtw_systime_to_ms
|
||||
_freertos_systime_to_sec, //rtw_systime_to_sec
|
||||
_freertos_ms_to_systime, //rtw_ms_to_systime
|
||||
_freertos_sec_to_systime, //rtw_sec_to_systime
|
||||
_freertos_msleep_os, //rtw_msleep_os
|
||||
_freertos_usleep_os, //rtw_usleep_os
|
||||
_freertos_mdelay_os, //rtw_mdelay_os
|
||||
_freertos_udelay_os, //rtw_udelay_os
|
||||
_freertos_yield_os, //rtw_yield_os
|
||||
|
||||
_freertos_ATOMIC_SET, //ATOMIC_SET
|
||||
_freertos_ATOMIC_READ, //ATOMIC_READ
|
||||
_freertos_ATOMIC_ADD, //ATOMIC_ADD
|
||||
_freertos_ATOMIC_SUB, //ATOMIC_SUB
|
||||
_freertos_ATOMIC_INC, //ATOMIC_INC
|
||||
_freertos_ATOMIC_DEC, //ATOMIC_DEC
|
||||
_freertos_ATOMIC_ADD_RETURN, //ATOMIC_ADD_RETURN
|
||||
_freertos_ATOMIC_SUB_RETURN, //ATOMIC_SUB_RETURN
|
||||
_freertos_ATOMIC_INC_RETURN, //ATOMIC_INC_RETURN
|
||||
_freertos_ATOMIC_DEC_RETURN, //ATOMIC_DEC_RETURN
|
||||
|
||||
_freertos_modular64, //rtw_modular64
|
||||
_freertos_get_random_bytes, //rtw_get_random_bytes
|
||||
_freertos_GetFreeHeapSize, //rtw_getFreeHeapSize
|
||||
|
||||
_freertos_create_task, //rtw_create_task
|
||||
_freertos_delete_task, //rtw_delete_task
|
||||
_freertos_wakeup_task, //rtw_wakeup_task
|
||||
|
||||
_freertos_thread_enter, //rtw_thread_enter
|
||||
_freertos_thread_exit, //rtw_thread_exit
|
||||
|
||||
_freertos_timerCreate, //rtw_timerCreate,
|
||||
_freertos_timerDelete, //rtw_timerDelete,
|
||||
_freertos_timerIsTimerActive, //rtw_timerIsTimerActive,
|
||||
_freertos_timerStop, //rtw_timerStop,
|
||||
_freertos_timerChangePeriod, //rtw_timerChangePeriod
|
||||
_freertos_timerGetID, //rtw_timerGetID
|
||||
_freertos_timerStart, //rtw_timerStart
|
||||
_freertos_timerStartFromISR, //rtw_timerStartFromISR
|
||||
_freertos_timerStopFromISR, //rtw_timerStopFromISR
|
||||
_freertos_timerResetFromISR, //rtw_timerResetFromISR
|
||||
_freertos_timerChangePeriodFromISR, //rtw_timerChangePeriodFromISR
|
||||
_freertos_timerReset, //rtw_timerReset
|
||||
|
||||
_freertos_acquire_wakelock, //rtw_acquire_wakelock
|
||||
_freertos_release_wakelock, //rtw_release_wakelock
|
||||
_freertos_wakelock_timeout, //rtw_wakelock_timeout
|
||||
_freertos_get_scheduler_state //rtw_get_scheduler_state
|
||||
};
|
237
lib/wlan/rtl8821cs/os/customer_rtos/customer_rtos_service.h
Normal file
237
lib/wlan/rtl8821cs/os/customer_rtos/customer_rtos_service.h
Normal file
@ -0,0 +1,237 @@
|
||||
#ifndef _CUSTOMER_RTOS_SERVICE_H_
|
||||
#define _CUSTOMER_RTOS_SERVICE_H_
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Include Files
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
#include "dlist.h"
|
||||
|
||||
/* For SPI interface transfer and us delay implementation */
|
||||
#include <rtwlan_bsp.h>
|
||||
|
||||
|
||||
#ifdef CONFIG_USB_HCI
|
||||
typedef struct urb * PURB;
|
||||
#endif
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
#include "basic_types.h"
|
||||
//----- ------------------------------------------------------------------
|
||||
// --------------------------------------------
|
||||
// Platform dependent type define
|
||||
// --------------------------------------------
|
||||
|
||||
#define FIELD_OFFSET(s,field) ((SSIZE_T)&((s*)(0))->field)
|
||||
|
||||
// os types
|
||||
typedef char osdepCHAR;
|
||||
typedef float osdepFLOAT;
|
||||
typedef double osdepDOUBLE;
|
||||
typedef long osdepLONG;
|
||||
typedef short osdepSHORT;
|
||||
typedef unsigned long osdepSTACK_TYPE;
|
||||
typedef long osdepBASE_TYPE;
|
||||
typedef unsigned long osdepTickType;
|
||||
|
||||
typedef void* _timerHandle;
|
||||
typedef void* _sema;
|
||||
typedef void* _mutex;
|
||||
typedef void* _lock;
|
||||
typedef void* _queueHandle;
|
||||
typedef void* _xqueue;
|
||||
typedef struct timer_list _timer;
|
||||
|
||||
typedef struct sk_buff _pkt;
|
||||
typedef unsigned char _buffer;
|
||||
typedef unsigned int systime;
|
||||
|
||||
#ifndef __LIST_H
|
||||
#warning "DLIST_NOT_DEFINE!!!!!!"
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct __queue {
|
||||
struct list_head queue;
|
||||
_lock lock;
|
||||
};
|
||||
|
||||
typedef struct __queue _queue;
|
||||
typedef struct list_head _list;
|
||||
typedef unsigned long _irqL;
|
||||
|
||||
typedef void* _thread_hdl_;
|
||||
typedef void thread_return;
|
||||
typedef void* thread_context;
|
||||
|
||||
typedef struct { volatile int counter; } atomic_t;
|
||||
|
||||
#define ATOMIC_T atomic_t
|
||||
#define HZ configTICK_RATE_HZ
|
||||
#define rtw_timer_list timer_list
|
||||
|
||||
|
||||
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
|
||||
/* emulate a modern version */
|
||||
#define LINUX_VERSION_CODE KERNEL_VERSION(2, 6, 17)
|
||||
|
||||
|
||||
static __inline _list *get_next(_list *list)
|
||||
{
|
||||
return list->next;
|
||||
}
|
||||
|
||||
static __inline _list *get_list_head(_queue *queue)
|
||||
{
|
||||
return (&(queue->queue));
|
||||
}
|
||||
|
||||
#define LIST_CONTAINOR(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(SIZE_T)((char *)&((type *)ptr)->member - (char *)ptr)))
|
||||
//#define container_of(p,t,n) (t*)((p)-&(((t*)0)->n))
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
|
||||
#ifndef TASK_PRORITY_LOW
|
||||
#define TASK_PRORITY_LOW 1
|
||||
#endif
|
||||
#ifndef TASK_PRORITY_MIDDLE
|
||||
#define TASK_PRORITY_MIDDLE 2
|
||||
#endif
|
||||
#ifndef TASK_PRORITY_HIGH
|
||||
#define TASK_PRORITY_HIGH 3
|
||||
#endif
|
||||
#ifndef TASK_PRORITY_SUPER
|
||||
#define TASK_PRORITY_SUPER 4
|
||||
#endif
|
||||
|
||||
|
||||
#define TIMER_MAX_DELAY 0xFFFFFFFF
|
||||
extern unsigned int g_prioritie_offset;
|
||||
#ifdef PRIORITIE_OFFSET
|
||||
#undef PRIORITIE_OFFSET
|
||||
#endif
|
||||
#define PRIORITIE_OFFSET (g_prioritie_offset)
|
||||
|
||||
|
||||
void save_and_cli(void);
|
||||
void restore_flags(void);
|
||||
void cli(void);
|
||||
#if 0
|
||||
#ifndef mdelay
|
||||
#define mdelay(t) ((t/portTICK_RATE_MS)>0)?(vTaskDelay(t/portTICK_RATE_MS)):(vTaskDelay(1))
|
||||
#endif
|
||||
|
||||
#ifndef udelay
|
||||
#define udelay(t) ((t/(portTICK_RATE_MS*1000))>0)?vTaskDelay(t/(portTICK_RATE_MS*1000)):(vTaskDelay(1))
|
||||
#endif
|
||||
#endif
|
||||
//----- ------------------------------------------------------------------
|
||||
// Common Definition
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
#define __init
|
||||
#define __exit
|
||||
#define __devinit
|
||||
#define __devexit
|
||||
|
||||
#define KERN_ERR
|
||||
#define KERN_INFO
|
||||
#define KERN_NOTICE
|
||||
|
||||
#undef GFP_KERNEL
|
||||
#define GFP_KERNEL 1
|
||||
#define GFP_ATOMIC 1
|
||||
|
||||
#define SET_MODULE_OWNER(some_struct) do { } while (0)
|
||||
#define SET_NETDEV_DEV(dev, obj) do { } while (0)
|
||||
#define register_netdev(dev) (0)
|
||||
#define unregister_netdev(dev) do { } while (0)
|
||||
#define netif_queue_stopped(dev) (0)
|
||||
#define netif_wake_queue(dev) do { } while (0)
|
||||
|
||||
int rtw_printf(const char *format, ...);
|
||||
#define printk rtw_printf
|
||||
|
||||
#ifndef __CC_ARM
|
||||
#define DBG_INFO(fmt, args...) printk("\n\rRTL871X: " fmt, ## args)
|
||||
#if WLAN_INTF_DBG
|
||||
#define DBG_TRACE(fmt, args...) printk("\n\rRTL871X: [%s] " fmt, __FUNCTION__, ## args)
|
||||
#else
|
||||
#define DBG_TRACE(fmt, args...)
|
||||
#endif
|
||||
#else
|
||||
#define DBG_INFO(...) do {printk("\n\rRTL871X: ");printk(__VA_ARGS__);} while(0)
|
||||
#if WLAN_INTF_DBG
|
||||
#define DBG_TRACE(...) do {printk("\n\rRTL871X: [%s] ", __FUNCTION__);printk(__VA_ARGS__);} while(0)
|
||||
#else
|
||||
#define DBG_TRACE(...)
|
||||
#endif
|
||||
#endif
|
||||
#define HALT() do { cli(); for(;;);} while(0)
|
||||
#undef ASSERT
|
||||
#define ASSERT(x) do { \
|
||||
if((x) == 0){\
|
||||
printk("\n\rRTL871X: Assert(" #x ") failed on line %d in file %s", __LINE__, __FILE__); \
|
||||
HALT();}\
|
||||
} while(0)
|
||||
|
||||
#undef DBG_ASSERT
|
||||
#define DBG_ASSERT(x, msg) do { \
|
||||
if((x) == 0) \
|
||||
printk("\n\rRTL871X: %s, Assert(" #x ") failed on line %d in file %s", msg, __LINE__, __FILE__); \
|
||||
} while(0)
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Atomic Operation
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* atomic_read - read atomic variable
|
||||
* @v: pointer of type atomic_t
|
||||
*
|
||||
* Atomically reads the value of @v. Note that the guaranteed
|
||||
* useful range of an atomic_t is only 24 bits.
|
||||
*/
|
||||
#undef atomic_read
|
||||
#define atomic_read(v) ((v)->counter)
|
||||
|
||||
/*
|
||||
* atomic_set - set atomic variable
|
||||
* @v: pointer of type atomic_t
|
||||
* @i: required value
|
||||
*
|
||||
* Atomically sets the value of @v to @i. Note that the guaranteed
|
||||
* useful range of an atomic_t is only 24 bits.
|
||||
*/
|
||||
#undef atomic_set
|
||||
#define atomic_set(v,i) ((v)->counter = (i))
|
||||
|
||||
/*
|
||||
* These inlines deal with timer wrapping correctly. You are
|
||||
* strongly encouraged to use them
|
||||
* 1. Because people otherwise forget
|
||||
* 2. Because if the timer wrap changes in future you wont have to
|
||||
* alter your driver code.
|
||||
*
|
||||
* time_after(a,b) returns true if the time a is after time b.
|
||||
*
|
||||
* Do this with "<0" and ">=0" to only test the sign of the result. A
|
||||
* good compiler would generate better code (and a really good compiler
|
||||
* wouldn't care). Gcc is currently neither.
|
||||
*/
|
||||
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
|
||||
#define time_before(a,b) time_after(b,a)
|
||||
|
||||
#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
|
||||
#define time_before_eq(a,b) time_after_eq(b,a)
|
||||
|
||||
|
||||
extern void rtw_init_listhead(_list *list);
|
||||
extern u32 rtw_is_list_empty(_list *phead);
|
||||
extern void rtw_list_insert_head(_list *plist, _list *phead);
|
||||
extern void rtw_list_insert_tail(_list *plist, _list *phead);
|
||||
extern void rtw_list_delete(_list *plist);
|
||||
|
||||
#endif /* _CUSTOMER_RTOS_SERVICE_H_ */
|
64
lib/wlan/rtl8821cs/os/os_dep/device_lock.c
Normal file
64
lib/wlan/rtl8821cs/os/os_dep/device_lock.c
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is proprietary property of RealTek and
|
||||
* possession or use of this module requires release permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "device_lock.h"
|
||||
|
||||
//------------------------------------------------------
|
||||
#define DEVICE_MUTEX_IS_INIT(device) (mutex_init & (1<<device))
|
||||
#define DEVICE_MUTEX_SET_INIT(device) (mutex_init |= (1<<device))
|
||||
#define DEVICE_MUTEX_CLR_INIT(device) (mutex_init &= (~(1<<device)))
|
||||
|
||||
static u32 mutex_init = 0;
|
||||
static _mutex device_mutex[RT_DEV_LOCK_MAX];
|
||||
|
||||
//======================================================
|
||||
static void device_mutex_init(RT_DEV_LOCK_E device)
|
||||
{
|
||||
if(!DEVICE_MUTEX_IS_INIT(device)){
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
if(!DEVICE_MUTEX_IS_INIT(device)){
|
||||
rtw_mutex_init(&device_mutex[device]);
|
||||
DEVICE_MUTEX_SET_INIT(device);
|
||||
}
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================
|
||||
void device_mutex_free(RT_DEV_LOCK_E device)
|
||||
{
|
||||
if(DEVICE_MUTEX_IS_INIT(device)){
|
||||
_lock lock;
|
||||
_irqL irqL;
|
||||
rtw_enter_critical(&lock, &irqL);
|
||||
if(DEVICE_MUTEX_IS_INIT(device)){
|
||||
rtw_mutex_free(&device_mutex[device]);
|
||||
DEVICE_MUTEX_CLR_INIT(device);
|
||||
}
|
||||
rtw_exit_critical(&lock, &irqL);
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================
|
||||
void device_mutex_lock(RT_DEV_LOCK_E device)
|
||||
{
|
||||
device_mutex_init(device);
|
||||
while(rtw_mutex_get_timeout(&device_mutex[device], 10000)<0)
|
||||
DBG_INFO("device lock timeout: %d\n", (int)device);
|
||||
}
|
||||
|
||||
//======================================================
|
||||
void device_mutex_unlock(RT_DEV_LOCK_E device)
|
||||
{
|
||||
device_mutex_init(device);
|
||||
rtw_mutex_put(&device_mutex[device]);
|
||||
}
|
28
lib/wlan/rtl8821cs/os/os_dep/include/device_lock.h
Normal file
28
lib/wlan/rtl8821cs/os/os_dep/include/device_lock.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is proprietary property of RealTek and
|
||||
* possession or use of this module requires release permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _DEVICE_LOCK_H_
|
||||
#define _DEVICE_LOCK_H_
|
||||
|
||||
enum _RT_DEV_LOCK_E
|
||||
{
|
||||
RT_DEV_LOCK_EFUSE = 0,
|
||||
RT_DEV_LOCK_FLASH = 1,
|
||||
RT_DEV_LOCK_CRYPTO = 2,
|
||||
RT_DEV_LOCK_PTA = 3,
|
||||
RT_DEV_LOCK_WLAN = 4,
|
||||
RT_DEV_LOCK_MAX = 5
|
||||
};
|
||||
typedef uint32_t RT_DEV_LOCK_E;
|
||||
|
||||
void device_mutex_lock(RT_DEV_LOCK_E device);
|
||||
void device_mutex_unlock(RT_DEV_LOCK_E device);
|
||||
void device_mutex_free(RT_DEV_LOCK_E device);
|
||||
|
||||
#endif //_DEVICE_LOCK_H_
|
83
lib/wlan/rtl8821cs/os/os_dep/include/net_stack_intf.h
Normal file
83
lib/wlan/rtl8821cs/os/os_dep/include/net_stack_intf.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __NET_STACK_INTF_H__
|
||||
#define __NET_STACK_INTF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <wireless.h>
|
||||
#include <skbuff.h>
|
||||
|
||||
struct netif;
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Ethernet Buffer
|
||||
//----- ------------------------------------------------------------------
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
#include "ethernetif.h"
|
||||
#else
|
||||
struct eth_drv_sg {
|
||||
unsigned int buf;
|
||||
unsigned int len;
|
||||
};
|
||||
#endif
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Wlan Interface Provided
|
||||
//----- ------------------------------------------------------------------
|
||||
unsigned char rltk_wlan_check_isup(int idx);
|
||||
void rltk_wlan_tx_inc(int idx);
|
||||
void rltk_wlan_tx_dec(int idx);
|
||||
struct sk_buff * rltk_wlan_get_recv_skb(int idx);
|
||||
struct sk_buff * rltk_wlan_alloc_skb(unsigned int total_len);
|
||||
void rltk_wlan_set_netif_info(int idx_wlan, void * dev, unsigned char * dev_addr);
|
||||
void rltk_wlan_send_skb(int idx, struct sk_buff *skb); //struct sk_buff as defined above comment line
|
||||
int rltk_wlan_send(int idx, struct eth_drv_sg *sg_list, int sg_len, int total_len);
|
||||
int rltk_wlan_recv(int idx, struct eth_drv_sg *sg_list, int sg_len);
|
||||
unsigned char rltk_wlan_running(unsigned char idx); // interface is up. 0: interface is down
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Network Interface provided
|
||||
//----- ------------------------------------------------------------------
|
||||
|
||||
int netif_is_valid_IP(int idx,unsigned char * ip_dest);
|
||||
int netif_get_idx(struct netif *pnetif);
|
||||
unsigned char *netif_get_hwaddr(int idx_wlan);
|
||||
void netif_rx(int idx, unsigned int len);
|
||||
void netif_post_sleep_processing(void);
|
||||
void netif_pre_sleep_processing(void);
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
extern void ethernetif_recv(struct netif *netif, int total_len);
|
||||
extern void lwip_PRE_SLEEP_PROCESSING(void);
|
||||
extern void lwip_POST_SLEEP_PROCESSING(void);
|
||||
#endif //CONFIG_LWIP_LAYER == 1
|
||||
|
||||
#if CONFIG_WOWLAN
|
||||
extern unsigned char *rltk_wlan_get_ip(int idx);
|
||||
extern unsigned char *rltk_wlan_get_gw(int idx);
|
||||
extern unsigned char *rltk_wlan_get_gwmask(int idx);
|
||||
#endif
|
||||
int rltk_wlan_wait_recv_data_ready(uint32_t timeout, uint32_t * recv_len);
|
||||
int rltk_wlan_ctx_init(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //#ifndef __NET_STACK_INTF_H__
|
1483
lib/wlan/rtl8821cs/os/os_dep/include/osdep_service.h
Normal file
1483
lib/wlan/rtl8821cs/os/os_dep/include/osdep_service.h
Normal file
File diff suppressed because it is too large
Load Diff
397
lib/wlan/rtl8821cs/os/os_dep/net_stack_intf.c
Normal file
397
lib/wlan/rtl8821cs/os/os_dep/net_stack_intf.c
Normal file
@ -0,0 +1,397 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//#define _NET_STACK_INTF_C_
|
||||
#include <stdint.h>
|
||||
#include <autoconf.h>
|
||||
#include <net_stack_intf.h>
|
||||
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
#include <lwip/netif.h>
|
||||
#include <lwip_netconf.h>
|
||||
#include <ethernetif.h>
|
||||
#endif
|
||||
#include <osdep_service.h>
|
||||
#include <wifi/wifi_util.h>
|
||||
//----- ------------------------------------------------------------------
|
||||
// External Reference
|
||||
//----- ------------------------------------------------------------------
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
extern struct netif xnetif[]; //LWIP netif
|
||||
#endif
|
||||
|
||||
#include "board.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
#include "timers.h"
|
||||
#include "semphr.h"
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
/*#include "FreeRTOS_DNS.h" */
|
||||
#include "NetworkBufferManagement.h"
|
||||
#include "NetworkInterface.h"
|
||||
#if USE_LWIP
|
||||
#include "ethernet.h"
|
||||
struct netif *wlan_netif = NULL;
|
||||
|
||||
void rltk_wlan_set_intf(void* intf)
|
||||
{
|
||||
wlan_netif = (struct netif*)intf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//#define DUMP_NETWORK_RX_DATA
|
||||
|
||||
/**
|
||||
* rltk_wlan_set_netif_info - set netif hw address and register dev pointer to netif device
|
||||
* @idx_wlan: netif index
|
||||
* 0 for STA only or SoftAP only or STA in STA+SoftAP concurrent mode,
|
||||
* 1 for SoftAP in STA+SoftAP concurrent mode
|
||||
* @dev: register netdev pointer to LWIP. Reserved.
|
||||
* @dev_addr: set netif hw address
|
||||
*
|
||||
* Return Value: None
|
||||
*/
|
||||
void rltk_wlan_set_netif_info(int idx_wlan, void * dev, unsigned char * dev_addr)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
rtw_memcpy(xnetif[idx_wlan].hwaddr, dev_addr, 6);
|
||||
xnetif[idx_wlan].state = dev;
|
||||
#else
|
||||
printf("\r\ndev_addr: %02x:%02x:%02x:%02x:%02x:%02x\r\n", dev_addr[0], dev_addr[1], dev_addr[2], dev_addr[3], dev_addr[4], dev_addr[5]);
|
||||
#if !defined(USE_LWIP) || (USE_LWIP == 0)
|
||||
FreeRTOS_UpdateMACAddress(dev_addr);
|
||||
#else
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* rltk_wlan_send - send IP packets to WLAN. Called by low_level_output().
|
||||
* @idx: netif index
|
||||
* @sg_list: data buffer list
|
||||
* @sg_len: size of each data buffer
|
||||
* @total_len: total data len
|
||||
*
|
||||
* Return Value: None
|
||||
*/
|
||||
int rltk_wlan_send(int idx, struct eth_drv_sg *sg_list, int sg_len, int total_len)
|
||||
{
|
||||
//#if (CONFIG_LWIP_LAYER == 1)
|
||||
struct eth_drv_sg *last_sg;
|
||||
struct sk_buff *skb = NULL;
|
||||
int ret = 0;
|
||||
|
||||
#ifdef CONFIG_TX_ZERO_COPY
|
||||
u8 *data = NULL;
|
||||
u8 *Mac_data = NULL;
|
||||
#endif
|
||||
|
||||
if(idx == -1){
|
||||
DBG_INFO("netif is DOWN");
|
||||
return -1;
|
||||
}
|
||||
DBG_TRACE("%s is called", __FUNCTION__);
|
||||
|
||||
save_and_cli();
|
||||
if (rltk_wlan_check_isup(idx)) {
|
||||
rltk_wlan_tx_inc(idx);
|
||||
} else {
|
||||
DBG_INFO("netif is DOWN");printf("%s is called\r\n", __FUNCTION__);
|
||||
restore_flags();
|
||||
return -1;
|
||||
}
|
||||
restore_flags();
|
||||
|
||||
#ifdef CONFIG_TX_ZERO_COPY
|
||||
data = rtw_malloc(1640);
|
||||
if(data == NULL){
|
||||
DBG_INFO("###########ERR_MEM at %s\r\n",__func__);
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
Mac_data = data + 80;
|
||||
|
||||
for (last_sg = &sg_list[sg_len]; sg_list < last_sg; ++sg_list) {
|
||||
rtw_memcpy(Mac_data, (void *)(sg_list->buf), sg_list->len);
|
||||
Mac_data+=sg_list->len;
|
||||
}
|
||||
|
||||
skb = (struct sk_buff *)rltk_wlan_alloc_skb_0copy();
|
||||
if (skb == NULL) {
|
||||
DBG_INFO("rltk_wlan_alloc_skb()failed!\r\n");
|
||||
goto exit;
|
||||
}
|
||||
skb->data = data + 80;
|
||||
skb->head = data;
|
||||
skb->end = data + 1640;
|
||||
skb->tail = data + 80 + total_len;
|
||||
skb->len = total_len;
|
||||
ret = 0;
|
||||
#else
|
||||
skb = rltk_wlan_alloc_skb(total_len);
|
||||
#endif
|
||||
|
||||
if (skb == NULL) {
|
||||
DBG_INFO("rltk_wlan_alloc_skb() for data len=%d failed!", total_len);
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_TX_ZERO_COPY
|
||||
for (last_sg = &sg_list[sg_len]; sg_list < last_sg; ++sg_list) {
|
||||
//printf("sg_list len :%d \r\n", sg_list->len);
|
||||
rtw_memcpy(skb->tail, (void *)(sg_list->buf), sg_list->len);
|
||||
skb_put(skb, sg_list->len);
|
||||
}
|
||||
#endif
|
||||
|
||||
rltk_wlan_send_skb(idx, skb);
|
||||
|
||||
exit:
|
||||
save_and_cli();
|
||||
rltk_wlan_tx_dec(idx);
|
||||
restore_flags();
|
||||
return ret;
|
||||
//#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* rltk_wlan_recv - indicate packets to LWIP. Called by ethernetif_recv().
|
||||
* @idx: netif index
|
||||
* @sg_list: data buffer list
|
||||
* @sg_len: size of each data buffer
|
||||
*
|
||||
* Return Value: None
|
||||
*/
|
||||
int rltk_wlan_recv(int idx, struct eth_drv_sg *sg_list, int sg_len)
|
||||
{
|
||||
//#if (CONFIG_LWIP_LAYER == 1)
|
||||
struct eth_drv_sg *last_sg;
|
||||
struct sk_buff *skb;
|
||||
|
||||
DBG_TRACE("%s is called", __FUNCTION__);
|
||||
if(idx == -1){
|
||||
DBG_INFO("skb is NULL");
|
||||
return 0;
|
||||
}//printf("\r\n%s is called at:%d\r\n", __FUNCTION__, __LINE__);
|
||||
skb = rltk_wlan_get_recv_skb(idx);
|
||||
if (NULL == skb) {printf("\r\n%s is called at:%d\r\n", __FUNCTION__, __LINE__);
|
||||
//mdelay(10);
|
||||
return 0;
|
||||
}
|
||||
DBG_ASSERT(skb, "No pending rx skb");
|
||||
|
||||
for (last_sg = &sg_list[sg_len]; sg_list < last_sg; ++sg_list) {
|
||||
if (sg_list->buf != 0) {
|
||||
rtw_memcpy((void *)(sg_list->buf), skb->data, sg_list->len);
|
||||
skb_pull(skb, sg_list->len);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
//#endif
|
||||
}
|
||||
|
||||
int netif_is_valid_IP(int idx, unsigned char *ip_dest)
|
||||
{
|
||||
#if CONFIG_LWIP_LAYER == 1
|
||||
struct netif * pnetif = &xnetif[idx];
|
||||
|
||||
ip_addr_t addr = { 0 };
|
||||
|
||||
#if CONFIG_MEMORY_ACCESS_ALIGNED
|
||||
unsigned int temp;
|
||||
memcpy(&temp, ip_dest, sizeof(unsigned int));
|
||||
u32_t *ip_dest_addr = &temp;
|
||||
#else
|
||||
u32_t *ip_dest_addr = (u32_t*)ip_dest;
|
||||
#endif
|
||||
|
||||
#if LWIP_VERSION_MAJOR >= 2
|
||||
ip_addr_set_ip4_u32(&addr, *ip_dest_addr);
|
||||
#else
|
||||
addr.addr = *ip_dest_addr;
|
||||
#endif
|
||||
|
||||
#if LWIP_VERSION_MAJOR >= 2
|
||||
if((ip_addr_get_ip4_u32(netif_ip_addr4(pnetif))) == 0)
|
||||
return 1;
|
||||
#else
|
||||
|
||||
if(pnetif->ip_addr.addr == 0)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
if(ip_addr_ismulticast(&addr) || ip_addr_isbroadcast(&addr,pnetif)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
//if(ip_addr_netcmp(&(pnetif->ip_addr), &addr, &(pnetif->netmask))) //addr&netmask
|
||||
// return 1;
|
||||
|
||||
if(ip_addr_cmp(&(pnetif->ip_addr),&addr))
|
||||
return 1;
|
||||
|
||||
DBG_TRACE("invalid IP: %d.%d.%d.%d ",ip_dest[0],ip_dest[1],ip_dest[2],ip_dest[3]);
|
||||
#endif
|
||||
//printf("\r\nnet id:%d IP: %d.%d.%d.%d \r\n", idx, ip_dest[0], ip_dest[1], ip_dest[2], ip_dest[3]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int netif_get_idx(struct netif* pnetif)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
int idx = pnetif - xnetif;
|
||||
|
||||
switch(idx) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char *netif_get_hwaddr(int idx_wlan)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return xnetif[idx_wlan].hwaddr;
|
||||
#else
|
||||
return (unsigned char *)FreeRTOS_GetMACAddress();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LWIP
|
||||
void wlan_ethernetif_input(void *h, size_t len);
|
||||
#endif
|
||||
|
||||
void netif_rx(int idx, unsigned int len)
|
||||
{
|
||||
//printf("%s idx:%d len:%d\r\n", __func__, idx, len);
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
ethernetif_recv(&xnetif[idx], len);
|
||||
#else
|
||||
#if USE_LWIP
|
||||
wlan_ethernetif_input(wlan_netif, len);
|
||||
#else
|
||||
NetworkBufferDescriptor_t * pxBufferDescriptor;
|
||||
IPStackEvent_t xRxEvent;
|
||||
int32_t xBytesReceived = len;
|
||||
int ret = -1;
|
||||
|
||||
pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( ( size_t ) xBytesReceived, 0 );
|
||||
|
||||
if( pxBufferDescriptor != NULL )
|
||||
{
|
||||
struct eth_drv_sg sg_list = {0};
|
||||
sg_list.buf = (unsigned int)pxBufferDescriptor->pucEthernetBuffer;
|
||||
sg_list.len = (unsigned int)xBytesReceived;
|
||||
ret = rltk_wlan_recv(0, &sg_list, 1);
|
||||
if (ret == 0) {
|
||||
printf("no rcv data\r\n");
|
||||
vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor );
|
||||
return;
|
||||
}
|
||||
#ifdef DUMP_NETWORK_RX_DATA
|
||||
if (1) {
|
||||
int i;
|
||||
char* tmp = (char *)pxBufferDescriptor->pucEthernetBuffer;
|
||||
printf("\r\n recv:");
|
||||
for (i = 0; i < sg_list.len; i++) {
|
||||
printf("%02x ", tmp[i]);
|
||||
}printf("recv end\r\n");
|
||||
}
|
||||
#endif
|
||||
//memcpy( pxBufferDescriptor->pucEthernetBuffer, buffer_pointer, ( size_t ) xBytesReceived );
|
||||
pxBufferDescriptor->xDataLength = ( size_t ) xBytesReceived;
|
||||
if( eConsiderFrameForProcessing( pxBufferDescriptor->pucEthernetBuffer ) == eProcessBuffer )
|
||||
{//printf("send eNetworkRxEvent\r\n");
|
||||
xRxEvent.eEventType = eNetworkRxEvent;
|
||||
xRxEvent.pvData = ( void * ) pxBufferDescriptor;
|
||||
if( xSendEventStructToIPTask( &xRxEvent, 0 ) == pdFALSE )
|
||||
{
|
||||
vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor );
|
||||
iptraceETHERNET_RX_EVENT_LOST();
|
||||
}
|
||||
else
|
||||
{
|
||||
iptraceNETWORK_INTERFACE_RECEIVE();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iptraceETHERNET_RX_EVENT_LOST();
|
||||
FreeRTOS_printf( ( "R_ETHER_Read_ZC2: Cleared descriptors\n" ) );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void netif_post_sleep_processing(void)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
lwip_POST_SLEEP_PROCESSING(); //For FreeRTOS tickless to enable Lwip ARP timer when leaving IPS - Alex Fang
|
||||
#endif
|
||||
}
|
||||
|
||||
void netif_pre_sleep_processing(void)
|
||||
{
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
lwip_PRE_SLEEP_PROCESSING();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_WOWLAN
|
||||
unsigned char *rltk_wlan_get_ip(int idx){
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return LwIP_GetIP(&xnetif[idx]);
|
||||
#else
|
||||
printf("rltk_wlan_get_ip\r\n");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
unsigned char *rltk_wlan_get_gw(int idx){
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return LwIP_GetGW(&xnetif[idx]);
|
||||
#else
|
||||
printf("rltk_wlan_get_gw\r\n");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char *rltk_wlan_get_gwmask(int idx){
|
||||
#if (CONFIG_LWIP_LAYER == 1)
|
||||
return LwIP_GetMASK(&xnetif[idx]);
|
||||
#else
|
||||
printf("rltk_wlan_get_gwmask\r\n");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
1387
lib/wlan/rtl8821cs/os/os_dep/osdep_service.c
Normal file
1387
lib/wlan/rtl8821cs/os/os_dep/osdep_service.c
Normal file
File diff suppressed because it is too large
Load Diff
279
lib/wlan/rtl8821cs/platform/include/dlist.h
Normal file
279
lib/wlan/rtl8821cs/platform/include/dlist.h
Normal file
@ -0,0 +1,279 @@
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2013-2016 Realtek Semiconductor Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __LIST_H
|
||||
#define __LIST_H
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This file is from Linux Kernel (include/linux/list.h)
|
||||
* and modified by simply removing hardware prefetching of list items.
|
||||
* Here by copyright, credits attributed to wherever they belong.
|
||||
* Kulesh Shanmugasundaram (kulesh [squiggly] isis.poly.edu)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
#define INIT_LIST_HEAD(ptr) do { \
|
||||
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_add(struct list_head *newitem,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = newitem;
|
||||
newitem->next = next;
|
||||
newitem->prev = prev;
|
||||
prev->next = newitem;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it after
|
||||
*
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
static inline void list_add(struct list_head *newitem, struct list_head *head)
|
||||
{
|
||||
__list_add(newitem, head, head->next);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it before
|
||||
*
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
static inline void list_add_tail(struct list_head *newitem, struct list_head *head)
|
||||
{
|
||||
__list_add(newitem, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
|
||||
*/
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = (struct list_head *) 0;
|
||||
entry->prev = (struct list_head *) 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del_init - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
static inline void list_del_init(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
INIT_LIST_HEAD(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move - delete from one list and add as another's head
|
||||
* @list: the entry to move
|
||||
* @head: the head that will precede our entry
|
||||
*/
|
||||
static inline void list_move(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move_tail - delete from one list and add as another's tail
|
||||
* @list: the entry to move
|
||||
* @head: the head that will follow our entry
|
||||
*/
|
||||
static inline void list_move_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add_tail(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
static inline void __list_splice(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice - join two lists
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
static inline void list_splice_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list_entry - get the struct for this entry
|
||||
* @ptr: the &struct list_head pointer.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
|
||||
|
||||
/**
|
||||
* list_first_entry - get the first element from a list
|
||||
* @ptr: the list head to take the element from.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*
|
||||
* Note, that list is expected to be not empty.
|
||||
*/
|
||||
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->next, type, member)
|
||||
|
||||
|
||||
/**
|
||||
* list_for_each - iterate over a list
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); \
|
||||
pos = pos->next)
|
||||
/**
|
||||
* list_for_each_prev - iterate over a list backwards
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); \
|
||||
pos = pos->prev)
|
||||
|
||||
/**
|
||||
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||
* @pos: the &struct list_head to use as a loop counter.
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_entry - iterate over list of given type
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, type, member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop counter.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member, type) \
|
||||
for (pos = list_entry((head)->next, type, member), \
|
||||
n = list_entry(pos->member.next, type, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, type, member))
|
||||
|
||||
#endif
|
||||
|
18
lib/wlan/rtl8821cs/platform/include/rtwlan_config.h
Normal file
18
lib/wlan/rtl8821cs/platform/include/rtwlan_config.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __RTWLAN_CONFIG_H
|
||||
#define __RTWLAN_CONFIG_H
|
||||
#include "FreeRTOSConfig.h"
|
||||
#define CONFIG_PLATFOMR_CUSTOMER_RTOS
|
||||
#define DRV_NAME "RTL8821CS"
|
||||
#define DRIVERVERSION "c9c2594a99792ec4c03af05362d0c1faa313be44"
|
||||
|
||||
#define CONFIG_DEBUG 1
|
||||
|
||||
#define CONFIG_MP_INCLUDED 1
|
||||
#define CONFIG_MP_NORMAL_IWPRIV_SUPPORT 1
|
||||
#define CONFIG_HARDWARE_8821C 1
|
||||
#define CONFIG_ENABLE_P2P 1
|
||||
#define CONFIG_WPS 1
|
||||
#define CONFIG_WPS_AP 1
|
||||
#define CONFIG_ENABLE_WPS_AP 1
|
||||
|
||||
#endif
|
34
lib/wlan/rtl8821cs/platform/rtwlan_bsp/rtwlan_bsp.c
Normal file
34
lib/wlan/rtl8821cs/platform/rtwlan_bsp/rtwlan_bsp.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdint.h>
|
||||
#include "timer.h"
|
||||
|
||||
/*static inline void sys_ctl_delay(unsigned long ulCount)
|
||||
{
|
||||
while(ulCount--);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Customer provide us level delay
|
||||
* FreeRTOS does not provide us level delay. Use busy wait
|
||||
* It is CPU platform dependent
|
||||
*/
|
||||
|
||||
void WLAN_BSP_UsLoop(int us)
|
||||
{
|
||||
|
||||
//unsigned long nloops = us * (configCPU_CLOCK_HZ / 3000000);
|
||||
//sys_ctl_delay(nloops);
|
||||
udelay(us);
|
||||
|
||||
}
|
||||
|
||||
/* Customer function to control HW specific wlan gpios */
|
||||
void Set_WLAN_Power_On(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Customer function to control HW specific wlan gpios */
|
||||
void Set_WLAN_Power_Off(void)
|
||||
{
|
||||
|
||||
}
|
21
lib/wlan/rtl8821cs/platform/rtwlan_bsp/rtwlan_bsp.h
Normal file
21
lib/wlan/rtl8821cs/platform/rtwlan_bsp/rtwlan_bsp.h
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtwlan_bsp.h
|
||||
* @author Realtek software team
|
||||
* @version V0.1
|
||||
* @date 05-March-2013
|
||||
* @brief Realtek WLAN hardware configuration.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __REALTEK_WLAN_BSP_H__
|
||||
#define __REALTEK_WLAN_BSP_H__
|
||||
/* Includes ---------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void Set_WLAN_Power_On(void);
|
||||
void Set_WLAN_Power_Off(void);
|
||||
void WLAN_BSP_UsLoop(int us);
|
||||
|
||||
#endif// __REALTEK_WLAN_BSP_H__
|
11
lib/wlan/rtl8821cs/platform/sdio/core/sdio_irq.h
Normal file
11
lib/wlan/rtl8821cs/platform/sdio/core/sdio_irq.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef _MMC_SDIO_IRQ_H
|
||||
#define _MMC_SDIO_IRQ_H
|
||||
|
||||
//#include "../include/card.h"
|
||||
#include "mmcsd_card.h"
|
||||
|
||||
int sdio_claim_irq(struct sdio_func *func, void(*handler)(struct sdio_func *));
|
||||
int sdio_release_irq(struct sdio_func *func);
|
||||
void sdio_irq_thread(void* exinf);
|
||||
|
||||
#endif
|
76
lib/wlan/rtl8821cs/platform/sdio/include/card.h
Normal file
76
lib/wlan/rtl8821cs/platform/sdio/include/card.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef _MMC_SDIO_CARD_H
|
||||
#define _MMC_SDIO_CARD_H
|
||||
|
||||
#ifdef CONFIG_READ_CIS
|
||||
/*
|
||||
* SDIO function CIS tuple (unknown to the core)
|
||||
*/
|
||||
struct sdio_func_tuple {
|
||||
struct sdio_func_tuple *next;
|
||||
unsigned char code;
|
||||
unsigned char size;
|
||||
unsigned char data[0];
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SDIO function devices
|
||||
*/
|
||||
struct sdio_func {
|
||||
struct mmc_card *card; /* the card this device belongs to */
|
||||
void (*irq_handler)(struct sdio_func *); /* IRQ callback */
|
||||
|
||||
unsigned int max_blksize; /* maximum block size */ //add
|
||||
unsigned int cur_blksize; /* current block size */ //add
|
||||
unsigned int enable_timeout; /* max enable timeout in msec */ //add
|
||||
unsigned int num; /* function number *///add
|
||||
unsigned short vendor; /* vendor id */ //add
|
||||
unsigned short device; /* device id */ //add
|
||||
unsigned num_info; /* number of info strings */ //add
|
||||
const char **info; /* info strings */ //add
|
||||
unsigned char class; /* standard interface class *///add
|
||||
|
||||
unsigned int tmpbuf_reserved; //for tmpbuf 4 byte alignment
|
||||
unsigned char tmpbuf[4]; /* DMA:able scratch buffer */
|
||||
|
||||
#ifdef CONFIG_READ_CIS
|
||||
struct sdio_func_tuple *tuples;
|
||||
#endif
|
||||
void *drv_priv;
|
||||
};
|
||||
|
||||
struct sdio_cccr {
|
||||
unsigned int sdio_vsn;
|
||||
unsigned int sd_vsn;
|
||||
unsigned int multi_block:1;
|
||||
unsigned int low_speed:1;
|
||||
unsigned int wide_bus:1;
|
||||
unsigned int high_power:1;
|
||||
unsigned int high_speed:1;
|
||||
unsigned int disable_cd:1;
|
||||
};
|
||||
|
||||
struct sdio_cis {
|
||||
unsigned short vendor;
|
||||
unsigned short device;
|
||||
unsigned short blksize;
|
||||
unsigned int max_dtr;
|
||||
};
|
||||
|
||||
struct mmc_card {
|
||||
struct mmc_host *host; /* the host this device belongs to */
|
||||
struct sdio_cccr cccr; /* common card info */
|
||||
struct sdio_cis cis; /* common tuple info */ //add
|
||||
struct sdio_func *sdio_func[7]; /* SDIO functions (devices) *///add
|
||||
unsigned int sdio_funcs; /* number of SDIO functions *///add
|
||||
|
||||
unsigned int rca; /* relative card address of device */
|
||||
unsigned int type; /* card type */
|
||||
|
||||
unsigned num_info; /* number of info strings *///add
|
||||
const char **info; /* info strings *///add
|
||||
#ifdef CONFIG_READ_CIS
|
||||
struct sdio_func_tuple *tuples; /* unknown common tuples *///add
|
||||
#endif
|
||||
};
|
||||
#endif
|
258
lib/wlan/rtl8821cs/platform/sdio/wifi_io.c
Normal file
258
lib/wlan/rtl8821cs/platform/sdio/wifi_io.c
Normal file
@ -0,0 +1,258 @@
|
||||
//#include "include/common.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "board.h"
|
||||
#ifdef SDMMC_SUPPORT
|
||||
#include "sdio.h"
|
||||
#include "wifi_io.h"
|
||||
#include "mmcsd_core.h"
|
||||
|
||||
/* test wifi driver */
|
||||
#define ADDR_MASK 0x10000
|
||||
#define LOCAL_ADDR_MASK 0x00000
|
||||
|
||||
int sdio_bus_probe(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int sdio_bus_remove(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void sdio_claim_host(struct sdio_func*func)
|
||||
{
|
||||
mmcsd_host_lock(func->card->host);
|
||||
}
|
||||
void sdio_release_host(struct sdio_func *func)
|
||||
{
|
||||
mmcsd_host_unlock(func->card->host);
|
||||
}
|
||||
|
||||
int32_t sdio_claim_irq(struct sdio_func *func,
|
||||
void(*handler)(struct sdio_func *))
|
||||
{
|
||||
return sdio_attach_irq(func, handler);
|
||||
}
|
||||
|
||||
int32_t sdio_release_irq(struct sdio_func *func)
|
||||
{
|
||||
return sdio_detach_irq(func);
|
||||
}
|
||||
|
||||
unsigned char sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret)
|
||||
{
|
||||
unsigned char ret;
|
||||
int32_t err = -1;
|
||||
ret = sdio_io_readb(func, addr, (int32_t *)&err);
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
if (err_ret)
|
||||
*err_ret = (int)err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void sdio_writeb(struct sdio_func *func, unsigned char b, unsigned int addr, int *err_ret)
|
||||
{
|
||||
int err = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
err= sdio_io_writeb(func, addr, b);
|
||||
if (NULL != err_ret)
|
||||
*err_ret = err;
|
||||
}
|
||||
|
||||
uint16_t sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret)
|
||||
{//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
return sdio_io_readw(func, addr, err_ret);
|
||||
}
|
||||
|
||||
void sdio_writew(struct sdio_func *func, uint16_t v, unsigned int addr, int *err_ret)
|
||||
{
|
||||
int err = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
err= sdio_io_writew(func, v, addr);
|
||||
if (NULL != err_ret)
|
||||
*err_ret = err;
|
||||
}
|
||||
|
||||
uint32_t sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret)
|
||||
{//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
return sdio_io_readl(func, addr, err_ret);
|
||||
}
|
||||
|
||||
void sdio_writel(struct sdio_func *func, uint32_t v, unsigned int addr, int *err_ret)
|
||||
{
|
||||
int err = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
err= sdio_io_writel(func, v, addr);
|
||||
if (NULL != err_ret)
|
||||
*err_ret = err;
|
||||
}
|
||||
|
||||
int sdio_memcpy_fromio(struct sdio_func *func, void *dst,
|
||||
unsigned int addr, int count)
|
||||
{
|
||||
return sdio_io_rw_extended_block(func, 0, addr, 1, (uint8_t *)dst, count);
|
||||
}
|
||||
|
||||
int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
|
||||
void *src, int count)
|
||||
{
|
||||
return sdio_io_rw_extended_block(func, 1, addr, 1, (uint8_t *)src, count);
|
||||
}
|
||||
|
||||
int wifi_read(struct sdio_func *func, u32 addr, u32 cnt, void *pdata)
|
||||
{
|
||||
int err;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
|
||||
err = sdio_memcpy_fromio(func, pdata, (unsigned int)addr, (int)cnt);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL(%d)! ADDR=%#x Size=%d\n", __func__, err, addr, cnt);
|
||||
}
|
||||
|
||||
sdio_release_host(func);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int wifi_write(struct sdio_func *func, u32 addr, u32 cnt, void *pdata)
|
||||
{
|
||||
int err;
|
||||
u32 size;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
|
||||
size = cnt;
|
||||
err = sdio_memcpy_toio(func, addr, pdata, size);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL(%d)! ADDR=%#x Size=%d(%d)\n", __func__, err, addr, cnt, size);
|
||||
}
|
||||
|
||||
sdio_release_host(func);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
u8 wifi_readb(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u8 ret = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
ret = sdio_readb(func, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x\n", __func__, err, addr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
u16 wifi_readw(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u16 v;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
v = sdio_readw(func, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x\n", __func__, err, addr);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
u32 wifi_readl(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u32 v;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
v = sdio_readl(func, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
void wifi_writeb(struct sdio_func *func, u32 addr, u8 val)
|
||||
{
|
||||
int err;
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
sdio_writeb(func, val, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x val=0x%02x\n", __func__, err, addr, val);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_writew(struct sdio_func *func, u32 addr, u16 v)
|
||||
{
|
||||
int err;
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
sdio_writew(func, v, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
if (err) {
|
||||
//dbg_host("%s: FAIL!(%d) addr=0x%05x val=0x%04x\n", __func__, err, addr, v);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_writel(struct sdio_func *func, u32 addr, u32 v)
|
||||
{
|
||||
int err;
|
||||
//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_claim_host(func);
|
||||
sdio_writel(func, v, ADDR_MASK | addr, &err);
|
||||
sdio_release_host(func);
|
||||
}
|
||||
|
||||
u8 wifi_readb_local(struct sdio_func *func, u32 addr)
|
||||
{
|
||||
int err;
|
||||
u8 ret = 0;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
ret = sdio_readb(func, LOCAL_ADDR_MASK | addr, &err);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wifi_writeb_local(struct sdio_func *func, u32 addr, u8 val)
|
||||
{
|
||||
int err;//printf("%s addr:%08x\r\n", __func__, addr);
|
||||
|
||||
sdio_writeb(func, val, LOCAL_ADDR_MASK | addr, &err);
|
||||
}
|
||||
extern int rtw_fake_driver_probe(struct sdio_func *func);
|
||||
void wifi_fake_driver_probe_rtlwifi(struct sdio_func *func)
|
||||
{
|
||||
rtw_fake_driver_probe(func);//todo1
|
||||
}
|
||||
|
||||
extern int sdio_bus_probe(void);
|
||||
extern int sdio_bus_remove(void);
|
||||
SDIO_BUS_OPS rtw_sdio_bus_ops = {
|
||||
sdio_bus_probe,
|
||||
sdio_bus_remove,
|
||||
sdio_enable_func,
|
||||
sdio_disable_func,
|
||||
NULL,
|
||||
NULL,
|
||||
sdio_claim_irq,
|
||||
sdio_release_irq,
|
||||
sdio_claim_host,
|
||||
sdio_release_host,
|
||||
sdio_readb,
|
||||
sdio_readw,
|
||||
sdio_readl,
|
||||
sdio_writeb,
|
||||
sdio_writew,
|
||||
sdio_writel,
|
||||
sdio_memcpy_fromio,
|
||||
sdio_memcpy_toio
|
||||
};
|
||||
#endif
|
||||
|
62
lib/wlan/rtl8821cs/platform/sdio/wifi_io.h
Normal file
62
lib/wlan/rtl8821cs/platform/sdio/wifi_io.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef _WIFI_IO_H
|
||||
#define _WIFI_IO_H
|
||||
|
||||
//#include "core/sdio_irq.h"
|
||||
|
||||
struct sdio_driver {
|
||||
int fake;
|
||||
};
|
||||
|
||||
//#define sdio_func sdio_function
|
||||
#ifndef u32
|
||||
#define u32 uint32_t
|
||||
#endif
|
||||
#ifndef u16
|
||||
#define u16 uint16_t
|
||||
#endif
|
||||
#ifndef u8
|
||||
#define u8 uint8_t
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(_x) (1 << (_x))
|
||||
#endif
|
||||
int wifi_read(struct sdio_func *func, u32 addr, u32 cnt, void *pdata);
|
||||
int wifi_write(struct sdio_func *func, u32 addr, u32 cnt, void *pdata);
|
||||
u8 wifi_readb(struct sdio_func *func, u32 addr);
|
||||
u16 wifi_readw(struct sdio_func *func, u32 addr);
|
||||
u32 wifi_readl(struct sdio_func *func, u32 addr);
|
||||
void wifi_writeb(struct sdio_func *func, u32 addr, u8 val);
|
||||
void wifi_writew(struct sdio_func *func, u32 addr, u16 v);
|
||||
void wifi_writel(struct sdio_func *func, u32 addr, u32 v);
|
||||
u8 wifi_readb_local(struct sdio_func *func, u32 addr);
|
||||
void wifi_writeb_local(struct sdio_func *func, u32 addr, u8 val);
|
||||
|
||||
//typedef unsigned long UINT32;
|
||||
typedef struct _SDIO_BUS_OPS{
|
||||
int (*bus_probe)(void);
|
||||
int (*bus_remove)(void);
|
||||
int (*enable)(struct sdio_func*func); /*enables a SDIO function for usage*/
|
||||
int (*disable)(struct sdio_func *func);
|
||||
int (*reg_driver)(struct sdio_driver*); /*register sdio function device driver callback*/
|
||||
void (*unreg_driver)(struct sdio_driver *);
|
||||
int (*claim_irq)(struct sdio_func *func, void(*handler)(struct sdio_func *));
|
||||
int (*release_irq)(struct sdio_func*func);
|
||||
void (*claim_host)(struct sdio_func*func); /*exclusively claim a bus for a certain SDIO function*/
|
||||
void (*release_host)(struct sdio_func *func);
|
||||
unsigned char (*readb)(struct sdio_func *func, unsigned int addr, int *err_ret);/*read a single byte from a SDIO function*/
|
||||
unsigned short (*readw)(struct sdio_func *func, unsigned int addr, int *err_ret); /*read a 16 bit integer from a SDIO function*/
|
||||
unsigned int (*readl)(struct sdio_func *func, unsigned int addr, int *err_ret); /*read a 32 bit integer from a SDIO function*/
|
||||
void (*writeb)(struct sdio_func *func, unsigned char b,unsigned int addr, int *err_ret); /*write a single byte to a SDIO function*/
|
||||
void (*writew)(struct sdio_func *func, unsigned short b,unsigned int addr, int *err_ret); /*write a 16 bit integer to a SDIO function*/
|
||||
void (*writel)(struct sdio_func *func, unsigned int b,unsigned int addr, int *err_ret); /*write a 32 bit integer to a SDIO function*/
|
||||
int (*memcpy_fromio)(struct sdio_func *func, void *dst,unsigned int addr, int count);/*read a chunk of memory from a SDIO functio*/
|
||||
int (*memcpy_toio)(struct sdio_func *func, unsigned int addr,void *src, int count); /*write a chunk of memory to a SDIO function*/
|
||||
}SDIO_BUS_OPS;
|
||||
|
||||
extern SDIO_BUS_OPS rtw_sdio_bus_ops;
|
||||
extern struct sdio_func *wifi_sdio_func;
|
||||
extern int sdio_bus_probe(void);
|
||||
extern int sdio_bus_remove(void);
|
||||
#endif
|
||||
|
454
lib/wlan/rtl8821cs/platform/usb/usb_io_realtek.c
Normal file
454
lib/wlan/rtl8821cs/platform/usb/usb_io_realtek.c
Normal file
@ -0,0 +1,454 @@
|
||||
#include "usb_io_realtek.h"
|
||||
|
||||
#define REALTEK_USB_VENQT_READ 0xC0
|
||||
#define REALTEK_USB_VENQT_WRITE 0x40
|
||||
#define RTW_USB_CONTROL_MSG_TIMEOUT 500//ms
|
||||
|
||||
#define FW_START_ADDRESS 0x1000
|
||||
#define VENDOR_CMD_MAX_DATA_LEN 254
|
||||
|
||||
#define ALIGNMENT_UNIT 32
|
||||
#define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */
|
||||
#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(_x) (1 << (_x))
|
||||
#endif
|
||||
|
||||
struct rtw_urb
|
||||
{
|
||||
struct urb urb;
|
||||
bool is_used;
|
||||
};
|
||||
|
||||
#define MaxurbNum 40
|
||||
static struct rtw_urb rtw_urb_read[MaxurbNum];
|
||||
static struct rtw_urb rtw_urb_write[MaxurbNum];
|
||||
|
||||
int rtw_usb_rcvctrlpipe(struct usb_device *dev, u32 endpoint)
|
||||
{
|
||||
return usb_rcvctrlpipe(dev,endpoint);
|
||||
}
|
||||
int rtw_usb_sndctrlpipe(struct usb_device *dev, u32 endpoint)
|
||||
{
|
||||
return usb_sndctrlpipe(dev,endpoint);
|
||||
}
|
||||
int rtw_usb_get_bulk_in_pipe(void *priv,unsigned char ep_addr)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
return usb_rcvbulkpipe(udev,ep_addr);
|
||||
}
|
||||
int rtw_usb_get_bulk_out_pipe(void *priv,unsigned char ep_addr)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
return usb_sndbulkpipe(udev,ep_addr);
|
||||
}
|
||||
struct urb * rtw_usb_alloc_urb(u16 iso_packets, int mem_flags)
|
||||
{
|
||||
//return usb_alloc_urb(iso_packets,mem_flags);
|
||||
return usb_alloc_urb(iso_packets); //xhl
|
||||
}
|
||||
void rtw_usb_free_urb(struct urb *urb)
|
||||
{
|
||||
usb_free_urb(urb);
|
||||
}
|
||||
void rtw_usb_kill_urb(struct urb *urb)
|
||||
{
|
||||
usb_kill_urb(urb);
|
||||
}
|
||||
int rtw_usb_submit_urb(struct urb *urb, int mem_flags)
|
||||
{
|
||||
// return usb_submit_urb(urb, mem_flags);
|
||||
return usb_submit_urb(urb); //xhl
|
||||
}
|
||||
void rtw_usb_fill_bulk_urb(struct urb *urb,struct usb_device *pDev,u32 Pipe,void *pTransferBuffer,s32 Length,usb_complete_t tCompleteFunc,void *pContext)
|
||||
{
|
||||
usb_fill_bulk_urb(urb,pDev, Pipe,pTransferBuffer,Length, tCompleteFunc,pContext);
|
||||
}
|
||||
int rtw_usb_register(struct usb_driver *driver)
|
||||
{
|
||||
return usb_register_driver(driver);
|
||||
}
|
||||
void rtw_usb_deregister(struct usb_driver *driver)
|
||||
{
|
||||
usb_deregister(driver);
|
||||
}
|
||||
|
||||
int usbctrl_vendorreq(void *priv,unsigned char bdir_in,unsigned short value,unsigned char *buf,unsigned int len)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
unsigned char request = 0x05;
|
||||
unsigned int pipe;
|
||||
int status = 0;
|
||||
unsigned char reqtype;
|
||||
unsigned char *pIo_buf;
|
||||
int vendorreq_times = 0;
|
||||
|
||||
unsigned char tmp_buf[MAX_USB_IO_CTL_SIZE];
|
||||
|
||||
/* Acquire IO memory for vendorreq */
|
||||
|
||||
if (len > MAX_VENDOR_REQ_CMD_SIZE) {
|
||||
printf("[%s] Buffer len error ,vendor request failed\n", __FUNCTION__);
|
||||
status = -22;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Added by Albert 2010/02/09 */
|
||||
/* For mstar platform, mstar suggests the address for USB IO should be 32 bytes alignment. */
|
||||
/* Trying to fix it here. */
|
||||
pIo_buf = tmp_buf + ALIGNMENT_UNIT - ((unsigned int)(tmp_buf) & 0x1f);//32字节对齐
|
||||
|
||||
while (++vendorreq_times <= 10) {
|
||||
rtw_memset(pIo_buf, 0, len);
|
||||
|
||||
if (bdir_in == 0x01) {
|
||||
pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
|
||||
reqtype = REALTEK_USB_VENQT_READ;
|
||||
} else {
|
||||
pipe = usb_sndctrlpipe(udev, 0);/* write_out */
|
||||
reqtype = REALTEK_USB_VENQT_WRITE;
|
||||
rtw_memcpy(pIo_buf, buf, len);
|
||||
}
|
||||
status = usb_control_msg(udev, pipe, request, reqtype, value, 0, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
|
||||
|
||||
if (status == len) { /* Success this control transfer. */
|
||||
if (bdir_in == 0x01) {
|
||||
/* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */
|
||||
rtw_memcpy(buf, pIo_buf, len);
|
||||
}
|
||||
} else { /* error cases */
|
||||
printf("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n"
|
||||
, value, (bdir_in == 0x01) ? "read" : "write" , len, status, *(u32 *)buf, vendorreq_times);
|
||||
}
|
||||
/* firmware download is checksumed, don't retry */
|
||||
if ((value >= FW_START_ADDRESS) || status == len)
|
||||
break;
|
||||
}
|
||||
exit:
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
extern void usb_read_port_complete(void *arg, unsigned int result);
|
||||
static int rtw_usb_read_complete(struct urb* purb)
|
||||
{
|
||||
int i =0;
|
||||
usb_read_port_complete(purb->context, purb->actual_length);
|
||||
if (purb->status != 0){
|
||||
printf("\r\n###=> rtw_usb_read_port_complete => urb.status(%d)\n", purb->status);
|
||||
}
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(&(rtw_urb_read[i].urb) == purb){
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_read[i].urb));
|
||||
rtw_urb_read[i].is_used = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i ==MaxurbNum ){
|
||||
printf("\r\n Error: some urb pointer we want read have not recored!");
|
||||
}
|
||||
usb_free_urb(purb);
|
||||
return purb->status;
|
||||
}
|
||||
|
||||
static int rtw_usb_bulk_in(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete_t callback,void *arg){
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
int status;
|
||||
int i = 0;
|
||||
struct urb *purb;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(!(rtw_urb_read[i].is_used)){
|
||||
rtw_urb_read[i].is_used = 1; //set the used to 1 first then use it
|
||||
purb = &rtw_urb_read[i].urb;
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_read[i].urb));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == MaxurbNum)
|
||||
printf("\r\n Error: something error in urb allocate in %s",__func__);
|
||||
|
||||
usb_fill_bulk_urb(purb,
|
||||
udev,
|
||||
pipe,
|
||||
buf,
|
||||
len,
|
||||
rtw_usb_read_complete,
|
||||
arg);
|
||||
status = usb_submit_urb(purb);
|
||||
return status;
|
||||
}
|
||||
|
||||
extern void usb_write_port_complete(void *arg, unsigned int result);
|
||||
static int rtw_usb_write_complete(struct urb* purb)
|
||||
{
|
||||
int i = 0;
|
||||
if (purb->status == 0){
|
||||
usb_write_port_complete(purb->context, purb->actual_length);
|
||||
}else{
|
||||
printf("\r\n###=> rtw_usb_write_port_complete => urb.status(%d)\n", purb->status);
|
||||
}
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(&(rtw_urb_write[i].urb) == purb){
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_write[i].urb));
|
||||
rtw_urb_write[i].is_used = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i ==MaxurbNum ){
|
||||
printf("\r\n Error: some urb pointer we want write have not recored!");
|
||||
}
|
||||
usb_free_urb(purb);
|
||||
return purb->status;
|
||||
}
|
||||
|
||||
static int rtw_usb_bulk_out(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete callback,void *arg){
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *udev = pusb_intf->usb_dev;
|
||||
int status;
|
||||
int i = 0;
|
||||
struct urb *purb;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(!(rtw_urb_write[i].is_used)){
|
||||
rtw_urb_write[i].is_used = 1; //set the used to 1 first then use it
|
||||
purb = &(rtw_urb_write[i].urb);
|
||||
rtw_memset(purb, 0, sizeof(rtw_urb_write[i].urb));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == MaxurbNum)
|
||||
printf("\r\n Error: something error in urb allocate in %s",__func__);
|
||||
usb_fill_bulk_urb(purb,
|
||||
udev,
|
||||
pipe,
|
||||
buf,
|
||||
len,
|
||||
rtw_usb_write_complete,
|
||||
arg);
|
||||
status = usb_submit_urb(purb);
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
static int rtw_usb_cancel_bulk_out(void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
int i = 0;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(rtw_urb_write[i].is_used){
|
||||
usb_kill_urb(&(rtw_urb_write[i].urb));
|
||||
rtw_memset(&(rtw_urb_write[i].urb), 0, sizeof(rtw_urb_write[i].urb));
|
||||
rtw_urb_write[i].is_used = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_usb_cancel_bulk_in(void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
int i = 0;
|
||||
for(;i<MaxurbNum;i++){
|
||||
if(rtw_urb_read[i].is_used){
|
||||
usb_kill_urb(&(rtw_urb_read[i].urb));
|
||||
rtw_memset(&(rtw_urb_read[i].urb), 0, sizeof(rtw_urb_read[i].urb));
|
||||
rtw_urb_read[i].is_used = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtw_usb_ctrl_req(void *priv,unsigned char bdir_in,unsigned short wvalue,unsigned char *buf,unsigned int len)
|
||||
{
|
||||
return usbctrl_vendorreq(priv,bdir_in,wvalue,buf,len);
|
||||
}
|
||||
|
||||
enum RTW_USB_SPEED {
|
||||
RTW_USB_SPEED_UNKNOWN = 0,
|
||||
RTW_USB_SPEED_1_1 = 1,
|
||||
RTW_USB_SPEED_2 = 2,
|
||||
RTW_USB_SPEED_3 = 3,
|
||||
};
|
||||
|
||||
static inline int RT_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK;
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_out(epd);
|
||||
}
|
||||
|
||||
static inline u8 RT_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return RT_usb_endpoint_xfer_int(epd) && RT_usb_endpoint_dir_in(epd);
|
||||
}
|
||||
|
||||
static inline u8 RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
|
||||
{
|
||||
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
||||
}
|
||||
|
||||
|
||||
void rtw_usb_disendpoint(u8 nr_endpoint,void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *pusbd = pusb_intf->usb_dev;
|
||||
struct usb_host_interface *phost_iface;
|
||||
struct usb_host_endpoint *phost_endp;
|
||||
int i;
|
||||
phost_iface = &pusb_intf->altsetting[0];
|
||||
for (i = 0; i < nr_endpoint; i++) {
|
||||
phost_endp = phost_iface->endpoint + i;
|
||||
if (phost_endp) {
|
||||
usb_hcd_disable_endpoint(pusbd, phost_endp);
|
||||
}
|
||||
}
|
||||
pusb_intf->user_data = NULL;
|
||||
}
|
||||
|
||||
|
||||
static int rtw_usb_get_speed_info(void *priv)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_device *pusbd;
|
||||
pusbd = pusb_intf->usb_dev;
|
||||
int speed;
|
||||
switch (pusbd->speed) {
|
||||
case 1:
|
||||
printf("Low Speed Case \n");
|
||||
(speed) = RTW_USB_SPEED_1_1;
|
||||
break;
|
||||
case 2:
|
||||
printf("full speed Case \n");
|
||||
(speed) = RTW_USB_SPEED_1_1;
|
||||
break;
|
||||
case 3:
|
||||
printf("high speed Case \n");
|
||||
(speed) = RTW_USB_SPEED_2;
|
||||
break;
|
||||
default:
|
||||
(speed) = RTW_USB_SPEED_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
if ((speed) == RTW_USB_SPEED_UNKNOWN)
|
||||
pusb_intf->user_data = NULL;
|
||||
return speed;
|
||||
}
|
||||
|
||||
static int rtw_usb_get_in_ep_info(void *priv,unsigned char *pipe_num_arrays)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_host_endpoint *phost_endp;
|
||||
struct usb_endpoint_descriptor *pendp_desc;
|
||||
struct usb_host_interface *phost_iface;
|
||||
struct usb_interface_descriptor *piface_desc;
|
||||
int NumInPipes = 0;
|
||||
int nr_endpoint;
|
||||
int i;
|
||||
phost_iface = &pusb_intf->cur_altsetting[0];
|
||||
piface_desc = &phost_iface->desc;
|
||||
nr_endpoint = piface_desc->bNumEndpoints;
|
||||
for (i = 0; i < (nr_endpoint); i++) {
|
||||
phost_endp = phost_iface->endpoint + i;
|
||||
if (phost_endp) {
|
||||
pendp_desc = &phost_endp->desc;
|
||||
printf("\nusb_endpoint_descriptor(%d):\n", i);
|
||||
printf("bLength=%x\n", pendp_desc->bLength);
|
||||
printf("bDescriptorType=%x\n", pendp_desc->bDescriptorType);
|
||||
printf("bEndpointAddress=%x\n", pendp_desc->bEndpointAddress);
|
||||
printf("wMaxPacketSize=%d\n", pendp_desc->wMaxPacketSize);
|
||||
printf("bInterval=%x\n", pendp_desc->bInterval);
|
||||
if (RT_usb_endpoint_is_bulk_in(pendp_desc)) {
|
||||
pipe_num_arrays[NumInPipes] = RT_usb_endpoint_num(pendp_desc);
|
||||
(NumInPipes)++;
|
||||
} else if (RT_usb_endpoint_is_int_in(pendp_desc)) {
|
||||
printf("\r\n RT_usb_endpoint_is_int_in = %x, Interval = %x", RT_usb_endpoint_num(pendp_desc), pendp_desc->bInterval);
|
||||
pipe_num_arrays[NumInPipes] = RT_usb_endpoint_num(pendp_desc);
|
||||
(NumInPipes)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NumInPipes;
|
||||
}
|
||||
static int rtw_usb_get_out_ep_info(void *priv,u8 *pipe_num_array)
|
||||
{
|
||||
struct usb_interface *pusb_intf = (struct usb_interface *)priv;
|
||||
struct usb_host_endpoint *phost_endp;
|
||||
struct usb_endpoint_descriptor *pendp_desc;
|
||||
struct usb_host_interface *phost_iface;
|
||||
struct usb_interface_descriptor *piface_desc;
|
||||
int NumOutPipes = 0;
|
||||
int nr_endpoint;
|
||||
int i;
|
||||
phost_iface = &pusb_intf->cur_altsetting[0];
|
||||
piface_desc = &phost_iface->desc;
|
||||
nr_endpoint = piface_desc->bNumEndpoints;
|
||||
for (i = 0; i < (nr_endpoint); i++) {
|
||||
phost_endp = phost_iface->endpoint + i;
|
||||
if (phost_endp) {
|
||||
pendp_desc = &phost_endp->desc;
|
||||
if (RT_usb_endpoint_is_bulk_out(pendp_desc)) {
|
||||
printf("\r\n RT_usb_endpoint_is_bulk_out = %x\n", RT_usb_endpoint_num(pendp_desc));
|
||||
pipe_num_array[NumOutPipes] = RT_usb_endpoint_num(pendp_desc);
|
||||
(NumOutPipes)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NumOutPipes;
|
||||
}
|
||||
|
||||
|
||||
extern USB_BUS_OPS rtw_usb_bus_ops= {
|
||||
rtw_usb_register,
|
||||
rtw_usb_deregister,
|
||||
rtw_usb_disendpoint,
|
||||
rtw_usb_ctrl_req,
|
||||
rtw_usb_get_speed_info,
|
||||
rtw_usb_get_in_ep_info,
|
||||
rtw_usb_get_out_ep_info,
|
||||
rtw_usb_get_bulk_in_pipe,
|
||||
rtw_usb_get_bulk_out_pipe,
|
||||
rtw_usb_bulk_in,
|
||||
rtw_usb_bulk_out,
|
||||
rtw_usb_cancel_bulk_in,
|
||||
rtw_usb_cancel_bulk_out,
|
||||
};
|
||||
|
31
lib/wlan/rtl8821cs/platform/usb/usb_io_realtek.h
Normal file
31
lib/wlan/rtl8821cs/platform/usb/usb_io_realtek.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef _USB_IO_REALTEK_H
|
||||
#define _USB_IO_REALTEK_H
|
||||
|
||||
#include "customer_rtos_service.h"
|
||||
|
||||
#include <usb.h>
|
||||
typedef struct USB_DATA_S{
|
||||
void *usb_intf;
|
||||
}USB_DATA,*PUSB_DATA;
|
||||
typedef void (*usb_complete)(void *arg, unsigned int result);
|
||||
|
||||
|
||||
typedef struct _USB_BUS_OPS{
|
||||
int (*register_drv)(struct usb_driver *driver);
|
||||
void (*deregister_drv)(struct usb_driver *driver);
|
||||
void (*usb_disendpoint)(u8 nr_endpoint,void *priv);
|
||||
int (*usb_ctrl_req)(void *priv,unsigned char bdir_in,unsigned short wvalue,unsigned char *buf,unsigned int len);
|
||||
int (*usb_get_speed_info)(void *priv);
|
||||
int (*usb_get_in_ep_info)(void *priv,unsigned char *pipe_num_array);
|
||||
int (*usb_get_out_ep_info)(void *priv,unsigned char *pipe_num_array);
|
||||
unsigned char(*usb_get_bulk_in_pipe)(void *priv,unsigned char ep_addr);
|
||||
unsigned char(*usb_get_bulk_out_pipe)(void *priv,unsigned char ep_addr);
|
||||
int (*usb_bulk_in)(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete callback,void *arg);
|
||||
int (*usb_bulk_out)(void *priv,unsigned char pipe,unsigned char *buf,unsigned int len,usb_complete callback,void *arg);
|
||||
int (*usb_cancel_bulk_in)(void *priv);
|
||||
int (*usb_cancel_bulk_out)(void *priv);
|
||||
}USB_BUS_OPS;
|
||||
|
||||
|
||||
extern USB_BUS_OPS rtw_usb_bus_ops;
|
||||
#endif
|
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.0.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.0.a
Normal file
Binary file not shown.
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.1.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.1.a
Normal file
Binary file not shown.
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.2.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.2.a
Normal file
Binary file not shown.
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.3.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.3.a
Normal file
Binary file not shown.
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.5.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.5.a
Normal file
Binary file not shown.
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.6.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.6.a
Normal file
Binary file not shown.
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.8.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v1.8.a
Normal file
Binary file not shown.
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v2.1.a
Normal file
BIN
lib/wlan/rtl8821cs/wlan_lib/wlan_lib_v2.1.a
Normal file
Binary file not shown.
Reference in New Issue
Block a user