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

Method GetTimebaseFrequency

src/include/kernel_fdt.hpp:173–190  ·  view source on GitHub ↗

* @brief 获取 CPU 时钟频率 * @return Expected 时钟频率 * @pre fdt_header_ 不为空 */

Source from the content-addressed store, hash-verified

171 * @pre fdt_header_ 不为空
172 */
173 [[nodiscard]] auto GetTimebaseFrequency() const -> Expected<uint32_t> {
174 assert(fdt_header_ != nullptr && "fdt_header_ is null");
175
176 return FindNode("/cpus").and_then([this](int offset) -> Expected<uint32_t> {
177 int len = 0;
178 const auto* prop = reinterpret_cast<const uint32_t*>(
179 fdt_getprop(fdt_header_, offset, "timebase-frequency", &len));
180 if (prop == nullptr) {
181 return std::unexpected(Error(ErrorCode::kFdtPropertyNotFound));
182 }
183
184 if (len != sizeof(uint32_t)) {
185 return std::unexpected(Error(ErrorCode::kFdtInvalidPropertySize));
186 }
187
188 return fdt32_to_cpu(*prop);
189 });
190 }
191
192 /**
193 * @brief 获取 GIC 信息

Callers 2

BasicInfoMethod · 0.80
TEST_FFunction · 0.80

Calls 1

ErrorClass · 0.85

Tested by 1

TEST_FFunction · 0.64