Open
feat: 新增支持 rmii 驱动接口 #23
feat: 新增支持 rmii 驱动接口 #23
Open
byosoft_wujimingAdd on 20 hours ago
Total: 5 files changed+576-2
@@ -2,6 +2,10 @@
2 2 
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
4 4 
5+## [1.0.14] - 2026-11-28
6+- 新增支持 rmii 驱动接口
7+ 
8+ 
5## [1.0.13] - 2026-11-269## [1.0.13] - 2026-11-26
6 10 
7- 支持 uart_connect 驱动接口11- 支持 uart_connect 驱动接口
@@ -10,3 +10,4 @@ subdir('i2c')
10subdir('lpc_snoop')10subdir('lpc_snoop')
11subdir('uart')11subdir('uart')
12subdir('uart_connect')12subdir('uart_connect')
13+subdir('rmii')
@@ -0,0 +1,13 @@
1+driver_name = 'rmii'
2+ 
3+sources = files('rmii.cpp')
4+bcal_dep = dependency('bcal', required: true)
5+ 
6+rmii_lib = shared_library(driver_name,
7+ sources,
8+ dependencies: [bcal_dep],
9+ # 默认隐藏,create_driver/destroy_driver 靠 visibility("default") 显式导出
10+ cpp_args: ['-fvisibility=hidden', '-fvisibility-inlines-hidden'],
11+ install: true,
JayYin
JayYinJayYin31 minutes ago

[Major] 新增的 librmii.so 未在 permissions.ini 登记

仓库根的 permissions.ini 逐条列出 opt/bmc/bcal/lib*.so 的落地权限(f 550 0 0),现有 12 个驱动全部在列,本次新增的 rmii 没有对应条目;conanfile.py 仍会把该文件打进包,安装后 librmii.so 的属主与权限不受该清单约束。

建议在 permissions.ini 末尾补一行 opt/bmc/bcal/librmii.so f 550 0 0,与其余驱动保持一致。

.. |
  8 |   dependencies: [bcal_dep],
  9 |   # 默认隐藏,create_driver/destroy_driver 靠 visibility("default") 显式导出
 10 |   cpp_args: ['-fvisibility=hidden', '-fvisibility-inlines-hidden'],
>11 |   install: true,
 12 |   install_dir: driver_install_dir
 13 | )

规则 permissions-ini-missing-so · AI 检视

likedislike
12+ install_dir: driver_install_dir
13+)
atomgit-bot
atomgit-botatomgit-bot20 hours ago

🔵 Low Priority

drivers/rmii/meson.build:6-11 的 shared_library 调用缺少 cpp_args: ['-fvisibility=hidden', '-fvisibility-inlines-hidden']。

证据链:仓库内 11 个驱动插件中,i2c/jtag/uart_connect/lpc_snoop/pwm/wdt/adc/uart 等均显式传入该 cpp_args,并在注释中写明“默认隐藏,create_driver/destroy_driver 靠 visibility("default") 显式导出”(见 drivers/i2c/meson.build:8-9、drivers/wdt/meson.build:8-9);rmii.cpp:340/346 也确实对 create_driver/destroy_driver 使用了 __attribute__((visibility("default")))——说明作者预期其余符号默认隐藏,但构建文件没有落地。

失败模式:rmii 插件会默认导出全部外部链接符号(BCAL_RMII_ASPEED::RmiiImpl::*、RTTI/typeinfo 等),与同进程内其它插件共享符号命名空间;一旦另一个插件或主程序出现同名弱符号/RTTI 符号,动态链接器可能发生符号插入(interposition),表现为难以定位的跨插件行为异常。这是与既有构建约定的不一致,且修复成本极低。

修复方向:按既有插件约定补上 cpp_args(该项为可选改进,不影响当前功能验证)。

建议:在 shared_library 参数中补上 cpp_args: ['-fvisibility=hidden', '-fvisibility-inlines-hidden'],与 i2c/uart/wdt 等既有驱动的构建约定保持一致,使只有显式标注 visibility("default") 的 create_driver/destroy_driver 被导出。

Suggestions
13
+ rmii_lib = shared_library(driver_name,
14
+ sources,
15
+ dependencies: [bcal_dep],
16
+ # 默认隐藏,create_driver/destroy_driver 靠 visibility("default") 显式导出
17
+ cpp_args: ['-fvisibility=hidden', '-fvisibility-inlines-hidden'],
18
+ install: true,
19
+ install_dir: driver_install_dir
13
20
  )
Apply suggestion
likedislike
Incorrect?
byosoft_wujiming
byosoft_wujiming
18 hours ago Comments:
likedislike
@@ -0,0 +1,556 @@
1+/*
2+ * Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.
3+ *
4+ * Licensed under Mulan PSL v2.
5+ * You may obtain a copy of Mulan PSL v2 at:
6+ * http://license.coscl.org.cn/MulanPSL2
7+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
8+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
9+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
10+ * See the Mulan PSL v2 for more details.
11+ */
12+ 
13+#include <bcal/rmii.h>
14+ 
15+#include <algorithm>
16+#include <cerrno>
17+#include <cstddef>
18+#include <cstdint>
19+#include <cstdio>
20+#include <cstring>
21+#include <mutex>
22+#include <stdexcept>
23+#include <string>
24+#include <system_error>
25+#include <unistd.h>
atomgit-bot
atomgit-botatomgit-bot20 hours ago

🔵 Low Priority

变更行 39-45、78、107-109 使用了 uint32_t / uint16_t / int32_t / size_t 等定宽与尺寸类型,但 13-29 行的 include 列表(algorithm/cerrno/cstdio/cstring/mutex/stdexcept/string/system_error/unistd.h + 系统头)没有 (也没有 提供 size_t)。当前能编译只是因为 <bcal/rmii.h> 或 <net/if.h> 间接引入了 ;一旦 bcal 头文件或系统头调整 include 集合,会直接编译失败。这是可选的健壮性改进,不是功能缺陷。建议在 21 行附近显式 #include <cstdint>(如需 size_t 再加 )。

建议:在标准库 include 段显式加入 (可选再加 ),避免依赖 bcal/系统头的间接包含。

Suggestions
25
+ #include <algorithm>
26
+ #include <cerrno>
27
+ #include <cstdint>
28
+ #include <cstdio>
29
+ #include <cstring>
30
+ #include <mutex>
31
+ #include <stdexcept>
32
+ #include <string>
33
+ #include <system_error>
25
34
  #include <unistd.h>
Apply suggestion
likedislike
Incorrect?
byosoft_wujiming
byosoft_wujiming
18 hours ago Comments:
likedislike
26+ 
27+#include <linux/if_packet.h>
28+#include <net/if.h>
29+#include <netinet/in.h>
30+#include <sys/ioctl.h>
31+#include <sys/socket.h>
32+ 
33+namespace BCAL_RMII_ASPEED {
34+using namespace bcal;
35+using namespace BCAL_DRIVER_RMII;
36+ 
37+namespace {
38+constexpr const char* DRIVER_VERSION = "bcal_rmii_aspeed v1.0.0 (raw socket NC-SI)";
39+ 
40+// ---- Packet layout constants (ported from v1 rmii.h) ----
41+constexpr uint32_t NCSI_MAC_LEN = 6;
42+constexpr uint32_t NCSI_ETHER_MIN_LEN = 290; // 46-1500 bytes data region
43+constexpr uint32_t NCSI_ETHER_MIN_LEN_MULTIPLE = 4;
44+constexpr uint32_t NCSI_ETH_NAME_LEN = 16;
45+constexpr uint32_t ETH_NCSI_TYPE = 0x88F8;
46+constexpr uint32_t RECV_BUFFER_LEN = 2048;
47+constexpr uint32_t ETHER_HEADER_LEN = 14;
48+constexpr uint32_t PACKET_HEADER_LEN = 16;
49+ 
50+// Total wire packet = 14 + 16 + (290*4 - 14 - 16) = 1160 bytes
51+constexpr size_t NCSI_PACKET_TOTAL_LEN =
52+ ETHER_HEADER_LEN + PACKET_HEADER_LEN +
53+ NCSI_ETHER_MIN_LEN * NCSI_ETHER_MIN_LEN_MULTIPLE - ETHER_HEADER_LEN - PACKET_HEADER_LEN;
54+ 
55+/* The Management Controller shall format the 14-byte Ethernet frame header so that when it is received,
56+it shall be formatted in the big-endian byte order.
57+ Bits
58+___________________________________________________________
59+| Bytes | 31..24 | 23..16 | 15..08 | 07..00 |
60+|_______|___________|____________|____________|____________|
61+|00..03 | DA5= 0xFF | DA4= 0xFF | DA3= 0xFF | DA2= 0xFF |
62+|_______|___________|_________________________|____________|
63+|04..07 | DA1= 0xFF | DA0= 0xFF | SA5 | SA4 |
64+|_______|___________|_________________________|____________|
65+|08..11 | SA3 | SA2 | SA1 | SA0 |
66+|_______|___________|_________________________|____________|
67+|12..13 | EtherType = 0x88F8 (DMTF NC-SI) |
68+|_______|__________________________________________________| */
69+/*
70+ * Note: ethernet_header / ctl_packet_header / common_packet_except_name are
71+ * packed so the struct layout matches the on-the-wire NC-SI byte layout
72+ * (14B ethernet at offset 0, 16B control header at offset 14, payload at
73+ * offset 30, total NCSI_PACKET_TOTAL_LEN). The static_assert below pins the
74+ * struct size to the documented packet length; any future alignment change
75+ * that breaks the layout fails at compile time instead of producing
76+ * silently malformed frames on the wire.
77+ */
78+struct __attribute__((packed)) ethernet_header {
79+ unsigned char des_address[NCSI_MAC_LEN];
80+ unsigned char src_address[NCSI_MAC_LEN];
81+ uint16_t ether_type;
82+};
83+ 
84+/* The 16-byte control packet header is used in command, response, and AEN packets, and contains data
85+values intended to allow the packet to be identified, validated, and processed. The packet header is in
86+big-endian byte order.
87+ 
88+Bytes 31..24 23..16 15..08 07..00
89+00..03 MC ID Header Revision Reserved IID
90+04..07 Control Packet Type Ch. ID Reserved Payload Length
91+08..11 Reserved
92+12..15 Reserved */
93+struct __attribute__((packed)) ctl_packet_header {
94+ unsigned char mc_id;
95+ unsigned char header_revision;
96+ unsigned char reserved;
97+ unsigned char iid; // Instance ID
98+ unsigned char packet_type; // Control Packet Type
99+#ifdef BD_BIG_ENDIAN
100+ unsigned char package_id : 3;
@@ -2,14 +2,14 @@
2 "name": "libsoc_adapter_aspeed",2 "name": "libsoc_adapter_aspeed",
3 "type": "application",3 "type": "application",
4 "deployConfig": "",4 "deployConfig": "",
5- "version": "1.0.13",5+ "version": "1.0.14",
6 "license": "Mulan PSL v2",6 "license": "Mulan PSL v2",
7 "description": "BMC chip adapter for Aspeed.",7 "description": "BMC chip adapter for Aspeed.",
8 "dependencies": {8 "dependencies": {
9 "test": [],9 "test": [],
10 "build": [10 "build": [
11 {11 {
12- "conan": "bcal/[>=0.0.13]"12+ "conan": "bcal/[>=0.0.14]"
13 }13 }
14 ]14 ]
15 },15 },