blob: 6c6a0451dbec51343bf49732f817ba80f77ad803 [file] [log] [blame]
Keith Davis33ed2212020-03-30 10:43:41 +01001//
Jim Flynnbbfe6032020-07-20 16:57:44 +01002// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Keith Davis33ed2212020-03-30 10:43:41 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "DeactivateTimelineReportingCommandHandler.hpp"
7
Jim Flynnf9db3ef2022-03-08 21:23:44 +00008#include <common/include/ProfilingException.hpp>
9
Jan Eilers156113c2020-09-09 19:11:16 +010010#include <fmt/format.h>
Keith Davis33ed2212020-03-30 10:43:41 +010011
12
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000013namespace arm
Keith Davis33ed2212020-03-30 10:43:41 +010014{
15
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000016namespace pipe
Keith Davis33ed2212020-03-30 10:43:41 +010017{
18
Jim Flynnbbfe6032020-07-20 16:57:44 +010019void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet)
Keith Davis33ed2212020-03-30 10:43:41 +010020{
21 ProfilingState currentState = m_StateMachine.GetCurrentState();
22
23 switch ( currentState )
24 {
25 case ProfilingState::Uninitialised:
26 case ProfilingState::NotConnected:
27 case ProfilingState::WaitingForAck:
Jim Flynnf9db3ef2022-03-08 21:23:44 +000028 throw arm::pipe::ProfilingException(fmt::format(
29 "Deactivate Timeline Reporting Command Handler invoked while in a wrong state: {}",
30 GetProfilingStateName(currentState)));
Keith Davis33ed2212020-03-30 10:43:41 +010031 case ProfilingState::Active:
32 if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 7u))
33 {
Jim Flynnf9db3ef2022-03-08 21:23:44 +000034 throw arm::pipe::ProfilingException(std::string(
35 "Expected Packet family = 0, id = 7 but received family =")
36 + std::to_string(packet.GetPacketFamily())
37 + " id = " + std::to_string(packet.GetPacketId()));
Keith Davis33ed2212020-03-30 10:43:41 +010038 }
39
40 m_TimelineReporting.store(false);
41
42 // Notify Backends
43 m_BackendNotifier.NotifyBackendsForTimelineReporting();
44
45 break;
46 default:
Jim Flynnf9db3ef2022-03-08 21:23:44 +000047 throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}",
48 static_cast<int>(currentState)));
Keith Davis33ed2212020-03-30 10:43:41 +010049 }
50}
51
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000052} // namespace pipe
Keith Davis33ed2212020-03-30 10:43:41 +010053
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000054} // namespace arm