2020-02-06 11:59:54 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Intel corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 17:12:04 +08:00
|
|
|
#include <zephyr/sys/ring_buffer.h>
|
2020-02-06 11:59:54 +08:00
|
|
|
|
|
|
|
static struct ring_buf tracing_ring_buf;
|
2020-05-28 00:26:57 +08:00
|
|
|
static uint8_t tracing_buffer[CONFIG_TRACING_BUFFER_SIZE + 1];
|
|
|
|
static uint8_t tracing_cmd_buffer[CONFIG_TRACING_CMD_BUFFER_SIZE];
|
2020-02-06 11:59:54 +08:00
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t tracing_cmd_buffer_alloc(uint8_t **data)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
*data = &tracing_cmd_buffer[0];
|
|
|
|
|
|
|
|
return sizeof(tracing_cmd_buffer);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t tracing_buffer_put_claim(uint8_t **data, uint32_t size)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_put_claim(&tracing_ring_buf, data, size);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
int tracing_buffer_put_finish(uint32_t size)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_put_finish(&tracing_ring_buf, size);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t tracing_buffer_put(uint8_t *data, uint32_t size)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_put(&tracing_ring_buf, data, size);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t tracing_buffer_get_claim(uint8_t **data, uint32_t size)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_get_claim(&tracing_ring_buf, data, size);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
int tracing_buffer_get_finish(uint32_t size)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_get_finish(&tracing_ring_buf, size);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t tracing_buffer_get(uint8_t *data, uint32_t size)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_get(&tracing_ring_buf, data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tracing_buffer_init(void)
|
|
|
|
{
|
|
|
|
ring_buf_init(&tracing_ring_buf,
|
|
|
|
sizeof(tracing_buffer), tracing_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool tracing_buffer_is_empty(void)
|
|
|
|
{
|
|
|
|
return ring_buf_is_empty(&tracing_ring_buf);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t tracing_buffer_capacity_get(void)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_capacity_get(&tracing_ring_buf);
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:26:57 +08:00
|
|
|
uint32_t tracing_buffer_space_get(void)
|
2020-02-06 11:59:54 +08:00
|
|
|
{
|
|
|
|
return ring_buf_space_get(&tracing_ring_buf);
|
|
|
|
}
|