/*
 * Copyright 2018 Google Inc.
 *
 * 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 "config.h"

#include "ipmi.hpp"
#include "manager.hpp"
#include "process.hpp"
#include "utils.hpp"

#include <ipmid/api.h>

#include <ipmid/api-types.hpp>
#include <ipmid/handler.hpp>
#include <ipmid/iana.hpp>
#include <ipmid/oemopenbmc.hpp>
#include <ipmid/oemrouter.hpp>
#include <phosphor-logging/log.hpp>
#include <user_channel/channel_layer.hpp>

#include <cstdio>
#include <memory>
#include <span>

namespace blobs
{

using namespace phosphor::logging;

void setupBlobGlobalHandler() __attribute__((constructor));

void setupBlobGlobalHandler()
{
    std::fprintf(stderr,
                 "Registering OEM:[%#08X], Cmd:[%#04X] for Blob Commands\n",
                 oem::obmcOemNumber, oem::Cmd::blobTransferCmd);

    ipmi::registerOemHandler(
        ipmi::prioOemBase, oem::obmcOemNumber, oem::Cmd::blobTransferCmd,
        ::ipmi::Privilege::User,
        [](ipmi::Context::ptr ctx, uint8_t cmd,
           const std::vector<uint8_t>& data) {
            // Get current IPMI channel and get the max transfer size
            // (assuming that it does not change).
            return handleBlobCommand(
                cmd, data, ipmi::getChannelMaxTransferSize(ctx->channel));
        });

    /* Install handlers. */
    try
    {
        loadLibraries(getBlobManager(), BLOB_LIB_PATH);
    }
    catch (const std::exception& e)
    {
        log<level::ERR>("ERROR loading blob handlers",
                        entry("ERROR=%s", e.what()));
    }
}
} // namespace blobs
