From 7b30b33fc3d59f13524061fd1231745317b61732 Mon Sep 17 00:00:00 2001 From: hsc Date: Wed, 4 Apr 2012 16:06:01 +0000 Subject: [PATCH] MemoryManager::get/setBytes: std::vector -> void* Feels way more useful for the experiment I'm working on. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1026 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- core/SAL/Memory.hpp | 17 +++++++++-------- core/SAL/bochs/BochsMemory.hpp | 27 ++++++++++++++++----------- core/SAL/ovp/OVPMemory.hpp | 15 ++++++++------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/core/SAL/Memory.hpp b/core/SAL/Memory.hpp index 442ba0b7..d198a2b6 100644 --- a/core/SAL/Memory.hpp +++ b/core/SAL/Memory.hpp @@ -41,14 +41,14 @@ class MemoryManager */ virtual byte_t getByte(guest_address_t addr) = 0; /** - * Retrieves \a cnt bytes at address \a addr in the memory. + * Retrieves \a cnt bytes at address \a addr from the memory. * @param addr The guest address where the bytes are located. * The address is expected to be valid. - * @param cnt the number of bytes to be retrieved. \a addr + \a cnt + * @param cnt The number of bytes to be retrieved. \a addr + \a cnt * is expected to not exceed the memory limit. - * @param dest the destination buffer to write the bytes to + * @param dest Pointer to destination buffer to copy the data to. */ - virtual void getBytes(guest_address_t addr, size_t cnt, std::vector& dest) = 0; + virtual void getBytes(guest_address_t addr, size_t cnt, void *dest) = 0; /** * Writes the byte \a data to memory. * @param addr The guest address to write. @@ -57,13 +57,14 @@ class MemoryManager */ virtual void setByte(guest_address_t addr, byte_t data) = 0; /** - * Writes the bytes \a data to memory. Consequently data.size() bytes - * will be written. + * Copies data to memory. * @param addr The guest address to write. * The address is expected to be valid. - * @param data The new bytes to write + * @param cnt The number of bytes to be retrieved. \a addr + \a cnt + * is expected to not exceed the memory limit. + * @param src Pointer to data to be copied. */ - virtual void setBytes(guest_address_t addr, const std::vector& data) = 0; + virtual void setBytes(guest_address_t addr, size_t cnt, void const *src) = 0; /** * Transforms the guest address \a addr to a host address. * @param addr The guest address to be transformed diff --git a/core/SAL/bochs/BochsMemory.hpp b/core/SAL/bochs/BochsMemory.hpp index 597b7b79..cf2d9e54 100644 --- a/core/SAL/bochs/BochsMemory.hpp +++ b/core/SAL/bochs/BochsMemory.hpp @@ -49,17 +49,19 @@ class BochsMemoryManager : public MemoryManager return (static_cast(*reinterpret_cast(haddr))); } /** - * Retrieves \a cnt bytes at address \a addr in the memory. + * Retrieves \a cnt bytes at address \a addr from the memory. * @param addr The guest address where the bytes are located. * The address is expected to be valid. * @param cnt The number of bytes to be retrieved. \a addr + \a cnt * is expected to not exceed the memory limit. - * @param dest The destination buffer to write the bytes to + * @param dest Pointer to destination buffer to copy the data to. */ - void getBytes(guest_address_t addr, size_t cnt, std::vector& dest) + void getBytes(guest_address_t addr, size_t cnt, void *dest) { - for(size_t i = 0; i < cnt; i++) - dest.push_back(getByte(addr+i)); + char *d = static_cast(dest); + for (size_t i = 0; i < cnt; ++i) { + d[i] = getByte(addr + i); + } } /** * Writes the byte \a data to memory. @@ -75,16 +77,19 @@ class BochsMemoryManager : public MemoryManager *reinterpret_cast(haddr) = data; } /** - * Writes the bytes \a data to memory. Consequently \c data.size() - * bytes will be written. + * Copies data to memory. * @param addr The guest address to write. * The address is expected to be valid. - * @param data The new bytes to write + * @param cnt The number of bytes to be retrieved. \a addr + \a cnt + * is expected to not exceed the memory limit. + * @param src Pointer to data to be copied. */ - void setBytes(guest_address_t addr, const std::vector& data) + void setBytes(guest_address_t addr, size_t cnt, void const *src) { - for(size_t i = 0; i < data.size(); i++) - setByte(addr+i, data[i]); + char const *s = static_cast(src); + for (size_t i = 0; i < cnt; ++i) { + setByte(addr + i, s[i]); + } } /** * Transforms the guest address \a addr to a host address. diff --git a/core/SAL/ovp/OVPMemory.hpp b/core/SAL/ovp/OVPMemory.hpp index 4bd8d901..8c51b7b2 100644 --- a/core/SAL/ovp/OVPMemory.hpp +++ b/core/SAL/ovp/OVPMemory.hpp @@ -50,11 +50,11 @@ class OVPMemoryManager : public MemoryManager * Retrieves \a cnt bytes at address \a addr in the memory. * @param addr The guest address where the bytes are located. * The address is expected to be valid. - * @param cnt The number of bytes to be retrieved. \a addr + \a cnt + * @param cnt the number of bytes to be retrieved. \a addr + \a cnt * is expected to not exceed the memory limit. - * @param dest The destination buffer to write the bytes to + * @param dest Pointer to destination buffer to copy the data to. */ - void getBytes(guest_address_t addr, size_t cnt, std::vector& dest) + void getBytes(guest_address_t addr, size_t cnt, void *dest) { } /** @@ -67,13 +67,14 @@ class OVPMemoryManager : public MemoryManager { } /** - * Writes the bytes \a data to memory. Consequently \c data.size() - * bytes will be written. + * Copies data to memory. * @param addr The guest address to write. * The address is expected to be valid. - * @param data The new bytes to write + * @param cnt The number of bytes to be retrieved. \a addr + \a cnt + * is expected to not exceed the memory limit. + * @param src Pointer to data to be copied. */ - void setBytes(guest_address_t addr, const std::vector& data) + void setBytes(guest_address_t addr, size_t cnt, void const *src) { } /**