47 "File %s doesn't seem to be a DTB.\n", filename);
64 const char *root_path =
"/";
65 const char *node_name =
"chosen";
66 const char *full_path_node_name =
"/chosen";
67 const char *property_name =
"bootargs";
71 uint8_t *fdt_buf_w_space =
new uint8_t[newLen];
73 int ret = fdt_open_into((
void *)
fileData, (
void *)fdt_buf_w_space, newLen);
75 warn(
"Error resizing buffer of flattened device tree, "
77 delete [] fdt_buf_w_space;
82 int offset = fdt_path_offset((
void *)fdt_buf_w_space, full_path_node_name);
85 offset = fdt_path_offset((
void *)fdt_buf_w_space, root_path);
86 offset = fdt_add_subnode((
void *)fdt_buf_w_space,
offset, node_name);
89 offset = fdt_path_offset((
void *)fdt_buf_w_space,
93 warn(
"Error finding or adding \"chosen\" subnode to flattened "
94 "device tree, errno: %d\n",
offset);
95 delete [] fdt_buf_w_space;
101 ret = fdt_setprop((
void *)fdt_buf_w_space,
offset, property_name,
102 (
const void *)_args,
len+1);
104 warn(
"Error setting \"bootargs\" property to flattened device tree, "
106 delete [] fdt_buf_w_space;
111 ret = fdt_pack((
void *)fdt_buf_w_space);
113 warn(
"Error re-packing flattened device tree structure, "
115 delete [] fdt_buf_w_space;
134 int offset = fdt_path_offset(
fd,
"/cpus/cpu@0");
137 const void *temp = fdt_getprop(
fd,
offset,
"cpu-release-addr", &
len);
141 rel_addr =
betoh(*
static_cast<const uint32_t *
>(temp));
143 rel_addr = (rel_addr << 32) |
144 betoh(*(
static_cast<const uint32_t *
>(temp) + 1));