ArmSystem.py revision 13396:23277eaae855
111375Sandreas.hansson@arm.com# Copyright (c) 2009, 2012-2013, 2015-2018 ARM Limited 211375Sandreas.hansson@arm.com# All rights reserved. 311375Sandreas.hansson@arm.com# 411375Sandreas.hansson@arm.com# The license below extends only to copyright in the software and shall 511375Sandreas.hansson@arm.com# not be construed as granting a license to any other intellectual 611375Sandreas.hansson@arm.com# property including but not limited to intellectual property relating 711375Sandreas.hansson@arm.com# to a hardware implementation of the functionality of the software 811375Sandreas.hansson@arm.com# licensed hereunder. You may use the software subject to the license 911375Sandreas.hansson@arm.com# terms below provided that you ensure that this notice is replicated 1011375Sandreas.hansson@arm.com# unmodified and in its entirety in all distributions of the software, 1111375Sandreas.hansson@arm.com# modified or unmodified, in source code or in binary form. 1211375Sandreas.hansson@arm.com# 1311375Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 1411375Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 1511375Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 1611375Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 1711375Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 1811375Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 1911375Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 2011375Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 2111375Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from 2211375Sandreas.hansson@arm.com# this software without specific prior written permission. 2311375Sandreas.hansson@arm.com# 2411375Sandreas.hansson@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2511375Sandreas.hansson@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2611375Sandreas.hansson@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2711375Sandreas.hansson@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2811375Sandreas.hansson@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2911375Sandreas.hansson@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3011375Sandreas.hansson@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3111375Sandreas.hansson@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3211375Sandreas.hansson@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3311375Sandreas.hansson@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3411375Sandreas.hansson@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3511375Sandreas.hansson@arm.com# 3611375Sandreas.hansson@arm.com# Authors: Ali Saidi 3711375Sandreas.hansson@arm.com# Glenn Bergmans 3811375Sandreas.hansson@arm.com 3911375Sandreas.hansson@arm.comfrom m5.params import * 4011375Sandreas.hansson@arm.comfrom m5.SimObject import * 4111375Sandreas.hansson@arm.comfrom m5.util.fdthelper import * 4211375Sandreas.hansson@arm.com 4311375Sandreas.hansson@arm.comfrom System import System 4411375Sandreas.hansson@arm.comfrom ArmSemihosting import ArmSemihosting 4511375Sandreas.hansson@arm.com 4611375Sandreas.hansson@arm.comclass ArmMachineType(Enum): 4711375Sandreas.hansson@arm.com map = { 4811375Sandreas.hansson@arm.com 'RealViewPBX' : 1901, 4911375Sandreas.hansson@arm.com 'VExpress_EMM' : 2272, 5011375Sandreas.hansson@arm.com 'VExpress_EMM64' : 2272, 5111375Sandreas.hansson@arm.com 'DTOnly' : -1, 5212727Snikos.nikoleris@arm.com } 5311375Sandreas.hansson@arm.com 5411375Sandreas.hansson@arm.comclass ArmSystem(System): 5512724Snikos.nikoleris@arm.com type = 'ArmSystem' 5611375Sandreas.hansson@arm.com cxx_header = "arch/arm/system.hh" 5711375Sandreas.hansson@arm.com multi_proc = Param.Bool(True, "Multiprocessor system?") 5811375Sandreas.hansson@arm.com boot_loader = VectorParam.String([], 5911375Sandreas.hansson@arm.com "File that contains the boot loader code. Zero or more files may be " 6011375Sandreas.hansson@arm.com "specified. The first boot loader that matches the kernel's " 6111375Sandreas.hansson@arm.com "architecture will be used.") 6211375Sandreas.hansson@arm.com gic_cpu_addr = Param.Addr(0, "Addres of the GIC CPU interface") 6311375Sandreas.hansson@arm.com flags_addr = Param.Addr(0, "Address of the flags register for MP booting") 6411375Sandreas.hansson@arm.com have_security = Param.Bool(False, 6511375Sandreas.hansson@arm.com "True if Security Extensions are implemented") 6611375Sandreas.hansson@arm.com have_virtualization = Param.Bool(False, 6711375Sandreas.hansson@arm.com "True if Virtualization Extensions are implemented") 6811375Sandreas.hansson@arm.com have_crypto = Param.Bool(False, 6911375Sandreas.hansson@arm.com "True if Crypto Extensions is implemented") 7011375Sandreas.hansson@arm.com have_lpae = Param.Bool(True, "True if LPAE is implemented") 7111375Sandreas.hansson@arm.com reset_addr = Param.Addr(0x0, 7211375Sandreas.hansson@arm.com "Reset address (ARMv8)") 7311375Sandreas.hansson@arm.com auto_reset_addr = Param.Bool(False, 7411375Sandreas.hansson@arm.com "Determine reset address from kernel entry point if no boot loader") 7511375Sandreas.hansson@arm.com highest_el_is_64 = Param.Bool(False, 7611375Sandreas.hansson@arm.com "True if the register width of the highest implemented exception level " 7711375Sandreas.hansson@arm.com "is 64 bits (ARMv8)") 7811375Sandreas.hansson@arm.com phys_addr_range_64 = Param.UInt8(40, 7913859Sodanrc@yahoo.com.br "Supported physical address range in bits when using AArch64 (ARMv8)") 8013859Sodanrc@yahoo.com.br have_large_asid_64 = Param.Bool(False, 8113859Sodanrc@yahoo.com.br "True if ASID is 16 bits in AArch64 (ARMv8)") 8213859Sodanrc@yahoo.com.br 8313859Sodanrc@yahoo.com.br semihosting = Param.ArmSemihosting(NULL, 8413859Sodanrc@yahoo.com.br "Enable support for the Arm semihosting by settings this parameter") 8513859Sodanrc@yahoo.com.br 8613859Sodanrc@yahoo.com.br m5ops_base = Param.Addr(0, 8713859Sodanrc@yahoo.com.br "Base of the 64KiB PA range used for memory-mapped m5ops. Set to 0 " 8813859Sodanrc@yahoo.com.br "to disable.") 8913859Sodanrc@yahoo.com.br 9013859Sodanrc@yahoo.com.br def generateDeviceTree(self, state): 9113859Sodanrc@yahoo.com.br # Generate a device tree root node for the system by creating the root 9213859Sodanrc@yahoo.com.br # node and adding the generated subnodes of all children. 9313859Sodanrc@yahoo.com.br # When a child needs to add multiple nodes, this is done by also 9413859Sodanrc@yahoo.com.br # creating a node called '/' which will then be merged with the 9513859Sodanrc@yahoo.com.br # root instead of appended. 9613859Sodanrc@yahoo.com.br 9713859Sodanrc@yahoo.com.br def generateMemNode(mem_range): 9813859Sodanrc@yahoo.com.br node = FdtNode("memory@%x" % long(mem_range.start)) 9913859Sodanrc@yahoo.com.br node.append(FdtPropertyStrings("device_type", ["memory"])) 10013859Sodanrc@yahoo.com.br node.append(FdtPropertyWords("reg", 10113859Sodanrc@yahoo.com.br state.addrCells(mem_range.start) + 10213859Sodanrc@yahoo.com.br state.sizeCells(mem_range.size()) )) 10313859Sodanrc@yahoo.com.br return node 10413859Sodanrc@yahoo.com.br 10513859Sodanrc@yahoo.com.br root = FdtNode('/') 10611375Sandreas.hansson@arm.com root.append(state.addrCellsProperty()) 10711375Sandreas.hansson@arm.com root.append(state.sizeCellsProperty()) 10811375Sandreas.hansson@arm.com 10911375Sandreas.hansson@arm.com # Add memory nodes 11011375Sandreas.hansson@arm.com for mem_range in self.mem_ranges: 11111375Sandreas.hansson@arm.com root.append(generateMemNode(mem_range)) 11211375Sandreas.hansson@arm.com 11311375Sandreas.hansson@arm.com for node in self.recurseDeviceTree(state): 11411375Sandreas.hansson@arm.com # Merge root nodes instead of adding them (for children 11511375Sandreas.hansson@arm.com # that need to add multiple root level nodes) 11611375Sandreas.hansson@arm.com if node.get_name() == root.get_name(): 11711375Sandreas.hansson@arm.com root.merge(node) 11811375Sandreas.hansson@arm.com else: 11911375Sandreas.hansson@arm.com root.append(node) 12011375Sandreas.hansson@arm.com 12111375Sandreas.hansson@arm.com return root 12213861Sodanrc@yahoo.com.br 12313861Sodanrc@yahoo.com.brclass GenericArmSystem(ArmSystem): 12413861Sodanrc@yahoo.com.br type = 'GenericArmSystem' 12511375Sandreas.hansson@arm.com cxx_header = "arch/arm/system.hh" 12611375Sandreas.hansson@arm.com machine_type = Param.ArmMachineType('DTOnly', 12711375Sandreas.hansson@arm.com "Machine id from http://www.arm.linux.org.uk/developer/machines/") 12811375Sandreas.hansson@arm.com atags_addr = Param.Addr("Address where default atags structure should " \ 12911375Sandreas.hansson@arm.com "be written") 13013861Sodanrc@yahoo.com.br dtb_filename = Param.String("", 13113861Sodanrc@yahoo.com.br "File that contains the Device Tree Blob. Don't use DTB if empty.") 13213861Sodanrc@yahoo.com.br early_kernel_symbols = Param.Bool(False, 13313861Sodanrc@yahoo.com.br "enable early kernel symbol tables before MMU") 13413861Sodanrc@yahoo.com.br enable_context_switch_stats_dump = Param.Bool(False, "enable stats/task info dumping at context switch boundaries") 13513861Sodanrc@yahoo.com.br 13613861Sodanrc@yahoo.com.br panic_on_panic = Param.Bool(False, "Trigger a gem5 panic if the " \ 13713861Sodanrc@yahoo.com.br "guest kernel panics") 13813861Sodanrc@yahoo.com.br panic_on_oops = Param.Bool(False, "Trigger a gem5 panic if the " \ 13913861Sodanrc@yahoo.com.br "guest kernel oopses") 14013861Sodanrc@yahoo.com.br 14113861Sodanrc@yahoo.com.brclass LinuxArmSystem(GenericArmSystem): 14213861Sodanrc@yahoo.com.br type = 'LinuxArmSystem' 14313861Sodanrc@yahoo.com.br cxx_header = "arch/arm/linux/system.hh" 14413861Sodanrc@yahoo.com.br 14513861Sodanrc@yahoo.com.br @cxxMethod 14613861Sodanrc@yahoo.com.br def dumpDmesg(self): 14713861Sodanrc@yahoo.com.br """Dump dmesg from the simulated kernel to standard out""" 14813861Sodanrc@yahoo.com.br pass 14913861Sodanrc@yahoo.com.br 15013861Sodanrc@yahoo.com.br # Have Linux systems for ARM auto-calc their load_addr_mask for proper 15113861Sodanrc@yahoo.com.br # kernel relocation. 15213861Sodanrc@yahoo.com.br load_addr_mask = 0x0 15313861Sodanrc@yahoo.com.br 15413861Sodanrc@yahoo.com.brclass FreebsdArmSystem(GenericArmSystem): 15513861Sodanrc@yahoo.com.br type = 'FreebsdArmSystem' 15613861Sodanrc@yahoo.com.br cxx_header = "arch/arm/freebsd/system.hh" 15711375Sandreas.hansson@arm.com