1 // Copyright 2022 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "ipmi.hpp" 16 17 #include "bmc_mode.hpp" 18 #include "cable.hpp" 19 #include "commands.hpp" 20 #include "cpld.hpp" 21 #include "entity_name.hpp" 22 #include "eth.hpp" 23 #include "flash_size.hpp" 24 #include "google_accel_oob.hpp" 25 #include "handler.hpp" 26 #include "host_power_off.hpp" 27 #include "linux_boot_done.hpp" 28 #include "machine_name.hpp" 29 #include "pcie_bifurcation.hpp" 30 #include "pcie_i2c.hpp" 31 #include "psu.hpp" 32 33 #include <ipmid/api.h> 34 35 #include <ipmid/api-types.hpp> 36 #include <ipmid/message.hpp> 37 38 #include <cstdint> 39 #include <cstdio> 40 #include <optional> 41 #include <span> 42 43 namespace google 44 { 45 namespace ipmi 46 { 47 48 Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr, 49 uint8_t cmd, std::span<const uint8_t> data) 50 { 51 switch (cmd) 52 { 53 case SysGetBmcMode: 54 return getBmcMode(data, handler); 55 case SysCableCheck: 56 return cableCheck(data, handler); 57 case SysCpldVersion: 58 return cpldVersion(data, handler); 59 case SysGetEthDevice: 60 return getEthDevice(data, handler); 61 case SysPsuHardReset: 62 return psuHardReset(data, handler); 63 case SysPcieSlotCount: 64 return pcieSlotCount(data, handler); 65 case SysPcieSlotI2cBusMapping: 66 return pcieSlotI2cBusMapping(data, handler); 67 case SysEntityName: 68 return getEntityName(data, handler); 69 case SysMachineName: 70 return getMachineName(data, handler); 71 case SysPsuHardResetOnShutdown: 72 return psuHardResetOnShutdown(data, handler); 73 case SysGetFlashSize: 74 return getFlashSize(data, handler); 75 case SysHostPowerOff: 76 return hostPowerOff(data, handler); 77 case SysAccelOobDeviceCount: 78 return accelOobDeviceCount(data, handler); 79 case SysAccelOobDeviceName: 80 return accelOobDeviceName(data, handler); 81 case SysAccelOobRead: 82 return accelOobRead(data, handler); 83 case SysAccelOobWrite: 84 return accelOobWrite(data, handler); 85 case SysPCIeSlotBifurcation: 86 return pcieBifurcation(data, handler); 87 case SysLinuxBootDone: 88 return linuxBootDone(data, handler); 89 default: 90 std::fprintf(stderr, "Invalid subcommand: 0x%x\n", cmd); 91 return ::ipmi::responseInvalidCommand(); 92 } 93 } 94 95 } // namespace ipmi 96 } // namespace google 97