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 "bios_setting.hpp" 18 #include "bm_instance.hpp" 19 #include "bmc_mode.hpp" 20 #include "cable.hpp" 21 #include "commands.hpp" 22 #include "cpld.hpp" 23 #include "entity_name.hpp" 24 #include "eth.hpp" 25 #include "flash_size.hpp" 26 #include "google_accel_oob.hpp" 27 #include "handler.hpp" 28 #include "host_power_off.hpp" 29 #include "linux_boot_done.hpp" 30 #include "machine_name.hpp" 31 #include "pcie_bifurcation.hpp" 32 #include "pcie_i2c.hpp" 33 #include "psu.hpp" 34 35 #include <ipmid/api.h> 36 37 #include <ipmid/api-types.hpp> 38 #include <ipmid/message.hpp> 39 #include <stdplus/print.hpp> 40 41 #include <cstdint> 42 #include <cstdio> 43 #include <optional> 44 #include <span> 45 46 namespace google 47 { 48 namespace ipmi 49 { 50 51 Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr ctx, 52 uint8_t cmd, std::span<const uint8_t> data) 53 { 54 switch (cmd) 55 { 56 case SysGetBmcMode: 57 return getBmcMode(data, handler); 58 case SysCableCheck: 59 return cableCheck(data, handler); 60 case SysCpldVersion: 61 return cpldVersion(data, handler); 62 case SysGetEthDevice: 63 return getEthDevice(data, handler); 64 case SysPsuHardReset: 65 return psuHardReset(data, handler); 66 case SysPcieSlotCount: 67 return pcieSlotCount(data, handler); 68 case SysPcieSlotI2cBusMapping: 69 return pcieSlotI2cBusMapping(data, handler); 70 case SysEntityName: 71 return getEntityName(data, handler); 72 case SysMachineName: 73 return getMachineName(data, handler); 74 case SysPsuHardResetOnShutdown: 75 return psuHardResetOnShutdown(data, handler); 76 case SysGetFlashSize: 77 return getFlashSize(data, handler); 78 case SysHostPowerOff: 79 return hostPowerOff(data, handler); 80 case SysAccelOobDeviceCount: 81 return accelOobDeviceCount(data, handler); 82 case SysAccelOobDeviceName: 83 return accelOobDeviceName(data, handler); 84 case SysAccelOobRead: 85 return accelOobRead(data, handler); 86 case SysAccelOobWrite: 87 return accelOobWrite(data, handler); 88 case SysPCIeSlotBifurcation: 89 return pcieBifurcation(data, handler); 90 case SysLinuxBootDone: 91 return linuxBootDone(data, handler); 92 case SysGetAccelVrSettings: 93 return accelGetVrSettings(ctx, data, handler); 94 case SysSetAccelVrSettings: 95 return accelSetVrSettings(ctx, data, handler); 96 case SysGetBMInstanceProperty: 97 return getBMInstanceProperty(data, handler); 98 case SysReadBiosSetting: 99 return readBiosSetting(data, handler); 100 default: 101 stdplus::print(stderr, "Invalid subcommand: {:#x}\n", cmd); 102 return ::ipmi::responseInvalidCommand(); 103 } 104 } 105 106 } // namespace ipmi 107 } // namespace google 108