mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 13:11:46 +03:00
Kernel/riscv64: Unflatten the DeviceTree
This commit is contained in:
parent
d3f6b03733
commit
7309427d2f
Notes:
sideshowbarker
2024-07-17 14:36:19 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/7309427d2f Pull-request: https://github.com/SerenityOS/serenity/pull/22948 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/kleinesfilmroellchen Reviewed-by: https://github.com/spholz
@ -288,7 +288,8 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init([[maybe_unused]] BootInfo con
|
||||
ACPI::initialize();
|
||||
|
||||
#if ARCH(RISCV64)
|
||||
// FIXME: Unflatten the device tree and use it for device discovery
|
||||
MUST(unflatten_fdt());
|
||||
|
||||
dump_fdt();
|
||||
#endif
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <Kernel/Memory/PhysicalAddress.h>
|
||||
#include <Kernel/Prekernel/Prekernel.h>
|
||||
#include <LibDeviceTree/DeviceTree.h>
|
||||
|
||||
#include <AK/Platform.h>
|
||||
VALIDATE_IS_RISCV64()
|
||||
@ -17,7 +18,14 @@ namespace Kernel {
|
||||
constexpr size_t fdt_storage_size = 2 * MiB;
|
||||
extern u8 s_fdt_storage[fdt_storage_size];
|
||||
|
||||
// FIXME: These should move to an architecture independent location,
|
||||
// once we need device tree parsing in other architectures, like aarch64
|
||||
extern BootInfo s_boot_info;
|
||||
|
||||
ErrorOr<void> unflatten_fdt();
|
||||
void dump_fdt();
|
||||
}
|
||||
|
||||
namespace DeviceTree {
|
||||
DeviceTree const& get();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user