zephyr/boards/posix/nrf52_bsim/trace_hook.c
Alberto Escolar Piedras 157596acf4 nrf52_bsim: drivers/console: Refactor printk backend
Fix a very old cmake warning for the nrf52_bsim due to the
console library being empty.
The printk backend was originally provided by the board
code for simplicity, but this left the console library
empty when building for this board.
Instead refactor that code to where all printk backends are.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-24 13:29:53 +02:00

52 lines
1.2 KiB
C

/*
* Copyright (c) 2017 Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <stdarg.h>
#include "bs_tracing.h"
#include "posix_board_if.h"
/*
* Provide the posix_print_* functions required from all POSIX arch boards
* (This functions provide a lower level, more direct, print mechanism than
* Zephyr's printk or logger and therefore can be relied on even if the kernel
* is down.
*/
void posix_print_error_and_exit(const char *format, ...)
{
va_list variable_argsp;
va_start(variable_argsp, format);
bs_trace_vprint(BS_TRACE_WARNING, NULL, 0, 0, BS_TRACE_AUTOTIME, 0,
format, variable_argsp);
va_end(variable_argsp);
posix_exit(1);
}
void posix_print_warning(const char *format, ...)
{
va_list variable_argsp;
va_start(variable_argsp, format);
bs_trace_vprint(BS_TRACE_WARNING, NULL, 0, 0, BS_TRACE_AUTOTIME, 0,
format, variable_argsp);
va_end(variable_argsp);
}
void posix_print_trace(const char *format, ...)
{
va_list variable_argsp;
va_start(variable_argsp, format);
bs_trace_vprint(BS_TRACE_RAW, NULL, 0, 2, BS_TRACE_AUTOTIME, 0,
format, variable_argsp);
va_end(variable_argsp);
}
int posix_trace_over_tty(int file_number)
{
return bs_trace_is_tty(file_number);
}