Andreas Sandberg merged this change by Andreas Sandberg. ( https://gem5-review.googlesource.com/8146 )

Change subject: mem: Add PortProxy read/write helper with explicit endianness
......................................................................

mem: Add PortProxy read/write helper with explicit endianness

Change-Id: Ia9a11ca68b2892dafd02f2c37324b99b35c77d34
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
Reviewed-by: Jack Travaglini <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/8146
Reviewed-by: Jason Lowe-Power <[email protected]>
---
M src/mem/port_proxy.hh
1 file changed, 32 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved



diff --git a/src/mem/port_proxy.hh b/src/mem/port_proxy.hh
index e9ddeec..ac1873b 100644
--- a/src/mem/port_proxy.hh
+++ b/src/mem/port_proxy.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2013 ARM Limited
+ * Copyright (c) 2011-2013, 2018 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -123,6 +123,20 @@
     template <typename T>
     void write(Addr address, T data) const;

+    /**
+     * Read sizeof(T) bytes from address and return as object T.
+     * Performs selected endianness transform.
+     */
+    template <typename T>
+    T readGtoH(Addr address, ByteOrder guest_byte_order) const;
+
+    /**
+     * Write object T to address. Writes sizeof(T) bytes.
+     * Performs selected endianness transform.
+     */
+    template <typename T>
+    void writeHtoG(Addr address, T data, ByteOrder guest_byte_order) const;
+
 #if THE_ISA != NULL_ISA
     /**
      * Read sizeof(T) bytes from address and return as object T.
@@ -157,6 +171,23 @@
     writeBlob(address, (uint8_t*)&data, sizeof(T));
 }

+template <typename T>
+T
+PortProxy::readGtoH(Addr address, ByteOrder byte_order) const
+{
+    T data;
+    readBlob(address, (uint8_t*)&data, sizeof(T));
+    return gtoh(data, byte_order);
+}
+
+template <typename T>
+void
+PortProxy::writeHtoG(Addr address, T data, ByteOrder byte_order) const
+{
+    data = htog(data, byte_order);
+    writeBlob(address, (uint8_t*)&data, sizeof(T));
+}
+
 #if THE_ISA != NULL_ISA
 template <typename T>
 T

--
To view, visit https://gem5-review.googlesource.com/8146
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia9a11ca68b2892dafd02f2c37324b99b35c77d34
Gerrit-Change-Number: 8146
Gerrit-PatchSet: 3
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to