mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:07:34 +00:00
LibDeviceTree: Add a slow, allocation-free property fetch API
Using the walk_device_tree helper, we can walk the device tree from the beginning looking for a specific property node. It's still missing the ability to get property lists, string lists, and property-specific data.
This commit is contained in:
parent
e9e279bb77
commit
613cfb31b1
3 changed files with 95 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibDeviceTree/FlattenedDeviceTree.h>
|
||||
#include <LibDeviceTree/Validation.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
|
@ -34,5 +35,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(DeviceTree::dump(*fdt_header, bytes));
|
||||
|
||||
auto compatible = TRY(DeviceTree::slow_get_property<StringView>("/compatible"sv, *fdt_header, bytes));
|
||||
auto compatible_strings = compatible.split_view('\0');
|
||||
dbgln("compatible with: {}", compatible_strings);
|
||||
|
||||
auto bootargs = TRY(DeviceTree::slow_get_property<StringView>("/chosen/bootargs"sv, *fdt_header, bytes));
|
||||
dbgln("bootargs: {}", bootargs);
|
||||
|
||||
auto cpu_compatible = TRY(DeviceTree::slow_get_property<StringView>("/cpus/cpu@0/compatible"sv, *fdt_header, bytes));
|
||||
dbgln("cpu0 compatible: {}", cpu_compatible);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue