1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:07:46 +00:00

Kernel/riscv64: Unflatten the DeviceTree

This commit is contained in:
Hediadyoin1 2024-02-14 15:01:21 +01:00 committed by Andrew Kaster
parent d3f6b03733
commit 7309427d2f
3 changed files with 26 additions and 1 deletions

View file

@ -4,17 +4,27 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Singleton.h>
#include <Kernel/Arch/riscv64/CPU.h>
#include <Kernel/Memory/MemoryManager.h>
#include <LibDeviceTree/DeviceTree.h>
#include <Userland/Libraries/LibDeviceTree/FlattenedDeviceTree.h>
#include <Userland/Libraries/LibDeviceTree/Validation.h>
static Singleton<OwnPtr<DeviceTree::DeviceTree>> s_device_tree;
namespace Kernel {
BootInfo s_boot_info;
alignas(PAGE_SIZE) __attribute__((section(".bss.fdt"))) u8 s_fdt_storage[fdt_storage_size];
ErrorOr<void> unflatten_fdt()
{
*s_device_tree = TRY(DeviceTree::DeviceTree::parse({ s_fdt_storage, fdt_storage_size }));
return {};
}
void dump_fdt()
{
auto& header = *bit_cast<DeviceTree::FlattenedDeviceTreeHeader*>(&s_fdt_storage[0]);
@ -23,3 +33,9 @@ void dump_fdt()
}
}
DeviceTree::DeviceTree const& DeviceTree::get()
{
VERIFY(*s_device_tree);
return **s_device_tree;
}