pagetable.hh revision 7436:b578349f9371
16019Shines@cs.fsu.edu/*
210037SARM gem5 Developers * Copyright (c) 2010 ARM Limited
37158Sgblack@eecs.umich.edu * All rights reserved
47158Sgblack@eecs.umich.edu *
57158Sgblack@eecs.umich.edu * The license below extends only to copyright in the software and shall
67158Sgblack@eecs.umich.edu * not be construed as granting a license to any other intellectual
77158Sgblack@eecs.umich.edu * property including but not limited to intellectual property relating
87158Sgblack@eecs.umich.edu * to a hardware implementation of the functionality of the software
97158Sgblack@eecs.umich.edu * licensed hereunder.  You may use the software subject to the license
107158Sgblack@eecs.umich.edu * terms below provided that you ensure that this notice is replicated
117158Sgblack@eecs.umich.edu * unmodified and in its entirety in all distributions of the software,
127158Sgblack@eecs.umich.edu * modified or unmodified, in source code or in binary form.
137158Sgblack@eecs.umich.edu *
146019Shines@cs.fsu.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan
156019Shines@cs.fsu.edu * All rights reserved.
166019Shines@cs.fsu.edu *
176019Shines@cs.fsu.edu * Redistribution and use in source and binary forms, with or without
186019Shines@cs.fsu.edu * modification, are permitted provided that the following conditions are
196019Shines@cs.fsu.edu * met: redistributions of source code must retain the above copyright
206019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer;
216019Shines@cs.fsu.edu * redistributions in binary form must reproduce the above copyright
226019Shines@cs.fsu.edu * notice, this list of conditions and the following disclaimer in the
236019Shines@cs.fsu.edu * documentation and/or other materials provided with the distribution;
246019Shines@cs.fsu.edu * neither the name of the copyright holders nor the names of its
256019Shines@cs.fsu.edu * contributors may be used to endorse or promote products derived from
266019Shines@cs.fsu.edu * this software without specific prior written permission.
276019Shines@cs.fsu.edu *
286019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
296019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
306019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
316019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
326019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
336019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
346019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
356019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
366019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
376019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
386019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
396019Shines@cs.fsu.edu *
406019Shines@cs.fsu.edu * Authors: Ali Saidi
416019Shines@cs.fsu.edu */
426019Shines@cs.fsu.edu
436019Shines@cs.fsu.edu#ifndef __ARCH_ARM_PAGETABLE_H__
446019Shines@cs.fsu.edu#define __ARCH_ARM_PAGETABLE_H__
456019Shines@cs.fsu.edu
466019Shines@cs.fsu.edu#include "arch/arm/isa_traits.hh"
476019Shines@cs.fsu.edu#include "arch/arm/utility.hh"
486019Shines@cs.fsu.edu#include "arch/arm/vtophys.hh"
496214Snate@binkert.org#include "config/full_system.hh"
508542Sgblack@eecs.umich.edu
516019Shines@cs.fsu.edunamespace ArmISA {
527811Ssteve.reinhardt@amd.com
536019Shines@cs.fsu.edustruct VAddr
546019Shines@cs.fsu.edu{
556019Shines@cs.fsu.edu    VAddr(Addr a) { panic("not implemented yet."); }
566019Shines@cs.fsu.edu};
576019Shines@cs.fsu.edu
586019Shines@cs.fsu.edu
596019Shines@cs.fsu.edu// ITB/DTB page table entry
606019Shines@cs.fsu.edustruct PTE
616019Shines@cs.fsu.edu{
626019Shines@cs.fsu.edu    void serialize(std::ostream &os)
636019Shines@cs.fsu.edu    {
646019Shines@cs.fsu.edu        panic("Need to implement PTE serialization\n");
656019Shines@cs.fsu.edu    }
666019Shines@cs.fsu.edu
676019Shines@cs.fsu.edu    void unserialize(Checkpoint *cp, const std::string &section)
686019Shines@cs.fsu.edu    {
696019Shines@cs.fsu.edu        panic("Need to implement PTE serialization\n");
706019Shines@cs.fsu.edu    }
716019Shines@cs.fsu.edu
726019Shines@cs.fsu.edu};
736019Shines@cs.fsu.edu
746019Shines@cs.fsu.edustruct TlbRange
756019Shines@cs.fsu.edu{
766019Shines@cs.fsu.edu    Addr va;
776019Shines@cs.fsu.edu    Addr size;
786019Shines@cs.fsu.edu    int contextId;
796019Shines@cs.fsu.edu    bool global;
806019Shines@cs.fsu.edu
816019Shines@cs.fsu.edu    inline bool
826019Shines@cs.fsu.edu    operator<(const TlbRange &r2) const
836019Shines@cs.fsu.edu    {
846019Shines@cs.fsu.edu        if (!(global || r2.global)) {
856019Shines@cs.fsu.edu            if (contextId < r2.contextId)
866019Shines@cs.fsu.edu                return true;
876019Shines@cs.fsu.edu            else if (contextId > r2.contextId)
886019Shines@cs.fsu.edu                return false;
896019Shines@cs.fsu.edu        }
906019Shines@cs.fsu.edu
916019Shines@cs.fsu.edu        if (va < r2.va)
926019Shines@cs.fsu.edu            return true;
936019Shines@cs.fsu.edu        return false;
946019Shines@cs.fsu.edu    }
956019Shines@cs.fsu.edu
966019Shines@cs.fsu.edu    inline bool
976019Shines@cs.fsu.edu    operator==(const TlbRange &r2) const
9810037SARM gem5 Developers    {
9910037SARM gem5 Developers        return va == r2.va &&
10010037SARM gem5 Developers               size == r2.size &&
1019057SAli.Saidi@ARM.com               contextId == r2.contextId &&
1029057SAli.Saidi@ARM.com               global == r2.global;
1036019Shines@cs.fsu.edu    }
1047799Sgblack@eecs.umich.edu};
1056019Shines@cs.fsu.edu
1066019Shines@cs.fsu.edu
1077400SAli.Saidi@ARM.com// ITB/DTB table entry
1086019Shines@cs.fsu.edustruct TlbEntry
1096019Shines@cs.fsu.edu{
1106019Shines@cs.fsu.edu  public:
1116019Shines@cs.fsu.edu    enum MemoryType {
1126019Shines@cs.fsu.edu        StronglyOrdered,
1136019Shines@cs.fsu.edu        Device,
1146735Sgblack@eecs.umich.edu        Normal
1156735Sgblack@eecs.umich.edu    };
1166974Stjones1@inf.ed.ac.uk    enum DomainType {
1176974Stjones1@inf.ed.ac.uk        DomainNoAccess = 0,
1187654Sminkyu.jeong@arm.com        DomainClient,
1197349SAli.Saidi@ARM.com        DomainReserved,
1209329Sdam.sunwoo@arm.com        DomainManager
1219329Sdam.sunwoo@arm.com    };
1229329Sdam.sunwoo@arm.com
1237400SAli.Saidi@ARM.com    // Matching variables
1247400SAli.Saidi@ARM.com    Addr pfn;
1257400SAli.Saidi@ARM.com    Addr size;              // Size of this entry, == Type of TLB Rec
1267400SAli.Saidi@ARM.com    Addr vpn;               // Virtual Page Number
1277400SAli.Saidi@ARM.com    uint32_t asid;          // Address Space Identifier
1287400SAli.Saidi@ARM.com    uint8_t N;              // Number of bits in pagesize
1298518Sgeoffrey.blake@arm.com    bool global;
13010037SARM gem5 Developers    bool valid;
13110037SARM gem5 Developers
1327400SAli.Saidi@ARM.com    // Type of memory
1337400SAli.Saidi@ARM.com    bool nonCacheable;     // Can we wrap this in mtype?
1347811Ssteve.reinhardt@amd.com    bool sNp;      // Section descriptor
1356019Shines@cs.fsu.edu
1366019Shines@cs.fsu.edu    // Memory Attributes
1376019Shines@cs.fsu.edu    MemoryType mtype;
1386019Shines@cs.fsu.edu    uint8_t innerAttrs;
139    uint8_t outerAttrs;
140    bool shareable;
141    uint32_t attributes;    // Memory attributes formatted for PAR
142
143
144    // Access permissions
145    bool xn;                // Execute Never
146    uint8_t ap:3;           // Access permissions bits
147    uint8_t domain:4;       // Access Domain
148
149    TlbRange range;         // For fast TLB searching
150
151    //Construct an entry that maps to physical address addr for SE mode
152    TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr)
153    {
154        pfn = _paddr >> PageShift;
155        size = PageBytes - 1;
156        asid = _asn;
157        global = false;
158        valid = true;
159
160        vpn = _vaddr >> PageShift;
161
162        nonCacheable = sNp = false;
163
164        xn = 0;
165        ap = 0; // ???
166        domain = DomainClient; //???
167    }
168
169    TlbEntry()
170    {}
171
172    void
173    updateVaddr(Addr new_vaddr)
174    {
175        vpn = new_vaddr >> PageShift;
176    }
177
178    Addr
179    pageStart()
180    {
181        return pfn << PageShift;
182    }
183
184    bool
185    match(Addr va, uint8_t cid)
186    {
187        Addr v = vpn << N;
188        if (valid && va >= v && va <= v + size && (global || cid == asid))
189            return true;
190        return false;
191    }
192
193    Addr
194    pAddr(Addr va)
195    {
196        return (pfn << N) | (va & size);
197    }
198
199    void serialize(std::ostream &os) { panic("Need to Implement\n"); }
200    void unserialize(Checkpoint *cp, const std::string &section)
201                   { panic("Need to Implement\n");}
202};
203
204
205
206};
207#endif // __ARCH_ARM_PAGETABLE_H__
208
209