chore: sdk compiles almost w/o warnings?

This commit is contained in:
2024-12-17 03:13:08 +06:00
parent 31efbc726f
commit 7c7b36a6b3
55 changed files with 658 additions and 514 deletions

View File

@@ -3,6 +3,7 @@
#include "lwip/memp.h"
#include "lwip/dhcp.h"
#include "lwip/dns.h"
#include "lwip/tcp.h"
#include "ethernetif.h"
#include "main.h"
#include "lwip_netconf.h"
@@ -18,6 +19,7 @@
#include "stm324xg_eval_lcd.h"
#endif
#include <platform/platform_stdlib.h>
#include <osdep_service.h>
#if defined(CONFIG_FAST_DHCP) && CONFIG_FAST_DHCP
#include "wlan_fast_connect/example_wlan_fast_connect.h"

View File

@@ -3,66 +3,65 @@
#include <autoconf.h>
#define CONFIG_WLAN 1
#include "FreeRTOSConfig.h"
#define CONFIG_WLAN 1
/* Header file declaration*/
void wlan_network();
/* Interactive Mode */
#define SERIAL_DEBUG_RX 1
#if defined(__ICCARM__)
static
static
#endif
char uart_buf[64];
/* WLAN and Netork */
#define STA_MODE_SSID "ap" /* Set SSID here */
#define AP_MODE_SSID "wlan_ap_ssid" /* Set SSID here */
#define AP_DEFAULT_CH 6
#define WLAN0_NAME "wlan0"
#define WLAN1_NAME "wlan1"
#define WPA_PASSPHRASE "1234567890" /* Max 32 cahracters */
#define WEP40_KEY {0x12, 0x34, 0x56, 0x78, 0x90}
#define STA_MODE_SSID "ap" /* Set SSID here */
#define AP_MODE_SSID "wlan_ap_ssid" /* Set SSID here */
#define AP_DEFAULT_CH 6
#define WLAN0_NAME "wlan0"
#define WLAN1_NAME "wlan1"
#define WPA_PASSPHRASE "1234567890" /* Max 32 cahracters */
#define WEP40_KEY {0x12, 0x34, 0x56, 0x78, 0x90}
/*Static IP ADDRESS*/
#define IP_ADDR0 192
#define IP_ADDR1 168
#define IP_ADDR2 1
#define IP_ADDR3 80
#define IP_ADDR0 192
#define IP_ADDR1 168
#define IP_ADDR2 1
#define IP_ADDR3 80
/*NETMASK*/
#define NETMASK_ADDR0 255
#define NETMASK_ADDR1 255
#define NETMASK_ADDR2 255
#define NETMASK_ADDR3 0
#define NETMASK_ADDR0 255
#define NETMASK_ADDR1 255
#define NETMASK_ADDR2 255
#define NETMASK_ADDR3 0
/*Gateway Address*/
#define GW_ADDR0 192
#define GW_ADDR1 168
#define GW_ADDR2 1
#define GW_ADDR3 1
#define GW_ADDR0 192
#define GW_ADDR1 168
#define GW_ADDR2 1
#define GW_ADDR3 1
/*******************************************/
/*Static IP ADDRESS*/
#define AP_IP_ADDR0 192
#define AP_IP_ADDR1 168
#define AP_IP_ADDR2 43
#define AP_IP_ADDR3 1
#define AP_IP_ADDR0 192
#define AP_IP_ADDR1 168
#define AP_IP_ADDR2 43
#define AP_IP_ADDR3 1
/*NETMASK*/
#define AP_NETMASK_ADDR0 255
#define AP_NETMASK_ADDR1 255
#define AP_NETMASK_ADDR2 255
#define AP_NETMASK_ADDR3 0
#define AP_NETMASK_ADDR0 255
#define AP_NETMASK_ADDR1 255
#define AP_NETMASK_ADDR2 255
#define AP_NETMASK_ADDR3 0
/*Gateway Address*/
#define AP_GW_ADDR0 192
#define AP_GW_ADDR1 168
#define AP_GW_ADDR2 43
#define AP_GW_ADDR3 1
#define AP_GW_ADDR0 192
#define AP_GW_ADDR1 168
#define AP_GW_ADDR2 43
#define AP_GW_ADDR3 1
#endif

View File

@@ -166,6 +166,7 @@ extern void vPortFree( void *pv );
#include "strproc.h"
#include "memproc.h"
#include "basic_types.h"
#include "rand.h"
#if USE_RTL_ROM_CLIB
#include "rtl_lib.h"
#include "rom_libc_string.h"
@@ -200,10 +201,10 @@ extern void vPortFree( void *pv );
#define printf buffered_printf
#else
#define printf rtl_printf
#endif
#define sprintf rtl_sprintf
#define snprintf rtl_snprintf
#define vsnprintf rtl_vsnprintf
#endif
#else
#define printf DiagPrintf
#define sprintf(fmt, arg...) DiagSPrintf((u8*)fmt, ##arg)
@@ -233,7 +234,9 @@ extern void vPortFree( void *pv );
#define atoi(str) prvAtoi(str)
#define strpbrk(cs, ct) _strpbrk(cs, ct) // for B-cut ROM
#if defined (__GNUC__)
#undef sscanf
// #undef sscanf
// #define sscanf _sscanf_patch
extern int _sscanf_patch(const char *s, const char *template, ...);
#define sscanf _sscanf_patch
#define rand Rand
#endif

View File

@@ -9,6 +9,7 @@
#include "utils/includes.h"
#include "utils/common.h"
#include "tls.h"
#include "wifi_eap_config.h"
#define DEBUG_LEVEL 0 // For debug: 5

View File

@@ -78,14 +78,14 @@ void judge_station_disconnect(void)
}
}
void eap_disconnected_hdl(char *buf, int buf_len, int flags, void* handler_user_data){
// printf("disconnected\n");
wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl);
wifi_unreg_event_handler(WIFI_EVENT_DISCONNECT, eap_disconnected_hdl);
eap_peer_unregister_methods();
eap_sm_deinit();
//reset_config();
}
// void eap_disconnected_hdl(char *buf, int buf_len, int flags, void* handler_user_data){
// // printf("disconnected\n");
// wifi_unreg_event_handler(WIFI_EVENT_EAPOL_RECVD, eap_eapol_recvd_hdl);
// wifi_unreg_event_handler(WIFI_EVENT_DISCONNECT, eap_disconnected_hdl);
// eap_peer_unregister_methods();
// eap_sm_deinit();
// //reset_config();
// }
/*
void eap_config(void){

View File

@@ -0,0 +1,69 @@
#ifndef __WIFI_EAP_CONFIG_H
#define __WIFI_EAP_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "basic_types.h"
// Function declarations
/**
* @brief Set the EAP phase flag
* @param is_trigger_eap Flag value to set
*/
void set_eap_phase(unsigned char is_trigger_eap);
/**
* @brief Get the current EAP phase
* @return Current EAP phase value
*/
int get_eap_phase(void);
/**
* @brief Get the current EAP method
* @return Current EAP method value
*/
int get_eap_method(void);
/**
* @brief Reset all EAP configuration parameters to NULL
*/
void reset_config(void);
/**
* @brief Start the EAP authentication process
* @param method The EAP method to use ("peap", "tls", or "ttls")
* @return 0 on success, -1 on failure
*/
int eap_start(char *method);
/**
* @brief Handle auto-reconnection for EAP
* @param method_id The EAP method ID to use for reconnection
*/
void eap_autoreconnect_hdl(u8 method_id);
/**
* @brief Initialize EAP certificates
* @return 0 on success, -1 on failure
*/
int eap_cert_init(void);
/**
* @brief Free client certificate resources
*/
void eap_client_cert_free(void);
/**
* @brief Free server certificate resources
*/
void eap_server_cert_free(void);
#ifdef __cplusplus
}
#endif
#endif /* __WIFI_EAP_CONFIG_H */

View File

@@ -13,6 +13,8 @@
#include "tcpip.h"
#include <osdep_service.h>
#include <device_lock.h>
#include "wifi_promisc.h"
// #include "dhcp.h"
#if CONFIG_EXAMPLE_WLAN_FAST_CONNECT || CONFIG_JD_SMART
#include "wlan_fast_connect/example_wlan_fast_connect.h"
@@ -67,7 +69,7 @@ static unsigned char ap_bssid[6];
#if CONFIG_WIFI_IND_USE_THREAD
static void* disconnect_sema = NULL;
#endif
extern rtw_mode_t wifi_mode;
rtw_mode_t wifi_mode = RTW_MODE_STA;
static rtw_wpa_mode wifi_wpa_mode = WPA_AUTO_MODE;
int error_flag = RTW_UNKNOWN;
@@ -460,7 +462,7 @@ static void wifi_handshake_done_hdl( char* buf, int buf_len, int flags, void* us
if(join_user_data != NULL)
rtw_up_sema(&join_user_data->join_sema);
}
extern void dhcp_stop(struct netif *netif);
static void wifi_disconn_hdl( char* buf, int buf_len, int flags, void* userdata)
{
#define REASON_4WAY_HNDSHK_TIMEOUT 15
@@ -871,7 +873,7 @@ int wifi_connect(
error:
if(semaphore == NULL){
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
}
join_user_data = NULL;
rtw_free((u8*)join_result);
@@ -1021,11 +1023,11 @@ int wifi_connect_bssid(
rtw_free(join_result->network_info.password);
}
rtw_free((u8*)join_result);
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
result = RTW_TIMEOUT;
goto error;
} else {
rtw_free_sema( &join_semaphore );
rtw_free_sema((_sema*)&join_semaphore);
if(join_result->network_info.password_len) {
rtw_free(join_result->network_info.password);
}
@@ -1283,7 +1285,7 @@ int wifi_connect_concurrent(
error:
if(semaphore == NULL){
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
}
join_user_data = NULL;
rtw_free((u8*)join_result);
@@ -1433,11 +1435,11 @@ int wifi_connect_bssid_concurrent(
rtw_free(join_result->network_info.password);
}
rtw_free((u8*)join_result);
rtw_free_sema( &join_semaphore);
rtw_free_sema((_sema*)&join_semaphore);
result = RTW_TIMEOUT;
goto error;
} else {
rtw_free_sema( &join_semaphore );
rtw_free_sema((_sema*)&join_semaphore);
if(join_result->network_info.password_len) {
rtw_free(join_result->network_info.password);
}
@@ -1681,6 +1683,7 @@ int wifi_get_channel_plan(uint8_t *channel_plan)
}
//----------------------------------------------------------------------------//
extern int rltk_wlan_get_sta_max_data_rate(u8 *inidata_rate);
int wifi_get_sta_max_data_rate(OUT u8 * inidata_rate)
{
return rltk_wlan_get_sta_max_data_rate(inidata_rate);
@@ -1995,7 +1998,7 @@ int wifi_set_power_mode(unsigned char ips_mode, unsigned char lps_mode)
int wifi_set_powersave_level(u8 level)
{
return rltk_set_lps_level(level);
// return rltk_set_lps_level(level);
}
int wifi_set_tdma_param(unsigned char slot_period, unsigned char rfon_period_len_1, unsigned char rfon_period_len_2, unsigned char rfon_period_len_3)
@@ -2017,7 +2020,7 @@ static void wifi_ap_sta_assoc_hdl( char* buf, int buf_len, int flags, void* user
{
#ifdef CONFIG_PLATFORM_8711B
if(enable_softap_adjust_phy){
softap_adjust_phy();
// softap_adjust_phy();
}
#endif
//USER TODO
@@ -2056,6 +2059,7 @@ int wifi_set_pmk_cache_enable(unsigned char value)
}
#endif
extern int set_hidden_ssid(const char *ifname, uint8_t value);
int wifi_start_ap(
char *ssid,
rtw_security_t security_type,
@@ -2154,7 +2158,7 @@ int wifi_start_ap(
// for adjust/recover phy parameters before/after link on softap mode
#ifdef CONFIG_PLATFORM_8711B
if(enable_softap_adjust_phy){
softap_adjust_phy();
// softap_adjust_phy();
}
#endif
@@ -2523,7 +2527,7 @@ int wifi_scan_networks_with_ssid_by_extended_security(int (results_handler)(char
return RTW_NOMEM;
}
rltk_wlan_enable_scan_with_ssid_by_extended_security(1);
// rltk_wlan_enable_scan_with_ssid_by_extended_security(1);
//set ssid
memset(scan_buf.buf, 0, scan_buf.buf_len);
@@ -2934,7 +2938,7 @@ int wifi_get_setting(const char *ifname, rtw_wifi_setting_t *pSetting)
int ret = 0;
int mode = 0;
unsigned short security = 0;
unsigned int auth_type = 0;
u32 auth_type = 0;
memset(pSetting, 0, sizeof(rtw_wifi_setting_t));
if(wext_get_mode(ifname, &mode) < 0)

View File

@@ -1,8 +1,8 @@
#include "FreeRTOS.h"
#include "wifi_promisc.h"
#include "task.h"
#include "main.h"
#include "tcpip.h"
#include "wifi/wifi_conf.h"
#ifndef CONFIG_WLAN
#define CONFIG_WLAN 1
@@ -11,6 +11,19 @@
#if CONFIG_WLAN
#include <platform/platform_stdlib.h>
#ifdef CONFIG_PROMISC
#define _adapter void
#define recv_frame void
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);
#endif
// Add extra interfaces to make release sdk able to determine promisc API linking
void promisc_deinit(void *padapter)
{
@@ -132,7 +145,6 @@ struct inic_eth_frame {
static struct inic_eth_frame *inic_frame, *inic_frame_tail = NULL;
static int inic_frame_cnt = 0;
#define MAX_INIC_FRAME_NUM 50 //maximum packets for each channel
extern void inic_c2h_msg(const char *atcmd, char status, char *msg, u16 msg_len);
#endif
@@ -144,8 +156,6 @@ struct eth_buffer {
static struct eth_buffer eth_buffer;
#ifdef 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;

View File

@@ -0,0 +1,53 @@
#ifndef WIFI_PROMISC_H
#define WIFI_PROMISC_H
#include <platform/platform_stdlib.h>
#include "FreeRTOS.h"
#include "wifi/wifi_conf.h"
#ifdef __cplusplus
extern "C" {
#endif
// Promisc mode function declarations
void promisc_deinit(void *padapter);
int promisc_recv_func(void *padapter, void *rframe);
int promisc_recv_lens_func(void *padapter, u8 *payload, u8 plen);
int promisc_filter_retransmit_pkt(u8 enable, u8 filter_interval_ms);
int promisc_filter_with_len(u16 len);
int promisc_set(rtw_rcr_level_t enabled,
void (*callback)(unsigned char *, unsigned int, void *),
unsigned char len_used);
unsigned char is_promisc_enabled(void);
int promisc_get_fixed_channel(void *fixed_bssid, u8 *ssid, int *ssid_length);
void promisc_filter_by_ap_and_phone_mac(u8 enable, void *ap_mac,
void *phone_mac);
// Packet filter functions
#ifdef CONFIG_PROMISC
void promisc_init_packet_filter(void);
int promisc_add_packet_filter(u8 filter_id, rtw_packet_filter_pattern_t *patt,
rtw_packet_filter_rule_t rule);
int promisc_enable_packet_filter(u8 filter_id);
int promisc_disable_packet_filter(u8 filter_id);
int promisc_remove_packet_filter(u8 filter_id);
#endif
// Command function
void cmd_promisc(int argc, char **argv);
// Constants
#define MAX_PACKET_FILTER_INFO 5
#define FILTER_ID_INIT_VALUE 10
#ifdef CONFIG_INIC_CMD_RSP
// maximum packets for each channel
#define MAX_INIC_FRAME_NUM 50
#endif
#ifdef __cplusplus
}
#endif
#endif /* WIFI_PROMISC_H */

View File

@@ -13,6 +13,7 @@
#include "wifi_simple_config.h"
#include "wifi_conf.h"
#include "wifi_util.h"
#include "wifi_promisc.h"
#if CONFIG_EXAMPLE_UART_ATCMD || CONFIG_EXAMPLE_SPI_ATCMD
#include "at_cmd/atcmd_wifi.h"
@@ -97,7 +98,7 @@ struct ack_msg {
PACK_STRUCT_FIELD(u16_t device_type);
PACK_STRUCT_FIELD(u32_t device_ip);
PACK_STRUCT_FIELD(u8_t device_name[64]);
};PACK_STRUCT_STRUCT;
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
#include "arch/epstruct.h"
@@ -299,7 +300,7 @@ int SC_send_simple_config_ack(u8 round)
}
#endif
printf("\nSending simple config ack\n");
FD_ZERO(&to_addr);
memset(&to_addr, 0, sizeof(struct sockaddr_in));
to_addr.sin_family = AF_INET;
to_addr.sin_port = htons(8864);
to_addr.sin_addr.s_addr = (backup_sc_ctx->ip_addr);
@@ -1022,19 +1023,19 @@ extern void rtk_sc_deinit(void);
void init_simple_config_lib_config(struct simple_config_lib_config* config)
{
config->free = rtw_mfree;
config->malloc = rtw_malloc;
config->memcmp = _memcmp;
config->memcpy = _memcpy;
config->memset = _memset;
config->free = (simple_config_free_fn)rtw_mfree;
config->malloc = (simple_config_malloc_fn)rtw_malloc;
config->memcmp = (simple_config_memcmp_fn)_memcmp;
config->memcpy = (simple_config_memcpy_fn)_memcpy;
config->memset = (simple_config_memset_fn)_memset;
config->printf = (simple_config_printf_fn)printf;
config->strcpy = _strcpy;
config->strlen = _strlen;
config->zmalloc = rtw_zmalloc;
config->strcpy = (simple_config_strcpy_fn)_strcpy;
config->strlen = (simple_config_strlen_fn)_strlen;
config->zmalloc = (simple_config_zmalloc_fn)rtw_zmalloc;
#if CONFIG_LWIP_LAYER
config->_ntohl = lwip_ntohl;
config->_ntohl = (simple_config_ntohl_fn)lwip_ntohl;
#else
config->_ntohl = _ntohl;
config->_ntohl = (simple_config_ntohl_fn)_ntohl;
#endif
config->is_promisc_callback_unlock = &is_promisc_callback_unlock;
}
@@ -1342,6 +1343,8 @@ static void init_promisc_scan_channel(unsigned char softAP_ch)
return;
}
extern void dhcps_deinit(void);
extern void dhcps_init(struct netif * pnetif);
static int SimpleConfig_softAP_start(const char* ap_name, const char *ap_password)
{
int timeout = 20;

View File

@@ -1400,6 +1400,7 @@ void wext_set_low_power_mode(__u8 enable)
}
#endif
extern int rltk_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned char channel_num);
int wext_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned char channel_num)
{
int ret = -1;
@@ -1411,11 +1412,13 @@ int wext_get_auto_chl(const char *ifname, unsigned char *channel_set, unsigned c
return ret;
}
extern int rltk_set_sta_num(unsigned char ap_sta_num);
int wext_set_sta_num(unsigned char ap_sta_num)
{
return rltk_set_sta_num(ap_sta_num);
}
extern int rltk_del_station(const char *ifname, unsigned char* hwaddr);
int wext_del_station(const char *ifname, unsigned char* hwaddr)
{
return rltk_del_station(ifname, hwaddr);
@@ -1506,13 +1509,15 @@ void wext_set_indicate_mgnt(int enable)
void wext_set_sigstat_fast_enable(int enable)
{
rtw_set_sigstat_fast_enable(enable);
// TODO: doesn't exist in lib_wlan
// rtw_set_sigstat_fast_enable(enable);
return;
}
void wext_set_lowrssi_use_b(int enable,int rssi)
{
rtw_set_lowrssi_use_b(enable,rssi);
// TODO: doesn't exist in lib_wlan
// rtw_set_lowrssi_use_b(enable,rssi);
return ;
}
#ifdef CONFIG_AP_MODE
@@ -1533,14 +1538,17 @@ void wext_suspend_softap_beacon(const char *ifname)
}
void wext_resume_softap(const char *ifname)
{
rltk_resume_softap(ifname);
// TODO: doesn't exist in lib_wlan
// rltk_resume_softap(ifname);
}
// extern int rtw_ap_switch_chl_and_inform(unsigned char new_channel);
int wext_ap_switch_chl_and_inform(unsigned char new_channel)
{
if(rtw_ap_switch_chl_and_inform(new_channel))
// TODO: doesn't exist in lib_wlan
// if(rtw_ap_switch_chl_and_inform(new_channel))
return RTW_SUCCESS;
else
return RTW_ERROR;
// else
// return RTW_ERROR;
}
#endif

View File

@@ -84,7 +84,15 @@ int wext_del_custom_ie(const char *ifname);
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);
void wext_set_sigstat_fast_enable(int enable);
void wext_stop_softap(const char *ifname);
void wext_suspend_softap(const char *ifname);
void wext_suspend_softap_beacon(const char *ifname);
void wext_resume_softap(const char *ifname);
int wext_ap_switch_chl_and_inform(unsigned char new_channel);
int wext_get_nhm_ratio_level(const char *ifname, __u32 *level);
int wext_get_retry_drop_num(const char *ifname, rtw_fw_retry_drop_t * retry);
@@ -107,6 +115,9 @@ __u8 wext_get_adaptivity_enable(const char *ifname);
int wext_set_adaptivity_mode(const char *ifname, __u8 mode);
__u8 wext_get_adaptivity_mode(const char *ifname);
__u8 wext_get_channel_plan(const char *ifname);
int wext_get_bcn_rssi(const char *ifname, int *rssi);
#ifdef __cplusplus
}
#endif

View File

@@ -259,7 +259,7 @@ void ethernet_mii_init()
}
// why tho
void rltk_mii_recv(struct eth_drv_sg *sg_list, int sg_len){
struct eth_drv_sg *last_sg;
u8* pbuf = RX_BUFFER;
@@ -272,7 +272,7 @@ void rltk_mii_recv(struct eth_drv_sg *sg_list, int sg_len){
}
}
// also why
s8 rltk_mii_send(struct eth_drv_sg *sg_list, int sg_len, int total_len){
int ret =0;
struct eth_drv_sg *last_sg;

View File

@@ -11,4 +11,7 @@
typedef void (*link_up_down_callback)(int blinkup);
#endif // __MII_ETHERNETIF_H__
s8 rltk_mii_send(struct eth_drv_sg *sg_list, int sg_len, int total_len);
void rltk_mii_recv(struct eth_drv_sg *sg_list, int sg_len);
#endif // __MII_ETHERNETIF_H__

View File

@@ -1,6 +1,7 @@
#include "platform_opts.h"
#include "rtw_opt_crypto_ssl.h"
#include "osdep_service.h"
#include "ssl_ram_map.h"
#if CONFIG_USE_MBEDTLS
/****************************************************************************************************

View File

@@ -236,7 +236,7 @@ typedef unsigned char __u8;
typedef char __s8;
typedef unsigned short __u16;
typedef short __s16;
typedef unsigned int __u32;
typedef unsigned long __u32;
typedef int __s32;
typedef unsigned long long __u64;
typedef long long __i64;

View File

@@ -41,7 +41,7 @@ struct sk_buff {
// 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(void);
void rltk_wlan_deinit_fastly(void);
void rltk_wlan_deinit_hardware(void);
int rltk_wlan_start(int idx_wlan);
@@ -70,7 +70,9 @@ void rltk_wlan_tx_auth(void);
* Enum wlan low power mode
******************************************************/
#if defined(CONFIG_WLAN_LOW_PW)
#ifndef BIT
#define BIT(x) (1<<(x))
#endif
typedef enum {
PW_MODE_NONE = 0,
PW_MODE_1 = BIT(0), // CPU 31.25

View File

@@ -32,6 +32,8 @@
extern "C" {
#endif
extern void RTC_ClokSource(u32 Source);
/** @addtogroup rtc RTC
* @ingroup hal
* @brief rtc functions
@@ -47,10 +49,10 @@ extern "C" {
typedef void (*alarm_irq_handler)(void);
struct alarm_s {
uint32_t yday;//which day of the year
uint32_t hour;
uint32_t min;
uint32_t sec;
uint32_t sec; /* Seconds */
uint32_t min; /* Minutes */
uint32_t hour; /* Hours */
uint32_t yday; /* Day of year */
};
typedef struct alarm_s alarm_t;
@@ -123,6 +125,11 @@ void rtc_disable_alarm(void);
///@}
#endif //CONFIG_PLATFORM_8711B || CONFIG_PLATFORM_8195BLP || CONFIG_PLATFORM_8721D || CONFIG_PLATFORM_8710C
/**
* @brief Backup RTC time information before system reset
*/
void rtc_backup_timeinfo(void);
/*\@}*/
#ifdef __cplusplus

View File

@@ -1,14 +0,0 @@
/* mbed Microcontroller Library - CMSIS
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
*
* A generic CMSIS include header, pulling in RTL8195A specifics
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H
#include <platform/platform_stdlib.h>
#include <hal_platform.h>
#endif

View File

@@ -1,14 +0,0 @@
/* mbed Microcontroller Library - CMSIS
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
*
* A generic CMSIS include header, pulling in RTL8195A specifics
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H
#include <platform/platform_stdlib.h>
#include <hal_platform.h>
#endif

View File

@@ -66,8 +66,8 @@ void ADC_ReceiveBuf_ACUT(u32 *pBuf)
while (1) {
isr = ADC_GetISR();
if (isr & (BIT_ADC_FIFO_FULL | BIT_ADC_FIFO_RD_REQ)) {
*pBuf = (u32)ADC_Read_RAM();
*(pBuf+1)= (u32)ADC_Read_RAM();
*pBuf = (u32)ADC_Read();
*(pBuf+1)= (u32)ADC_Read();
ADC_INTClear();
ADC_INTConfig(BIT_ADC_FIFO_FULL_EN|BIT_ADC_FIFO_RD_REQ_EN, DISABLE);

View File

@@ -84,6 +84,8 @@ static u32 EFUSE_OTP_Check(u16 Addr, u8 Data)
* @brief Get remaining efuse length
* @retval remaining efuse length
*/
_LONG_CALL_ int EFUSE_RemainLength(void);
int efuse_get_remaining_length(void)
{
return EFUSE_RemainLength();
@@ -293,6 +295,21 @@ void efuse_rdp_keyset(u8 *rdp_key)
* @param SW_Key: key for encyption
* @note none
*/
_LONG_CALL_ int aes_init(void);
_LONG_CALL_ int aes_encrypt_key(
const unsigned char *key,
const int key_len,
aes_encrypt_ctx *ctx
);
_LONG_CALL_ int aes_ecb_encrypt(
const unsigned char *in,
unsigned char *out,
int length,
aes_encrypt_ctx *ctx
);
void efuse_rdp_check_image_encrypt(u8* SW_Key)
{
@@ -301,7 +318,7 @@ void efuse_rdp_check_image_encrypt(u8* SW_Key)
u8 * pByte;
pByte = (u8 *)&rdp_bin_checksum;
memset(&enc_ctx, 0, sizeof(enc_ctx));
_memset(&enc_ctx, 0, sizeof(enc_ctx));
/*calculate checksum using plaintext*/
for(i=0; i<4; i++) {
@@ -488,7 +505,7 @@ void efuse_otf_keyset(u8 *otf_key)
IMAGE2_RAM_TEXT_SECTION
void efuse_otf_check(uint32_t origin_data)
{
extern char set_key[40];
char set_key[40];
FLASH_Write_Lock();
uint32_t data = 0;
u8 otf_iv[16]={0x21, 0x32, 0x53, 0x64, 0x75, 0x86, 0xa7, 0xb8,

View File

@@ -46,7 +46,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
GPIO_InitStruct.GPIO_ITTrigger = GPIO_INT_Trigger_EDGE;
GPIO_InitStruct.GPIO_ITPolarity = GPIO_INT_POLARITY_ACTIVE_LOW;
InterruptRegister(GPIO_INTHandler, GPIO_IRQ, NULL, 10);
InterruptRegister(GPIO_INTHandler, GPIO_IRQ, 0, 10);
InterruptEn(GPIO_IRQ, 10);
GPIO_Init(&GPIO_InitStruct);

View File

@@ -99,7 +99,7 @@ void i2s_init(i2s_t *obj, PinName sck, PinName ws, PinName sd_tx, PinName sd_rx,
I2S_StructInit(&I2SInitStruct);
/*I2S Interrupt Initialization*/
InterruptRegister((IRQ_FUN) i2s_isr, I2S0_PCM0_IRQ, NULL, 3);
InterruptRegister((IRQ_FUN) i2s_isr, I2S0_PCM0_IRQ, 0, 3);
InterruptEn(I2S0_PCM0_IRQ, 3);
/* enable system pll */

View File

@@ -17,9 +17,6 @@
#include "rtc_api.h"
#include <time.h>
#include "timer_api.h"
static struct tm rtc_timeinfo;
static int rtc_en = 0;
static alarm_irq_handler rtc_alarm_handler;
@@ -158,6 +155,7 @@ void rtc_backup_timeinfo(void)
* @param none
* @retval none
*/
void rtc_init(void)
{
RTC_InitTypeDef RTC_InitStruct;

View File

@@ -15,6 +15,9 @@
*/
#include "wait_api.h"
#include "us_ticker_api.h"
#include "basic_types.h"
_LONG_CALL_ void DelayUs(u32 us);
void wait(float s)
{

View File

@@ -32,6 +32,8 @@
#ifndef __CPU_H__
#define __CPU_H__
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#endif /* __CPU_H__ */

View File

@@ -163,6 +163,9 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
return ERR_OK;
}
extern s8 rltk_mii_send(struct eth_drv_sg *sg_list, int sg_len, int total_len);
extern void rltk_mii_recv(struct eth_drv_sg *sg_list, int sg_len);
/*for ethernet mii interface*/
static err_t low_level_output_mii(struct netif *netif, struct pbuf *p)
{
@@ -311,27 +314,27 @@ err_t ethernetif_init(struct netif *netif)
return ERR_OK;
}
err_t ethernetif_mii_init(struct netif *netif)
{
LWIP_ASSERT("netif != NULL", (netif != NULL));
// err_t ethernetif_mii_init(struct netif *netif)
// {
// LWIP_ASSERT("netif != NULL", (netif != NULL));
#if LWIP_NETIF_HOSTNAME
netif->hostname = "lwip2";
#endif /* LWIP_NETIF_HOSTNAME */
// #if LWIP_NETIF_HOSTNAME
// netif->hostname = "lwip2";
// #endif /* LWIP_NETIF_HOSTNAME */
netif->output = etharp_output;
//#if LWIP_IPV6
// netif->output_ip6 = ethip6_output;
//#endif
netif->linkoutput = low_level_output_mii;
// netif->output = etharp_output;
// //#if LWIP_IPV6
// // netif->output_ip6 = ethip6_output;
// //#endif
// netif->linkoutput = low_level_output_mii;
/* initialize the hardware */
low_level_init(netif);
// /* initialize the hardware */
// low_level_init(netif);
etharp_init();
// etharp_init();
return ERR_OK;
}
// return ERR_OK;
// }
static void arp_timer(void *arg)
{

View File

@@ -80,6 +80,7 @@
#include "lwip/dhcp.h"
#include "lwip/autoip.h"
#include "lwip/dns.h"
#include "lwip/igmp.h"
#include "netif/etharp.h"
#include <string.h>

View File

@@ -92,6 +92,7 @@ err_t igmp_start(struct netif *netif);
err_t igmp_stop(struct netif *netif);
void igmp_report_groups(struct netif *netif);
struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr);
void igmp_report_groups_leave(struct netif *netif);
void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest);
err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr);
err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr);

View File

@@ -121,6 +121,7 @@ err_t dhcp_start(struct netif *netif);
err_t dhcp_renew(struct netif *netif);
/** release the DHCP lease, usually called before dhcp_stop()*/
err_t dhcp_release(struct netif *netif);
err_t dhcp_release_unicast(struct netif *netif); //Realtek add
/** stop DHCP configuration */
void dhcp_stop(struct netif *netif);
/** inform server of our manual IP address */

View File

@@ -55,6 +55,10 @@
#endif
#include <stdlib.h>
// lmao, importing hal_crypto imports the entire fwlib bloat
// and conflicts with the variable names
#include "rtl8711b_crypto.h"
#include "rtl8710b_crypto_api.h"
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
!defined(EFI32)

View File

@@ -1,74 +1,64 @@
#include "rom_ssl_ram_map.h"
#include <diag.h>
#include "ssl_ram_map.h"
extern struct _rom_ssl_ram_map rom_ssl_ram_map;
//AES HW CRYPTO
extern int rtl_crypto_aes_ecb_init(IN const u8* key, IN const u32 keylen);
extern int rtl_crypto_aes_ecb_decrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
extern int rtl_crypto_aes_ecb_encrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
extern int rtl_crypto_aes_cbc_init(IN const u8* key, IN const u32 keylen);
extern int rtl_crypto_aes_cbc_decrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
extern int rtl_crypto_aes_cbc_encrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
// AES HW CRYPTO
int rtl_crypto_aes_ecb_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_aes_ecb_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_aes_ecb_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_aes_cbc_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_aes_cbc_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_aes_cbc_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
//DES HW CRYPTO
extern int rtl_crypto_des_cbc_init(IN const u8* key, IN const u32 keylen);
extern int rtl_crypto_des_cbc_decrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
extern int rtl_crypto_des_cbc_encrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
extern int rtl_crypto_3des_cbc_init(IN const u8* key, IN const u32 keylen);
extern int rtl_crypto_3des_cbc_decrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
extern int rtl_crypto_3des_cbc_encrypt(
IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
// DES HW CRYPTO
int rtl_crypto_des_cbc_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_des_cbc_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_des_cbc_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_3des_cbc_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_3des_cbc_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_3des_cbc_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int platform_set_malloc_free( void * (*malloc_func)( size_t ),
void (*free_func)( void * ) )
{
/* OS interface */
rom_ssl_ram_map.ssl_malloc = malloc_func;
rom_ssl_ram_map.ssl_free = free_func;
rom_ssl_ram_map.ssl_printf = (int (*)(char const *, ...))DiagPrintf;
int platform_set_malloc_free(void* (*malloc_func)(size_t),
void (*free_func)(void*)) {
/* OS interface */
rom_ssl_ram_map.ssl_malloc = malloc_func;
rom_ssl_ram_map.ssl_free = free_func;
rom_ssl_ram_map.ssl_printf = (int (*)(char const*, ...))DiagPrintf;
//AES HW CRYPTO
rom_ssl_ram_map.hw_crypto_aes_ecb_init = rtl_crypto_aes_ecb_init;
rom_ssl_ram_map.hw_crypto_aes_ecb_decrypt = rtl_crypto_aes_ecb_decrypt;
rom_ssl_ram_map.hw_crypto_aes_ecb_encrypt = rtl_crypto_aes_ecb_encrypt;
rom_ssl_ram_map.hw_crypto_aes_cbc_init = rtl_crypto_aes_cbc_init;
rom_ssl_ram_map.hw_crypto_aes_cbc_decrypt = rtl_crypto_aes_cbc_decrypt;
rom_ssl_ram_map.hw_crypto_aes_cbc_encrypt = rtl_crypto_aes_cbc_encrypt;
// AES HW CRYPTO
rom_ssl_ram_map.hw_crypto_aes_ecb_init = rtl_crypto_aes_ecb_init;
rom_ssl_ram_map.hw_crypto_aes_ecb_decrypt = rtl_crypto_aes_ecb_decrypt;
rom_ssl_ram_map.hw_crypto_aes_ecb_encrypt = rtl_crypto_aes_ecb_encrypt;
rom_ssl_ram_map.hw_crypto_aes_cbc_init = rtl_crypto_aes_cbc_init;
rom_ssl_ram_map.hw_crypto_aes_cbc_decrypt = rtl_crypto_aes_cbc_decrypt;
rom_ssl_ram_map.hw_crypto_aes_cbc_encrypt = rtl_crypto_aes_cbc_encrypt;
//DES HW CRYPTO
rom_ssl_ram_map.hw_crypto_des_cbc_init = rtl_crypto_des_cbc_init;
rom_ssl_ram_map.hw_crypto_des_cbc_decrypt = rtl_crypto_des_cbc_decrypt;
rom_ssl_ram_map.hw_crypto_des_cbc_encrypt = rtl_crypto_des_cbc_encrypt;
rom_ssl_ram_map.hw_crypto_3des_cbc_init = rtl_crypto_3des_cbc_init;
rom_ssl_ram_map.hw_crypto_3des_cbc_decrypt = rtl_crypto_3des_cbc_decrypt;
rom_ssl_ram_map.hw_crypto_3des_cbc_encrypt = rtl_crypto_3des_cbc_encrypt;
// DES HW CRYPTO
rom_ssl_ram_map.hw_crypto_des_cbc_init = rtl_crypto_des_cbc_init;
rom_ssl_ram_map.hw_crypto_des_cbc_decrypt = rtl_crypto_des_cbc_decrypt;
rom_ssl_ram_map.hw_crypto_des_cbc_encrypt = rtl_crypto_des_cbc_encrypt;
rom_ssl_ram_map.hw_crypto_3des_cbc_init = rtl_crypto_3des_cbc_init;
rom_ssl_ram_map.hw_crypto_3des_cbc_decrypt = rtl_crypto_3des_cbc_decrypt;
rom_ssl_ram_map.hw_crypto_3des_cbc_encrypt = rtl_crypto_3des_cbc_encrypt;
/* Variables */
rom_ssl_ram_map.use_hw_crypto_func = 1;
/* Variables */
rom_ssl_ram_map.use_hw_crypto_func = 1;
return 0;
return 0;
}

View File

@@ -0,0 +1,52 @@
#ifndef SSL_RAM_MAP_H
#define SSL_RAM_MAP_H
#include <diag.h>
#include "rom_ssl_ram_map.h"
/* Function declarations */
/**
* @brief Sets up malloc, free and other platform-specific functions for SSL
* operations
* @param malloc_func Function pointer to memory allocation function
* @param free_func Function pointer to memory deallocation function
* @return 0 on success
*/
int platform_set_malloc_free(void* (*malloc_func)(size_t),
void (*free_func)(void*));
/* AES Hardware Crypto Function Declarations */
int rtl_crypto_aes_ecb_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_aes_ecb_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_aes_ecb_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_aes_cbc_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_aes_cbc_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_aes_cbc_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
/* DES Hardware Crypto Function Declarations */
int rtl_crypto_des_cbc_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_des_cbc_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_des_cbc_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_3des_cbc_init(IN const u8* key, IN const u32 keylen);
int rtl_crypto_3des_cbc_decrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
int rtl_crypto_3des_cbc_encrypt(IN const u8* message, IN const u32 msglen,
IN const u8* iv, IN const u32 ivlen,
OUT u8* pResult);
#endif /* SSL_RAM_MAP_H */

View File

@@ -36,7 +36,7 @@ static const char *ep;
const char *cJSON_GetErrorPtr(void) {return ep;}
#define sprintf rtl_sprintf
// #define sprintf rtl_sprintf
static int cJSON_strcasecmp(const char *s1,const char *s2)
{

View File

@@ -2,6 +2,7 @@
#include "task.h"
#include <string.h>
#include <stdio.h>
#include <osdep_service.h>
#include "platform_opts.h"

View File

@@ -55,6 +55,8 @@
#include "timers.h"
#include "queue.h"
#include "semphr.h"
#include "rtl8710b.h"
// #include "core_cm4.h"
#define FREERTOS_VERSION 0x00080001 // bits[31:16] main version, bits[15:0] sub-version

View File

@@ -8,8 +8,12 @@
#include <stdio.h>
#include <freertos_pmu.h>
//#include <tcm_heap.h>
#include "rtl8710b.h"
#include "rtl8710b_freertos_pmu.h"
/********************* os depended utilities ********************/
extern int rtw_if_wifi_thread(const char *name);
#ifndef USE_MUTEX_FOR_SPINLOCK
#define USE_MUTEX_FOR_SPINLOCK 1
#endif
@@ -534,7 +538,7 @@ static int _freertos_arc4random(void)
return (int)seed;
}
static int _freertos_get_random_bytes(void *buf, size_t len)
static int _freertos_get_random_bytes(void *buf, u32 len)
{
#if 1 //becuase of 4-byte align, we use the follow code style.
unsigned int ranbuf;
@@ -620,7 +624,7 @@ static int _freertos_create_task(struct task_struct *ptask, const char *name,
stack_size,
task_ctx,
priority,
&ptask->task);
(TaskHandle_t*)&ptask->task);
#endif
}
else{
@@ -630,7 +634,7 @@ static int _freertos_create_task(struct task_struct *ptask, const char *name,
stack_size,
task_ctx,
priority,
&ptask->task);
(TaskHandle_t*)&ptask->task);
}
if(ret != pdPASS){
@@ -687,7 +691,7 @@ _timerHandle _freertos_timerCreate( const signed char *pcTimerName,
if(xTimerPeriodInTicks == TIMER_MAX_DELAY) {
xTimerPeriodInTicks = portMAX_DELAY;
}
return xTimerCreate((const char *)pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction);
return xTimerCreate((const char *)pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, (TimerCallbackFunction_t)pxCallbackFunction);
}
u32 _freertos_timerDelete( _timerHandle xTimer,

View File

@@ -6,9 +6,9 @@
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*/
#include "basic_types.h"
u32
Rand (
extern _LONG_CALL_ u32 Rand (
VOID
);

View File

@@ -62,6 +62,7 @@
#include <device_lock.h>
#include "rtl8710b_ota.h"
#include "lwip/netdb.h"
#include "rtc_api.h"
#define OTA2_DEFAULT_ADDR (0x08080000)

View File

@@ -6,9 +6,9 @@
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*/
#include "basic_types.h"
u32
Rand (
extern _LONG_CALL_ u32 Rand (
VOID
);

View File

@@ -100,7 +100,7 @@ static inline int isodigit(const char c)
return c >= '0' && c <= '7';
}
#ifndef strtoul
#define strtoul(str, endp, base) Strtoul(str, endp, base)
#define strtoul(str, endp, base) simple_strtoul(str, endp, base)
#endif
#ifndef strtol
#define strtol(str, endp, base) simple_strtol(str, endp, base)