Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/55783 )

Change subject: dev: Add a qemu fw config item for a byte array.
......................................................................

dev: Add a qemu fw config item for a byte array.

This is similar to the string item, except it's easier to set up with
binary data, and harder to set up if the data is a string constant.

Change-Id: I9aa2aa223386e275308377a98bdadaf65e6cb896
---
M src/dev/qemu/fw_cfg.hh
M src/dev/qemu/SConscript
M src/dev/qemu/QemuFwCfg.py
3 files changed, 43 insertions(+), 1 deletion(-)



diff --git a/src/dev/qemu/QemuFwCfg.py b/src/dev/qemu/QemuFwCfg.py
index 3a21063..0851ef0 100644
--- a/src/dev/qemu/QemuFwCfg.py
+++ b/src/dev/qemu/QemuFwCfg.py
@@ -56,6 +56,14 @@
     # The string which directly populates this item.
     string = Param.String('String to export')

+class QemuFwCfgItemBytes(QemuFwCfgItem):
+    type = 'QemuFwCfgItemBytes'
+    cxx_class = 'gem5::qemu::FwCfgItemFactory<gem5::qemu::FwCfgItemBytes>'
+    cxx_template_params = ['class ItemType']
+    cxx_header = 'dev/qemu/fw_cfg.hh'
+
+    data = VectorParam.UInt8('Bytes to export')
+
 class QemuFwCfg(PioDevice):
     type = 'QemuFwCfg'
     cxx_class = 'gem5::qemu::FwCfg'
diff --git a/src/dev/qemu/SConscript b/src/dev/qemu/SConscript
index a2fff02..59a50cf 100644
--- a/src/dev/qemu/SConscript
+++ b/src/dev/qemu/SConscript
@@ -26,7 +26,8 @@
 Import('*')

 SimObject('QemuFwCfg.py', sim_objects=[
-    'QemuFwCfgItem', 'QemuFwCfgItemFile', 'QemuFwCfgItemString',
+    'QemuFwCfgItem',
+    'QemuFwCfgItemBytes', 'QemuFwCfgItemFile', 'QemuFwCfgItemString',
     'QemuFwCfg', 'QemuFwCfgIo', 'QemuFwCfgMmio'])
 Source('fw_cfg.cc')

diff --git a/src/dev/qemu/fw_cfg.hh b/src/dev/qemu/fw_cfg.hh
index 4c780b3..c196eb6 100644
--- a/src/dev/qemu/fw_cfg.hh
+++ b/src/dev/qemu/fw_cfg.hh
@@ -40,6 +40,7 @@
 #include "params/QemuFwCfg.hh"
 #include "params/QemuFwCfgIo.hh"
 #include "params/QemuFwCfgItem.hh"
+#include "params/QemuFwCfgItemBytes.hh"
 #include "params/QemuFwCfgItemFile.hh"
 #include "params/QemuFwCfgItemString.hh"
 #include "params/QemuFwCfgMmio.hh"
@@ -134,6 +135,26 @@
     }
 };

+// An item who's value comes from an array of bytes.
+class FwCfgItemBytes : public FwCfgItemFixed
+{
+  private:
+    std::vector<uint8_t> data;
+
+  public:
+    FwCfgItemBytes(const std::string &new_path, bool arch_specific,
+            const std::vector<uint8_t> &_data, uint16_t new_index=0) :
+        FwCfgItemFixed(new_path, arch_specific, new_index), data(_data)
+    {}
+
+    FwCfgItemBytes(const QemuFwCfgItemBytesParams &p) :
+        FwCfgItemBytes(p.path, p.arch_specific, p.data, p.index)
+    {}
+
+    const void *bytes() const override { return (void *)data.data(); }
+    uint64_t length() const override { return data.size(); }
+};
+
 /*
* Base and template classes for creating SimObject wrappers for item types.
  */

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/55783
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: I9aa2aa223386e275308377a98bdadaf65e6cb896
Gerrit-Change-Number: 55783
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to