gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
isa.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 RISC-V Foundation
3  * Copyright (c) 2016 The University of Virginia
4  * Copyright (c) 2020 Barkhausen Institut
5  * Copyright (c) 2022 Google LLC
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met: redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer;
12  * redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution;
15  * neither the name of the copyright holders nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include "arch/riscv/isa.hh"
33 
34 #include <ctime>
35 #include <set>
36 #include <sstream>
37 
38 #include "arch/riscv/faults.hh"
39 #include "arch/riscv/interrupts.hh"
40 #include "arch/riscv/mmu.hh"
41 #include "arch/riscv/pagetable.hh"
42 #include "arch/riscv/pmp.hh"
43 #include "arch/riscv/regs/float.hh"
44 #include "arch/riscv/regs/int.hh"
45 #include "arch/riscv/regs/misc.hh"
46 #include "base/bitfield.hh"
47 #include "base/compiler.hh"
48 #include "base/logging.hh"
49 #include "base/trace.hh"
50 #include "cpu/base.hh"
51 #include "debug/Checkpoint.hh"
52 #include "debug/LLSC.hh"
53 #include "debug/MatRegs.hh"
54 #include "debug/RiscvMisc.hh"
55 #include "mem/packet.hh"
56 #include "mem/request.hh"
57 #include "params/RiscvISA.hh"
58 #include "sim/pseudo_inst.hh"
59 
60 namespace gem5
61 {
62 
63 namespace RiscvISA
64 {
65 
66 [[maybe_unused]] const std::array<const char *, NUM_MISCREGS> MiscRegNames = {{
67  [MISCREG_PRV] = "PRV",
68  [MISCREG_ISA] = "ISA",
69  [MISCREG_VENDORID] = "VENDORID",
70  [MISCREG_ARCHID] = "ARCHID",
71  [MISCREG_IMPID] = "IMPID",
72  [MISCREG_HARTID] = "HARTID",
73  [MISCREG_STATUS] = "STATUS",
74  [MISCREG_IP] = "IP",
75  [MISCREG_IE] = "IE",
76  [MISCREG_CYCLE] = "CYCLE",
77  [MISCREG_TIME] = "TIME",
78  [MISCREG_INSTRET] = "INSTRET",
79  [MISCREG_HPMCOUNTER03] = "HPMCOUNTER03",
80  [MISCREG_HPMCOUNTER04] = "HPMCOUNTER04",
81  [MISCREG_HPMCOUNTER05] = "HPMCOUNTER05",
82  [MISCREG_HPMCOUNTER06] = "HPMCOUNTER06",
83  [MISCREG_HPMCOUNTER07] = "HPMCOUNTER07",
84  [MISCREG_HPMCOUNTER08] = "HPMCOUNTER08",
85  [MISCREG_HPMCOUNTER09] = "HPMCOUNTER09",
86  [MISCREG_HPMCOUNTER10] = "HPMCOUNTER10",
87  [MISCREG_HPMCOUNTER11] = "HPMCOUNTER11",
88  [MISCREG_HPMCOUNTER12] = "HPMCOUNTER12",
89  [MISCREG_HPMCOUNTER13] = "HPMCOUNTER13",
90  [MISCREG_HPMCOUNTER14] = "HPMCOUNTER14",
91  [MISCREG_HPMCOUNTER15] = "HPMCOUNTER15",
92  [MISCREG_HPMCOUNTER16] = "HPMCOUNTER16",
93  [MISCREG_HPMCOUNTER17] = "HPMCOUNTER17",
94  [MISCREG_HPMCOUNTER18] = "HPMCOUNTER18",
95  [MISCREG_HPMCOUNTER19] = "HPMCOUNTER19",
96  [MISCREG_HPMCOUNTER20] = "HPMCOUNTER20",
97  [MISCREG_HPMCOUNTER21] = "HPMCOUNTER21",
98  [MISCREG_HPMCOUNTER22] = "HPMCOUNTER22",
99  [MISCREG_HPMCOUNTER23] = "HPMCOUNTER23",
100  [MISCREG_HPMCOUNTER24] = "HPMCOUNTER24",
101  [MISCREG_HPMCOUNTER25] = "HPMCOUNTER25",
102  [MISCREG_HPMCOUNTER26] = "HPMCOUNTER26",
103  [MISCREG_HPMCOUNTER27] = "HPMCOUNTER27",
104  [MISCREG_HPMCOUNTER28] = "HPMCOUNTER28",
105  [MISCREG_HPMCOUNTER29] = "HPMCOUNTER29",
106  [MISCREG_HPMCOUNTER30] = "HPMCOUNTER30",
107  [MISCREG_HPMCOUNTER31] = "HPMCOUNTER31",
108  [MISCREG_HPMEVENT03] = "HPMEVENT03",
109  [MISCREG_HPMEVENT04] = "HPMEVENT04",
110  [MISCREG_HPMEVENT05] = "HPMEVENT05",
111  [MISCREG_HPMEVENT06] = "HPMEVENT06",
112  [MISCREG_HPMEVENT07] = "HPMEVENT07",
113  [MISCREG_HPMEVENT08] = "HPMEVENT08",
114  [MISCREG_HPMEVENT09] = "HPMEVENT09",
115  [MISCREG_HPMEVENT10] = "HPMEVENT10",
116  [MISCREG_HPMEVENT11] = "HPMEVENT11",
117  [MISCREG_HPMEVENT12] = "HPMEVENT12",
118  [MISCREG_HPMEVENT13] = "HPMEVENT13",
119  [MISCREG_HPMEVENT14] = "HPMEVENT14",
120  [MISCREG_HPMEVENT15] = "HPMEVENT15",
121  [MISCREG_HPMEVENT16] = "HPMEVENT16",
122  [MISCREG_HPMEVENT17] = "HPMEVENT17",
123  [MISCREG_HPMEVENT18] = "HPMEVENT18",
124  [MISCREG_HPMEVENT19] = "HPMEVENT19",
125  [MISCREG_HPMEVENT20] = "HPMEVENT20",
126  [MISCREG_HPMEVENT21] = "HPMEVENT21",
127  [MISCREG_HPMEVENT22] = "HPMEVENT22",
128  [MISCREG_HPMEVENT23] = "HPMEVENT23",
129  [MISCREG_HPMEVENT24] = "HPMEVENT24",
130  [MISCREG_HPMEVENT25] = "HPMEVENT25",
131  [MISCREG_HPMEVENT26] = "HPMEVENT26",
132  [MISCREG_HPMEVENT27] = "HPMEVENT27",
133  [MISCREG_HPMEVENT28] = "HPMEVENT28",
134  [MISCREG_HPMEVENT29] = "HPMEVENT29",
135  [MISCREG_HPMEVENT30] = "HPMEVENT30",
136  [MISCREG_HPMEVENT31] = "HPMEVENT31",
137  [MISCREG_TSELECT] = "TSELECT",
138  [MISCREG_TDATA1] = "TDATA1",
139  [MISCREG_TDATA2] = "TDATA2",
140  [MISCREG_TDATA3] = "TDATA3",
141  [MISCREG_DCSR] = "DCSR",
142  [MISCREG_DPC] = "DPC",
143  [MISCREG_DSCRATCH] = "DSCRATCH",
144 
145  [MISCREG_MEDELEG] = "MEDELEG",
146  [MISCREG_MIDELEG] = "MIDELEG",
147  [MISCREG_MTVEC] = "MTVEC",
148  [MISCREG_MCOUNTEREN] = "MCOUNTEREN",
149  [MISCREG_MSCRATCH] = "MSCRATCH",
150  [MISCREG_MEPC] = "MEPC",
151  [MISCREG_MCAUSE] = "MCAUSE",
152  [MISCREG_MTVAL] = "MTVAL",
153  [MISCREG_PMPCFG0] = "PMPCFG0",
154  [MISCREG_PMPCFG1] = "PMPCFG1", // pmpcfg1 is rv32 only
155  [MISCREG_PMPCFG2] = "PMPCFG2",
156  [MISCREG_PMPCFG3] = "PMPCFG3", // pmpcfg3 is rv32 only
157  [MISCREG_PMPADDR00] = "PMPADDR00",
158  [MISCREG_PMPADDR01] = "PMPADDR01",
159  [MISCREG_PMPADDR02] = "PMPADDR02",
160  [MISCREG_PMPADDR03] = "PMPADDR03",
161  [MISCREG_PMPADDR04] = "PMPADDR04",
162  [MISCREG_PMPADDR05] = "PMPADDR05",
163  [MISCREG_PMPADDR06] = "PMPADDR06",
164  [MISCREG_PMPADDR07] = "PMPADDR07",
165  [MISCREG_PMPADDR08] = "PMPADDR08",
166  [MISCREG_PMPADDR09] = "PMPADDR09",
167  [MISCREG_PMPADDR10] = "PMPADDR10",
168  [MISCREG_PMPADDR11] = "PMPADDR11",
169  [MISCREG_PMPADDR12] = "PMPADDR12",
170  [MISCREG_PMPADDR13] = "PMPADDR13",
171  [MISCREG_PMPADDR14] = "PMPADDR14",
172  [MISCREG_PMPADDR15] = "PMPADDR15",
173 
174  [MISCREG_SEDELEG] = "SEDELEG",
175  [MISCREG_SIDELEG] = "SIDELEG",
176  [MISCREG_STVEC] = "STVEC",
177  [MISCREG_SCOUNTEREN] = "SCOUNTEREN",
178  [MISCREG_SSCRATCH] = "SSCRATCH",
179  [MISCREG_SEPC] = "SEPC",
180  [MISCREG_SCAUSE] = "SCAUSE",
181  [MISCREG_STVAL] = "STVAL",
182  [MISCREG_SATP] = "SATP",
183 
184  [MISCREG_UTVEC] = "UTVEC",
185  [MISCREG_USCRATCH] = "USCRATCH",
186  [MISCREG_UEPC] = "UEPC",
187  [MISCREG_UCAUSE] = "UCAUSE",
188  [MISCREG_UTVAL] = "UTVAL",
189  [MISCREG_FFLAGS] = "FFLAGS",
190  [MISCREG_FRM] = "FRM",
191 
192  [MISCREG_NMIVEC] = "NMIVEC",
193  [MISCREG_NMIE] = "NMIE",
194  [MISCREG_NMIP] = "NMIP",
195 
196  // following are rv32 only registers
197  [MISCREG_MSTATUSH] = "MSTATUSH",
198 
199  [MISCREG_CYCLEH] = "CYCLEH",
200  [MISCREG_TIMEH] = "TIMEH",
201  [MISCREG_INSTRETH] = "INSTRETH",
202  [MISCREG_HPMCOUNTER03H] = "HPMCOUNTER03H",
203  [MISCREG_HPMCOUNTER04H] = "HPMCOUNTER04H",
204  [MISCREG_HPMCOUNTER05H] = "HPMCOUNTER05H",
205  [MISCREG_HPMCOUNTER06H] = "HPMCOUNTER06H",
206  [MISCREG_HPMCOUNTER07H] = "HPMCOUNTER07H",
207  [MISCREG_HPMCOUNTER08H] = "HPMCOUNTER08H",
208  [MISCREG_HPMCOUNTER09H] = "HPMCOUNTER09H",
209  [MISCREG_HPMCOUNTER10H] = "HPMCOUNTER10H",
210  [MISCREG_HPMCOUNTER11H] = "HPMCOUNTER11H",
211  [MISCREG_HPMCOUNTER12H] = "HPMCOUNTER12H",
212  [MISCREG_HPMCOUNTER13H] = "HPMCOUNTER13H",
213  [MISCREG_HPMCOUNTER14H] = "HPMCOUNTER14H",
214  [MISCREG_HPMCOUNTER15H] = "HPMCOUNTER15H",
215  [MISCREG_HPMCOUNTER16H] = "HPMCOUNTER16H",
216  [MISCREG_HPMCOUNTER17H] = "HPMCOUNTER17H",
217  [MISCREG_HPMCOUNTER18H] = "HPMCOUNTER18H",
218  [MISCREG_HPMCOUNTER19H] = "HPMCOUNTER19H",
219  [MISCREG_HPMCOUNTER20H] = "HPMCOUNTER20H",
220  [MISCREG_HPMCOUNTER21H] = "HPMCOUNTER21H",
221  [MISCREG_HPMCOUNTER22H] = "HPMCOUNTER22H",
222  [MISCREG_HPMCOUNTER23H] = "HPMCOUNTER23H",
223  [MISCREG_HPMCOUNTER24H] = "HPMCOUNTER24H",
224  [MISCREG_HPMCOUNTER25H] = "HPMCOUNTER25H",
225  [MISCREG_HPMCOUNTER26H] = "HPMCOUNTER26H",
226  [MISCREG_HPMCOUNTER27H] = "HPMCOUNTER27H",
227  [MISCREG_HPMCOUNTER28H] = "HPMCOUNTER28H",
228  [MISCREG_HPMCOUNTER29H] = "HPMCOUNTER29H",
229  [MISCREG_HPMCOUNTER30H] = "HPMCOUNTER30H",
230  [MISCREG_HPMCOUNTER31H] = "HPMCOUNTER31H",
231 }};
232 
233 namespace
234 {
235 
236 /* Not applicable to RISCV */
237 RegClass vecRegClass(VecRegClass, VecRegClassName, 1, debug::IntRegs);
240  debug::IntRegs);
241 RegClass matRegClass(MatRegClass, MatRegClassName, 1, debug::MatRegs);
242 RegClass ccRegClass(CCRegClass, CCRegClassName, 0, debug::IntRegs);
243 
244 } // anonymous namespace
245 
246 ISA::ISA(const Params &p) :
247  BaseISA(p), rv_type(p.riscv_type), checkAlignment(p.check_alignment)
248 {
249  _regClasses.push_back(&intRegClass);
250  _regClasses.push_back(&floatRegClass);
251  _regClasses.push_back(&vecRegClass);
252  _regClasses.push_back(&vecElemClass);
253  _regClasses.push_back(&vecPredRegClass);
254  _regClasses.push_back(&matRegClass);
255  _regClasses.push_back(&ccRegClass);
256  _regClasses.push_back(&miscRegClass);
257 
258  miscRegFile.resize(NUM_MISCREGS);
259  clear();
260 }
261 
262 bool ISA::inUserMode() const
263 {
264  return miscRegFile[MISCREG_PRV] == PRV_U;
265 }
266 
267 void
269 {
270  // First loop through the integer registers.
271  for (auto &id: intRegClass)
272  tc->setReg(id, src->getReg(id));
273 
274  // Second loop through the float registers.
275  for (auto &id: floatRegClass)
276  tc->setReg(id, src->getReg(id));
277 
278  // Lastly copy PC/NPC
279  tc->pcState(src->pcState());
280 }
281 
283 {
284  std::fill(miscRegFile.begin(), miscRegFile.end(), 0);
285 
290 
291  MISA misa = 0;
292  STATUS status = 0;
293 
294  // default config arch isa string is rv64(32)imafdc
295  misa.rvi = misa.rvm = misa.rva = misa.rvf = misa.rvd = misa.rvc = 1;
296  // default privlege modes if MSU
297  misa.rvs = misa.rvu = 1;
298 
299  // mark FS is initial
300  status.fs = INITIAL;
301 
302  // rv_type dependent init.
303  switch (rv_type) {
304  case RV32:
305  misa.rv32_mxl = 1;
306  break;
307  case RV64:
308  misa.rv64_mxl = 2;
309  status.uxl = status.sxl = 2;
310  break;
311  default:
312  panic("%s: Unknown rv_type: %d", name(), (int)rv_type);
313  }
314 
315  miscRegFile[MISCREG_ISA] = misa;
319  // don't set it to zero; software may try to determine the supported
320  // triggers, starting at zero. simply set a different value here.
322  // NMI is always enabled.
324 }
325 
326 bool
327 ISA::hpmCounterEnabled(int misc_reg) const
328 {
329  int hpmcounter = 0;
330  if (misc_reg >= MISCREG_CYCLEH) {
331  hpmcounter = misc_reg - MISCREG_CYCLEH;
332  } else {
333  hpmcounter = misc_reg - MISCREG_CYCLE;
334  }
335 
336  if (hpmcounter < 0 || hpmcounter > 31)
337  panic("Illegal HPM counter %d\n", hpmcounter);
338  int counteren;
339  switch (readMiscRegNoEffect(MISCREG_PRV)) {
340  case PRV_M:
341  return true;
342  case PRV_S:
343  counteren = MISCREG_MCOUNTEREN;
344  break;
345  case PRV_U:
346  counteren = MISCREG_SCOUNTEREN;
347  break;
348  default:
349  panic("Unknown privilege level %d\n", miscRegFile[MISCREG_PRV]);
350  return false;
351  }
352  return (miscRegFile[counteren] & (1ULL << (hpmcounter))) > 0;
353 }
354 
355 RegVal
357 {
358  // Illegal CSR
359  panic_if(idx > NUM_MISCREGS, "Illegal CSR index %#x\n", idx);
360  DPRINTF(RiscvMisc, "Reading MiscReg %s (%d): %#x.\n",
361  MiscRegNames[idx], idx, miscRegFile[idx]);
362  return miscRegFile[idx];
363 }
364 
365 RegVal
367 {
368  switch (idx) {
369  case MISCREG_HARTID:
370  return tc->contextId();
371  case MISCREG_CYCLE:
373  DPRINTF(RiscvMisc, "Cycle counter at: %llu.\n",
374  tc->getCpuPtr()->curCycle());
375  return static_cast<RegVal>(tc->getCpuPtr()->curCycle());
376  } else {
377  warn("Cycle counter disabled.\n");
378  return 0;
379  }
380  case MISCREG_CYCLEH:
382  DPRINTF(RiscvMisc, "Cycle counter at: %llu.\n",
383  tc->getCpuPtr()->curCycle());
384  return bits<RegVal>(tc->getCpuPtr()->curCycle(), 63, 32);
385  } else {
386  warn("Cycle counter disabled.\n");
387  return 0;
388  }
389  case MISCREG_TIME:
391  DPRINTF(RiscvMisc, "Wall-clock counter at: %llu.\n",
392  std::time(nullptr));
394  } else {
395  warn("Wall clock disabled.\n");
396  return 0;
397  }
398  case MISCREG_TIMEH:
400  DPRINTF(RiscvMisc, "Wall-clock counter at: %llu.\n",
401  std::time(nullptr));
403  } else {
404  warn("Wall clock disabled.\n");
405  return 0;
406  }
407  case MISCREG_INSTRET:
409  DPRINTF(RiscvMisc, "Instruction counter at: %llu.\n",
410  tc->getCpuPtr()->totalInsts());
411  return static_cast<RegVal>(tc->getCpuPtr()->totalInsts());
412  } else {
413  warn("Instruction counter disabled.\n");
414  return 0;
415  }
416  case MISCREG_INSTRETH:
418  DPRINTF(RiscvMisc, "Instruction counter at: %llu.\n",
419  tc->getCpuPtr()->totalInsts());
420  return bits<RegVal>(tc->getCpuPtr()->totalInsts(), 63, 32);
421  } else {
422  warn("Instruction counter disabled.\n");
423  return 0;
424  }
425  case MISCREG_IP:
426  {
427  auto ic = dynamic_cast<RiscvISA::Interrupts *>(
429  return ic->readIP();
430  }
431  case MISCREG_IE:
432  {
433  auto ic = dynamic_cast<RiscvISA::Interrupts *>(
435  return ic->readIE();
436  }
437  case MISCREG_SEPC:
438  case MISCREG_MEPC:
439  {
440  MISA misa = readMiscRegNoEffect(MISCREG_ISA);
441  auto val = readMiscRegNoEffect(idx);
442  // if compressed instructions are disabled, epc[1] is set to 0
443  if (misa.rvc == 0)
444  return mbits(val, 63, 2);
445  // epc[0] is always 0
446  else
447  return mbits(val, 63, 1);
448  }
449  case MISCREG_STATUS:
450  {
451  // Updating the SD bit.
452  // . Per RISC-V ISA Manual, vol II, section 3.1.6.6, page 26,
453  // the SD bit is a read-only bit indicating whether any of
454  // FS, VS, and XS fields being in the respective dirty state.
455  // . Per section 3.1.6, page 20, the SD bit is the most
456  // significant bit of the MSTATUS CSR for both RV32 and RV64.
457  // . Per section 3.1.6.6, page 29, the explicit formula for
458  // updating the SD is,
459  // SD = ((FS==DIRTY) | (XS==DIRTY) | (VS==DIRTY))
460  // . Ideally, we want to update the SD after every relevant
461  // instruction, however, lazily updating the Status register
462  // upon its read produces the same effect as well.
463  STATUS status = readMiscRegNoEffect(idx);
464  uint64_t sd_bit = \
465  (status.xs == 3) || (status.fs == 3) || (status.vs == 3);
466  // For RV32, the SD bit is at index 31
467  // For RV64, the SD bit is at index 63.
468  switch (rv_type) {
469  case RV32:
470  status.rv32_sd = sd_bit;
471  break;
472  case RV64:
473  status.rv64_sd = sd_bit;
474  break;
475  default:
476  panic("%s: Unknown rv_type: %d", name(), (int)rv_type);
477  }
479 
480  return readMiscRegNoEffect(idx);
481  }
482  default:
483  // Try reading HPM counters
484  // As a placeholder, all HPM counters are just cycle counters
485  if (idx >= MISCREG_HPMCOUNTER03 &&
486  idx <= MISCREG_HPMCOUNTER31) {
487  if (hpmCounterEnabled(idx)) {
488  DPRINTF(RiscvMisc, "HPM counter %d: %llu.\n",
489  idx - MISCREG_CYCLE, tc->getCpuPtr()->curCycle());
490  return tc->getCpuPtr()->curCycle();
491  } else {
492  warn("HPM counter %d disabled.\n", idx - MISCREG_CYCLE);
493  return 0;
494  }
495  } else if (idx >= MISCREG_HPMCOUNTER03H &&
496  idx <= MISCREG_HPMCOUNTER31H) {
497  if (hpmCounterEnabled(idx)) {
498  DPRINTF(RiscvMisc, "HPM counter %d: %llu.\n",
499  idx - MISCREG_CYCLE, tc->getCpuPtr()->curCycle());
500  return bits<RegVal>(tc->getCpuPtr()->curCycle(), 63, 32);
501  } else {
502  warn("HPM counter %d disabled.\n", idx - MISCREG_CYCLE);
503  return 0;
504  }
505  }
506  return readMiscRegNoEffect(idx);
507  }
508 }
509 
510 void
512 {
513  // Illegal CSR
514  panic_if(idx > NUM_MISCREGS, "Illegal CSR index %#x\n", idx);
515  DPRINTF(RiscvMisc, "Setting MiscReg %s (%d) to %#x.\n",
516  MiscRegNames[idx], idx, val);
517  miscRegFile[idx] = val;
518 }
519 
520 void
522 {
523  if (idx >= MISCREG_CYCLE && idx <= MISCREG_HPMCOUNTER31) {
524  // Ignore writes to HPM counters for now
525  warn("Ignoring write to miscreg %s.\n", MiscRegNames[idx]);
526  } else {
527  switch (idx) {
528 
529  // From section 3.7.1 of RISCV priv. specs
530  // V1.12, the odd-numbered configuration
531  // registers are illegal for RV64 and
532  // each 64 bit CFG register hold configurations
533  // for 8 PMP entries.
534 
535  case MISCREG_PMPCFG0:
536  case MISCREG_PMPCFG1:
537  case MISCREG_PMPCFG2:
538  case MISCREG_PMPCFG3:
539  {
540  // PMP registers should only be modified in M mode
542 
543  int regSize = 0;
544  switch (rv_type) {
545  case RV32:
546  regSize = 4;
547  break;
548  case RV64:
549  regSize = 8;
550  break;
551  default:
552  panic("%s: Unknown rv_type: %d", name(), (int)rv_type);
553  }
554 
555  // Specs do not seem to mention what should be
556  // configured first, cfg or address regs!
557  // qemu seems to update the tables when
558  // pmp addr regs are written (with the assumption
559  // that cfg regs are already written)
560  RegVal res = 0;
561  RegVal old_val = readMiscRegNoEffect(idx);
562 
563  for (int i=0; i < regSize; i++) {
564 
565  uint8_t cfg_val = (val >> (8*i)) & 0xff;
566  auto mmu = dynamic_cast<RiscvISA::MMU *>
567  (tc->getMMUPtr());
568 
569  // Form pmp_index using the index i and
570  // PMPCFG register number
571  uint32_t pmp_index = i+(4*(idx-MISCREG_PMPCFG0));
572  bool result = mmu->getPMP()->pmpUpdateCfg(pmp_index,cfg_val);
573  if (result) {
574  res |= ((RegVal)cfg_val << (8*i));
575  } else {
576  res |= (old_val & (0xFF << (8*i)));
577  }
578  }
579 
580  setMiscRegNoEffect(idx, res);
581  }
582  break;
584  {
585  // PMP registers should only be modified in M mode
587 
588  auto mmu = dynamic_cast<RiscvISA::MMU *>
589  (tc->getMMUPtr());
590  uint32_t pmp_index = idx-MISCREG_PMPADDR00;
591  if (mmu->getPMP()->pmpUpdateAddr(pmp_index, val)) {
592  setMiscRegNoEffect(idx, val);
593  }
594  }
595  break;
596 
597  case MISCREG_IP:
598  {
599  auto ic = dynamic_cast<RiscvISA::Interrupts *>(
601  ic->setIP(val);
602  }
603  break;
604  case MISCREG_IE:
605  {
606  auto ic = dynamic_cast<RiscvISA::Interrupts *>(
608  ic->setIE(val);
609  }
610  break;
611  case MISCREG_SATP:
612  {
613  // we only support bare and Sv39 mode; setting a different mode
614  // shall have no effect (see 4.1.12 in priv ISA manual)
615  SATP cur_val = readMiscRegNoEffect(idx);
616  SATP new_val = val;
617  if (new_val.mode != AddrXlateMode::BARE &&
618  new_val.mode != AddrXlateMode::SV39)
619  new_val.mode = cur_val.mode;
620  setMiscRegNoEffect(idx, new_val);
621  }
622  break;
623  case MISCREG_TSELECT:
624  {
625  // we don't support debugging, so always set a different value
626  // than written
627  setMiscRegNoEffect(idx, val + 1);
628  }
629  break;
630  case MISCREG_ISA:
631  {
632  MISA cur_misa = (MISA)readMiscRegNoEffect(MISCREG_ISA);
633  MISA new_misa = (MISA)val;
634  // only allow to disable compressed instructions
635  // if the following instruction is 4-byte aligned
636  if (new_misa.rvc == 0 &&
637  bits(tc->pcState().as<RiscvISA::PCState>().npc(),
638  2, 0) != 0) {
639  new_misa.rvc = new_misa.rvc | cur_misa.rvc;
640  }
641  setMiscRegNoEffect(idx, new_misa);
642  }
643  break;
644  case MISCREG_STATUS:
645  {
646  if (rv_type != RV32) {
647  // SXL and UXL are hard-wired to 64 bit
648  auto cur = readMiscRegNoEffect(idx);
650  val |= cur & (STATUS_SXL_MASK | STATUS_UXL_MASK);
651  }
652  setMiscRegNoEffect(idx, val);
653  }
654  break;
655  default:
656  setMiscRegNoEffect(idx, val);
657  }
658  }
659 }
660 
661 void
663 {
664  DPRINTF(Checkpoint, "Serializing Riscv Misc Registers\n");
666 }
667 
668 void
670 {
671  DPRINTF(Checkpoint, "Unserializing Riscv Misc Registers\n");
673 }
674 
675 void
677 {
678  Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
679 
680  if (load_reservation_addr == INVALID_RESERVATION_ADDR)
681  return;
682  Addr snoop_addr = pkt->getAddr() & cacheBlockMask;
683  DPRINTF(LLSC, "Locked snoop on address %x.\n", snoop_addr);
684  if ((load_reservation_addr & cacheBlockMask) == snoop_addr)
685  load_reservation_addr = INVALID_RESERVATION_ADDR;
686 }
687 
688 
689 void
691 {
692  Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
693 
694  load_reservation_addr = req->getPaddr();
695  DPRINTF(LLSC, "[cid:%d]: Reserved address %x.\n",
696  req->contextId(), req->getPaddr());
697 }
698 
699 bool
700 ISA::handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask)
701 {
702  Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
703  bool lr_addr_empty = (load_reservation_addr == INVALID_RESERVATION_ADDR);
704 
705  // Normally RISC-V uses zero to indicate success and nonzero to indicate
706  // failure (right now only 1 is reserved), but in gem5 zero indicates
707  // failure and one indicates success, so here we conform to that (it should
708  // be switched in the instruction's implementation)
709 
710  DPRINTF(LLSC, "[cid:%d]: load_reservation_addrs empty? %s.\n",
711  req->contextId(),
712  lr_addr_empty ? "yes" : "no");
713  if (!lr_addr_empty) {
714  DPRINTF(LLSC, "[cid:%d]: addr = %x.\n", req->contextId(),
715  req->getPaddr() & cacheBlockMask);
716  DPRINTF(LLSC, "[cid:%d]: last locked addr = %x.\n", req->contextId(),
717  load_reservation_addr & cacheBlockMask);
718  }
719  if (lr_addr_empty ||
720  (load_reservation_addr & cacheBlockMask)
721  != ((req->getPaddr() & cacheBlockMask))) {
722  req->setExtraData(0);
723  int stCondFailures = tc->readStCondFailures();
724  tc->setStCondFailures(++stCondFailures);
725  if (stCondFailures % WARN_FAILURE == 0) {
726  warn("%i: context %d: %d consecutive SC failures.\n",
727  curTick(), tc->contextId(), stCondFailures);
728  }
729 
730  // Must clear any reservations
731  load_reservation_addr = INVALID_RESERVATION_ADDR;
732 
733  return false;
734  }
735  if (req->isUncacheable()) {
736  req->setExtraData(2);
737  }
738 
739  // Must clear any reservations
740  load_reservation_addr = INVALID_RESERVATION_ADDR;
741 
742  DPRINTF(LLSC, "[cid:%d]: SC success! Current locked addr = %x.\n",
743  req->contextId(), load_reservation_addr & cacheBlockMask);
744  return true;
745 }
746 
747 void
749 {
750  tc->getCpuPtr()->wakeup(tc->threadId());
751  Addr& load_reservation_addr = load_reservation_addrs[tc->contextId()];
752  load_reservation_addr = INVALID_RESERVATION_ADDR;
753 }
754 
755 void
757 {
758  Reset().invoke(tc);
759 }
760 
761 } // namespace RiscvISA
762 } // namespace gem5
763 
764 std::ostream &
766 {
767  switch (pm) {
769  return os << "PRV_U";
771  return os << "PRV_S";
773  return os << "PRV_M";
774  }
775  return os << "PRV_<invalid>";
776 }
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::RiscvISA::MISCREG_HPMCOUNTER31
@ MISCREG_HPMCOUNTER31
Definition: misc.hh:109
gem5::RiscvISA::MISCREG_HPMEVENT11
@ MISCREG_HPMEVENT11
Definition: misc.hh:118
gem5::RiscvISA::PRV_S
@ PRV_S
Definition: isa.hh:58
gem5::MipsISA::fill
fill
Definition: pra_constants.hh:57
gem5::RiscvISA::MISCREG_STATUS
@ MISCREG_STATUS
Definition: misc.hh:75
gem5::RiscvISA::ISA::WARN_FAILURE
const int WARN_FAILURE
Definition: isa.hh:80
gem5::RiscvISA::MISCREG_HPMCOUNTER09
@ MISCREG_HPMCOUNTER09
Definition: misc.hh:87
gem5::RiscvISA::MISCREG_HPMCOUNTER08H
@ MISCREG_HPMCOUNTER08H
Definition: misc.hh:215
gem5::RiscvISA::PRV_M
@ PRV_M
Definition: isa.hh:59
gem5::BaseISA::tc
ThreadContext * tc
Definition: isa.hh:66
warn
#define warn(...)
Definition: logging.hh:256
gem5::RiscvISA::MISCREG_HPMCOUNTER27H
@ MISCREG_HPMCOUNTER27H
Definition: misc.hh:234
gem5::RiscvISA::MISCREG_HPMCOUNTER21H
@ MISCREG_HPMCOUNTER21H
Definition: misc.hh:228
gem5::RiscvISA::MISCREG_PMPADDR11
@ MISCREG_PMPADDR11
Definition: misc.hh:170
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::RiscvISA::MISCREG_HPMEVENT16
@ MISCREG_HPMEVENT16
Definition: misc.hh:123
gem5::RiscvISA::MISCREG_HPMCOUNTER27
@ MISCREG_HPMCOUNTER27
Definition: misc.hh:105
faults.hh
gem5::RiscvISA::MISCREG_HPMCOUNTER08
@ MISCREG_HPMCOUNTER08
Definition: misc.hh:86
gem5::ps2::Reset
@ Reset
Definition: types.hh:69
gem5::Clocked::curCycle
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Definition: clocked_object.hh:195
gem5::RiscvISA::MISCREG_HPMCOUNTER12
@ MISCREG_HPMCOUNTER12
Definition: misc.hh:90
gem5::igbreg::txd_op::ic
bool ic(TxDesc *d)
Definition: i8254xGBe_defs.hh:302
gem5::RiscvISA::MISCREG_SIDELEG
@ MISCREG_SIDELEG
Definition: misc.hh:177
gem5::RiscvISA::ISA::inUserMode
bool inUserMode() const override
Definition: isa.cc:262
gem5::VecElemClass
@ VecElemClass
Vector Register Native Elem lane.
Definition: reg_class.hh:65
gem5::VecRegClassName
constexpr char VecRegClassName[]
Definition: reg_class.hh:76
gem5::BaseCPU::getInterruptController
BaseInterrupts * getInterruptController(ThreadID tid)
Definition: base.hh:228
gem5::ThreadContext::getReg
virtual RegVal getReg(const RegId &reg) const
Definition: thread_context.cc:180
UNSERIALIZE_CONTAINER
#define UNSERIALIZE_CONTAINER(member)
Definition: serialize.hh:634
pseudo_inst.hh
gem5::RiscvISA::MISCREG_SSCRATCH
@ MISCREG_SSCRATCH
Definition: misc.hh:180
gem5::RiscvISA::ISA::copyRegsFrom
void copyRegsFrom(ThreadContext *src) override
Definition: isa.cc:268
gem5::PCStateBase::as
Target & as()
Definition: pcstate.hh:72
gem5::CCRegClass
@ CCRegClass
Condition-code register.
Definition: reg_class.hh:68
gem5::ThreadContext::getMMUPtr
virtual BaseMMU * getMMUPtr()=0
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::RiscvISA::MISCREG_HPMEVENT19
@ MISCREG_HPMEVENT19
Definition: misc.hh:126
gem5::RiscvISA::MMU
Definition: mmu.hh:54
gem5::ThreadContext::pcState
virtual const PCStateBase & pcState() const =0
gem5::RiscvISA::MISCREG_HPMCOUNTER23H
@ MISCREG_HPMCOUNTER23H
Definition: misc.hh:230
gem5::VecPredRegClassName
constexpr char VecPredRegClassName[]
Definition: reg_class.hh:78
gem5::RiscvISA::MISCREG_PMPADDR09
@ MISCREG_PMPADDR09
Definition: misc.hh:168
gem5::RiscvISA::MISCREG_PMPCFG1
@ MISCREG_PMPCFG1
Definition: misc.hh:156
gem5::RiscvISA::MISCREG_HPMCOUNTER26
@ MISCREG_HPMCOUNTER26
Definition: misc.hh:104
gem5::RiscvISA::RV64
constexpr enums::RiscvType RV64
Definition: pcstate.hh:55
gem5::RiscvISA::MISCREG_MSTATUSH
@ MISCREG_MSTATUSH
Definition: misc.hh:205
gem5::RiscvISA::MISCREG_HPMCOUNTER04H
@ MISCREG_HPMCOUNTER04H
Definition: misc.hh:211
gem5::RiscvISA::MISCREG_TIMEH
@ MISCREG_TIMEH
Definition: misc.hh:208
operator<<
std::ostream & operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm)
Definition: isa.cc:765
gem5::RiscvISA::PrivilegeMode
PrivilegeMode
Definition: isa.hh:55
gem5::RiscvISA::MISCREG_MTVAL
@ MISCREG_MTVAL
Definition: misc.hh:154
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:776
gem5::RiscvISA::MISCREG_HPMEVENT15
@ MISCREG_HPMEVENT15
Definition: misc.hh:122
gem5::RiscvISA::ISA::INVALID_RESERVATION_ADDR
const Addr INVALID_RESERVATION_ADDR
Definition: isa.hh:81
gem5::RiscvISA::MISCREG_HPMEVENT05
@ MISCREG_HPMEVENT05
Definition: misc.hh:112
interrupts.hh
gem5::RiscvISA::MISCREG_SEDELEG
@ MISCREG_SEDELEG
Definition: misc.hh:176
gem5::RiscvISA::MISCREG_HPMCOUNTER28H
@ MISCREG_HPMCOUNTER28H
Definition: misc.hh:235
gem5::RiscvISA::MISCREG_HPMCOUNTER07
@ MISCREG_HPMCOUNTER07
Definition: misc.hh:85
gem5::RiscvISA::NUM_MISCREGS
@ NUM_MISCREGS
Definition: misc.hh:240
gem5::ThreadContext::contextId
virtual ContextID contextId() const =0
gem5::RiscvISA::MISCREG_DPC
@ MISCREG_DPC
Definition: misc.hh:144
gem5::RiscvISA::ISA::load_reservation_addrs
std::unordered_map< int, Addr > load_reservation_addrs
Definition: isa.hh:82
gem5::RiscvISA::MISCREG_HPMCOUNTER15H
@ MISCREG_HPMCOUNTER15H
Definition: misc.hh:222
gem5::RiscvISA::MISCREG_ISA
@ MISCREG_ISA
Definition: misc.hh:70
gem5::RiscvISA::MISCREG_IE
@ MISCREG_IE
Definition: misc.hh:77
gem5::RiscvISA::MISCREG_HPMEVENT14
@ MISCREG_HPMEVENT14
Definition: misc.hh:121
float.hh
gem5::RiscvISA::MISCREG_HPMCOUNTER24H
@ MISCREG_HPMCOUNTER24H
Definition: misc.hh:231
gem5::RiscvISA::MISCREG_CYCLE
@ MISCREG_CYCLE
Definition: misc.hh:78
gem5::RiscvISA::RV32
constexpr enums::RiscvType RV32
Definition: pcstate.hh:54
gem5::mbits
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
Definition: bitfield.hh:103
gem5::RiscvISA::MISCREG_HPMCOUNTER14
@ MISCREG_HPMCOUNTER14
Definition: misc.hh:92
gem5::RiscvISA::INITIAL
@ INITIAL
Definition: isa.hh:65
gem5::RiscvISA::MISCREG_HPMCOUNTER11H
@ MISCREG_HPMCOUNTER11H
Definition: misc.hh:218
gem5::RiscvISA::ISA::Params
RiscvISAParams Params
Definition: isa.hh:85
isa.hh
request.hh
gem5::RiscvISA::MISCREG_HPMEVENT22
@ MISCREG_HPMEVENT22
Definition: misc.hh:129
gem5::RiscvISA::MISCREG_HPMCOUNTER13
@ MISCREG_HPMCOUNTER13
Definition: misc.hh:91
gem5::RiscvISA::MISCREG_HPMCOUNTER14H
@ MISCREG_HPMCOUNTER14H
Definition: misc.hh:221
gem5::BaseCPU::totalInsts
virtual Counter totalInsts() const =0
gem5::RiscvISA::MISCREG_HPMCOUNTER26H
@ MISCREG_HPMCOUNTER26H
Definition: misc.hh:233
gem5::VecPredRegClass
@ VecPredRegClass
Definition: reg_class.hh:66
gem5::RiscvISA::MISCREG_HPMEVENT09
@ MISCREG_HPMEVENT09
Definition: misc.hh:116
misc.hh
gem5::RiscvISA::STATUS_UXL_MASK
const RegVal STATUS_UXL_MASK
Definition: misc.hh:846
gem5::RiscvISA::MISCREG_PMPADDR12
@ MISCREG_PMPADDR12
Definition: misc.hh:171
gem5::RiscvISA::MISCREG_HPMCOUNTER25H
@ MISCREG_HPMCOUNTER25H
Definition: misc.hh:232
packet.hh
gem5::RiscvISA::MISCREG_SCAUSE
@ MISCREG_SCAUSE
Definition: misc.hh:182
gem5::RiscvISA::MISCREG_NMIE
@ MISCREG_NMIE
Definition: misc.hh:200
gem5::RiscvISA::MISCREG_HPMCOUNTER06
@ MISCREG_HPMCOUNTER06
Definition: misc.hh:84
gem5::RiscvISA::MISCREG_MEDELEG
@ MISCREG_MEDELEG
Definition: misc.hh:147
gem5::RiscvISA::PCState
Definition: pcstate.hh:57
gem5::RiscvISA::MISCREG_DSCRATCH
@ MISCREG_DSCRATCH
Definition: misc.hh:145
gem5::RiscvISA::MISCREG_HPMEVENT29
@ MISCREG_HPMEVENT29
Definition: misc.hh:136
gem5::RiscvISA::MISCREG_INSTRETH
@ MISCREG_INSTRETH
Definition: misc.hh:209
gem5::BaseCPU::wakeup
virtual void wakeup(ThreadID tid)=0
gem5::RiscvISA::MISCREG_PMPADDR01
@ MISCREG_PMPADDR01
Definition: misc.hh:160
gem5::RiscvISA::MISCREG_INSTRET
@ MISCREG_INSTRET
Definition: misc.hh:80
pmp.hh
gem5::RiscvISA::MISCREG_HPMCOUNTER29
@ MISCREG_HPMCOUNTER29
Definition: misc.hh:107
gem5::BaseISA::_regClasses
RegClasses _regClasses
Definition: isa.hh:68
gem5::RiscvISA::ISA::clear
void clear() override
Definition: isa.cc:282
bitfield.hh
gem5::RiscvISA::MISCREG_PMPADDR05
@ MISCREG_PMPADDR05
Definition: misc.hh:164
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
gem5::RiscvISA::MISCREG_HPMEVENT24
@ MISCREG_HPMEVENT24
Definition: misc.hh:131
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::RiscvISA::MISCREG_HPMCOUNTER25
@ MISCREG_HPMCOUNTER25
Definition: misc.hh:103
gem5::MatRegClass
@ MatRegClass
Matrix Register.
Definition: reg_class.hh:67
gem5::RiscvISA::MISCREG_HPMCOUNTER09H
@ MISCREG_HPMCOUNTER09H
Definition: misc.hh:216
gem5::RiscvISA::MISCREG_HPMEVENT31
@ MISCREG_HPMEVENT31
Definition: misc.hh:138
gem5::RiscvISA::MISCREG_FRM
@ MISCREG_FRM
Definition: misc.hh:192
gem5::RiscvISA::MISCREG_SEPC
@ MISCREG_SEPC
Definition: misc.hh:181
gem5::RiscvISA::MISCREG_MSCRATCH
@ MISCREG_MSCRATCH
Definition: misc.hh:151
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:210
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::RiscvISA::MISCREG_HPMCOUNTER19H
@ MISCREG_HPMCOUNTER19H
Definition: misc.hh:226
gem5::RiscvISA::MISCREG_HPMCOUNTER31H
@ MISCREG_HPMCOUNTER31H
Definition: misc.hh:238
gem5::RiscvISA::MISCREG_HPMCOUNTER18
@ MISCREG_HPMCOUNTER18
Definition: misc.hh:96
gem5::RiscvISA::MISCREG_IMPID
@ MISCREG_IMPID
Definition: misc.hh:73
gem5::RiscvISA::MISCREG_HPMCOUNTER17
@ MISCREG_HPMCOUNTER17
Definition: misc.hh:95
gem5::RiscvISA::MISCREG_PMPCFG3
@ MISCREG_PMPCFG3
Definition: misc.hh:158
gem5::RiscvISA::ISA::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:669
gem5::RiscvISA::MISCREG_PMPADDR00
@ MISCREG_PMPADDR00
Definition: misc.hh:159
gem5::RiscvISA::STATUS_SXL_MASK
const RegVal STATUS_SXL_MASK
Definition: misc.hh:845
gem5::RiscvISA::MISCREG_HPMCOUNTER23
@ MISCREG_HPMCOUNTER23
Definition: misc.hh:101
gem5::RiscvISA::MISCREG_VENDORID
@ MISCREG_VENDORID
Definition: misc.hh:71
gem5::RiscvISA::MISCREG_HPMCOUNTER06H
@ MISCREG_HPMCOUNTER06H
Definition: misc.hh:213
gem5::RiscvISA::MISCREG_SATP
@ MISCREG_SATP
Definition: misc.hh:184
gem5::RiscvISA::ISA::rv_type
RiscvType rv_type
Definition: isa.hh:73
gem5::RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
gem5::RiscvISA::MISCREG_PMPADDR08
@ MISCREG_PMPADDR08
Definition: misc.hh:167
gem5::RiscvISA::MISCREG_HPMEVENT21
@ MISCREG_HPMEVENT21
Definition: misc.hh:128
gem5::RiscvISA::MISCREG_HPMEVENT08
@ MISCREG_HPMEVENT08
Definition: misc.hh:115
gem5::RiscvISA::MISCREG_MCAUSE
@ MISCREG_MCAUSE
Definition: misc.hh:153
gem5::RiscvISA::MISCREG_HPMCOUNTER29H
@ MISCREG_HPMCOUNTER29H
Definition: misc.hh:236
gem5::RiscvISA::MISCREG_HPMEVENT13
@ MISCREG_HPMEVENT13
Definition: misc.hh:120
gem5::MatRegClassName
constexpr char MatRegClassName[]
Definition: reg_class.hh:79
gem5::RiscvISA::MISCREG_HPMCOUNTER12H
@ MISCREG_HPMCOUNTER12H
Definition: misc.hh:219
gem5::RiscvISA::MISCREG_HPMEVENT20
@ MISCREG_HPMEVENT20
Definition: misc.hh:127
gem5::RiscvISA::MISCREG_HPMEVENT07
@ MISCREG_HPMEVENT07
Definition: misc.hh:114
gem5::RiscvISA::MISCREG_TDATA1
@ MISCREG_TDATA1
Definition: misc.hh:140
gem5::RiscvISA::MISCREG_HPMEVENT30
@ MISCREG_HPMEVENT30
Definition: misc.hh:137
gem5::RiscvISA::MISCREG_CYCLEH
@ MISCREG_CYCLEH
Definition: misc.hh:207
gem5::bits
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
compiler.hh
gem5::RiscvISA::ISA::miscRegFile
std::vector< RegVal > miscRegFile
Definition: isa.hh:74
gem5::RiscvISA::MISCREG_PMPCFG2
@ MISCREG_PMPCFG2
Definition: misc.hh:157
gem5::RiscvISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::RiscvISA::MISCREG_TDATA3
@ MISCREG_TDATA3
Definition: misc.hh:142
gem5::RiscvISA::MISCREG_TSELECT
@ MISCREG_TSELECT
Definition: misc.hh:139
gem5::RiscvISA::MISCREG_HPMEVENT17
@ MISCREG_HPMEVENT17
Definition: misc.hh:124
gem5::RiscvISA::MISCREG_USCRATCH
@ MISCREG_USCRATCH
Definition: misc.hh:187
gem5::RiscvISA::MISCREG_HPMCOUNTER22H
@ MISCREG_HPMCOUNTER22H
Definition: misc.hh:229
gem5::RiscvISA::ISA::readMiscReg
RegVal readMiscReg(RegIndex idx) override
Definition: isa.cc:366
gem5::ThreadContext::readStCondFailures
virtual unsigned readStCondFailures() const =0
gem5::RiscvISA::ISA::handleLockedRead
void handleLockedRead(const RequestPtr &req) override
Definition: isa.cc:690
gem5::RiscvISA::Interrupts
Definition: interrupts.hh:56
gem5::RiscvISA::MISCREG_NMIVEC
@ MISCREG_NMIVEC
Definition: misc.hh:198
gem5::RiscvISA::intRegClass
constexpr RegClass intRegClass(IntRegClass, IntRegClassName, int_reg::NumRegs, debug::IntRegs)
gem5::VecElemClassName
constexpr char VecElemClassName[]
Definition: reg_class.hh:77
gem5::RiscvISA::MISCREG_HPMCOUNTER17H
@ MISCREG_HPMCOUNTER17H
Definition: misc.hh:224
gem5::RiscvISA::MISCREG_HPMCOUNTER04
@ MISCREG_HPMCOUNTER04
Definition: misc.hh:82
gem5::RiscvISA::ISA::setMiscRegNoEffect
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Definition: isa.cc:511
gem5::RiscvISA::MISCREG_PMPADDR15
@ MISCREG_PMPADDR15
Definition: misc.hh:174
gem5::RiscvISA::ISA::handleLockedSnoop
void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override
Definition: isa.cc:676
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::RiscvISA::MISCREG_PMPADDR03
@ MISCREG_PMPADDR03
Definition: misc.hh:162
gem5::RegClass
Definition: reg_class.hh:184
gem5::RiscvISA::MISCREG_PMPADDR10
@ MISCREG_PMPADDR10
Definition: misc.hh:169
gem5::RiscvISA::MISCREG_HPMEVENT27
@ MISCREG_HPMEVENT27
Definition: misc.hh:134
gem5::RiscvISA::MISCREG_HPMCOUNTER03H
@ MISCREG_HPMCOUNTER03H
Definition: misc.hh:210
gem5::CCRegClassName
constexpr char CCRegClassName[]
Definition: reg_class.hh:80
gem5::RiscvISA::MISCREG_HPMEVENT12
@ MISCREG_HPMEVENT12
Definition: misc.hh:119
gem5::ArmISA::vecRegClass
constexpr RegClass vecRegClass
Definition: vec.hh:101
gem5::RiscvISA::MISCREG_MEPC
@ MISCREG_MEPC
Definition: misc.hh:152
gem5::RiscvISA::MISCREG_HARTID
@ MISCREG_HARTID
Definition: misc.hh:74
gem5::RiscvISA::MISCREG_HPMCOUNTER22
@ MISCREG_HPMCOUNTER22
Definition: misc.hh:100
gem5::RiscvISA::MISCREG_HPMCOUNTER03
@ MISCREG_HPMCOUNTER03
Definition: misc.hh:81
gem5::RiscvISA::MISCREG_PMPADDR07
@ MISCREG_PMPADDR07
Definition: misc.hh:166
gem5::RiscvISA::MISCREG_HPMCOUNTER10H
@ MISCREG_HPMCOUNTER10H
Definition: misc.hh:217
gem5::RiscvISA::ISA::setMiscReg
void setMiscReg(RegIndex idx, RegVal val) override
Definition: isa.cc:521
gem5::RiscvISA::MISCREG_HPMCOUNTER13H
@ MISCREG_HPMCOUNTER13H
Definition: misc.hh:220
gem5::RiscvISA::MISCREG_HPMEVENT10
@ MISCREG_HPMEVENT10
Definition: misc.hh:117
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:214
gem5::RiscvISA::MISCREG_HPMCOUNTER30H
@ MISCREG_HPMCOUNTER30H
Definition: misc.hh:237
gem5::RiscvISA::ISA::resetThread
void resetThread() override
Definition: isa.cc:756
gem5::RiscvISA::MISCREG_HPMEVENT26
@ MISCREG_HPMEVENT26
Definition: misc.hh:133
gem5::RiscvISA::MISCREG_ARCHID
@ MISCREG_ARCHID
Definition: misc.hh:72
mmu.hh
gem5::ArmISA::vecElemClass
constexpr RegClass vecElemClass
Definition: vec.hh:105
gem5::RiscvISA::MISCREG_UTVEC
@ MISCREG_UTVEC
Definition: misc.hh:186
base.hh
gem5::RiscvISA::MISCREG_HPMCOUNTER21
@ MISCREG_HPMCOUNTER21
Definition: misc.hh:99
gem5::RiscvISA::miscRegClass
constexpr RegClass miscRegClass(MiscRegClass, MiscRegClassName, NUM_MISCREGS, debug::MiscRegs)
gem5::RiscvISA::MISCREG_HPMEVENT23
@ MISCREG_HPMEVENT23
Definition: misc.hh:130
gem5::RiscvISA::MISCREG_PMPADDR06
@ MISCREG_PMPADDR06
Definition: misc.hh:165
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:810
gem5::RiscvISA::ISA::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:662
gem5::RiscvISA::MISCREG_PMPCFG0
@ MISCREG_PMPCFG0
Definition: misc.hh:155
gem5::RiscvISA::rv_type
rv_type
Definition: types.hh:60
SERIALIZE_CONTAINER
#define SERIALIZE_CONTAINER(member)
Definition: serialize.hh:626
gem5::RiscvISA::ISA::globalClearExclusive
void globalClearExclusive() override
Definition: isa.cc:748
gem5::RiscvISA::MISCREG_HPMCOUNTER18H
@ MISCREG_HPMCOUNTER18H
Definition: misc.hh:225
gem5::RiscvISA::MISCREG_PMPADDR04
@ MISCREG_PMPADDR04
Definition: misc.hh:163
gem5::RiscvISA::MISCREG_PMPADDR14
@ MISCREG_PMPADDR14
Definition: misc.hh:173
logging.hh
gem5::RiscvISA::MISCREG_TIME
@ MISCREG_TIME
Definition: misc.hh:79
gem5::RiscvISA::MiscRegNames
const std::array< const char *, NUM_MISCREGS > MiscRegNames
Definition: isa.cc:66
gem5::RiscvISA::MISCREG_UEPC
@ MISCREG_UEPC
Definition: misc.hh:188
gem5::RiscvISA::MISCREG_HPMEVENT25
@ MISCREG_HPMEVENT25
Definition: misc.hh:132
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::RiscvISA::MISCREG_MIDELEG
@ MISCREG_MIDELEG
Definition: misc.hh:148
gem5::RiscvISA::MISCREG_HPMCOUNTER07H
@ MISCREG_HPMCOUNTER07H
Definition: misc.hh:214
gem5::RiscvISA::MISCREG_PMPADDR02
@ MISCREG_PMPADDR02
Definition: misc.hh:161
gem5::ThreadContext::getCpuPtr
virtual BaseCPU * getCpuPtr()=0
gem5::RiscvISA::PRV_U
@ PRV_U
Definition: isa.hh:57
gem5::RiscvISA::MISCREG_STVAL
@ MISCREG_STVAL
Definition: misc.hh:183
gem5::RiscvISA::MISCREG_HPMCOUNTER10
@ MISCREG_HPMCOUNTER10
Definition: misc.hh:88
gem5::ThreadContext::threadId
virtual int threadId() const =0
trace.hh
gem5::RiscvISA::MISCREG_UCAUSE
@ MISCREG_UCAUSE
Definition: misc.hh:189
gem5::RiscvISA::MISCREG_HPMCOUNTER24
@ MISCREG_HPMCOUNTER24
Definition: misc.hh:102
gem5::RiscvISA::MISCREG_HPMCOUNTER20H
@ MISCREG_HPMCOUNTER20H
Definition: misc.hh:227
gem5::VecRegClass
@ VecRegClass
Vector Register.
Definition: reg_class.hh:63
gem5::RiscvISA::MISCREG_HPMCOUNTER05H
@ MISCREG_HPMCOUNTER05H
Definition: misc.hh:212
gem5::RiscvISA::ISA::handleLockedWrite
bool handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask) override
Definition: isa.cc:700
gem5::ArmISA::vecPredRegClass
constexpr RegClass vecPredRegClass
Definition: vec.hh:109
gem5::RiscvISA::MISCREG_HPMCOUNTER30
@ MISCREG_HPMCOUNTER30
Definition: misc.hh:108
gem5::BaseISA
Definition: isa.hh:58
gem5::RegIndex
uint16_t RegIndex
Definition: types.hh:176
gem5::RiscvISA::MISCREG_UTVAL
@ MISCREG_UTVAL
Definition: misc.hh:190
gem5::Packet::getAddr
Addr getAddr() const
Definition: packet.hh:807
gem5::RiscvISA::MISCREG_HPMCOUNTER16
@ MISCREG_HPMCOUNTER16
Definition: misc.hh:94
gem5::ThreadContext::setStCondFailures
virtual void setStCondFailures(unsigned sc_failures)=0
gem5::RiscvISA::MISCREG_MCOUNTEREN
@ MISCREG_MCOUNTEREN
Definition: misc.hh:150
gem5::RiscvISA::MISCREG_HPMEVENT28
@ MISCREG_HPMEVENT28
Definition: misc.hh:135
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::RiscvISA::MISCREG_PRV
@ MISCREG_PRV
Definition: misc.hh:69
gem5::RiscvISA::floatRegClass
constexpr RegClass floatRegClass(FloatRegClass, FloatRegClassName, float_reg::NumRegs, debug::FloatRegs)
gem5::ArmISA::matRegClass
constexpr RegClass matRegClass
Definition: mat.hh:92
int.hh
gem5::RiscvISA::MISCREG_HPMEVENT18
@ MISCREG_HPMEVENT18
Definition: misc.hh:125
gem5::RiscvISA::MISCREG_HPMCOUNTER19
@ MISCREG_HPMCOUNTER19
Definition: misc.hh:97
gem5::RiscvISA::i
Bitfield< 2 > i
Definition: pra_constants.hh:279
gem5::RiscvISA::ISA::hpmCounterEnabled
bool hpmCounterEnabled(int counter) const
Definition: isa.cc:327
gem5::RiscvISA::MISCREG_PMPADDR13
@ MISCREG_PMPADDR13
Definition: misc.hh:172
gem5::RiscvISA::MISCREG_TDATA2
@ MISCREG_TDATA2
Definition: misc.hh:141
gem5::RiscvISA::MISCREG_HPMEVENT04
@ MISCREG_HPMEVENT04
Definition: misc.hh:111
gem5::RiscvISA::MISCREG_FFLAGS
@ MISCREG_FFLAGS
Definition: misc.hh:191
pagetable.hh
gem5::RiscvISA::MISCREG_DCSR
@ MISCREG_DCSR
Definition: misc.hh:143
gem5::RiscvISA::MISCREG_IP
@ MISCREG_IP
Definition: misc.hh:76
gem5::RiscvISA::MISCREG_STVEC
@ MISCREG_STVEC
Definition: misc.hh:178
gem5::RiscvISA::MISCREG_HPMEVENT06
@ MISCREG_HPMEVENT06
Definition: misc.hh:113
gem5::ArmISA::ccRegClass
constexpr RegClass ccRegClass
Definition: cc.hh:87
gem5::RiscvISA::ISA::ISA
ISA(const Params &p)
Definition: isa.cc:246
gem5::RiscvISA::MISCREG_HPMCOUNTER15
@ MISCREG_HPMCOUNTER15
Definition: misc.hh:93
gem5::RiscvISA::MISCREG_NMIP
@ MISCREG_NMIP
Definition: misc.hh:202
gem5::RiscvISA::MISCREG_MTVEC
@ MISCREG_MTVEC
Definition: misc.hh:149
gem5::RiscvISA::MISCREG_SCOUNTEREN
@ MISCREG_SCOUNTEREN
Definition: misc.hh:179
gem5::RiscvISA::ISA::readMiscRegNoEffect
RegVal readMiscRegNoEffect(RegIndex idx) const override
Definition: isa.cc:356
gem5::RiscvISA::MISCREG_HPMCOUNTER11
@ MISCREG_HPMCOUNTER11
Definition: misc.hh:89
gem5::RiscvISA::MISCREG_HPMCOUNTER05
@ MISCREG_HPMCOUNTER05
Definition: misc.hh:83
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::RiscvISA::MISCREG_HPMCOUNTER28
@ MISCREG_HPMCOUNTER28
Definition: misc.hh:106
gem5::RiscvISA::MISCREG_HPMCOUNTER20
@ MISCREG_HPMCOUNTER20
Definition: misc.hh:98
gem5::RiscvISA::MISCREG_HPMEVENT03
@ MISCREG_HPMEVENT03
Definition: misc.hh:110
gem5::ArmISA::status
Bitfield< 5, 0 > status
Definition: misc_types.hh:480
gem5::ThreadContext::setReg
virtual void setReg(const RegId &reg, RegVal val)
Definition: thread_context.cc:188
gem5::RiscvISA::MISCREG_HPMCOUNTER16H
@ MISCREG_HPMCOUNTER16H
Definition: misc.hh:223

Generated on Sun Jul 30 2023 01:56:46 for gem5 by doxygen 1.8.17