2 * Copyright (c) 2003 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef __ARGUMENTS_HH__
30 #define __ARGUMENTS_HH__
34 #include "base/refcnt.hh"
35 #include "kern/tru64/kernel.hh"
36 #include "sim/host.hh"
37 #include "targetarch/vtophys.hh"
46 uint64_t getArg(bool fp = false);
49 class Data : public RefCounted
56 std::list<char *> data;
59 char *alloc(size_t size);
62 RefCountingPtr<Data> data;
65 AlphaArguments(ExecContext *ctx, int n = 0)
66 : xc(ctx), number(n), data(NULL)
67 { assert(number >= 0); data = new Data;}
68 AlphaArguments(const AlphaArguments &args)
69 : xc(args.xc), number(args.number), data(args.data) {}
72 ExecContext *getExecContext() const { return xc; }
74 const AlphaArguments &operator=(const AlphaArguments &args) {
81 AlphaArguments &operator++() {
87 AlphaArguments operator++(int) {
88 AlphaArguments args = *this;
94 AlphaArguments &operator--() {
100 AlphaArguments operator--(int) {
101 AlphaArguments args = *this;
107 const AlphaArguments &operator+=(int index) {
113 const AlphaArguments &operator-=(int index) {
119 AlphaArguments operator[](int index) {
120 return AlphaArguments(xc, index);
125 assert(sizeof(T) <= sizeof(uint64_t));
126 T data = static_cast<T>(getArg());
132 T *buf = (T *)data->alloc(sizeof(T));
133 CopyData(xc, buf, getArg(), sizeof(T));
138 char *buf = data->alloc(2048);
139 CopyString(xc, buf, getArg(), 2048);
144 #endif // __ARGUMENTS_HH__