Files
fail/core/SAL/Memory.hpp
hsc 7b30b33fc3 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
2012-04-04 16:06:01 +00:00

79 lines
2.4 KiB
C++

#ifndef __MEMORY_HPP__
#define __MEMORY_HPP__
// Author: Adrian Böckenkamp
// Date: 07.09.2011
#include <vector>
#include <stdint.h>
#include <cstring> // Added for size_t support
#include "SALConfig.hpp"
namespace sal
{
/**
* \class MemoryManager
* Defines an abstract interface to access the simulated memory pool
* and query meta information, e.g. the memory size.
*/
class MemoryManager
{
public:
virtual ~MemoryManager() { }
/**
* Retrieves the size of the available simulated memory.
* @return the size of the memory pool in bytes
*/
virtual size_t getPoolSize() const = 0;
/**
* Retrieves the starting address of the host memory. This is the
* first valid address in memory.
* @return the starting address
*/
virtual host_address_t getStartAddr() const = 0;
/**
* Retrieves the byte at address \a addr in the memory.
* @param addr The guest address where the byte is located.
* The address is expected to be valid.
* @return the byte at \a addr
*/
virtual byte_t getByte(guest_address_t addr) = 0;
/**
* 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 Pointer to destination buffer to copy the data to.
*/
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.
* The address is expected to be valid.
* @param data The new byte to write
*/
virtual void setByte(guest_address_t addr, byte_t data) = 0;
/**
* Copies data to memory.
* @param addr The guest address to write.
* 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 src Pointer to data to be copied.
*/
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
* @return the transformed (host) address or \c ADDR_INV on errors
*/
virtual host_address_t guestToHost(guest_address_t addr) = 0;
};
} // end-of-namespace: sal
#endif /* __MEMORY_HPP__ */