Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 1 | /* |
Steve Reinhardt | ad8b963 | 2005-06-05 05:16:00 -0400 | [diff] [blame] | 2 | * Copyright (c) 2003-2005 The Regents of The University of Michigan |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 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. |
Ali Saidi | cb0cf2d | 2006-05-31 19:26:56 -0400 | [diff] [blame] | 27 | * |
| 28 | * Authors: Nathan Binkert |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | /** |
| 32 | * @file |
Nathan Binkert | eef3a2e | 2009-05-17 14:34:50 -0700 | [diff] [blame] | 33 | * Defines global host-dependent types: |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 34 | * Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t. |
| 35 | */ |
| 36 | |
Nathan Binkert | eef3a2e | 2009-05-17 14:34:50 -0700 | [diff] [blame] | 37 | #ifndef __BASE_TYPES_HH__ |
| 38 | #define __BASE_TYPES_HH__ |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 39 | |
| 40 | #include <inttypes.h> |
| 41 | |
| 42 | /** uint64_t constant */ |
Ali Saidi | 3a3e356 | 2008-09-10 14:26:15 -0400 | [diff] [blame] | 43 | #define ULL(N) ((uint64_t)N##ULL) |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 44 | /** int64_t constant */ |
Ali Saidi | 3a3e356 | 2008-09-10 14:26:15 -0400 | [diff] [blame] | 45 | #define LL(N) ((int64_t)N##LL) |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 46 | |
| 47 | /** Statistics counter type. Not much excuse for not using a 64-bit |
| 48 | * integer here, but if you're desperate and only run short |
| 49 | * simulations you could make this 32 bits. |
| 50 | */ |
| 51 | typedef int64_t Counter; |
| 52 | |
| 53 | /** |
| 54 | * Clock cycle count type. |
| 55 | * @note using an unsigned breaks the cache. |
| 56 | */ |
| 57 | typedef int64_t Tick; |
Nathan Binkert | 2c5fe6f | 2009-11-04 16:57:01 -0800 | [diff] [blame] | 58 | typedef uint64_t UTick; |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 59 | |
Nathan Binkert | 0b83563 | 2008-10-09 04:58:23 -0700 | [diff] [blame] | 60 | const Tick MaxTick = LL(0x7fffffffffffffff); |
Steve Reinhardt | 29e34a7 | 2006-06-09 23:01:31 -0400 | [diff] [blame] | 61 | |
Gabe Black | 3f7979c | 2006-02-21 03:38:21 -0500 | [diff] [blame] | 62 | /** |
| 63 | * Address type |
| 64 | * This will probably be moved somewhere else in the near future. |
| 65 | * This should be at least as big as the biggest address width in use |
| 66 | * in the system, which will probably be 64 bits. |
| 67 | */ |
| 68 | typedef uint64_t Addr; |
| 69 | |
Gabe Black | 6f4bd2c | 2010-10-31 00:07:20 -0700 | [diff] [blame^] | 70 | typedef uint16_t MicroPC; |
| 71 | |
| 72 | static const MicroPC MicroPCRomBit = 1 << (sizeof(MicroPC) * 8 - 1); |
| 73 | |
| 74 | static inline MicroPC |
| 75 | romMicroPC(MicroPC upc) |
| 76 | { |
| 77 | return upc | MicroPCRomBit; |
| 78 | } |
| 79 | |
| 80 | static inline MicroPC |
| 81 | normalMicroPC(MicroPC upc) |
| 82 | { |
| 83 | return upc & ~MicroPCRomBit; |
| 84 | } |
| 85 | |
| 86 | static inline bool |
| 87 | isRomMicroPC(MicroPC upc) |
| 88 | { |
| 89 | return MicroPCRomBit & upc; |
| 90 | } |
| 91 | |
Gabe Black | e3651fd | 2006-03-10 18:26:12 -0500 | [diff] [blame] | 92 | const Addr MaxAddr = (Addr)-1; |
| 93 | |
Nathan Binkert | 47877cf | 2009-05-26 09:23:13 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Thread index/ID type |
| 96 | */ |
| 97 | typedef int16_t ThreadID; |
| 98 | const ThreadID InvalidThreadID = (ThreadID)-1; |
| 99 | |
Gabe Black | 6833ca7 | 2010-09-13 19:26:03 -0700 | [diff] [blame] | 100 | class FaultBase; |
| 101 | template <class T> class RefCountingPtr; |
| 102 | typedef RefCountingPtr<FaultBase> Fault; |
| 103 | |
Nathan Binkert | eef3a2e | 2009-05-17 14:34:50 -0700 | [diff] [blame] | 104 | #endif // __BASE_TYPES_HH__ |