blob: 0a69f27491f1cb44197cafdf4cd6ba0361091412 [file] [log] [blame]
Jim Flynn4e755a52020-03-29 17:48:26 +01001//
2// Copyright © 2020 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8
Jim Flynn27761832022-03-20 21:52:17 +00009#include <common/include/IgnoreUnused.hpp>
10#include <common/include/TargetEndianess.hpp>
Jim Flynn4e755a52020-03-29 17:48:26 +010011
12#include <cstdint>
13#include <memory>
14#include <vector>
15
Jim Flynnbbfe6032020-07-20 16:57:44 +010016// forward declare to prevent a circular dependency
17namespace arm
18{
19namespace pipe
20{
Jim Flynnbbfe6032020-07-20 16:57:44 +010021
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000022class Packet;
Jim Flynn01d02812020-04-29 21:12:13 +010023
Jim Flynn01d02812020-04-29 21:12:13 +010024// the handlers need to be able to do two
25// things to service the FileOnlyProfilingConnection
26// and any other implementation of IProfilingConnection
27// set the endianness and write a packet back i.e.
28// return a packet and close the connection
29class IInternalProfilingConnection
30{
31public:
32 virtual ~IInternalProfilingConnection() {};
33
34 virtual void SetEndianess(const TargetEndianness& endianness) = 0;
35
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000036 virtual void ReturnPacket(Packet& packet) = 0;
Jim Flynn01d02812020-04-29 21:12:13 +010037
38 virtual void Close() = 0;
39};
Jim Flynn4e755a52020-03-29 17:48:26 +010040
41class ILocalPacketHandler
42{
43public:
44 virtual ~ILocalPacketHandler() {};
45
46 /// @return lists the headers of the packets that this handler accepts
47 /// only these packets will get sent to this handler.
48 /// If this function returns an empty list then ALL packets
49 /// will be sent to the PacketHandler i.e. a universal handler.
50 virtual std::vector<uint32_t> GetHeadersAccepted() = 0;
51
52 /// process the packet
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000053 virtual void HandlePacket(const Packet& packet) = 0;
Jim Flynn4e755a52020-03-29 17:48:26 +010054
55 /// Set a profiling connection on the handler. Only need to implement this
56 /// function if the handler will be writing data back to the profiled application.
Jim Flynn01d02812020-04-29 21:12:13 +010057 virtual void SetConnection(IInternalProfilingConnection* profilingConnection)
Jim Flynn27761832022-03-20 21:52:17 +000058 {
59 arm::pipe::IgnoreUnused(profilingConnection);
60 }
Jim Flynn4e755a52020-03-29 17:48:26 +010061};
62
63using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>;
64using ILocalPacketHandlerSharedPtr = std::shared_ptr<ILocalPacketHandler>;
65
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000066} // namespace pipe
Jim Flynn4e755a52020-03-29 17:48:26 +010067
Jim Flynn27761832022-03-20 21:52:17 +000068} // namespace arm