mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:34:57 +00:00
LibDeviceTree: Add a simple DeviceTree class
This makes it easier to work with device tree nodes and properties, then writing simple state machines to parse the device tree. This also makes the old slow traversal methods use the DeviceTreeProperty helper class, and adds a simple test.
This commit is contained in:
parent
0fa718ead8
commit
21a21c6a11
10 changed files with 316 additions and 31 deletions
|
@ -35,14 +35,13 @@ 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 compatible = TRY(DeviceTree::slow_get_property("/compatible"sv, *fdt_header, bytes)).as_strings();
|
||||
dbgln("compatible with: {}", compatible);
|
||||
|
||||
auto bootargs = TRY(DeviceTree::slow_get_property<StringView>("/chosen/bootargs"sv, *fdt_header, bytes));
|
||||
auto bootargs = TRY(DeviceTree::slow_get_property("/chosen/bootargs"sv, *fdt_header, bytes)).as_string();
|
||||
dbgln("bootargs: {}", bootargs);
|
||||
|
||||
auto cpu_compatible = TRY(DeviceTree::slow_get_property<StringView>("/cpus/cpu@0/compatible"sv, *fdt_header, bytes));
|
||||
auto cpu_compatible = TRY(DeviceTree::slow_get_property("/cpus/cpu@0/compatible"sv, *fdt_header, bytes)).as_string();
|
||||
dbgln("cpu0 compatible: {}", cpu_compatible);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue