2020-02-06 11:59:54 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Oticon A/S
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <soc.h>
|
|
|
|
#include <cmdline.h>
|
|
|
|
#include <tracing_backend.h>
|
2023-07-06 21:56:45 +08:00
|
|
|
#include "tracing_backend_posix_bottom.h"
|
2020-02-06 11:59:54 +08:00
|
|
|
|
|
|
|
static void *out_stream;
|
|
|
|
static const char *file_name;
|
|
|
|
|
|
|
|
static void tracing_backend_posix_init(void)
|
|
|
|
{
|
|
|
|
if (file_name == NULL) {
|
|
|
|
file_name = "channel0_0";
|
|
|
|
}
|
|
|
|
|
2023-07-06 21:56:45 +08:00
|
|
|
out_stream = tracing_backend_posix_init_bottom(file_name);
|
2020-02-06 11:59:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tracing_backend_posix_output(
|
|
|
|
const struct tracing_backend *backend,
|
2020-05-28 00:26:57 +08:00
|
|
|
uint8_t *data, uint32_t length)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
2023-07-06 21:56:45 +08:00
|
|
|
ARG_UNUSED(backend);
|
2020-02-06 11:59:54 +08:00
|
|
|
|
2023-07-06 21:56:45 +08:00
|
|
|
tracing_backend_posix_output_bottom(data, length, out_stream);
|
2020-02-06 11:59:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct tracing_backend_api tracing_backend_posix_api = {
|
|
|
|
.init = tracing_backend_posix_init,
|
|
|
|
.output = tracing_backend_posix_output
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACING_BACKEND_DEFINE(tracing_backend_posix, tracing_backend_posix_api);
|
|
|
|
|
|
|
|
void tracing_backend_posix_option(void)
|
|
|
|
{
|
|
|
|
static struct args_struct_t tracing_backend_option[] = {
|
|
|
|
{
|
|
|
|
.manual = false,
|
|
|
|
.is_mandatory = false,
|
|
|
|
.is_switch = false,
|
|
|
|
.option = "trace-file",
|
|
|
|
.name = "file_name",
|
|
|
|
.type = 's',
|
|
|
|
.dest = (void *)&file_name,
|
|
|
|
.call_when_found = NULL,
|
|
|
|
.descript = "File name for tracing output.",
|
|
|
|
},
|
|
|
|
ARG_TABLE_ENDMARKER
|
|
|
|
};
|
|
|
|
|
|
|
|
native_add_command_line_opts(tracing_backend_option);
|
|
|
|
}
|
|
|
|
|
|
|
|
NATIVE_TASK(tracing_backend_posix_option, PRE_BOOT_1, 1);
|