tracing_buffer.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2019 Intel corporation
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <sys/ring_buffer.h>
  7. static struct ring_buf tracing_ring_buf;
  8. static uint8_t tracing_buffer[CONFIG_TRACING_BUFFER_SIZE + 1];
  9. static uint8_t tracing_cmd_buffer[CONFIG_TRACING_CMD_BUFFER_SIZE];
  10. uint32_t tracing_cmd_buffer_alloc(uint8_t **data)
  11. {
  12. *data = &tracing_cmd_buffer[0];
  13. return sizeof(tracing_cmd_buffer);
  14. }
  15. uint32_t tracing_buffer_put_claim(uint8_t **data, uint32_t size)
  16. {
  17. return ring_buf_put_claim(&tracing_ring_buf, data, size);
  18. }
  19. int tracing_buffer_put_finish(uint32_t size)
  20. {
  21. return ring_buf_put_finish(&tracing_ring_buf, size);
  22. }
  23. uint32_t tracing_buffer_put(uint8_t *data, uint32_t size)
  24. {
  25. return ring_buf_put(&tracing_ring_buf, data, size);
  26. }
  27. uint32_t tracing_buffer_get_claim(uint8_t **data, uint32_t size)
  28. {
  29. return ring_buf_get_claim(&tracing_ring_buf, data, size);
  30. }
  31. int tracing_buffer_get_finish(uint32_t size)
  32. {
  33. return ring_buf_get_finish(&tracing_ring_buf, size);
  34. }
  35. uint32_t tracing_buffer_get(uint8_t *data, uint32_t size)
  36. {
  37. return ring_buf_get(&tracing_ring_buf, data, size);
  38. }
  39. void tracing_buffer_init(void)
  40. {
  41. ring_buf_init(&tracing_ring_buf,
  42. sizeof(tracing_buffer), tracing_buffer);
  43. }
  44. bool tracing_buffer_is_empty(void)
  45. {
  46. return ring_buf_is_empty(&tracing_ring_buf);
  47. }
  48. uint32_t tracing_buffer_capacity_get(void)
  49. {
  50. return ring_buf_capacity_get(&tracing_ring_buf);
  51. }
  52. uint32_t tracing_buffer_space_get(void)
  53. {
  54. return ring_buf_space_get(&tracing_ring_buf);
  55. }