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));
bool addBootData(const char *_cmdline, size_t cmdline_len, off_t initrd_addr, size_t initrd_len)
Adds the passed in Command Line options and initrd for the kernel to the proper location in the devic...
Addr findReleaseAddr()
Parse the DTB file enough to find the provided release address and return it.
DtbFile(const std::string &name)
MemoryImage buildImage() const override
bool fileDataMmapped
Bool marking if this dtb file has replaced the original read in DTB file with a new modified buffer.
ImageFileDataPtr imageData
This implements an image file format to support loading and modifying flattened device tree blobs for...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
std::shared_ptr< ImageFileData > ImageFileDataPtr
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)