| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2016 Ericsson |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | *******************************************************************************/ |
| 9 | |
| 10 | package org.lttng.scope.lttng.kernel.core.analysis.os.handlers.internal; |
| 11 | |
| 12 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
| 13 | import org.lttng.scope.lttng.kernel.core.trace.layout.ILttngKernelEventLayout; |
| 14 | |
| 15 | import ca.polymtl.dorsal.libdelorean.ITmfStateSystemBuilder; |
| 16 | import ca.polymtl.dorsal.libdelorean.exceptions.AttributeNotFoundException; |
| 17 | import ca.polymtl.dorsal.libdelorean.statevalue.TmfStateValue; |
| 18 | |
| 19 | /** |
| 20 | * IPI Exit Handler |
| 21 | * |
| 22 | * @author Matthew Khouzam |
| 23 | */ |
| 24 | public class IPIExitHandler extends KernelEventHandler { |
| 25 | |
| 26 | /** |
| 27 | * Constructor |
| 28 | * |
| 29 | * @param layout |
| 30 | * event layout |
| 31 | */ |
| 32 | public IPIExitHandler(ILttngKernelEventLayout layout) { |
| 33 | super(layout); |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public void handleEvent(ITmfStateSystemBuilder ss, ITmfEvent event) throws AttributeNotFoundException { |
| 38 | Integer cpu = KernelEventHandlerUtils.getCpu(event); |
| 39 | if (cpu == null) { |
| 40 | return; |
| 41 | } |
| 42 | int currentThreadNode = KernelEventHandlerUtils.getCurrentThreadNode(cpu, ss); |
| 43 | Integer irqId = ((Long) event.getContent().getField(getLayout().fieldIPIVector()).getValue()).intValue(); |
| 44 | /* Put this IRQ back to inactive in the resource tree */ |
| 45 | int quark = ss.getQuarkRelativeAndAdd(KernelEventHandlerUtils.getNodeIRQs(cpu, ss), irqId.toString()); |
| 46 | TmfStateValue value = TmfStateValue.nullValue(); |
| 47 | long timestamp = KernelEventHandlerUtils.getTimestamp(event); |
| 48 | ss.modifyAttribute(timestamp, value, quark); |
| 49 | |
| 50 | /* Set the previous process back to running */ |
| 51 | KernelEventHandlerUtils.setProcessToRunning(timestamp, currentThreadNode, ss); |
| 52 | |
| 53 | /* Set the CPU status back to running or "idle" */ |
| 54 | KernelEventHandlerUtils.cpuExitInterrupt(timestamp, cpu, ss); |
| 55 | } |
| 56 | } |