114039Sstacze01@arm.com/*
214039Sstacze01@arm.com * Copyright (c) 2013, 2018-2019 ARM Limited
314039Sstacze01@arm.com * All rights reserved
414039Sstacze01@arm.com *
514039Sstacze01@arm.com * The license below extends only to copyright in the software and shall
614039Sstacze01@arm.com * not be construed as granting a license to any other intellectual
714039Sstacze01@arm.com * property including but not limited to intellectual property relating
814039Sstacze01@arm.com * to a hardware implementation of the functionality of the software
914039Sstacze01@arm.com * licensed hereunder.  You may use the software subject to the license
1014039Sstacze01@arm.com * terms below provided that you ensure that this notice is replicated
1114039Sstacze01@arm.com * unmodified and in its entirety in all distributions of the software,
1214039Sstacze01@arm.com * modified or unmodified, in source code or in binary form.
1314039Sstacze01@arm.com *
1414039Sstacze01@arm.com * Redistribution and use in source and binary forms, with or without
1514039Sstacze01@arm.com * modification, are permitted provided that the following conditions are
1614039Sstacze01@arm.com * met: redistributions of source code must retain the above copyright
1714039Sstacze01@arm.com * notice, this list of conditions and the following disclaimer;
1814039Sstacze01@arm.com * redistributions in binary form must reproduce the above copyright
1914039Sstacze01@arm.com * notice, this list of conditions and the following disclaimer in the
2014039Sstacze01@arm.com * documentation and/or other materials provided with the distribution;
2114039Sstacze01@arm.com * neither the name of the copyright holders nor the names of its
2214039Sstacze01@arm.com * contributors may be used to endorse or promote products derived from
2314039Sstacze01@arm.com * this software without specific prior written permission.
2414039Sstacze01@arm.com *
2514039Sstacze01@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2614039Sstacze01@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2714039Sstacze01@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2814039Sstacze01@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2914039Sstacze01@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3014039Sstacze01@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3114039Sstacze01@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3214039Sstacze01@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3314039Sstacze01@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3414039Sstacze01@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3514039Sstacze01@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3614039Sstacze01@arm.com *
3714039Sstacze01@arm.com * Authors: Stan Czerniawski
3814039Sstacze01@arm.com */
3914039Sstacze01@arm.com
4014039Sstacze01@arm.com#ifndef __DEV_ARM_SMMU_V3_PTOPS_HH__
4114039Sstacze01@arm.com#define __DEV_ARM_SMMU_V3_PTOPS_HH__
4214039Sstacze01@arm.com
4314039Sstacze01@arm.com#include <stdint.h>
4414039Sstacze01@arm.com
4514039Sstacze01@arm.com#include "base/types.hh"
4614039Sstacze01@arm.com
4714039Sstacze01@arm.comstruct PageTableOps
4814039Sstacze01@arm.com{
4914039Sstacze01@arm.com    typedef int64_t pte_t;
5014039Sstacze01@arm.com
5114039Sstacze01@arm.com    virtual bool isValid(pte_t pte, unsigned level) const = 0;
5214039Sstacze01@arm.com    virtual bool isLeaf(pte_t pte, unsigned level) const = 0;
5314039Sstacze01@arm.com    virtual bool isWritable(pte_t pte, unsigned level, bool stage2) const = 0;
5414039Sstacze01@arm.com    virtual Addr nextLevelPointer(pte_t pte, unsigned level) const = 0;
5514039Sstacze01@arm.com    virtual Addr index(Addr va, unsigned level) const = 0;
5614039Sstacze01@arm.com    virtual Addr pageMask(pte_t pte, unsigned level) const = 0;
5714039Sstacze01@arm.com    virtual Addr walkMask(unsigned level) const = 0;
5814100Sgiacomo.travaglini@arm.com    virtual unsigned firstLevel(uint8_t tsz) const = 0;
5914039Sstacze01@arm.com    virtual unsigned lastLevel() const = 0;
6014039Sstacze01@arm.com};
6114039Sstacze01@arm.com
6214039Sstacze01@arm.comstruct V7LPageTableOps : public PageTableOps
6314039Sstacze01@arm.com{
6414099Sgiacomo.travaglini@arm.com    bool isValid(pte_t pte, unsigned level) const override;
6514099Sgiacomo.travaglini@arm.com    bool isLeaf(pte_t pte, unsigned level) const override;
6614099Sgiacomo.travaglini@arm.com    bool isWritable(pte_t pte, unsigned level, bool stage2) const override;
6714099Sgiacomo.travaglini@arm.com    Addr nextLevelPointer(pte_t pte, unsigned level) const override;
6814099Sgiacomo.travaglini@arm.com    Addr index(Addr va, unsigned level) const override;
6914099Sgiacomo.travaglini@arm.com    Addr pageMask(pte_t pte, unsigned level) const override;
7014099Sgiacomo.travaglini@arm.com    Addr walkMask(unsigned level) const override;
7114100Sgiacomo.travaglini@arm.com    unsigned firstLevel(uint8_t tsz) const override;
7214099Sgiacomo.travaglini@arm.com    unsigned lastLevel() const override;
7314039Sstacze01@arm.com};
7414039Sstacze01@arm.com
7514039Sstacze01@arm.comstruct V8PageTableOps4k : public PageTableOps
7614039Sstacze01@arm.com{
7714099Sgiacomo.travaglini@arm.com    bool isValid(pte_t pte, unsigned level) const override;
7814099Sgiacomo.travaglini@arm.com    bool isLeaf(pte_t pte, unsigned level) const override;
7914099Sgiacomo.travaglini@arm.com    bool isWritable(pte_t pte, unsigned level, bool stage2) const override;
8014099Sgiacomo.travaglini@arm.com    Addr nextLevelPointer(pte_t pte, unsigned level) const override;
8114099Sgiacomo.travaglini@arm.com    Addr index(Addr va, unsigned level) const override;
8214099Sgiacomo.travaglini@arm.com    Addr pageMask(pte_t pte, unsigned level) const override;
8314099Sgiacomo.travaglini@arm.com    Addr walkMask(unsigned level) const override;
8414100Sgiacomo.travaglini@arm.com    unsigned firstLevel(uint8_t tsz) const override;
8514099Sgiacomo.travaglini@arm.com    unsigned lastLevel() const override;
8614039Sstacze01@arm.com};
8714039Sstacze01@arm.com
8814098Smichiel.vantol@arm.comstruct V8PageTableOps16k : public PageTableOps
8914098Smichiel.vantol@arm.com{
9014099Sgiacomo.travaglini@arm.com    bool isValid(pte_t pte, unsigned level) const override;
9114099Sgiacomo.travaglini@arm.com    bool isLeaf(pte_t pte, unsigned level) const override;
9214099Sgiacomo.travaglini@arm.com    bool isWritable(pte_t pte, unsigned level, bool stage2) const override;
9314099Sgiacomo.travaglini@arm.com    Addr nextLevelPointer(pte_t pte, unsigned level) const override;
9414099Sgiacomo.travaglini@arm.com    Addr index(Addr va, unsigned level) const override;
9514099Sgiacomo.travaglini@arm.com    Addr pageMask(pte_t pte, unsigned level) const override;
9614099Sgiacomo.travaglini@arm.com    Addr walkMask(unsigned level) const override;
9714100Sgiacomo.travaglini@arm.com    unsigned firstLevel(uint8_t tsz) const override;
9814099Sgiacomo.travaglini@arm.com    unsigned lastLevel() const override;
9914098Smichiel.vantol@arm.com};
10014098Smichiel.vantol@arm.com
10114039Sstacze01@arm.comstruct V8PageTableOps64k : public PageTableOps
10214039Sstacze01@arm.com{
10314099Sgiacomo.travaglini@arm.com    bool isValid(pte_t pte, unsigned level) const override;
10414099Sgiacomo.travaglini@arm.com    bool isLeaf(pte_t pte, unsigned level) const override;
10514099Sgiacomo.travaglini@arm.com    bool isWritable(pte_t pte, unsigned level, bool stage2) const override;
10614099Sgiacomo.travaglini@arm.com    Addr nextLevelPointer(pte_t pte, unsigned level) const override;
10714099Sgiacomo.travaglini@arm.com    Addr index(Addr va, unsigned level) const override;
10814099Sgiacomo.travaglini@arm.com    Addr pageMask(pte_t pte, unsigned level) const override;
10914099Sgiacomo.travaglini@arm.com    Addr walkMask(unsigned level) const override;
11014100Sgiacomo.travaglini@arm.com    unsigned firstLevel(uint8_t tsz) const override;
11114099Sgiacomo.travaglini@arm.com    unsigned lastLevel() const override;
11214039Sstacze01@arm.com};
11314039Sstacze01@arm.com
11414039Sstacze01@arm.com#endif /* __DEV_ARM_SMMU_V3_PTOPS_HH__ */
115