#define __SIM_ARGUMENTS_HH__
#include <cassert>
+#include <memory>
-#include "arch/vtophys.hh"
-#include "base/refcnt.hh"
#include "base/types.hh"
-#include "mem/vport.hh"
+#include "mem/fs_translating_port_proxy.hh"
class ThreadContext;
protected:
ThreadContext *tc;
int number;
- uint64_t getArg(uint8_t size, bool fp = false);
+ uint64_t getArg(uint16_t size = (uint16_t)(-1), bool fp = false);
protected:
- class Data : public RefCounted
+ class Data
{
public:
Data(){}
char *alloc(size_t size);
};
- RefCountingPtr<Data> data;
+ std::shared_ptr<Data> data;
public:
Arguments(ThreadContext *ctx, int n = 0)
- : tc(ctx), number(n), data(NULL)
- { assert(number >= 0); data = new Data;}
+ : tc(ctx), number(n), data(new Data())
+ { assert(number >= 0); }
Arguments(const Arguments &args)
: tc(args.tc), number(args.number), data(args.data) {}
~Arguments() {}
ThreadContext *getThreadContext() const { return tc; }
const Arguments &operator=(const Arguments &args) {
- tc = args.tc;
- number = args.number;
- data = args.data;
+ if (this != &args) {
+ tc = args.tc;
+ number = args.number;
+ data = args.data;
+ }
return *this;
}
// for checking if an argument is NULL
bool operator!() {
- return getArg(TheISA::MachineBytes) == 0;
+ return getArg() == 0;
}
Arguments &operator++() {
template <class T>
operator T() {
assert(sizeof(T) <= sizeof(uint64_t));
- T data = static_cast<T>(getArg(sizeof(T)));
- return data;
+ T d = static_cast<T>(getArg(sizeof(T)));
+ return d;
}
template <class T>
operator T *() {
T *buf = (T *)data->alloc(sizeof(T));
- CopyData(tc, buf, getArg(sizeof(T)), sizeof(T));
+ CopyOut(tc, buf, getArg(sizeof(T)), sizeof(T));
return buf;
}
operator char *() {
char *buf = data->alloc(2048);
- CopyStringOut(tc, buf, getArg(TheISA::MachineBytes), 2048);
+ CopyStringOut(tc, buf, getArg(), 2048);
return buf;
}
};