Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | |
| 9 | #include <armnn/utility/IgnoreUnused.hpp> |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame^] | 10 | #include "../../../profiling/common/include/TargetEndianess.hpp" |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 11 | |
| 12 | #include <cstdint> |
| 13 | #include <memory> |
| 14 | #include <vector> |
| 15 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 16 | // forward declare to prevent a circular dependency |
| 17 | namespace arm |
| 18 | { |
| 19 | namespace pipe |
| 20 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 21 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame^] | 22 | class Packet; |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 23 | |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 24 | // 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 |
| 29 | class IInternalProfilingConnection |
| 30 | { |
| 31 | public: |
| 32 | virtual ~IInternalProfilingConnection() {}; |
| 33 | |
| 34 | virtual void SetEndianess(const TargetEndianness& endianness) = 0; |
| 35 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame^] | 36 | virtual void ReturnPacket(Packet& packet) = 0; |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 37 | |
| 38 | virtual void Close() = 0; |
| 39 | }; |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 40 | |
| 41 | class ILocalPacketHandler |
| 42 | { |
| 43 | public: |
| 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 Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame^] | 53 | virtual void HandlePacket(const Packet& packet) = 0; |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 54 | |
| 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 Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 57 | virtual void SetConnection(IInternalProfilingConnection* profilingConnection) |
| 58 | {armnn::IgnoreUnused(profilingConnection);} |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>; |
| 62 | using ILocalPacketHandlerSharedPtr = std::shared_ptr<ILocalPacketHandler>; |
| 63 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame^] | 64 | } // namespace pipe |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 65 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame^] | 66 | } // namespace arm |