blob: e5e6cb23e505d0a02f5e55e73d3361dccb1fe926 [file] [log] [blame]
Julian Hall04460402021-07-08 17:40:57 +01001/*
2 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef LOGGING_CALLER_H
8#define LOGGING_CALLER_H
9
10#include <stdint.h>
11#include <stdio.h>
12#include <rpc_caller.h>
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**
20 * An rpc_caller that logs call requests and responses to a file.
21 * Can be stacked on top of another rpc_caller to allow call traffic to be
22 * observed without interferring with the call flow. Intended to be used
23 * for debug and test purposes.
24 **/
25struct logging_caller
26{
27 struct rpc_caller rpc_caller;
28 struct rpc_caller *attached_caller;
29 uint32_t call_index;
30 FILE *log_file;
31};
32
33/**
34 * @brief Initialises a logging_caller
35 *
36 * @param[in] this_instance The RPC caller instance to initialize
37 * @param[in] log_file Log to this file (assumed to be open)
38 */
39void logging_caller_init(
40 struct logging_caller *this_instance,
41 FILE *log_file);
42
43/**
44 * @brief De-initialises a logging_caller
45 *
46 * @param[in] this_instance The RPC caller instance to deinitialize
47 */
48void logging_caller_deinit(
49 struct logging_caller *this_instance);
50
51/**
52 * @brief Attach an rpc_caller to form a stack
53 *
54 * @param[in] this_instance The RPC caller instance to initialize
55 * @param[in] attached_caller Stacked over this rpc_caller
56 *
57 * @return The base rpc_caller that a client may use
58 */
59struct rpc_caller *logging_caller_attach(
60 struct logging_caller *this_instance,
61 struct rpc_caller *attached_caller);
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif /* LOGGING_CALLER_H */