46 if (fdt_magic((
void*)data) == FDT_MAGIC) {
56 :
ObjectFile(_filename, _len, _data, _arch, _opSys)
89 const char* root_path =
"/";
90 const char* node_name =
"chosen";
91 const char* full_path_node_name =
"/chosen";
92 const char* property_name =
"bootargs";
95 int newLen = 2*this->
len;
96 uint8_t* fdt_buf_w_space =
new uint8_t[newLen];
98 int ret = fdt_open_into((
void*)
fileData, (
void*)fdt_buf_w_space, (newLen));
100 warn(
"Error resizing buffer of flattened device tree, "
102 delete [] fdt_buf_w_space;
107 int offset = fdt_path_offset((
void*)fdt_buf_w_space, full_path_node_name);
110 offset = fdt_path_offset((
void*)fdt_buf_w_space, root_path);
111 offset = fdt_add_subnode((
void*)fdt_buf_w_space, offset, node_name);
114 offset = fdt_path_offset((
void*)fdt_buf_w_space, full_path_node_name);
117 warn(
"Error finding or adding \"chosen\" subnode to flattened "
118 "device tree, errno: %d\n", offset);
119 delete [] fdt_buf_w_space;
125 ret = fdt_setprop((
void*)fdt_buf_w_space, offset, property_name,
126 (
const void*)_args, len+1);
128 warn(
"Error setting \"bootargs\" property to flattened device tree, "
130 delete [] fdt_buf_w_space;
135 ret = fdt_pack((
void*)fdt_buf_w_space);
137 warn(
"Error re-packing flattened device tree structure, "
139 delete [] fdt_buf_w_space;
160 int offset = fdt_path_offset(fd,
"/cpus/cpu@0");
163 const void* temp = fdt_getprop(fd, offset,
"cpu-release-addr", &len);
167 rel_addr =
betoh(*static_cast<const uint32_t*>(temp));
169 rel_addr = (rel_addr << 32) | betoh(*(static_cast<const uint32_t*>(temp)+1));
bool loadAllSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr addrMask=maxAddr)
This implements an object file format to support loading and modifying flattened device tree blobs fo...
DtbObject(const std::string &_filename, size_t _len, uint8_t *_data, Arch _arch, OpSys _opSys)
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.
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...
static ObjectFile * tryFile(const std::string &fname, size_t len, uint8_t *data)
Static function that tries to load file as a flattened device tree blob.
bool loadLocalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr addrMask=maxAddr)
bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr addrMask=maxAddr)