initial commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _MONITOR_LIB_H_
|
||||
#define _MONITOR_LIB_H_
|
||||
|
||||
|
||||
VOID
|
||||
DumpForOneBytes(
|
||||
IN u8 *pData,
|
||||
IN u8 Len
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern u32
|
||||
CmdDumpByte(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern u32
|
||||
CmdDumpHalfWord(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
|
||||
_LONG_CALL_
|
||||
extern u32
|
||||
CmdDumpWord(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern u32
|
||||
CmdWriteByte(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern u32
|
||||
CmdWriteWord(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern u32 CmdFlash(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern u32 CmdEfuse(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _RTK_CONSOL_H_
|
||||
#define _RTK_CONSOL_H_
|
||||
|
||||
//Log UART
|
||||
//UART_LOG_CMD_BUFLEN: only 126 bytes could be used for keeping input
|
||||
// cmd, the last byte is for string end ('\0').
|
||||
#define UART_LOG_CMD_BUFLEN 127
|
||||
#define MAX_ARGV 10
|
||||
|
||||
|
||||
|
||||
typedef u32 (*ECHOFUNC)(IN u8*,...); //UART LOG echo-function type.
|
||||
|
||||
typedef struct {
|
||||
u8 BufCount; //record the input cmd char number.
|
||||
u8 UARTLogBuf[UART_LOG_CMD_BUFLEN]; //record the input command.
|
||||
} UART_LOG_BUF, *PUART_LOG_BUF;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
u8 NewIdx;
|
||||
u8 SeeIdx;
|
||||
u8 RevdNo;
|
||||
u8 EscSTS;
|
||||
u8 ExecuteCmd;
|
||||
u8 ExecuteEsc;
|
||||
u8 BootRdy;
|
||||
u8 Resvd;
|
||||
PUART_LOG_BUF pTmpLogBuf;
|
||||
VOID *pfINPUT;
|
||||
PCOMMAND_TABLE pCmdTbl;
|
||||
u32 CmdTblSz;
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
u32 CRSTS;
|
||||
#endif
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
u8 (*pHistoryBuf)[UART_LOG_CMD_BUFLEN];
|
||||
#endif
|
||||
} UART_LOG_CTL, *PUART_LOG_CTL;
|
||||
|
||||
|
||||
#define KB_ASCII_NUL 0x00
|
||||
#define KB_ASCII_BS 0x08
|
||||
#define KB_ASCII_TAB 0x09
|
||||
#define KB_ASCII_LF 0x0A
|
||||
#define KB_ASCII_CR 0x0D
|
||||
#define KB_ASCII_ESC 0x1B
|
||||
#define KB_ASCII_SP 0x20
|
||||
#define KB_ASCII_BS_7F 0x7F
|
||||
#define KB_ASCII_LBRKT 0x5B //[
|
||||
|
||||
#define KB_SPACENO_TAB 1
|
||||
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
#define UART_LOG_HISTORY_LEN 5
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOG
|
||||
#define _ConsolePrint DiagPrintf
|
||||
#else
|
||||
#define _ConsolePrint
|
||||
#endif
|
||||
|
||||
#define CONSOLE_PREFIX "<RTL8195A>"
|
||||
|
||||
#define CONSOLE_8195A(...) do {\
|
||||
_ConsolePrint("\r"CONSOLE_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
#define AMEBA_CONSOLE_PREFIX "#"
|
||||
#define CONSOLE_AMEBA(...) do {\
|
||||
_ConsolePrint("\r"AMEBA_CONSOLE_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
_LONG_CALL_ VOID RtlConsolInit(u32 Boot, u32 TBLSz, VOID *pTBL);
|
||||
_LONG_CALL_ VOID RtlConsolTaskRom(VOID *Data);
|
||||
_LONG_CALL_ u32 Strtoul(const u8 *nptr, u8 **endptr, u32 base);
|
||||
_LONG_CALL_ u32 GetRomCmdNum(VOID);
|
||||
_LONG_CALL_ VOID UartLogCmdExecute(PUART_LOG_CTL pUartLogCtlExe);
|
||||
_LONG_CALL_ VOID RtlConsolRom(u32 MaxWaitCount);
|
||||
_LONG_CALL_ void LOGUART_SetBaud_FromFlash(void);
|
||||
#endif //_RTK_CONSOL_H_
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#ifndef _RTK_CONSOL_RAM_H_
|
||||
#define _RTK_CONSOL_RAM_H_
|
||||
|
||||
VOID ReRegisterPlatformLogUart(VOID);
|
||||
VOID RtlConsolTaskRam(VOID *Data);
|
||||
#endif //_RTK_CONSOL_RAM_H_
|
||||
134
lib/amb1_sdk/soc/realtek/8711b/app/monitor/include/rtl_trace.h
Normal file
134
lib/amb1_sdk/soc/realtek/8711b/app/monitor/include/rtl_trace.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtl_trace.h
|
||||
* @author
|
||||
* @version V1.0.0
|
||||
* @date 2016-05-17
|
||||
* @brief This file contains all the functions for log print and mask.
|
||||
******************************************************************************
|
||||
* @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) 2015, Realtek Semiconductor Corporation. All rights reserved.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _RTK_TRACE_H_
|
||||
#define _RTK_TRACE_H_
|
||||
|
||||
/** @addtogroup AmebaZ_Platform
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup Platform_Debug Debug
|
||||
* @brief Platform_Debug modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup Platform_Debug_Log_Trace_Exported_Types Log Trace Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Log Module Definition */
|
||||
typedef enum {
|
||||
MODULE_OS = 0, /**< FreeRTOS */
|
||||
MODULE_BOOT = 1, /**< bootloader */
|
||||
MODULE_GDMA = 2, /**< gdma */
|
||||
MODULE_GPIO = 3, /**< gpio */
|
||||
MODULE_TIMER = 4, /**< timer */
|
||||
MODULE_I2C = 5, /**< i2c */
|
||||
MODULE_I2S = 6, /**< i2s */
|
||||
MODULE_PWM = 7, /**< pwm */
|
||||
MODULE_SDIO = 8, /**< sdio */
|
||||
MODULE_SPI = 9, /**< spi */
|
||||
MODULE_FLASH = 10, /**< flash */
|
||||
MODULE_UART = 11, /**< uart */
|
||||
MODULE_USOC = 12, /**< usoc */
|
||||
MODULE_IPSEC = 13, /**< ipsec */
|
||||
MODULE_ADC = 14, /**< adc */
|
||||
MODULE_EFUSE = 15, /**< efuse */
|
||||
MODULE_MONIT = 16, /**< monitor */
|
||||
MODULE_MISC = 17, /**< misc */
|
||||
|
||||
MODULE_NUMs /**< Module Number */
|
||||
} MODULE_DEFINE;
|
||||
|
||||
/** @brief Log Level Definition */
|
||||
typedef enum {
|
||||
LEVEL_ERROR = 0, /**< Error */
|
||||
LEVEL_WARN = 1, /**< Warning */
|
||||
LEVEL_INFO = 2, /**< Information */
|
||||
LEVEL_TRACE = 3, /**< Trace Data */
|
||||
LEVEL_NUMs = 4 /**< Level Number */
|
||||
} LEVEL_DEFINE;
|
||||
/** End of Platform_Debug_Log_Trace_Exported_Types
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Platform_Debug_Log_Trace_Functions_And_Macro Function & Macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @cond private */
|
||||
/** @brief Debug Log mask */
|
||||
extern u32 ConfigDebug[];
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Debug Log Mask Set.
|
||||
* @param config[4] -- Print log if bit MODULE_DEFINE of config[LEVEL_DEFINE] is 1;
|
||||
* @return void.
|
||||
* @note Here is a MODULE_BOOT module sample to demostrate the using of LOG_MASK().
|
||||
* We want to print log under ERROR level and INFO level.
|
||||
* @code{.c}
|
||||
* u32 debug[4];
|
||||
* debug[LEVEL_ERROR] = BIT(MODULE_BOOT);
|
||||
* debug[LEVEL_WARN] = 0x0;
|
||||
* debug[LEVEL_INFO] = BIT(MODULE_BOOT);
|
||||
* debug[LEVEL_TRACE] = 0x0;
|
||||
* LOG_MASK(debug);
|
||||
*
|
||||
* DBG_PRINTF(MODULE_BOOT, LEVEL_INFO, "MODULE_BOOT Info.\n");
|
||||
* DBG_PRINTF(MODULE_BOOT, LEVEL_ERROR, "MODULE_BOOT Error!\n");
|
||||
* @endcode
|
||||
*/
|
||||
void LOG_MASK_MODULE(u32 module, u32 level, u32 new_status);
|
||||
void LOG_MASK(u32 config[]);
|
||||
void LOG_PRINTF(u32 module, u32 level, u32 line, const char*fmt, ...);
|
||||
|
||||
/**
|
||||
* @brief DBG_PRINTF is used to print log
|
||||
*/
|
||||
#define RELEASE_VERSION
|
||||
#ifdef RELEASE_VERSION
|
||||
#define DBG_PRINTF(MODULE, LEVEL, pFormat, ...) do {\
|
||||
if ((LEVEL < LEVEL_NUMs) && (MODULE < MODULE_NUMs) && (ConfigDebug[LEVEL] & BIT(MODULE))) {\
|
||||
DEBUG_TRACE_DATA_SECTION static const char traceFormat[] = pFormat;\
|
||||
}\
|
||||
}while(0)
|
||||
#else
|
||||
#define DBG_PRINTF(MODULE, LEVEL, pFormat, ...) do {\
|
||||
if ((LEVEL < LEVEL_NUMs) && (MODULE < MODULE_NUMs) && (ConfigDebug[LEVEL] & BIT(MODULE))) {\
|
||||
static const char traceFormat[] DEBUG_TRACE_DATA_SECTION = pFormat;\
|
||||
LOG_PRINTF(MODULE, LEVEL, __LINE__, traceFormat, ##__VA_ARGS__); \
|
||||
}\
|
||||
}while(0)
|
||||
#endif
|
||||
|
||||
/** End of Platform_Debug_Log_Trace_Functions_And_Macro
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** End of Platform_Debug
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** End of AmebaZ_Platform
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif //_RTK_TRACE_H_
|
||||
/******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
|
||||
@@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
#include "ameba_soc.h"
|
||||
|
||||
#if !defined (__ICCARM__)
|
||||
extern u8 RAM_IMG1_VALID_PATTEN[];
|
||||
void *tmp = RAM_IMG1_VALID_PATTEN;
|
||||
#endif
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
size_t __write(int Handle, const unsigned char * Buf, size_t Bufsize)
|
||||
{
|
||||
int nChars = 0;
|
||||
/* Check for stdout and stderr
|
||||
(only necessary if file descriptors are enabled.) */
|
||||
if (Handle != 1 && Handle != 2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
for (/*Empty */; Bufsize > 0; --Bufsize)
|
||||
{
|
||||
DiagPutChar(*Buf++);
|
||||
++nChars;
|
||||
}
|
||||
return nChars;
|
||||
}
|
||||
|
||||
size_t __read(int Handle, unsigned char * Buf, size_t Bufsize)
|
||||
{
|
||||
int nChars = 0;
|
||||
/* Check for stdin
|
||||
(only necessary if FILE descriptors are enabled) */
|
||||
if (Handle != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
for (/*Empty*/; Bufsize > 0; --Bufsize)
|
||||
{
|
||||
int c = DiagGetChar(_FALSE);
|
||||
if (c < 0)
|
||||
break;
|
||||
*(Buf++) = c;
|
||||
++nChars;
|
||||
}
|
||||
return nChars;
|
||||
}
|
||||
#endif
|
||||
328
lib/amb1_sdk/soc/realtek/8711b/app/monitor/ram/monitor.c
Normal file
328
lib/amb1_sdk/soc/realtek/8711b/app/monitor/ram/monitor.c
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
|
||||
#include "ameba_soc.h"
|
||||
#include "monitor_lib.h"
|
||||
#include "rtl_consol.h"
|
||||
#include "freertos_pmu.h"
|
||||
|
||||
VOID WlanNormal( IN u16 argc, IN u8 *argv[]);
|
||||
|
||||
u32
|
||||
CmdRamHelp(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
);
|
||||
|
||||
u32
|
||||
CmdReboot(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
)
|
||||
{
|
||||
if (_strcmp(argv[0], "uartburn") == 0){
|
||||
BKUP_Set(0, BIT_UARTBURN_BOOT);
|
||||
}
|
||||
|
||||
if (_strcmp(argv[0], "cpu") == 0){
|
||||
//BOOT_RAM_CPUReset();
|
||||
}
|
||||
|
||||
/* set system reset happen, should clear this bit when bootup */
|
||||
BKUP_Set(0, BIT_SYS_RESET_HAPPEN);
|
||||
|
||||
DBG_8195A("\n\rRebooting ...\n\r");
|
||||
NVIC_SystemReset();
|
||||
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
u32
|
||||
CmdTickPS(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
)
|
||||
{
|
||||
if (_strcmp(argv[0], "r") == 0){// release
|
||||
if (_strcmp(argv[1], "debug") == 0) {
|
||||
pmu_tickless_debug(ENABLE);
|
||||
} else {
|
||||
pmu_tickless_debug(DISABLE);
|
||||
}
|
||||
pmu_release_wakelock(PMU_OS);
|
||||
}
|
||||
|
||||
if (_strcmp(argv[0], "a") == 0){// acquire
|
||||
pmu_acquire_wakelock(PMU_OS);
|
||||
}
|
||||
|
||||
if (_strcmp(argv[0], "type") == 0){// PG or CG
|
||||
if (_strcmp(argv[1], "pg") == 0) {
|
||||
pmu_set_sleep_type(SLEEP_PG);
|
||||
} else if (_strcmp(argv[1], "cg") == 0) {
|
||||
pmu_set_sleep_type(SLEEP_CG);
|
||||
} else {
|
||||
pmu_set_sleep_type(SLEEP_PG);
|
||||
}
|
||||
}
|
||||
|
||||
if (_strcmp(argv[0], "get") == 0){// get sleep & wake time
|
||||
pmu_get_wakelock_hold_stats(NULL,0);
|
||||
}
|
||||
|
||||
if (_strcmp(argv[0], "clear") == 0){// clear sleep & wake time
|
||||
pmu_clean_wakelock_stat();
|
||||
}
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
u32
|
||||
CmdRTC(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
)
|
||||
{
|
||||
RTC_TimeTypeDef RTC_TimeStruct;
|
||||
|
||||
if (_strcmp(argv[0], "get") == 0) {// dump RTC
|
||||
RTC_AlarmTypeDef RTC_AlarmStruct_temp;
|
||||
RTC_TypeDef* RTC = ((RTC_TypeDef *) RTC_BASE);
|
||||
|
||||
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
RTC_GetAlarm(RTC_Format_BIN, &RTC_AlarmStruct_temp);
|
||||
|
||||
DBG_8195A("time: %d:%d:%d:%d (%d) \n", RTC_TimeStruct.RTC_Days,
|
||||
RTC_TimeStruct.RTC_Hours,
|
||||
RTC_TimeStruct.RTC_Minutes,
|
||||
RTC_TimeStruct.RTC_Seconds,
|
||||
RTC_TimeStruct.RTC_H12_PMAM);
|
||||
|
||||
DBG_8195A("alarm: %d:%d:%d:%d (%d) \n", RTC_AlarmStruct_temp.RTC_AlarmTime.RTC_Days,
|
||||
RTC_AlarmStruct_temp.RTC_AlarmTime.RTC_Hours,
|
||||
RTC_AlarmStruct_temp.RTC_AlarmTime.RTC_Minutes,
|
||||
RTC_AlarmStruct_temp.RTC_AlarmTime.RTC_Seconds,
|
||||
RTC_AlarmStruct_temp.RTC_AlarmTime.RTC_H12_PMAM);
|
||||
|
||||
DBG_8195A("ISR: %x \n", RTC->ISR);
|
||||
DBG_8195A("ALMR1: %x \n", RTC->ALMR1);
|
||||
DBG_8195A("ALMR2: %x \n", RTC->ALMR2);
|
||||
DBG_8195A("OSC8M: %d \n", OSC8M_Get());
|
||||
}
|
||||
|
||||
if (_strcmp(argv[0], "set") == 0) {
|
||||
RTC_TimeStructInit(&RTC_TimeStruct);
|
||||
RTC_TimeStruct.RTC_Hours = Strtoul((const u8*)(argv[1]), (u8 **)NULL, 10);
|
||||
RTC_TimeStruct.RTC_Minutes = Strtoul((const u8*)(argv[2]), (u8 **)NULL, 10);
|
||||
RTC_TimeStruct.RTC_Seconds = Strtoul((const u8*)(argv[3]), (u8 **)NULL, 10);
|
||||
|
||||
if (_strcmp(argv[5], "pm") == 0) {
|
||||
RTC_TimeStruct.RTC_H12_PMAM = RTC_H12_PM;
|
||||
} else {
|
||||
RTC_TimeStruct.RTC_H12_PMAM = RTC_H12_AM;
|
||||
}
|
||||
|
||||
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
|
||||
}
|
||||
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
u32
|
||||
CmdWlanNormal(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
)
|
||||
{
|
||||
#if SUPPORT_INTERACTIVE_MODE
|
||||
|
||||
if(argc<1)
|
||||
{
|
||||
DBG_8195A("Wrong argument number!\r\n");
|
||||
return _FALSE;
|
||||
}
|
||||
|
||||
|
||||
DBG_8195A("Wlan Normal Mode\n");
|
||||
|
||||
WlanNormal( argc, argv);
|
||||
#endif
|
||||
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
u32
|
||||
CmdUartLog(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
)
|
||||
{
|
||||
if (_strcmp(argv[0], "set") == 0) {
|
||||
u32 rate = Strtoul((const u8*)(argv[1]), (u8 **)NULL, 10);
|
||||
u32 index = 0;
|
||||
|
||||
DBG_8195A("UlogRate: %d, reboot after set baudrate \n", rate);
|
||||
|
||||
while (1) {
|
||||
if (0xffffffff == BAUDRATE_TABLE_40M[index][0]) {
|
||||
DBG_8195A("UlogRate: Err \n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (rate == BAUDRATE_TABLE_40M[index][0]) {
|
||||
FLASH_EreaseDwordsXIP(FLASH_SYSTEM_DATA_ADDR + 0x30, 1);
|
||||
FLASH_TxData12BXIP(FLASH_SYSTEM_DATA_ADDR + 0x30, 4, (u8*)&rate);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
} else {
|
||||
u32 time = 0;
|
||||
u32 delta = 0;
|
||||
|
||||
time=SYSTIMER_TickGet();
|
||||
DBG_8195A("123456789a123456789\n");
|
||||
delta = SYSTIMER_TickGet() - time;
|
||||
|
||||
/* tick is 30.5 us */
|
||||
DBG_8195A("BaudRate: %d K\n", 200*1000*10/(delta*305));
|
||||
}
|
||||
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_stricmp(const char* str1, const char* str2)
|
||||
{
|
||||
char c1, c2;
|
||||
|
||||
do {
|
||||
c1 = *str1++;
|
||||
c2 = *str2++;
|
||||
if (c1 != c2) {
|
||||
char c1_upc = c1 | 0x20;
|
||||
if ((c1_upc >= 'a') && (c1_upc <= 'z')) {
|
||||
/* characters are not equal an one is in the alphabet range:
|
||||
downcase both chars and check again */
|
||||
char c2_upc = c2 | 0x20;
|
||||
if (c1_upc != c2_upc) {
|
||||
/* still not equal */
|
||||
/* don't care for < or > */
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
/* characters are not equal but none is in the alphabet range */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} while (c1 != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const COMMAND_TABLE UartLogRamCmdTable[] = {
|
||||
#if (CONFIG_INIC_EN == 0)
|
||||
{(const u8*)"?", 0, CmdRamHelp, (const u8*)"\tHELP (?) : \n"
|
||||
"\t\t Print help messag\n"},
|
||||
{(const u8*)"DW", 2, CmdDumpWord, (const u8*)"\tDW <Address, Hex>\n"
|
||||
"\t\t Dump memory dword or Read Hw dword register; \n"
|
||||
"\t\t Can Dump only one dword at the same time \n"
|
||||
"\t\t Unit: 4Bytes \n"},
|
||||
{(const u8*)"EW", 2, CmdWriteWord, (const u8*)"\tEW <Address, Hex>\n"
|
||||
"\t\t Write memory dword or Write Hw dword register \n"
|
||||
"\t\t Can write only one dword at the same time \n"
|
||||
"\t\t Ex: EW Address Value \n"},
|
||||
|
||||
{(const u8*)"DB", 2, CmdDumpByte, (const u8*)"\tDW <Address, Hex>\n"
|
||||
"\t\t Dump memory byte or Read Hw byte register; \n"
|
||||
"\t\t Can Dump only one byte at the same time \n"
|
||||
"\t\t Unit: 1Bytes \n"},
|
||||
{(const u8*)"EB", 2, CmdWriteByte, (const u8*)"\tEW <Address, Hex>\n"
|
||||
"\t\t Write memory byte or Write Hw byte register \n"
|
||||
"\t\t Can write only one byte at the same time \n"
|
||||
"\t\t Ex: EW Address Value \n"},
|
||||
{(const u8*)"FLASH", 8, CmdFlash, (const u8*)"\tFLASH \n"
|
||||
"\t\t erase chip \n"
|
||||
"\t\t erase sector addr \n"
|
||||
"\t\t erase block addr \n"
|
||||
"\t\t read addr len \n"
|
||||
"\t\t write addr data \n"},
|
||||
{(const u8*)"EFUSE", 8, CmdEfuse, (const u8*)"\tEFUSE \n"
|
||||
"\t\t wmap addr len data\n"
|
||||
"\t\t rmap \n"},
|
||||
{(const u8*)"REBOOT", 4, CmdReboot, (const u8*)"\tREBOOT \n"
|
||||
"\t\t reboot \n"
|
||||
"\t\t reboot uartburn \n"},
|
||||
{(const u8*)"TICKPS", 4, CmdTickPS, (const u8*)"\tTICKPS \n"
|
||||
"\t\t r: release os wakelock \n"
|
||||
"\t\t a: acquire os wakelock \n"},
|
||||
{(const u8*)"RTC", 4, CmdRTC, (const u8*)"\tRTC \n"
|
||||
"\t\t get\n"},
|
||||
{(const u8*)"WLAN", 4, CmdWlanNormal, (const u8*)"\tWLAN \n"
|
||||
"\t\t WLAN Driver Cmd\n"},
|
||||
{(const u8*)"ULOG", 4, CmdUartLog, (const u8*)"\tULOG \n"
|
||||
"\t\t set xxxx (like 3000000)\n"},
|
||||
#endif
|
||||
};
|
||||
|
||||
monitor_cmd_handler Get_HalCmd(char* argv)
|
||||
{
|
||||
u32 CmdCnt = 0;
|
||||
u32 CmdNum = (sizeof(UartLogRamCmdTable) / sizeof(COMMAND_TABLE));
|
||||
monitor_cmd_handler cmd_handler = NULL;
|
||||
|
||||
for (CmdCnt = 0; CmdCnt< CmdNum; CmdCnt++) {
|
||||
if ((cmd_stricmp(argv, UartLogRamCmdTable[CmdCnt].cmd))==0){
|
||||
cmd_handler = UartLogRamCmdTable[CmdCnt].func;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return cmd_handler;
|
||||
}
|
||||
|
||||
u32
|
||||
GetRamCmdNum(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (sizeof(UartLogRamCmdTable)/sizeof(COMMAND_TABLE));
|
||||
}
|
||||
|
||||
//======================================================
|
||||
//<Function>: CmdTest
|
||||
//<Usage >: This function is a demo test function.
|
||||
//<Argus >: argc --> number of argus
|
||||
// argv --> pointer to a cmd parameter array
|
||||
//<Return >: VOID
|
||||
//<Notes >: NA
|
||||
//======================================================
|
||||
|
||||
u32
|
||||
CmdRamHelp(
|
||||
IN u16 argc,
|
||||
IN u8 *argv[]
|
||||
)
|
||||
{
|
||||
u32 LoopINdex ;
|
||||
|
||||
DBG_8195A("----------------- COMMAND MODE HELP ------------------\n");
|
||||
for( LoopINdex=0 ; LoopINdex < (sizeof(UartLogRamCmdTable) / sizeof(COMMAND_TABLE)) ; LoopINdex++ )
|
||||
{
|
||||
if( UartLogRamCmdTable[LoopINdex].msg )
|
||||
{
|
||||
DBG_8195A( "%s\n",UartLogRamCmdTable[LoopINdex].msg );
|
||||
}
|
||||
}
|
||||
DBG_8195A("----------------- COMMAND MODE END ------------------\n");
|
||||
|
||||
return _TRUE ;
|
||||
}
|
||||
|
||||
521
lib/amb1_sdk/soc/realtek/8711b/app/monitor/ram/rtl_consol.c
Normal file
521
lib/amb1_sdk/soc/realtek/8711b/app/monitor/ram/rtl_consol.c
Normal file
@@ -0,0 +1,521 @@
|
||||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "ameba_soc.h"
|
||||
#include "osdep_service.h"
|
||||
#include <stdarg.h>
|
||||
#include "rtl_consol.h"
|
||||
#include "strproc.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <event_groups.h>
|
||||
#include "semphr.h"
|
||||
|
||||
extern volatile UART_LOG_CTL UartLogCtl;
|
||||
extern volatile UART_LOG_CTL *pUartLogCtl;
|
||||
extern u8 *ArgvArray[MAX_ARGV];
|
||||
extern UART_LOG_BUF UartLogBuf;
|
||||
|
||||
extern COMMAND_TABLE UartLogRamCmdTable[];
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
extern u8 UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN];
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL
|
||||
u32 Consol_TaskRdy;
|
||||
_sema Consol_Sema;
|
||||
#else
|
||||
// Since ROM code will reference this typedef, so keep the typedef same size
|
||||
u32 Consol_TaskRdy;
|
||||
void *Consol_Sema;
|
||||
#endif
|
||||
|
||||
extern monitor_cmd_handler Get_HalCmd(char* argv);
|
||||
|
||||
_LONG_CALL_
|
||||
extern u8
|
||||
UartLogCmdChk(
|
||||
IN u8 RevData,
|
||||
IN UART_LOG_CTL *prvUartLogCtl,
|
||||
IN u8 EchoFlag
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern VOID
|
||||
ArrayInitialize(
|
||||
IN u8 *pArrayToInit,
|
||||
IN u8 ArrayLen,
|
||||
IN u8 InitValue
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern VOID
|
||||
UartLogHistoryCmd(
|
||||
IN u8 RevData,
|
||||
IN UART_LOG_CTL *prvUartLogCtl,
|
||||
IN u8 EchoFlag
|
||||
);
|
||||
|
||||
//=================================================
|
||||
|
||||
|
||||
/* Minimum and maximum values a `signed long int' can hold.
|
||||
(Same as `int'). */
|
||||
#ifndef __LONG_MAX__
|
||||
#if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9) || defined (__s390x__)
|
||||
#define __LONG_MAX__ 9223372036854775807L
|
||||
#else
|
||||
#define __LONG_MAX__ 2147483647L
|
||||
#endif /* __alpha__ || sparc64 */
|
||||
#endif
|
||||
#undef LONG_MIN
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
#undef LONG_MAX
|
||||
#define LONG_MAX __LONG_MAX__
|
||||
|
||||
/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
|
||||
#undef ULONG_MAX
|
||||
#define ULONG_MAX (LONG_MAX * 2UL + 1)
|
||||
|
||||
#ifndef __LONG_LONG_MAX__
|
||||
#define __LONG_LONG_MAX__ 9223372036854775807LL
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//======================================================
|
||||
//<Function>: UartLogIrqHandleRam
|
||||
//<Usage >: To deal with Uart-Log RX IRQ
|
||||
//<Argus >: VOID
|
||||
//<Return >: VOID
|
||||
//<Notes >: NA
|
||||
//======================================================
|
||||
VOID
|
||||
UartLogIrqHandleRam
|
||||
(
|
||||
VOID * Data
|
||||
)
|
||||
{
|
||||
volatile u8 reg_iir;
|
||||
reg_iir = UART_IntStatus(UART2_DEV);
|
||||
if ((reg_iir & RUART_IIR_INT_PEND) != 0) {
|
||||
// No pending IRQ
|
||||
return;
|
||||
}
|
||||
|
||||
u8 UartReceiveData = 0;
|
||||
//For Test
|
||||
BOOL PullMode = _FALSE;
|
||||
|
||||
u32 IrqEn = DiagGetIsrEnReg();
|
||||
|
||||
DiagSetIsrEnReg(0);
|
||||
|
||||
UartReceiveData = DiagGetChar(PullMode);
|
||||
|
||||
//KB_ESC chk is for cmd history, it's a special case here.
|
||||
if (UartReceiveData == KB_ASCII_ESC) {
|
||||
//4 Esc detection is only valid in the first stage of boot sequence (few seconds)
|
||||
if (pUartLogCtl->ExecuteEsc != _TRUE)
|
||||
{
|
||||
pUartLogCtl->ExecuteEsc = _TRUE;
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//4 the input commands are valid only when the task is ready to execute commands
|
||||
if ((pUartLogCtl->BootRdy == 1)
|
||||
#ifdef CONFIG_KERNEL
|
||||
||(Consol_TaskRdy == 1)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if ((*pUartLogCtl).EscSTS==0)
|
||||
{
|
||||
(*pUartLogCtl).EscSTS = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((*pUartLogCtl).EscSTS==1){
|
||||
if (UartReceiveData != KB_ASCII_LBRKT){
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
}
|
||||
else{
|
||||
(*pUartLogCtl).EscSTS = 2;
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
if ((*pUartLogCtl).EscSTS==2){
|
||||
(*pUartLogCtl).EscSTS = 0;
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
if ((UartReceiveData=='A')|| UartReceiveData=='B'){
|
||||
UartLogHistoryCmd(UartReceiveData,(UART_LOG_CTL *)pUartLogCtl,1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
if (UartLogCmdChk(UartReceiveData,(UART_LOG_CTL *)pUartLogCtl,1)==2)
|
||||
{
|
||||
//4 check UartLog buffer to prevent from incorrect access
|
||||
if (pUartLogCtl->pTmpLogBuf != NULL)
|
||||
{
|
||||
pUartLogCtl->ExecuteCmd = _TRUE;
|
||||
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||
if (Consol_TaskRdy)
|
||||
rtw_up_sema_from_isr((_sema *)&Consol_Sema);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayInitialize((u8 *)pUartLogCtl->pTmpLogBuf->UARTLogBuf, UART_LOG_CMD_BUFLEN, '\0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DiagSetIsrEnReg(IrqEn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID
|
||||
RtlConsolInitRam(
|
||||
IN u32 Boot,
|
||||
IN u32 TBLSz,
|
||||
IN VOID *pTBL
|
||||
)
|
||||
{
|
||||
u32 stack_size = 0;
|
||||
|
||||
UartLogBuf.BufCount = 0;
|
||||
ArrayInitialize(&UartLogBuf.UARTLogBuf[0],UART_LOG_CMD_BUFLEN,'\0');
|
||||
pUartLogCtl = &UartLogCtl;
|
||||
|
||||
pUartLogCtl->NewIdx = 0;
|
||||
pUartLogCtl->SeeIdx = 0;
|
||||
pUartLogCtl->RevdNo = 0;
|
||||
pUartLogCtl->EscSTS = 0;
|
||||
pUartLogCtl->BootRdy = 0;
|
||||
pUartLogCtl->pTmpLogBuf = &UartLogBuf;
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
pUartLogCtl->CRSTS = 0;
|
||||
pUartLogCtl->pHistoryBuf = &UartLogHistoryBuf[0];
|
||||
#endif
|
||||
pUartLogCtl->pfINPUT = (VOID*)&DiagPrintf;
|
||||
pUartLogCtl->pCmdTbl = (PCOMMAND_TABLE) pTBL;
|
||||
pUartLogCtl->CmdTblSz = TBLSz;
|
||||
#ifdef CONFIG_KERNEL
|
||||
Consol_TaskRdy = 0;
|
||||
#endif
|
||||
//executing boot sequence
|
||||
if (Boot == ROM_STAGE)
|
||||
{
|
||||
pUartLogCtl->ExecuteCmd = _FALSE;
|
||||
pUartLogCtl->ExecuteEsc = _FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pUartLogCtl->ExecuteCmd = _FALSE;
|
||||
pUartLogCtl->ExecuteEsc= _TRUE;//don't check Esc anymore
|
||||
#if defined(CONFIG_KERNEL)
|
||||
/* Create a Semaphone */
|
||||
rtw_init_sema((_sema*)&(Consol_Sema), 0);
|
||||
Consol_TaskRdy = 0;
|
||||
|
||||
stack_size = 512;
|
||||
#if defined (__GNUC__) /* for Verification need more stack */
|
||||
stack_size += 1024;
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
if (pdTRUE != xTaskCreate( RtlConsolTaskRam, (const char * const)"LOGUART_TASK", stack_size, NULL, tskIDLE_PRIORITY + 5 , NULL))
|
||||
{
|
||||
DiagPrintf("Create Log UART Task Err!!\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
CONSOLE_AMEBA();
|
||||
}
|
||||
|
||||
extern u8** GetArgv(const u8 *string);
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
extern char log_buf[LOG_SERVICE_BUFLEN];
|
||||
extern _sema log_rx_interrupt_sema;
|
||||
#endif
|
||||
//======================================================
|
||||
u32 console_cmd_exec(u8 argc, u8 **argv)
|
||||
{
|
||||
#if defined(CONFIG_WIFI_NORMAL)
|
||||
if(argc == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
rtw_up_sema((_sema *)&log_rx_interrupt_sema);
|
||||
#endif
|
||||
ArrayInitialize(argv[0], sizeof(argv[0]) ,0);
|
||||
|
||||
//(*pUartLogBuf).BufCount = 0;
|
||||
//ArrayInitialize(&(*pUartLogBuf).UARTLogBuf[0], UART_LOG_CMD_BUFLEN, '\0');
|
||||
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
//======================================================
|
||||
// overload original RtlConsolTaskRam
|
||||
|
||||
u32
|
||||
UartLogCmdExecuteRam(
|
||||
u8 argc, u8 **argv
|
||||
){
|
||||
monitor_cmd_handler cmd_handler = NULL;
|
||||
|
||||
if (argc > 0){
|
||||
cmd_handler = Get_HalCmd(argv[0]);
|
||||
|
||||
#if 0
|
||||
if (cmd_handler == NULL) {
|
||||
cmd_handler = Get_TestCmd(argv[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cmd_handler != NULL) {
|
||||
StrUpr(argv[0]);
|
||||
cmd_handler((argc-1) , (argv+1));
|
||||
ArrayInitialize(argv[0], sizeof(argv[0]) ,0);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//(*pUartLogBuf).BufCount = 0;
|
||||
//ArrayInitialize(&(*pUartLogBuf).UARTLogBuf[0], UART_LOG_CMD_BUFLEN, '\0');
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
RtlConsolTaskRam(
|
||||
VOID *Data
|
||||
)
|
||||
{
|
||||
u32 ret = TRUE;
|
||||
|
||||
#if defined(CONFIG_WIFI_NORMAL)
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
log_service_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//4 Set this for UartLog check cmd history
|
||||
#ifdef CONFIG_KERNEL
|
||||
Consol_TaskRdy = 1;
|
||||
#endif
|
||||
#ifndef CONFIG_KERNEL
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
#endif
|
||||
do{
|
||||
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||
rtw_down_sema((_sema *)&Consol_Sema);
|
||||
#endif
|
||||
if (pUartLogCtl->ExecuteCmd) {
|
||||
u8 argc = 0;
|
||||
u8 **argv;
|
||||
PUART_LOG_BUF pUartLogBuf = pUartLogCtl->pTmpLogBuf;
|
||||
#if defined(CONFIG_WIFI_NORMAL)
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
_strncpy(log_buf, (const u8*)&(*pUartLogBuf).UARTLogBuf[0], LOG_SERVICE_BUFLEN-1);
|
||||
#endif
|
||||
#endif
|
||||
argc = GetArgc((const u8*)&((*pUartLogBuf).UARTLogBuf[0]));
|
||||
argv = GetArgv((const u8*)&((*pUartLogBuf).UARTLogBuf[0])); /* UARTLogBuf will be changed */
|
||||
|
||||
if (argc > 0) {
|
||||
/* FPGA Verification */
|
||||
ret = UartLogCmdExecuteRam(argc, argv);
|
||||
|
||||
/* normal for LOG service */
|
||||
if (ret == FALSE) {
|
||||
ret = console_cmd_exec(argc, argv);
|
||||
}
|
||||
|
||||
(*pUartLogBuf).BufCount = 0;
|
||||
ArrayInitialize(&(*pUartLogBuf).UARTLogBuf[0], UART_LOG_CMD_BUFLEN, '\0');
|
||||
} else {
|
||||
/*In some exception case, even if argc parsed is 0(when the first character value in log buffer is '\0'),
|
||||
log buffer may not be empty and log buffer counter may not be zero. If not clean log buffer and counter
|
||||
, some error will happen. Therefore, clean log buffer and initialize buffer counter when it occurs.*/
|
||||
if((*pUartLogBuf).BufCount != 0) {
|
||||
(*pUartLogBuf).BufCount = 0;
|
||||
ArrayInitialize(&(*pUartLogBuf).UARTLogBuf[0], UART_LOG_CMD_BUFLEN, '\0');
|
||||
}
|
||||
CONSOLE_AMEBA();
|
||||
}
|
||||
pUartLogCtl->ExecuteCmd = _FALSE;
|
||||
|
||||
pmu_set_sysactive_time(10000);
|
||||
}
|
||||
}while(1);
|
||||
}
|
||||
|
||||
|
||||
//======================================================
|
||||
#if BUFFERED_PRINTF
|
||||
//print log buffer length, if buffer get full, the extra logs will be discarded.
|
||||
#define MAX_PRINTF_BUF_LEN 1024
|
||||
|
||||
xTaskHandle print_task = NULL;
|
||||
EventGroupHandle_t print_event = NULL;
|
||||
char print_buffer[MAX_PRINTF_BUF_LEN];
|
||||
int flush_idx = 0;
|
||||
int used_length = 0;
|
||||
|
||||
int available_space(void)
|
||||
{
|
||||
return MAX_PRINTF_BUF_LEN-used_length;
|
||||
}
|
||||
|
||||
int buffered_printf(const char* fmt, ...)
|
||||
{
|
||||
if((print_task==NULL) || (print_event==NULL) )
|
||||
return 0;
|
||||
char tmp_buffer[UART_LOG_CMD_BUFLEN+1];
|
||||
static int print_idx = 0;
|
||||
int cnt;
|
||||
va_list arglist;
|
||||
|
||||
if(xEventGroupGetBits(print_event)!=1)
|
||||
xEventGroupSetBits(print_event, 1);
|
||||
|
||||
memset(tmp_buffer,0,UART_LOG_CMD_BUFLEN+1);
|
||||
va_start(arglist, fmt);
|
||||
rtl_vsnprintf(tmp_buffer, sizeof(tmp_buffer), fmt, arglist);
|
||||
va_end(arglist);
|
||||
|
||||
cnt = _strlen(tmp_buffer);
|
||||
if(cnt < available_space()){
|
||||
if(print_idx >= flush_idx){
|
||||
if(MAX_PRINTF_BUF_LEN-print_idx >= cnt){
|
||||
memcpy(&print_buffer[print_idx], tmp_buffer, cnt);
|
||||
}else{
|
||||
memcpy(&print_buffer[print_idx], tmp_buffer, MAX_PRINTF_BUF_LEN-print_idx);
|
||||
memcpy(&print_buffer[0], &tmp_buffer[MAX_PRINTF_BUF_LEN-print_idx], cnt-(MAX_PRINTF_BUF_LEN-print_idx));
|
||||
}
|
||||
}else{ // space is flush_idx - print_idx, and available space is enough
|
||||
memcpy(&print_buffer[print_idx], tmp_buffer, cnt);
|
||||
}
|
||||
// protection needed
|
||||
taskENTER_CRITICAL();
|
||||
used_length+=cnt;
|
||||
taskEXIT_CRITICAL();
|
||||
print_idx+=cnt;
|
||||
if(print_idx>=MAX_PRINTF_BUF_LEN)
|
||||
print_idx -= MAX_PRINTF_BUF_LEN;
|
||||
}else{
|
||||
// skip
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
void printing_task(void* arg)
|
||||
{
|
||||
while(1){
|
||||
//wait event
|
||||
if(xEventGroupWaitBits(print_event, 1, pdFALSE, pdFALSE, 100 ) == 1){
|
||||
while(used_length > 0){
|
||||
DiagPutChar(print_buffer[flush_idx]);
|
||||
flush_idx++;
|
||||
if(flush_idx >= MAX_PRINTF_BUF_LEN)
|
||||
flush_idx-=MAX_PRINTF_BUF_LEN;
|
||||
taskENTER_CRITICAL();
|
||||
used_length--;
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
// clear event
|
||||
xEventGroupClearBits( print_event, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rtl_printf_init()
|
||||
{
|
||||
if(print_event==NULL){
|
||||
print_event = xEventGroupCreate();
|
||||
if(print_event == NULL)
|
||||
printf("\n\rprint event init fail!\n");
|
||||
}
|
||||
if(print_task == NULL){
|
||||
if(xTaskCreate(printing_task, (const char *)"print_task", 512, NULL, tskIDLE_PRIORITY + 1, &print_task) != pdPASS)
|
||||
printf("\n\rprint task init fail!\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//======================================================
|
||||
|
||||
/**
|
||||
* @brief Set UartLog Baud Rate use baudrate val.
|
||||
* @param BaudRate: Baud Rate Val, like 115200 (unit is HZ).
|
||||
* @retval True/False
|
||||
*/
|
||||
int LOGUART_SetBaud(u32 BaudRate)
|
||||
{
|
||||
UART_INTConfig(UART2_DEV, RUART_IER_ERBI | RUART_IER_ELSI, DISABLE);
|
||||
UART_RxCmd(UART2_DEV, DISABLE);
|
||||
|
||||
while (UART_Writable(UART2_DEV) == 0);
|
||||
|
||||
UART_SetBaud(UART2_DEV, BaudRate);
|
||||
|
||||
UART_INTConfig(UART2_DEV, RUART_IER_ERBI | RUART_IER_ELSI, ENABLE);
|
||||
UART_RxCmd(UART2_DEV, ENABLE);
|
||||
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
void LOGUART_SetBaud_FromFlash(void)
|
||||
{
|
||||
SYSTEM_DATA *SysData = (SYSTEM_DATA *)(SPI_FLASH_BASE + FLASH_SYSTEM_DATA_ADDR);
|
||||
|
||||
/* 0xFFFFFFFF is 115200 */
|
||||
if (SysData->UlogRate != 0xFFFFFFFF) {
|
||||
DBG_8195A("LOGUART_SetBaud %d \n\n", SysData->UlogRate);
|
||||
LOGUART_SetBaud(SysData->UlogRate);
|
||||
}
|
||||
}
|
||||
|
||||
VOID ReRegisterPlatformLogUart(VOID)
|
||||
{
|
||||
DIAG_UartReInit((IRQ_FUN) UartLogIrqHandleRam);
|
||||
NVIC_SetPriority(UART_LOG_IRQ, 10); /* this is rom_code_patch */
|
||||
|
||||
LOGUART_SetBaud_FromFlash();
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((u32)RAM_STAGE,(u32)GetRamCmdNum(),(VOID*)UartLogRamCmdTable);
|
||||
#else
|
||||
RtlConsolInitRam((u32)ROM_STAGE,(u32)GetRamCmdNum(),(VOID*)UartLogRamCmdTable);
|
||||
#endif
|
||||
|
||||
#if BUFFERED_PRINTF
|
||||
rtl_printf_init();
|
||||
#endif
|
||||
}
|
||||
88
lib/amb1_sdk/soc/realtek/8711b/app/monitor/ram/rtl_trace.c
Normal file
88
lib/amb1_sdk/soc/realtek/8711b/app/monitor/ram/rtl_trace.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtl_trace.c
|
||||
* @author
|
||||
* @version V1.0.0
|
||||
* @date 2016-05-17
|
||||
* @brief This file contains all the functions for log print and mask.
|
||||
******************************************************************************
|
||||
* @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) 2015, Realtek Semiconductor Corporation. All rights reserved.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "ameba_soc.h"
|
||||
#include "platform_stdlib.h"
|
||||
|
||||
extern void rtl_libc_init(void);
|
||||
|
||||
const char *debug_prefix[MODULE_NUMs] = {
|
||||
"OS", // = 0, /**< FreeRTOS */
|
||||
"BOOT", // = 1, /**< bootloader */
|
||||
"GDMA", // = 2, /**< gdma */
|
||||
"GPIO", // = 3, /**< gpio */
|
||||
"TIMER", // = 4, /**< timer */
|
||||
"I2C", // = 5, /**< i2c */
|
||||
"I2S", // = 6, /**< i2s */
|
||||
"PWM", // = 7, /**< pwm */
|
||||
"SDIO", // = 8, /**< sdio */
|
||||
"SPI", // = 9, /**< spi */
|
||||
"FLASH", // = 10, /**< flash */
|
||||
"UART", // = 11, /**< uart */
|
||||
"USOC", // = 12, /**< usoc */
|
||||
"IPSEC", // = 13, /**< ipsec */
|
||||
"ADC", // = 14, /**< adc */
|
||||
"EFUSE", // = 15, /**< efuse */
|
||||
"MONIT", // = 16, /**< monitor */
|
||||
"MISC", // = 17, /**< misc */
|
||||
};
|
||||
|
||||
const char *debug_level[LEVEL_NUMs] = {
|
||||
"E", //LEVEL_ERROR = 0
|
||||
"W", //LEVEL_WARN = 1
|
||||
"I", //LEVEL_INFO = 2
|
||||
"T" //LEVEL_TRACE = 3
|
||||
};
|
||||
|
||||
u32 ConfigDebug[LEVEL_NUMs];
|
||||
|
||||
|
||||
void LOG_MASK(u32 config[])
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < LEVEL_NUMs; i++) {
|
||||
ConfigDebug[i] = config[i];
|
||||
}
|
||||
}
|
||||
|
||||
void LOG_MASK_MODULE(u32 module, u32 level, u32 new_status)
|
||||
{
|
||||
if (new_status == ENABLE) {
|
||||
ConfigDebug[level] |= BIT(module);
|
||||
} else {
|
||||
ConfigDebug[level] &= ~BIT(module);
|
||||
}
|
||||
}
|
||||
|
||||
void LOG_PRINTF(u32 module, u32 level, u32 line, const char*fmt, ...)
|
||||
{
|
||||
static char print_buffer[256];
|
||||
u32 len = 0;
|
||||
va_list ap;
|
||||
|
||||
rtl_libc_init();
|
||||
|
||||
len = DiagSPrintf(print_buffer, "[%s-%s-%d]: ", debug_prefix[module], debug_level[level], line);
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsnprintf(print_buffer + len, 256 - len, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
DiagPrintf(print_buffer);
|
||||
}
|
||||
/******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
|
||||
Reference in New Issue
Block a user