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

Method ValidatePsciFunctionIds

src/include/kernel_fdt.hpp:803–827  ·  view source on GitHub ↗

* @brief 验证 PSCI 函数 ID * @param offset 节点偏移 * @return Expected 验证结果 */

Source from the content-addressed store, hash-verified

801 * @return Expected<void> 验证结果
802 */
803 [[nodiscard]] auto ValidatePsciFunctionIds(int offset) const
804 -> Expected<void> {
805 auto validate_id = [this, offset](const char* name,
806 uint64_t expected) -> Expected<void> {
807 int len = 0;
808 const auto* prop = fdt_get_property(fdt_header_, offset, name, &len);
809 if (prop != nullptr && static_cast<size_t>(len) >= sizeof(uint32_t)) {
810 uint32_t id =
811 fdt32_to_cpu(*reinterpret_cast<const uint32_t*>(prop->data));
812 klog::Debug("PSCI {} function ID: {:#X}", name, id);
813 if (id != expected) {
814 klog::Err("PSCI {} function ID mismatch: expected {:#X}, got {:#X}",
815 name, expected, id);
816 return std::unexpected(Error(ErrorCode::kFdtPropertyNotFound));
817 }
818 }
819 return {};
820 };
821
822 return validate_id("cpu_on", kPsciCpuOnFuncId)
823 .and_then([&]() { return validate_id("cpu_off", kPsciCpuOffFuncId); })
824 .and_then([&]() {
825 return validate_id("cpu_suspend", kPsciCpuSuspendFuncId);
826 });
827 }
828};
829
830using KernelFdtSingleton = etl::singleton<KernelFdt>;

Callers

nothing calls this directly

Calls 3

DebugFunction · 0.85
ErrFunction · 0.85
ErrorClass · 0.85

Tested by

no test coverage detected