initial commit
This commit is contained in:
247
lib/amb1_sdk/soc/realtek/8195a/misc/driver/console_hs_uart.c
Normal file
247
lib/amb1_sdk/soc/realtek/8195a/misc/driver/console_hs_uart.c
Normal file
@@ -0,0 +1,247 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2016 Realtek Corporation. All rights reserved.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#include <platform_opts.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "semphr.h"
|
||||
#include "device.h"
|
||||
#include "serial_api.h"
|
||||
#include "at_cmd/log_service.h"
|
||||
#include "osdep_service.h"
|
||||
#include "serial_ex_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
char hs_uart_ready = 0; // used to switch between loguart and high speed uart
|
||||
// 0: loguart
|
||||
// 1: highspeed uart
|
||||
|
||||
// select uart tx/rx pin with gpio interrupt function
|
||||
#define UART_TX PA_7
|
||||
#define UART_RX PA_6
|
||||
|
||||
#define KEY_NL 0xa // '\n'
|
||||
#define KEY_ENTER 0xd // '\r'
|
||||
#define KEY_BS 0x8
|
||||
#define KEY_ESC 0x1B
|
||||
#define KEY_LBRKT 0x5B
|
||||
#define STR_END_OF_MP_FORMAT "\r\n\r\r#"
|
||||
|
||||
|
||||
#define CMD_HISTORY_LEN 4 // max number of executed command saved
|
||||
extern char log_buf[LOG_SERVICE_BUFLEN];
|
||||
extern xSemaphoreHandle log_rx_interrupt_sema;
|
||||
char cmd_history[CMD_HISTORY_LEN][LOG_SERVICE_BUFLEN];
|
||||
static unsigned int cmd_history_count = 0;
|
||||
|
||||
serial_t loguart_sobj;
|
||||
//_sema at_printf_sema;
|
||||
_sema hs_uart_dma_tx_sema;
|
||||
|
||||
#define HS_UART_USE_DMA_TX 1
|
||||
|
||||
void hs_uart_put_char(u8 c){
|
||||
serial_putc(&loguart_sobj, c);
|
||||
}
|
||||
|
||||
void hs_uart_send_string(char *str)
|
||||
{
|
||||
unsigned int i=0;
|
||||
while (str[i] != '\0') {
|
||||
serial_putc(&loguart_sobj, str[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
#if UART_AT_USE_DMA_TX
|
||||
static void hs_uart_send_buf_done(uint32_t id)
|
||||
{
|
||||
//serial_t *sobj = (serial_t *)id;
|
||||
|
||||
rtw_up_sema_from_isr(&uart_at_dma_tx_sema);
|
||||
}
|
||||
#endif
|
||||
|
||||
void hs_uart_send_buf(u8 *buf, u32 len)
|
||||
{
|
||||
unsigned char *st_p=buf;
|
||||
if(!len || (!buf)){
|
||||
return;
|
||||
}
|
||||
#if UART_AT_USE_DMA_TX
|
||||
int ret;
|
||||
while(rtw_down_sema(&uart_at_dma_tx_sema) == _TRUE){
|
||||
ret = serial_send_stream_dma(&loguart_sobj, st_p, len);
|
||||
if(ret != HAL_OK){
|
||||
rtw_up_sema(&uart_at_dma_tx_sema);
|
||||
return;
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
while(len){
|
||||
serial_putc(&loguart_sobj, *st_p);
|
||||
st_p++;
|
||||
len--;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hs_uart_irq(uint32_t id, SerialIrq event)
|
||||
{
|
||||
serial_t *sobj = (serial_t *)id;
|
||||
unsigned char rc=0;
|
||||
static unsigned char temp_buf[LOG_SERVICE_BUFLEN] = "\0";
|
||||
static unsigned char combo_key = 0;
|
||||
static unsigned short buf_count = 0;
|
||||
static unsigned char key_enter = 0;
|
||||
static char cmd_history_index = 0;
|
||||
if(event == RxIrq) {
|
||||
rc = serial_getc(sobj);
|
||||
|
||||
if(key_enter && rc == KEY_NL){
|
||||
//serial_putc(sobj, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
if(rc == KEY_ESC){
|
||||
combo_key = 1;
|
||||
}else if(combo_key == 1){
|
||||
if(rc == KEY_LBRKT)
|
||||
combo_key = 2;
|
||||
else
|
||||
combo_key = 0;
|
||||
}else if(combo_key == 2){
|
||||
if(rc == 'A' || rc == 'B'){ // UP or Down
|
||||
if(rc == 'A'){
|
||||
cmd_history_index--;
|
||||
if(cmd_history_index < 0)
|
||||
cmd_history_index = (cmd_history_count>CMD_HISTORY_LEN)?CMD_HISTORY_LEN-1:(cmd_history_count-1)%CMD_HISTORY_LEN;
|
||||
}else{
|
||||
cmd_history_index++;
|
||||
if(cmd_history_index > (cmd_history_count>CMD_HISTORY_LEN?CMD_HISTORY_LEN-1:(cmd_history_count-1)%CMD_HISTORY_LEN))
|
||||
cmd_history_index = 0;
|
||||
}
|
||||
|
||||
if(cmd_history_count > 0){
|
||||
buf_count = strlen(temp_buf);
|
||||
rtw_memset(temp_buf,'\0',buf_count);
|
||||
while(--buf_count >= 0){
|
||||
serial_putc(sobj, KEY_BS);
|
||||
serial_putc(sobj, ' ');
|
||||
serial_putc(sobj, KEY_BS);
|
||||
}
|
||||
hs_uart_send_string(cmd_history[cmd_history_index%CMD_HISTORY_LEN]);
|
||||
strncpy(temp_buf, cmd_history[cmd_history_index%CMD_HISTORY_LEN], LOG_SERVICE_BUFLEN);
|
||||
buf_count = strlen(temp_buf);
|
||||
}
|
||||
}
|
||||
|
||||
// exit combo
|
||||
combo_key = 0;
|
||||
}
|
||||
else if(rc == KEY_ENTER){
|
||||
key_enter = 1;
|
||||
if(buf_count>0){
|
||||
serial_putc(sobj, KEY_NL);
|
||||
serial_putc(sobj, KEY_ENTER);
|
||||
rtw_memset(log_buf,'\0',LOG_SERVICE_BUFLEN);
|
||||
strncpy(log_buf,(char *)&temp_buf[0],buf_count);
|
||||
rtw_up_sema_from_isr(&log_rx_interrupt_sema);
|
||||
rtw_memset(temp_buf,'\0',buf_count);
|
||||
|
||||
/* save command */
|
||||
rtw_memset(cmd_history[((cmd_history_count)%CMD_HISTORY_LEN)], '\0', buf_count+1);
|
||||
strncpy(cmd_history[((cmd_history_count++)%CMD_HISTORY_LEN)], log_buf, LOG_SERVICE_BUFLEN);
|
||||
cmd_history_index = cmd_history_count%CMD_HISTORY_LEN;
|
||||
//cmd_history_count++;
|
||||
buf_count=0;
|
||||
}else{
|
||||
hs_uart_send_string(STR_END_OF_MP_FORMAT);
|
||||
}
|
||||
}
|
||||
else if(rc == KEY_BS){
|
||||
if(buf_count>0){
|
||||
buf_count--;
|
||||
temp_buf[buf_count] = '\0';
|
||||
|
||||
serial_putc(sobj, rc);
|
||||
serial_putc(sobj, ' ');
|
||||
serial_putc(sobj, rc);
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* cache input characters */
|
||||
if(buf_count < (LOG_SERVICE_BUFLEN - 1)){
|
||||
temp_buf[buf_count] = rc;
|
||||
buf_count++;
|
||||
serial_putc(sobj, rc);
|
||||
key_enter = 0;
|
||||
}
|
||||
else if(buf_count == (LOG_SERVICE_BUFLEN - 1)){
|
||||
temp_buf[buf_count] = '\0';
|
||||
|
||||
hs_uart_send_string("\r\nERROR:exceed size limit"STR_END_OF_ATCMD_RET);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void console_init_hs_uart(void)
|
||||
{
|
||||
serial_init(&loguart_sobj,UART_TX,UART_RX);
|
||||
serial_baud(&loguart_sobj,38400);
|
||||
serial_format(&loguart_sobj, 8, ParityNone, 1);
|
||||
|
||||
#if UART_AT_USE_DMA_TX
|
||||
rtw_init_sema(&hs_uart_dma_tx_sema, 1);
|
||||
serial_send_comp_handler(&loguart_sobj, (void*)hs_uart_send_buf_done, (uint32_t)&loguart_sobj);
|
||||
#endif
|
||||
|
||||
serial_irq_handler(&loguart_sobj, hs_uart_irq, (uint32_t)&loguart_sobj);
|
||||
serial_irq_set(&loguart_sobj, RxIrq, 1);
|
||||
|
||||
for(char i=0; i<CMD_HISTORY_LEN; i++)
|
||||
memset(cmd_history[i], '\0', LOG_SERVICE_BUFLEN);
|
||||
|
||||
/* indicate low level layer that hs uart is ready */
|
||||
hs_uart_ready = 1;
|
||||
}
|
||||
|
||||
int use_mode;
|
||||
|
||||
|
||||
VOID HalSerialPutcRtl8195a(
|
||||
IN u8 c
|
||||
)
|
||||
{
|
||||
extern char hs_uart_ready;
|
||||
extern void hs_uart_put_char(u8 c);
|
||||
if(hs_uart_ready)
|
||||
hs_uart_put_char(c);
|
||||
}
|
||||
|
||||
void console_init(void)
|
||||
{
|
||||
sys_log_uart_off();
|
||||
console_init_hs_uart();
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((u32)RAM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#else
|
||||
RtlConsolInitRam((u32)ROM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#endif
|
||||
|
||||
#if BUFFERED_PRINTF
|
||||
rtl_printf_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
166
lib/amb1_sdk/soc/realtek/8195a/misc/driver/console_i2c.c
Normal file
166
lib/amb1_sdk/soc/realtek/8195a/misc/driver/console_i2c.c
Normal file
@@ -0,0 +1,166 @@
|
||||
#include <platform_opts.h>
|
||||
#include "serial_api.h"
|
||||
#include "serial_ex_api.h"
|
||||
#include "PinNames.h"
|
||||
#include "i2c_api.h"
|
||||
#include "pinmap.h"
|
||||
#include "ex_api.h"
|
||||
|
||||
#define MBED_I2C_MTR_SDA PB_3 //i2c3
|
||||
#define MBED_I2C_MTR_SCL PB_2
|
||||
|
||||
#define UART_BAUDRATE 115200
|
||||
|
||||
#define MBED_I2C_SLAVE_ADDR0 0x4D // 0x9A //
|
||||
#define MBED_I2C_BUS_CLK 500000 //hz *Remind that in baud rate 9600 or 19200, 100000hz is suitable*
|
||||
|
||||
static i2c_t i2cmaster;
|
||||
|
||||
#define I2C_DATA_LENGTH 2
|
||||
static char i2cdatardsrc[I2C_DATA_LENGTH];
|
||||
static char i2cdatarddst[I2C_DATA_LENGTH];
|
||||
|
||||
const u8 DLL = 921600/UART_BAUDRATE;
|
||||
|
||||
char ctrl_initial_1[2] = {0x03 << 3,0x80};
|
||||
char ctrl_initial_2[2] = {0x00 << 3,921600/UART_BAUDRATE};
|
||||
char ctrl_initial_3[2] = {0x01 << 3,0x00};
|
||||
char ctrl_initial_4[2] = {0x03 << 3,0xbf};
|
||||
char ctrl_initial_5[2] = {0x02 << 3,0x10};
|
||||
char ctrl_initial_6[2] = {0x03 << 3,0x03};
|
||||
char ctrl_initial_7[2] = {0x02 << 3,0x06};
|
||||
char ctrl_initial_8[2] = {0x02 << 3,0x01};
|
||||
//end i2c
|
||||
|
||||
|
||||
// Master// Tx
|
||||
#define CLEAR_MST_TXC_FLAG (masterTXC = 0)
|
||||
#define SET_MST_TXC_FLAG (masterTXC = 1)
|
||||
#define WAIT_MST_TXC while(masterTXC == 0){;}
|
||||
|
||||
volatile int masterTXC;
|
||||
static char i2c_ready = 0;
|
||||
|
||||
|
||||
static void i2c_master_rxc_callback(void *userdata)
|
||||
{
|
||||
|
||||
int i2clocalcnt;
|
||||
int result = 0;
|
||||
|
||||
// verify result
|
||||
result = 1;
|
||||
for (i2clocalcnt = 0; i2clocalcnt < I2C_DATA_LENGTH; i2clocalcnt++) {
|
||||
if (i2cdatarddst[i2clocalcnt] != i2cdatardsrc[i2clocalcnt]) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void i2c_master_txc_callback(void *userdata)
|
||||
{
|
||||
SET_MST_TXC_FLAG;
|
||||
}
|
||||
|
||||
static void i2c_master_write(void)
|
||||
{
|
||||
|
||||
//DBG_8195A("Mst-W\n");
|
||||
CLEAR_MST_TXC_FLAG;
|
||||
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_1[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_2[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_3[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_4[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_5[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_6[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_7[0], 2, 1);
|
||||
i2c_write(&i2cmaster, MBED_I2C_SLAVE_ADDR0, &ctrl_initial_8[0], 2, 1);
|
||||
|
||||
WAIT_MST_TXC;
|
||||
|
||||
}
|
||||
|
||||
static void i2c_master_enable(void)
|
||||
{
|
||||
_memset(&i2cmaster, 0x00, sizeof(i2c_t));
|
||||
i2c_init(&i2cmaster, MBED_I2C_MTR_SDA ,MBED_I2C_MTR_SCL);
|
||||
i2c_frequency(&i2cmaster,MBED_I2C_BUS_CLK);
|
||||
i2c_set_user_callback(&i2cmaster, I2C_RX_COMPLETE, i2c_master_rxc_callback);
|
||||
i2c_set_user_callback(&i2cmaster, I2C_TX_COMPLETE, i2c_master_txc_callback);
|
||||
//i2c_set_user_callback(&i2cmaster, I2C_ERR_OCCURRED, i2c_master_err_callback);
|
||||
|
||||
}
|
||||
|
||||
void i2c_redirect_init(void)
|
||||
{
|
||||
|
||||
// prepare for transmission
|
||||
|
||||
_memset(&i2cdatardsrc[0], 0x00, I2C_DATA_LENGTH);
|
||||
_memset(&i2cdatarddst[0], 0x00, I2C_DATA_LENGTH);
|
||||
|
||||
i2c_ready = 1;
|
||||
|
||||
i2c_master_enable();
|
||||
i2c_master_write();
|
||||
|
||||
}
|
||||
|
||||
static u8 tx_data_i2c[2];
|
||||
static u8 rx_data_i2c[2];
|
||||
|
||||
void i2c_put_char(u8 c){
|
||||
|
||||
_memset(&tx_data_i2c[0],0x00,2);
|
||||
_memset(&rx_data_i2c[0],0x00,2);
|
||||
tx_data_i2c[0] = 0x00 << 3;
|
||||
tx_data_i2c[1] = c;
|
||||
i2c_write(&i2cmaster, 0x4D, &tx_data_i2c[0], 2, 1);
|
||||
i2c_read (&i2cmaster, 0x4D, &rx_data_i2c[0], 2, 1);
|
||||
}
|
||||
|
||||
int use_mode;
|
||||
|
||||
void console_init(void)
|
||||
{
|
||||
i2c_redirect_init();
|
||||
|
||||
if(HalCheckSDramExist()){
|
||||
//DiagPrintf("It's 8195_AM\n");
|
||||
redirect_rom_init();
|
||||
}
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((u32)RAM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#else
|
||||
RtlConsolInitRam((u32)ROM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#endif
|
||||
|
||||
#if BUFFERED_PRINTF
|
||||
rtl_printf_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID HalSerialPutcRtl8195a(IN u8 c){
|
||||
|
||||
u32 CounterIndex = 0;
|
||||
|
||||
extern char i2c_ready;
|
||||
if(i2c_ready)
|
||||
i2c_put_char(c);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
119
lib/amb1_sdk/soc/realtek/8195a/misc/driver/low_level_io.c
Normal file
119
lib/amb1_sdk/soc/realtek/8195a/misc/driver/low_level_io.c
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <stdio.h>
|
||||
#include "hal_api.h"
|
||||
#include "rtl8195a.h"
|
||||
#include "platform_opts.h"
|
||||
|
||||
#if !defined (__ICCARM__)
|
||||
extern u8 RAM_IMG1_VALID_PATTEN[];
|
||||
void *tmp = RAM_IMG1_VALID_PATTEN;
|
||||
#endif
|
||||
|
||||
//for internal test
|
||||
#ifdef USE_MODE
|
||||
extern int use_mode;
|
||||
void mode_init(void){use_mode = 1;}
|
||||
#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
|
||||
|
||||
|
||||
|
||||
int disablePrintf = FALSE;
|
||||
|
||||
|
||||
__weak VOID HalSerialPutcRtl8195a(IN u8 c){
|
||||
|
||||
u32 CounterIndex = 0;
|
||||
|
||||
if(disablePrintf == TRUE) return;
|
||||
|
||||
while(1) {
|
||||
CounterIndex++;
|
||||
if (CounterIndex >=6540)
|
||||
break;
|
||||
|
||||
if (HAL_UART_READ8(UART_LINE_STATUS_REG_OFF) & 0x60)
|
||||
break;
|
||||
}
|
||||
HAL_UART_WRITE8(UART_TRAN_HOLD_OFF, c);
|
||||
if (c == 0x0a) {
|
||||
HAL_UART_WRITE8(UART_TRAN_HOLD_OFF, 0x0d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include <diag.h>
|
||||
u32
|
||||
DiagPrintf(
|
||||
IN const char *fmt, ...
|
||||
)
|
||||
{
|
||||
if(disablePrintf == TRUE) return _TRUE;
|
||||
|
||||
(void)VSprintf(0, fmt, ((const int *)&fmt)+1);
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
extern u32 ConfigDebugErr;
|
||||
extern u32 ConfigDebugInfo;
|
||||
extern u32 ConfigDebugWarn;
|
||||
static u32 backupErr;
|
||||
static u32 backupInfo;
|
||||
static u32 backupWarn;
|
||||
void log_uart_enable_printf(void)
|
||||
{
|
||||
disablePrintf = FALSE;
|
||||
ConfigDebugErr = backupErr;
|
||||
ConfigDebugInfo = backupInfo;
|
||||
ConfigDebugWarn = backupWarn;
|
||||
}
|
||||
|
||||
void log_uart_disable_printf(void)
|
||||
{
|
||||
disablePrintf = TRUE;
|
||||
backupErr = ConfigDebugErr;
|
||||
backupInfo = ConfigDebugInfo;
|
||||
backupWarn = ConfigDebugWarn;
|
||||
ConfigDebugErr = 0;
|
||||
ConfigDebugInfo = 0;
|
||||
ConfigDebugWarn = 0;
|
||||
}
|
||||
490
lib/amb1_sdk/soc/realtek/8195a/misc/driver/rtl_consol.c
Normal file
490
lib/amb1_sdk/soc/realtek/8195a/misc/driver/rtl_consol.c
Normal file
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
* 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 "rtl8195a.h"
|
||||
//#include <stdarg.h>
|
||||
#include "rtl_consol.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <event_groups.h>
|
||||
#include "semphr.h"
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
#include "freertos_pmu.h"
|
||||
#endif
|
||||
#include "tcm_heap.h"
|
||||
|
||||
// Those symbols will be defined in linker script for gcc compiler
|
||||
// If not doing this would cause extra memory cost
|
||||
#if defined (__GNUC__)
|
||||
|
||||
extern volatile UART_LOG_CTL UartLogCtl;
|
||||
extern volatile UART_LOG_CTL *pUartLogCtl;
|
||||
extern u8 *ArgvArray[MAX_ARGV];
|
||||
extern UART_LOG_BUF UartLogBuf;
|
||||
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
extern u8 UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN];
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
MON_RAM_BSS_SECTION
|
||||
volatile UART_LOG_CTL UartLogCtl;
|
||||
MON_RAM_BSS_SECTION
|
||||
volatile UART_LOG_CTL *pUartLogCtl;
|
||||
MON_RAM_BSS_SECTION
|
||||
u8 *ArgvArray[MAX_ARGV];
|
||||
MON_RAM_BSS_SECTION
|
||||
UART_LOG_BUF UartLogBuf;
|
||||
|
||||
#ifdef CONFIG_UART_LOG_HISTORY
|
||||
MON_RAM_BSS_SECTION
|
||||
u8 UartLogHistoryBuf[UART_LOG_HISTORY_LEN][UART_LOG_CMD_BUFLEN];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL
|
||||
static void (*up_sema_from_isr)(_sema *) = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
_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
|
||||
);
|
||||
|
||||
_LONG_CALL_
|
||||
extern VOID
|
||||
UartLogCmdExecute(
|
||||
IN PUART_LOG_CTL pUartLogCtlExe
|
||||
);
|
||||
|
||||
|
||||
|
||||
//=================================================
|
||||
|
||||
|
||||
/* 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
|
||||
//======================================================
|
||||
//MON_RAM_TEXT_SECTION
|
||||
VOID
|
||||
UartLogIrqHandleRam
|
||||
(
|
||||
VOID * Data
|
||||
)
|
||||
{
|
||||
u8 UartReceiveData = 0;
|
||||
//For Test
|
||||
BOOL PullMode = _FALSE;
|
||||
|
||||
u32 IrqEn = DiagGetIsrEnReg();
|
||||
|
||||
DiagSetIsrEnReg(0);
|
||||
|
||||
UartReceiveData = DiagGetChar(PullMode);
|
||||
if (UartReceiveData == 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
//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
|
||||
||(pUartLogCtl->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 (pUartLogCtl->TaskRdy && up_sema_from_isr != NULL)
|
||||
//RtlUpSemaFromISR((_Sema *)&pUartLogCtl->Sema);
|
||||
up_sema_from_isr((_sema *)&pUartLogCtl->Sema);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayInitialize((u8 *)pUartLogCtl->pTmpLogBuf->UARTLogBuf, UART_LOG_CMD_BUFLEN, '\0');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit:
|
||||
DiagSetIsrEnReg(IrqEn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//MON_RAM_TEXT_SECTION
|
||||
VOID
|
||||
RtlConsolInitRam(
|
||||
IN u32 Boot,
|
||||
IN u32 TBLSz,
|
||||
IN VOID *pTBL
|
||||
)
|
||||
{
|
||||
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
|
||||
pUartLogCtl->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 */
|
||||
//RtlInitSema((_Sema*)&(pUartLogCtl->Sema), 0);
|
||||
rtw_init_sema((_sema*)&(pUartLogCtl->Sema), 0);
|
||||
pUartLogCtl->TaskRdy = 0;
|
||||
#ifdef PLATFORM_FREERTOS
|
||||
#define LOGUART_STACK_SIZE 128 //USE_MIN_STACK_SIZE modify from 512 to 128
|
||||
#if CONFIG_USE_TCM_HEAP
|
||||
{
|
||||
int ret = 0;
|
||||
void *stack_addr = tcm_heap_malloc(LOGUART_STACK_SIZE*sizeof(int));
|
||||
//void *stack_addr = rtw_malloc(stack_size*sizeof(int));
|
||||
if(stack_addr == NULL){
|
||||
DiagPrintf("Out of TCM heap in \"LOGUART_TASK\" ");
|
||||
}
|
||||
ret = xTaskGenericCreate(
|
||||
RtlConsolTaskRam,
|
||||
(const char *)"LOGUART_TASK",
|
||||
LOGUART_STACK_SIZE,
|
||||
NULL,
|
||||
tskIDLE_PRIORITY + 5 + PRIORITY_OFFSET,
|
||||
NULL,
|
||||
stack_addr,
|
||||
NULL);
|
||||
if (pdTRUE != ret)
|
||||
{
|
||||
DiagPrintf("Create Log UART Task Err!!\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (pdTRUE != xTaskCreate( RtlConsolTaskRam, (const signed char * const)"LOGUART_TASK", LOGUART_STACK_SIZE, NULL, tskIDLE_PRIORITY + 5 + PRIORITY_OFFSET, NULL))
|
||||
{
|
||||
DiagPrintf("Create Log UART Task Err!!\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
CONSOLE_8195A();
|
||||
}
|
||||
|
||||
extern u8** GetArgv(const u8 *string);
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
extern char log_buf[LOG_SERVICE_BUFLEN];
|
||||
extern xSemaphoreHandle log_rx_interrupt_sema;
|
||||
#endif
|
||||
//======================================================
|
||||
void console_cmd_exec(PUART_LOG_CTL pUartLogCtlExe)
|
||||
{
|
||||
u8 CmdCnt = 0;
|
||||
u8 argc = 0;
|
||||
u8 **argv;
|
||||
//u32 CmdNum;
|
||||
PUART_LOG_BUF pUartLogBuf = pUartLogCtlExe->pTmpLogBuf;
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
strncpy(log_buf, (const u8*)&(*pUartLogBuf).UARTLogBuf[0], LOG_SERVICE_BUFLEN-1);
|
||||
#endif
|
||||
argc = GetArgc((const u8*)&((*pUartLogBuf).UARTLogBuf[0]));
|
||||
argv = GetArgv((const u8*)&((*pUartLogBuf).UARTLogBuf[0]));
|
||||
|
||||
if(argc > 0){
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
// if(log_handler(argv[0]) == NULL)
|
||||
// legency_interactive_handler(argc, argv);
|
||||
//RtlUpSema((_Sema *)&log_rx_interrupt_sema);
|
||||
rtw_up_sema((_sema *)&log_rx_interrupt_sema);
|
||||
#endif
|
||||
ArrayInitialize(argv[0], (argc * sizeof(u8)) ,0);
|
||||
}else{
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
pmu_acquire_wakelock(BIT(PMU_LOGUART_DEVICE));
|
||||
#endif
|
||||
CONSOLE_8195A(); // for null command
|
||||
}
|
||||
|
||||
(*pUartLogBuf).BufCount = 0;
|
||||
ArrayInitialize(&(*pUartLogBuf).UARTLogBuf[0], UART_LOG_CMD_BUFLEN, '\0');
|
||||
}
|
||||
//======================================================
|
||||
// overload original RtlConsolTaskRam
|
||||
//MON_RAM_TEXT_SECTION
|
||||
VOID
|
||||
RtlConsolTaskRam(
|
||||
VOID *Data
|
||||
)
|
||||
{
|
||||
#if SUPPORT_LOG_SERVICE
|
||||
log_service_init();
|
||||
#endif
|
||||
//4 Set this for UartLog check cmd history
|
||||
#ifdef CONFIG_KERNEL
|
||||
pUartLogCtl->TaskRdy = 1;
|
||||
up_sema_from_isr = rtw_up_sema_from_isr;
|
||||
#endif
|
||||
#ifndef CONFIG_KERNEL
|
||||
pUartLogCtl->BootRdy = 1;
|
||||
#endif
|
||||
do{
|
||||
#if defined(CONFIG_KERNEL) && !TASK_SCHEDULER_DISABLED
|
||||
//RtlDownSema((_Sema *)&pUartLogCtl->Sema);
|
||||
rtw_down_sema((_sema *)&pUartLogCtl->Sema);
|
||||
#endif
|
||||
if (pUartLogCtl->ExecuteCmd) {
|
||||
// Add command handler here
|
||||
console_cmd_exec((PUART_LOG_CTL)pUartLogCtl);
|
||||
//UartLogCmdExecute((PUART_LOG_CTL)pUartLogCtl);
|
||||
pUartLogCtl->ExecuteCmd = _FALSE;
|
||||
}
|
||||
}while(1);
|
||||
}
|
||||
|
||||
//======================================================
|
||||
#if BUFFERED_PRINTF
|
||||
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
|
||||
//======================================================
|
||||
|
||||
|
||||
__weak void console_init(void)
|
||||
{
|
||||
|
||||
IRQ_HANDLE UartIrqHandle;
|
||||
|
||||
//4 Register Log Uart Callback function
|
||||
UartIrqHandle.Data = NULL;//(u32)&UartAdapter;
|
||||
UartIrqHandle.IrqNum = UART_LOG_IRQ;
|
||||
UartIrqHandle.IrqFun = (IRQ_FUN) UartLogIrqHandleRam;
|
||||
UartIrqHandle.Priority = 6;
|
||||
|
||||
|
||||
//4 Register Isr handle
|
||||
InterruptUnRegister(&UartIrqHandle);
|
||||
InterruptRegister(&UartIrqHandle);
|
||||
|
||||
|
||||
|
||||
#if !TASK_SCHEDULER_DISABLED
|
||||
RtlConsolInitRam((u32)RAM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#else
|
||||
RtlConsolInitRam((u32)ROM_STAGE,(u32)0,(VOID*)NULL);
|
||||
#endif
|
||||
|
||||
#if BUFFERED_PRINTF
|
||||
rtl_printf_init();
|
||||
#endif
|
||||
}
|
||||
140
lib/amb1_sdk/soc/realtek/8195a/misc/driver/rtl_consol.h
Normal file
140
lib/amb1_sdk/soc/realtek/8195a/misc/driver/rtl_consol.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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_
|
||||
/*
|
||||
* Include user defined options first. Anything not defined in these files
|
||||
* will be set to standard values. Override anything you dont like!
|
||||
*/
|
||||
#if defined(CONFIG_PLATFORM_8195A) || defined(CONFIG_PLATFORM_8711B)
|
||||
#include "platform_opts.h"
|
||||
#endif
|
||||
|
||||
//#include "osdep_api.h"
|
||||
#include "osdep_service.h"
|
||||
#include "hal_diag.h"
|
||||
#include "platform_stdlib.h"
|
||||
|
||||
#define CONSOLE_PREFIX "#"
|
||||
|
||||
|
||||
//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
|
||||
|
||||
//print log buffer length, if buffer get full, the extra logs will be discarded.
|
||||
#if BUFFERED_PRINTF
|
||||
#define MAX_PRINTF_BUF_LEN 1024
|
||||
#endif
|
||||
|
||||
|
||||
typedef u32 (*ECHOFUNC)(IN u8*,...); //UART LOG echo-function type.
|
||||
|
||||
typedef struct _UART_LOG_BUF_ {
|
||||
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 _UART_LOG_CTL_ {
|
||||
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
|
||||
#ifdef CONFIG_KERNEL
|
||||
u32 TaskRdy;
|
||||
//_Sema Sema;
|
||||
_sema Sema;
|
||||
#else
|
||||
// Since ROM code will reference this typedef, so keep the typedef same size
|
||||
u32 TaskRdy;
|
||||
void *Sema;
|
||||
#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
|
||||
|
||||
#ifndef CONSOLE_PREFIX
|
||||
#define CONSOLE_PREFIX "<RTL8195A>"
|
||||
#endif
|
||||
|
||||
#define CONSOLE_8195A(...) do {\
|
||||
_ConsolePrint("\r"CONSOLE_PREFIX __VA_ARGS__);\
|
||||
}while(0)
|
||||
|
||||
|
||||
_LONG_CALL_ VOID
|
||||
RtlConsolInit(
|
||||
IN u32 Boot,
|
||||
IN u32 TBLSz,
|
||||
IN VOID *pTBL
|
||||
);
|
||||
|
||||
#if defined(CONFIG_KERNEL)
|
||||
_LONG_CALL_ VOID
|
||||
RtlConsolTaskRam(
|
||||
VOID *Data
|
||||
);
|
||||
#endif
|
||||
|
||||
_LONG_CALL_ VOID
|
||||
RtlConsolTaskRom(
|
||||
VOID *Data
|
||||
);
|
||||
|
||||
|
||||
_LONG_CALL_ u32
|
||||
Strtoul(
|
||||
IN const u8 *nptr,
|
||||
IN u8 **endptr,
|
||||
IN u32 base
|
||||
);
|
||||
|
||||
void console_init(void);
|
||||
|
||||
#endif //_RTK_CONSOL_H_
|
||||
56
lib/amb1_sdk/soc/realtek/8195a/misc/driver/rtl_sec.h
Normal file
56
lib/amb1_sdk/soc/realtek/8195a/misc/driver/rtl_sec.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtl_sec.h
|
||||
* @author
|
||||
* @version
|
||||
* @brief This file provides user interface for efuse encrypt/ decrypt data
|
||||
******************************************************************************
|
||||
* @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.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef RTL_SEC_H
|
||||
#define RTL_SEC_H
|
||||
|
||||
/** @addtogroup efuse_sec EFUSE_SEC
|
||||
* @ingroup hal
|
||||
* @brief efuse secure data functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <platform_stdlib.h>
|
||||
|
||||
#define SEC_PROCESS_OPT_ENC 1
|
||||
#define SEC_PROCESS_OPT_DEC 2
|
||||
#define SEC_PROCESS_OPT_VERIFY 3
|
||||
#define SEC_PROCESS_OPT_ENC_AES_256 4
|
||||
#define SEC_PROCESS_OPT_DEC_AES_256 5
|
||||
|
||||
#define sec_process_data ProcessSecData
|
||||
|
||||
/**
|
||||
* @brief Use efuse OTP key to encrypt/decrypt data
|
||||
* @param[in] key_idx : the key index in efuse
|
||||
* @param[in] opt : SEC_PROCESS_OPT_ENC => encrypt by AES 128
|
||||
SEC_PROCESS_OPT_DEC => decrypt by AES 128
|
||||
SEC_PROCESS_OPT_VERIFY => verify
|
||||
SEC_PROCESS_OPT_ENC_AES_256 => encrypt by AES 256
|
||||
SEC_PROCESS_OPT_DEC_AES_256 => decrypt by AES 256
|
||||
* @param[in] iv : initialization vector
|
||||
* @param[in] input_buf : input buffer that need to encrypt or decrypt
|
||||
* @param[in] buf_len : input but length
|
||||
* @param[out] output_buf : output buffer that has been encrypted or decrypted
|
||||
*
|
||||
* @return 0 : failed, input_buf==NULL, output_buf==NULL, buf_len<0, buf_len>16000, buf_len isn't 16-Bytes align
|
||||
* key_idx isn't 1 or 2, opt isn't 1~5
|
||||
* 1 : success
|
||||
*/
|
||||
uint32_t sec_process_data(uint8_t key_idx, uint32_t opt, uint8_t *iv, uint8_t *input_buf, uint32_t buf_len, uint8_t *output_buf);
|
||||
|
||||
/*\@}*/
|
||||
|
||||
#endif // RTL_SEC_H
|
||||
Reference in New Issue
Block a user