51 "File %s doesn't seem to be a DTB.\n", filename);
67 off_t initrd_start,
size_t initrd_len)
69 const char *root_path =
"/";
70 const char *node_name =
"chosen";
71 const char *full_path_node_name =
"/chosen";
72 const char *bootargs_property_name =
"bootargs";
73 const char *linux_initrd_start_property_name =
"linux,initrd-start";
74 const char *linux_initrd_end_property_name =
"linux,initrd-end";
78 uint8_t *fdt_buf_w_space =
new uint8_t[newLen];
80 int ret = fdt_open_into((
void *)
fileData, (
void *)fdt_buf_w_space, newLen);
82 warn(
"Error resizing buffer of flattened device tree, "
84 delete [] fdt_buf_w_space;
89 int offset = fdt_path_offset((
void *)fdt_buf_w_space, full_path_node_name);
92 offset = fdt_path_offset((
void *)fdt_buf_w_space, root_path);
93 offset = fdt_add_subnode((
void *)fdt_buf_w_space,
offset, node_name);
96 offset = fdt_path_offset((
void *)fdt_buf_w_space,
100 warn(
"Error finding or adding \"chosen\" subnode to flattened "
101 "device tree, errno: %d\n",
offset);
102 delete [] fdt_buf_w_space;
108 ret = fdt_setprop((
void *)fdt_buf_w_space,
offset, bootargs_property_name,
109 (
const void *)_cmdline, cmdline_len+1);
111 warn(
"Error setting \"bootargs\" property to flattened device tree, "
113 delete [] fdt_buf_w_space;
117 if (initrd_len != 0) {
119 ret = fdt_setprop_u64((
void *)fdt_buf_w_space,
offset,
120 linux_initrd_start_property_name,
121 (uint64_t)initrd_start);
123 warn(
"Error setting \"linux,initrd-start\" property to flattened "
124 "device tree, errno: %d\n", ret);
125 delete [] fdt_buf_w_space;
130 ret = fdt_setprop_u64((
void *)fdt_buf_w_space,
offset,
131 linux_initrd_end_property_name,
132 (uint64_t)initrd_start + initrd_len);
134 warn(
"Error setting \"linux,initrd-len\" property to flattened "
135 "device tree, errno: %d\n", ret);
136 delete [] fdt_buf_w_space;
142 ret = fdt_pack((
void *)fdt_buf_w_space);
144 warn(
"Error re-packing flattened device tree structure, "
146 delete [] fdt_buf_w_space;
165 int offset = fdt_path_offset(
fd,
"/cpus/cpu@0");
168 const void *temp = fdt_getprop(
fd,
offset,
"cpu-release-addr", &
len);
172 rel_addr =
betoh(*
static_cast<const uint32_t *
>(temp));
174 rel_addr = (rel_addr << 32) |
175 betoh(*(
static_cast<const uint32_t *
>(temp) + 1));