RealView.py revision 11841:16dec978b549
112837Sgabeblack@google.com# Copyright (c) 2009-2017 ARM Limited 212837Sgabeblack@google.com# All rights reserved. 312837Sgabeblack@google.com# 412837Sgabeblack@google.com# The license below extends only to copyright in the software and shall 512837Sgabeblack@google.com# not be construed as granting a license to any other intellectual 612837Sgabeblack@google.com# property including but not limited to intellectual property relating 712837Sgabeblack@google.com# to a hardware implementation of the functionality of the software 812837Sgabeblack@google.com# licensed hereunder. You may use the software subject to the license 912837Sgabeblack@google.com# terms below provided that you ensure that this notice is replicated 1012837Sgabeblack@google.com# unmodified and in its entirety in all distributions of the software, 1112837Sgabeblack@google.com# modified or unmodified, in source code or in binary form. 1212837Sgabeblack@google.com# 1312837Sgabeblack@google.com# Copyright (c) 2006-2007 The Regents of The University of Michigan 1412837Sgabeblack@google.com# All rights reserved. 1512837Sgabeblack@google.com# 1612837Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 1712837Sgabeblack@google.com# modification, are permitted provided that the following conditions are 1812837Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 1912837Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 2012837Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 2112837Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 2212837Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 2312837Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 2412837Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 2512837Sgabeblack@google.com# this software without specific prior written permission. 2612837Sgabeblack@google.com# 2712837Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2812837Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2912837Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3012901Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3112901Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3212901Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3312837Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3412982Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3512951Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3612953Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3712837Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3812951Sgabeblack@google.com# 3912837Sgabeblack@google.com# Authors: Ali Saidi 4012952Sgabeblack@google.com# Gabe Black 4112952Sgabeblack@google.com# William Wang 4212952Sgabeblack@google.com 4312952Sgabeblack@google.comfrom m5.params import * 4412952Sgabeblack@google.comfrom m5.proxy import * 4512952Sgabeblack@google.comfrom ClockDomain import ClockDomain 4612993Sgabeblack@google.comfrom VoltageDomain import VoltageDomain 4712993Sgabeblack@google.comfrom Device import BasicPioDevice, PioDevice, IsaFake, BadAddr, DmaDevice 4812993Sgabeblack@google.comfrom PciHost import * 4912952Sgabeblack@google.comfrom Ethernet import NSGigE, IGbE_igb, IGbE_e1000 5012952Sgabeblack@google.comfrom Ide import * 5112952Sgabeblack@google.comfrom Platform import Platform 5212952Sgabeblack@google.comfrom Terminal import Terminal 5312952Sgabeblack@google.comfrom Uart import Uart 5412993Sgabeblack@google.comfrom SimpleMemory import SimpleMemory 5512993Sgabeblack@google.comfrom Gic import * 5612993Sgabeblack@google.comfrom EnergyCtrl import EnergyCtrl 5712952Sgabeblack@google.comfrom ClockDomain import SrcClockDomain 5812952Sgabeblack@google.comfrom SubSystem import SubSystem 5912952Sgabeblack@google.com 6012952Sgabeblack@google.com# Platforms with KVM support should generally use in-kernel GIC 6112952Sgabeblack@google.com# emulation. Use a GIC model that automatically switches between 6212993Sgabeblack@google.com# gem5's GIC model and KVM's GIC model if KVM is available. 6312993Sgabeblack@google.comtry: 6413060Sgabeblack@google.com from KvmGic import MuxingKvmGic 6512993Sgabeblack@google.com kvm_gicv2_class = MuxingKvmGic 6612952Sgabeblack@google.comexcept ImportError: 6712952Sgabeblack@google.com # KVM support wasn't compiled into gem5. Fallback to a 6813035Sgabeblack@google.com # software-only GIC. 6913035Sgabeblack@google.com kvm_gicv2_class = Pl390 7012952Sgabeblack@google.com pass 7112952Sgabeblack@google.com 7212837Sgabeblack@google.comclass AmbaPioDevice(BasicPioDevice): 7312837Sgabeblack@google.com type = 'AmbaPioDevice' 7412837Sgabeblack@google.com abstract = True 7512951Sgabeblack@google.com cxx_header = "dev/arm/amba_device.hh" 7612951Sgabeblack@google.com amba_id = Param.UInt32("ID of AMBA device for kernel detection") 7712951Sgabeblack@google.com 7812837Sgabeblack@google.comclass AmbaIntDevice(AmbaPioDevice): 7912951Sgabeblack@google.com type = 'AmbaIntDevice' 8012951Sgabeblack@google.com abstract = True 8112951Sgabeblack@google.com cxx_header = "dev/arm/amba_device.hh" 8212837Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "Gic to use for interrupting") 8312837Sgabeblack@google.com int_num = Param.UInt32("Interrupt number that connects to GIC") 8412837Sgabeblack@google.com int_delay = Param.Latency("100ns", 8512982Sgabeblack@google.com "Time between action and interrupt generation by device") 8612837Sgabeblack@google.com 8712837Sgabeblack@google.comclass AmbaDmaDevice(DmaDevice): 8812837Sgabeblack@google.com type = 'AmbaDmaDevice' 8912837Sgabeblack@google.com abstract = True 9012837Sgabeblack@google.com cxx_header = "dev/arm/amba_device.hh" 9112837Sgabeblack@google.com pio_addr = Param.Addr("Address for AMBA slave interface") 9212837Sgabeblack@google.com pio_latency = Param.Latency("10ns", "Time between action and write/read result by AMBA DMA Device") 9312837Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "Gic to use for interrupting") 9412837Sgabeblack@google.com int_num = Param.UInt32("Interrupt number that connects to GIC") 9512837Sgabeblack@google.com amba_id = Param.UInt32("ID of AMBA device for kernel detection") 9612837Sgabeblack@google.com 9712837Sgabeblack@google.comclass A9SCU(BasicPioDevice): 9812837Sgabeblack@google.com type = 'A9SCU' 9912837Sgabeblack@google.com cxx_header = "dev/arm/a9scu.hh" 10012837Sgabeblack@google.com 10112837Sgabeblack@google.comclass ArmPciIntRouting(Enum): vals = [ 10212837Sgabeblack@google.com 'ARM_PCI_INT_STATIC', 10312837Sgabeblack@google.com 'ARM_PCI_INT_DEV', 10412837Sgabeblack@google.com 'ARM_PCI_INT_PIN', 10512837Sgabeblack@google.com ] 10612837Sgabeblack@google.com 10712837Sgabeblack@google.comclass GenericArmPciHost(GenericPciHost): 10812837Sgabeblack@google.com type = 'GenericArmPciHost' 10912837Sgabeblack@google.com cxx_header = "dev/arm/pci_host.hh" 11012837Sgabeblack@google.com 11112837Sgabeblack@google.com int_policy = Param.ArmPciIntRouting("PCI interrupt routing policy") 11212837Sgabeblack@google.com int_base = Param.Unsigned("PCI interrupt base") 11312837Sgabeblack@google.com int_count = Param.Unsigned("Maximum number of interrupts used by this host") 11412837Sgabeblack@google.com 11512837Sgabeblack@google.comclass RealViewCtrl(BasicPioDevice): 11612837Sgabeblack@google.com type = 'RealViewCtrl' 11712837Sgabeblack@google.com cxx_header = "dev/arm/rv_ctrl.hh" 11812837Sgabeblack@google.com proc_id0 = Param.UInt32(0x0C000000, "Processor ID, SYS_PROCID") 11912837Sgabeblack@google.com proc_id1 = Param.UInt32(0x0C000222, "Processor ID, SYS_PROCID1") 12012837Sgabeblack@google.com idreg = Param.UInt32(0x00000000, "ID Register, SYS_ID") 12112837Sgabeblack@google.com 12212837Sgabeblack@google.comclass RealViewOsc(ClockDomain): 12312837Sgabeblack@google.com type = 'RealViewOsc' 12412837Sgabeblack@google.com cxx_header = "dev/arm/rv_ctrl.hh" 12512837Sgabeblack@google.com 12612837Sgabeblack@google.com parent = Param.RealViewCtrl(Parent.any, "RealView controller") 12712837Sgabeblack@google.com 12812837Sgabeblack@google.com # TODO: We currently don't have the notion of a clock source, 12912837Sgabeblack@google.com # which means we have to associate oscillators with a voltage 13012837Sgabeblack@google.com # source. 13112837Sgabeblack@google.com voltage_domain = Param.VoltageDomain(Parent.voltage_domain, 13212837Sgabeblack@google.com "Voltage domain") 13312837Sgabeblack@google.com 13412837Sgabeblack@google.com # See ARM DUI 0447J (ARM Motherboard Express uATX -- V2M-P1) and 13512837Sgabeblack@google.com # the individual core/logic tile reference manuals for details 13612837Sgabeblack@google.com # about the site/position/dcc/device allocation. 13712837Sgabeblack@google.com site = Param.UInt8("Board Site") 13812837Sgabeblack@google.com position = Param.UInt8("Position in device stack") 13912837Sgabeblack@google.com dcc = Param.UInt8("Daughterboard Configuration Controller") 14012837Sgabeblack@google.com device = Param.UInt8("Device ID") 14112837Sgabeblack@google.com 14212837Sgabeblack@google.com freq = Param.Clock("Default frequency") 14312837Sgabeblack@google.com 14412837Sgabeblack@google.comclass RealViewTemperatureSensor(SimObject): 14512837Sgabeblack@google.com type = 'RealViewTemperatureSensor' 14612837Sgabeblack@google.com cxx_header = "dev/arm/rv_ctrl.hh" 14712837Sgabeblack@google.com 14812837Sgabeblack@google.com parent = Param.RealViewCtrl(Parent.any, "RealView controller") 14912837Sgabeblack@google.com 15012837Sgabeblack@google.com system = Param.System(Parent.any, "system") 15112837Sgabeblack@google.com 15212837Sgabeblack@google.com # See ARM DUI 0447J (ARM Motherboard Express uATX -- V2M-P1) and 15312837Sgabeblack@google.com # the individual core/logic tile reference manuals for details 15412837Sgabeblack@google.com # about the site/position/dcc/device allocation. 15512837Sgabeblack@google.com site = Param.UInt8("Board Site") 15612837Sgabeblack@google.com position = Param.UInt8("Position in device stack") 15712837Sgabeblack@google.com dcc = Param.UInt8("Daughterboard Configuration Controller") 15812837Sgabeblack@google.com device = Param.UInt8("Device ID") 15912837Sgabeblack@google.com 16012837Sgabeblack@google.comclass VExpressMCC(SubSystem): 16112951Sgabeblack@google.com """ARM V2M-P1 Motherboard Configuration Controller 16212837Sgabeblack@google.com 16312837Sgabeblack@google.comThis subsystem describes a subset of the devices that sit behind the 16412837Sgabeblack@google.commotherboard configuration controller on the the ARM Motherboard 16512837Sgabeblack@google.comExpress (V2M-P1) motherboard. See ARM DUI 0447J for details. 16612837Sgabeblack@google.com """ 16712951Sgabeblack@google.com 16812837Sgabeblack@google.com class Osc(RealViewOsc): 16912837Sgabeblack@google.com site, position, dcc = (0, 0, 0) 17012951Sgabeblack@google.com 17112952Sgabeblack@google.com class Temperature(RealViewTemperatureSensor): 17212951Sgabeblack@google.com site, position, dcc = (0, 0, 0) 17312951Sgabeblack@google.com 17412837Sgabeblack@google.com osc_mcc = Osc(device=0, freq="50MHz") 17512951Sgabeblack@google.com osc_clcd = Osc(device=1, freq="23.75MHz") 17612951Sgabeblack@google.com osc_peripheral = Osc(device=2, freq="24MHz") 17712951Sgabeblack@google.com osc_system_bus = Osc(device=4, freq="24MHz") 17812951Sgabeblack@google.com 17912951Sgabeblack@google.com # See Table 4.19 in ARM DUI 0447J (Motherboard Express uATX TRM). 18012928Sgabeblack@google.com temp_crtl = Temperature(device=0) 18112837Sgabeblack@google.com 18212837Sgabeblack@google.comclass CoreTile2A15DCC(SubSystem): 18312837Sgabeblack@google.com """ARM CoreTile Express A15x2 Daughterboard Configuration Controller 18412837Sgabeblack@google.com 18512837Sgabeblack@google.comThis subsystem describes a subset of the devices that sit behind the 18612837Sgabeblack@google.comdaughterboard configuration controller on a CoreTile Express A15x2. See 18712837Sgabeblack@google.comARM DUI 0604E for details. 18812837Sgabeblack@google.com """ 18912837Sgabeblack@google.com 19012837Sgabeblack@google.com class Osc(RealViewOsc): 19112837Sgabeblack@google.com site, position, dcc = (1, 0, 0) 19212837Sgabeblack@google.com 19312837Sgabeblack@google.com # See Table 2.8 in ARM DUI 0604E (CoreTile Express A15x2 TRM) 19412837Sgabeblack@google.com osc_cpu = Osc(device=0, freq="60MHz") 19512837Sgabeblack@google.com osc_hsbm = Osc(device=4, freq="40MHz") 19612837Sgabeblack@google.com osc_pxl = Osc(device=5, freq="23.75MHz") 19712837Sgabeblack@google.com osc_smb = Osc(device=6, freq="50MHz") 19812837Sgabeblack@google.com osc_sys = Osc(device=7, freq="60MHz") 19912837Sgabeblack@google.com osc_ddr = Osc(device=8, freq="40MHz") 20012837Sgabeblack@google.com 20112837Sgabeblack@google.comclass VGic(PioDevice): 20212837Sgabeblack@google.com type = 'VGic' 20312837Sgabeblack@google.com cxx_header = "dev/arm/vgic.hh" 20412837Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "Gic to use for interrupting") 20512837Sgabeblack@google.com platform = Param.Platform(Parent.any, "Platform this device is part of.") 20612837Sgabeblack@google.com vcpu_addr = Param.Addr(0, "Address for vcpu interfaces") 20712837Sgabeblack@google.com hv_addr = Param.Addr(0, "Address for hv control") 20812837Sgabeblack@google.com pio_delay = Param.Latency('10ns', "Delay for PIO r/w") 20912837Sgabeblack@google.com # The number of list registers is not currently configurable at runtime. 21012837Sgabeblack@google.com ppint = Param.UInt32("HV maintenance interrupt number") 21112837Sgabeblack@google.com 21212837Sgabeblack@google.comclass AmbaFake(AmbaPioDevice): 21312837Sgabeblack@google.com type = 'AmbaFake' 21412837Sgabeblack@google.com cxx_header = "dev/arm/amba_fake.hh" 21512837Sgabeblack@google.com ignore_access = Param.Bool(False, "Ignore reads/writes to this device, (e.g. IsaFake + AMBA)") 21612837Sgabeblack@google.com amba_id = 0; 21712837Sgabeblack@google.com 21812837Sgabeblack@google.comclass Pl011(Uart): 21912837Sgabeblack@google.com type = 'Pl011' 22012837Sgabeblack@google.com cxx_header = "dev/arm/pl011.hh" 22112837Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "Gic to use for interrupting") 22212837Sgabeblack@google.com int_num = Param.UInt32("Interrupt number that connects to GIC") 22312837Sgabeblack@google.com end_on_eot = Param.Bool(False, "End the simulation when a EOT is received on the UART") 22412837Sgabeblack@google.com int_delay = Param.Latency("100ns", "Time between action and interrupt generation by UART") 22512837Sgabeblack@google.com 22612837Sgabeblack@google.comclass Sp804(AmbaPioDevice): 22712837Sgabeblack@google.com type = 'Sp804' 22812837Sgabeblack@google.com cxx_header = "dev/arm/timer_sp804.hh" 22912837Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "Gic to use for interrupting") 23012837Sgabeblack@google.com int_num0 = Param.UInt32("Interrupt number that connects to GIC") 23112837Sgabeblack@google.com clock0 = Param.Clock('1MHz', "Clock speed of the input") 23212837Sgabeblack@google.com int_num1 = Param.UInt32("Interrupt number that connects to GIC") 23312837Sgabeblack@google.com clock1 = Param.Clock('1MHz', "Clock speed of the input") 23412953Sgabeblack@google.com amba_id = 0x00141804 23512837Sgabeblack@google.com 23612837Sgabeblack@google.comclass CpuLocalTimer(BasicPioDevice): 23712837Sgabeblack@google.com type = 'CpuLocalTimer' 23812953Sgabeblack@google.com cxx_header = "dev/arm/timer_cpulocal.hh" 23912837Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "Gic to use for interrupting") 24012953Sgabeblack@google.com int_num_timer = Param.UInt32("Interrrupt number used per-cpu to GIC") 24112837Sgabeblack@google.com int_num_watchdog = Param.UInt32("Interrupt number for per-cpu watchdog to GIC") 24212837Sgabeblack@google.com 24312837Sgabeblack@google.comclass GenericTimer(SimObject): 24412951Sgabeblack@google.com type = 'GenericTimer' 24512951Sgabeblack@google.com cxx_header = "dev/arm/generic_timer.hh" 24612837Sgabeblack@google.com system = Param.ArmSystem(Parent.any, "system") 24712951Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "GIC to use for interrupting") 24812837Sgabeblack@google.com # @todo: for now only two timers per CPU is supported, which is the 24912951Sgabeblack@google.com # normal behaviour when security extensions are disabled. 25012837Sgabeblack@google.com int_phys = Param.UInt32("Physical timer interrupt number") 25112837Sgabeblack@google.com int_virt = Param.UInt32("Virtual timer interrupt number") 25212837Sgabeblack@google.com 25312951Sgabeblack@google.comclass GenericTimerMem(PioDevice): 25412837Sgabeblack@google.com type = 'GenericTimerMem' 25512951Sgabeblack@google.com cxx_header = "dev/arm/generic_timer.hh" 25612837Sgabeblack@google.com gic = Param.BaseGic(Parent.any, "GIC to use for interrupting") 25712837Sgabeblack@google.com 25812837Sgabeblack@google.com base = Param.Addr(0, "Base address") 25912951Sgabeblack@google.com 26012837Sgabeblack@google.com int_phys = Param.UInt32("Interrupt number") 26112951Sgabeblack@google.com int_virt = Param.UInt32("Interrupt number") 26212837Sgabeblack@google.com 26312837Sgabeblack@google.comclass PL031(AmbaIntDevice): 26412837Sgabeblack@google.com type = 'PL031' 26512951Sgabeblack@google.com cxx_header = "dev/arm/rtc_pl031.hh" 26612837Sgabeblack@google.com time = Param.Time('01/01/2009', "System time to use ('Now' for actual time)") 26712951Sgabeblack@google.com amba_id = 0x00341031 26812837Sgabeblack@google.com 26912837Sgabeblack@google.comclass Pl050(AmbaIntDevice): 27012837Sgabeblack@google.com type = 'Pl050' 27112951Sgabeblack@google.com cxx_header = "dev/arm/kmi.hh" 27212837Sgabeblack@google.com vnc = Param.VncInput(Parent.any, "Vnc server for remote frame buffer display") 27312951Sgabeblack@google.com is_mouse = Param.Bool(False, "Is this interface a mouse, if not a keyboard") 27412837Sgabeblack@google.com int_delay = '1us' 27512837Sgabeblack@google.com amba_id = 0x00141050 27612837Sgabeblack@google.com 27712951Sgabeblack@google.comclass Pl111(AmbaDmaDevice): 27812837Sgabeblack@google.com type = 'Pl111' 27912951Sgabeblack@google.com cxx_header = "dev/arm/pl111.hh" 28012837Sgabeblack@google.com pixel_clock = Param.Clock('24MHz', "Pixel clock") 28112837Sgabeblack@google.com vnc = Param.VncInput(Parent.any, "Vnc server for remote frame buffer display") 28212837Sgabeblack@google.com amba_id = 0x00141111 28312951Sgabeblack@google.com enable_capture = Param.Bool(True, "capture frame to system.framebuffer.bmp") 28412837Sgabeblack@google.com 28512951Sgabeblack@google.comclass HDLcd(AmbaDmaDevice): 28612837Sgabeblack@google.com type = 'HDLcd' 28712837Sgabeblack@google.com cxx_header = "dev/arm/hdlcd.hh" 28812837Sgabeblack@google.com vnc = Param.VncInput(Parent.any, "Vnc server for remote frame buffer " 28912951Sgabeblack@google.com "display") 29012837Sgabeblack@google.com amba_id = 0x00141000 29112951Sgabeblack@google.com workaround_swap_rb = Param.Bool(False, "Workaround incorrect color " 29212837Sgabeblack@google.com "selector order in some kernels") 29312837Sgabeblack@google.com workaround_dma_line_count = Param.Bool(True, "Workaround incorrect " 29412837Sgabeblack@google.com "DMA line count (off by 1)") 29512951Sgabeblack@google.com enable_capture = Param.Bool(True, "capture frame to system.framebuffer.bmp") 29612837Sgabeblack@google.com 29712951Sgabeblack@google.com pixel_buffer_size = Param.MemorySize32("2kB", "Size of address range") 29812837Sgabeblack@google.com 29912837Sgabeblack@google.com pxl_clk = Param.ClockDomain("Pixel clock source") 30012837Sgabeblack@google.com pixel_chunk = Param.Unsigned(32, "Number of pixels to handle in one batch") 30112951Sgabeblack@google.com 30212837Sgabeblack@google.comclass RealView(Platform): 30312951Sgabeblack@google.com type = 'RealView' 30412837Sgabeblack@google.com cxx_header = "dev/arm/realview.hh" 30512837Sgabeblack@google.com system = Param.System(Parent.any, "system") 30612837Sgabeblack@google.com _mem_regions = [(Addr(0), Addr('256MB'))] 30712951Sgabeblack@google.com 30812837Sgabeblack@google.com def _on_chip_devices(self): 30912951Sgabeblack@google.com return [] 31012837Sgabeblack@google.com 31112837Sgabeblack@google.com def _off_chip_devices(self): 31212837Sgabeblack@google.com return [] 31312929Sgabeblack@google.com 31412929Sgabeblack@google.com _off_chip_ranges = [] 31512929Sgabeblack@google.com 31612929Sgabeblack@google.com def _attach_device(self, device, bus, dma_ports=None): 31712929Sgabeblack@google.com if hasattr(device, "pio"): 31812929Sgabeblack@google.com device.pio = bus.master 31912929Sgabeblack@google.com if hasattr(device, "dma"): 32012929Sgabeblack@google.com if dma_ports is None: 32112837Sgabeblack@google.com device.dma = bus.slave 32212837Sgabeblack@google.com else: 32312837Sgabeblack@google.com dma_ports.append(device.dma) 32412951Sgabeblack@google.com 32512837Sgabeblack@google.com def _attach_io(self, devices, *args, **kwargs): 32612837Sgabeblack@google.com for d in devices: 32712837Sgabeblack@google.com self._attach_device(d, *args, **kwargs) 32812951Sgabeblack@google.com 32912837Sgabeblack@google.com def _attach_clk(self, devices, clkdomain): 33012951Sgabeblack@google.com for d in devices: 33112837Sgabeblack@google.com if hasattr(d, "clk_domain"): 33212837Sgabeblack@google.com d.clk_domain = clkdomain 33312837Sgabeblack@google.com 33412951Sgabeblack@google.com def attachPciDevices(self): 33512837Sgabeblack@google.com pass 33612951Sgabeblack@google.com 33712837Sgabeblack@google.com def enableMSIX(self): 33812837Sgabeblack@google.com pass 33912837Sgabeblack@google.com 34012951Sgabeblack@google.com def onChipIOClkDomain(self, clkdomain): 34112837Sgabeblack@google.com self._attach_clk(self._on_chip_devices(), clkdomain) 34212951Sgabeblack@google.com 34312837Sgabeblack@google.com def offChipIOClkDomain(self, clkdomain): 34412837Sgabeblack@google.com self._attach_clk(self._off_chip_devices(), clkdomain) 34512837Sgabeblack@google.com 34612951Sgabeblack@google.com def attachOnChipIO(self, bus, bridge=None, **kwargs): 34712837Sgabeblack@google.com self._attach_io(self._on_chip_devices(), bus, **kwargs) 34812951Sgabeblack@google.com if bridge: 34912837Sgabeblack@google.com bridge.ranges = self._off_chip_ranges 35012837Sgabeblack@google.com 35112837Sgabeblack@google.com def attachIO(self, *args, **kwargs): 35212951Sgabeblack@google.com self._attach_io(self._off_chip_devices(), *args, **kwargs) 35312837Sgabeblack@google.com 35412951Sgabeblack@google.com 35512837Sgabeblack@google.com def setupBootLoader(self, mem_bus, cur_sys, loc): 35612837Sgabeblack@google.com self.nvmem = SimpleMemory(range = AddrRange('2GB', size = '64MB'), 35712837Sgabeblack@google.com conf_table_reported = False) 35812951Sgabeblack@google.com self.nvmem.port = mem_bus.master 35912837Sgabeblack@google.com cur_sys.boot_loader = loc('boot.arm') 36012951Sgabeblack@google.com cur_sys.atags_addr = 0x100 36112837Sgabeblack@google.com cur_sys.load_addr_mask = 0xfffffff 36212837Sgabeblack@google.com cur_sys.load_offset = 0 36312837Sgabeblack@google.com 36412951Sgabeblack@google.com 36512837Sgabeblack@google.com# Reference for memory map and interrupt number 36612951Sgabeblack@google.com# RealView Platform Baseboard Explore for Cortex-A9 User Guide(ARM DUI 0440A) 36712837Sgabeblack@google.com# Chapter 4: Programmer's Reference 36812837Sgabeblack@google.comclass RealViewPBX(RealView): 36912837Sgabeblack@google.com uart = Pl011(pio_addr=0x10009000, int_num=44) 37012951Sgabeblack@google.com realview_io = RealViewCtrl(pio_addr=0x10000000) 37112837Sgabeblack@google.com mcc = VExpressMCC() 37212951Sgabeblack@google.com dcc = CoreTile2A15DCC() 37312837Sgabeblack@google.com gic = Pl390() 37412837Sgabeblack@google.com pci_host = GenericPciHost( 37512837Sgabeblack@google.com conf_base=0x30000000, conf_size='256MB', conf_device_bits=16, 37612951Sgabeblack@google.com pci_pio_base=0) 37712837Sgabeblack@google.com timer0 = Sp804(int_num0=36, int_num1=36, pio_addr=0x10011000) 37812951Sgabeblack@google.com timer1 = Sp804(int_num0=37, int_num1=37, pio_addr=0x10012000) 37912837Sgabeblack@google.com local_cpu_timer = CpuLocalTimer(int_num_timer=29, int_num_watchdog=30, pio_addr=0x1f000600) 38012837Sgabeblack@google.com clcd = Pl111(pio_addr=0x10020000, int_num=55) 38112837Sgabeblack@google.com kmi0 = Pl050(pio_addr=0x10006000, int_num=52) 38212951Sgabeblack@google.com kmi1 = Pl050(pio_addr=0x10007000, int_num=53, is_mouse=True) 38312837Sgabeblack@google.com a9scu = A9SCU(pio_addr=0x1f000000) 38412951Sgabeblack@google.com cf_ctrl = IdeController(disks=[], pci_func=0, pci_dev=7, pci_bus=2, 38512837Sgabeblack@google.com io_shift = 1, ctrl_offset = 2, Command = 0x1, 38612837Sgabeblack@google.com BAR0 = 0x18000000, BAR0Size = '16B', 38712837Sgabeblack@google.com BAR1 = 0x18000100, BAR1Size = '1B', 38812951Sgabeblack@google.com BAR0LegacyIO = True, BAR1LegacyIO = True) 38912837Sgabeblack@google.com 39012951Sgabeblack@google.com 39112837Sgabeblack@google.com l2x0_fake = IsaFake(pio_addr=0x1f002000, pio_size=0xfff) 39212837Sgabeblack@google.com flash_fake = IsaFake(pio_addr=0x40000000, pio_size=0x20000000, 39312837Sgabeblack@google.com fake_mem=True) 39412951Sgabeblack@google.com dmac_fake = AmbaFake(pio_addr=0x10030000) 39512837Sgabeblack@google.com uart1_fake = AmbaFake(pio_addr=0x1000a000) 39612951Sgabeblack@google.com uart2_fake = AmbaFake(pio_addr=0x1000b000) 39712837Sgabeblack@google.com uart3_fake = AmbaFake(pio_addr=0x1000c000) 39812837Sgabeblack@google.com smc_fake = AmbaFake(pio_addr=0x100e1000) 39912837Sgabeblack@google.com sp810_fake = AmbaFake(pio_addr=0x10001000, ignore_access=True) 40012837Sgabeblack@google.com watchdog_fake = AmbaFake(pio_addr=0x10010000) 40112909Sgabeblack@google.com gpio0_fake = AmbaFake(pio_addr=0x10013000) 40212909Sgabeblack@google.com gpio1_fake = AmbaFake(pio_addr=0x10014000) 40312951Sgabeblack@google.com gpio2_fake = AmbaFake(pio_addr=0x10015000) 40412909Sgabeblack@google.com ssp_fake = AmbaFake(pio_addr=0x1000d000) 40512909Sgabeblack@google.com sci_fake = AmbaFake(pio_addr=0x1000e000) 40612914Sgabeblack@google.com aaci_fake = AmbaFake(pio_addr=0x10004000) 40712951Sgabeblack@google.com mmc_fake = AmbaFake(pio_addr=0x10005000) 40812914Sgabeblack@google.com rtc = PL031(pio_addr=0x10017000, int_num=42) 40912951Sgabeblack@google.com energy_ctrl = EnergyCtrl(pio_addr=0x1000f000) 41012914Sgabeblack@google.com 41112914Sgabeblack@google.com 41212914Sgabeblack@google.com # Attach I/O devices that are on chip and also set the appropriate 41312951Sgabeblack@google.com # ranges for the bridge 41412914Sgabeblack@google.com def attachOnChipIO(self, bus, bridge): 41512951Sgabeblack@google.com self.gic.pio = bus.master 41612914Sgabeblack@google.com self.l2x0_fake.pio = bus.master 41712914Sgabeblack@google.com self.a9scu.pio = bus.master 41812914Sgabeblack@google.com self.local_cpu_timer.pio = bus.master 41912951Sgabeblack@google.com # Bridge ranges based on excluding what is part of on-chip I/O 42012914Sgabeblack@google.com # (gic, l2x0, a9scu, local_cpu_timer) 42112951Sgabeblack@google.com bridge.ranges = [AddrRange(self.realview_io.pio_addr, 42212914Sgabeblack@google.com self.a9scu.pio_addr - 1), 42312914Sgabeblack@google.com AddrRange(self.flash_fake.pio_addr, 42412914Sgabeblack@google.com self.flash_fake.pio_addr + \ 42512951Sgabeblack@google.com self.flash_fake.pio_size - 1)] 42612914Sgabeblack@google.com 42712951Sgabeblack@google.com # Set the clock domain for IO objects that are considered 42812914Sgabeblack@google.com # to be "close" to the cores. 42912914Sgabeblack@google.com def onChipIOClkDomain(self, clkdomain): 43012909Sgabeblack@google.com self.gic.clk_domain = clkdomain 43112909Sgabeblack@google.com self.l2x0_fake.clk_domain = clkdomain 43212837Sgabeblack@google.com self.a9scu.clkdomain = clkdomain 43312837Sgabeblack@google.com self.local_cpu_timer.clk_domain = clkdomain 43412958Sgabeblack@google.com 43512958Sgabeblack@google.com # Attach I/O devices to specified bus object. Can't do this 43612837Sgabeblack@google.com # earlier, since the bus object itself is typically defined at the 43712837Sgabeblack@google.com # System level. 43812837Sgabeblack@google.com def attachIO(self, bus): 43912958Sgabeblack@google.com self.uart.pio = bus.master 44012837Sgabeblack@google.com self.realview_io.pio = bus.master 44112958Sgabeblack@google.com self.pci_host.pio = bus.master 44212958Sgabeblack@google.com self.timer0.pio = bus.master 44312837Sgabeblack@google.com self.timer1.pio = bus.master 44412837Sgabeblack@google.com self.clcd.pio = bus.master 44512837Sgabeblack@google.com self.clcd.dma = bus.slave 44612958Sgabeblack@google.com self.kmi0.pio = bus.master 44712837Sgabeblack@google.com self.kmi1.pio = bus.master 44812958Sgabeblack@google.com self.cf_ctrl.pio = bus.master 44912958Sgabeblack@google.com self.cf_ctrl.dma = bus.slave 45012837Sgabeblack@google.com self.dmac_fake.pio = bus.master 45112837Sgabeblack@google.com self.uart1_fake.pio = bus.master 45212837Sgabeblack@google.com self.uart2_fake.pio = bus.master 45312958Sgabeblack@google.com self.uart3_fake.pio = bus.master 45412837Sgabeblack@google.com self.smc_fake.pio = bus.master 45512958Sgabeblack@google.com self.sp810_fake.pio = bus.master 45612958Sgabeblack@google.com self.watchdog_fake.pio = bus.master 45712837Sgabeblack@google.com self.gpio0_fake.pio = bus.master 45812837Sgabeblack@google.com self.gpio1_fake.pio = bus.master 45912837Sgabeblack@google.com self.gpio2_fake.pio = bus.master 46012958Sgabeblack@google.com self.ssp_fake.pio = bus.master 46112837Sgabeblack@google.com self.sci_fake.pio = bus.master 46212958Sgabeblack@google.com self.aaci_fake.pio = bus.master 46312958Sgabeblack@google.com self.mmc_fake.pio = bus.master 46412837Sgabeblack@google.com self.rtc.pio = bus.master 46512837Sgabeblack@google.com self.flash_fake.pio = bus.master 46612837Sgabeblack@google.com self.energy_ctrl.pio = bus.master 46712951Sgabeblack@google.com 46812837Sgabeblack@google.com # Set the clock domain for IO objects that are considered 46912951Sgabeblack@google.com # to be "far" away from the cores. 47012837Sgabeblack@google.com def offChipIOClkDomain(self, clkdomain): 47112837Sgabeblack@google.com self.uart.clk_domain = clkdomain 47212837Sgabeblack@google.com self.realview_io.clk_domain = clkdomain 47312958Sgabeblack@google.com self.timer0.clk_domain = clkdomain 47412837Sgabeblack@google.com self.timer1.clk_domain = clkdomain 47512958Sgabeblack@google.com self.clcd.clk_domain = clkdomain 47612958Sgabeblack@google.com self.kmi0.clk_domain = clkdomain 47712837Sgabeblack@google.com self.kmi1.clk_domain = clkdomain 47812837Sgabeblack@google.com self.cf_ctrl.clk_domain = clkdomain 47912837Sgabeblack@google.com self.dmac_fake.clk_domain = clkdomain 48012951Sgabeblack@google.com self.uart1_fake.clk_domain = clkdomain 48112837Sgabeblack@google.com self.uart2_fake.clk_domain = clkdomain 48212951Sgabeblack@google.com self.uart3_fake.clk_domain = clkdomain 48312837Sgabeblack@google.com self.smc_fake.clk_domain = clkdomain 48412837Sgabeblack@google.com self.sp810_fake.clk_domain = clkdomain 48512837Sgabeblack@google.com self.watchdog_fake.clk_domain = clkdomain 48612958Sgabeblack@google.com self.gpio0_fake.clk_domain = clkdomain 48712837Sgabeblack@google.com self.gpio1_fake.clk_domain = clkdomain 48812958Sgabeblack@google.com self.gpio2_fake.clk_domain = clkdomain 48912958Sgabeblack@google.com self.ssp_fake.clk_domain = clkdomain 49012958Sgabeblack@google.com self.sci_fake.clk_domain = clkdomain 49112837Sgabeblack@google.com self.aaci_fake.clk_domain = clkdomain 49212837Sgabeblack@google.com self.mmc_fake.clk_domain = clkdomain 49312837Sgabeblack@google.com self.rtc.clk_domain = clkdomain 49412951Sgabeblack@google.com self.flash_fake.clk_domain = clkdomain 49512837Sgabeblack@google.com self.energy_ctrl.clk_domain = clkdomain 49612951Sgabeblack@google.com 49712837Sgabeblack@google.com# Reference for memory map and interrupt number 49812837Sgabeblack@google.com# RealView Emulation Baseboard User Guide (ARM DUI 0143B) 49912837Sgabeblack@google.com# Chapter 4: Programmer's Reference 50012958Sgabeblack@google.comclass RealViewEB(RealView): 50112837Sgabeblack@google.com uart = Pl011(pio_addr=0x10009000, int_num=44) 50212958Sgabeblack@google.com realview_io = RealViewCtrl(pio_addr=0x10000000, idreg=0x01400500) 50312958Sgabeblack@google.com mcc = VExpressMCC() 50412958Sgabeblack@google.com dcc = CoreTile2A15DCC() 50512837Sgabeblack@google.com gic = Pl390(dist_addr=0x10041000, cpu_addr=0x10040000) 50612837Sgabeblack@google.com timer0 = Sp804(int_num0=36, int_num1=36, pio_addr=0x10011000) 50712837Sgabeblack@google.com timer1 = Sp804(int_num0=37, int_num1=37, pio_addr=0x10012000) 50812951Sgabeblack@google.com clcd = Pl111(pio_addr=0x10020000, int_num=23) 50912837Sgabeblack@google.com kmi0 = Pl050(pio_addr=0x10006000, int_num=20) 51012951Sgabeblack@google.com kmi1 = Pl050(pio_addr=0x10007000, int_num=21, is_mouse=True) 51112837Sgabeblack@google.com 51212837Sgabeblack@google.com l2x0_fake = IsaFake(pio_addr=0x1f002000, pio_size=0xfff, warn_access="1") 51312929Sgabeblack@google.com flash_fake = IsaFake(pio_addr=0x40000000, pio_size=0x20000000-1, 51412929Sgabeblack@google.com fake_mem=True) 51512929Sgabeblack@google.com dmac_fake = AmbaFake(pio_addr=0x10030000) 51612929Sgabeblack@google.com uart1_fake = AmbaFake(pio_addr=0x1000a000) 51712929Sgabeblack@google.com uart2_fake = AmbaFake(pio_addr=0x1000b000) 51812929Sgabeblack@google.com uart3_fake = AmbaFake(pio_addr=0x1000c000) 51912929Sgabeblack@google.com smcreg_fake = IsaFake(pio_addr=0x10080000, pio_size=0x10000-1) 52012837Sgabeblack@google.com smc_fake = AmbaFake(pio_addr=0x100e1000) 52112837Sgabeblack@google.com sp810_fake = AmbaFake(pio_addr=0x10001000, ignore_access=True) 52212837Sgabeblack@google.com watchdog_fake = AmbaFake(pio_addr=0x10010000) 52312837Sgabeblack@google.com gpio0_fake = AmbaFake(pio_addr=0x10013000) 52412958Sgabeblack@google.com gpio1_fake = AmbaFake(pio_addr=0x10014000) 52512958Sgabeblack@google.com gpio2_fake = AmbaFake(pio_addr=0x10015000) 52612958Sgabeblack@google.com ssp_fake = AmbaFake(pio_addr=0x1000d000) 52712837Sgabeblack@google.com sci_fake = AmbaFake(pio_addr=0x1000e000) 52812837Sgabeblack@google.com aaci_fake = AmbaFake(pio_addr=0x10004000) 52912837Sgabeblack@google.com mmc_fake = AmbaFake(pio_addr=0x10005000) 53012958Sgabeblack@google.com rtc_fake = AmbaFake(pio_addr=0x10017000, amba_id=0x41031) 53112837Sgabeblack@google.com energy_ctrl = EnergyCtrl(pio_addr=0x1000f000) 53212958Sgabeblack@google.com 53312958Sgabeblack@google.com # Attach I/O devices that are on chip and also set the appropriate 53412837Sgabeblack@google.com # ranges for the bridge 53512837Sgabeblack@google.com def attachOnChipIO(self, bus, bridge): 53612837Sgabeblack@google.com self.gic.pio = bus.master 53712958Sgabeblack@google.com self.l2x0_fake.pio = bus.master 53812837Sgabeblack@google.com # Bridge ranges based on excluding what is part of on-chip I/O 53912958Sgabeblack@google.com # (gic, l2x0) 54012958Sgabeblack@google.com bridge.ranges = [AddrRange(self.realview_io.pio_addr, 54112958Sgabeblack@google.com self.gic.cpu_addr - 1), 54212837Sgabeblack@google.com AddrRange(self.flash_fake.pio_addr, Addr.max)] 54312837Sgabeblack@google.com 54412837Sgabeblack@google.com # Set the clock domain for IO objects that are considered 54512958Sgabeblack@google.com # to be "close" to the cores. 54612837Sgabeblack@google.com def onChipIOClkDomain(self, clkdomain): 54712958Sgabeblack@google.com self.gic.clk_domain = clkdomain 54812958Sgabeblack@google.com self.l2x0_fake.clk_domain = clkdomain 54912958Sgabeblack@google.com 55012837Sgabeblack@google.com # Attach I/O devices to specified bus object. Can't do this 55112837Sgabeblack@google.com # earlier, since the bus object itself is typically defined at the 55212837Sgabeblack@google.com # System level. 55312958Sgabeblack@google.com def attachIO(self, bus): 55412837Sgabeblack@google.com self.uart.pio = bus.master 55512958Sgabeblack@google.com self.realview_io.pio = bus.master 55612958Sgabeblack@google.com self.pci_host.pio = bus.master 55712958Sgabeblack@google.com self.timer0.pio = bus.master 55812837Sgabeblack@google.com self.timer1.pio = bus.master 55912837Sgabeblack@google.com self.clcd.pio = bus.master 56012837Sgabeblack@google.com self.clcd.dma = bus.slave 56112958Sgabeblack@google.com self.kmi0.pio = bus.master 56212837Sgabeblack@google.com self.kmi1.pio = bus.master 56312958Sgabeblack@google.com self.dmac_fake.pio = bus.master 56412958Sgabeblack@google.com self.uart1_fake.pio = bus.master 56512958Sgabeblack@google.com self.uart2_fake.pio = bus.master 56612837Sgabeblack@google.com self.uart3_fake.pio = bus.master 56712837Sgabeblack@google.com self.smc_fake.pio = bus.master 56812837Sgabeblack@google.com self.sp810_fake.pio = bus.master 56912951Sgabeblack@google.com self.watchdog_fake.pio = bus.master 57012837Sgabeblack@google.com self.gpio0_fake.pio = bus.master 57112951Sgabeblack@google.com self.gpio1_fake.pio = bus.master 57212837Sgabeblack@google.com self.gpio2_fake.pio = bus.master 57312837Sgabeblack@google.com self.ssp_fake.pio = bus.master 57412837Sgabeblack@google.com self.sci_fake.pio = bus.master 57512958Sgabeblack@google.com self.aaci_fake.pio = bus.master 57612837Sgabeblack@google.com self.mmc_fake.pio = bus.master 57712958Sgabeblack@google.com self.rtc_fake.pio = bus.master 57812958Sgabeblack@google.com self.flash_fake.pio = bus.master 57912958Sgabeblack@google.com self.smcreg_fake.pio = bus.master 58012837Sgabeblack@google.com self.energy_ctrl.pio = bus.master 58112837Sgabeblack@google.com 58212837Sgabeblack@google.com # Set the clock domain for IO objects that are considered 58312951Sgabeblack@google.com # to be "far" away from the cores. 58412837Sgabeblack@google.com def offChipIOClkDomain(self, clkdomain): 58512951Sgabeblack@google.com self.uart.clk_domain = clkdomain 58612837Sgabeblack@google.com self.realview_io.clk_domain = clkdomain 58712837Sgabeblack@google.com self.timer0.clk_domain = clkdomain 58812837Sgabeblack@google.com self.timer1.clk_domain = clkdomain 58912958Sgabeblack@google.com self.clcd.clk_domain = clkdomain 59012837Sgabeblack@google.com self.kmi0.clk_domain = clkdomain 59112958Sgabeblack@google.com self.kmi1.clk_domain = clkdomain 59212958Sgabeblack@google.com self.dmac_fake.clk_domain = clkdomain 59312958Sgabeblack@google.com self.uart1_fake.clk_domain = clkdomain 59412958Sgabeblack@google.com self.uart2_fake.clk_domain = clkdomain 59512837Sgabeblack@google.com self.uart3_fake.clk_domain = clkdomain 59612837Sgabeblack@google.com self.smc_fake.clk_domain = clkdomain 59712837Sgabeblack@google.com self.sp810_fake.clk_domain = clkdomain 59812951Sgabeblack@google.com self.watchdog_fake.clk_domain = clkdomain 59912837Sgabeblack@google.com self.gpio0_fake.clk_domain = clkdomain 60012951Sgabeblack@google.com self.gpio1_fake.clk_domain = clkdomain 60112837Sgabeblack@google.com self.gpio2_fake.clk_domain = clkdomain 60212837Sgabeblack@google.com self.ssp_fake.clk_domain = clkdomain 60312837Sgabeblack@google.com self.sci_fake.clk_domain = clkdomain 60412958Sgabeblack@google.com self.aaci_fake.clk_domain = clkdomain 60512837Sgabeblack@google.com self.mmc_fake.clk_domain = clkdomain 60612958Sgabeblack@google.com self.rtc.clk_domain = clkdomain 60712958Sgabeblack@google.com self.flash_fake.clk_domain = clkdomain 60812958Sgabeblack@google.com self.smcreg_fake.clk_domain = clkdomain 60912958Sgabeblack@google.com self.energy_ctrl.clk_domain = clkdomain 61012837Sgabeblack@google.com 61112837Sgabeblack@google.comclass VExpress_EMM(RealView): 61212837Sgabeblack@google.com _mem_regions = [(Addr('2GB'), Addr('2GB'))] 61312951Sgabeblack@google.com uart = Pl011(pio_addr=0x1c090000, int_num=37) 61412837Sgabeblack@google.com realview_io = RealViewCtrl( 61512951Sgabeblack@google.com proc_id0=0x14000000, proc_id1=0x14000000, 61612837Sgabeblack@google.com idreg=0x02250000, pio_addr=0x1C010000) 61712837Sgabeblack@google.com mcc = VExpressMCC() 61812909Sgabeblack@google.com dcc = CoreTile2A15DCC() 61912909Sgabeblack@google.com gic = Pl390(dist_addr=0x2C001000, cpu_addr=0x2C002000) 62012909Sgabeblack@google.com pci_host = GenericPciHost( 62112909Sgabeblack@google.com conf_base=0x30000000, conf_size='256MB', conf_device_bits=16, 62212909Sgabeblack@google.com pci_pio_base=0) 62312909Sgabeblack@google.com local_cpu_timer = CpuLocalTimer(int_num_timer=29, int_num_watchdog=30, pio_addr=0x2C080000) 62412914Sgabeblack@google.com generic_timer = GenericTimer(int_phys=29, int_virt=27) 62512914Sgabeblack@google.com timer0 = Sp804(int_num0=34, int_num1=34, pio_addr=0x1C110000, clock0='1MHz', clock1='1MHz') 62612914Sgabeblack@google.com timer1 = Sp804(int_num0=35, int_num1=35, pio_addr=0x1C120000, clock0='1MHz', clock1='1MHz') 62712914Sgabeblack@google.com clcd = Pl111(pio_addr=0x1c1f0000, int_num=46) 62812914Sgabeblack@google.com hdlcd = HDLcd(pxl_clk=dcc.osc_pxl, 62912914Sgabeblack@google.com pio_addr=0x2b000000, int_num=117, 63012914Sgabeblack@google.com workaround_swap_rb=True) 63112914Sgabeblack@google.com kmi0 = Pl050(pio_addr=0x1c060000, int_num=44) 63212914Sgabeblack@google.com kmi1 = Pl050(pio_addr=0x1c070000, int_num=45, is_mouse=True) 63312914Sgabeblack@google.com vgic = VGic(vcpu_addr=0x2c006000, hv_addr=0x2c004000, ppint=25) 63412914Sgabeblack@google.com cf_ctrl = IdeController(disks=[], pci_func=0, pci_dev=0, pci_bus=2, 63512914Sgabeblack@google.com io_shift = 2, ctrl_offset = 2, Command = 0x1, 63612914Sgabeblack@google.com BAR0 = 0x1C1A0000, BAR0Size = '256B', 63712914Sgabeblack@google.com BAR1 = 0x1C1A0100, BAR1Size = '4096B', 63812914Sgabeblack@google.com BAR0LegacyIO = True, BAR1LegacyIO = True) 63912914Sgabeblack@google.com 64012914Sgabeblack@google.com vram = SimpleMemory(range = AddrRange(0x18000000, size='32MB'), 64112914Sgabeblack@google.com conf_table_reported = False) 64212914Sgabeblack@google.com rtc = PL031(pio_addr=0x1C170000, int_num=36) 64312914Sgabeblack@google.com 64412914Sgabeblack@google.com l2x0_fake = IsaFake(pio_addr=0x2C100000, pio_size=0xfff) 64512914Sgabeblack@google.com uart1_fake = AmbaFake(pio_addr=0x1C0A0000) 64612914Sgabeblack@google.com uart2_fake = AmbaFake(pio_addr=0x1C0B0000) 64712914Sgabeblack@google.com uart3_fake = AmbaFake(pio_addr=0x1C0C0000) 64812837Sgabeblack@google.com sp810_fake = AmbaFake(pio_addr=0x1C020000, ignore_access=True) 64913035Sgabeblack@google.com watchdog_fake = AmbaFake(pio_addr=0x1C0F0000) 65012837Sgabeblack@google.com aaci_fake = AmbaFake(pio_addr=0x1C040000) 65113035Sgabeblack@google.com lan_fake = IsaFake(pio_addr=0x1A000000, pio_size=0xffff) 65213035Sgabeblack@google.com usb_fake = IsaFake(pio_addr=0x1B000000, pio_size=0x1ffff) 65313035Sgabeblack@google.com mmc_fake = AmbaFake(pio_addr=0x1c050000) 65412837Sgabeblack@google.com energy_ctrl = EnergyCtrl(pio_addr=0x1c080000) 65512837Sgabeblack@google.com 65612837Sgabeblack@google.com # Attach any PCI devices that are supported 65712930Sgabeblack@google.com def attachPciDevices(self): 65812930Sgabeblack@google.com self.ethernet = IGbE_e1000(pci_bus=0, pci_dev=0, pci_func=0, 65912930Sgabeblack@google.com InterruptLine=1, InterruptPin=1) 66012930Sgabeblack@google.com self.ide = IdeController(disks = [], pci_bus=0, pci_dev=1, pci_func=0, 66112930Sgabeblack@google.com InterruptLine=2, InterruptPin=2) 66212930Sgabeblack@google.com 66312930Sgabeblack@google.com def enableMSIX(self): 66412837Sgabeblack@google.com self.gic = Pl390(dist_addr=0x2C001000, cpu_addr=0x2C002000, it_lines=512) 66512837Sgabeblack@google.com self.gicv2m = Gicv2m() 66612982Sgabeblack@google.com self.gicv2m.frames = [Gicv2mFrame(spi_base=256, spi_len=64, addr=0x2C1C0000)] 66712837Sgabeblack@google.com 66812837Sgabeblack@google.com def setupBootLoader(self, mem_bus, cur_sys, loc): 66912837Sgabeblack@google.com self.nvmem = SimpleMemory(range = AddrRange('64MB'), 67012837Sgabeblack@google.com conf_table_reported = False) 67112837Sgabeblack@google.com self.nvmem.port = mem_bus.master 67212982Sgabeblack@google.com cur_sys.boot_loader = loc('boot_emm.arm') 67312837Sgabeblack@google.com cur_sys.atags_addr = 0x8000000 67412837Sgabeblack@google.com cur_sys.load_addr_mask = 0xfffffff 67512901Sgabeblack@google.com cur_sys.load_offset = 0x80000000 67612901Sgabeblack@google.com 67712901Sgabeblack@google.com # Attach I/O devices that are on chip and also set the appropriate 67812901Sgabeblack@google.com # ranges for the bridge 67912901Sgabeblack@google.com def attachOnChipIO(self, bus, bridge=None): 68012901Sgabeblack@google.com self.gic.pio = bus.master 68112901Sgabeblack@google.com self.vgic.pio = bus.master 68212901Sgabeblack@google.com self.local_cpu_timer.pio = bus.master 68312837Sgabeblack@google.com if hasattr(self, "gicv2m"): 684 self.gicv2m.pio = bus.master 685 self.hdlcd.dma = bus.slave 686 if bridge: 687 # Bridge ranges based on excluding what is part of on-chip I/O 688 # (gic, a9scu) 689 bridge.ranges = [AddrRange(0x2F000000, size='16MB'), 690 AddrRange(0x2B000000, size='4MB'), 691 AddrRange(0x30000000, size='256MB'), 692 AddrRange(0x40000000, size='512MB'), 693 AddrRange(0x18000000, size='64MB'), 694 AddrRange(0x1C000000, size='64MB')] 695 696 697 # Set the clock domain for IO objects that are considered 698 # to be "close" to the cores. 699 def onChipIOClkDomain(self, clkdomain): 700 self.gic.clk_domain = clkdomain 701 if hasattr(self, "gicv2m"): 702 self.gicv2m.clk_domain = clkdomain 703 self.hdlcd.clk_domain = clkdomain 704 self.vgic.clk_domain = clkdomain 705 706 # Attach I/O devices to specified bus object. Done here 707 # as the specified bus to connect to may not always be fixed. 708 def attachIO(self, bus): 709 self.uart.pio = bus.master 710 self.realview_io.pio = bus.master 711 self.pci_host.pio = bus.master 712 self.timer0.pio = bus.master 713 self.timer1.pio = bus.master 714 self.clcd.pio = bus.master 715 self.clcd.dma = bus.slave 716 self.hdlcd.pio = bus.master 717 self.kmi0.pio = bus.master 718 self.kmi1.pio = bus.master 719 self.cf_ctrl.pio = bus.master 720 self.cf_ctrl.dma = bus.slave 721 self.rtc.pio = bus.master 722 self.vram.port = bus.master 723 724 self.l2x0_fake.pio = bus.master 725 self.uart1_fake.pio = bus.master 726 self.uart2_fake.pio = bus.master 727 self.uart3_fake.pio = bus.master 728 self.sp810_fake.pio = bus.master 729 self.watchdog_fake.pio = bus.master 730 self.aaci_fake.pio = bus.master 731 self.lan_fake.pio = bus.master 732 self.usb_fake.pio = bus.master 733 self.mmc_fake.pio = bus.master 734 self.energy_ctrl.pio = bus.master 735 736 # Try to attach the I/O if it exists 737 try: 738 self.ide.pio = bus.master 739 self.ide.dma = bus.slave 740 self.ethernet.pio = bus.master 741 self.ethernet.dma = bus.slave 742 except: 743 pass 744 745 # Set the clock domain for IO objects that are considered 746 # to be "far" away from the cores. 747 def offChipIOClkDomain(self, clkdomain): 748 self.uart.clk_domain = clkdomain 749 self.realview_io.clk_domain = clkdomain 750 self.timer0.clk_domain = clkdomain 751 self.timer1.clk_domain = clkdomain 752 self.clcd.clk_domain = clkdomain 753 self.kmi0.clk_domain = clkdomain 754 self.kmi1.clk_domain = clkdomain 755 self.cf_ctrl.clk_domain = clkdomain 756 self.rtc.clk_domain = clkdomain 757 self.vram.clk_domain = clkdomain 758 759 self.l2x0_fake.clk_domain = clkdomain 760 self.uart1_fake.clk_domain = clkdomain 761 self.uart2_fake.clk_domain = clkdomain 762 self.uart3_fake.clk_domain = clkdomain 763 self.sp810_fake.clk_domain = clkdomain 764 self.watchdog_fake.clk_domain = clkdomain 765 self.aaci_fake.clk_domain = clkdomain 766 self.lan_fake.clk_domain = clkdomain 767 self.usb_fake.clk_domain = clkdomain 768 self.mmc_fake.clk_domain = clkdomain 769 self.energy_ctrl.clk_domain = clkdomain 770 771class VExpress_EMM64(VExpress_EMM): 772 # Three memory regions are specified totalling 512GB 773 _mem_regions = [(Addr('2GB'), Addr('2GB')), (Addr('34GB'), Addr('30GB')), 774 (Addr('512GB'), Addr('480GB'))] 775 pci_host = GenericPciHost( 776 conf_base=0x30000000, conf_size='256MB', conf_device_bits=12, 777 pci_pio_base=0x2f000000) 778 779 def setupBootLoader(self, mem_bus, cur_sys, loc): 780 self.nvmem = SimpleMemory(range=AddrRange(0, size='64MB'), 781 conf_table_reported=False) 782 self.nvmem.port = mem_bus.master 783 cur_sys.boot_loader = loc('boot_emm.arm64') 784 cur_sys.atags_addr = 0x8000000 785 cur_sys.load_addr_mask = 0xfffffff 786 cur_sys.load_offset = 0x80000000 787 788 789class VExpress_GEM5_V1(RealView): 790 """ 791The VExpress gem5 memory map is loosely based on a modified 792Versatile Express RS1 memory map. 793 794The gem5 platform has been designed to implement a subset of the 795original Versatile Express RS1 memory map. Off-chip peripherals should, 796when possible, adhere to the Versatile Express memory map. Non-PCI 797off-chip devices that are gem5-specific should live in the CS5 memory 798space to avoid conflicts with existing devices that we might want to 799model in the future. Such devices should normally have interrupts in 800the gem5-specific SPI range. 801 802On-chip peripherals are loosely modeled after the ARM CoreTile Express 803A15x2 A7x3 memory and interrupt map. In particular, the GIC and 804Generic Timer have the same interrupt lines and base addresses. Other 805on-chip devices are gem5 specific. 806 807Unlike the original Versatile Express RS2 extended platform, gem5 implements a 808large contigious DRAM space, without aliases or holes, starting at the 8092GiB boundary. This means that PCI memory is limited to 1GiB. 810 811Memory map: 812 0x00000000-0x03ffffff: Boot memory (CS0) 813 0x04000000-0x07ffffff: Reserved 814 0x08000000-0x0bffffff: Reserved (CS0 alias) 815 0x0c000000-0x0fffffff: Reserved (Off-chip, CS4) 816 0x10000000-0x13ffffff: gem5-specific peripherals (Off-chip, CS5) 817 0x10000000-0x1000ffff: gem5 energy controller 818 819 0x14000000-0x17ffffff: Reserved (Off-chip, PSRAM, CS1) 820 0x18000000-0x1bffffff: Reserved (Off-chip, Peripherals, CS2) 821 0x1c000000-0x1fffffff: Peripheral block 1 (Off-chip, CS3): 822 0x1c010000-0x1c01ffff: realview_io (VE system control regs.) 823 0x1c060000-0x1c06ffff: KMI0 (keyboard) 824 0x1c070000-0x1c07ffff: KMI1 (mouse) 825 0x1c090000-0x1c09ffff: UART0 826 0x1c0a0000-0x1c0affff: UART1 (reserved) 827 0x1c0b0000-0x1c0bffff: UART2 (reserved) 828 0x1c0c0000-0x1c0cffff: UART3 (reserved) 829 0x1c170000-0x1c17ffff: RTC 830 831 0x20000000-0x3fffffff: On-chip peripherals: 832 0x2b000000-0x2b00ffff: HDLCD 833 834 0x2c001000-0x2c001fff: GIC (distributor) 835 0x2c002000-0x2c0020ff: GIC (CPU interface) 836 0x2c004000-0x2c005fff: vGIC (HV) 837 0x2c006000-0x2c007fff: vGIC (VCPU) 838 0x2c1c0000-0x2c1cffff: GICv2m MSI frame 0 839 840 0x2d000000-0x2d00ffff: GPU (reserved) 841 842 0x2f000000-0x2fffffff: PCI IO space 843 0x30000000-0x3fffffff: PCI config space 844 845 0x40000000-0x7fffffff: Ext. AXI: Used as PCI memory 846 847 0x80000000-X: DRAM 848 849Interrupts: 850 0- 15: Software generated interrupts (SGIs) 851 16- 31: On-chip private peripherals (PPIs) 852 25 : vgic 853 26 : generic_timer (hyp) 854 27 : generic_timer (virt) 855 28 : Reserved (Legacy FIQ) 856 29 : generic_timer (phys, sec) 857 30 : generic_timer (phys, non-sec) 858 31 : Reserved (Legacy IRQ) 859 32- 95: Mother board peripherals (SPIs) 860 32 : Reserved (SP805) 861 33 : Reserved (IOFPGA SW int) 862 34-35: Reserved (SP804) 863 36 : RTC 864 37-40: uart0-uart3 865 41-42: Reserved (PL180) 866 43 : Reserved (AACI) 867 44-45: kmi0-kmi1 868 46 : Reserved (CLCD) 869 47 : Reserved (Ethernet) 870 48 : Reserved (USB) 871 95-255: On-chip interrupt sources (we use these for 872 gem5-specific devices, SPIs) 873 95 : HDLCD 874 96- 98: GPU (reserved) 875 100-103: PCI 876 256-319: MSI frame 0 (gem5-specific, SPIs) 877 320-511: Unused 878 879 """ 880 881 # Everything above 2GiB is memory 882 _mem_regions = [(Addr('2GB'), Addr('510GB'))] 883 884 _off_chip_ranges = [ 885 # CS1-CS5 886 AddrRange(0x0c000000, 0x1fffffff), 887 # External AXI interface (PCI) 888 AddrRange(0x2f000000, 0x7fffffff), 889 ] 890 891 # Platform control device (off-chip) 892 realview_io = RealViewCtrl(proc_id0=0x14000000, proc_id1=0x14000000, 893 idreg=0x02250000, pio_addr=0x1c010000) 894 mcc = VExpressMCC() 895 dcc = CoreTile2A15DCC() 896 897 ### On-chip devices ### 898 gic = kvm_gicv2_class(dist_addr=0x2c001000, cpu_addr=0x2c002000, 899 it_lines=512) 900 vgic = VGic(vcpu_addr=0x2c006000, hv_addr=0x2c004000, ppint=25) 901 gicv2m = Gicv2m() 902 gicv2m.frames = [ 903 Gicv2mFrame(spi_base=256, spi_len=64, addr=0x2c1c0000), 904 ] 905 906 generic_timer = GenericTimer(int_phys=29, int_virt=27) 907 908 hdlcd = HDLcd(pxl_clk=dcc.osc_pxl, 909 pio_addr=0x2b000000, int_num=95) 910 911 def _on_chip_devices(self): 912 return [ 913 self.gic, self.vgic, self.gicv2m, 914 self.hdlcd, 915 self.generic_timer, 916 ] 917 918 ### Off-chip devices ### 919 uart0 = Pl011(pio_addr=0x1c090000, int_num=37) 920 921 kmi0 = Pl050(pio_addr=0x1c060000, int_num=44) 922 kmi1 = Pl050(pio_addr=0x1c070000, int_num=45, is_mouse=True) 923 924 rtc = PL031(pio_addr=0x1c170000, int_num=36) 925 926 ### gem5-specific off-chip devices ### 927 pci_host = GenericArmPciHost( 928 conf_base=0x30000000, conf_size='256MB', conf_device_bits=12, 929 pci_pio_base=0x2f000000, 930 int_policy="ARM_PCI_INT_DEV", int_base=100, int_count=4) 931 932 energy_ctrl = EnergyCtrl(pio_addr=0x10000000) 933 934 935 def _off_chip_devices(self): 936 return [ 937 self.realview_io, 938 self.uart0, 939 self.kmi0, self.kmi1, 940 self.rtc, 941 self.pci_host, 942 self.energy_ctrl, 943 ] 944 945 def attachPciDevice(self, device, *args, **kwargs): 946 device.host = self.pci_host 947 self._attach_device(device, *args, **kwargs) 948 949 def setupBootLoader(self, mem_bus, cur_sys, loc): 950 self.nvmem = SimpleMemory(range=AddrRange(0, size='64MB'), 951 conf_table_reported=False) 952 self.nvmem.port = mem_bus.master 953 cur_sys.boot_loader = [ loc('boot_emm.arm64'), loc('boot_emm.arm') ] 954 cur_sys.atags_addr = 0x8000000 955 cur_sys.load_addr_mask = 0xfffffff 956 cur_sys.load_offset = 0x80000000 957