Merge pull request #2602 from yangjie11/yj_fix_branch
[components/utilities]delete log_trace from components,remove log_trace from bsp
This commit is contained in:
commit
3e7bd27ce7
|
@ -189,8 +189,6 @@
|
||||||
#define RT_LWIP_MSKADDR3 0
|
#define RT_LWIP_MSKADDR3 0
|
||||||
// </section>
|
// </section>
|
||||||
|
|
||||||
#define RT_USING_LOGTRACE
|
|
||||||
|
|
||||||
// </RDTConfigurator>
|
// </RDTConfigurator>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
#include <shell.h>
|
#include <shell.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RT_USING_LOGTRACE
|
|
||||||
#include <log_trace.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RT_USING_VBUS
|
#ifdef RT_USING_VBUS
|
||||||
#include <vbus.h>
|
#include <vbus.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,11 +25,6 @@
|
||||||
/* thread phase init */
|
/* thread phase init */
|
||||||
void rt_init_thread_entry(void *parameter)
|
void rt_init_thread_entry(void *parameter)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_LOGTRACE
|
|
||||||
log_trace_init();
|
|
||||||
log_trace_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RT_USING_FINSH
|
#ifdef RT_USING_FINSH
|
||||||
/* initialize finsh */
|
/* initialize finsh */
|
||||||
finsh_system_init();
|
finsh_system_init();
|
||||||
|
|
|
@ -227,7 +227,6 @@
|
||||||
// </section>
|
// </section>
|
||||||
|
|
||||||
#define RT_USING_VBUS
|
#define RT_USING_VBUS
|
||||||
#define RT_USING_LOGTRACE
|
|
||||||
|
|
||||||
// </RDTConfigurator>
|
// </RDTConfigurator>
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,6 @@
|
||||||
#include <shell.h>
|
#include <shell.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RT_USING_LOGTRACE
|
|
||||||
#include <log_trace.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RT_USING_VBUS
|
#ifdef RT_USING_VBUS
|
||||||
#include <vbus.h>
|
#include <vbus.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,10 +55,6 @@ void rt_init_thread_entry(void *parameter)
|
||||||
*register unsigned int _psp __asm("psp");
|
*register unsigned int _psp __asm("psp");
|
||||||
*rt_kprintf("msp@ %p, psp@ %p\n", _msp, _psp);
|
*rt_kprintf("msp@ %p, psp@ %p\n", _msp, _psp);
|
||||||
*/
|
*/
|
||||||
#ifdef RT_USING_LOGTRACE
|
|
||||||
log_trace_init();
|
|
||||||
log_trace_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RT_USING_FINSH
|
#ifdef RT_USING_FINSH
|
||||||
/* initialize finsh */
|
/* initialize finsh */
|
||||||
|
|
|
@ -226,8 +226,6 @@
|
||||||
// </section>
|
// </section>
|
||||||
|
|
||||||
#define RT_USING_VBUS
|
#define RT_USING_VBUS
|
||||||
#define RT_USING_LOGTRACE
|
|
||||||
|
|
||||||
// </RDTConfigurator>
|
// </RDTConfigurator>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -219,10 +219,6 @@
|
||||||
|
|
||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
|
||||||
#define RT_USING_LOGTRACE
|
|
||||||
#define LOG_TRACE_MAX_SESSION 16
|
|
||||||
#define LOG_TRACE_USING_LEVEL_INFO
|
|
||||||
#define RT_USING_LWP
|
#define RT_USING_LWP
|
||||||
|
|
||||||
/* RT-Thread online packages */
|
/* RT-Thread online packages */
|
||||||
|
|
|
@ -174,7 +174,6 @@
|
||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
|
||||||
#define RT_USING_LOGTRACE
|
|
||||||
#define LOG_TRACE_MAX_SESSION 16
|
#define LOG_TRACE_MAX_SESSION 16
|
||||||
/* LOG_TRACE_USING_LEVEL_NOTRACE is not set */
|
/* LOG_TRACE_USING_LEVEL_NOTRACE is not set */
|
||||||
/* LOG_TRACE_USING_LEVEL_ERROR is not set */
|
/* LOG_TRACE_USING_LEVEL_ERROR is not set */
|
||||||
|
|
|
@ -146,8 +146,6 @@
|
||||||
|
|
||||||
// </RDTConfigurator>
|
// </RDTConfigurator>
|
||||||
|
|
||||||
#define RT_USING_LOGTRACE
|
|
||||||
|
|
||||||
// <section name="RT_USING_VMM" description="Enable RT-Thread hypervisor" default="true" >
|
// <section name="RT_USING_VMM" description="Enable RT-Thread hypervisor" default="true" >
|
||||||
// #define RT_USING_VMM
|
// #define RT_USING_VMM
|
||||||
// </section>
|
// </section>
|
||||||
|
|
|
@ -1,47 +1,5 @@
|
||||||
menu "Utilities"
|
menu "Utilities"
|
||||||
|
|
||||||
config RT_USING_LOGTRACE
|
|
||||||
bool "Enable log trace"
|
|
||||||
default n
|
|
||||||
|
|
||||||
if RT_USING_LOGTRACE
|
|
||||||
config LOG_TRACE_MAX_SESSION
|
|
||||||
int "Maximal number of session"
|
|
||||||
default 16
|
|
||||||
|
|
||||||
choice
|
|
||||||
prompt "The default level of log"
|
|
||||||
default LOG_TRACE_USING_LEVEL_INFO
|
|
||||||
|
|
||||||
config LOG_TRACE_USING_LEVEL_NOTRACE
|
|
||||||
bool "No trace"
|
|
||||||
|
|
||||||
config LOG_TRACE_USING_LEVEL_ERROR
|
|
||||||
bool "Only error log"
|
|
||||||
|
|
||||||
config LOG_TRACE_USING_LEVEL_WARNING
|
|
||||||
bool "Warning log"
|
|
||||||
|
|
||||||
config LOG_TRACE_USING_LEVEL_INFO
|
|
||||||
bool "Information log"
|
|
||||||
|
|
||||||
config LOG_TRACE_USING_LEVEL_VERBOSE
|
|
||||||
bool "Verbose log"
|
|
||||||
|
|
||||||
config LOG_TRACE_USING_LEVEL_DEBUG
|
|
||||||
bool "All debug log"
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
config LOG_TRACE_USING_MEMLOG
|
|
||||||
bool "Enable memory log for logtrace"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Enable memory log for logtrace, then the logs in log_trace
|
|
||||||
will be printed out in idle thread hook function.
|
|
||||||
|
|
||||||
Please make sure the idle hook is not used.
|
|
||||||
endif
|
|
||||||
|
|
||||||
config RT_USING_RYM
|
config RT_USING_RYM
|
||||||
bool "Enable Ymodem"
|
bool "Enable Ymodem"
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
from building import *
|
|
||||||
|
|
||||||
cwd = GetCurrentDir()
|
|
||||||
src = Split('''
|
|
||||||
log_trace.c
|
|
||||||
''')
|
|
||||||
CPPPATH = [cwd]
|
|
||||||
|
|
||||||
if GetDepend('LOG_TRACE_USING_MEMLOG'):
|
|
||||||
src += ['memlog.c']
|
|
||||||
|
|
||||||
if GetDepend('RT_USING_DFS'):
|
|
||||||
src += ['log_file.c']
|
|
||||||
|
|
||||||
group = DefineGroup('Utilities', src, depend = ['RT_USING_LOGTRACE'], CPPPATH = CPPPATH)
|
|
||||||
|
|
||||||
Return('group')
|
|
|
@ -1,151 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* Bernard the first version
|
|
||||||
* 2013-06-26 Grissiom refactor
|
|
||||||
*/
|
|
||||||
#include <rtthread.h>
|
|
||||||
#include <log_trace.h>
|
|
||||||
|
|
||||||
#ifdef RT_USING_DFS
|
|
||||||
|
|
||||||
#include <dfs_posix.h>
|
|
||||||
|
|
||||||
struct file_device
|
|
||||||
{
|
|
||||||
struct rt_device parent;
|
|
||||||
|
|
||||||
int fd;
|
|
||||||
char *filename;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* file device for log trace */
|
|
||||||
static struct file_device _file_device;
|
|
||||||
|
|
||||||
/* common device interface */
|
|
||||||
static rt_err_t fdevice_open(rt_device_t dev, rt_uint16_t oflag)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
struct file_device *fdev = (struct file_device *)dev;
|
|
||||||
|
|
||||||
if (fdev->fd >= 0)
|
|
||||||
return -RT_EBUSY;
|
|
||||||
|
|
||||||
/* test and open */
|
|
||||||
fd = open(fdev->filename, O_RDONLY, 0);
|
|
||||||
if (fd >= 0)
|
|
||||||
{
|
|
||||||
close(fd);
|
|
||||||
fd = open(fdev->filename, O_WRONLY | O_APPEND, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* file not exists */
|
|
||||||
fd = open(fdev->filename, O_WRONLY | O_CREAT, 0);
|
|
||||||
}
|
|
||||||
fdev->fd = fd;
|
|
||||||
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static rt_err_t fdevice_close(rt_device_t dev)
|
|
||||||
{
|
|
||||||
rt_err_t result;
|
|
||||||
struct file_device *fdev = (struct file_device *)dev;
|
|
||||||
|
|
||||||
if (fdev->fd < 0)
|
|
||||||
return -RT_EBUSY;
|
|
||||||
|
|
||||||
result = close(fdev->fd);
|
|
||||||
if (result == 0)
|
|
||||||
{
|
|
||||||
fdev->fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static rt_size_t fdevice_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
|
||||||
{
|
|
||||||
struct file_device *fdev = (struct file_device *)dev;
|
|
||||||
|
|
||||||
if (fdev->fd < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return write(fdev->fd, buffer, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static rt_err_t fdevice_control(rt_device_t dev, int cmd, void *arg)
|
|
||||||
{
|
|
||||||
struct file_device *fdev = (struct file_device *)dev;
|
|
||||||
|
|
||||||
if (fdev->fd < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case LOG_TRACE_CTRL_FLUSH:
|
|
||||||
if (fsync(fdev->fd) != 0)
|
|
||||||
return RT_ERROR;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef RT_USING_DEVICE_OPS
|
|
||||||
const static struct rt_device_ops log_trace_ops =
|
|
||||||
{
|
|
||||||
RT_NULL,
|
|
||||||
fdevice_open,
|
|
||||||
fdevice_close,
|
|
||||||
RT_NULL,
|
|
||||||
fdevice_write,
|
|
||||||
fdevice_control
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void log_trace_file_init(const char *filename)
|
|
||||||
{
|
|
||||||
rt_device_t device;
|
|
||||||
|
|
||||||
device = rt_device_find("logfile");
|
|
||||||
if (device == RT_NULL)
|
|
||||||
{
|
|
||||||
rt_memset(&_file_device, 0x00, sizeof(_file_device));
|
|
||||||
|
|
||||||
_file_device.parent.type = RT_Device_Class_Char;
|
|
||||||
|
|
||||||
#ifdef RT_USING_DEVICE_OPS
|
|
||||||
_file_device.parent.ops = &log_trace_ops;
|
|
||||||
#else
|
|
||||||
_file_device.parent.init = RT_NULL;
|
|
||||||
_file_device.parent.open = fdevice_open;
|
|
||||||
_file_device.parent.close = fdevice_close;
|
|
||||||
_file_device.parent.write = fdevice_write;
|
|
||||||
_file_device.parent.control = fdevice_control;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rt_device_register(&_file_device.parent, "logfile", O_RDWR);
|
|
||||||
}
|
|
||||||
|
|
||||||
_file_device.filename = rt_strdup(filename);
|
|
||||||
_file_device.fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_trace_set_file(const char *filename)
|
|
||||||
{
|
|
||||||
log_trace_file_init(filename);
|
|
||||||
log_trace_set_device("logfile");
|
|
||||||
}
|
|
||||||
#ifdef RT_USING_FINSH
|
|
||||||
#include <finsh.h>
|
|
||||||
FINSH_FUNCTION_EXPORT_ALIAS(log_trace_set_file, log_file, set output filename of log trace);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* RT_USING_DFS */
|
|
|
@ -1,445 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* Bernard the first version
|
|
||||||
* 2013-06-26 Grissiom refactor
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rtthread.h>
|
|
||||||
#include <rthw.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "log_trace.h"
|
|
||||||
|
|
||||||
#ifdef RT_USING_FINSH
|
|
||||||
#include <finsh.h>
|
|
||||||
#else
|
|
||||||
#define FINSH_FUNCTION_EXPORT(...)
|
|
||||||
#define FINSH_FUNCTION_EXPORT_ALIAS(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* log pseudo device */
|
|
||||||
static struct rt_device _log_device;
|
|
||||||
|
|
||||||
static rt_device_t _traceout_device = RT_NULL;
|
|
||||||
|
|
||||||
/* define a default lg session. The name is empty. */
|
|
||||||
static struct log_trace_session _def_session = {{"\0"}, LOG_TRACE_LEVEL_DEFAULT};
|
|
||||||
static const struct log_trace_session *_the_sessions[LOG_TRACE_MAX_SESSION] = {&_def_session};
|
|
||||||
/* there is a default session at least */
|
|
||||||
static rt_uint16_t _the_sess_nr = 1;
|
|
||||||
|
|
||||||
rt_inline int _idname_len(log_trace_idnum_t id)
|
|
||||||
{
|
|
||||||
/* little endian */
|
|
||||||
if ((id & 0x000000FF) == 0)
|
|
||||||
return 0;
|
|
||||||
if ((id & 0x0000FF00) == 0)
|
|
||||||
return 1;
|
|
||||||
if ((id & 0x00FF0000) == 0)
|
|
||||||
return 2;
|
|
||||||
if ((id & 0xFF000000) == 0)
|
|
||||||
return 3;
|
|
||||||
#ifndef LOG_TRACE_USE_LONGNAME
|
|
||||||
return 4;
|
|
||||||
#else
|
|
||||||
{
|
|
||||||
rt_uint32_t id2 = id >> 32;
|
|
||||||
if ((id2 & 0x000000FF) == 0)
|
|
||||||
return 4;
|
|
||||||
if ((id2 & 0x0000FF00) == 0)
|
|
||||||
return 5;
|
|
||||||
if ((id2 & 0x00FF0000) == 0)
|
|
||||||
return 6;
|
|
||||||
if ((id2 & 0xFF000000) == 0)
|
|
||||||
return 7;
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lookup the session according to name.
|
|
||||||
*
|
|
||||||
* @param len is the length of the name
|
|
||||||
* @return the pointer to the named session. RT_NULL when there is no such a
|
|
||||||
* session.
|
|
||||||
*/
|
|
||||||
static struct log_trace_session* _lg_lookup_session(log_trace_idnum_t num)
|
|
||||||
{
|
|
||||||
static const struct log_trace_session *_cache = &_def_session;
|
|
||||||
rt_uint16_t first, last;
|
|
||||||
|
|
||||||
if (_cache->id.num == num)
|
|
||||||
return (struct log_trace_session *)_cache;
|
|
||||||
|
|
||||||
first = 0;
|
|
||||||
last = _the_sess_nr;
|
|
||||||
do {
|
|
||||||
unsigned int i = (first + last)/2;
|
|
||||||
|
|
||||||
RT_ASSERT(_the_sessions[i]);
|
|
||||||
|
|
||||||
if (_the_sessions[i]->id.num == num)
|
|
||||||
{
|
|
||||||
/* there is no need to protect the _cache because write a pointer
|
|
||||||
* is atomic. So we cannot get a invalid pointer. The worst thing
|
|
||||||
* could happen is there is an interrupt in the read/modify/write
|
|
||||||
* process and we wrote the old one to _cache. But it doesn't harm
|
|
||||||
* a lot because it will be flushed in the next time. */
|
|
||||||
_cache = _the_sessions[i];
|
|
||||||
return (struct log_trace_session *)_the_sessions[i];
|
|
||||||
}
|
|
||||||
else if (_the_sessions[i]->id.num > num)
|
|
||||||
{
|
|
||||||
last = i;
|
|
||||||
}
|
|
||||||
else // _the_sessions[i]->id.num < num
|
|
||||||
{
|
|
||||||
first = i;
|
|
||||||
}
|
|
||||||
} while (first != last-1);
|
|
||||||
|
|
||||||
return RT_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
rt_err_t log_trace_register_session(const struct log_trace_session *session)
|
|
||||||
{
|
|
||||||
unsigned int lvl, i;
|
|
||||||
|
|
||||||
if (_the_sess_nr == LOG_TRACE_MAX_SESSION)
|
|
||||||
return -RT_EFULL;
|
|
||||||
|
|
||||||
if (session == RT_NULL)
|
|
||||||
return RT_EOK;
|
|
||||||
|
|
||||||
lvl = rt_hw_interrupt_disable();
|
|
||||||
/* inserting the sessions in ascending order.
|
|
||||||
*
|
|
||||||
* this might take relatively long time. But since the register should only
|
|
||||||
* happen when initialize the whole system, this should not be a matter. */
|
|
||||||
for (i = 0; i < _the_sess_nr; i++)
|
|
||||||
{
|
|
||||||
if (_the_sessions[i]->id.num > session->id.num)
|
|
||||||
{
|
|
||||||
rt_memmove(_the_sessions+i+1, _the_sessions+i,
|
|
||||||
(_the_sess_nr-i)*sizeof(&_the_sessions[0]));
|
|
||||||
_the_sessions[i] = session;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (_the_sessions[i]->id.num == session->id.num)
|
|
||||||
{
|
|
||||||
rt_kprintf("registering session 0x%p twice\n", session);
|
|
||||||
rt_hw_interrupt_enable(lvl);
|
|
||||||
return -RT_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == _the_sess_nr)
|
|
||||||
_the_sessions[i] = session;
|
|
||||||
_the_sess_nr++;
|
|
||||||
rt_hw_interrupt_enable(lvl);
|
|
||||||
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct log_trace_session* log_trace_session_find(const char *name)
|
|
||||||
{
|
|
||||||
union log_trace_id *idp;
|
|
||||||
|
|
||||||
RT_ASSERT(name);
|
|
||||||
idp = (union log_trace_id*)name;
|
|
||||||
return _lg_lookup_session(idp->num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_trace_set_level(rt_uint8_t level)
|
|
||||||
{
|
|
||||||
_def_session.lvl = level;
|
|
||||||
}
|
|
||||||
FINSH_FUNCTION_EXPORT_ALIAS(log_trace_set_level, log_level, set the filter level of log trace);
|
|
||||||
|
|
||||||
void log_trace_session_set_level(struct log_trace_session *sess, rt_uint8_t level)
|
|
||||||
{
|
|
||||||
RT_ASSERT(sess);
|
|
||||||
sess->lvl = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* parse the level info in fmt
|
|
||||||
*
|
|
||||||
* @param flen the length of the format.
|
|
||||||
* @param lvlp the pointer to level. It will store the level in the memory the
|
|
||||||
* lvlp points to. The default value is LOG_TRACE_LEVEL_DEFAULT.
|
|
||||||
* @return the number of char it scaned.
|
|
||||||
*/
|
|
||||||
static rt_size_t _lg_parse_lvl(const char *fmt, rt_size_t flen, int *lvlp)
|
|
||||||
{
|
|
||||||
RT_ASSERT(fmt);
|
|
||||||
RT_ASSERT(lvlp);
|
|
||||||
|
|
||||||
/* setup default value */
|
|
||||||
*lvlp = LOG_TRACE_LEVEL_DEFAULT;
|
|
||||||
|
|
||||||
if (flen < 3)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt[0] == '<' && fmt[2] == '>')
|
|
||||||
{
|
|
||||||
*lvlp = fmt[1] - '0';
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* parse the header in fmt
|
|
||||||
*
|
|
||||||
* @param flen the length of the format.
|
|
||||||
* @param sessp the pointer of pointer to the session. It will store the
|
|
||||||
* session pointer in the memory the sessp points to. When failed to
|
|
||||||
* find the session, it will be setted to the default session.
|
|
||||||
* @return the number of char it scaned, i.e., the length of header.
|
|
||||||
*/
|
|
||||||
static rt_size_t _lg_parse_session(
|
|
||||||
const char *fmt, rt_size_t flen, struct log_trace_session **sessp)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
struct log_trace_session *tmpsess;
|
|
||||||
union log_trace_id id;
|
|
||||||
|
|
||||||
RT_ASSERT(fmt);
|
|
||||||
RT_ASSERT(sessp);
|
|
||||||
|
|
||||||
/* setup default value */
|
|
||||||
*sessp = &_def_session;
|
|
||||||
|
|
||||||
/* no name space left */
|
|
||||||
if (flen < sizeof(id) + 2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (fmt[0] != '[')
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
id.num = 0;
|
|
||||||
/* skip '[' and convert the string to id number. */
|
|
||||||
for (i = 1; fmt[i] != ']'; i++)
|
|
||||||
{
|
|
||||||
if (i - 1 == sizeof(id))
|
|
||||||
return 0;
|
|
||||||
id.name[i-1] = fmt[i];
|
|
||||||
}
|
|
||||||
tmpsess = _lg_lookup_session(id.num);
|
|
||||||
if (tmpsess != RT_NULL)
|
|
||||||
{
|
|
||||||
*sessp = tmpsess;
|
|
||||||
/* only count the header length when we found the session. So
|
|
||||||
* the wrong [name] will be printed out. */
|
|
||||||
return i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __logtrace_vfmtout(const struct log_trace_session *session,
|
|
||||||
const char *fmt,
|
|
||||||
va_list argptr)
|
|
||||||
{
|
|
||||||
/* 1 for ']' */
|
|
||||||
static char _trace_buf[1+LOG_TRACE_BUFSZ];
|
|
||||||
char *ptr;
|
|
||||||
rt_size_t length;
|
|
||||||
|
|
||||||
RT_ASSERT(session);
|
|
||||||
RT_ASSERT(fmt);
|
|
||||||
|
|
||||||
/* it's default session */
|
|
||||||
if (session->id.name[0] == '\0')
|
|
||||||
{
|
|
||||||
rt_snprintf(_trace_buf, sizeof(_trace_buf), "[%08x]", rt_tick_get());
|
|
||||||
if (_traceout_device != RT_NULL)
|
|
||||||
{
|
|
||||||
rt_device_write(_traceout_device, -1, _trace_buf, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = &_trace_buf[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rt_snprintf(_trace_buf, sizeof(_trace_buf), "[%08x][", rt_tick_get());
|
|
||||||
if (_traceout_device != RT_NULL)
|
|
||||||
{
|
|
||||||
rt_device_write(_traceout_device, -1, _trace_buf, 11);
|
|
||||||
rt_device_write(_traceout_device, -1,
|
|
||||||
session->id.name, _idname_len(session->id.num));
|
|
||||||
}
|
|
||||||
|
|
||||||
_trace_buf[0] = ']';
|
|
||||||
ptr = &_trace_buf[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
length = rt_vsnprintf(ptr, LOG_TRACE_BUFSZ, fmt, argptr);
|
|
||||||
|
|
||||||
if (length >= LOG_TRACE_BUFSZ)
|
|
||||||
length = LOG_TRACE_BUFSZ - 1;
|
|
||||||
|
|
||||||
if (_traceout_device != RT_NULL)
|
|
||||||
{
|
|
||||||
rt_device_write(_traceout_device, -1, _trace_buf, length + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_trace(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
int level;
|
|
||||||
struct log_trace_session *session;
|
|
||||||
|
|
||||||
RT_ASSERT(fmt);
|
|
||||||
|
|
||||||
fmt += _lg_parse_lvl(fmt, strlen(fmt), &level);
|
|
||||||
fmt += _lg_parse_session(fmt, strlen(fmt), &session);
|
|
||||||
|
|
||||||
/* filter by level */
|
|
||||||
if (level > session->lvl)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
|
||||||
__logtrace_vfmtout(session, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
FINSH_FUNCTION_EXPORT(log_trace, log trace);
|
|
||||||
|
|
||||||
void log_session(const struct log_trace_session *session, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
int level;
|
|
||||||
|
|
||||||
RT_ASSERT(session);
|
|
||||||
RT_ASSERT(fmt);
|
|
||||||
|
|
||||||
fmt += _lg_parse_lvl(fmt, strlen(fmt), &level);
|
|
||||||
if (level > session->lvl)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
|
||||||
__logtrace_vfmtout(session, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_trace_flush(void)
|
|
||||||
{
|
|
||||||
rt_device_control(_traceout_device, LOG_TRACE_CTRL_FLUSH, RT_NULL);
|
|
||||||
}
|
|
||||||
FINSH_FUNCTION_EXPORT_ALIAS(log_trace_flush, log_flush, flush log on the buffer);
|
|
||||||
|
|
||||||
/* RT-Thread common device interface */
|
|
||||||
static rt_size_t _log_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
int level;
|
|
||||||
rt_size_t head_len;
|
|
||||||
const char *ptr = buffer;
|
|
||||||
struct log_trace_session *session;
|
|
||||||
|
|
||||||
head_len = _lg_parse_lvl(ptr, size, &level);
|
|
||||||
head_len += _lg_parse_session(ptr+head_len, size-head_len, &session);
|
|
||||||
|
|
||||||
/* filter by level */
|
|
||||||
if (level > session->lvl)
|
|
||||||
return size;
|
|
||||||
|
|
||||||
if (_traceout_device != RT_NULL)
|
|
||||||
{
|
|
||||||
c = '[';
|
|
||||||
rt_device_write(_traceout_device, -1, &c, 1);
|
|
||||||
rt_device_write(_traceout_device, -1, session->id.name, _idname_len(session->id.num));
|
|
||||||
c = ']';
|
|
||||||
rt_device_write(_traceout_device, -1, &c, 1);
|
|
||||||
rt_device_write(_traceout_device, -1, ((char*)buffer)+head_len, size - head_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static rt_err_t _log_control(rt_device_t dev, int cmd, void *arg)
|
|
||||||
{
|
|
||||||
if (_traceout_device == RT_NULL) return -RT_ERROR;
|
|
||||||
|
|
||||||
return rt_device_control(_traceout_device, cmd, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef RT_USING_DEVICE_OPS
|
|
||||||
const static struct rt_device_ops log_device_ops =
|
|
||||||
{
|
|
||||||
RT_NULL,
|
|
||||||
RT_NULL,
|
|
||||||
RT_NULL,
|
|
||||||
RT_NULL,
|
|
||||||
_log_write,
|
|
||||||
_log_control
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int log_trace_init(void)
|
|
||||||
{
|
|
||||||
rt_memset(&_log_device, 0x00, sizeof(_log_device));
|
|
||||||
|
|
||||||
_log_device.type = RT_Device_Class_Char;
|
|
||||||
#ifdef RT_USING_DEVICE_OPS
|
|
||||||
_log_device.ops = &log_device_ops;
|
|
||||||
#else
|
|
||||||
_log_device.init = RT_NULL;
|
|
||||||
_log_device.open = RT_NULL;
|
|
||||||
_log_device.close = RT_NULL;
|
|
||||||
_log_device.read = RT_NULL;
|
|
||||||
_log_device.write = _log_write;
|
|
||||||
_log_device.control = _log_control;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* no indication and complete callback */
|
|
||||||
_log_device.rx_indicate = RT_NULL;
|
|
||||||
_log_device.tx_complete = RT_NULL;
|
|
||||||
|
|
||||||
rt_device_register(&_log_device, "log", RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_RDWR);
|
|
||||||
|
|
||||||
/* set console as default device */
|
|
||||||
_traceout_device = rt_console_get_device();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
INIT_DEVICE_EXPORT(log_trace_init);
|
|
||||||
|
|
||||||
rt_device_t log_trace_get_device(void)
|
|
||||||
{
|
|
||||||
return _traceout_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
rt_err_t log_trace_set_device(const char *device_name)
|
|
||||||
{
|
|
||||||
struct rt_device *output_device;
|
|
||||||
|
|
||||||
/* find out output device */
|
|
||||||
output_device = rt_device_find(device_name);
|
|
||||||
if (output_device != RT_NULL)
|
|
||||||
{
|
|
||||||
rt_err_t result;
|
|
||||||
|
|
||||||
/* open device */
|
|
||||||
result = rt_device_open(output_device, RT_DEVICE_FLAG_STREAM | RT_DEVICE_OFLAG_RDWR);
|
|
||||||
if (result != RT_EOK)
|
|
||||||
{
|
|
||||||
rt_kprintf("Open trace device failed.\n");
|
|
||||||
return -RT_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set trace out device */
|
|
||||||
if (_traceout_device != RT_NULL)
|
|
||||||
rt_device_close(_traceout_device);
|
|
||||||
_traceout_device = output_device;
|
|
||||||
|
|
||||||
return RT_EOK;
|
|
||||||
}
|
|
||||||
FINSH_FUNCTION_EXPORT_ALIAS(log_trace_set_device, log_device, set device of log trace);
|
|
||||||
|
|
|
@ -1,187 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* Bernard the first version
|
|
||||||
* 2013-06-26 Grissiom refactor
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LOG_TRACE_H__
|
|
||||||
#define __LOG_TRACE_H__
|
|
||||||
|
|
||||||
#include <rtthread.h>
|
|
||||||
|
|
||||||
#define LOG_TRACE_LEVEL_MASK 0x0f
|
|
||||||
#define LOG_TRACE_LEVEL_NOTRACE 0x00
|
|
||||||
#define LOG_TRACE_LEVEL_ERROR 0x01
|
|
||||||
#define LOG_TRACE_LEVEL_WARNING 0x03
|
|
||||||
#define LOG_TRACE_LEVEL_INFO 0x05
|
|
||||||
#define LOG_TRACE_LEVEL_VERBOSE 0x07
|
|
||||||
#define LOG_TRACE_LEVEL_DEBUG 0x09
|
|
||||||
#define LOG_TRACE_LEVEL_ALL 0x0f
|
|
||||||
|
|
||||||
#if defined(LOG_TRACE_USING_LEVEL_NOTRACE)
|
|
||||||
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_NOTRACE
|
|
||||||
#elif defined(LOG_TRACE_USING_LEVEL_ERROR)
|
|
||||||
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_ERROR
|
|
||||||
#elif defined(LOG_TRACE_USING_LEVEL_WARNING)
|
|
||||||
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_WARNING
|
|
||||||
#elif defined(LOG_TRACE_USING_LEVEL_INFO)
|
|
||||||
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_INFO
|
|
||||||
#elif defined(LOG_TRACE_USING_LEVEL_VERBOSE)
|
|
||||||
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_VERBOSE
|
|
||||||
#elif defined(LOG_TRACE_USING_LEVEL_DEBUG)
|
|
||||||
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_DEBUG
|
|
||||||
#else
|
|
||||||
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_INFO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOG_TRACE_ERROR "<1>"
|
|
||||||
#define LOG_TRACE_WARNING "<3>"
|
|
||||||
#define LOG_TRACE_INFO "<5>"
|
|
||||||
#define LOG_TRACE_VERBOSE "<7>"
|
|
||||||
#define LOG_TRACE_DEBUG "<9>"
|
|
||||||
|
|
||||||
#define LOG_TRACE_OPT_NOTS 0x10 /* no timestamp */
|
|
||||||
#define LOG_TRACE_OPT_LN 0x20 /* terminate the current line */
|
|
||||||
|
|
||||||
#define LOG_TRACE_CTRL_FLUSH 0x10
|
|
||||||
#define LOG_TRACE_CTRL_RESET 0x11
|
|
||||||
#define LOG_TRACE_CTRL_DUMP 0x12
|
|
||||||
|
|
||||||
//#define LOG_TRACE_USE_LONGNAME
|
|
||||||
|
|
||||||
#ifndef LOG_TRACE_BUFSZ
|
|
||||||
#define LOG_TRACE_BUFSZ RT_CONSOLEBUF_SIZE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** maximum number of sessions that can be registered to the log_trace system
|
|
||||||
*/
|
|
||||||
#ifndef LOG_TRACE_MAX_SESSION
|
|
||||||
#define LOG_TRACE_MAX_SESSION 16
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LOG_TRACE_USE_LONGNAME
|
|
||||||
typedef rt_uint64_t log_trace_idnum_t;
|
|
||||||
#else
|
|
||||||
typedef rt_uint32_t log_trace_idnum_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* use a integer to represent a string to avoid strcmp. Even 4 chars
|
|
||||||
* should be enough for most of the cases.
|
|
||||||
* NOTE: take care when converting the name string to id number, you
|
|
||||||
* can trapped in endianness.
|
|
||||||
*/
|
|
||||||
union log_trace_id {
|
|
||||||
char name[sizeof(log_trace_idnum_t)];
|
|
||||||
log_trace_idnum_t num;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct log_trace_session
|
|
||||||
{
|
|
||||||
union log_trace_id id;
|
|
||||||
rt_uint8_t lvl;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** initialize the log_trace system */
|
|
||||||
int log_trace_init(void);
|
|
||||||
|
|
||||||
/** register a session.
|
|
||||||
*
|
|
||||||
* @return RT_EOK on success. -RT_EFULL if there is no space for registration.
|
|
||||||
*/
|
|
||||||
rt_err_t log_trace_register_session(const struct log_trace_session *session);
|
|
||||||
|
|
||||||
/** find a session with name
|
|
||||||
*
|
|
||||||
* The name is not enclosed by parenthesis([]).
|
|
||||||
*
|
|
||||||
* @return RT_NULL if there is no such a session.
|
|
||||||
*/
|
|
||||||
struct log_trace_session* log_trace_session_find(const char *name);
|
|
||||||
|
|
||||||
/** set the log level of the default session. */
|
|
||||||
void log_trace_set_level(rt_uint8_t level);
|
|
||||||
|
|
||||||
/** set the log level of the session */
|
|
||||||
void log_trace_session_set_level(
|
|
||||||
struct log_trace_session *session, rt_uint8_t level);
|
|
||||||
|
|
||||||
/** log according to the format
|
|
||||||
*
|
|
||||||
* the format of log_trace is: "<level>[name]log messages". It will output
|
|
||||||
* "[systick][name]log messages" When there is no session named name, the
|
|
||||||
* default session will be used.
|
|
||||||
*
|
|
||||||
* We have keep the level tag before the name tag because we don't print put
|
|
||||||
* the level tag to the output and it's easier to implement if we place the
|
|
||||||
* level tag in the very beginning.
|
|
||||||
*/
|
|
||||||
void log_trace(const char *fmt, ...);
|
|
||||||
|
|
||||||
/** log into session.
|
|
||||||
*
|
|
||||||
* the format of log_trace is: "<level>log messages". It will output
|
|
||||||
* "[systick][name]log messages". The name is the name of the session. It is
|
|
||||||
* faster than bare log_trace.
|
|
||||||
*/
|
|
||||||
void log_session(const struct log_trace_session *session, const char *fmt, ...);
|
|
||||||
|
|
||||||
extern void __logtrace_vfmtout(const struct log_trace_session *session,
|
|
||||||
const char *fmt,
|
|
||||||
va_list argptr);
|
|
||||||
|
|
||||||
rt_inline void __logtrace_fmtout(const struct log_trace_session *session,
|
|
||||||
const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
|
||||||
__logtrace_vfmtout(session, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* log with numeric level
|
|
||||||
*
|
|
||||||
* The prototype of this function is:
|
|
||||||
*
|
|
||||||
* void log_session_lvl(struct log_trace_session *session,
|
|
||||||
* int lvl,
|
|
||||||
* const char *fmt, ...);
|
|
||||||
*
|
|
||||||
* If the @session is const and @level is greater than @session->lvl, the whole
|
|
||||||
* function will be optimized out. This is suitable for performance critical
|
|
||||||
* places where in most cases, the log is turned off by level.
|
|
||||||
*/
|
|
||||||
#define log_session_lvl(session, level, fmt, ...) \
|
|
||||||
do { \
|
|
||||||
if ((level) > (session)->lvl) \
|
|
||||||
{ \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
__logtrace_fmtout(session, fmt, ##__VA_ARGS__); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* here comes the global part. All sessions share the some output backend. */
|
|
||||||
|
|
||||||
/** get the backend device */
|
|
||||||
rt_device_t log_trace_get_device(void);
|
|
||||||
|
|
||||||
/** set the backend device */
|
|
||||||
rt_err_t log_trace_set_device(const char *device_name);
|
|
||||||
|
|
||||||
void log_trace_flush(void);
|
|
||||||
|
|
||||||
#ifdef RT_USING_DFS
|
|
||||||
/** set the backend to file */
|
|
||||||
void log_trace_set_file(const char *filename);
|
|
||||||
|
|
||||||
void log_trace_file_init(const char *filename);
|
|
||||||
#endif /* RT_USING_DFS */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Change Logs:
|
|
||||||
* Date Author Notes
|
|
||||||
* 2013-06-26 Grissiom the first version
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <rtthread.h>
|
|
||||||
#include <rtdevice.h>
|
|
||||||
#include <log_trace.h>
|
|
||||||
|
|
||||||
#define PIPE_SZ 2048
|
|
||||||
#define PIPE_NAME "memlog"
|
|
||||||
|
|
||||||
static rt_pipe_t *_log_pipe = NULL;
|
|
||||||
static rt_uint8_t outbuf[1024];
|
|
||||||
void memlog_flush(void)
|
|
||||||
{
|
|
||||||
rt_size_t readsz;
|
|
||||||
rt_device_t console;
|
|
||||||
|
|
||||||
console = rt_console_get_device();
|
|
||||||
if (!console) return;
|
|
||||||
|
|
||||||
readsz = rt_device_read((rt_device_t)&(_log_pipe->parent), 0, outbuf, sizeof(outbuf));
|
|
||||||
if (readsz)
|
|
||||||
rt_device_write(console, 0, outbuf, readsz);
|
|
||||||
}
|
|
||||||
|
|
||||||
int memlog_init(void)
|
|
||||||
{
|
|
||||||
_log_pipe = rt_pipe_create(PIPE_NAME, PIPE_SZ);
|
|
||||||
if (_log_pipe == RT_NULL)
|
|
||||||
{
|
|
||||||
rt_kprintf("init pipe device failed.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_trace_set_device(PIPE_NAME);
|
|
||||||
rt_thread_idle_sethook(memlog_flush);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
INIT_APP_EXPORT(memlog_init);
|
|
|
@ -21,38 +21,11 @@
|
||||||
#define RT_VBUS_RB_LOW_TICK (RT_VMM_RB_BLK_NR * 2 / 3)
|
#define RT_VBUS_RB_LOW_TICK (RT_VMM_RB_BLK_NR * 2 / 3)
|
||||||
#define RT_VBUS_RB_TICK_STEP (100)
|
#define RT_VBUS_RB_TICK_STEP (100)
|
||||||
|
|
||||||
#ifndef RT_USING_LOGTRACE
|
|
||||||
/* console could be run on vbus. If we log on it, there will be oops. */
|
/* console could be run on vbus. If we log on it, there will be oops. */
|
||||||
#define vbus_debug(...)
|
#define vbus_debug(...)
|
||||||
#define vbus_verbose(...)
|
#define vbus_verbose(...)
|
||||||
#define vbus_info(...)
|
#define vbus_info(...)
|
||||||
#define vbus_error(...)
|
#define vbus_error(...)
|
||||||
#else // have RT_USING_LOGTRACE
|
|
||||||
#include <log_trace.h>
|
|
||||||
|
|
||||||
#if defined(log_session_lvl)
|
|
||||||
/* Define log_trace_session as const so the compiler could optimize some log
|
|
||||||
* out. */
|
|
||||||
const static struct log_trace_session _lgs = {
|
|
||||||
.id = {.name = "vbus"},
|
|
||||||
.lvl = LOG_TRACE_LEVEL_VERBOSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define vbus_debug(fmt, ...) log_session_lvl(&_lgs, LOG_TRACE_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
|
||||||
#define vbus_verbose(fmt, ...) log_session_lvl(&_lgs, LOG_TRACE_LEVEL_VERBOSE, fmt, ##__VA_ARGS__)
|
|
||||||
#define vbus_info(fmt, ...) log_session_lvl(&_lgs, LOG_TRACE_LEVEL_INFO, fmt, ##__VA_ARGS__)
|
|
||||||
#define vbus_error(fmt, ...) log_session_lvl(&_lgs, LOG_TRACE_LEVEL_ERROR, fmt, ##__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
static struct log_trace_session _lgs = {
|
|
||||||
.id = {.name = "vbus"},
|
|
||||||
.lvl = LOG_TRACE_LEVEL_VERBOSE,
|
|
||||||
};
|
|
||||||
#define vbus_debug(fmt, ...) log_session(&_lgs, LOG_TRACE_DEBUG""fmt, ##__VA_ARGS__)
|
|
||||||
#define vbus_verbose(fmt, ...) log_session(&_lgs, LOG_TRACE_VERBOSE""fmt, ##__VA_ARGS__)
|
|
||||||
#define vbus_info(fmt, ...) log_session(&_lgs, LOG_TRACE_INFO""fmt, ##__VA_ARGS__)
|
|
||||||
#define vbus_error(fmt, ...) log_session(&_lgs, LOG_TRACE_ERROR""fmt, ##__VA_ARGS__)
|
|
||||||
#endif
|
|
||||||
#endif // RT_USING_LOGTRACE
|
|
||||||
|
|
||||||
#ifndef ARRAY_SIZE
|
#ifndef ARRAY_SIZE
|
||||||
#define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
|
#define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
|
||||||
|
@ -1158,10 +1131,6 @@ int rt_vbus_init(void *outr, void *inr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef RT_USING_LOGTRACE
|
|
||||||
log_trace_register_session(&_lgs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (outr > inr)
|
if (outr > inr)
|
||||||
{
|
{
|
||||||
RT_ASSERT((char*)outr - (char*)inr >= sizeof(struct rt_vbus_ring));
|
RT_ASSERT((char*)outr - (char*)inr >= sizeof(struct rt_vbus_ring));
|
||||||
|
|
|
@ -24,14 +24,6 @@ extern void rt_application_init(void);
|
||||||
|
|
||||||
void vmm_entry(struct vmm_entry_param* param) SECTION(".vmm_init");
|
void vmm_entry(struct vmm_entry_param* param) SECTION(".vmm_init");
|
||||||
|
|
||||||
#ifdef RT_USING_LOGTRACE
|
|
||||||
#include <log_trace.h>
|
|
||||||
static struct log_trace_session _lgs = {
|
|
||||||
.id = {.name = "vmm"},
|
|
||||||
.lvl = LOG_TRACE_LEVEL_VERBOSE,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct rt_thread vmm_thread SECTION(".bss.share.vmm");
|
struct rt_thread vmm_thread SECTION(".bss.share.vmm");
|
||||||
extern rt_uint8_t vmm_stack_start;
|
extern rt_uint8_t vmm_stack_start;
|
||||||
extern rt_uint8_t vmm_stack_end;
|
extern rt_uint8_t vmm_stack_end;
|
||||||
|
@ -122,15 +114,6 @@ void vmm_entry(struct vmm_entry_param *param)
|
||||||
/* init board */
|
/* init board */
|
||||||
rt_hw_board_init();
|
rt_hw_board_init();
|
||||||
|
|
||||||
#ifdef RT_USING_LOGTRACE
|
|
||||||
/* Some parts of VMM use log_trace, so we need to init it right after
|
|
||||||
* board_init. */
|
|
||||||
log_trace_init();
|
|
||||||
log_trace_set_device(RT_CONSOLE_DEVICE_NAME);
|
|
||||||
|
|
||||||
log_trace_register_session(&_lgs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* show version */
|
/* show version */
|
||||||
rt_show_version();
|
rt_show_version();
|
||||||
rt_kprintf("share ctx: %p(%x)\n",
|
rt_kprintf("share ctx: %p(%x)\n",
|
||||||
|
|
|
@ -30,18 +30,13 @@ unsigned long vmm_find_iomap_by_pa(unsigned long pa);
|
||||||
|
|
||||||
void vmm_vector_init(void);
|
void vmm_vector_init(void);
|
||||||
|
|
||||||
#ifndef RT_USING_LOGTRACE
|
|
||||||
/* If the rshell is run, we could not rt_kprintf in some situation because
|
/* If the rshell is run, we could not rt_kprintf in some situation because
|
||||||
* write to a vbus channel *Would BLOCK*. So we cannot use it in interrupt
|
* write to a vbus channel *Would BLOCK*. So we cannot use it in interrupt
|
||||||
* context, we cannot use it within the context of idle(vmm). */
|
* context, we cannot use it within the context of idle(vmm). */
|
||||||
#define vmm_debug(fmt, ...)
|
#define vmm_debug(fmt, ...)
|
||||||
#define vmm_verbose(fmt, ...)
|
#define vmm_verbose(fmt, ...)
|
||||||
#define vmm_info(fmt, ...)
|
#define vmm_info(fmt, ...)
|
||||||
#else // have RT_USING_LOGTRACE
|
|
||||||
#define vmm_debug(fmt, ...) log_trace(LOG_TRACE_DEBUG "[vmm]"fmt, ##__VA_ARGS__)
|
|
||||||
#define vmm_verbose(fmt, ...) log_trace(LOG_TRACE_VERBOSE"[vmm]"fmt, ##__VA_ARGS__)
|
|
||||||
#define vmm_info(fmt, ...) log_trace(LOG_TRACE_INFO "[vmm]"fmt, ##__VA_ARGS__)
|
|
||||||
#endif // RT_USING_LOGTRACE
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
|
#define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
|
||||||
|
|
Loading…
Reference in New Issue