1 /* 2 * Routines to access hardware 3 * 4 * Copyright (c) 2013 Realtek Semiconductor Corp. 5 * 6 * This module is a confidential and proprietary property of RealTek and 7 * possession or use of this module requires written permission of RealTek. 8 */ 9 10 #ifndef _RTK_CONSOL_H_ 11 #define _RTK_CONSOL_H_ 12 13 //Log UART 14 //UART_LOG_CMD_BUFLEN: only 126 bytes could be used for keeping input 15 // cmd, the last byte is for string end ('\0'). 16 #define UART_LOG_CMD_BUFLEN 127 17 #define MAX_ARGV 16 18 19 typedef u32 (*ECHOFUNC)(IN u8*,...); //UART LOG echo-function type. 20 typedef u32 (*monitor_cmd_handler)(u16 argc, u8* argv[]); 21 22 typedef struct { 23 u8 BufCount; //record the input cmd char number. 24 u8 UARTLogBuf[UART_LOG_CMD_BUFLEN]; //record the input command. 25 } UART_LOG_BUF, *PUART_LOG_BUF; 26 27 typedef struct _COMMAND_TABLE_ { 28 const u8* cmd; 29 u16 ArgvCnt; 30 u32 (*func)(u16 argc, u8* argv[]); 31 const u8* msg; 32 }COMMAND_TABLE, *PCOMMAND_TABLE; 33 34 35 typedef struct { 36 u8 NewIdx; 37 u8 SeeIdx; 38 u8 RevdNo; 39 u8 EscSTS; 40 u8 ExecuteCmd; 41 u8 ExecuteEsc; 42 u8 BootRdy; 43 u8 Resvd; 44 PUART_LOG_BUF pTmpLogBuf; 45 VOID *pfINPUT; 46 PCOMMAND_TABLE pCmdTbl; 47 u32 CmdTblSz; 48 u32 CRSTS; 49 #ifdef CONFIG_UART_LOG_HISTORY 50 u8 (*pHistoryBuf)[UART_LOG_CMD_BUFLEN]; 51 #endif 52 53 void (*GiveSema)(void); 54 u32 shell_task_rdy; 55 } UART_LOG_CTL, *PUART_LOG_CTL; 56 57 58 #define KB_ASCII_NUL 0x00 59 #define KB_ASCII_BS 0x08 60 #define KB_ASCII_TAB 0x09 61 #define KB_ASCII_LF 0x0A 62 #define KB_ASCII_CR 0x0D 63 #define KB_ASCII_ESC 0x1B 64 #define KB_ASCII_SP 0x20 65 #define KB_ASCII_BS_7F 0x7F 66 #define KB_ASCII_LBRKT 0x5B //[ 67 68 #define KB_SPACENO_TAB 1 69 70 #ifdef CONFIG_UART_LOG_HISTORY 71 #define UART_LOG_HISTORY_LEN 5 72 #endif 73 74 //#ifdef CONFIG_DEBUG_LOG 75 #define _ConsolePrint DiagPrintf 76 //#else 77 //#define _ConsolePrint 78 //#endif 79 80 #define AMEBA_CONSOLE_PREFIX "#" 81 #define CONSOLE_AMEBA(...) do {\ 82 _ConsolePrint("\r"AMEBA_CONSOLE_PREFIX __VA_ARGS__);\ 83 }while(0) 84 85 _LONG_CALL_ VOID shell_init_rom(u32 TBLSz, VOID *pTBL); 86 _LONG_CALL_ VOID shell_task_rom(VOID *Data); 87 _LONG_CALL_ VOID shell_rom(u32 MaxWaitCount); 88 _LONG_CALL_ void shell_uart_irq_rom(void * Data); 89 90 _LONG_CALL_ 91 extern VOID 92 shell_cmd_history( 93 IN u8 RevData, 94 IN UART_LOG_CTL *prvUartLogCtl, 95 IN u8 EchoFlag 96 ); 97 _LONG_CALL_ 98 extern u8 99 shell_cmd_chk( 100 IN u8 RevData, 101 IN UART_LOG_CTL *prvUartLogCtl, 102 IN u8 EchoFlag 103 ); 104 105 _LONG_CALL_ 106 extern VOID 107 shell_array_init( 108 IN u8 *pArrayToInit, 109 IN u8 ArrayLen, 110 IN u8 InitValue 111 ); 112 extern u8** shell_get_argv(const u8 *string); 113 extern u8 shell_get_argc(const u8 *string); 114 115 VOID shell_init_ram(VOID); 116 void shell_switch_ipc_int(VOID *Data, u32 IrqStatus, u32 ChanNum); 117 118 #define RtlConsolTaskRom shell_task_rom 119 120 extern u32 shell_recv_all_data_onetime; 121 extern u32 shell_interrupt_on; 122 #endif //_RTK_CONSOL_H_ 123