Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "PerJobCounterSelectionCommandHandler.hpp" |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 7 | |
| 8 | #include <common/include/CommonProfilingUtils.hpp> |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 9 | |
Jan Eilers | 156113c | 2020-09-09 19:11:16 +0100 | [diff] [blame] | 10 | #include <fmt/format.h> |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 11 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 12 | namespace arm |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 13 | { |
| 14 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 15 | namespace pipe |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 16 | { |
| 17 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 18 | void PerJobCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& packet) |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 19 | { |
| 20 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 21 | switch (currentState) |
| 22 | { |
| 23 | case ProfilingState::Uninitialised: |
| 24 | case ProfilingState::NotConnected: |
| 25 | case ProfilingState::WaitingForAck: |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 26 | throw arm::pipe::ProfilingException(fmt::format( |
Jan Eilers | 156113c | 2020-09-09 19:11:16 +0100 | [diff] [blame] | 27 | "Per-Job Counter Selection Command Handler invoked while in an incorrect state: {}", |
| 28 | GetProfilingStateName(currentState))); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 29 | case ProfilingState::Active: |
| 30 | // Process the packet |
| 31 | if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 5u)) |
| 32 | { |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 33 | throw arm::pipe::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 5 but " |
| 34 | "received family = {}, id = {}", |
| 35 | packet.GetPacketFamily(), |
| 36 | packet.GetPacketId())); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | // Silently drop the packet |
| 40 | |
| 41 | break; |
| 42 | default: |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 43 | throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", |
| 44 | static_cast<int>(currentState))); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 45 | } |
| 46 | } |
| 47 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 48 | } // namespace pipe |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 49 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 50 | } // namespace arm |