// Copyright 2022 Google LLC
//
// 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 "ipmi.hpp"

#include "bmc_mode.hpp"
#include "cable.hpp"
#include "commands.hpp"
#include "cpld.hpp"
#include "entity_name.hpp"
#include "eth.hpp"
#include "flash_size.hpp"
#include "google_accel_oob.hpp"
#include "handler.hpp"
#include "host_power_off.hpp"
#include "machine_name.hpp"
#include "pcie_bifurcation.hpp"
#include "pcie_i2c.hpp"
#include "psu.hpp"

#include <ipmid/api.h>

#include <cstdint>
#include <cstdio>
#include <ipmid/api-types.hpp>
#include <ipmid/message.hpp>
#include <optional>
#include <span>

namespace google
{
namespace ipmi
{

Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr,
                      uint8_t cmd, std::span<const uint8_t> data)
{
    switch (cmd)
    {
        case SysGetBmcMode:
            return getBmcMode(data, handler);
        case SysCableCheck:
            return cableCheck(data, handler);
        case SysCpldVersion:
            return cpldVersion(data, handler);
        case SysGetEthDevice:
            return getEthDevice(data, handler);
        case SysPsuHardReset:
            return psuHardReset(data, handler);
        case SysPcieSlotCount:
            return pcieSlotCount(data, handler);
        case SysPcieSlotI2cBusMapping:
            return pcieSlotI2cBusMapping(data, handler);
        case SysEntityName:
            return getEntityName(data, handler);
        case SysMachineName:
            return getMachineName(data, handler);
        case SysPsuHardResetOnShutdown:
            return psuHardResetOnShutdown(data, handler);
        case SysGetFlashSize:
            return getFlashSize(data, handler);
        case SysHostPowerOff:
            return hostPowerOff(data, handler);
        case SysAccelOobDeviceCount:
            return accelOobDeviceCount(data, handler);
        case SysAccelOobDeviceName:
            return accelOobDeviceName(data, handler);
        case SysAccelOobRead:
            return accelOobRead(data, handler);
        case SysAccelOobWrite:
            return accelOobWrite(data, handler);
        case SysPCIeSlotBifurcation:
            return pcieBifurcation(data, handler);
        default:
            std::fprintf(stderr, "Invalid subcommand: 0x%x\n", cmd);
            return ::ipmi::responseInvalidCommand();
    }
}

} // namespace ipmi
} // namespace google
