Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018-present Facebook. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jayashree Dhanapal | 4ec8056 | 2022-06-28 15:41:47 +0530 | [diff] [blame] | 17 | #include <commandutils.hpp> |
Patrick Williams | 2405ae9 | 2023-05-10 07:50:09 -0500 | [diff] [blame] | 18 | #include <usb-dbg.hpp> |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 19 | |
| 20 | namespace ipmi |
| 21 | { |
| 22 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 23 | ipmi_ret_t getNetworkData(uint8_t lan_param, char* data); |
Daniel Hsu | d8d95a3 | 2024-05-27 16:05:25 +0800 | [diff] [blame] | 24 | std::string getMotherBoardFruName(); |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 25 | int8_t getFruData(std::string& serial, std::string& name); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 26 | int8_t sysConfig(std::vector<std::string>& data, size_t pos); |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame] | 27 | int8_t procInfo(std::string& result, size_t pos); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 28 | |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 29 | bool isMultiHostPlatform(); |
| 30 | |
| 31 | /* Declare Host Selector interface and path */ |
| 32 | namespace selector |
| 33 | { |
| 34 | const std::string path = "/xyz/openbmc_project/Chassis/Buttons/HostSelector"; |
| 35 | const std::string interface = |
Potin Lai | cff150e | 2022-09-19 09:34:57 +0800 | [diff] [blame] | 36 | "xyz.openbmc_project.Chassis.Buttons.HostSelector"; |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 37 | } // namespace selector |
| 38 | |
Vijay Khemka | 427b276 | 2019-12-12 12:49:25 -0800 | [diff] [blame] | 39 | /* Declare storage functions used here */ |
| 40 | namespace storage |
| 41 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 42 | int getSensorValue(std::string&, double&); |
| 43 | int getSensorUnit(std::string&, std::string&); |
Delphine CC Chiu | 2ca4aa0 | 2023-02-01 16:30:18 +0800 | [diff] [blame] | 44 | int getSensorThreshold(std::string&, std::string&); |
Vijay Khemka | 58bd5d8 | 2019-12-13 11:05:56 -0800 | [diff] [blame] | 45 | } // namespace storage |
Vijay Khemka | 427b276 | 2019-12-12 12:49:25 -0800 | [diff] [blame] | 46 | |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 47 | namespace boot |
| 48 | { |
| 49 | std::tuple<std::string, std::string> objPath(size_t id); |
| 50 | void setBootOrder(std::string bootObjPath, const std::vector<uint8_t>& bootSeq, |
| 51 | std::string hostName); |
| 52 | void getBootOrder(std::string bootObjPath, std::vector<uint8_t>& bootSeq, |
| 53 | std::string hostName); |
| 54 | } // namespace boot |
| 55 | |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 56 | void getMaxHostPosition(size_t& maxPosition) |
Potin Lai | f24c78e | 2022-10-27 17:13:14 +0800 | [diff] [blame] | 57 | { |
| 58 | try |
| 59 | { |
| 60 | std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); |
Patrick Williams | 010dee0 | 2024-08-16 15:19:44 -0400 | [diff] [blame] | 61 | std::string service = |
| 62 | getService(*dbus, ipmi::selector::interface, ipmi::selector::path); |
| 63 | Value variant = |
| 64 | getDbusProperty(*dbus, service, ipmi::selector::path, |
| 65 | ipmi::selector::interface, "MaxPosition"); |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 66 | maxPosition = std::get<size_t>(variant); |
Potin Lai | f24c78e | 2022-10-27 17:13:14 +0800 | [diff] [blame] | 67 | } |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 68 | catch (const std::exception& e) |
Potin Lai | f24c78e | 2022-10-27 17:13:14 +0800 | [diff] [blame] | 69 | { |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 70 | lg2::error("Unable to get max host position - {MAXPOSITION}", |
| 71 | "MAXPOSITION", maxPosition); |
| 72 | throw e; |
Potin Lai | f24c78e | 2022-10-27 17:13:14 +0800 | [diff] [blame] | 73 | } |
Potin Lai | f24c78e | 2022-10-27 17:13:14 +0800 | [diff] [blame] | 74 | } |
| 75 | |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 76 | void getSelectorPosition(size_t& hostPosition) |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 77 | { |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 78 | try |
| 79 | { |
| 80 | std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); |
Patrick Williams | 010dee0 | 2024-08-16 15:19:44 -0400 | [diff] [blame] | 81 | std::string service = |
| 82 | getService(*dbus, ipmi::selector::interface, ipmi::selector::path); |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 83 | Value variant = getDbusProperty(*dbus, service, ipmi::selector::path, |
| 84 | ipmi::selector::interface, "Position"); |
| 85 | hostPosition = std::get<size_t>(variant); |
| 86 | } |
| 87 | catch (const std::exception& e) |
| 88 | { |
| 89 | lg2::error("Unable to get host position - {POSITION}", "POSITION", |
| 90 | hostPosition); |
| 91 | throw e; |
| 92 | } |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 93 | } |
| 94 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 95 | static int panelNum = (sizeof(panels) / sizeof(struct ctrl_panel)) - 1; |
| 96 | |
| 97 | /* Returns the FRU the hand-switch is switched to. If it is switched to BMC |
| 98 | * it returns FRU_ALL. Note, if in err, it returns FRU_ALL */ |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 99 | static size_t plat_get_fru_sel() |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 100 | { |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 101 | size_t position; |
| 102 | bool platform = isMultiHostPlatform(); |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 103 | if (platform == true) |
| 104 | { |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 105 | getSelectorPosition(position); |
| 106 | if (position == BMC_POSITION) |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 107 | { |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 108 | return FRU_ALL; |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 109 | } |
| 110 | } |
| 111 | else |
| 112 | { |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 113 | /* For Tiogapass it just return 1, |
| 114 | * can modify to support more platform */ |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 115 | position = 1; |
| 116 | } |
| 117 | return position; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | // return 0 on seccuess |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 121 | void frame::init(size_t size) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 122 | { |
| 123 | // Reset status |
| 124 | idx_head = idx_tail = 0; |
| 125 | lines = 0; |
| 126 | esc_sts = 0; |
| 127 | pages = 1; |
| 128 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 129 | if (buf != nullptr && max_size == size) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 130 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 131 | return; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 132 | } |
| 133 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 134 | if (buf != nullptr && max_size != size) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 135 | { |
| 136 | delete[] buf; |
| 137 | } |
| 138 | // Initialize Configuration |
| 139 | title[0] = '\0'; |
| 140 | buf = new char[size]; |
| 141 | max_size = size; |
| 142 | max_page = size; |
| 143 | line_per_page = 7; |
| 144 | line_width = 16; |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 145 | overwrite = false; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 146 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 147 | return; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | // return 0 on seccuess |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 151 | void frame::append(const std::string& str, size_t indent) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 152 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 153 | for (auto ch : parse(str, indent)) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 154 | { |
| 155 | if (isFull()) |
| 156 | { |
| 157 | if (overwrite) |
| 158 | { |
| 159 | if (buf[idx_head] == LINE_DELIMITER) |
| 160 | lines--; |
| 161 | idx_head = (idx_head + 1) % max_size; |
| 162 | } |
| 163 | else |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 164 | { |
| 165 | throw std::overflow_error("No room in buffer"); |
| 166 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 167 | } |
| 168 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 169 | buf[idx_tail] = ch; |
| 170 | if (ch == LINE_DELIMITER) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 171 | lines++; |
| 172 | |
| 173 | idx_tail = (idx_tail + 1) % max_size; |
| 174 | } |
| 175 | |
| 176 | pages = (lines / line_per_page) + ((lines % line_per_page) ? 1 : 0); |
| 177 | |
| 178 | if (pages > max_page) |
| 179 | pages = max_page; |
| 180 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 181 | return; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | // return page size |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 185 | int frame::getPage(size_t page, char* page_buf, size_t page_buf_size) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 186 | { |
| 187 | int ret; |
| 188 | uint16_t line = 0; |
| 189 | uint16_t idx, len; |
| 190 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 191 | if (buf == nullptr) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 192 | return -1; |
| 193 | |
| 194 | // 1-based page |
| 195 | if (page > pages || page < 1) |
| 196 | return -1; |
| 197 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 198 | if (page_buf == nullptr || page_buf_size == 0) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 199 | return -1; |
| 200 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 201 | ret = snprintf(page_buf, 17, "%-10s %02zd/%02zd", title, page, pages); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 202 | len = strlen(page_buf); |
| 203 | if (ret < 0) |
| 204 | return -1; |
| 205 | |
| 206 | line = 0; |
| 207 | idx = idx_head; |
| 208 | while (line < ((page - 1) * line_per_page) && idx != idx_tail) |
| 209 | { |
| 210 | if (buf[idx] == LINE_DELIMITER) |
| 211 | line++; |
| 212 | idx = (idx + 1) % max_size; |
| 213 | } |
| 214 | |
| 215 | while (line < ((page)*line_per_page) && idx != idx_tail) |
| 216 | { |
| 217 | if (buf[idx] == LINE_DELIMITER) |
| 218 | { |
| 219 | line++; |
| 220 | } |
| 221 | else |
| 222 | { |
| 223 | page_buf[len++] = buf[idx]; |
| 224 | if (len == (page_buf_size - 1)) |
| 225 | { |
| 226 | break; |
| 227 | } |
| 228 | } |
| 229 | idx = (idx + 1) % max_size; |
| 230 | } |
| 231 | |
| 232 | return len; |
| 233 | } |
| 234 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 235 | bool frame::isFull() const |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 236 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 237 | if (buf == nullptr) |
| 238 | return true; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 239 | |
| 240 | if ((idx_tail + 1) % max_size == idx_head) |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 241 | return true; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 242 | else |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 243 | return false; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | // return 1 for Escape Sequence |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 247 | bool frame::isEscSeq(char chr) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 248 | { |
| 249 | uint8_t curr_sts = esc_sts; |
| 250 | |
| 251 | if (esc_sts == 0 && (chr == 0x1b)) |
| 252 | esc_sts = 1; // Escape Sequence |
| 253 | else if (esc_sts == 1 && (chr == 0x5b)) |
| 254 | esc_sts = 2; // Control Sequence Introducer(CSI) |
| 255 | else if (esc_sts == 1 && (chr != 0x5b)) |
| 256 | esc_sts = 0; |
| 257 | else if (esc_sts == 2 && (chr >= 0x40 && chr <= 0x7e)) |
| 258 | esc_sts = 0; |
| 259 | |
| 260 | if (curr_sts || esc_sts) |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 261 | return true; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 262 | else |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 263 | return false; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | // return 0 on success |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 267 | auto frame::parse(const std::string& input, size_t indent) -> std::string |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 268 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 269 | if (indent > line_width) |
| 270 | return {}; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 271 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 272 | std::string result; |
| 273 | size_t linepos = 0; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 274 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 275 | for (auto ch : input) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 276 | { |
Cosmo Chou | 6c02bfb | 2024-08-29 15:49:42 +0800 | [diff] [blame] | 277 | if (linepos == 0) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 278 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 279 | result.append(indent, ' '); |
| 280 | linepos = indent; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 281 | } |
| 282 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 283 | // Insert character. |
| 284 | result.push_back(ch); |
Cosmo Chou | 6c02bfb | 2024-08-29 15:49:42 +0800 | [diff] [blame] | 285 | |
| 286 | if (!isEscSeq(ch)) |
| 287 | { |
| 288 | // Check if new line is needed. |
| 289 | if (++linepos == line_width) |
| 290 | { |
| 291 | result.push_back(LINE_DELIMITER); |
| 292 | linepos = 0; |
| 293 | } |
| 294 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 295 | } |
| 296 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 297 | // Fill out remaining line. |
| 298 | result.append(line_width - linepos, ' '); |
| 299 | result.push_back(LINE_DELIMITER); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 300 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 301 | return result; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 302 | } |
| 303 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 304 | static int chk_cri_sel_update(uint8_t* cri_sel_up) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 305 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 306 | FILE* fp; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 307 | struct stat file_stat; |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 308 | size_t pos = plat_get_fru_sel(); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 309 | static uint8_t pre_pos = 0xff; |
| 310 | |
| 311 | fp = fopen("/mnt/data/cri_sel", "r"); |
| 312 | if (fp) |
| 313 | { |
| 314 | if ((stat("/mnt/data/cri_sel", &file_stat) == 0) && |
| 315 | (file_stat.st_mtime != frame_sel.mtime || pre_pos != pos)) |
| 316 | { |
| 317 | *cri_sel_up = 1; |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | *cri_sel_up = 0; |
| 322 | } |
| 323 | fclose(fp); |
| 324 | } |
| 325 | else |
| 326 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 327 | if (frame_sel.buf == nullptr || frame_sel.lines != 0 || pre_pos != pos) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 328 | { |
| 329 | *cri_sel_up = 1; |
| 330 | } |
| 331 | else |
| 332 | { |
| 333 | *cri_sel_up = 0; |
| 334 | } |
| 335 | } |
| 336 | pre_pos = pos; |
| 337 | return 0; |
| 338 | } |
| 339 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 340 | int plat_udbg_get_frame_info(uint8_t* num) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 341 | { |
| 342 | *num = 3; |
| 343 | return 0; |
| 344 | } |
| 345 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 346 | int plat_udbg_get_updated_frames(uint8_t* count, uint8_t* buffer) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 347 | { |
| 348 | uint8_t cri_sel_up = 0; |
| 349 | uint8_t info_page_up = 1; |
| 350 | |
| 351 | *count = 0; |
| 352 | |
| 353 | // info page update |
| 354 | if (info_page_up == 1) |
| 355 | { |
| 356 | buffer[*count] = 1; |
| 357 | *count += 1; |
| 358 | } |
| 359 | |
| 360 | // cri sel update |
| 361 | chk_cri_sel_update(&cri_sel_up); |
| 362 | if (cri_sel_up == 1) |
| 363 | { |
| 364 | buffer[*count] = 2; |
| 365 | *count += 1; |
| 366 | } |
| 367 | |
| 368 | // cri sensor update |
| 369 | buffer[*count] = 3; |
| 370 | *count += 1; |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 375 | int plat_udbg_get_post_desc(uint8_t index, uint8_t* next, uint8_t phase, |
| 376 | uint8_t* end, uint8_t* length, uint8_t* buffer) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 377 | { |
Vijay Khemka | cc0d6d9 | 2019-08-27 14:51:17 -0700 | [diff] [blame] | 378 | nlohmann::json postObj; |
| 379 | std::string postCode; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 380 | |
Vijay Khemka | cc0d6d9 | 2019-08-27 14:51:17 -0700 | [diff] [blame] | 381 | /* Get post description data stored in json file */ |
| 382 | std::ifstream file(JSON_POST_DATA_FILE); |
| 383 | if (file) |
| 384 | { |
| 385 | file >> postObj; |
| 386 | file.close(); |
| 387 | } |
| 388 | else |
| 389 | { |
| 390 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 391 | "Post code description file not found", |
| 392 | phosphor::logging::entry("POST_CODE_FILE=%s", JSON_POST_DATA_FILE)); |
| 393 | return -1; |
| 394 | } |
| 395 | |
| 396 | std::string phaseStr = "PhaseAny"; |
| 397 | if (postObj.find(phaseStr) == postObj.end()) |
| 398 | { |
| 399 | phaseStr = "Phase" + std::to_string(phase); |
| 400 | } |
| 401 | |
| 402 | if (postObj.find(phaseStr) == postObj.end()) |
| 403 | { |
| 404 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 405 | "Post code phase not available", |
| 406 | phosphor::logging::entry("PHASE=%d", phase)); |
| 407 | return -1; |
| 408 | } |
| 409 | |
| 410 | auto phaseObj = postObj[phaseStr]; |
| 411 | int phaseSize = phaseObj.size(); |
| 412 | |
| 413 | for (int i = 0; i < phaseSize; i++) |
| 414 | { |
| 415 | postCode = phaseObj[i][0]; |
| 416 | if (index == stoul(postCode, nullptr, 16)) |
| 417 | { |
| 418 | std::string postDesc = phaseObj[i][1]; |
| 419 | *length = postDesc.size(); |
| 420 | memcpy(buffer, postDesc.data(), *length); |
| 421 | buffer[*length] = '\0'; |
| 422 | |
| 423 | if (phaseSize != i + 1) |
| 424 | { |
| 425 | postCode = phaseObj[i + 1][0]; |
| 426 | *next = stoul(postCode, nullptr, 16); |
| 427 | *end = 0; |
| 428 | } |
| 429 | else |
| 430 | { |
| 431 | if (postObj.size() != phase) |
| 432 | { |
Patrick Williams | 010dee0 | 2024-08-16 15:19:44 -0400 | [diff] [blame] | 433 | std::string nextPhaseStr = |
| 434 | "Phase" + std::to_string(phase + 1); |
Vijay Khemka | cc0d6d9 | 2019-08-27 14:51:17 -0700 | [diff] [blame] | 435 | postCode = postObj[nextPhaseStr][0][0]; |
| 436 | *next = stoul(postCode, nullptr, 16); |
| 437 | *end = 0; |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | *next = 0xff; |
| 442 | *end = 1; |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | return 0; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 451 | "Post code description data not available", |
| 452 | phosphor::logging::entry("PHASE_CODE=%d_0x%x", phase, index)); |
| 453 | return -1; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 454 | } |
| 455 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 456 | int plat_udbg_get_gpio_desc(uint8_t index, uint8_t* next, uint8_t* level, |
| 457 | uint8_t* def, uint8_t* length, uint8_t* buffer) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 458 | { |
Vijay Khemka | 38183d6 | 2019-08-28 16:19:33 -0700 | [diff] [blame] | 459 | nlohmann::json gpioObj; |
| 460 | std::string gpioPin; |
| 461 | |
| 462 | /* Get gpio data stored in json file */ |
| 463 | std::ifstream file(JSON_GPIO_DATA_FILE); |
| 464 | if (file) |
| 465 | { |
| 466 | file >> gpioObj; |
| 467 | file.close(); |
| 468 | } |
| 469 | else |
| 470 | { |
| 471 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 472 | "GPIO pin description file not found", |
| 473 | phosphor::logging::entry("GPIO_PIN_DETAILS_FILE=%s", |
| 474 | JSON_GPIO_DATA_FILE)); |
| 475 | return -1; |
| 476 | } |
| 477 | |
| 478 | if (gpioObj.find(DEBUG_GPIO_KEY) == gpioObj.end()) |
| 479 | { |
| 480 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 481 | "GPIO pin details not available", |
| 482 | phosphor::logging::entry("GPIO_JSON_KEY=%d", DEBUG_GPIO_KEY)); |
| 483 | return -1; |
| 484 | } |
| 485 | |
| 486 | auto obj = gpioObj[DEBUG_GPIO_KEY]; |
| 487 | int objSize = obj.size(); |
| 488 | |
| 489 | for (int i = 0; i < objSize; i++) |
| 490 | { |
| 491 | if (obj[i].size() != GPIO_ARRAY_SIZE) |
| 492 | { |
| 493 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 494 | "Size of gpio array is incorrect", |
| 495 | phosphor::logging::entry("EXPECTED_SIZE=%d", GPIO_ARRAY_SIZE)); |
| 496 | return -1; |
| 497 | } |
| 498 | |
| 499 | gpioPin = obj[i][GPIO_PIN_INDEX]; |
| 500 | if (index == stoul(gpioPin, nullptr, 16)) |
| 501 | { |
| 502 | if (objSize != i + 1) |
| 503 | { |
| 504 | gpioPin = obj[i + 1][GPIO_PIN_INDEX]; |
| 505 | *next = stoul(gpioPin, nullptr, 16); |
| 506 | } |
| 507 | else |
| 508 | { |
| 509 | *next = 0xff; |
| 510 | } |
| 511 | |
| 512 | *level = obj[i][GPIO_LEVEL_INDEX]; |
| 513 | *def = obj[i][GPIO_DEF_INDEX]; |
| 514 | std::string gpioDesc = obj[i][GPIO_DESC_INDEX]; |
| 515 | *length = gpioDesc.size(); |
| 516 | memcpy(buffer, gpioDesc.data(), *length); |
| 517 | buffer[*length] = '\0'; |
| 518 | |
| 519 | return 0; |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 524 | "GPIO pin description data not available", |
| 525 | phosphor::logging::entry("GPIO_PIN=0x%x", index)); |
| 526 | return -1; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 527 | } |
| 528 | |
Bonnie Lo | e9baaff | 2022-11-08 16:36:21 +0800 | [diff] [blame] | 529 | static int getBiosVer(std::string& ver, size_t hostPosition) |
Vijay Khemka | 88884b8 | 2019-08-27 15:23:07 -0700 | [diff] [blame] | 530 | { |
| 531 | nlohmann::json appObj; |
| 532 | |
| 533 | std::ifstream file(JSON_APP_DATA_FILE); |
| 534 | if (file) |
| 535 | { |
| 536 | file >> appObj; |
| 537 | file.close(); |
Bonnie Lo | e9baaff | 2022-11-08 16:36:21 +0800 | [diff] [blame] | 538 | std::string version_key = KEY_SYSFW_VER + std::to_string(hostPosition); |
| 539 | |
| 540 | if (appObj.find(version_key) != appObj.end()) |
Vijay Khemka | 88884b8 | 2019-08-27 15:23:07 -0700 | [diff] [blame] | 541 | { |
Bonnie Lo | e9baaff | 2022-11-08 16:36:21 +0800 | [diff] [blame] | 542 | ver = appObj[version_key].get<std::string>(); |
Vijay Khemka | 88884b8 | 2019-08-27 15:23:07 -0700 | [diff] [blame] | 543 | return 0; |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | return -1; |
| 548 | } |
| 549 | |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 550 | int sendBicCmd(uint8_t netFn, uint8_t cmd, uint8_t bicAddr, |
| 551 | std::vector<uint8_t>& cmdData, std::vector<uint8_t>& respData) |
| 552 | { |
| 553 | static constexpr uint8_t lun = 0; |
| 554 | |
| 555 | auto bus = getSdBus(); |
| 556 | |
| 557 | auto method = bus->new_method_call("xyz.openbmc_project.Ipmi.Channel.Ipmb", |
| 558 | "/xyz/openbmc_project/Ipmi/Channel/Ipmb", |
| 559 | "org.openbmc.Ipmb", "sendRequest"); |
| 560 | method.append(bicAddr, netFn, lun, cmd, cmdData); |
| 561 | |
| 562 | auto reply = bus->call(method); |
| 563 | if (reply.is_method_error()) |
| 564 | { |
| 565 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 566 | "Error reading from BIC"); |
| 567 | return -1; |
| 568 | } |
| 569 | |
| 570 | IpmbMethodType resp; |
| 571 | reply.read(resp); |
| 572 | |
| 573 | respData = |
| 574 | std::move(std::get<std::remove_reference_t<decltype(respData)>>(resp)); |
| 575 | |
| 576 | return 0; |
| 577 | } |
| 578 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 579 | int sendMeCmd(uint8_t netFn, uint8_t cmd, std::vector<uint8_t>& cmdData, |
| 580 | std::vector<uint8_t>& respData) |
Vijay Khemka | dd14c0f | 2020-03-18 14:48:13 -0700 | [diff] [blame] | 581 | { |
| 582 | auto bus = getSdBus(); |
| 583 | |
| 584 | if (DEBUG) |
| 585 | { |
| 586 | std::cout << "ME NetFn:cmd " << (int)netFn << ":" << (int)cmd << "\n"; |
| 587 | std::cout << "ME req data: "; |
| 588 | for (auto d : cmdData) |
| 589 | { |
| 590 | std::cout << d << " "; |
| 591 | } |
| 592 | std::cout << "\n"; |
| 593 | } |
| 594 | |
| 595 | auto method = bus->new_method_call("xyz.openbmc_project.Ipmi.Channel.Ipmb", |
| 596 | "/xyz/openbmc_project/Ipmi/Channel/Ipmb", |
| 597 | "org.openbmc.Ipmb", "sendRequest"); |
| 598 | method.append(meAddress, netFn, lun, cmd, cmdData); |
| 599 | |
| 600 | auto reply = bus->call(method); |
| 601 | if (reply.is_method_error()) |
| 602 | { |
| 603 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 604 | "Error reading from ME"); |
| 605 | return -1; |
| 606 | } |
| 607 | |
| 608 | IpmbMethodType resp; |
| 609 | reply.read(resp); |
| 610 | |
| 611 | respData = |
| 612 | std::move(std::get<std::remove_reference_t<decltype(respData)>>(resp)); |
| 613 | |
| 614 | if (DEBUG) |
| 615 | { |
| 616 | std::cout << "ME resp data: "; |
| 617 | for (auto d : respData) |
| 618 | { |
| 619 | std::cout << d << " "; |
| 620 | } |
| 621 | std::cout << "\n"; |
| 622 | } |
| 623 | |
| 624 | return 0; |
| 625 | } |
| 626 | |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 627 | static int udbg_get_info_page(uint8_t, uint8_t page, uint8_t* next, |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 628 | uint8_t* count, uint8_t* buffer) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 629 | { |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 630 | char line_buff[1000]; |
| 631 | [[maybe_unused]] char* pres_dev = line_buff; |
| 632 | [[maybe_unused]] size_t pos = plat_get_fru_sel(); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 633 | int ret; |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 634 | std::string serialName = "SerialNumber"; |
| 635 | std::string partName = "PartNumber"; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 636 | std::string verDel = "VERSION="; |
| 637 | std::string verPath = "/etc/os-release"; |
BonnieLo-wiwynn | 21a7923 | 2023-03-09 16:42:48 +0800 | [diff] [blame] | 638 | size_t hostPosition = 0; |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 639 | size_t maxPosition; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 640 | |
| 641 | if (page == 1) |
| 642 | { |
| 643 | // Only update frame data while getting page 1 |
| 644 | |
| 645 | // initialize and clear frame |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 646 | frame_info.init(); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 647 | snprintf(frame_info.title, 32, "SYS_Info"); |
| 648 | |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 649 | bool platform = isMultiHostPlatform(); |
| 650 | if (platform == true) |
| 651 | { |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 652 | hostPosition = plat_get_fru_sel(); |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 653 | } |
| 654 | |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 655 | getMaxHostPosition(maxPosition); |
Jayashree Dhanapal | 4ec8056 | 2022-06-28 15:41:47 +0530 | [diff] [blame] | 656 | if (hostPosition == BMC_POSITION || hostInstances == "0") |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 657 | { |
Daniel Hsu | d8d95a3 | 2024-05-27 16:05:25 +0800 | [diff] [blame] | 658 | std::string data = "FRU:" + getMotherBoardFruName(); |
| 659 | frame_info.append(data); |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 660 | } |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 661 | else if (hostPosition != BMC_POSITION && hostPosition <= maxPosition) |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 662 | { |
| 663 | std::string data = "FRU:slot" + std::to_string(hostPosition); |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 664 | frame_info.append(data); |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | // FRU |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 668 | std::string data; |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 669 | frame_info.append("SN:"); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 670 | if (getFruData(data, serialName) != 0) |
| 671 | { |
| 672 | data = "Not Found"; |
| 673 | } |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 674 | frame_info.append(data, 1); |
| 675 | frame_info.append("PN:"); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 676 | if (getFruData(data, partName) != 0) |
| 677 | { |
| 678 | data = "Not Found"; |
| 679 | } |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 680 | frame_info.append(data, 1); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 681 | |
| 682 | // LAN |
| 683 | getNetworkData(3, line_buff); |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 684 | frame_info.append("BMC_IP:"); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 685 | frame_info.append(line_buff, 1); |
| 686 | getNetworkData(59, line_buff); |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 687 | frame_info.append("BMC_IPv6:"); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 688 | frame_info.append(line_buff, 1); |
| 689 | |
| 690 | // BMC ver |
| 691 | std::ifstream file(verPath); |
| 692 | if (file) |
| 693 | { |
| 694 | std::string line; |
| 695 | while (std::getline(file, line)) |
| 696 | { |
| 697 | if (line.find(verDel) != std::string::npos) |
| 698 | { |
| 699 | std::string bmcVer = line.substr(verDel.size()); |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 700 | frame_info.append("BMC_FW_ver:"); |
| 701 | frame_info.append(bmcVer, 1); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 702 | break; |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | |
Daniel Hsu | 3add478 | 2024-11-26 09:59:17 +0800 | [diff] [blame] | 707 | if (hostPosition != BMC_POSITION || hostInstances == "0") |
Vijay Khemka | 88884b8 | 2019-08-27 15:23:07 -0700 | [diff] [blame] | 708 | { |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 709 | // BIOS ver |
| 710 | std::string biosVer; |
Bonnie Lo | e9baaff | 2022-11-08 16:36:21 +0800 | [diff] [blame] | 711 | if (getBiosVer(biosVer, hostPosition) == 0) |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 712 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 713 | frame_info.append("BIOS_FW_ver:"); |
| 714 | frame_info.append(biosVer, 1); |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 715 | } |
Vijay Khemka | 88884b8 | 2019-08-27 15:23:07 -0700 | [diff] [blame] | 716 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 717 | |
Vijay Khemka | 317999d | 2020-01-02 13:43:42 -0800 | [diff] [blame] | 718 | /* TBD: Board ID needs implementation */ |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 719 | // Board ID |
| 720 | |
| 721 | // Battery - Use Escape sequence |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 722 | frame_info.append("Battery:"); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 723 | frame_info.append(ESC_BAT " ", 1); |
| 724 | // frame_info.append(&frame_info, esc_bat, 1); |
| 725 | |
| 726 | // MCU Version - Use Escape sequence |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 727 | frame_info.append("MCUbl_ver:"); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 728 | frame_info.append(ESC_MCU_BL_VER, 1); |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 729 | frame_info.append("MCU_ver:"); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 730 | frame_info.append(ESC_MCU_RUN_VER, 1); |
| 731 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 732 | // Sys config present device |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 733 | if (hostPosition != BMC_POSITION) |
| 734 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 735 | frame_info.append("Sys Conf. info:"); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 736 | |
| 737 | // Dimm info |
| 738 | std::vector<std::string> data; |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 739 | if (sysConfig(data, pos) == 0) |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 740 | { |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 741 | for (auto& info : data) |
| 742 | { |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 743 | frame_info.append(info, 1); |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 744 | } |
| 745 | } |
| 746 | else |
| 747 | { |
| 748 | frame_info.append("Not Found", 1); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 749 | } |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame] | 750 | |
| 751 | // Processor info |
| 752 | std::string result; |
Karthikeyan Pasupathi | e1ff81f | 2022-11-21 17:54:46 +0530 | [diff] [blame] | 753 | if (procInfo(result, pos) != 0) |
| 754 | { |
| 755 | result = "Not Found"; |
| 756 | } |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 757 | frame_info.append(result, 1); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 758 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 759 | |
| 760 | } // End of update frame |
| 761 | |
| 762 | if (page > frame_info.pages) |
| 763 | { |
| 764 | return -1; |
| 765 | } |
| 766 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 767 | ret = frame_info.getPage(page, (char*)buffer, FRAME_PAGE_BUF_SIZE); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 768 | if (ret < 0) |
| 769 | { |
| 770 | *count = 0; |
| 771 | return -1; |
| 772 | } |
| 773 | *count = (uint8_t)ret; |
| 774 | |
| 775 | if (page < frame_info.pages) |
| 776 | *next = page + 1; |
| 777 | else |
| 778 | *next = 0xFF; // Set the value of next to 0xFF to indicate this is the |
| 779 | // last page |
| 780 | |
| 781 | return 0; |
| 782 | } |
| 783 | |
Peter Yin | b340aa2 | 2024-07-08 16:07:55 +0800 | [diff] [blame] | 784 | static int udbg_get_postcode(uint8_t, uint8_t page, uint8_t* next, |
| 785 | uint8_t* count, uint8_t* buffer) |
| 786 | { |
Cosmo Chou | 5a6917d | 2024-09-05 23:29:11 +0800 | [diff] [blame] | 787 | // up to 70 codes can be displayed on 10 pages |
| 788 | static constexpr size_t maxPostcodes = 70; |
| 789 | |
Peter Yin | b340aa2 | 2024-07-08 16:07:55 +0800 | [diff] [blame] | 790 | if (page == 1) |
| 791 | { |
| 792 | // Initialize and clear frame (example initialization) |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 793 | frame_postcode.init(); |
Cosmo Chou | 5a6917d | 2024-09-05 23:29:11 +0800 | [diff] [blame] | 794 | snprintf(frame_postcode.title, 32, "POST CODE"); |
| 795 | frame_postcode.max_page = 10; |
Peter Yin | b340aa2 | 2024-07-08 16:07:55 +0800 | [diff] [blame] | 796 | |
| 797 | // Synchronously get D-Bus connection |
| 798 | auto bus = sdbusplus::bus::new_default(); |
| 799 | |
| 800 | // Build D-Bus method call |
| 801 | auto method = bus.new_method_call( |
| 802 | "xyz.openbmc_project.State.Boot.PostCode0", // Target service name |
| 803 | "/xyz/openbmc_project/State/Boot/PostCode0", // Object path |
| 804 | "xyz.openbmc_project.State.Boot.PostCode", // Interface name |
| 805 | "GetPostCodes"); // Method name |
| 806 | |
| 807 | method.append(uint16_t(1)); // Add method parameter, assuming it's page |
| 808 | |
| 809 | try |
| 810 | { |
| 811 | auto reply = bus.call(method); // Send synchronous method call |
| 812 | |
| 813 | // Read postcode value |
Cosmo Chou | 5e18a70 | 2024-10-06 09:27:15 +0800 | [diff] [blame] | 814 | std::vector<std::tuple<std::vector<uint8_t>, std::vector<uint8_t>>> |
| 815 | postcodes; |
Peter Yin | b340aa2 | 2024-07-08 16:07:55 +0800 | [diff] [blame] | 816 | reply.read(postcodes); |
| 817 | |
Cosmo Chou | 5a6917d | 2024-09-05 23:29:11 +0800 | [diff] [blame] | 818 | // retrieve the latest postcodes |
| 819 | size_t numEntries = std::min(maxPostcodes, postcodes.size()); |
Cosmo Chou | 5e18a70 | 2024-10-06 09:27:15 +0800 | [diff] [blame] | 820 | auto range = std::ranges::subrange(postcodes.rbegin(), |
| 821 | postcodes.rbegin() + numEntries); |
| 822 | for (const auto& [code, extra] : range) |
Peter Yin | b340aa2 | 2024-07-08 16:07:55 +0800 | [diff] [blame] | 823 | { |
Cosmo Chou | 5e18a70 | 2024-10-06 09:27:15 +0800 | [diff] [blame] | 824 | std::string result; |
| 825 | result.reserve(2 * code.size()); |
| 826 | for (const auto& byte : code) |
Potin Lai | 3c9f5b6 | 2024-08-28 13:40:37 +0800 | [diff] [blame] | 827 | { |
Cosmo Chou | 5a6917d | 2024-09-05 23:29:11 +0800 | [diff] [blame] | 828 | result += std::format("{:02X}", byte); |
Potin Lai | 3c9f5b6 | 2024-08-28 13:40:37 +0800 | [diff] [blame] | 829 | } |
Cosmo Chou | 5a6917d | 2024-09-05 23:29:11 +0800 | [diff] [blame] | 830 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 831 | frame_postcode.append(result); |
Cosmo Chou | 5a6917d | 2024-09-05 23:29:11 +0800 | [diff] [blame] | 832 | if (frame_postcode.lines >= maxPostcodes) |
| 833 | { |
| 834 | break; |
| 835 | } |
Peter Yin | b340aa2 | 2024-07-08 16:07:55 +0800 | [diff] [blame] | 836 | } |
| 837 | } |
| 838 | catch (const std::exception& e) |
| 839 | { |
| 840 | // Handle exceptions |
| 841 | std::cerr << "Error retrieving postcodes: " << e.what() |
| 842 | << std::endl; |
| 843 | return -1; |
| 844 | } |
| 845 | } |
| 846 | |
| 847 | if (page > frame_postcode.pages) |
| 848 | { |
| 849 | return -1; |
| 850 | } |
| 851 | |
| 852 | int ret = frame_postcode.getPage(page, (char*)buffer, FRAME_PAGE_BUF_SIZE); |
| 853 | if (ret < 0) |
| 854 | { |
| 855 | *count = 0; |
| 856 | return -1; |
| 857 | } |
| 858 | *count = (uint8_t)ret; |
| 859 | |
| 860 | if (page < frame_postcode.pages) |
| 861 | *next = page + 1; |
| 862 | else |
| 863 | *next = 0xFF; // Set next to 0xFF to indicate last page |
| 864 | return 0; |
| 865 | } |
| 866 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 867 | int plat_udbg_get_frame_data(uint8_t frame, uint8_t page, uint8_t* next, |
| 868 | uint8_t* count, uint8_t* buffer) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 869 | { |
| 870 | switch (frame) |
| 871 | { |
| 872 | case 1: // info_page |
| 873 | return udbg_get_info_page(frame, page, next, count, buffer); |
Peter Yin | b340aa2 | 2024-07-08 16:07:55 +0800 | [diff] [blame] | 874 | case 2: // Extra Post Code |
| 875 | return udbg_get_postcode(frame, page, next, count, buffer); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 876 | default: |
| 877 | return -1; |
| 878 | } |
| 879 | } |
| 880 | |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 881 | static panel panel_main(size_t item) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 882 | { |
| 883 | // Update item list when select item 0 |
| 884 | switch (item) |
| 885 | { |
| 886 | case 1: |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 887 | return panels[std::to_underlying(panel::BOOT_ORDER)].select(0); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 888 | case 2: |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 889 | return panels[std::to_underlying(panel::POWER_POLICY)].select(0); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 890 | default: |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 891 | return panel::MAIN; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 892 | } |
| 893 | } |
| 894 | |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 895 | static panel panel_boot_order(size_t selectedItemIndex) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 896 | { |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 897 | static constexpr size_t sizeBootOrder = 6; |
| 898 | static constexpr size_t bootValid = 0x80; |
| 899 | |
| 900 | std::vector<uint8_t> bootSeq; |
| 901 | |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 902 | ctrl_panel& bootOrderPanel = panels[std::to_underlying(panel::BOOT_ORDER)]; |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 903 | |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 904 | size_t pos = plat_get_fru_sel(); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 905 | |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 906 | if (pos == FRU_ALL) |
| 907 | { |
| 908 | bootOrderPanel.item_num = 0; |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 909 | return panel::BOOT_ORDER; |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | auto [bootObjPath, hostName] = ipmi::boot::objPath(pos); |
| 913 | ipmi::boot::getBootOrder(bootObjPath, bootSeq, hostName); |
| 914 | |
| 915 | uint8_t& bootMode = bootSeq.front(); |
| 916 | |
| 917 | // One item is selected to set a new boot sequence. |
| 918 | // The selected item become the first boot order. |
| 919 | if (selectedItemIndex > 0 && selectedItemIndex < sizeBootOrder) |
| 920 | { |
| 921 | // Move the selected item to second element (the first one is boot mode) |
| 922 | std::rotate(bootSeq.begin() + 1, bootSeq.begin() + selectedItemIndex, |
| 923 | bootSeq.begin() + selectedItemIndex + 1); |
| 924 | |
| 925 | bootMode |= bootValid; |
| 926 | try |
| 927 | { |
| 928 | ipmi::boot::setBootOrder(bootObjPath, bootSeq, hostName); |
| 929 | } |
| 930 | catch (const std::exception& e) |
| 931 | { |
| 932 | lg2::error("Fail to set boot order : {ERROR}", "ERROR", e); |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 933 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 934 | |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 935 | // refresh items |
| 936 | return bootOrderPanel.select(0); |
| 937 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 938 | |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 939 | // '*': boot flags valid, BIOS has not yet read |
Patrick Williams | 010dee0 | 2024-08-16 15:19:44 -0400 | [diff] [blame] | 940 | bootOrderPanel.item_str[0] = |
| 941 | std::string("Boot Order") + ((bootMode & bootValid) ? "*" : ""); |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 942 | |
| 943 | static const std::unordered_map<uint8_t, const char*> |
| 944 | bootOrderMappingTable = { |
| 945 | {0x00, " USB device"}, {0x01, " Network v4"}, {0x02, " SATA HDD"}, |
| 946 | {0x03, " SATA-CDROM"}, {0x04, " Other"}, {0x09, " Network v6"}, |
| 947 | }; |
| 948 | |
| 949 | size_t validItem = 0; |
| 950 | for (size_t i = 1; i < sizeBootOrder; i++) |
| 951 | { |
| 952 | auto find = bootOrderMappingTable.find(bootSeq[i]); |
| 953 | if (find == bootOrderMappingTable.end()) |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 954 | { |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 955 | lg2::error("Unknown boot order : {BOOTORDER}", "BOOTORDER", |
| 956 | bootSeq[i]); |
| 957 | break; |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 958 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 959 | |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 960 | bootOrderPanel.item_str[i] = find->second; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 961 | |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 962 | validItem++; |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 963 | } |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 964 | |
| 965 | bootOrderPanel.item_num = validItem; |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 966 | return panel::BOOT_ORDER; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 967 | } |
| 968 | |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 969 | static panel panel_power_policy(size_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 970 | { |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 971 | /* To be cleaned */ |
| 972 | #if 0 |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 973 | uint8_t buff[32] = {0}; |
| 974 | uint8_t res_len; |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 975 | size_t pos = plat_get_fru_sel(); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 976 | uint8_t policy; |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 977 | uint8_t pwr_policy_item_map[3] = {POWER_CFG_ON, POWER_CFG_LPS, |
| 978 | POWER_CFG_OFF}; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 979 | |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 980 | if (pos != FRU_ALL) |
| 981 | { |
| 982 | if (item > 0 && item <= sizeof(pwr_policy_item_map)) |
| 983 | { |
| 984 | policy = pwr_policy_item_map[item - 1]; |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 985 | pal_set_power_restore_policy(pos, &policy, nullptr); |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 986 | } |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 987 | pal_get_chassis_status(pos, nullptr, buff, &res_len); |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 988 | policy = (((uint8_t)buff[0]) >> 5) & 0x7; |
| 989 | snprintf(panels[PANEL_POWER_POLICY].item_str[1], 32, "%cPower On", |
| 990 | policy == POWER_CFG_ON ? '*' : ' '); |
| 991 | snprintf(panels[PANEL_POWER_POLICY].item_str[2], 32, "%cLast State", |
| 992 | policy == POWER_CFG_LPS ? '*' : ' '); |
| 993 | snprintf(panels[PANEL_POWER_POLICY].item_str[3], 32, "%cPower Off", |
| 994 | policy == POWER_CFG_OFF ? '*' : ' '); |
| 995 | panels[PANEL_POWER_POLICY].item_num = 3; |
| 996 | } |
| 997 | else |
| 998 | { |
| 999 | panels[PANEL_POWER_POLICY].item_num = 0; |
| 1000 | } |
| 1001 | #endif |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1002 | return panel::POWER_POLICY; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1003 | } |
| 1004 | |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1005 | ipmi_ret_t plat_udbg_control_panel(uint8_t cur_panel, uint8_t operation, |
Patrick Williams | 5e58948 | 2024-07-13 16:18:13 -0500 | [diff] [blame] | 1006 | uint8_t item, uint8_t* count, |
| 1007 | uint8_t* buffer) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1008 | { |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1009 | if (cur_panel > panelNum || cur_panel < std::to_underlying(panel::MAIN)) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1010 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1011 | |
| 1012 | // No more item; End of item list |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1013 | if (item > panels[cur_panel].item_num) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1014 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1015 | |
| 1016 | switch (operation) |
| 1017 | { |
| 1018 | case 0: // Get Description |
| 1019 | break; |
| 1020 | case 1: // Select item |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1021 | cur_panel = std::to_underlying(panels[cur_panel].select(item)); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1022 | item = 0; |
| 1023 | break; |
| 1024 | case 2: // Back |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1025 | cur_panel = std::to_underlying(panels[cur_panel].parent); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1026 | item = 0; |
| 1027 | break; |
| 1028 | default: |
| 1029 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1030 | } |
| 1031 | |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1032 | buffer[0] = cur_panel; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1033 | buffer[1] = item; |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1034 | buffer[2] = std::size(panels[cur_panel].item_str[item]); |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 1035 | |
Patrick Williams | 13ce379 | 2024-08-27 13:03:46 -0400 | [diff] [blame] | 1036 | if (buffer[2] > 0 && (buffer[2] + 3u) < FRAME_PAGE_BUF_SIZE) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1037 | { |
Patrick Williams | a758d0a | 2024-08-27 08:35:55 -0400 | [diff] [blame] | 1038 | std::memcpy(&buffer[3], (panels[cur_panel].item_str[item]).c_str(), |
Delphine CC Chiu | 7bb4592 | 2023-04-10 13:34:04 +0800 | [diff] [blame] | 1039 | buffer[2]); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1040 | } |
| 1041 | *count = buffer[2] + 3; |
| 1042 | return IPMI_CC_OK; |
| 1043 | } |
| 1044 | |
| 1045 | } // end of namespace ipmi |