gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
intregs.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2014 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) 2009 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * Authors: Gabe Black
41  */
42 
43 #include <cassert>
44 
45 #ifndef __ARCH_ARM_INTREGS_HH__
46 #define __ARCH_ARM_INTREGS_HH__
47 
48 #include "arch/arm/types.hh"
49 
50 namespace ArmISA
51 {
52 
54 {
55  /* All the unique register indices. */
75 
80 
85 
88 
93 
98 
103 
113 
118  INTREG_DUMMY, // Dummy reg used to throw away int reg results
119 
124 
127 
128  /* AArch64 registers */
161 
163 
164  /* All the aliased indexes. */
165 
166  /* USR mode */
186 
187  /* SVC mode */
203 
204  /* MON mode */
220 
221  /* ABT mode */
237 
238  /* HYP mode */
256 
257  /* UND mode */
273 
274  /* IRQ mode */
290 
291  /* FIQ mode */
302 };
303 
305 
315 };
316 
325  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
326 };
327 
328 static inline IntRegIndex
329 INTREG_USR(unsigned index)
330 {
331  assert(index < NUM_ARCH_INTREGS);
332  return IntRegUsrMap[index];
333 }
334 
343  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
344 };
345 
346 static inline IntRegIndex
347 INTREG_HYP(unsigned index)
348 {
349  assert(index < NUM_ARCH_INTREGS);
350  return IntRegHypMap[index];
351 }
352 
361  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
362 };
363 
364 static inline IntRegIndex
365 INTREG_SVC(unsigned index)
366 {
367  assert(index < NUM_ARCH_INTREGS);
368  return IntRegSvcMap[index];
369 }
370 
379  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
380 };
381 
382 static inline IntRegIndex
383 INTREG_MON(unsigned index)
384 {
385  assert(index < NUM_ARCH_INTREGS);
386  return IntRegMonMap[index];
387 }
388 
397  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
398 };
399 
400 static inline IntRegIndex
401 INTREG_ABT(unsigned index)
402 {
403  assert(index < NUM_ARCH_INTREGS);
404  return IntRegAbtMap[index];
405 }
406 
415  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
416 };
417 
418 static inline IntRegIndex
419 INTREG_UND(unsigned index)
420 {
421  assert(index < NUM_ARCH_INTREGS);
422  return IntRegUndMap[index];
423 }
424 
433  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
434 };
435 
436 static inline IntRegIndex
437 INTREG_IRQ(unsigned index)
438 {
439  assert(index < NUM_ARCH_INTREGS);
440  return IntRegIrqMap[index];
441 }
442 
451  INTREG_ZERO, INTREG_ZERO, INTREG_ZERO, INTREG_ZERO
452 };
453 
454 static inline IntRegIndex
455 INTREG_FIQ(unsigned index)
456 {
457  assert(index < NUM_ARCH_INTREGS);
458  return IntRegFiqMap[index];
459 }
460 
461 static const unsigned intRegsPerMode = NUM_INTREGS;
462 
463 static inline int
465 {
466  assert(reg < NUM_ARCH_INTREGS);
467  return mode * intRegsPerMode + reg;
468 }
469 
470 static inline int
472 {
473  int mode = reg / intRegsPerMode;
474  reg = reg % intRegsPerMode;
475  switch (mode) {
476  case MODE_USER:
477  case MODE_SYSTEM:
478  return INTREG_USR(reg);
479  case MODE_FIQ:
480  return INTREG_FIQ(reg);
481  case MODE_IRQ:
482  return INTREG_IRQ(reg);
483  case MODE_SVC:
484  return INTREG_SVC(reg);
485  case MODE_MON:
486  return INTREG_MON(reg);
487  case MODE_ABORT:
488  return INTREG_ABT(reg);
489  case MODE_HYP:
490  return INTREG_HYP(reg);
491  case MODE_UNDEFINED:
492  return INTREG_UND(reg);
493  default:
494  panic("%d: Flattening into an unknown mode: reg:%#x mode:%#x\n",
495  curTick(), reg, mode);
496  }
497 }
498 
499 
500 static inline IntRegIndex
502 {
503  if (reg == INTREG_X31)
504  reg = INTREG_SPX;
505  return reg;
506 }
507 
508 static inline IntRegIndex
510 {
511  if (reg == INTREG_X31)
512  reg = INTREG_ZERO;
513  return reg;
514 }
515 
516 static inline bool
518 {
519  return reg == INTREG_SPX;
520 }
521 
522 }
523 
524 #endif
const IntRegMap IntRegSvcMap
Definition: intregs.hh:353
static IntRegIndex makeSP(IntRegIndex reg)
Definition: intregs.hh:501
Bitfield< 30, 0 > index
static IntRegIndex INTREG_USR(unsigned index)
Definition: intregs.hh:329
Bitfield< 5, 3 > reg
Definition: types.hh:89
static IntRegIndex INTREG_SVC(unsigned index)
Definition: intregs.hh:365
IntRegIndex
Definition: intregs.hh:53
#define panic(...)
Definition: misc.hh:153
static IntRegIndex INTREG_IRQ(unsigned index)
Definition: intregs.hh:437
static IntRegIndex makeZero(IntRegIndex reg)
Definition: intregs.hh:509
const IntRegMap IntReg64Map
Definition: intregs.hh:306
OperatingMode
Definition: types.hh:569
static const unsigned intRegsPerMode
Definition: intregs.hh:461
Bitfield< 4, 0 > mode
Definition: miscregs.hh:1385
const IntRegMap IntRegHypMap
Definition: intregs.hh:335
const IntRegMap IntRegFiqMap
Definition: intregs.hh:443
Tick curTick()
The current simulated tick.
Definition: core.hh:47
static IntRegIndex INTREG_MON(unsigned index)
Definition: intregs.hh:383
IntRegIndex IntRegMap[NUM_ARCH_INTREGS]
Definition: intregs.hh:304
const IntRegMap IntRegUndMap
Definition: intregs.hh:407
const IntRegMap IntRegAbtMap
Definition: intregs.hh:389
static IntRegIndex INTREG_UND(unsigned index)
Definition: intregs.hh:419
static int flattenIntRegModeIndex(int reg)
Definition: intregs.hh:471
static IntRegIndex INTREG_FIQ(unsigned index)
Definition: intregs.hh:455
const IntRegMap IntRegUsrMap
Definition: intregs.hh:317
static IntRegIndex INTREG_ABT(unsigned index)
Definition: intregs.hh:401
const IntRegMap IntRegMonMap
Definition: intregs.hh:371
static IntRegIndex INTREG_HYP(unsigned index)
Definition: intregs.hh:347
static bool isSP(IntRegIndex reg)
Definition: intregs.hh:517
const IntRegMap IntRegIrqMap
Definition: intregs.hh:425
static int intRegInMode(OperatingMode mode, int reg)
Definition: intregs.hh:464

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