Pull in latest fixes from dtc, up to 0060471
This includes a small battery of /memreserve/ fixes to make sure dtc is properly writing these regions into the output file and reading them back out. As of this update, dtc will now also assume common defaults for -I/-O if only one is specified; namely, dts for one implies dtb for the other and vice versa (Requested by: jhibbits, preserves GPL dtc behavior too). MFC after: 1 week
This commit is contained in:
parent
3cd6b1b8b8
commit
eadfc7ee36
@ -36,7 +36,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -94,6 +94,8 @@ void version(const char* progname)
|
||||
} // Anonymous namespace
|
||||
|
||||
using fdt::device_tree;
|
||||
using fdt::tree_write_fn_ptr;
|
||||
using fdt::tree_read_fn_ptr;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@ -104,8 +106,8 @@ main(int argc, char **argv)
|
||||
const char *in_file = "-";
|
||||
FILE *depfile = 0;
|
||||
bool debug_mode = false;
|
||||
auto write_fn = &device_tree::write_binary;
|
||||
auto read_fn = &device_tree::parse_dts;
|
||||
tree_write_fn_ptr write_fn = nullptr;
|
||||
tree_read_fn_ptr read_fn = nullptr;
|
||||
uint32_t boot_cpu = 0;
|
||||
bool boot_cpu_specified = false;
|
||||
bool keep_going = false;
|
||||
@ -135,6 +137,10 @@ main(int argc, char **argv)
|
||||
if (arg == "dtb")
|
||||
{
|
||||
read_fn = &device_tree::parse_dtb;
|
||||
if (write_fn == nullptr)
|
||||
{
|
||||
write_fn = &device_tree::write_dts;
|
||||
}
|
||||
}
|
||||
else if (arg == "dts")
|
||||
{
|
||||
@ -161,6 +167,10 @@ main(int argc, char **argv)
|
||||
else if (arg == "dts")
|
||||
{
|
||||
write_fn = &device_tree::write_dts;
|
||||
if (read_fn == nullptr)
|
||||
{
|
||||
read_fn = &device_tree::parse_dtb;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -298,6 +308,14 @@ main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
if (read_fn == nullptr)
|
||||
{
|
||||
read_fn = &device_tree::parse_dts;
|
||||
}
|
||||
if (write_fn == nullptr)
|
||||
{
|
||||
write_fn = &device_tree::write_binary;
|
||||
}
|
||||
if (optind < argc)
|
||||
{
|
||||
in_file = argv[optind];
|
||||
|
@ -1563,11 +1563,11 @@ device_tree::parse_file(text_input_buffer &input,
|
||||
{
|
||||
input.next_token();
|
||||
// Read the header
|
||||
while (input.consume("/dts-v1/;"))
|
||||
if (input.consume("/dts-v1/;"))
|
||||
{
|
||||
read_header = true;
|
||||
input.next_token();
|
||||
}
|
||||
input.next_token();
|
||||
if (input.consume("/plugin/;"))
|
||||
{
|
||||
is_plugin = true;
|
||||
@ -1589,9 +1589,12 @@ device_tree::parse_file(text_input_buffer &input,
|
||||
{
|
||||
input.parse_error("Expected size on /memreserve/ node.");
|
||||
}
|
||||
else
|
||||
{
|
||||
reservations.push_back(reservation(start, len));
|
||||
}
|
||||
input.next_token();
|
||||
input.consume(';');
|
||||
reservations.push_back(reservation(start, len));
|
||||
input.next_token();
|
||||
}
|
||||
while (valid && !input.finished())
|
||||
@ -1661,7 +1664,7 @@ device_tree::write(int fd)
|
||||
reservation_writer.write_comment(string("Reservation start"));
|
||||
reservation_writer.write_data(i.first);
|
||||
reservation_writer.write_comment(string("Reservation length"));
|
||||
reservation_writer.write_data(i.first);
|
||||
reservation_writer.write_data(i.second);
|
||||
}
|
||||
// Write n spare reserve map entries, plus the trailing 0.
|
||||
for (uint32_t i=0 ; i<=spare_reserve_map_entries ; i++)
|
||||
@ -1747,10 +1750,11 @@ device_tree::write_dts(int fd)
|
||||
if (!reservations.empty())
|
||||
{
|
||||
const char msg[] = "/memreserve/";
|
||||
fwrite(msg, sizeof(msg), 1, file);
|
||||
// Exclude the null byte when we're writing it out to the file.
|
||||
fwrite(msg, sizeof(msg) - 1, 1, file);
|
||||
for (auto &i : reservations)
|
||||
{
|
||||
fprintf(file, " %" PRIx64 " %" PRIx64, i.first, i.second);
|
||||
fprintf(file, " 0x%" PRIx64 " 0x%" PRIx64, i.first, i.second);
|
||||
}
|
||||
fputs(";\n\n", file);
|
||||
}
|
||||
@ -1794,6 +1798,10 @@ device_tree::parse_dtb(const string &fn, FILE *)
|
||||
valid = false;
|
||||
return;
|
||||
}
|
||||
if (start != 0 || length != 0)
|
||||
{
|
||||
reservations.push_back(reservation(start, length));
|
||||
}
|
||||
} while (!((start == 0) && (length == 0)));
|
||||
input_buffer struct_table =
|
||||
input.buffer_from_offset(h.off_dt_struct, h.size_dt_struct);
|
||||
|
@ -58,6 +58,14 @@ namespace fdt
|
||||
class property;
|
||||
class node;
|
||||
class device_tree;
|
||||
/**
|
||||
* Type for device tree write functions.
|
||||
*/
|
||||
typedef void (device_tree::* tree_write_fn_ptr)(int);
|
||||
/**
|
||||
* Type for device tree read functions.
|
||||
*/
|
||||
typedef void (device_tree::* tree_read_fn_ptr)(const std::string &, FILE *);
|
||||
/**
|
||||
* Type for (owned) pointers to properties.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user