gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
translation.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 ARM Limited
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2002-2005 The Regents of The University of Michigan
15  * Copyright (c) 2009 The University of Edinburgh
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Authors: Gabe Black
42  * Timothy M. Jones
43  */
44 
45 #ifndef __CPU_TRANSLATION_HH__
46 #define __CPU_TRANSLATION_HH__
47 
48 #include "arch/generic/tlb.hh"
49 #include "sim/faults.hh"
50 
62 {
63  protected:
66 
67  public:
68  bool delay;
69  bool isSplit;
73  uint8_t *data;
74  uint64_t *res;
76 
81  WholeTranslationState(RequestPtr _req, uint8_t *_data, uint64_t *_res,
82  BaseTLB::Mode _mode)
83  : outstanding(1), delay(false), isSplit(false), mainReq(_req),
84  sreqLow(NULL), sreqHigh(NULL), data(_data), res(_res), mode(_mode)
85  {
86  faults[0] = faults[1] = NoFault;
87  assert(mode == BaseTLB::Read || mode == BaseTLB::Write);
88  }
89 
96  RequestPtr _sreqHigh, uint8_t *_data, uint64_t *_res,
97  BaseTLB::Mode _mode)
98  : outstanding(2), delay(false), isSplit(true), mainReq(_req),
99  sreqLow(_sreqLow), sreqHigh(_sreqHigh), data(_data), res(_res),
100  mode(_mode)
101  {
102  faults[0] = faults[1] = NoFault;
103  assert(mode == BaseTLB::Read || mode == BaseTLB::Write);
104  }
105 
113  bool
114  finish(const Fault &fault, int index)
115  {
116  assert(outstanding);
117  faults[index] = fault;
118  outstanding--;
119  if (isSplit && outstanding == 0) {
120 
121  // For ease later, we copy some state to the main request.
122  if (faults[0] == NoFault) {
124  }
127  }
128  return outstanding == 0;
129  }
130 
135  Fault
136  getFault() const
137  {
138  if (!isSplit)
139  return faults[0];
140  else if (faults[0] != NoFault)
141  return faults[0];
142  else if (faults[1] != NoFault)
143  return faults[1];
144  else
145  return NoFault;
146  }
147 
149  void
151  {
152  faults[0] = faults[1] = NoFault;
153  }
154 
160  bool
162  {
163  return mainReq->isStrictlyOrdered();
164  }
165 
171  bool
172  isPrefetch() const
173  {
174  return mainReq->isPrefetch();
175  }
176 
178  Addr
179  getPaddr() const
180  {
181  return mainReq->getPaddr();
182  }
183 
189  unsigned
191  {
192  return mainReq->getFlags();
193  }
194 
196  void
198  {
199  delete mainReq;
200  if (isSplit) {
201  delete sreqLow;
202  delete sreqHigh;
203  }
204  }
205 };
206 
207 
217 template <class ExecContextPtr>
219 {
220  protected:
221  ExecContextPtr xc;
223  int index;
224 
225  public:
226  DataTranslation(ExecContextPtr _xc, WholeTranslationState* _state)
227  : xc(_xc), state(_state), index(0)
228  {
229  }
230 
231  DataTranslation(ExecContextPtr _xc, WholeTranslationState* _state,
232  int _index)
233  : xc(_xc), state(_state), index(_index)
234  {
235  }
236 
241  void
243  {
244  state->delay = true;
245  }
246 
251  void
252  finish(const Fault &fault, RequestPtr req, ThreadContext *tc,
254  {
255  assert(state);
256  assert(mode == state->mode);
257  if (state->finish(fault, index)) {
258  if (state->getFault() == NoFault) {
259  // Don't access the request if faulted (due to squash)
260  req->setTranslateLatency();
261  }
262  xc->finishTranslation(state);
263  }
264  delete this;
265  }
266 
267  bool
268  squashed() const
269  {
270  return xc->isSquashed();
271  }
272 };
273 
274 #endif // __CPU_TRANSLATION_HH__
DataTranslation(ExecContextPtr _xc, WholeTranslationState *_state, int _index)
Definition: translation.hh:231
This class represents part of a data address translation.
Definition: translation.hh:218
unsigned getFlags()
Get the flags associated with this request.
Definition: translation.hh:190
Bitfield< 30, 0 > index
decltype(nullptr) constexpr NoFault
Definition: types.hh:189
bool isStrictlyOrdered() const
Definition: request.hh:768
void deleteReqs()
Delete all requests that make up this translation.
Definition: translation.hh:197
void markDelayed()
Signal the translation state that the translation has been delayed due to a hw page table walk...
Definition: translation.hh:242
This class captures the state of an address translation.
Definition: translation.hh:61
Bitfield< 4, 0 > mode
Definition: miscregs.hh:1385
bool isPrefetch() const
Definition: request.hh:770
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void finish(const Fault &fault, RequestPtr req, ThreadContext *tc, BaseTLB::Mode mode)
Finish this part of the translation and indicate that the whole translation is complete if the state ...
Definition: translation.hh:252
bool squashed() const
This function is used by the page table walker to determine if it should translate the a pending requ...
Definition: translation.hh:268
Fault getFault() const
Determine whether this translation produced a fault.
Definition: translation.hh:136
bool isPrefetch() const
Check if this request is a prefetch.
Definition: translation.hh:172
WholeTranslationState(RequestPtr _req, RequestPtr _sreqLow, RequestPtr _sreqHigh, uint8_t *_data, uint64_t *_res, BaseTLB::Mode _mode)
Split translation state.
Definition: translation.hh:95
bool finish(const Fault &fault, int index)
Finish part of a translation.
Definition: translation.hh:114
DataTranslation(ExecContextPtr _xc, WholeTranslationState *_state)
Definition: translation.hh:226
Addr getPaddr() const
Definition: request.hh:519
BaseTLB::Mode mode
Definition: translation.hh:75
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
WholeTranslationState(RequestPtr _req, uint8_t *_data, uint64_t *_res, BaseTLB::Mode _mode)
Single translation state.
Definition: translation.hh:81
Flags getFlags()
Accessor for flags.
Definition: request.hh:584
Mode
Definition: tlb.hh:61
void setNoFault()
Remove all faults from the translation.
Definition: translation.hh:150
WholeTranslationState * state
Definition: translation.hh:222
bool isStrictlyOrdered() const
Check if this request is strictly ordered device access.
Definition: translation.hh:161
void setPaddr(Addr paddr)
Set just the physical address.
Definition: request.hh:487
void setFlags(Flags flags)
Note that unlike other accessors, this function sets specific flags (ORs them in); it does not assign...
Definition: request.hh:595
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
ExecContextPtr xc
Definition: translation.hh:221
void setTranslateLatency()
Set/Get the time taken for this request to be successfully translated.
Definition: request.hh:731
Addr getPaddr() const
Get the physical address of this request.
Definition: translation.hh:179

Generated on Fri Jun 9 2017 13:03:45 for gem5 by doxygen 1.8.6