gem5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
sim
arguments.hh
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2003-2005 The Regents of The University of Michigan
3
* All rights reserved.
4
*
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.
15
*
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.
27
*
28
* Authors: Nathan Binkert
29
*/
30
31
#ifndef __SIM_ARGUMENTS_HH__
32
#define __SIM_ARGUMENTS_HH__
33
34
#include <cassert>
35
#include <memory>
36
37
#include "
mem/fs_translating_port_proxy.hh
"
38
39
class
ThreadContext
;
40
41
class
Arguments
42
{
43
protected
:
44
ThreadContext
*
tc
;
45
int
number
;
46
uint64_t
getArg
(uint16_t
size
= (uint16_t)(-1),
bool
fp
=
false
);
47
48
protected
:
49
class
Data
50
{
51
public
:
52
Data
(){}
53
~Data
();
54
55
private
:
56
std::list<char *>
data
;
57
58
public
:
59
char
*
alloc
(
size_t
size
);
60
};
61
62
std::shared_ptr<Data>
data
;
63
64
public
:
65
Arguments
(
ThreadContext
*ctx,
int
n
= 0)
66
:
tc
(ctx),
number
(
n
),
data
(new
Data
())
67
{ assert(
number
>= 0); }
68
Arguments
(
const
Arguments
&args)
69
:
tc
(args.
tc
),
number
(args.
number
),
data
(args.
data
) {}
70
~Arguments
() {}
71
72
ThreadContext
*
getThreadContext
()
const
{
return
tc
; }
73
74
const
Arguments
&
operator=
(
const
Arguments
&args) {
75
if
(
this
!= &args) {
76
tc
= args.
tc
;
77
number
= args.
number
;
78
data
= args.
data
;
79
}
80
return
*
this
;
81
}
82
83
// for checking if an argument is NULL
84
bool
operator!
() {
85
return
getArg
() == 0;
86
}
87
88
Arguments
&
operator++
() {
89
++
number
;
90
assert(
number
>= 0);
91
return
*
this
;
92
}
93
94
Arguments
operator++
(
int
) {
95
Arguments
args = *
this
;
96
++
number
;
97
assert(
number
>= 0);
98
return
args;
99
}
100
101
Arguments
&
operator--
() {
102
--
number
;
103
assert(
number
>= 0);
104
return
*
this
;
105
}
106
107
Arguments
operator--
(
int
) {
108
Arguments
args = *
this
;
109
--
number
;
110
assert(
number
>= 0);
111
return
args;
112
}
113
114
const
Arguments
&
operator+=
(
int
index
) {
115
number
+=
index
;
116
assert(
number
>= 0);
117
return
*
this
;
118
}
119
120
const
Arguments
&
operator-=
(
int
index
) {
121
number
-=
index
;
122
assert(
number
>= 0);
123
return
*
this
;
124
}
125
126
Arguments
operator[]
(
int
index
) {
127
return
Arguments
(
tc
, index);
128
}
129
130
template
<
class
T>
131
operator
T() {
132
assert(
sizeof
(T) <=
sizeof
(uint64_t));
133
T
d
=
static_cast<
T
>
(
getArg
(
sizeof
(T)));
134
return
d
;
135
}
136
137
template
<
class
T>
138
operator
T *() {
139
T *buf = (T *)
data
->alloc(
sizeof
(T));
140
CopyOut
(
tc
, buf,
getArg
(
sizeof
(T)),
sizeof
(T));
141
return
buf;
142
}
143
144
operator
char
*() {
145
char
*buf =
data
->alloc(2048);
146
CopyStringOut
(
tc
, buf,
getArg
(), 2048);
147
return
buf;
148
}
149
};
150
151
#endif // __SIM_ARGUMENTS_HH__
Arguments::Data::Data
Data()
Definition:
arguments.hh:52
MipsISA::index
Bitfield< 30, 0 > index
Definition:
pra_constants.hh:46
Arguments
Definition:
arguments.hh:41
Arguments::operator[]
Arguments operator[](int index)
Definition:
arguments.hh:126
Arguments::Data::~Data
~Data()
Definition:
arguments.cc:36
MipsISA::fp
Bitfield< 0 > fp
Definition:
pra_constants.hh:246
Arguments::number
int number
Definition:
arguments.hh:45
Arguments::~Arguments
~Arguments()
Definition:
arguments.hh:70
CopyOut
void CopyOut(ThreadContext *tc, void *dest, Addr src, size_t cplen)
Definition:
fs_translating_port_proxy.cc:126
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Definition:
thread_context.hh:93
ArmISA::n
Bitfield< 31 > n
Definition:
miscregs.hh:1636
Arguments::operator++
Arguments operator++(int)
Definition:
arguments.hh:94
Arguments::Arguments
Arguments(const Arguments &args)
Definition:
arguments.hh:68
Arguments::getThreadContext
ThreadContext * getThreadContext() const
Definition:
arguments.hh:72
Arguments::Data::alloc
char * alloc(size_t size)
Definition:
arguments.cc:45
Arguments::Arguments
Arguments(ThreadContext *ctx, int n=0)
Definition:
arguments.hh:65
CopyStringOut
void CopyStringOut(ThreadContext *tc, char *dst, Addr vaddr, size_t maxlen)
Definition:
fs_translating_port_proxy.cc:140
ArmISA::d
Bitfield< 9 > d
Definition:
miscregs.hh:1375
Arguments::operator--
Arguments operator--(int)
Definition:
arguments.hh:107
Arguments::data
std::shared_ptr< Data > data
Definition:
arguments.hh:62
std::list< char * >
Arguments::operator-=
const Arguments & operator-=(int index)
Definition:
arguments.hh:120
X86ISA::size
int size()
Definition:
pagetable.hh:146
Arguments::operator--
Arguments & operator--()
Definition:
arguments.hh:101
Arguments::Data::data
std::list< char * > data
Definition:
arguments.hh:56
Arguments::Data
Definition:
arguments.hh:49
fs_translating_port_proxy.hh
TranslatingPortProxy Object Declaration for FS.
Arguments::operator=
const Arguments & operator=(const Arguments &args)
Definition:
arguments.hh:74
Arguments::operator!
bool operator!()
Definition:
arguments.hh:84
Arguments::operator+=
const Arguments & operator+=(int index)
Definition:
arguments.hh:114
Arguments::tc
ThreadContext * tc
Definition:
arguments.hh:44
Arguments::getArg
uint64_t getArg(uint16_t size=(uint16_t)(-1), bool fp=false)
Definition:
arguments.cc:53
Arguments::operator++
Arguments & operator++()
Definition:
arguments.hh:88
Generated on Fri Jun 9 2017 13:03:51 for gem5 by
doxygen
1.8.6