/**
 * Copyright (C) 2019 IBM Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "nmi_interface.hpp"

extern "C"
{
#include <libpdbg.h>
#include <libpdbg_sbe.h>
}

#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <xyz/openbmc_project/Common/error.hpp>

namespace openpower
{
namespace proc
{

NMI::NMI(sdbusplus::bus_t& bus, const char* path) :
    Interface(bus, path), bus(bus), objectPath(path)
{}

void NMI::nmi()
{
    using namespace phosphor::logging;
    using InternalFailure =
        sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;

    struct pdbg_target* target;

    pdbg_for_each_class_target("thread", target)
    {
        if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
            continue;

        if (thread_stop(target) < 0 || !thread_status(target).quiesced)
        {
            log<level::ERR>("Failed to stop all threads");
            report<InternalFailure>();
            return;
        }
    }

    if (thread_sreset_all() < 0)
    {
        log<level::ERR>("Failed to sreset all threads");
        report<InternalFailure>();
    }
}
} // namespace proc
} // namespace openpower
