| @@ -1,4 +1,7 @@ | |||
| 1 | # Changelog | 1 | # Changelog |
| 2 | +## [0.0.14] - 2026-11-27 | ||
| 3 | +新增rmii驱动接口以及bcaldfx调试命令。 | ||
| 4 | + | ||
| 2 | ## [0.0.13] - 2026-11-27 | 5 | ## [0.0.13] - 2026-11-27 |
| 3 | 6 | ||
| 4 | UartConnect 新增 CMD_GET_UART_ROUTE / CMD_GET_PORT_ROUTE 扩展查询命令, | 7 | UartConnect 新增 CMD_GET_UART_ROUTE / CMD_GET_PORT_ROUTE 扩展查询命令, |
| @@ -11,6 +11,7 @@ | |||||||||||||||||||||||||
| 11 | 11 | ||||||||||||||||||||||||
| 12 | #include <algorithm> | 12 | #include <algorithm> | ||||||||||||||||||||||
| 13 | #include <cctype> | 13 | #include <cctype> | ||||||||||||||||||||||
| 14 | +#include <cerrno> | ||||||||||||||||||||||||
| 14 | #include <cstdint> | 15 | #include <cstdint> | ||||||||||||||||||||||
| 15 | #include <cstring> | 16 | #include <cstring> | ||||||||||||||||||||||
| 16 | #include <functional> | 17 | #include <functional> | ||||||||||||||||||||||
| @@ -42,6 +43,7 @@ | |||||||||||||||||||||||||
| 42 | #include "bcal/mmc.h" | 43 | #include "bcal/mmc.h" | ||||||||||||||||||||||
| 43 | #include "bcal/peci.h" | 44 | #include "bcal/peci.h" | ||||||||||||||||||||||
| 44 | #include "bcal/pwm.h" | 45 | #include "bcal/pwm.h" | ||||||||||||||||||||||
| 46 | +#include "bcal/rmii.h" | ||||||||||||||||||||||||
| 45 | #include "bcal/sol.h" | 47 | #include "bcal/sol.h" | ||||||||||||||||||||||
| 46 | #include "bcal/spi.h" | 48 | #include "bcal/spi.h" | ||||||||||||||||||||||
| 47 | #include "bcal/trng.h" | 49 | #include "bcal/trng.h" | ||||||||||||||||||||||
| @@ -1055,6 +1057,105 @@ static void exec_kcs(bcal::IDriver* driver, const std::vector<std::string>& args | |||||||||||||||||||||||||
| 1055 | } | 1057 | } | ||||||||||||||||||||||
| 1056 | } | 1058 | } | ||||||||||||||||||||||
| 1057 | 1059 | ||||||||||||||||||||||||
| 1060 | +static void exec_rmii(bcal::IDriver* driver, const std::vector<std::string>& args) | ||||||||||||||||||||||||
| 1061 | +{ | ||||||||||||||||||||||||
| 1062 | + auto* rmii = static_cast<BCAL_DRIVER_RMII::Rmii*>(driver); | ||||||||||||||||||||||||
| 1063 | + if (args.empty()) { | ||||||||||||||||||||||||
| 1064 | + return; | ||||||||||||||||||||||||
| 1065 | + } | ||||||||||||||||||||||||
| 1066 | + const std::string& cmd = args[0]; | ||||||||||||||||||||||||
| 1067 | + | ||||||||||||||||||||||||
| 1068 | + try { | ||||||||||||||||||||||||
| 1069 | + if (cmd == "config") { | ||||||||||||||||||||||||
| 1070 | + // rmii config [interface_name] [timeout_ms] [retry_count] | ||||||||||||||||||||||||
| 1071 | + // All args optional. Build RmiiConfig with defaults, override with provided args. | ||||||||||||||||||||||||
| 1072 | + BCAL_DRIVER_RMII::RmiiConfig cfg{}; | ||||||||||||||||||||||||
| 1073 | + cfg.interface_name = "eth0"; | ||||||||||||||||||||||||
| 1074 | + if (args.size() > 1) { | ||||||||||||||||||||||||
| 1075 | + if (args[1].empty()) { | ||||||||||||||||||||||||
| 1076 | + print_err("rmii.config: interface_name must not be empty"); | ||||||||||||||||||||||||
| 1077 | + return; | ||||||||||||||||||||||||
| 1078 | + } | ||||||||||||||||||||||||
| 1079 | + cfg.interface_name = args[1]; | ||||||||||||||||||||||||
| 1080 | + } | ||||||||||||||||||||||||
| 1081 | + if (args.size() > 2) { | ||||||||||||||||||||||||
| 1082 | + cfg.timeout_ms = parse_uint(args[2]); | ||||||||||||||||||||||||
| 1083 | + } | ||||||||||||||||||||||||
| 1084 | + if (args.size() > 3) { | ||||||||||||||||||||||||
| 1085 | + cfg.retry_count = parse_uint(args[3]); | ||||||||||||||||||||||||
| 1086 | + } | ||||||||||||||||||||||||
| 1087 | + rmii->init(&cfg, sizeof(cfg)); | ||||||||||||||||||||||||
| 1088 | + print_ok("rmii.config called"); | ||||||||||||||||||||||||
| 1089 | + } else if (cmd == "send") { | ||||||||||||||||||||||||
| 1090 | + // rmii send <hex_data> [length] | ||||||||||||||||||||||||
| 1091 | + if (args.size() < 2) { | ||||||||||||||||||||||||
| 1092 | + print_err("Usage: rmii send <hex_data> [length]"); | ||||||||||||||||||||||||
| 1093 | + return; | ||||||||||||||||||||||||
| 1094 | + } | ||||||||||||||||||||||||
| 1095 | + std::string bytes = hex_to_bytes(args[1]); | ||||||||||||||||||||||||
| 1096 | + int32_t length = -1; | ||||||||||||||||||||||||
| 1097 | + if (args.size() > 2) { | ||||||||||||||||||||||||
| 1098 | + length = parse_int(args[2], -1); | ||||||||||||||||||||||||
| 1099 | + } | ||||||||||||||||||||||||
| 1100 | + if (length != -1 && (length < 0 || static_cast<size_t>(length) > bytes.size())) { | ||||||||||||||||||||||||
| 1101 | + print_err("rmii.send: invalid length " + std::to_string(length) + ", payload is " + | ||||||||||||||||||||||||
| 1102 | + std::to_string(bytes.size()) + " bytes"); | ||||||||||||||||||||||||
| 1103 | + return; | ||||||||||||||||||||||||
| 1104 | + } | ||||||||||||||||||||||||
| 1105 | + int32_t ret = rmii->send_ncsi_cmd(string_view_t(bytes.data(), bytes.size()), length); | ||||||||||||||||||||||||
🟡 Medium Priority 变更行 dfx/src/main.cpp:1097-1102: 建议:下发给驱动前校验 length 只能是 -1 或 [0, bytes.size()] 范围内的值,越界时 print_err 并 return;parse_int 的第二参数传 -1,避免非法输入被当成 0 长度。 Suggestions
![]() ![]() Incorrect? | |||||||||||||||||||||||||
| 1106 | + if (ret == 0) { | ||||||||||||||||||||||||
| 1107 | + print_ok("rmii.send success"); | ||||||||||||||||||||||||
| 1108 | + } else { | ||||||||||||||||||||||||
| 1109 | + print_err("rmii.send failed: ret=" + std::to_string(ret) + | ||||||||||||||||||||||||
| 1110 | + (errno != 0 ? std::string(" (") + strerror(errno) + ")" : std::string())); | ||||||||||||||||||||||||
| 1111 | + } | ||||||||||||||||||||||||
| 1112 | + } else if (cmd == "recv") { | ||||||||||||||||||||||||
| 1113 | + // rmii recv [sock] | ||||||||||||||||||||||||
| 1114 | + int32_t sock = -1; | ||||||||||||||||||||||||
| 1115 | + if (args.size() > 1) { | ||||||||||||||||||||||||
| 1116 | + sock = parse_int(args[1], -1); | ||||||||||||||||||||||||
| 1117 | + } | ||||||||||||||||||||||||
🔵 Low Priority 变更行 dfx/src/main.cpp:1110-1113: 建议:parse_int 第二个参数传 -1,使非法输入回落为"默认套接字"而不是 fd 0。 Suggestions
![]() ![]() Incorrect? | |||||||||||||||||||||||||
| 1118 | + string_t data = rmii->ncsi_receive_packet(sock); | ||||||||||||||||||||||||
| 1119 | + if (data.empty()) { | ||||||||||||||||||||||||
| 1120 | + print_info("rmii.recv: length=0 (no data)"); | ||||||||||||||||||||||||
| 1121 | + } else { | ||||||||||||||||||||||||
| 1122 | + print_result("rmii.recv", "length=" + std::to_string(data.size()) + ", data=" + hex_dump(data)); | ||||||||||||||||||||||||
| 1123 | + } | ||||||||||||||||||||||||
| 1124 | + } else if (cmd == "get_interface") { | ||||||||||||||||||||||||
| 1125 | + print_result("rmii.get_interface", rmii->get_interface_name()); | ||||||||||||||||||||||||
| 1126 | + } else if (cmd == "set_interface") { | ||||||||||||||||||||||||
| 1127 | + if (args.size() < 2) { | ||||||||||||||||||||||||
| 1128 | + print_err("Usage: rmii set_interface <name>"); | ||||||||||||||||||||||||
| 1129 | + return; | ||||||||||||||||||||||||
| 1130 | + } | ||||||||||||||||||||||||
| 1131 | + rmii->set_interface_name(args[1]); | ||||||||||||||||||||||||
| 1132 | + print_ok("rmii.set_interface called"); | ||||||||||||||||||||||||
| 1133 | + } else if (cmd == "link_status") { | ||||||||||||||||||||||||
| 1134 | + bool available = rmii->is_available(); | ||||||||||||||||||||||||
| 1135 | + print_result("rmii.is_available", available ? "true" : "false"); | ||||||||||||||||||||||||
| 1136 | + if (!available) { | ||||||||||||||||||||||||
| 1137 | + print_info("rmii not ready (freed or not initialized), or interface '" + rmii->get_interface_name() + | ||||||||||||||||||||||||
| 1138 | + "' is down; run 'rmii config <iface> [timeout_ms] [retry]'"); | ||||||||||||||||||||||||
| 1139 | + } | ||||||||||||||||||||||||
| 1140 | + } else if (cmd == "free") { | ||||||||||||||||||||||||
| 1141 | + rmii->free(); | ||||||||||||||||||||||||
| 1142 | + // Keep the instance in the cache: free() only marks it freed, and the next | ||||||||||||||||||||||||
| 1143 | + // send/recv will report "driver has been freed", while 'rmii config' | ||||||||||||||||||||||||
| 1144 | + // re-initializes it. Erasing here made every following command silently | ||||||||||||||||||||||||
| 1145 | + // create a fresh default instance (and print "loaded successfully"). | ||||||||||||||||||||||||
| 1146 | + print_ok("rmii.free called (run 'rmii config' to re-initialize)"); | ||||||||||||||||||||||||
| 1147 | + } else { | ||||||||||||||||||||||||
| 1148 | + handle_common(driver, args); | ||||||||||||||||||||||||
| 1149 | + } | ||||||||||||||||||||||||
| 1150 | + } catch (const std::runtime_error& e) { | ||||||||||||||||||||||||
| 1151 | + print_err("rmii." + cmd + ": " + e.what()); | ||||||||||||||||||||||||
| 1152 | + } catch (const std::exception& e) { | ||||||||||||||||||||||||
| 1153 | + print_err("rmii." + cmd + ": " + e.what()); | ||||||||||||||||||||||||
| 1154 | + } catch (...) { | ||||||||||||||||||||||||
| 1155 | + print_err("rmii." + cmd + ": unknown exception"); | ||||||||||||||||||||||||
| 1156 | + } | ||||||||||||||||||||||||
| 1157 | +} | ||||||||||||||||||||||||
| 1158 | + | ||||||||||||||||||||||||
| 1058 | static void exec_canbus(bcal::IDriver* driver, const std::vector<std::string>& args) | 1159 | static void exec_canbus(bcal::IDriver* driver, const std::vector<std::string>& args) | ||||||||||||||||||||||
| 1059 | { | 1160 | { | ||||||||||||||||||||||
| 1060 | auto* canbus = static_cast<BCAL_DRIVER_CANBUS::Canbus*>(driver); | 1161 | auto* canbus = static_cast<BCAL_DRIVER_CANBUS::Canbus*>(driver); | ||||||||||||||||||||||
| @@ -2615,32 +2716,15 @@ static void exec_usb_drd(bcal::IDriver* driver, const std::vector<std::string>& | |||||||||||||||||||||||||
| 2615 | 2716 | ||||||||||||||||||||||||
| 2616 | static const std::map<std::string, std::function<void(bcal::IDriver*, const std::vector<std::string>&)>> | 2717 | static const std::map<std::string, std::function<void(bcal::IDriver*, const std::vector<std::string>&)>> | ||||||||||||||||||||||
| 2617 | g_driver_executors = { | 2718 | g_driver_executors = { | ||||||||||||||||||||||
| 2618 | - {"wdt", exec_wdt}, | 2719 | + {"wdt", exec_wdt}, {"peci", exec_peci}, {"usb_drd", exec_usb_drd}, | ||||||||||||||||||||||
| 2619 | - {"peci", exec_peci}, | 2720 | + {"i2c", exec_i2c}, {"jtag", exec_jtag}, {"localbus", exec_localbus}, | ||||||||||||||||||||||
| 2620 | - {"usb_drd", exec_usb_drd}, | 2721 | + {"adc", exec_adc}, {"gpio", exec_gpio}, {"canbus", exec_canbus}, | ||||||||||||||||||||||
| 2621 | - {"i2c", exec_i2c}, | 2722 | + {"usb", exec_usb}, {"efuse", exec_efuse}, {"mmc", exec_mmc}, | ||||||||||||||||||||||
| 2622 | - {"jtag", exec_jtag}, | 2723 | + {"mctp", exec_mctp}, {"uart", exec_uart}, {"uart_connect", exec_uart_connect}, | ||||||||||||||||||||||
| 2623 | - {"localbus", exec_localbus}, | 2724 | + {"spi", exec_spi}, {"sol", exec_sol}, {"pwm", exec_pwm}, | ||||||||||||||||||||||
| 2624 | - {"adc", exec_adc}, | 2725 | + {"edma", exec_edma}, {"ipmb", exec_ipmb}, {"bt", exec_bt}, | ||||||||||||||||||||||
| 2625 | - {"gpio", exec_gpio}, | 2726 | + {"mem", exec_mem}, {"kcs", exec_kcs}, {"mdio", exec_mdio}, | ||||||||||||||||||||||
| 2626 | - {"canbus", exec_canbus}, | 2727 | + {"trng", exec_trng}, {"rmii", exec_rmii}, {"lpc_snoop", exec_lpc_snoop}, | ||||||||||||||||||||||
🔵 Low Priority 新问题(本轮新增观察): 证据链: ![]() ![]() Incorrect? | |||||||||||||||||||||||||
| 2627 | - {"usb", exec_usb}, | ||||||||||||||||||||||||
| 2628 | - {"efuse", exec_efuse}, | ||||||||||||||||||||||||
| 2629 | - {"mmc", exec_mmc}, | ||||||||||||||||||||||||
| 2630 | - {"mctp", exec_mctp}, | ||||||||||||||||||||||||
| 2631 | - {"uart", exec_uart}, | ||||||||||||||||||||||||
| 2632 | - {"uart_connect", exec_uart_connect}, | ||||||||||||||||||||||||
| 2633 | - {"spi", exec_spi}, | ||||||||||||||||||||||||
| 2634 | - {"sol", exec_sol}, | ||||||||||||||||||||||||
| 2635 | - {"pwm", exec_pwm}, | ||||||||||||||||||||||||
| 2636 | - {"edma", exec_edma}, | ||||||||||||||||||||||||
| 2637 | - {"ipmb", exec_ipmb}, | ||||||||||||||||||||||||
| 2638 | - {"bt", exec_bt}, | ||||||||||||||||||||||||
| 2639 | - {"mem", exec_mem}, | ||||||||||||||||||||||||
| 2640 | - {"kcs", exec_kcs}, | ||||||||||||||||||||||||
| 2641 | - {"mdio", exec_mdio}, | ||||||||||||||||||||||||
| 2642 | - {"trng", exec_trng}, | ||||||||||||||||||||||||
| 2643 | - {"lpc_snoop", exec_lpc_snoop}, | ||||||||||||||||||||||||
| 2644 | }; | 2728 | }; | ||||||||||||||||||||||
| 2645 | 2729 | ||||||||||||||||||||||||
| 2646 | static void cmd_driver_exec(const std::string& driver_name, const std::vector<std::string>& args) | 2730 | static void cmd_driver_exec(const std::string& driver_name, const std::vector<std::string>& args) | ||||||||||||||||||||||
| @@ -2877,6 +2961,14 @@ static void cmd_help(const std::vector<std::string>& /*args*/) | |||||||||||||||||||||||||
| 2877 | std::cout << " poll\n"; | 2961 | std::cout << " poll\n"; | ||||||||||||||||||||||
| 2878 | std::cout << " read <index> <max_len> <timeout>\n"; | 2962 | std::cout << " read <index> <max_len> <timeout>\n"; | ||||||||||||||||||||||
| 2879 | std::cout << " write <index> <val> <timeout>\n"; | 2963 | std::cout << " write <index> <val> <timeout>\n"; | ||||||||||||||||||||||
| 2964 | + std::cout << " \033[33mrmii\033[0m\n"; | ||||||||||||||||||||||||
| 2965 | + std::cout << " config [interface_name] [timeout_ms] [retry_count]\n"; | ||||||||||||||||||||||||
| 2966 | + std::cout << " send <hex_data> [length]\n"; | ||||||||||||||||||||||||
| 2967 | + std::cout << " recv [sock]\n"; | ||||||||||||||||||||||||
| 2968 | + std::cout << " get_interface\n"; | ||||||||||||||||||||||||
| 2969 | + std::cout << " set_interface <name>\n"; | ||||||||||||||||||||||||
| 2970 | + std::cout << " link_status\n"; | ||||||||||||||||||||||||
| 2971 | + std::cout << " free\n"; | ||||||||||||||||||||||||
| 2880 | std::cout << std::endl; | 2972 | std::cout << std::endl; | ||||||||||||||||||||||
| 2881 | } | 2973 | } | ||||||||||||||||||||||
| 2882 | 2974 | ||||||||||||||||||||||||
| @@ -0,0 +1,97 @@ | |||||||||||||
| 1 | +/* Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved. | ||||||||||||
| 2 | + * openUBMC is licensed under Mulan PSL v2. | ||||||||||||
| 3 | + * You may obtain a copy of Mulan PSL v2 at: | ||||||||||||
| 4 | + * http://license.coscl.org.cn/MulanPSL2 | ||||||||||||
| 5 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||||||||||||
| 6 | + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||||||||||||
| 7 | + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||||||||||||
| 8 | + * See the Mulan PSL v2 for more details. | ||||||||||||
| 9 | + */ | ||||||||||||
| 10 | + | ||||||||||||
| 11 | +/** | ||||||||||||
| 12 | + * @file rmii.h | ||||||||||||
| 13 | + * @brief RMII (Reduced Media Independent Interface) 驱动接口 | ||||||||||||
| 14 | + * 用于 NC-SI(Network Controller Sideband Interface)协议 over Ethernet, | ||||||||||||
| 15 | + * 典型用途:BMC 通过 RMII 通道与服务器管理控制器通信 | ||||||||||||
| 16 | + */ | ||||||||||||
| 17 | +#ifndef BCAL_RMII_H | ||||||||||||
| 18 | +#define BCAL_RMII_H | ||||||||||||
| 19 | + | ||||||||||||
| 20 | +#include "bcal/driver.h" | ||||||||||||
| 21 | + | ||||||||||||
| 22 | +namespace BCAL_DRIVER_RMII { | ||||||||||||
| 23 | +using namespace bcal; | ||||||||||||
| 24 | + | ||||||||||||
| 25 | +/** | ||||||||||||
| 26 | + * @struct RmiiConfig | ||||||||||||
| 27 | + * @brief RMII 驱动初始化配置 | ||||||||||||
| 28 | + */ | ||||||||||||
| 29 | +struct RmiiConfig { | ||||||||||||
| 30 | + string_t interface_name; /**< 网络接口名称,如 "eth0" */ | ||||||||||||
| 31 | + uint32_t timeout_ms = 5000; /**< 超时时间(毫秒),默认 5000 */ | ||||||||||||
| 32 | + uint32_t retry_count = 3; /**< 重试次数,默认 3 */ | ||||||||||||
| 33 | +}; | ||||||||||||
🔵 Low Priority 变更行 include/bcal/rmii.h:29-33 新增的 建议:给 timeout_ms / retry_count 增加类内默认初始化(5000 / 3),避免调用方构造后未赋值就读到不确定值。 Suggestions
![]() ![]() Incorrect? | |||||||||||||
| 34 | + | ||||||||||||
| 35 | +/** | ||||||||||||
| 36 | + * @class Rmii | ||||||||||||
| 37 | + * @brief RMII 驱动接口 | ||||||||||||
| 38 | + * @note 每个 Rmii 实例对应一个网络接口(如 eth0),通过 init() 传入配置 | ||||||||||||
| 39 | + */ | ||||||||||||
| 40 | +class Rmii : public IDriver { | ||||||||||||
| 41 | +public: | ||||||||||||
| 42 | + /** | ||||||||||||
| 43 | + * @brief 发送 NCSI 命令数据包 | ||||||||||||
| 44 | + * | ||||||||||||
| 45 | + * @param packet 数据包内容 | ||||||||||||
| 46 | + * @param length 数据包长度(字节)。取值范围 length ∈ {-1} ∪ [0, packet.size()]: | ||||||||||||
| 47 | + * -1 表示发送整个 packet; | ||||||||||||
| 48 | + * 0 ≤ length ≤ packet.size() 表示发送 packet 前 length 字节。 | ||||||||||||
| 49 | + * 前置条件:length 不得大于 packet.size(),否则实现不得越界读取, | ||||||||||||
| 50 | + * 应返回 -1(或抛出 std::invalid_argument)而非按错误长度从 packet 读数据。 | ||||||||||||
| 51 | + * @return int32_t 0: 发送成功, -1: 发送失败(含 length 越界/非法、底层 sendto 失败) | ||||||||||||
| 52 | + */ | ||||||||||||
| 53 | + virtual int32_t send_ncsi_cmd(const string_view_t& packet, int32_t length) = 0; | ||||||||||||
🔵 Low Priority 变更行 include/bcal/rmii.h:49: 证据链:
失败模式:其它调用方(业务进程直接使用该接口)传入大于 建议:在 send_ncsi_cmd 的 Doxygen 注释中补充前置条件 length ∈ {-1} ∪ [0, packet.size()],并说明超出时实现应返回 -1 而非越界读。 ![]() ![]() Incorrect? | |||||||||||||
| 54 | + | ||||||||||||
| 55 | + /** | ||||||||||||
| 56 | + * @brief 接收 NCSI 响应数据包 | ||||||||||||
| 57 | + * | ||||||||||||
| 58 | + * @param sock 套接字句柄,-1 表示使用默认套接字 | ||||||||||||
| 59 | + * @return string_t 接收到的数据包内容。返回语义: | ||||||||||||
| 60 | + * - 成功接收到一个包时返回其内容(长度 > 0); | ||||||||||||
| 61 | + * - 超时无数据、被信号中断或没有数据时返回空串(长度 == 0, | ||||||||||||
| 62 | + * 这是「无数据」的正常状态,不是错误); | ||||||||||||
| 63 | + * - 底层接收真实失败(如 socket 已关闭)时抛出 | ||||||||||||
| 64 | + * std::system_error,调用方须捕获并视为接收失败。 | ||||||||||||
| 65 | + */ | ||||||||||||
| 66 | + virtual string_t ncsi_receive_packet(int32_t sock = -1) = 0; | ||||||||||||
🔵 Low Priority 上一轮问题复查:仍存在,未修复。 证据链:
建议:在 rmii.h 的 Doxygen 注释中明确失败语义:要么约定「失败返回空串并通过 errno 给出原因」,要么改为 ![]() ![]() Incorrect? | |||||||||||||
| 67 | + | ||||||||||||
| 68 | + /** | ||||||||||||
| 69 | + * @brief 获取当前使用的网络接口名称 | ||||||||||||
| 70 | + * | ||||||||||||
| 71 | + * @return string_t 接口名称,如 "eth0" | ||||||||||||
| 72 | + */ | ||||||||||||
| 73 | + virtual string_t get_interface_name(void) = 0; | ||||||||||||
| 74 | + | ||||||||||||
| 75 | + /** | ||||||||||||
| 76 | + * @brief 设置网络接口名称 | ||||||||||||
| 77 | + * | ||||||||||||
| 78 | + * @param name 新的接口名称 | ||||||||||||
| 79 | + */ | ||||||||||||
| 80 | + virtual void set_interface_name(const string_view_t& name) = 0; | ||||||||||||
| 81 | + | ||||||||||||
| 82 | + /** | ||||||||||||
| 83 | + * @brief 释放 RMII 驱动资源 | ||||||||||||
| 84 | + */ | ||||||||||||
| 85 | + virtual void free(void) = 0; | ||||||||||||
🔵 Low Priority 变更行 include/bcal/rmii.h:76:释放资源的纯虚接口命名为 证据链: 失败模式:同一 HAL 层出现两种释放语义命名(deinit vs free),调用方/实现方容易按 修复方向:重命名为 建议:按 bcal 既有释放约定把 ![]() ![]() Incorrect? | |||||||||||||
| 86 | + | ||||||||||||
| 87 | + /** | ||||||||||||
| 88 | + * @brief 检查 RMII 接口是否可用 | ||||||||||||
| 89 | + * | ||||||||||||
| 90 | + * @return bool 可用返回 true | ||||||||||||
| 91 | + */ | ||||||||||||
| 92 | + virtual bool is_available(void) = 0; | ||||||||||||
| 93 | +}; | ||||||||||||
| 94 | + | ||||||||||||
| 95 | +} // namespace BCAL_DRIVER_RMII | ||||||||||||
| 96 | + | ||||||||||||
| 97 | +#endif // BCAL_RMII_H | ||||||||||||
| @@ -2,7 +2,7 @@ | |||
| 2 | "name": "bcal", | 2 | "name": "bcal", |
| 3 | "type": "library", | 3 | "type": "library", |
| 4 | "deployConfig": "", | 4 | "deployConfig": "", |
| 5 | - "version": "0.0.13", | 5 | + "version": "0.0.14", |
| 6 | "license": "Mulan PSL v2", | 6 | "license": "Mulan PSL v2", |
| 7 | "description": "", | 7 | "description": "", |
| 8 | "dependencies": { | 8 | "dependencies": { |
| @@ -41,6 +41,7 @@ headers = files( | |||
| 41 | 'include/bcal/mmc.h', | 41 | 'include/bcal/mmc.h', |
| 42 | 'include/bcal/peci.h', | 42 | 'include/bcal/peci.h', |
| 43 | 'include/bcal/pwm.h', | 43 | 'include/bcal/pwm.h', |
| 44 | + 'include/bcal/rmii.h', | ||
| 44 | 'include/bcal/sol.h', | 45 | 'include/bcal/sol.h', |
| 45 | 'include/bcal/spi.h', | 46 | 'include/bcal/spi.h', |
| 46 | 'include/bcal/trng.h', | 47 | 'include/bcal/trng.h', |


🔵 Low Priority
变更行 dfx/src/main.cpp:1083-1088:
config子命令用parse_uint(args[2])/parse_uint(args[3])解析超时与重试次数,而parse_uint(107-117)的缺省返回值为 0,非数字、负数(std::stoul("-1")会解析成大数)、纯字母等都会静默回落为 0。证据链:
exec_rmii在 1074-1075 显式把默认值写成 5000/3,却在用户给出非法值时把它覆盖成 0。失败模式:
rmii config eth0 5s 3(手误)→ timeout_ms=0;rmii config eth0 5000 3x→ retry_count=0。随后程序仍打印rmii.config called(1090),用户以为配置生效,实际拿到 0 超时 / 0 重试,发送命令会立即失败且难以定位。修复方向:解析失败时不覆盖默认值(把 def_val 传成 5000 / 3),或对 0 与非法输入做校验并 print_err 后 return。
建议:为 parse_uint 传入默认值(如 parse_uint(args[2], 5000) / parse_uint(args[3], 3)),或校验解析结果合法性,非法时 print_err 并 return,避免静默把超时/重试置 0。