Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "DeactivateTimelineReportingCommandHandler.hpp" |
| 7 | |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 8 | #include <common/include/ProfilingException.hpp> |
| 9 | |
Jan Eilers | 156113c | 2020-09-09 19:11:16 +0100 | [diff] [blame] | 10 | #include <fmt/format.h> |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 11 | |
| 12 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 13 | namespace arm |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 14 | { |
| 15 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 16 | namespace pipe |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 17 | { |
| 18 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 19 | void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet) |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 20 | { |
| 21 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 22 | |
| 23 | switch ( currentState ) |
| 24 | { |
| 25 | case ProfilingState::Uninitialised: |
| 26 | case ProfilingState::NotConnected: |
| 27 | case ProfilingState::WaitingForAck: |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 28 | throw arm::pipe::ProfilingException(fmt::format( |
| 29 | "Deactivate Timeline Reporting Command Handler invoked while in a wrong state: {}", |
| 30 | GetProfilingStateName(currentState))); |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 31 | case ProfilingState::Active: |
| 32 | if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 7u)) |
| 33 | { |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 34 | 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 Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | m_TimelineReporting.store(false); |
| 41 | |
| 42 | // Notify Backends |
| 43 | m_BackendNotifier.NotifyBackendsForTimelineReporting(); |
| 44 | |
| 45 | break; |
| 46 | default: |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 47 | throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", |
| 48 | static_cast<int>(currentState))); |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 52 | } // namespace pipe |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 53 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 54 | } // namespace arm |