1 // Copyright 2026 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 "config.h" 16 17 #include "cpu_config.hpp" 18 19 #include "commands.hpp" 20 #include "handler.hpp" 21 22 #include <ipmid/api-types.hpp> 23 #include <ipmid/api.hpp> 24 #include <stdplus/print.hpp> 25 26 #include <cstdint> 27 #include <optional> 28 #include <vector> 29 30 namespace google 31 { 32 namespace ipmi 33 { 34 35 Resp getCoreCount(std::span<const uint8_t>, HandlerInterface* handler) 36 { 37 // data is not used in this function but is kept for consistency with other 38 // handlers. 39 std::optional<uint16_t> coreCountOpt = 40 handler->getCoreCount(CPU_CONFIG_PATH); 41 if (!coreCountOpt.has_value()) 42 { 43 return ::ipmi::responseUnspecifiedError(); 44 } 45 46 uint16_t coreCount = coreCountOpt.value(); 47 std::vector<uint8_t> reply; 48 reply.push_back(static_cast<uint8_t>(coreCount & 0xFF)); // LSB 49 reply.push_back(static_cast<uint8_t>((coreCount >> 8) & 0xFF)); // MSB 50 return ::ipmi::responseSuccess(SysOEMCommands::SysGetCoreCount, reply); 51 } 52 53 } // namespace ipmi 54 } // namespace google 55