pagetable.hh revision 2984
12984Sgblack@eecs.umich.edu/*
22984Sgblack@eecs.umich.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan
32984Sgblack@eecs.umich.edu * All rights reserved.
42984Sgblack@eecs.umich.edu *
52984Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
62984Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
72984Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
82984Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
92984Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
102984Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
112984Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
122984Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
132984Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
142984Sgblack@eecs.umich.edu * this software without specific prior written permission.
152984Sgblack@eecs.umich.edu *
162984Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172984Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182984Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192984Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202984Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212984Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222984Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232984Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242984Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252984Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262984Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272984Sgblack@eecs.umich.edu *
282984Sgblack@eecs.umich.edu * Authors: Nathan Binkert
292984Sgblack@eecs.umich.edu *          Steve Reinhardt
302984Sgblack@eecs.umich.edu */
312984Sgblack@eecs.umich.edu
322984Sgblack@eecs.umich.edu#ifndef __ARCH_ALPHA_PAGETABLE_H__
332984Sgblack@eecs.umich.edu#define __ARCH_ALPHA_PAGETABLE_H__
342984Sgblack@eecs.umich.edu
352984Sgblack@eecs.umich.edu#include "arch/alpha/isa_traits.hh"
362984Sgblack@eecs.umich.edu#include "arch/alpha/utility.hh"
372984Sgblack@eecs.umich.edu#include "config/full_system.hh"
382984Sgblack@eecs.umich.edu
392984Sgblack@eecs.umich.edunamespace AlphaISA {
402984Sgblack@eecs.umich.edu
412984Sgblack@eecs.umich.edu#if FULL_SYSTEM
422984Sgblack@eecs.umich.edu    struct VAddr
432984Sgblack@eecs.umich.edu    {
442984Sgblack@eecs.umich.edu        static const int ImplBits = 43;
452984Sgblack@eecs.umich.edu        static const Addr ImplMask = (ULL(1) << ImplBits) - 1;
462984Sgblack@eecs.umich.edu        static const Addr UnImplMask = ~ImplMask;
472984Sgblack@eecs.umich.edu
482984Sgblack@eecs.umich.edu        VAddr(Addr a) : addr(a) {}
492984Sgblack@eecs.umich.edu        Addr addr;
502984Sgblack@eecs.umich.edu        operator Addr() const { return addr; }
512984Sgblack@eecs.umich.edu        const VAddr &operator=(Addr a) { addr = a; return *this; }
522984Sgblack@eecs.umich.edu
532984Sgblack@eecs.umich.edu        Addr vpn() const { return (addr & ImplMask) >> PageShift; }
542984Sgblack@eecs.umich.edu        Addr page() const { return addr & PageMask; }
552984Sgblack@eecs.umich.edu        Addr offset() const { return addr & PageOffset; }
562984Sgblack@eecs.umich.edu
572984Sgblack@eecs.umich.edu        Addr level3() const
582984Sgblack@eecs.umich.edu        { return AlphaISA::PteAddr(addr >> PageShift); }
592984Sgblack@eecs.umich.edu        Addr level2() const
602984Sgblack@eecs.umich.edu        { return AlphaISA::PteAddr(addr >> NPtePageShift + PageShift); }
612984Sgblack@eecs.umich.edu        Addr level1() const
622984Sgblack@eecs.umich.edu        { return AlphaISA::PteAddr(addr >> 2 * NPtePageShift + PageShift); }
632984Sgblack@eecs.umich.edu    };
642984Sgblack@eecs.umich.edu
652984Sgblack@eecs.umich.edu    struct PageTableEntry
662984Sgblack@eecs.umich.edu    {
672984Sgblack@eecs.umich.edu        PageTableEntry(uint64_t e) : entry(e) {}
682984Sgblack@eecs.umich.edu        uint64_t entry;
692984Sgblack@eecs.umich.edu        operator uint64_t() const { return entry; }
702984Sgblack@eecs.umich.edu        const PageTableEntry &operator=(uint64_t e) { entry = e; return *this; }
712984Sgblack@eecs.umich.edu        const PageTableEntry &operator=(const PageTableEntry &e)
722984Sgblack@eecs.umich.edu        { entry = e.entry; return *this; }
732984Sgblack@eecs.umich.edu
742984Sgblack@eecs.umich.edu        Addr _pfn()  const { return (entry >> 32) & 0xffffffff; }
752984Sgblack@eecs.umich.edu        Addr _sw()   const { return (entry >> 16) & 0xffff; }
762984Sgblack@eecs.umich.edu        int  _rsv0() const { return (entry >> 14) & 0x3; }
772984Sgblack@eecs.umich.edu        bool _uwe()  const { return (entry >> 13) & 0x1; }
782984Sgblack@eecs.umich.edu        bool _kwe()  const { return (entry >> 12) & 0x1; }
792984Sgblack@eecs.umich.edu        int  _rsv1() const { return (entry >> 10) & 0x3; }
802984Sgblack@eecs.umich.edu        bool _ure()  const { return (entry >>  9) & 0x1; }
812984Sgblack@eecs.umich.edu        bool _kre()  const { return (entry >>  8) & 0x1; }
822984Sgblack@eecs.umich.edu        bool _nomb() const { return (entry >>  7) & 0x1; }
832984Sgblack@eecs.umich.edu        int  _gh()   const { return (entry >>  5) & 0x3; }
842984Sgblack@eecs.umich.edu        bool _asm()  const { return (entry >>  4) & 0x1; }
852984Sgblack@eecs.umich.edu        bool _foe()  const { return (entry >>  3) & 0x1; }
862984Sgblack@eecs.umich.edu        bool _fow()  const { return (entry >>  2) & 0x1; }
872984Sgblack@eecs.umich.edu        bool _for()  const { return (entry >>  1) & 0x1; }
882984Sgblack@eecs.umich.edu        bool valid() const { return (entry >>  0) & 0x1; }
892984Sgblack@eecs.umich.edu
902984Sgblack@eecs.umich.edu        Addr paddr() const { return _pfn() << PageShift; }
912984Sgblack@eecs.umich.edu    };
922984Sgblack@eecs.umich.edu
932984Sgblack@eecs.umich.edu    // ITB/DTB page table entry
942984Sgblack@eecs.umich.edu    struct PTE
952984Sgblack@eecs.umich.edu    {
962984Sgblack@eecs.umich.edu        Addr tag;			// virtual page number tag
972984Sgblack@eecs.umich.edu        Addr ppn;			// physical page number
982984Sgblack@eecs.umich.edu        uint8_t xre;		// read permissions - VMEM_PERM_* mask
992984Sgblack@eecs.umich.edu        uint8_t xwe;		// write permissions - VMEM_PERM_* mask
1002984Sgblack@eecs.umich.edu        uint8_t asn;		// address space number
1012984Sgblack@eecs.umich.edu        bool asma;			// address space match
1022984Sgblack@eecs.umich.edu        bool fonr;			// fault on read
1032984Sgblack@eecs.umich.edu        bool fonw;			// fault on write
1042984Sgblack@eecs.umich.edu        bool valid;			// valid page table entry
1052984Sgblack@eecs.umich.edu
1062984Sgblack@eecs.umich.edu        void serialize(std::ostream &os);
1072984Sgblack@eecs.umich.edu        void unserialize(Checkpoint *cp, const std::string &section);
1082984Sgblack@eecs.umich.edu    };
1092984Sgblack@eecs.umich.edu#endif
1102984Sgblack@eecs.umich.edu};
1112984Sgblack@eecs.umich.edu#endif // __ARCH_ALPHA_PAGETABLE_H__
1122984Sgblack@eecs.umich.edu
113