syslog & ramlog: add BOARDIOC_RESET_CAUSE for syslog & ramlog

cold boot should clear syslog & ramlog buffer

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-06-27 16:45:44 +08:00 committed by GUIDINGLI
parent d867c46bbc
commit 904ca21a00
2 changed files with 31 additions and 0 deletions

View File

@ -38,6 +38,7 @@
#include <assert.h>
#include <debug.h>
#include <ctype.h>
#include <sys/boardctl.h>
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
@ -224,6 +225,10 @@ static void ramlog_pollnotify(FAR struct ramlog_dev_s *priv,
static void ramlog_initbuf(void)
{
FAR struct ramlog_dev_s *priv = &g_sysdev;
#ifdef CONFIG_BOARDCTL_RESET_CAUSE
struct boardioc_reset_cause_s cause;
int ret;
#endif
bool is_empty = true;
char prev;
char cur;
@ -235,6 +240,17 @@ static void ramlog_initbuf(void)
return;
}
#ifdef CONFIG_BOARDCTL_RESET_CAUSE
memset(&cause, 0, sizeof(cause));
ret = boardctl(BOARDIOC_RESET_CAUSE, (uintptr_t)&cause);
if (ret >= 0 && cause.cause == BOARDIOC_RESETCAUSE_SYS_CHIPPOR)
{
memset(priv->rl_buffer, 0, priv->rl_bufsize);
priv->rl_head = priv->rl_tail = 0;
return;
}
#endif
prev = priv->rl_buffer[priv->rl_bufsize - 1];
for (i = 0; i < priv->rl_bufsize; i++)

View File

@ -28,6 +28,7 @@
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <sys/boardctl.h>
#ifdef CONFIG_ARCH_LOWPUTC
#include <nuttx/arch.h>
@ -387,6 +388,10 @@ ssize_t syslog_rpmsg_write(FAR struct syslog_channel_s *channel,
void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
{
FAR struct syslog_rpmsg_s *priv = &g_syslog_rpmsg;
#ifdef CONFIG_BOARDCTL_RESET_CAUSE
struct boardioc_reset_cause_s cause;
int ret;
#endif
char prev;
char cur;
size_t i;
@ -396,6 +401,16 @@ void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
priv->buffer = buffer;
priv->size = size;
#ifdef CONFIG_BOARDCTL_RESET_CAUSE
memset(&cause, 0, sizeof(cause));
ret = boardctl(BOARDIOC_RESET_CAUSE, (uintptr_t)&cause);
if (ret >= 0 && cause.cause == BOARDIOC_RESETCAUSE_SYS_CHIPPOR)
{
memset(buffer, 0, size);
return;
}
#endif
prev = priv->buffer[size - 1];
for (i = 0; i < size; i++)