MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / FindEnabledCompatibleNode

Method FindEnabledCompatibleNode

src/include/kernel_fdt.hpp:704–726  ·  view source on GitHub ↗

* @brief 根据 compatible 查找已启用的节点(跳过 status="disabled") * @param compatible 要查找的 compatible 字符串 * @return Expected 节点偏移量 */

Source from the content-addressed store, hash-verified

702 * @return Expected<int> 节点偏移量
703 */
704 [[nodiscard]] auto FindEnabledCompatibleNode(const char* compatible) const
705 -> Expected<int> {
706 int offset = -1;
707 while (true) {
708 offset = fdt_node_offset_by_compatible(fdt_header_, offset, compatible);
709 if (offset < 0) {
710 return std::unexpected(Error(ErrorCode::kFdtNodeNotFound));
711 }
712
713 int len = 0;
714 const auto* status_prop =
715 fdt_get_property(fdt_header_, offset, "status", &len);
716
717 if (status_prop == nullptr) {
718 return offset;
719 }
720
721 const char* status = reinterpret_cast<const char*>(status_prop->data);
722 if (strcmp(status, "okay") == 0 || strcmp(status, "ok") == 0) {
723 return offset;
724 }
725 }
726 }
727
728 /**
729 * @brief 获取 reg 属性(返回第一个 reg 条目)

Callers

nothing calls this directly

Calls 2

ErrorClass · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected