Alistair Delva has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/54183 )
Change subject: base: Add support for DT initrd/initramfs
......................................................................
base: Add support for DT initrd/initramfs
Add a new API function, addBootData(), which allows the ports to specify
the size and load address of the initrd/initramfs via DeviceTree. This
uses the standard chosen nodes for initrd-start/initrd-end.
Update the addBootCmdline() to call addBootData() with no
initrd/initramfs so as to maintain backwards compatibility.
Change-Id: I7b1d5cf2a0b18685eaadf1d881434f3d48c45d8b
Signed-off-by: Alistair Delva <[email protected]>
---
M src/base/loader/dtb_file.cc
M src/base/loader/dtb_file.hh
2 files changed, 63 insertions(+), 5 deletions(-)
diff --git a/src/base/loader/dtb_file.cc b/src/base/loader/dtb_file.cc
index f89b1ae..c3aa9b4 100644
--- a/src/base/loader/dtb_file.cc
+++ b/src/base/loader/dtb_file.cc
@@ -63,12 +63,15 @@
}
bool
-DtbFile::addBootCmdLine(const char *_args, size_t len)
+DtbFile::addBootData(const char *_cmdline, size_t cmdline_len,
+ off_t initrd_start, size_t initrd_len)
{
const char *root_path = "/";
const char *node_name = "chosen";
const char *full_path_node_name = "/chosen";
- const char *property_name = "bootargs";
+ const char *bootargs_property_name = "bootargs";
+ const char *linux_initrd_start_property_name = "linux,initrd-start";
+ const char *linux_initrd_end_property_name = "linux,initrd-end";
// Make a new buffer that has extra space to add nodes/properties
int newLen = 2 * length;
@@ -102,8 +105,8 @@
}
// Set the bootargs property in the /chosen node
- ret = fdt_setprop((void *)fdt_buf_w_space, offset, property_name,
- (const void *)_args, len+1);
+ ret = fdt_setprop((void *)fdt_buf_w_space, offset,
bootargs_property_name,
+ (const void *)_cmdline, cmdline_len+1);
if (ret < 0) {
warn("Error setting \"bootargs\" property to flattened device
tree, "
"errno: %d\n", ret);
@@ -111,6 +114,30 @@
return false;
}
+ if (initrd_len != 0) {
+ // Set the linux,initrd-start property in the /chosen node
+ ret = fdt_setprop_u64((void *)fdt_buf_w_space, offset,
+ linux_initrd_start_property_name,
+ (uint64_t)initrd_start);
+ if (ret < 0) {
+ warn("Error setting \"linux,initrd-start\" property to
flattened "
+ "device tree, errno: %d\n", ret);
+ delete [] fdt_buf_w_space;
+ return false;
+ }
+
+ // Set the computed linux,initrd-end property in the /chosen node
+ ret = fdt_setprop_u64((void *)fdt_buf_w_space, offset,
+ linux_initrd_end_property_name,
+ (uint64_t)initrd_start + initrd_len + 1);
+ if (ret < 0) {
+ warn("Error setting \"linux,initrd-len\" property to
flattened "
+ "device tree, errno: %d\n", ret);
+ delete [] fdt_buf_w_space;
+ return false;
+ }
+ }
+
// Repack the dtb for kernel use
ret = fdt_pack((void *)fdt_buf_w_space);
if (ret < 0) {
diff --git a/src/base/loader/dtb_file.hh b/src/base/loader/dtb_file.hh
index f0a211f..c11b195 100644
--- a/src/base/loader/dtb_file.hh
+++ b/src/base/loader/dtb_file.hh
@@ -58,13 +58,27 @@
DtbFile(const std::string &name);
~DtbFile();
+ /** Adds the passed in Command Line options and initrd for the kernel
+ * to the proper location in the device tree.
+ * @param _cmdline command line to append
+ * @param cmdline_len length of the command line string
+ * @param initrd_addr starting physical address of initrd
+ * @param initrd_len length of initrd data in memory
+ * @return returns true on success, false otherwise
+ */
+ bool addBootData(const char* _cmdline, size_t cmdline_len,
+ off_t initrd_addr, size_t initrd_len);
+
/** Adds the passed in Command Line options for the kernel
* to the proper location in the device tree.
* @param _args command line to append
* @param len length of the command line string
* @return returns true on success, false otherwise
*/
- bool addBootCmdLine(const char* _args, size_t len);
+ inline bool
+ addBootCmdLine(const char* _args, size_t len) {
+ return addBootData(_args, len, 0, 0);
+ }
/** Parse the DTB file enough to find the provided release
* address and return it.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/54183
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7b1d5cf2a0b18685eaadf1d881434f3d48c45d8b
Gerrit-Change-Number: 54183
Gerrit-PatchSet: 1
Gerrit-Owner: Alistair Delva <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s