gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ev5.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-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: Steve Reinhardt
29  * Nathan Binkert
30  */
31 
32 #include "arch/alpha/faults.hh"
33 #include "arch/alpha/isa_traits.hh"
35 #include "arch/alpha/osfpal.hh"
36 #include "arch/alpha/tlb.hh"
37 #include "base/cp_annotate.hh"
38 #include "base/debug.hh"
39 #include "cpu/base.hh"
40 #include "cpu/simple_thread.hh"
41 #include "cpu/thread_context.hh"
42 #include "sim/sim_exit.hh"
43 
44 namespace AlphaISA {
45 
47 //
48 // Machine dependent functions
49 //
50 void
51 initCPU(ThreadContext *tc, int cpuId)
52 {
53  initIPRs(tc, cpuId);
54 
55  tc->setIntReg(16, cpuId);
56  tc->setIntReg(0, cpuId);
57 
59 
60  tc->pcState(tc->readMiscRegNoEffect(IPR_PAL_BASE) + reset->vect());
61 
62  delete reset;
63 }
64 
65 template <class CPU>
66 void
67 zeroRegisters(CPU *cpu)
68 {
69  // Insure ISA semantics
70  // (no longer very clean due to the change in setIntReg() in the
71  // cpu model. Consider changing later.)
72  cpu->thread->setIntReg(ZeroReg, 0);
73  cpu->thread->setFloatReg(ZeroReg, 0.0);
74 }
75 
77 //
78 //
79 //
80 void
81 initIPRs(ThreadContext *tc, int cpuId)
82 {
83  for (int i = 0; i < NumInternalProcRegs; ++i) {
84  tc->setMiscRegNoEffect(i, 0);
85  }
86 
88  tc->setMiscRegNoEffect(IPR_MCSR, 0x6);
90 }
91 
92 MiscReg
94 {
95  uint64_t retval = 0; // return value, default 0
96 
97  switch (idx) {
98  case IPR_PALtemp0:
99  case IPR_PALtemp1:
100  case IPR_PALtemp2:
101  case IPR_PALtemp3:
102  case IPR_PALtemp4:
103  case IPR_PALtemp5:
104  case IPR_PALtemp6:
105  case IPR_PALtemp7:
106  case IPR_PALtemp8:
107  case IPR_PALtemp9:
108  case IPR_PALtemp10:
109  case IPR_PALtemp11:
110  case IPR_PALtemp12:
111  case IPR_PALtemp13:
112  case IPR_PALtemp14:
113  case IPR_PALtemp15:
114  case IPR_PALtemp16:
115  case IPR_PALtemp17:
116  case IPR_PALtemp18:
117  case IPR_PALtemp19:
118  case IPR_PALtemp20:
119  case IPR_PALtemp21:
120  case IPR_PALtemp22:
121  case IPR_PALtemp23:
122  case IPR_PAL_BASE:
123 
124  case IPR_IVPTBR:
125  case IPR_DC_MODE:
126  case IPR_MAF_MODE:
127  case IPR_ISR:
128  case IPR_EXC_ADDR:
129  case IPR_IC_PERR_STAT:
130  case IPR_DC_PERR_STAT:
131  case IPR_MCSR:
132  case IPR_ASTRR:
133  case IPR_ASTER:
134  case IPR_SIRR:
135  case IPR_ICSR:
136  case IPR_ICM:
137  case IPR_DTB_CM:
138  case IPR_IPLR:
139  case IPR_INTID:
140  case IPR_PMCTR:
141  // no side-effect
142  retval = ipr[idx];
143  break;
144 
145  case IPR_CC:
146  retval |= ipr[idx] & ULL(0xffffffff00000000);
147  retval |= tc->getCpuPtr()->curCycle() & ULL(0x00000000ffffffff);
148  break;
149 
150  case IPR_VA:
151  retval = ipr[idx];
152  break;
153 
154  case IPR_VA_FORM:
155  case IPR_MM_STAT:
156  case IPR_IFAULT_VA_FORM:
157  case IPR_EXC_MASK:
158  case IPR_EXC_SUM:
159  retval = ipr[idx];
160  break;
161 
162  case IPR_DTB_PTE:
163  {
164  TlbEntry &entry = tc->getDTBPtr()->index(1);
165 
166  retval |= ((uint64_t)entry.ppn & ULL(0x7ffffff)) << 32;
167  retval |= ((uint64_t)entry.xre & ULL(0xf)) << 8;
168  retval |= ((uint64_t)entry.xwe & ULL(0xf)) << 12;
169  retval |= ((uint64_t)entry.fonr & ULL(0x1)) << 1;
170  retval |= ((uint64_t)entry.fonw & ULL(0x1))<< 2;
171  retval |= ((uint64_t)entry.asma & ULL(0x1)) << 4;
172  retval |= ((uint64_t)entry.asn & ULL(0x7f)) << 57;
173  }
174  break;
175 
176  // write only registers
177  case IPR_HWINT_CLR:
178  case IPR_SL_XMIT:
179  case IPR_DC_FLUSH:
180  case IPR_IC_FLUSH:
181  case IPR_ALT_MODE:
182  case IPR_DTB_IA:
183  case IPR_DTB_IAP:
184  case IPR_ITB_IA:
185  case IPR_ITB_IAP:
186  panic("Tried to read write only register %d\n", idx);
187  break;
188 
189  default:
190  // invalid IPR
191  panic("Tried to read from invalid ipr %d\n", idx);
192  break;
193  }
194 
195  return retval;
196 }
197 
198 // Cause the simulator to break when changing to the following IPL
199 int break_ipl = -1;
200 
201 void
202 ISA::setIpr(int idx, uint64_t val, ThreadContext *tc)
203 {
204  switch (idx) {
205  case IPR_PALtemp0:
206  case IPR_PALtemp1:
207  case IPR_PALtemp2:
208  case IPR_PALtemp3:
209  case IPR_PALtemp4:
210  case IPR_PALtemp5:
211  case IPR_PALtemp6:
212  case IPR_PALtemp7:
213  case IPR_PALtemp8:
214  case IPR_PALtemp9:
215  case IPR_PALtemp10:
216  case IPR_PALtemp11:
217  case IPR_PALtemp12:
218  case IPR_PALtemp13:
219  case IPR_PALtemp14:
220  case IPR_PALtemp15:
221  case IPR_PALtemp16:
222  case IPR_PALtemp17:
223  case IPR_PALtemp18:
224  case IPR_PALtemp19:
225  case IPR_PALtemp20:
226  case IPR_PALtemp21:
227  case IPR_PALtemp22:
228  case IPR_PAL_BASE:
229  case IPR_IC_PERR_STAT:
230  case IPR_DC_PERR_STAT:
231  case IPR_PMCTR:
232  // write entire quad w/ no side-effect
233  ipr[idx] = val;
234  break;
235 
236  case IPR_CC_CTL:
237  // This IPR resets the cycle counter. We assume this only
238  // happens once... let's verify that.
239  assert(ipr[idx] == 0);
240  ipr[idx] = 1;
241  break;
242 
243  case IPR_CC:
244  // This IPR only writes the upper 64 bits. It's ok to write
245  // all 64 here since we mask out the lower 32 in rpcc (see
246  // isa_desc).
247  ipr[idx] = val;
248  break;
249 
250  case IPR_PALtemp23:
251  // write entire quad w/ no side-effect
252  if (tc->getKernelStats())
253  tc->getKernelStats()->context(ipr[idx], val, tc);
254  ipr[idx] = val;
255  break;
256 
257  case IPR_DTB_PTE:
258  // write entire quad w/ no side-effect, tag is forthcoming
259  ipr[idx] = val;
260  break;
261 
262  case IPR_EXC_ADDR:
263  // second least significant bit in PC is always zero
264  ipr[idx] = val & ~2;
265  break;
266 
267  case IPR_ASTRR:
268  case IPR_ASTER:
269  // only write least significant four bits - privilege mask
270  ipr[idx] = val & 0xf;
271  break;
272 
273  case IPR_IPLR:
274  // only write least significant five bits - interrupt level
275  ipr[idx] = val & 0x1f;
276  if (tc->getKernelStats())
277  tc->getKernelStats()->swpipl(ipr[idx]);
278  break;
279 
280  case IPR_DTB_CM:
281  if (val & 0x18) {
282  if (tc->getKernelStats())
283  tc->getKernelStats()->mode(Kernel::user, tc);
284  } else {
285  if (tc->getKernelStats())
286  tc->getKernelStats()->mode(Kernel::kernel, tc);
287  }
288 
289  case IPR_ICM:
290  // only write two mode bits - processor mode
291  ipr[idx] = val & 0x18;
292  break;
293 
294  case IPR_ALT_MODE:
295  // only write two mode bits - processor mode
296  ipr[idx] = val & 0x18;
297  break;
298 
299  case IPR_MCSR:
300  // more here after optimization...
301  ipr[idx] = val;
302  break;
303 
304  case IPR_SIRR:
305  // only write software interrupt mask
306  ipr[idx] = val & 0x7fff0;
307  break;
308 
309  case IPR_ICSR:
310  ipr[idx] = val & ULL(0xffffff0300);
311  break;
312 
313  case IPR_IVPTBR:
314  case IPR_MVPTBR:
315  ipr[idx] = val & ULL(0xffffffffc0000000);
316  break;
317 
318  case IPR_DC_TEST_CTL:
319  ipr[idx] = val & 0x1ffb;
320  break;
321 
322  case IPR_DC_MODE:
323  case IPR_MAF_MODE:
324  ipr[idx] = val & 0x3f;
325  break;
326 
327  case IPR_ITB_ASN:
328  ipr[idx] = val & 0x7f0;
329  break;
330 
331  case IPR_DTB_ASN:
332  ipr[idx] = val & ULL(0xfe00000000000000);
333  break;
334 
335  case IPR_EXC_SUM:
336  case IPR_EXC_MASK:
337  // any write to this register clears it
338  ipr[idx] = 0;
339  break;
340 
341  case IPR_INTID:
342  case IPR_SL_RCV:
343  case IPR_MM_STAT:
344  case IPR_ITB_PTE_TEMP:
345  case IPR_DTB_PTE_TEMP:
346  // read-only registers
347  panic("Tried to write read only ipr %d\n", idx);
348 
349  case IPR_HWINT_CLR:
350  case IPR_SL_XMIT:
351  case IPR_DC_FLUSH:
352  case IPR_IC_FLUSH:
353  // the following are write only
354  ipr[idx] = val;
355  break;
356 
357  case IPR_DTB_IA:
358  // really a control write
359  ipr[idx] = 0;
360 
361  tc->getDTBPtr()->flushAll();
362  break;
363 
364  case IPR_DTB_IAP:
365  // really a control write
366  ipr[idx] = 0;
367 
368  tc->getDTBPtr()->flushProcesses();
369  break;
370 
371  case IPR_DTB_IS:
372  // really a control write
373  ipr[idx] = val;
374 
375  tc->getDTBPtr()->flushAddr(val, DTB_ASN_ASN(ipr[IPR_DTB_ASN]));
376  break;
377 
378  case IPR_DTB_TAG: {
379  struct TlbEntry entry;
380 
381  // FIXME: granularity hints NYI...
382  if (DTB_PTE_GH(ipr[IPR_DTB_PTE]) != 0)
383  panic("PTE GH field != 0");
384 
385  // write entire quad
386  ipr[idx] = val;
387 
388  // construct PTE for new entry
389  entry.ppn = DTB_PTE_PPN(ipr[IPR_DTB_PTE]);
390  entry.xre = DTB_PTE_XRE(ipr[IPR_DTB_PTE]);
391  entry.xwe = DTB_PTE_XWE(ipr[IPR_DTB_PTE]);
392  entry.fonr = DTB_PTE_FONR(ipr[IPR_DTB_PTE]);
393  entry.fonw = DTB_PTE_FONW(ipr[IPR_DTB_PTE]);
394  entry.asma = DTB_PTE_ASMA(ipr[IPR_DTB_PTE]);
395  entry.asn = DTB_ASN_ASN(ipr[IPR_DTB_ASN]);
396 
397  // insert new TAG/PTE value into data TLB
398  tc->getDTBPtr()->insert(val, entry);
399  }
400  break;
401 
402  case IPR_ITB_PTE: {
403  struct TlbEntry entry;
404 
405  // FIXME: granularity hints NYI...
406  if (ITB_PTE_GH(val) != 0)
407  panic("PTE GH field != 0");
408 
409  // write entire quad
410  ipr[idx] = val;
411 
412  // construct PTE for new entry
413  entry.ppn = ITB_PTE_PPN(val);
414  entry.xre = ITB_PTE_XRE(val);
415  entry.xwe = 0;
416  entry.fonr = ITB_PTE_FONR(val);
417  entry.fonw = ITB_PTE_FONW(val);
418  entry.asma = ITB_PTE_ASMA(val);
419  entry.asn = ITB_ASN_ASN(ipr[IPR_ITB_ASN]);
420 
421  // insert new TAG/PTE value into data TLB
422  tc->getITBPtr()->insert(ipr[IPR_ITB_TAG], entry);
423  }
424  break;
425 
426  case IPR_ITB_IA:
427  // really a control write
428  ipr[idx] = 0;
429 
430  tc->getITBPtr()->flushAll();
431  break;
432 
433  case IPR_ITB_IAP:
434  // really a control write
435  ipr[idx] = 0;
436 
437  tc->getITBPtr()->flushProcesses();
438  break;
439 
440  case IPR_ITB_IS:
441  // really a control write
442  ipr[idx] = val;
443 
444  tc->getITBPtr()->flushAddr(val, ITB_ASN_ASN(ipr[IPR_ITB_ASN]));
445  break;
446 
447  default:
448  // invalid IPR
449  panic("Tried to write to invalid ipr %d\n", idx);
450  }
451 
452  // no error...
453 }
454 
455 void
457 {
458  for (int i = 0; i < NumInternalProcRegs; ++i)
460 }
461 
462 } // namespace AlphaISA
463 
464 using namespace AlphaISA;
465 
466 Fault
468 {
469  PCState pc = pcState();
470  if (!(pc.pc() & 0x3))
471  return std::make_shared<UnimplementedOpcodeFault>();
472 
473  pc.npc(readMiscRegNoEffect(IPR_EXC_ADDR));
474  pcState(pc);
475 
476  CPA::cpa()->swAutoBegin(tc, pc.npc());
477 
478  if (kernelStats)
479  kernelStats->hwrei();
480 
481  // FIXME: XXX check for interrupts? XXX
482  return NoFault;
483 }
484 
489 bool
491 {
492  if (kernelStats)
493  kernelStats->callpal(palFunc, tc);
494 
495  switch (palFunc) {
496  case PAL::halt:
497  halt();
498  if (--System::numSystemsRunning == 0)
499  exitSimLoop("all cpus halted");
500  break;
501 
502  case PAL::bpt:
503  case PAL::bugchk:
504  if (system->breakpoint())
505  return false;
506  break;
507  }
508 
509  return true;
510 }
int DTB_ASN_ASN(uint64_t reg)
Definition: ev5.hh:70
cbk_rst func reset
Definition: gpu_nomali.cc:101
decltype(nullptr) constexpr NoFault
Definition: types.hh:189
void copyIprs(ThreadContext *src, ThreadContext *dest)
Definition: ev5.cc:456
int DTB_PTE_FONR(uint64_t reg)
Definition: ev5.hh:75
int ITB_PTE_GH(uint64_t reg)
Definition: ev5.hh:86
Bitfield< 7 > i
Definition: miscregs.hh:1378
int DTB_PTE_XRE(uint64_t reg)
Definition: ev5.hh:73
#define panic(...)
Definition: misc.hh:153
int ITB_PTE_XRE(uint64_t reg)
Definition: ev5.hh:83
InternalProcReg readIpr(int idx, ThreadContext *tc)
Definition: ev5.cc:93
bool ITB_PTE_ASMA(uint64_t reg)
Definition: ev5.hh:87
virtual FaultVect vect()=0
virtual MiscReg readMiscRegNoEffect(int misc_reg) const =0
InternalProcReg ipr[NumInternalProcRegs]
Definition: isa.hh:68
bool simPalCheck(int palFunc)
Check for special simulator handling of specific PAL calls.
Definition: ev5.cc:490
uint64_t MiscReg
Definition: registers.hh:54
Addr ITB_PTE_PPN(uint64_t reg)
Definition: ev5.hh:81
bool ITB_PTE_FONR(uint64_t reg)
Definition: ev5.hh:84
int DTB_PTE_ASMA(uint64_t reg)
Definition: ev5.hh:78
virtual void setIntReg(int reg_idx, uint64_t val)=0
bool ITB_PTE_FONW(uint64_t reg)
Definition: ev5.hh:85
virtual BaseCPU * getCpuPtr()=0
virtual TheISA::PCState pcState()=0
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Addr DTB_PTE_PPN(uint64_t reg)
Definition: ev5.hh:71
Bitfield< 63 > val
Definition: misc.hh:770
Addr pc() const
Definition: types.hh:138
void swAutoBegin(ThreadContext *tc, Addr next_pc)
Definition: cp_annotate.hh:90
system
Definition: isa.cc:226
static CPA * cpa()
Definition: cp_annotate.hh:84
void setIpr(int idx, InternalProcReg val, ThreadContext *tc)
Definition: ev5.cc:202
void initCPU(ThreadContext *tc, int cpuId)
Definition: ev5.cc:51
virtual TheISA::TLB * getDTBPtr()=0
const RegIndex ZeroReg
Definition: registers.hh:77
int DTB_PTE_FONW(uint64_t reg)
Definition: ev5.hh:76
void zeroRegisters(CPU *cpu)
Definition: ev5.cc:67
const Addr PalBase
Definition: ev5.hh:108
Fault hwrei()
Definition: ev5.cc:467
#define ULL(N)
uint64_t constant
Definition: types.hh:50
void initIPRs(ThreadContext *tc, int cpuId)
Definition: ev5.cc:81
int ITB_ASN_ASN(uint64_t reg)
Definition: ev5.hh:80
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
Definition: sim_events.cc:83
int break_ipl
Definition: ev5.cc:199
Addr npc() const
Definition: types.hh:141
static int numSystemsRunning
Definition: system.hh:551
int DTB_PTE_GH(uint64_t reg)
Definition: ev5.hh:77
IntReg pc
Definition: remote_gdb.hh:91
int DTB_PTE_XWE(uint64_t reg)
Definition: ev5.hh:74
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val)=0
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
virtual TheISA::TLB * getITBPtr()=0
Bitfield< 26 > halt
Definition: dt_constants.hh:46
virtual TheISA::Kernel::Statistics * getKernelStats()=0

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