diff options
author | Daniel R. Carvalho <odanrc@yahoo.com.br> | 2019-10-16 14:38:04 +0200 |
---|---|---|
committer | Daniel Carvalho <odanrc@yahoo.com.br> | 2019-12-12 14:43:09 +0000 |
commit | 05156e673095de0ab296166e6508494fa6e21bf9 (patch) | |
tree | bcd61502e6ec5db4c862994683d55750b16286c7 /src/mem/abstract_mem.hh | |
parent | a87a3e4fad3bc83cb42f4896404dbd65fd3a0d73 (diff) | |
download | gem5-05156e673095de0ab296166e6508494fa6e21bf9.tar.xz |
mem: Encapsulate mapping gem5 to host address space
Create a function to encapsulate mapping an address in gem5's
address space to the host's address space. The returned value can
be used to access the contents of the given address.
As a side effect, make the local variable hostAddr use snake_case
to comply with gem5's coding style.
Change-Id: I2445d3ab4c7ce5746182b307c26cbafc68aa139c
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22610
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/mem/abstract_mem.hh')
-rw-r--r-- | src/mem/abstract_mem.hh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mem/abstract_mem.hh b/src/mem/abstract_mem.hh index d92e7070c..14694f9d5 100644 --- a/src/mem/abstract_mem.hh +++ b/src/mem/abstract_mem.hh @@ -271,6 +271,19 @@ class AbstractMemory : public ClockedObject AddrRange getAddrRange() const; /** + * Transform a gem5 address space address into its physical counterpart + * in the host address space. + * + * @param addr Address in gem5's address space. + * @return Pointer to the corresponding memory address of the host. + */ + inline uint8_t * + toHostAddr(Addr addr) const + { + return pmemAddr + addr - range.start(); + } + + /** * Get the memory size. * * @return the size of the memory |