46 "File %s doesn't seem to be a DTB.\n", filename);
63 const char *root_path =
"/";
64 const char *node_name =
"chosen";
65 const char *full_path_node_name =
"/chosen";
66 const char *property_name =
"bootargs";
70 uint8_t *fdt_buf_w_space =
new uint8_t[newLen];
72 int ret = fdt_open_into((
void *)
fileData, (
void *)fdt_buf_w_space, newLen);
74 warn(
"Error resizing buffer of flattened device tree, " 76 delete [] fdt_buf_w_space;
81 int offset = fdt_path_offset((
void *)fdt_buf_w_space, full_path_node_name);
84 offset = fdt_path_offset((
void *)fdt_buf_w_space, root_path);
85 offset = fdt_add_subnode((
void *)fdt_buf_w_space, offset, node_name);
88 offset = fdt_path_offset((
void *)fdt_buf_w_space,
92 warn(
"Error finding or adding \"chosen\" subnode to flattened " 93 "device tree, errno: %d\n", offset);
94 delete [] fdt_buf_w_space;
100 ret = fdt_setprop((
void *)fdt_buf_w_space, offset, property_name,
101 (
const void *)_args, len+1);
103 warn(
"Error setting \"bootargs\" property to flattened device tree, " 105 delete [] fdt_buf_w_space;
110 ret = fdt_pack((
void *)fdt_buf_w_space);
112 warn(
"Error re-packing flattened device tree structure, " 114 delete [] fdt_buf_w_space;
121 fileData = fdt_buf_w_space;
133 int offset = fdt_path_offset(fd,
"/cpus/cpu@0");
136 const void *temp = fdt_getprop(fd, offset,
"cpu-release-addr", &len);
140 rel_addr =
betoh(*static_cast<const uint32_t *>(temp));
142 rel_addr = (rel_addr << 32) |
143 betoh(*(static_cast<const uint32_t *>(temp) + 1));
ImageFileDataPtr imageData
bool fileDataMmapped
Bool marking if this dtb file has replaced the original read in DTB file with a new modified buffer...
Addr findReleaseAddr()
Parse the DTB file enough to find the provided release address and return it.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
DtbFile(const std::string &name)
This implements an image file format to support loading and modifying flattened device tree blobs for...
MemoryImage buildImage() const override
bool addBootCmdLine(const char *_args, size_t len)
Adds the passed in Command Line options for the kernel to the proper location in the device tree...
std::shared_ptr< ImageFileData > ImageFileDataPtr
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...