blob: 778bdb772d96f377656ea800b76ac3d2c64ccd08 [file] [log] [blame]
Jim Flynn64063552020-02-14 10:18:08 +00001//
Jim Flynn6398a982020-05-27 17:05:21 +01002// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Jim Flynn64063552020-02-14 10:18:08 +00003// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include "CounterIdMap.hpp"
9#include "Holder.hpp"
Jim Flynnaf947722022-03-02 11:04:47 +000010#include "ICounterValues.hpp"
Jim Flynn34430252022-03-04 15:03:58 +000011#include "IInitialiseProfilingService.hpp"
Jim Flynn6398a982020-05-27 17:05:21 +010012#include "IProfilingServiceStatus.hpp"
Jim Flynn64063552020-02-14 10:18:08 +000013#include "ISendCounterPacket.hpp"
Jim Flynn3e9bc192022-03-23 23:01:26 +000014#include "ISendTimelinePacket.hpp"
Jim Flynnaf947722022-03-02 11:04:47 +000015#include "IReportStructure.hpp"
Jim Flynn27761832022-03-20 21:52:17 +000016#include "ProfilingOptions.hpp"
Jim Flynnaf947722022-03-02 11:04:47 +000017#include "ProfilingState.hpp"
Nikhil Raj5b1bcc92021-06-08 12:31:50 +010018
Jim Flynnc454ac92022-03-16 18:43:18 +000019#include <common/include/ICounterRegistry.hpp>
Jim Flynndecd08b2022-03-13 22:35:46 +000020#include <common/include/Optional.hpp>
Nikhil Raj5b1bcc92021-06-08 12:31:50 +010021#include <common/include/ProfilingGuidGenerator.hpp>
Jim Flynn64063552020-02-14 10:18:08 +000022
Jim Flynnc454ac92022-03-16 18:43:18 +000023
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000024namespace arm
Jim Flynn64063552020-02-14 10:18:08 +000025{
26
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000027namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000028{
29
Jim Flynn3e9bc192022-03-23 23:01:26 +000030// forward declaration
31class IBackendProfilingContext;
32
Jim Flynnaf947722022-03-02 11:04:47 +000033class IProfilingService : public IProfilingGuidGenerator,
34 public IProfilingServiceStatus,
35 public IReadWriteCounterValues
Jim Flynn64063552020-02-14 10:18:08 +000036{
37public:
Jim Flynnaf947722022-03-02 11:04:47 +000038 static std::unique_ptr<IProfilingService> CreateProfilingService(
Jim Flynn34430252022-03-04 15:03:58 +000039 uint16_t maxGlobalCounterId,
40 IInitialiseProfilingService& initialiser,
Jim Flynn9c85b412022-03-16 00:27:43 +000041 const std::string& softwareInfo,
42 const std::string& softwareVersion,
43 const std::string& hardwareVersion,
Jim Flynndecd08b2022-03-13 22:35:46 +000044 arm::pipe::Optional<IReportStructure&> reportStructure = arm::pipe::EmptyOptional());
Jim Flynn64063552020-02-14 10:18:08 +000045 virtual ~IProfilingService() {};
46 virtual std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const = 0;
47 virtual const ICounterMappings& GetCounterMappings() const = 0;
48 virtual ISendCounterPacket& GetSendCounterPacket() = 0;
49 virtual bool IsProfilingEnabled() const = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000050 virtual bool IsTimelineReportingEnabled() const = 0;
Jim Flynn64063552020-02-14 10:18:08 +000051 virtual CaptureData GetCaptureData() = 0;
Jim Flynnaf947722022-03-02 11:04:47 +000052 virtual ProfilingState GetCurrentState() const = 0;
53 // Resets the profiling options, optionally clears the profiling service entirely
54 virtual void ResetExternalProfilingOptions(const ProfilingOptions& options,
55 bool resetProfilingService = false) = 0;
56 virtual ProfilingState ConfigureProfilingService(const ProfilingOptions& options,
57 bool resetProfilingService = false) = 0;
58 // Store a profiling context returned from a backend that support profiling.
Cathal Corbett6f073722022-03-04 12:11:09 +000059 virtual void AddBackendProfilingContext(const std::string& backendId,
Jim Flynnaf947722022-03-02 11:04:47 +000060 std::shared_ptr<IBackendProfilingContext> profilingContext) = 0;
61 virtual ICounterRegistry& GetCounterRegistry() = 0;
62 virtual IRegisterCounterMapping& GetCounterMappingRegistry() = 0;
Jim Flynn34430252022-03-04 15:03:58 +000063 virtual bool IsCategoryRegistered(const std::string& categoryName) const = 0;
64 virtual void InitializeCounterValue(uint16_t counterUid) = 0;
65
Jim Flynnaf947722022-03-02 11:04:47 +000066 // IProfilingGuidGenerator functions
67 /// Return the next random Guid in the sequence
68 ProfilingDynamicGuid NextGuid() override;
69 /// Create a ProfilingStaticGuid based on a hash of the string
70 ProfilingStaticGuid GenerateStaticId(const std::string& str) override;
71 static ProfilingDynamicGuid GetNextGuid();
72 static ProfilingStaticGuid GetStaticId(const std::string& str);
73 void ResetGuidGenerator();
74
Jim Flynn34430252022-03-04 15:03:58 +000075 virtual void Disconnect() = 0;
76
Jim Flynnaf947722022-03-02 11:04:47 +000077private:
78 static ProfilingGuidGenerator m_GuidGenerator;
Jim Flynn64063552020-02-14 10:18:08 +000079};
80
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000081} // namespace pipe
Jim Flynn64063552020-02-14 10:18:08 +000082
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000083} // namespace arm