system.hh revision 10466
12567SN/A/* 210037SARM gem5 Developers * Copyright (c) 2010, 2012-2013 ARM Limited 37650SAli.Saidi@ARM.com * All rights reserved 47650SAli.Saidi@ARM.com * 57650SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall 67650SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual 77650SAli.Saidi@ARM.com * property including but not limited to intellectual property relating 87650SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software 97650SAli.Saidi@ARM.com * licensed hereunder. You may use the software subject to the license 107650SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated 117650SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software, 127650SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form. 137650SAli.Saidi@ARM.com * 142567SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 152567SN/A * All rights reserved. 162567SN/A * 172567SN/A * Redistribution and use in source and binary forms, with or without 182567SN/A * modification, are permitted provided that the following conditions are 192567SN/A * met: redistributions of source code must retain the above copyright 202567SN/A * notice, this list of conditions and the following disclaimer; 212567SN/A * redistributions in binary form must reproduce the above copyright 222567SN/A * notice, this list of conditions and the following disclaimer in the 232567SN/A * documentation and/or other materials provided with the distribution; 242567SN/A * neither the name of the copyright holders nor the names of its 252567SN/A * contributors may be used to endorse or promote products derived from 262567SN/A * this software without specific prior written permission. 272567SN/A * 282567SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292567SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302567SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312567SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322567SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332567SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342567SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352567SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362567SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372567SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382567SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392665SN/A * 402665SN/A * Authors: Ali Saidi 412567SN/A */ 422567SN/A 436757SAli.Saidi@ARM.com#ifndef __ARCH_ARM_SYSTEM_HH__ 446757SAli.Saidi@ARM.com#define __ARCH_ARM_SYSTEM_HH__ 452567SN/A 462567SN/A#include <string> 472567SN/A#include <vector> 482567SN/A 4910037SARM gem5 Developers#include "dev/arm/generic_timer.hh" 508229Snate@binkert.org#include "kern/linux/events.hh" 516757SAli.Saidi@ARM.com#include "params/ArmSystem.hh" 522567SN/A#include "sim/sim_object.hh" 532567SN/A#include "sim/system.hh" 542567SN/A 5510037SARM gem5 Developersclass ThreadContext; 5610037SARM gem5 Developers 576757SAli.Saidi@ARM.comclass ArmSystem : public System 582567SN/A{ 598285SPrakash.Ramrakhyani@arm.com protected: 607650SAli.Saidi@ARM.com /** 617650SAli.Saidi@ARM.com * PC based event to skip the dprink() call and emulate its 627650SAli.Saidi@ARM.com * functionality 637650SAli.Saidi@ARM.com */ 647650SAli.Saidi@ARM.com Linux::DebugPrintkEvent *debugPrintkEvent; 657650SAli.Saidi@ARM.com 668286SAli.Saidi@ARM.com /** 678286SAli.Saidi@ARM.com * Pointer to the bootloader object 688286SAli.Saidi@ARM.com */ 698286SAli.Saidi@ARM.com ObjectFile *bootldr; 708286SAli.Saidi@ARM.com 7110037SARM gem5 Developers /** 7210037SARM gem5 Developers * True if this system implements the Security Extensions 7310037SARM gem5 Developers */ 7410037SARM gem5 Developers const bool _haveSecurity; 7510037SARM gem5 Developers 7610037SARM gem5 Developers /** 7710037SARM gem5 Developers * True if this system implements the Large Physical Address Extension 7810037SARM gem5 Developers */ 7910037SARM gem5 Developers const bool _haveLPAE; 8010037SARM gem5 Developers 8110037SARM gem5 Developers /** 8210037SARM gem5 Developers * True if this system implements the virtualization Extensions 8310037SARM gem5 Developers */ 8410037SARM gem5 Developers const bool _haveVirtualization; 8510037SARM gem5 Developers 8610037SARM gem5 Developers /** 8710037SARM gem5 Developers * True if this system implements the Generic Timer extension 8810037SARM gem5 Developers */ 8910037SARM gem5 Developers const bool _haveGenericTimer; 9010037SARM gem5 Developers 9110037SARM gem5 Developers /** 9210037SARM gem5 Developers * Pointer to the Generic Timer wrapper. 9310037SARM gem5 Developers */ 9410037SARM gem5 Developers GenericTimer *_genericTimer; 9510037SARM gem5 Developers 9610037SARM gem5 Developers /** 9710037SARM gem5 Developers * True if the register width of the highest implemented exception level is 9810037SARM gem5 Developers * 64 bits (ARMv8) 9910037SARM gem5 Developers */ 10010037SARM gem5 Developers bool _highestELIs64; 10110037SARM gem5 Developers 10210037SARM gem5 Developers /** 10310037SARM gem5 Developers * Reset address if the highest implemented exception level is 64 bits 10410037SARM gem5 Developers * (ARMv8) 10510037SARM gem5 Developers */ 10610037SARM gem5 Developers const Addr _resetAddr64; 10710037SARM gem5 Developers 10810037SARM gem5 Developers /** 10910037SARM gem5 Developers * Supported physical address range in bits if the highest implemented 11010037SARM gem5 Developers * exception level is 64 bits (ARMv8) 11110037SARM gem5 Developers */ 11210037SARM gem5 Developers const uint8_t _physAddrRange64; 11310037SARM gem5 Developers 11410037SARM gem5 Developers /** 11510037SARM gem5 Developers * True if ASID is 16 bits in AArch64 (ARMv8) 11610037SARM gem5 Developers */ 11710037SARM gem5 Developers const bool _haveLargeAsid64; 11810037SARM gem5 Developers 1192567SN/A public: 1206757SAli.Saidi@ARM.com typedef ArmSystemParams Params; 1218286SAli.Saidi@ARM.com const Params * 1228286SAli.Saidi@ARM.com params() const 1238286SAli.Saidi@ARM.com { 1248286SAli.Saidi@ARM.com return dynamic_cast<const Params *>(_params); 1258286SAli.Saidi@ARM.com } 1268286SAli.Saidi@ARM.com 1276757SAli.Saidi@ARM.com ArmSystem(Params *p); 1286757SAli.Saidi@ARM.com ~ArmSystem(); 1298286SAli.Saidi@ARM.com 1308706Sandreas.hansson@arm.com /** 1318706Sandreas.hansson@arm.com * Initialise the system 1328706Sandreas.hansson@arm.com */ 1338706Sandreas.hansson@arm.com virtual void initState(); 1348286SAli.Saidi@ARM.com 1358527SAli.Saidi@ARM.com /** Check if an address should be uncacheable until all caches are enabled. 1368527SAli.Saidi@ARM.com * This exits because coherence on some addresses at boot is maintained via 1378527SAli.Saidi@ARM.com * sw coherence until the caches are enbaled. Since we don't support sw 1388527SAli.Saidi@ARM.com * coherence operations in gem5, this is a method that allows a system 1398527SAli.Saidi@ARM.com * type to designate certain addresses that should remain uncachebale 1408527SAli.Saidi@ARM.com * for a while. 1418527SAli.Saidi@ARM.com */ 1428527SAli.Saidi@ARM.com virtual bool adderBootUncacheable(Addr a) { return false; } 1438527SAli.Saidi@ARM.com 1443553SN/A virtual Addr fixFuncEventAddr(Addr addr) 1453553SN/A { 1467693SAli.Saidi@ARM.com // Remove the low bit that thumb symbols have set 1477693SAli.Saidi@ARM.com // but that aren't actually odd aligned 1487693SAli.Saidi@ARM.com if (addr & 0x1) 1497720Sgblack@eecs.umich.edu return addr & ~1; 1503553SN/A return addr; 1513553SN/A } 1529050Schander.sudanthi@arm.com 1539050Schander.sudanthi@arm.com /** true if this a multiprocessor system */ 1549050Schander.sudanthi@arm.com bool multiProc; 15510037SARM gem5 Developers 15610037SARM gem5 Developers /** Returns true if this system implements the Security Extensions */ 15710037SARM gem5 Developers bool haveSecurity() const { return _haveSecurity; } 15810037SARM gem5 Developers 15910037SARM gem5 Developers /** Returns true if this system implements the Large Physical Address 16010037SARM gem5 Developers * Extension */ 16110037SARM gem5 Developers bool haveLPAE() const { return _haveLPAE; } 16210037SARM gem5 Developers 16310037SARM gem5 Developers /** Returns true if this system implements the virtualization 16410037SARM gem5 Developers * Extensions 16510037SARM gem5 Developers */ 16610037SARM gem5 Developers bool haveVirtualization() const { return _haveVirtualization; } 16710037SARM gem5 Developers 16810037SARM gem5 Developers /** Returns true if this system implements the Generic Timer extension. */ 16910037SARM gem5 Developers bool haveGenericTimer() const { return _haveGenericTimer; } 17010037SARM gem5 Developers 17110037SARM gem5 Developers /** Sets the pointer to the Generic Timer. */ 17210037SARM gem5 Developers void setGenericTimer(GenericTimer *generic_timer) 17310037SARM gem5 Developers { 17410037SARM gem5 Developers _genericTimer = generic_timer; 17510037SARM gem5 Developers } 17610037SARM gem5 Developers 17710037SARM gem5 Developers /** Returns a pointer to the system counter. */ 17810037SARM gem5 Developers GenericTimer::SystemCounter *getSystemCounter() const; 17910037SARM gem5 Developers 18010037SARM gem5 Developers /** Returns a pointer to the appropriate architected timer. */ 18110037SARM gem5 Developers GenericTimer::ArchTimer *getArchTimer(int cpu_id) const; 18210037SARM gem5 Developers 18310037SARM gem5 Developers /** Returns true if the register width of the highest implemented exception 18410037SARM gem5 Developers * level is 64 bits (ARMv8) */ 18510037SARM gem5 Developers bool highestELIs64() const { return _highestELIs64; } 18610037SARM gem5 Developers 18710037SARM gem5 Developers /** Returns the highest implemented exception level */ 18810037SARM gem5 Developers ExceptionLevel highestEL() const 18910037SARM gem5 Developers { 19010037SARM gem5 Developers if (_haveSecurity) 19110037SARM gem5 Developers return EL3; 19210037SARM gem5 Developers // @todo: uncomment this to enable Virtualization 19310037SARM gem5 Developers // if (_haveVirtualization) 19410037SARM gem5 Developers // return EL2; 19510037SARM gem5 Developers return EL1; 19610037SARM gem5 Developers } 19710037SARM gem5 Developers 19810037SARM gem5 Developers /** Returns the reset address if the highest implemented exception level is 19910037SARM gem5 Developers * 64 bits (ARMv8) */ 20010037SARM gem5 Developers Addr resetAddr64() const { return _resetAddr64; } 20110037SARM gem5 Developers 20210037SARM gem5 Developers /** Returns true if ASID is 16 bits in AArch64 (ARMv8) */ 20310037SARM gem5 Developers bool haveLargeAsid64() const { return _haveLargeAsid64; } 20410037SARM gem5 Developers 20510037SARM gem5 Developers /** Returns the supported physical address range in bits if the highest 20610037SARM gem5 Developers * implemented exception level is 64 bits (ARMv8) */ 20710037SARM gem5 Developers uint8_t physAddrRange64() const { return _physAddrRange64; } 20810037SARM gem5 Developers 20910037SARM gem5 Developers /** Returns the supported physical address range in bits */ 21010037SARM gem5 Developers uint8_t physAddrRange() const 21110037SARM gem5 Developers { 21210037SARM gem5 Developers if (_highestELIs64) 21310037SARM gem5 Developers return _physAddrRange64; 21410037SARM gem5 Developers if (_haveLPAE) 21510037SARM gem5 Developers return 40; 21610037SARM gem5 Developers return 32; 21710037SARM gem5 Developers } 21810037SARM gem5 Developers 21910037SARM gem5 Developers /** Returns the physical address mask */ 22010037SARM gem5 Developers Addr physAddrMask() const 22110037SARM gem5 Developers { 22210037SARM gem5 Developers return mask(physAddrRange()); 22310037SARM gem5 Developers } 22410037SARM gem5 Developers 22510037SARM gem5 Developers /** Returns true if the system of a specific thread context implements the 22610037SARM gem5 Developers * Security Extensions 22710037SARM gem5 Developers */ 22810037SARM gem5 Developers static bool haveSecurity(ThreadContext *tc); 22910037SARM gem5 Developers 23010037SARM gem5 Developers /** Returns true if the system of a specific thread context implements the 23110037SARM gem5 Developers * virtualization Extensions 23210037SARM gem5 Developers */ 23310037SARM gem5 Developers static bool haveVirtualization(ThreadContext *tc); 23410037SARM gem5 Developers 23510037SARM gem5 Developers /** Returns true if the system of a specific thread context implements the 23610037SARM gem5 Developers * Large Physical Address Extension 23710037SARM gem5 Developers */ 23810037SARM gem5 Developers static bool haveLPAE(ThreadContext *tc); 23910037SARM gem5 Developers 24010037SARM gem5 Developers /** Returns true if the register width of the highest implemented exception 24110037SARM gem5 Developers * level for the system of a specific thread context is 64 bits (ARMv8) 24210037SARM gem5 Developers */ 24310037SARM gem5 Developers static bool highestELIs64(ThreadContext *tc); 24410037SARM gem5 Developers 24510037SARM gem5 Developers /** Returns the highest implemented exception level for the system of a 24610037SARM gem5 Developers * specific thread context 24710037SARM gem5 Developers */ 24810037SARM gem5 Developers static ExceptionLevel highestEL(ThreadContext *tc); 24910037SARM gem5 Developers 25010037SARM gem5 Developers /** Returns the reset address if the highest implemented exception level for 25110037SARM gem5 Developers * the system of a specific thread context is 64 bits (ARMv8) 25210037SARM gem5 Developers */ 25310037SARM gem5 Developers static Addr resetAddr64(ThreadContext *tc); 25410037SARM gem5 Developers 25510037SARM gem5 Developers /** Returns the supported physical address range in bits for the system of a 25610037SARM gem5 Developers * specific thread context 25710037SARM gem5 Developers */ 25810037SARM gem5 Developers static uint8_t physAddrRange(ThreadContext *tc); 25910037SARM gem5 Developers 26010037SARM gem5 Developers /** Returns the physical address mask for the system of a specific thread 26110037SARM gem5 Developers * context 26210037SARM gem5 Developers */ 26310037SARM gem5 Developers static Addr physAddrMask(ThreadContext *tc); 26410037SARM gem5 Developers 26510037SARM gem5 Developers /** Returns true if ASID is 16 bits for the system of a specific thread 26610037SARM gem5 Developers * context while in AArch64 (ARMv8) */ 26710037SARM gem5 Developers static bool haveLargeAsid64(ThreadContext *tc); 26810037SARM gem5 Developers 2692567SN/A}; 2702567SN/A 2712567SN/A#endif 2722567SN/A 273