mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 05:35:52 +03:00
5e1499d104
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2021, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/ByteString.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/MappedFile.h>
|
|
#include <LibCore/System.h>
|
|
#include <LibDeviceTree/FlattenedDeviceTree.h>
|
|
#include <LibDeviceTree/Validation.h>
|
|
#include <LibMain/Main.h>
|
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
{
|
|
TRY(Core::System::pledge("stdio rpath"));
|
|
|
|
ByteString filename;
|
|
|
|
Core::ArgsParser args;
|
|
args.add_positional_argument(filename, "File to process", "file", Core::ArgsParser::Required::Yes);
|
|
args.parse(arguments);
|
|
|
|
// FIXME: Figure out how to do this sanely from stdin
|
|
auto file = TRY(Core::MappedFile::map(filename));
|
|
|
|
if (TRY(file->size()) < sizeof(DeviceTree::FlattenedDeviceTreeHeader)) {
|
|
warnln("Not enough data in {} to contain a device tree header!", filename);
|
|
return 1;
|
|
}
|
|
|
|
auto const* fdt_header = reinterpret_cast<DeviceTree::FlattenedDeviceTreeHeader const*>(file->data());
|
|
auto bytes = file->bytes();
|
|
|
|
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;
|
|
}
|