RealView.py revision 11244:a2af58a06c4e
1# Copyright (c) 2009-2015 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder.  You may use the software subject to the license
9# terms below provided that you ensure that this notice is replicated
10# unmodified and in its entirety in all distributions of the software,
11# modified or unmodified, in source code or in binary form.
12#
13# Copyright (c) 2006-2007 The Regents of The University of Michigan
14# All rights reserved.
15#
16# Redistribution and use in source and binary forms, with or without
17# modification, are permitted provided that the following conditions are
18# met: redistributions of source code must retain the above copyright
19# notice, this list of conditions and the following disclaimer;
20# redistributions in binary form must reproduce the above copyright
21# notice, this list of conditions and the following disclaimer in the
22# documentation and/or other materials provided with the distribution;
23# neither the name of the copyright holders nor the names of its
24# contributors may be used to endorse or promote products derived from
25# this software without specific prior written permission.
26#
27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38#
39# Authors: Ali Saidi
40#          Gabe Black
41#          William Wang
42
43from m5.params import *
44from m5.proxy import *
45from ClockDomain import ClockDomain
46from VoltageDomain import VoltageDomain
47from Device import BasicPioDevice, PioDevice, IsaFake, BadAddr, DmaDevice
48from PciHost import *
49from Ethernet import NSGigE, IGbE_igb, IGbE_e1000
50from Ide import *
51from Platform import Platform
52from Terminal import Terminal
53from Uart import Uart
54from SimpleMemory import SimpleMemory
55from Gic import *
56from EnergyCtrl import EnergyCtrl
57from ClockDomain import SrcClockDomain
58from SubSystem import SubSystem
59
60class AmbaPioDevice(BasicPioDevice):
61    type = 'AmbaPioDevice'
62    abstract = True
63    cxx_header = "dev/arm/amba_device.hh"
64    amba_id = Param.UInt32("ID of AMBA device for kernel detection")
65
66class AmbaIntDevice(AmbaPioDevice):
67    type = 'AmbaIntDevice'
68    abstract = True
69    cxx_header = "dev/arm/amba_device.hh"
70    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
71    int_num = Param.UInt32("Interrupt number that connects to GIC")
72    int_delay = Param.Latency("100ns",
73            "Time between action and interrupt generation by device")
74
75class AmbaDmaDevice(DmaDevice):
76    type = 'AmbaDmaDevice'
77    abstract = True
78    cxx_header = "dev/arm/amba_device.hh"
79    pio_addr = Param.Addr("Address for AMBA slave interface")
80    pio_latency = Param.Latency("10ns", "Time between action and write/read result by AMBA DMA Device")
81    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
82    int_num = Param.UInt32("Interrupt number that connects to GIC")
83    amba_id = Param.UInt32("ID of AMBA device for kernel detection")
84
85class A9SCU(BasicPioDevice):
86    type = 'A9SCU'
87    cxx_header = "dev/arm/a9scu.hh"
88
89class RealViewCtrl(BasicPioDevice):
90    type = 'RealViewCtrl'
91    cxx_header = "dev/arm/rv_ctrl.hh"
92    proc_id0 = Param.UInt32(0x0C000000, "Processor ID, SYS_PROCID")
93    proc_id1 = Param.UInt32(0x0C000222, "Processor ID, SYS_PROCID1")
94    idreg = Param.UInt32(0x00000000, "ID Register, SYS_ID")
95
96class RealViewOsc(ClockDomain):
97    type = 'RealViewOsc'
98    cxx_header = "dev/arm/rv_ctrl.hh"
99
100    parent = Param.RealViewCtrl(Parent.any, "RealView controller")
101
102    # TODO: We currently don't have the notion of a clock source,
103    # which means we have to associate oscillators with a voltage
104    # source.
105    voltage_domain = Param.VoltageDomain(Parent.voltage_domain,
106                                         "Voltage domain")
107
108    # See ARM DUI 0447J (ARM Motherboard Express uATX -- V2M-P1) and
109    # the individual core/logic tile reference manuals for details
110    # about the site/position/dcc/device allocation.
111    site = Param.UInt8("Board Site")
112    position = Param.UInt8("Position in device stack")
113    dcc = Param.UInt8("Daughterboard Configuration Controller")
114    device = Param.UInt8("Device ID")
115
116    freq = Param.Clock("Default frequency")
117
118class VExpressMCC(SubSystem):
119    """ARM V2M-P1 Motherboard Configuration Controller
120
121This subsystem describes a subset of the devices that sit behind the
122motherboard configuration controller on the the ARM Motherboard
123Express (V2M-P1) motherboard. See ARM DUI 0447J for details.
124    """
125
126    class Osc(RealViewOsc):
127        site, position, dcc = (0, 0, 0)
128
129    osc_mcc = Osc(device=0, freq="50MHz")
130    osc_clcd = Osc(device=1, freq="23.75MHz")
131    osc_peripheral = Osc(device=2, freq="24MHz")
132    osc_system_bus = Osc(device=4, freq="24MHz")
133
134class CoreTile2A15DCC(SubSystem):
135    """ARM CoreTile Express A15x2 Daughterboard Configuration Controller
136
137This subsystem describes a subset of the devices that sit behind the
138daughterboard configuration controller on a CoreTile Express A15x2. See
139ARM DUI 0604E for details.
140    """
141
142    class Osc(RealViewOsc):
143        site, position, dcc = (1, 0, 0)
144
145    # See Table 2.8 in ARM DUI 0604E (CoreTile Express A15x2 TRM)
146    osc_cpu = Osc(device=0, freq="60MHz")
147    osc_hsbm = Osc(device=4, freq="40MHz")
148    osc_pxl = Osc(device=5, freq="23.75MHz")
149    osc_smb = Osc(device=6, freq="50MHz")
150    osc_sys = Osc(device=7, freq="60MHz")
151    osc_ddr = Osc(device=8, freq="40MHz")
152
153class VGic(PioDevice):
154    type = 'VGic'
155    cxx_header = "dev/arm/vgic.hh"
156    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
157    platform = Param.Platform(Parent.any, "Platform this device is part of.")
158    vcpu_addr = Param.Addr(0, "Address for vcpu interfaces")
159    hv_addr = Param.Addr(0, "Address for hv control")
160    pio_delay = Param.Latency('10ns', "Delay for PIO r/w")
161   # The number of list registers is not currently configurable at runtime.
162    ppint = Param.UInt32("HV maintenance interrupt number")
163
164class AmbaFake(AmbaPioDevice):
165    type = 'AmbaFake'
166    cxx_header = "dev/arm/amba_fake.hh"
167    ignore_access = Param.Bool(False, "Ignore reads/writes to this device, (e.g. IsaFake + AMBA)")
168    amba_id = 0;
169
170class Pl011(Uart):
171    type = 'Pl011'
172    cxx_header = "dev/arm/pl011.hh"
173    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
174    int_num = Param.UInt32("Interrupt number that connects to GIC")
175    end_on_eot = Param.Bool(False, "End the simulation when a EOT is received on the UART")
176    int_delay = Param.Latency("100ns", "Time between action and interrupt generation by UART")
177
178class Sp804(AmbaPioDevice):
179    type = 'Sp804'
180    cxx_header = "dev/arm/timer_sp804.hh"
181    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
182    int_num0 = Param.UInt32("Interrupt number that connects to GIC")
183    clock0 = Param.Clock('1MHz', "Clock speed of the input")
184    int_num1 = Param.UInt32("Interrupt number that connects to GIC")
185    clock1 = Param.Clock('1MHz', "Clock speed of the input")
186    amba_id = 0x00141804
187
188class CpuLocalTimer(BasicPioDevice):
189    type = 'CpuLocalTimer'
190    cxx_header = "dev/arm/timer_cpulocal.hh"
191    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
192    int_num_timer = Param.UInt32("Interrrupt number used per-cpu to GIC")
193    int_num_watchdog = Param.UInt32("Interrupt number for per-cpu watchdog to GIC")
194
195class GenericTimer(SimObject):
196    type = 'GenericTimer'
197    cxx_header = "dev/arm/generic_timer.hh"
198    system = Param.System(Parent.any, "system")
199    gic = Param.BaseGic(Parent.any, "GIC to use for interrupting")
200    # @todo: for now only two timers per CPU is supported, which is the
201    # normal behaviour when security extensions are disabled.
202    int_phys = Param.UInt32("Physical timer interrupt number")
203    int_virt = Param.UInt32("Virtual timer interrupt number")
204
205class GenericTimerMem(PioDevice):
206    type = 'GenericTimerMem'
207    cxx_header = "dev/arm/generic_timer.hh"
208    gic = Param.BaseGic(Parent.any, "GIC to use for interrupting")
209
210    base = Param.Addr(0, "Base address")
211
212    int_phys = Param.UInt32("Interrupt number")
213    int_virt = Param.UInt32("Interrupt number")
214
215class PL031(AmbaIntDevice):
216    type = 'PL031'
217    cxx_header = "dev/arm/rtc_pl031.hh"
218    time = Param.Time('01/01/2009', "System time to use ('Now' for actual time)")
219    amba_id = 0x00341031
220
221class Pl050(AmbaIntDevice):
222    type = 'Pl050'
223    cxx_header = "dev/arm/kmi.hh"
224    vnc = Param.VncInput(Parent.any, "Vnc server for remote frame buffer display")
225    is_mouse = Param.Bool(False, "Is this interface a mouse, if not a keyboard")
226    int_delay = '1us'
227    amba_id = 0x00141050
228
229class Pl111(AmbaDmaDevice):
230    type = 'Pl111'
231    cxx_header = "dev/arm/pl111.hh"
232    pixel_clock = Param.Clock('24MHz', "Pixel clock")
233    vnc   = Param.VncInput(Parent.any, "Vnc server for remote frame buffer display")
234    amba_id = 0x00141111
235    enable_capture = Param.Bool(True, "capture frame to system.framebuffer.bmp")
236
237class HDLcd(AmbaDmaDevice):
238    type = 'HDLcd'
239    cxx_header = "dev/arm/hdlcd.hh"
240    vnc = Param.VncInput(Parent.any, "Vnc server for remote frame buffer "
241                                     "display")
242    amba_id = 0x00141000
243    workaround_swap_rb = Param.Bool(False, "Workaround incorrect color "
244                                    "selector order in some kernels")
245    workaround_dma_line_count = Param.Bool(True, "Workaround incorrect "
246                                           "DMA line count (off by 1)")
247    enable_capture = Param.Bool(True, "capture frame to system.framebuffer.bmp")
248
249    pixel_buffer_size = Param.MemorySize32("2kB", "Size of address range")
250
251    pxl_clk = Param.ClockDomain("Pixel clock source")
252    pixel_chunk = Param.Unsigned(32, "Number of pixels to handle in one batch")
253
254class RealView(Platform):
255    type = 'RealView'
256    cxx_header = "dev/arm/realview.hh"
257    system = Param.System(Parent.any, "system")
258    _mem_regions = [(Addr(0), Addr('256MB'))]
259
260    def attachPciDevices(self):
261        pass
262
263    def enableMSIX(self):
264        pass
265
266    def onChipIOClkDomain(self, clkdomain):
267        pass
268
269    def offChipIOClkDomain(self, clkdomain):
270        pass
271
272    def setupBootLoader(self, mem_bus, cur_sys, loc):
273        self.nvmem = SimpleMemory(range = AddrRange('2GB', size = '64MB'),
274                                  conf_table_reported = False)
275        self.nvmem.port = mem_bus.master
276        cur_sys.boot_loader = loc('boot.arm')
277        cur_sys.atags_addr = 0x100
278        cur_sys.load_addr_mask = 0xfffffff
279        cur_sys.load_offset = 0
280
281
282# Reference for memory map and interrupt number
283# RealView Platform Baseboard Explore for Cortex-A9 User Guide(ARM DUI 0440A)
284# Chapter 4: Programmer's Reference
285class RealViewPBX(RealView):
286    uart = Pl011(pio_addr=0x10009000, int_num=44)
287    realview_io = RealViewCtrl(pio_addr=0x10000000)
288    mcc = VExpressMCC()
289    dcc = CoreTile2A15DCC()
290    gic = Pl390()
291    pci_host = GenericPciHost(
292        conf_base=0x30000000, conf_size='256MB', conf_device_bits=16,
293        pci_pio_base=0)
294    timer0 = Sp804(int_num0=36, int_num1=36, pio_addr=0x10011000)
295    timer1 = Sp804(int_num0=37, int_num1=37, pio_addr=0x10012000)
296    local_cpu_timer = CpuLocalTimer(int_num_timer=29, int_num_watchdog=30, pio_addr=0x1f000600)
297    clcd = Pl111(pio_addr=0x10020000, int_num=55)
298    kmi0   = Pl050(pio_addr=0x10006000, int_num=52)
299    kmi1   = Pl050(pio_addr=0x10007000, int_num=53, is_mouse=True)
300    a9scu  = A9SCU(pio_addr=0x1f000000)
301    cf_ctrl = IdeController(disks=[], pci_func=0, pci_dev=7, pci_bus=2,
302                            io_shift = 1, ctrl_offset = 2, Command = 0x1,
303                            BAR0 = 0x18000000, BAR0Size = '16B',
304                            BAR1 = 0x18000100, BAR1Size = '1B',
305                            BAR0LegacyIO = True, BAR1LegacyIO = True)
306
307
308    l2x0_fake     = IsaFake(pio_addr=0x1f002000, pio_size=0xfff)
309    flash_fake    = IsaFake(pio_addr=0x40000000, pio_size=0x20000000,
310                            fake_mem=True)
311    dmac_fake     = AmbaFake(pio_addr=0x10030000)
312    uart1_fake    = AmbaFake(pio_addr=0x1000a000)
313    uart2_fake    = AmbaFake(pio_addr=0x1000b000)
314    uart3_fake    = AmbaFake(pio_addr=0x1000c000)
315    smc_fake      = AmbaFake(pio_addr=0x100e1000)
316    sp810_fake    = AmbaFake(pio_addr=0x10001000, ignore_access=True)
317    watchdog_fake = AmbaFake(pio_addr=0x10010000)
318    gpio0_fake    = AmbaFake(pio_addr=0x10013000)
319    gpio1_fake    = AmbaFake(pio_addr=0x10014000)
320    gpio2_fake    = AmbaFake(pio_addr=0x10015000)
321    ssp_fake      = AmbaFake(pio_addr=0x1000d000)
322    sci_fake      = AmbaFake(pio_addr=0x1000e000)
323    aaci_fake     = AmbaFake(pio_addr=0x10004000)
324    mmc_fake      = AmbaFake(pio_addr=0x10005000)
325    rtc           = PL031(pio_addr=0x10017000, int_num=42)
326    energy_ctrl   = EnergyCtrl(pio_addr=0x1000f000)
327
328
329    # Attach I/O devices that are on chip and also set the appropriate
330    # ranges for the bridge
331    def attachOnChipIO(self, bus, bridge):
332       self.gic.pio = bus.master
333       self.l2x0_fake.pio = bus.master
334       self.a9scu.pio = bus.master
335       self.local_cpu_timer.pio = bus.master
336       # Bridge ranges based on excluding what is part of on-chip I/O
337       # (gic, l2x0, a9scu, local_cpu_timer)
338       bridge.ranges = [AddrRange(self.realview_io.pio_addr,
339                                  self.a9scu.pio_addr - 1),
340                        AddrRange(self.flash_fake.pio_addr,
341                                  self.flash_fake.pio_addr + \
342                                  self.flash_fake.pio_size - 1)]
343
344    # Set the clock domain for IO objects that are considered
345    # to be "close" to the cores.
346    def onChipIOClkDomain(self, clkdomain):
347        self.gic.clk_domain             = clkdomain
348        self.l2x0_fake.clk_domain       = clkdomain
349        self.a9scu.clkdomain            = clkdomain
350        self.local_cpu_timer.clk_domain = clkdomain
351
352    # Attach I/O devices to specified bus object.  Can't do this
353    # earlier, since the bus object itself is typically defined at the
354    # System level.
355    def attachIO(self, bus):
356       self.uart.pio          = bus.master
357       self.realview_io.pio   = bus.master
358       self.pci_host.pio      = bus.master
359       self.timer0.pio        = bus.master
360       self.timer1.pio        = bus.master
361       self.clcd.pio          = bus.master
362       self.clcd.dma          = bus.slave
363       self.kmi0.pio          = bus.master
364       self.kmi1.pio          = bus.master
365       self.cf_ctrl.pio       = bus.master
366       self.cf_ctrl.dma       = bus.slave
367       self.dmac_fake.pio     = bus.master
368       self.uart1_fake.pio    = bus.master
369       self.uart2_fake.pio    = bus.master
370       self.uart3_fake.pio    = bus.master
371       self.smc_fake.pio      = bus.master
372       self.sp810_fake.pio    = bus.master
373       self.watchdog_fake.pio = bus.master
374       self.gpio0_fake.pio    = bus.master
375       self.gpio1_fake.pio    = bus.master
376       self.gpio2_fake.pio    = bus.master
377       self.ssp_fake.pio      = bus.master
378       self.sci_fake.pio      = bus.master
379       self.aaci_fake.pio     = bus.master
380       self.mmc_fake.pio      = bus.master
381       self.rtc.pio           = bus.master
382       self.flash_fake.pio    = bus.master
383       self.energy_ctrl.pio   = bus.master
384
385    # Set the clock domain for IO objects that are considered
386    # to be "far" away from the cores.
387    def offChipIOClkDomain(self, clkdomain):
388        self.uart.clk_domain          = clkdomain
389        self.realview_io.clk_domain   = clkdomain
390        self.timer0.clk_domain        = clkdomain
391        self.timer1.clk_domain        = clkdomain
392        self.clcd.clk_domain          = clkdomain
393        self.kmi0.clk_domain          = clkdomain
394        self.kmi1.clk_domain          = clkdomain
395        self.cf_ctrl.clk_domain       = clkdomain
396        self.dmac_fake.clk_domain     = clkdomain
397        self.uart1_fake.clk_domain    = clkdomain
398        self.uart2_fake.clk_domain    = clkdomain
399        self.uart3_fake.clk_domain    = clkdomain
400        self.smc_fake.clk_domain      = clkdomain
401        self.sp810_fake.clk_domain    = clkdomain
402        self.watchdog_fake.clk_domain = clkdomain
403        self.gpio0_fake.clk_domain    = clkdomain
404        self.gpio1_fake.clk_domain    = clkdomain
405        self.gpio2_fake.clk_domain    = clkdomain
406        self.ssp_fake.clk_domain      = clkdomain
407        self.sci_fake.clk_domain      = clkdomain
408        self.aaci_fake.clk_domain     = clkdomain
409        self.mmc_fake.clk_domain      = clkdomain
410        self.rtc.clk_domain           = clkdomain
411        self.flash_fake.clk_domain    = clkdomain
412        self.energy_ctrl.clk_domain   = clkdomain
413
414# Reference for memory map and interrupt number
415# RealView Emulation Baseboard User Guide (ARM DUI 0143B)
416# Chapter 4: Programmer's Reference
417class RealViewEB(RealView):
418    uart = Pl011(pio_addr=0x10009000, int_num=44)
419    realview_io = RealViewCtrl(pio_addr=0x10000000, idreg=0x01400500)
420    mcc = VExpressMCC()
421    dcc = CoreTile2A15DCC()
422    gic = Pl390(dist_addr=0x10041000, cpu_addr=0x10040000)
423    timer0 = Sp804(int_num0=36, int_num1=36, pio_addr=0x10011000)
424    timer1 = Sp804(int_num0=37, int_num1=37, pio_addr=0x10012000)
425    clcd   = Pl111(pio_addr=0x10020000, int_num=23)
426    kmi0   = Pl050(pio_addr=0x10006000, int_num=20)
427    kmi1   = Pl050(pio_addr=0x10007000, int_num=21, is_mouse=True)
428
429    l2x0_fake     = IsaFake(pio_addr=0x1f002000, pio_size=0xfff, warn_access="1")
430    flash_fake    = IsaFake(pio_addr=0x40000000, pio_size=0x20000000-1,
431                            fake_mem=True)
432    dmac_fake     = AmbaFake(pio_addr=0x10030000)
433    uart1_fake    = AmbaFake(pio_addr=0x1000a000)
434    uart2_fake    = AmbaFake(pio_addr=0x1000b000)
435    uart3_fake    = AmbaFake(pio_addr=0x1000c000)
436    smcreg_fake   = IsaFake(pio_addr=0x10080000, pio_size=0x10000-1)
437    smc_fake      = AmbaFake(pio_addr=0x100e1000)
438    sp810_fake    = AmbaFake(pio_addr=0x10001000, ignore_access=True)
439    watchdog_fake = AmbaFake(pio_addr=0x10010000)
440    gpio0_fake    = AmbaFake(pio_addr=0x10013000)
441    gpio1_fake    = AmbaFake(pio_addr=0x10014000)
442    gpio2_fake    = AmbaFake(pio_addr=0x10015000)
443    ssp_fake      = AmbaFake(pio_addr=0x1000d000)
444    sci_fake      = AmbaFake(pio_addr=0x1000e000)
445    aaci_fake     = AmbaFake(pio_addr=0x10004000)
446    mmc_fake      = AmbaFake(pio_addr=0x10005000)
447    rtc_fake      = AmbaFake(pio_addr=0x10017000, amba_id=0x41031)
448    energy_ctrl   = EnergyCtrl(pio_addr=0x1000f000)
449
450    # Attach I/O devices that are on chip and also set the appropriate
451    # ranges for the bridge
452    def attachOnChipIO(self, bus, bridge):
453       self.gic.pio = bus.master
454       self.l2x0_fake.pio = bus.master
455       # Bridge ranges based on excluding what is part of on-chip I/O
456       # (gic, l2x0)
457       bridge.ranges = [AddrRange(self.realview_io.pio_addr,
458                                  self.gic.cpu_addr - 1),
459                        AddrRange(self.flash_fake.pio_addr, Addr.max)]
460
461    # Set the clock domain for IO objects that are considered
462    # to be "close" to the cores.
463    def onChipIOClkDomain(self, clkdomain):
464        self.gic.clk_domain             = clkdomain
465        self.l2x0_fake.clk_domain       = clkdomain
466
467    # Attach I/O devices to specified bus object.  Can't do this
468    # earlier, since the bus object itself is typically defined at the
469    # System level.
470    def attachIO(self, bus):
471       self.uart.pio          = bus.master
472       self.realview_io.pio   = bus.master
473       self.pci_host.pio      = bus.master
474       self.timer0.pio        = bus.master
475       self.timer1.pio        = bus.master
476       self.clcd.pio          = bus.master
477       self.clcd.dma          = bus.slave
478       self.kmi0.pio          = bus.master
479       self.kmi1.pio          = bus.master
480       self.dmac_fake.pio     = bus.master
481       self.uart1_fake.pio    = bus.master
482       self.uart2_fake.pio    = bus.master
483       self.uart3_fake.pio    = bus.master
484       self.smc_fake.pio      = bus.master
485       self.sp810_fake.pio    = bus.master
486       self.watchdog_fake.pio = bus.master
487       self.gpio0_fake.pio    = bus.master
488       self.gpio1_fake.pio    = bus.master
489       self.gpio2_fake.pio    = bus.master
490       self.ssp_fake.pio      = bus.master
491       self.sci_fake.pio      = bus.master
492       self.aaci_fake.pio     = bus.master
493       self.mmc_fake.pio      = bus.master
494       self.rtc_fake.pio      = bus.master
495       self.flash_fake.pio    = bus.master
496       self.smcreg_fake.pio   = bus.master
497       self.energy_ctrl.pio   = bus.master
498
499    # Set the clock domain for IO objects that are considered
500    # to be "far" away from the cores.
501    def offChipIOClkDomain(self, clkdomain):
502        self.uart.clk_domain          = clkdomain
503        self.realview_io.clk_domain   = clkdomain
504        self.timer0.clk_domain        = clkdomain
505        self.timer1.clk_domain        = clkdomain
506        self.clcd.clk_domain          = clkdomain
507        self.kmi0.clk_domain          = clkdomain
508        self.kmi1.clk_domain          = clkdomain
509        self.dmac_fake.clk_domain     = clkdomain
510        self.uart1_fake.clk_domain    = clkdomain
511        self.uart2_fake.clk_domain    = clkdomain
512        self.uart3_fake.clk_domain    = clkdomain
513        self.smc_fake.clk_domain      = clkdomain
514        self.sp810_fake.clk_domain    = clkdomain
515        self.watchdog_fake.clk_domain = clkdomain
516        self.gpio0_fake.clk_domain    = clkdomain
517        self.gpio1_fake.clk_domain    = clkdomain
518        self.gpio2_fake.clk_domain    = clkdomain
519        self.ssp_fake.clk_domain      = clkdomain
520        self.sci_fake.clk_domain      = clkdomain
521        self.aaci_fake.clk_domain     = clkdomain
522        self.mmc_fake.clk_domain      = clkdomain
523        self.rtc.clk_domain           = clkdomain
524        self.flash_fake.clk_domain    = clkdomain
525        self.smcreg_fake.clk_domain   = clkdomain
526        self.energy_ctrl.clk_domain   = clkdomain
527
528class VExpress_EMM(RealView):
529    _mem_regions = [(Addr('2GB'), Addr('2GB'))]
530    uart = Pl011(pio_addr=0x1c090000, int_num=37)
531    realview_io = RealViewCtrl(
532        proc_id0=0x14000000, proc_id1=0x14000000,
533        idreg=0x02250000, pio_addr=0x1C010000)
534    mcc = VExpressMCC()
535    dcc = CoreTile2A15DCC()
536    gic = Pl390(dist_addr=0x2C001000, cpu_addr=0x2C002000)
537    pci_host = GenericPciHost(
538        conf_base=0x30000000, conf_size='256MB', conf_device_bits=16,
539        pci_pio_base=0)
540    local_cpu_timer = CpuLocalTimer(int_num_timer=29, int_num_watchdog=30, pio_addr=0x2C080000)
541    generic_timer = GenericTimer(int_phys=29, int_virt=27)
542    timer0 = Sp804(int_num0=34, int_num1=34, pio_addr=0x1C110000, clock0='1MHz', clock1='1MHz')
543    timer1 = Sp804(int_num0=35, int_num1=35, pio_addr=0x1C120000, clock0='1MHz', clock1='1MHz')
544    clcd   = Pl111(pio_addr=0x1c1f0000, int_num=46)
545    hdlcd  = HDLcd(pxl_clk=dcc.osc_pxl,
546                   pio_addr=0x2b000000, int_num=117,
547                   workaround_swap_rb=True)
548    kmi0   = Pl050(pio_addr=0x1c060000, int_num=44)
549    kmi1   = Pl050(pio_addr=0x1c070000, int_num=45, is_mouse=True)
550    vgic   = VGic(vcpu_addr=0x2c006000, hv_addr=0x2c004000, ppint=25)
551    cf_ctrl = IdeController(disks=[], pci_func=0, pci_dev=0, pci_bus=2,
552                            io_shift = 2, ctrl_offset = 2, Command = 0x1,
553                            BAR0 = 0x1C1A0000, BAR0Size = '256B',
554                            BAR1 = 0x1C1A0100, BAR1Size = '4096B',
555                            BAR0LegacyIO = True, BAR1LegacyIO = True)
556
557    vram           = SimpleMemory(range = AddrRange(0x18000000, size='32MB'),
558                                  conf_table_reported = False)
559    rtc            = PL031(pio_addr=0x1C170000, int_num=36)
560
561    l2x0_fake      = IsaFake(pio_addr=0x2C100000, pio_size=0xfff)
562    uart1_fake     = AmbaFake(pio_addr=0x1C0A0000)
563    uart2_fake     = AmbaFake(pio_addr=0x1C0B0000)
564    uart3_fake     = AmbaFake(pio_addr=0x1C0C0000)
565    sp810_fake     = AmbaFake(pio_addr=0x1C020000, ignore_access=True)
566    watchdog_fake  = AmbaFake(pio_addr=0x1C0F0000)
567    aaci_fake      = AmbaFake(pio_addr=0x1C040000)
568    lan_fake       = IsaFake(pio_addr=0x1A000000, pio_size=0xffff)
569    usb_fake       = IsaFake(pio_addr=0x1B000000, pio_size=0x1ffff)
570    mmc_fake       = AmbaFake(pio_addr=0x1c050000)
571    energy_ctrl    = EnergyCtrl(pio_addr=0x1c080000)
572
573    # Attach any PCI devices that are supported
574    def attachPciDevices(self):
575        self.ethernet = IGbE_e1000(pci_bus=0, pci_dev=0, pci_func=0,
576                                   InterruptLine=1, InterruptPin=1)
577        self.ide = IdeController(disks = [], pci_bus=0, pci_dev=1, pci_func=0,
578                                 InterruptLine=2, InterruptPin=2)
579
580    def enableMSIX(self):
581        self.gic = Pl390(dist_addr=0x2C001000, cpu_addr=0x2C002000, it_lines=512)
582        self.gicv2m = Gicv2m()
583        self.gicv2m.frames = [Gicv2mFrame(spi_base=256, spi_len=64, addr=0x2C1C0000)]
584
585    def setupBootLoader(self, mem_bus, cur_sys, loc):
586        self.nvmem = SimpleMemory(range = AddrRange('64MB'),
587                                  conf_table_reported = False)
588        self.nvmem.port = mem_bus.master
589        cur_sys.boot_loader = loc('boot_emm.arm')
590        cur_sys.atags_addr = 0x8000000
591        cur_sys.load_addr_mask = 0xfffffff
592        cur_sys.load_offset = 0x80000000
593
594    # Attach I/O devices that are on chip and also set the appropriate
595    # ranges for the bridge
596    def attachOnChipIO(self, bus, bridge=None):
597        self.gic.pio             = bus.master
598        self.vgic.pio            = bus.master
599        self.local_cpu_timer.pio = bus.master
600        if hasattr(self, "gicv2m"):
601            self.gicv2m.pio      = bus.master
602        self.hdlcd.dma           = bus.slave
603        if bridge:
604            # Bridge ranges based on excluding what is part of on-chip I/O
605            # (gic, a9scu)
606            bridge.ranges = [AddrRange(0x2F000000, size='16MB'),
607                             AddrRange(0x2B000000, size='4MB'),
608                             AddrRange(0x30000000, size='256MB'),
609                             AddrRange(0x40000000, size='512MB'),
610                             AddrRange(0x18000000, size='64MB'),
611                             AddrRange(0x1C000000, size='64MB')]
612
613
614    # Set the clock domain for IO objects that are considered
615    # to be "close" to the cores.
616    def onChipIOClkDomain(self, clkdomain):
617        self.gic.clk_domain             = clkdomain
618        if hasattr(self, "gicv2m"):
619            self.gicv2m.clk_domain      = clkdomain
620        self.hdlcd.clk_domain           = clkdomain
621        self.vgic.clk_domain            = clkdomain
622
623    # Attach I/O devices to specified bus object.  Done here
624    # as the specified bus to connect to may not always be fixed.
625    def attachIO(self, bus):
626       self.uart.pio            = bus.master
627       self.realview_io.pio     = bus.master
628       self.pci_host.pio        = bus.master
629       self.timer0.pio          = bus.master
630       self.timer1.pio          = bus.master
631       self.clcd.pio            = bus.master
632       self.clcd.dma            = bus.slave
633       self.hdlcd.pio           = bus.master
634       self.kmi0.pio            = bus.master
635       self.kmi1.pio            = bus.master
636       self.cf_ctrl.pio         = bus.master
637       self.cf_ctrl.dma         = bus.slave
638       self.rtc.pio             = bus.master
639       self.vram.port           = bus.master
640
641       self.l2x0_fake.pio       = bus.master
642       self.uart1_fake.pio      = bus.master
643       self.uart2_fake.pio      = bus.master
644       self.uart3_fake.pio      = bus.master
645       self.sp810_fake.pio      = bus.master
646       self.watchdog_fake.pio   = bus.master
647       self.aaci_fake.pio       = bus.master
648       self.lan_fake.pio        = bus.master
649       self.usb_fake.pio        = bus.master
650       self.mmc_fake.pio        = bus.master
651       self.energy_ctrl.pio     = bus.master
652
653       # Try to attach the I/O if it exists
654       try:
655           self.ide.pio         = bus.master
656           self.ide.dma         = bus.slave
657           self.ethernet.pio    = bus.master
658           self.ethernet.dma    = bus.slave
659       except:
660           pass
661
662    # Set the clock domain for IO objects that are considered
663    # to be "far" away from the cores.
664    def offChipIOClkDomain(self, clkdomain):
665        self.uart.clk_domain          = clkdomain
666        self.realview_io.clk_domain   = clkdomain
667        self.timer0.clk_domain        = clkdomain
668        self.timer1.clk_domain        = clkdomain
669        self.clcd.clk_domain          = clkdomain
670        self.kmi0.clk_domain          = clkdomain
671        self.kmi1.clk_domain          = clkdomain
672        self.cf_ctrl.clk_domain       = clkdomain
673        self.rtc.clk_domain           = clkdomain
674        self.vram.clk_domain          = clkdomain
675
676        self.l2x0_fake.clk_domain     = clkdomain
677        self.uart1_fake.clk_domain    = clkdomain
678        self.uart2_fake.clk_domain    = clkdomain
679        self.uart3_fake.clk_domain    = clkdomain
680        self.sp810_fake.clk_domain    = clkdomain
681        self.watchdog_fake.clk_domain = clkdomain
682        self.aaci_fake.clk_domain     = clkdomain
683        self.lan_fake.clk_domain      = clkdomain
684        self.usb_fake.clk_domain      = clkdomain
685        self.mmc_fake.clk_domain      = clkdomain
686        self.energy_ctrl.clk_domain   = clkdomain
687
688class VExpress_EMM64(VExpress_EMM):
689    # Three memory regions are specified totalling 512GB
690    _mem_regions = [(Addr('2GB'), Addr('2GB')), (Addr('34GB'), Addr('30GB')),
691                    (Addr('512GB'), Addr('480GB'))]
692    pci_host = GenericPciHost(
693        conf_base=0x30000000, conf_size='256MB', conf_device_bits=12,
694        pci_pio_base=0x2f000000)
695
696    def setupBootLoader(self, mem_bus, cur_sys, loc):
697        self.nvmem = SimpleMemory(range = AddrRange(0, size = '64MB'))
698        self.nvmem.port = mem_bus.master
699        cur_sys.boot_loader = loc('boot_emm.arm64')
700        cur_sys.atags_addr = 0x8000000
701        cur_sys.load_addr_mask = 0xfffffff
702        cur_sys.load_offset = 0x80000000
703
704
705