Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions drivers/note/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@ if(CONFIG_DRIVERS_NOTE)
list(APPEND SRCS note_initialize.c)
endif()

if(CONFIG_DRIVERS_NOTEFILE OR CONFIG_DRIVERS_NOTELOWEROUT)
list(APPEND SRCS notestream_driver.c)
endif()

if(CONFIG_DRIVERS_NOTERAM)
if(NOT "${CONFIG_DRIVERS_NOTERAM_SECTION}" STREQUAL "")
target_compile_definitions(
drivers
PRIVATE -DDRIVERS_NOTERAM_SECTION="${CONFIG_DRIVERS_NOTERAM_SECTION}")
endif()

list(APPEND SRCS noteram_driver.c)
endif()

Expand Down
4 changes: 2 additions & 2 deletions drivers/note/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ config DRIVERS_NOTERPMSG_SERVER
bool "Enable RPMSG server for NOTE"
select DRIVERS_NOTE
default n
depends on RPTUN
depends on RPMSG
---help---
Use rpmsg to receive message from remote proc.

config DRIVERS_NOTERPMSG
bool "Note to RPMSG"
select DRIVERS_NOTE
depends on RPTUN
depends on RPMSG
depends on SCHED_WORKQUEUE
default n
---help---
Expand Down
51 changes: 30 additions & 21 deletions drivers/note/note_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
#define note_vprintf(drv, ip, fmt, va) \
((drv)->ops->vprintf && ((drv)->ops->vprintf(drv, ip, fmt, va), true))

#define BUFFER_SIZE 256
static_assert(BUFFER_SIZE >= sizeof(struct note_event_s),
"Buffer size too small");

/****************************************************************************
* Private Types
****************************************************************************/
Expand Down Expand Up @@ -607,7 +611,8 @@ void sched_note_add(FAR const void *data, size_t len)
* claims more than is left would wrap len and walk off the packet.
*/

if (notelen < sizeof(struct note_common_s) || notelen > len)
if (notelen < sizeof(struct note_common_s) ||
NOTE_ALIGN(notelen) > len)
{
break;
}
Expand All @@ -624,8 +629,12 @@ void sched_note_add(FAR const void *data, size_t len)
note_add(*driver, note, notelen);
}

data = (FAR void *)((uintptr_t)data + notelen);
len -= notelen;
/* The note data from note rpmsg is aligned. When parsing
* the data, it is necessary to align the notelen.
*/

data = (FAR void *)((uintptr_t)data + NOTE_ALIGN(notelen));
len -= NOTE_ALIGN(notelen);
}
}
#endif
Expand Down Expand Up @@ -749,7 +758,7 @@ void sched_note_stop(FAR struct tcb_s *tcb)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_stop_s));
note_add(*driver, &note, note.nsp_cmn.nc_length);
}
}

Expand Down Expand Up @@ -788,7 +797,7 @@ void sched_note_suspend(FAR struct tcb_s *tcb)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_suspend_s));
note_add(*driver, &note, note.nsu_cmn.nc_length);
}
}

Expand Down Expand Up @@ -826,7 +835,7 @@ void sched_note_resume(FAR struct tcb_s *tcb)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_resume_s));
note_add(*driver, &note, note.nre_cmn.nc_length);
}
}

Expand Down Expand Up @@ -866,7 +875,7 @@ void sched_note_cpu_start(FAR struct tcb_s *tcb, int cpu)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_cpu_start_s));
note_add(*driver, &note, note.ncs_cmn.nc_length);
}
}

Expand Down Expand Up @@ -904,7 +913,7 @@ void sched_note_cpu_started(FAR struct tcb_s *tcb)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_cpu_started_s));
note_add(*driver, &note, note.ncs_cmn.nc_length);
}
}

Expand Down Expand Up @@ -943,7 +952,7 @@ void sched_note_cpu_pause(FAR struct tcb_s *tcb, int cpu)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_cpu_pause_s));
note_add(*driver, &note, note.ncp_cmn.nc_length);
}
}

Expand Down Expand Up @@ -981,7 +990,7 @@ void sched_note_cpu_paused(FAR struct tcb_s *tcb)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_cpu_paused_s));
note_add(*driver, &note, note.ncp_cmn.nc_length);
}
}

Expand Down Expand Up @@ -1020,7 +1029,7 @@ void sched_note_cpu_resume(FAR struct tcb_s *tcb, int cpu)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_cpu_resume_s));
note_add(*driver, &note, note.ncr_cmn.nc_length);
}
}

Expand Down Expand Up @@ -1058,7 +1067,7 @@ void sched_note_cpu_resumed(FAR struct tcb_s *tcb)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_cpu_resumed_s));
note_add(*driver, &note, note.ncr_cmn.nc_length);
}
}
#endif /* CONFIG_SMP */
Expand Down Expand Up @@ -1102,7 +1111,7 @@ void sched_note_preemption(FAR struct tcb_s *tcb, bool locked)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_preempt_s));
note_add(*driver, &note, note.npr_cmn.nc_length);
}

spin_unlock_irqrestore_notrace(&g_note_lock, flags);
Expand Down Expand Up @@ -1147,7 +1156,7 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_csection_s));
note_add(*driver, &note, note.ncs_cmn.nc_length);
}
}
#endif
Expand Down Expand Up @@ -1206,7 +1215,7 @@ void sched_note_spinlock(FAR struct tcb_s *tcb,

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_spinlock_s));
note_add(*driver, &note, note.nsp_cmn.nc_length);
}
}

Expand Down Expand Up @@ -1362,7 +1371,7 @@ void sched_note_syscall_leave(int nr, uintptr_t result)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_syscall_leave_s));
note_add(*driver, &note, note.nsc_cmn.nc_length);
}
}
#endif
Expand Down Expand Up @@ -1404,7 +1413,7 @@ void sched_note_irqhandler(int irq, FAR void *handler, bool enter)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(struct note_irqhandler_s));
note_add(*driver, &note, note.nih_cmn.nc_length);
}
}
#endif
Expand Down Expand Up @@ -1441,7 +1450,7 @@ void sched_note_wdog(uint8_t event, FAR void *handler, FAR const void *arg)

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(note));
note_add(*driver, &note, note.nwd_cmn.nc_length);
}

leave_critical_section_notrace(flags);
Expand Down Expand Up @@ -1486,7 +1495,7 @@ void sched_note_heap(uint8_t event, FAR void *heap, FAR void *mem,

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(note));
note_add(*driver, &note, note.nhp_cmn.nc_length);
}
}
#endif
Expand All @@ -1498,7 +1507,7 @@ void sched_note_event_ip(uint32_t tag, uintptr_t ip, uint8_t event,
FAR struct note_event_s *note;
FAR struct note_driver_s **driver;
bool formatted = false;
char data[256];
char data[BUFFER_SIZE];
unsigned int length;
FAR struct tcb_s *tcb = running_task();

Expand Down Expand Up @@ -1552,7 +1561,7 @@ void sched_note_vprintf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
FAR struct note_printf_s *note;
FAR struct note_driver_s **driver;
bool formatted = false;
uint8_t data[256];
uint8_t data[BUFFER_SIZE];
size_t length = 0;
FAR struct tcb_s *tcb = running_task();

Expand Down
18 changes: 9 additions & 9 deletions drivers/note/notelog_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ static void notelog_csection(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb, bool enter);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
static void note_spinlock(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb,
FAR volatile void *spinlock,
int type);
static void notelog_spinlock(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb,
FAR volatile void *spinlock,
int type);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
static void notelog_irqhandler(FAR struct note_driver_s *drv, int irq,
Expand Down Expand Up @@ -109,7 +109,7 @@ static const struct note_driver_ops_s g_notelog_ops =
notelog_csection, /* csection */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
note_spinlock, /* spinlock */
notelog_spinlock, /* spinlock */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
NULL, /* syscall_enter */
Expand Down Expand Up @@ -283,10 +283,10 @@ static void notelog_csection(FAR struct note_driver_s *drv,
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS
static void note_spinlock(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb,
FAR volatile void *spinlock,
int type)
static void notelog_spinlock(FAR struct note_driver_s *drv,
FAR struct tcb_s *tcb,
FAR volatile void *spinlock,
int type)
{
FAR static const char * const tmp[] =
{
Expand Down
22 changes: 16 additions & 6 deletions drivers/note/noteram_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,6 @@ static ssize_t noteram_get(FAR struct noteram_driver_s *drv,

if (buflen < notelen)
{
/* Skip the large note so that we do not get constipated. */

drv->ni_read = noteram_next(drv, read, NOTE_ALIGN(notelen));

/* and return an error */

return -EFBIG;
Expand Down Expand Up @@ -496,9 +492,23 @@ static ssize_t noteram_read(FAR struct file *filep, FAR char *buffer,
if (ctx->mode == NOTERAM_MODE_READ_BINARY)
#endif
{
size_t nread = 0;

flags = spin_lock_irqsave_notrace(&drv->lock);
ret = noteram_get(drv, (FAR uint8_t *)buffer, buflen);
while (nread < buflen)
{
ret = noteram_get(drv, (FAR uint8_t *)buffer + nread,
buflen - nread);
if (ret <= 0)
{
break;
}

nread += ret;
}

spin_unlock_irqrestore_notrace(&drv->lock, flags);
return nread;
}
#ifdef CONFIG_DRIVERS_NOTERAM_TEXT_DUMP
else
Expand All @@ -509,7 +519,7 @@ static ssize_t noteram_read(FAR struct file *filep, FAR char *buffer,

do
{
uint8_t note[256];
aligned_data(sizeof(uintptr_t)) uint8_t note[256];

/* Get the next note (removing it from the buffer) */

Expand Down
Loading
Loading