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