RTEMS  5.0.0
recordclient.h
1 /*
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (C) 2018, 2019 embedded brains GmbH
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /*
29  * This file must be compatible to general purpose POSIX system, e.g. Linux,
30  * FreeBSD. It may be used for utility programs.
31  */
32 
33 #ifndef _RTEMS_RECORDCLIENT_H
34 #define _RTEMS_RECORDCLIENT_H
35 
36 #include "recorddata.h"
37 
38 #include <stddef.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43 
50 #define RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT 32
51 
52 typedef enum {
53  RTEMS_RECORD_CLIENT_SUCCESS,
54  RTEMS_RECORD_CLIENT_ERROR_INVALID_MAGIC,
55  RTEMS_RECORD_CLIENT_ERROR_UNKNOWN_FORMAT,
56  RTEMS_RECORD_CLIENT_ERROR_UNSUPPORTED_VERSION,
57  RTEMS_RECORD_CLIENT_ERROR_UNSUPPORTED_CPU
58 } rtems_record_client_status;
59 
60 typedef rtems_record_client_status ( *rtems_record_client_handler )(
61  uint32_t seconds,
62  uint32_t nanoseconds,
63  uint32_t cpu,
64  rtems_record_event event,
65  uint64_t data,
66  void *arg
67 );
68 
69 typedef struct {
70  struct {
71  uint64_t bt;
72  uint32_t time_at_bt;
73  uint32_t time_last;
74  uint32_t time_accumulated;
75  } uptime;
76  uint32_t tail[ 2 ];
77  uint32_t head[ 2 ];
78  size_t index;
80 
82  uint64_t to_bt_scaler;
83  rtems_record_client_per_cpu per_cpu[ RTEMS_RECORD_CLIENT_MAXIMUM_CPU_COUNT ];
84  uint64_t data;
85  uint32_t cpu;
86  uint32_t event;
87  uint32_t count;
88  union {
89  rtems_record_item_32 format_32;
90  rtems_record_item_64 format_64;
91  } item;
92  size_t todo;
93  void *pos;
94  rtems_record_client_status ( *consume )(
96  const void *,
97  size_t
98  );
99  rtems_record_client_handler handler;
100  void *handler_arg;
101  uint32_t header[ 2 ];
103 
116  rtems_record_client_handler handler,
117  void *arg
118 );
119 
127 rtems_record_client_status rtems_record_client_run(
129  const void *buf,
130  size_t n
131 );
132 
135 #ifdef __cplusplus
136 }
137 #endif /* __cplusplus */
138 
139 #endif /* _RTEMS_RECORDCLIENT_H */
void rtems_record_client_init(rtems_record_client_context *ctx, rtems_record_client_handler handler, void *arg)
Initializes a record client.
Definition: record-client.c:426
rtems_record_client_status rtems_record_client_run(rtems_record_client_context *ctx, const void *buf, size_t n)
Runs the record client to consume new stream data.
Definition: record-client.c:441
rtems_record_event
The record events.
Definition: recorddata.h:88
Definition: recordclient.h:81
Definition: recordclient.h:69
The 32-bit format record item.
Definition: recorddata.h:1181