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
This commit is contained in:
hsc
2012-04-04 16:06:01 +00:00
parent a64b271bb6
commit 7b30b33fc3
3 changed files with 33 additions and 26 deletions

View File

@ -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<byte_t>& 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<byte_t>& 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

View File

@ -49,17 +49,19 @@ class BochsMemoryManager : public MemoryManager
return (static_cast<byte_t>(*reinterpret_cast<Bit8u*>(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<byte_t>& 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<char *>(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<Bit8u*>(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<byte_t>& 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<char const *>(src);
for (size_t i = 0; i < cnt; ++i) {
setByte(addr + i, s[i]);
}
}
/**
* Transforms the guest address \a addr to a host address.

View File

@ -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<byte_t>& 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<byte_t>& data)
void setBytes(guest_address_t addr, size_t cnt, void const *src)
{
}
/**