Skip to content

Commit

Permalink
[console] Flag to disable default console output
Browse files Browse the repository at this point in the history
Introduces a flag which allows a project to disable the default output
to platform_dputc. This is useful is the project wants to maintain
`platform_dputc` for panic conditions but otherwise use a registered
callback for console io.

Change-Id: I1362529a6bb40d191ac3f7c6069985c371d9284c
  • Loading branch information
schultetwin1 committed Nov 17, 2023
1 parent 94a1511 commit f89decc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/io/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ static void out_count(const char *str, size_t len) {
spin_unlock_restore(&print_spin_lock, state, PRINT_LOCK_FLAGS);
}

#if CONSOLE_OUTPUT_TO_PLATFORM_PUTC
/* write out the serial port */
for (i = 0; i < len; i++) {
platform_dputc(str[i]);
}
#endif
}

void register_print_callback(print_callback_t *cb) {
Expand Down
5 changes: 5 additions & 0 deletions lib/io/include/lib/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ static inline void io_handle_init(io_handle_t *io, io_handle_hooks_t *hooks) {
/* the main console io handle */
extern io_handle_t console_io;

/* should the console also output to the platform's putc (usually UART) */
#ifndef CONSOLE_OUTPUT_TO_PLATFORM_PUTC
#define CONSOLE_OUTPUT_TO_PLATFORM_PUTC 1
#endif

#ifndef CONSOLE_HAS_INPUT_BUFFER
#define CONSOLE_HAS_INPUT_BUFFER 0
#endif
Expand Down

0 comments on commit f89decc

Please sign in to comment.