1 /* Definitions to support the MIPS TLB entry wrapper class.
2    Copyright 2001, 2003 Brian R. Gaeke.
3 
4 This file is part of VMIPS.
5 
6 VMIPS is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10 
11 VMIPS is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15 
16 You should have received a copy of the GNU General Public License along
17 with VMIPS; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19 
20 #ifndef _TLBENTRY_H_
21 #define _TLBENTRY_H_
22 
23 /* Class representing a TLB entry for CP0.
24  *
25  * The TLB entry is 64 bits wide and contains 7 fields, which may be
26  * accessed using the accessor functions implemented here; they are
27  * merely a convenience, as the entryHi and entryLo fields are public.
28  */
29 
30 #include "config.h"
31 #include "cpzeroreg.h"
32 #include "types.h"
33 #include <cstdlib>
34 
35 class TLBEntry {
36 public:
37 	uint32 entryHi;
38 	uint32 entryLo;
TLBEntry()39 	TLBEntry () {
40 #ifdef INTENTIONAL_CONFUSION
41 		entryHi = random ();
42 		entryLo = random ();
43 #endif
44 	}
vpn()45 	uint32 vpn() const { return (entryHi & EntryHi_VPN_MASK); }
asid()46 	uint16 asid() const { return (entryHi & EntryHi_ASID_MASK); }
pfn()47 	uint32 pfn() const { return (entryLo & EntryLo_PFN_MASK); }
noncacheable()48 	bool noncacheable() const { return (entryLo & EntryLo_N_MASK); }
dirty()49 	bool dirty() const { return (entryLo & EntryLo_D_MASK); }
valid()50 	bool valid() const { return (entryLo & EntryLo_V_MASK); }
global()51 	bool global() const { return (entryLo & EntryLo_G_MASK); }
52 };
53 
54 #endif /* _TLBENTRY_H_ */
55