This commit is contained in:
pvvx 2017-09-22 10:44:42 +03:00
parent 9ffd9dac1a
commit eac35630e6
31 changed files with 185 additions and 130 deletions

View file

@ -157,13 +157,22 @@
//
// memory management
//
#ifndef CONFIG_MBED_ENABLED
extern void *pvPortMalloc( size_t xWantedSize );
extern void vPortFree( void *pv );
#define malloc pvPortMalloc
#define zalloc pvPortZalloc
#define free vPortFree
#endif
#undef malloc
extern void *pvPortMalloc(size_t xWantedSize);
#define malloc pvPortMalloc
#undef zalloc
extern void *pvPortZalloc(size_t xWantedSize);
#define zalloc pvPortZalloc
#undef realloc
extern void *pvPortReAlloc(void *pv, size_t xWantedSize);
#define realloc pvPortReAlloc
#undef free
extern void vPortFree(void *pv);
#define free vPortFree
#elif defined (CONFIG_PLATFORM_8711B)
#if defined (__IARSTDLIB__)

View file

@ -19,9 +19,8 @@
extern void _promisc_deinit(_adapter *padapter);
extern int _promisc_recv_func(_adapter *padapter, recv_frame *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, unsigned char *ssid, int *ssid_length);
extern unsigned char is_promisc_enabled(void);
extern unsigned char _is_promisc_enabled(void);
extern int _promisc_get_fixed_channel(void *fixed_bssid, unsigned char *ssid, int *ssid_length);
#endif

View file

@ -127,7 +127,7 @@ LOCAL int _wifi_scan_networks(rtw_scan_result_handler_t results_handler) {
pscan_rec->user_data = NULL;
wifi_reg_event_handler(WIFI_EVENT_SCAN_RESULT_REPORT, wifi_scan_each_report_hdl, NULL);
wifi_reg_event_handler(WIFI_EVENT_SCAN_DONE, _wifi_scan_done_hdl, NULL);
if(wext_set_scan(WLAN0_NAME, NULL, 0, RTW_SCAN_TYPE_ACTIVE | (RTW_SCAN_COMMAMD << 4) | (RTW_BSS_TYPE_ANY << 8)) == RTW_SUCCESS) {
if(wext_set_scan(WLAN0_NAME, NULL, 0, RTW_SCAN_TYPE_ACTIVE | (RTW_SCAN_COMMAMD << 4) | (RTW_BSS_TYPE_ANY << 8)) == RTW_SUCCESS) { // Только RTW_SCAN_TYPE_ACTIVE ?
return RTW_SUCCESS;
}
};

View file

@ -109,7 +109,7 @@ SD_RESULT SD_GetCapacity(uint32_t *sector_count) {
//----- SD_ReadBlocks
SD_RESULT SD_ReadBlocks(u32 sector, u8 *data, u32 count) {
int rd_count;
int rd_count = 0;
unsigned char * buf;
if ((u32) data & 3) {
@ -145,7 +145,7 @@ SD_RESULT SD_ReadBlocks(u32 sector, u8 *data, u32 count) {
//----- SD_WriteBlocks
SD_RESULT SD_WriteBlocks(u32 sector, const u8 *data, u32 count) {
int wr_count;
int wr_count = 0;
unsigned char * buf;
if ((u32) data & 3) {

View file

@ -186,7 +186,7 @@ s8 sdio_write_blocks(uint32_t sector, const uint8_t *buffer, uint32_t count) {
rtl_memset(gAdmaTbls, 0, sizeof(ADMA2_DESC_FMT) * count);
if (1) {
ADMA2_DESC_FMT *p = gAdmaTbls;
u8 * pbuf = buffer;
u8 * pbuf = (u8 *)buffer;
int i = 0;
while (i < count) {
i++;
@ -255,14 +255,14 @@ s8 sdio_sd_setClock(SD_CLK_FREQUENCY SDCLK) {
if (sdio_status <= SDIO_SD_NONE) {
return -1;
}
ADMA2_DESC_FMT * padma = rtw_zmalloc(sizeof(ADMA2_DESC_FMT));
ADMA2_DESC_FMT * padma = (ADMA2_DESC_FMT *) rtw_zmalloc(sizeof(ADMA2_DESC_FMT));
if (!padma) {
DBG_SDIO_ERR("Malloc ADMA2 table fail.\n");
return -1;
}
DBG_SDIO_INFO("SD card set CLK %d Hz\n", PLATFORM_CLOCK/(2 << (SD_CLK_41_6MHZ - SDCLK)));
sta = HalSdioHostOp.HalSdioHostChangeSdClock(&SdioHostAdapter, SDCLK);
rtw_mfree(padma, sizeof(ADMA2_DESC_FMT));
rtw_mfree((u8 *)padma, sizeof(ADMA2_DESC_FMT));
if (sta)
return -1;
return 0;
@ -296,11 +296,10 @@ s8 sdio_sd_setProtection(bool protection) {
}
LABEL_8:
sd_protected = protection;
LABEL_7:
DBG_SDIO_INFO("Set SD card Protection done.\n");
result = 0;
LABEL_17:
rtw_mfree(padma, sizeof(ADMA2_DESC_FMT));
rtw_mfree((u8 *)padma, sizeof(ADMA2_DESC_FMT));
return result;
}
return -1;

View file

@ -6,12 +6,11 @@
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*/
#include "integer.h"
#include <disk_if/inc/sdcard.h>
#if FATFS_DISK_SD
//#if FATFS_DISK_SD
#include "sd.h" // sd card driver with sdio interface
#include "integer.h"
#include <disk_if/inc/sdcard.h>
#define SD_BLOCK_SIZE 512
@ -53,7 +52,7 @@ DRESULT SD_disk_read(BYTE *buff, DWORD sector, UINT count){
/* Write sector(s) --------------------------------------------*/
#if _USE_WRITE == 1
DRESULT SD_disk_write(const BYTE *buff, DWORD sector, UINT count){
DRESULT SD_disk_write(const BYTE * buff, DWORD sector, UINT count){
SD_RESULT res;
res = SD_WriteBlocks(sector, buff, count);
@ -66,7 +65,6 @@ DRESULT SD_disk_write(const BYTE *buff, DWORD sector, UINT count){
DRESULT SD_disk_ioctl (BYTE cmd, void* buff){
DRESULT res = RES_ERROR;
SD_RESULT result;
DWORD last_blk_addr, block_size;
switch(cmd){
/* Generic command (used by FatFs) */
@ -118,7 +116,8 @@ DRESULT SD_disk_ioctl (BYTE cmd, void* buff){
}
#endif
ll_diskio_drv SD_disk_Driver ={
ll_diskio_drv SD_disk_Driver = {
.disk_initialize = SD_disk_initialize,
.disk_status = SD_disk_status,
.disk_read = SD_disk_read,
@ -130,4 +129,5 @@ ll_diskio_drv SD_disk_Driver ={
#endif
.TAG = "SD"
};
#endif
//#endif // FATFS_DISK_SD

View file

@ -335,6 +335,7 @@ int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
#endif
#ifdef __cplusplus
}
#endif

View file

@ -87,7 +87,7 @@ DRESULT disk_write (
)
{
DRESULT res = RES_PARERR;
int index = 0;
// int index = 0;
if (pdrv < 0 || pdrv >= disk.nbr || buff == (void*)0 || count <= 0)
return RES_PARERR; // Return if the parameter is invalid

View file

@ -119,8 +119,6 @@
#include "diskio.h" /* Declarations of disk I/O functions */
/*--------------------------------------------------------------------------
Module Private Definitions
@ -595,9 +593,14 @@ int mem_cmp (const void* dst, const void* src, UINT cnt) {
return r;
}
#else
#define mem_cpy memcpy
#define mem_set memset
#define mem_cmp memcmp
typedef unsigned int size_t;
extern int rtl_memcmp(const void * m1 , const void * m2 , size_t n);
extern void * rtl_memcpy(void * dst0 , const void * src0 , size_t len0);
extern void * rtl_memset(void * m , int c , size_t n);
#define mem_cpy rtl_memcpy
#define mem_set rtl_memset
#define mem_cmp rtl_memcmp
#endif
/* Check if chr is contained in the string */

View file

@ -167,7 +167,7 @@ void sys_adc_calibration(u8 write, u16 *offset, u16 *gain)
extern flash_t flash;
if(write){
// backup
u8 *pbuf = RtlMalloc(FLASH_SECTOR_SIZE);
u8 *pbuf = malloc(FLASH_SECTOR_SIZE);
if(!pbuf) return;
device_mutex_lock(RT_DEV_LOCK_FLASH);
flash_stream_read(&flash, FLASH_SYSTEM_DATA_ADDR, FLASH_SECTOR_SIZE, pbuf);
@ -180,7 +180,7 @@ extern flash_t flash;
flash_erase_sector(&flash, FLASH_SYSTEM_DATA_ADDR);
flash_stream_write(&flash, FLASH_SYSTEM_DATA_ADDR, FLASH_SECTOR_SIZE, pbuf);
device_mutex_unlock(RT_DEV_LOCK_FLASH);
RtlMfree(pbuf, FLASH_SECTOR_SIZE);
free(pbuf);
printf("Store ADC calibration success.\n");
}
device_mutex_lock(RT_DEV_LOCK_FLASH);

View file

@ -98,6 +98,7 @@ struct stream_context
#define RTP_PT_H263 34
#define RTP_PT_RTCP_BASE 72
#define RTP_PT_DYN_BASE 96
#undef RTP_PT_UNKNOWN
#define RTP_PT_UNKNOWN -1
#include "section_config.h"
@ -333,4 +334,4 @@ void fillRtpHeader(rtp_hdr_t *rtphdr, int version, int padding, int extension, i
/************************************************************** end of rtp **************************************************************/
#endif
#endif

View file

@ -291,7 +291,7 @@
/*
* combine the four dirtypenrsize parameters to one cmd parameter
* combine the four dir<EFBFBD>Atype<EFBFBD>Anr<EFBFBD>Asize parameters to one cmd parameter
*
*/
#ifndef _IOC
@ -511,40 +511,40 @@ found:
static inline unsigned long find_next_zero_bit(
const unsigned long *addr,unsigned long size, unsigned long offset)
{
const unsigned long *p = addr + BIT_WORD(offset); // offset位于p指向的long地址32位空?
unsigned long result = offset & ~(BITS_PER_LONG-1); // offset是第result?4字?
const unsigned long *p = addr + BIT_WORD(offset); // offset<EFBFBD><EFBFBD>_p<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD><EFBFBD>long<EFBFBD>a<EFBFBD>}32<33><32><EFBFBD>?
unsigned long result = offset & ~(BITS_PER_LONG-1); // offset<EFBFBD>O<EFBFBD><EFBFBD>result?4<>r?
unsigned long tmp;
if (offset >= size)
return size;
size -= result; // ?整32位整倍?上
offset %= BITS_PER_LONG; // offset位于32位的第几位
if (offset) { // offset不在一?long?据的第0位上,在1-31位中[luther.gliethttp]
size -= result; // ?<EFBFBD><EFBFBD>32<EFBFBD><EFBFBD>㭿?<3F>W
offset %= BITS_PER_LONG; // offset<EFBFBD><EFBFBD>_32<EFBFBD><EFBFBD>ĤL<EFBFBD><EFBFBD>
if (offset) { // offset<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>@?long?<3F>u<EFBFBD><75><EFBFBD><EFBFBD>0<EFBFBD><30>W,<2C>b1-31<33>[luther.gliethttp]
tmp = *(p++);
tmp |= ~0UL >> (BITS_PER_LONG - offset); // ?0-offset?据填充上1.
if (size < BITS_PER_LONG) // 不足32bits
tmp |= ~0UL >> (BITS_PER_LONG - offset); // ?0-offset?<EFBFBD>u<EFBFBD><EFBFBD>R<EFBFBD>W1.
if (size < BITS_PER_LONG) // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>32bits
goto found_first;
if (~tmp) // 取非非0?明含有0值
if (~tmp) // <EFBFBD><EFBFBD><EFBFBD>D<EFBFBD>D0?<3F><><EFBFBD>t<EFBFBD><74>0<EFBFBD><30>
goto found_middle;
size -= BITS_PER_LONG; // 如果上面~tmp等于0,那么?明?*p?据?32位全1.[luther.gliethttp]
size -= BITS_PER_LONG; // <EFBFBD>p<EFBFBD>G<EFBFBD>W<EFBFBD><EFBFBD>~tmp<6D><70><EFBFBD>_0,<2C><><EFBFBD>\?<3F><>?*p?<3F>u?32<33><32><EFBFBD>1.[luther.gliethttp]
result += BITS_PER_LONG;
}
while (size & ~(BITS_PER_LONG-1)) { // 好了,?行到?里,我?的offset已??在4字?的第0位上,下面?行
if (~(tmp = *(p++))) // 4字?快速查?.如果~tmp非0,?明?32位?据中含有0?据,找到.[luther.gliethttp]
while (size & ~(BITS_PER_LONG-1)) { // <EFBFBD>n<EFBFBD>F,?<3F><><EFBFBD>?<3F><>,<2C><>?<3F><>offset<65>w??<3F>b4<62>r?<3F><><EFBFBD><EFBFBD>0<EFBFBD><30>W,<2C>U<EFBFBD><55>?<3F><>
if (~(tmp = *(p++))) // 4<EFBFBD>r?<3F>ֳt<D6B3>d?.<2E>p<EFBFBD>G~tmp<6D>D0,?<3F><>?32<33><32>?<3F>u<EFBFBD><75><EFBFBD>t<EFBFBD><74>0?<3F>u,<2C><><EFBFBD>.[luther.gliethttp]
goto found_middle;
result += BITS_PER_LONG; // 到下一?4字?空?
size -= BITS_PER_LONG; // ?少4字??据
result += BITS_PER_LONG; // <EFBFBD><EFBFBD>U<EFBFBD>@?4<>r?<3F><>?
size -= BITS_PER_LONG; // ?<EFBFBD><EFBFBD>4<EFBFBD>r??<3F>u
}
if (!size) // size等于0,?明首先size等于4字?整倍?,其次所有?据已?查完,
return result; // 所有?据全部?1,?有??0位,result等于size.[luther.gliethttp]
tmp = *p; // size不是32位整倍?,?剩几?bit?有?查,???行下面?查工作.[luther.gliethtp]
if (!size) // size<EFBFBD><EFBFBD><EFBFBD>_0,?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>size<7A><65><EFBFBD>_4<5F>r?<3F>㭿?,<2C><EFBFBD>Ҧ<EFBFBD>?<3F>u<EFBFBD>w?<3F>d<EFBFBD><64>,
return result; // <EFBFBD>Ҧ<EFBFBD>?<3F>u<EFBFBD><75><EFBFBD><EFBFBD>?1,?<3F><>??0<><30>,result<6C><74><EFBFBD>_size.[luther.gliethttp]
tmp = *p; // size<EFBFBD><EFBFBD><EFBFBD>O32<EFBFBD><EFBFBD>㭿?,?<3F>ѤL?bit?<3F><>?<3F>d,???<3F><>U<EFBFBD><55>?<3F>d<EFBFBD>u<EFBFBD>@.[luther.gliethtp]
found_first:
tmp |= ~0UL << size; // ?在0-size?有效?据,size-31?未使用空?,所以先?size-31置成全1.
if (tmp == ~0UL) /* Are any bits zero? */ // 如果tmp全1,那么?明就?找找1?
return result + size; /* Nope. */ // result+size就等于函??入的??size大小.[luther.gliethttp]
tmp |= ~0UL << size; // ?<EFBFBD>b0-size?<3F><><EFBFBD><EFBFBD>?<3F>u,size-31?<3F><><EFBFBD>ϥΪ<CFA5>?,<2C>ҥH<D2A5><48>?size-31<33>m<EFBFBD><6D><EFBFBD><EFBFBD>1.
if (tmp == ~0UL) /* Are any bits zero? */ // <EFBFBD>p<EFBFBD>Gtmp<EFBFBD><EFBFBD>1,<2C><><EFBFBD>\?<3F><><EFBFBD>N?<3F><><EFBFBD>1?
return result + size; /* Nope. */ // result+size<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><EFBFBD>??<3F>J<EFBFBD><4A>??size<7A>j<EFBFBD>p.[luther.gliethttp]
found_middle:
return result + ffz(tmp); // 我?在32位?据的0-31中??必定存在0位值,?算他是第几位.[luther.gliethttp]
return result + ffz(tmp); // <EFBFBD><EFBFBD>?<3F>b32<33><32>?<3F>u<EFBFBD><75>0-31<33><31>??<3F><><EFBFBD>w<EFBFBD>s<EFBFBD>b0<62><30><EFBFBD>,?<3F><>L<EFBFBD>O<EFBFBD>ĤL<C4A4><4C>.[luther.gliethttp]
}
//int find_next_zero_bit(const void * p, int size, int offset);
@ -570,7 +570,7 @@ static inline void set_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long flags;
(void)flags;
//taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags);
*p |= mask;
@ -593,7 +593,7 @@ static inline void clear_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long flags;
(void)flags;
_atomic_spin_lock_irqsave(p, flags);
//taskENTER_CRITICAL();
*p &= ~mask;
@ -616,7 +616,7 @@ static inline void change_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long flags;
(void)flags;
//taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags);
*p ^= mask;
@ -638,8 +638,8 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long old;
//unsigned long flags;
unsigned long flags;
(void)flags;
//taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags);
@ -666,7 +666,7 @@ static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
unsigned long old;
unsigned long flags;
(void)flags;
//taskENTER_CRITICAL();
_atomic_spin_lock_irqsave(p, flags);
old = *p;
@ -691,7 +691,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
unsigned long old;
unsigned long flags;
(void)flags;
_atomic_spin_lock_irqsave(p, flags);
old = *p;
*p = old ^ mask;
@ -725,6 +725,7 @@ static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1,
static inline int atomic_inc_return(volatile atomic_t *v)
{
unsigned long flags;
(void)flags;
int retval;
cris_atomic_save(v, flags);
retval = ++(v->counter);
@ -843,4 +844,4 @@ do { \
#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
#endif
#endif /*_V4L2_OSDEP_H_*/
#endif /*_V4L2_OSDEP_H_*/