Device.py revision 13665:9c7fe3811b88
15217Ssaidi@eecs.umich.edu# Copyright (c) 2012-2016 ARM Limited
212109SRekai.GonzalezAlberquilla@arm.com# All rights reserved.
39920Syasuko.eckert@amd.com#
49428SAndreas.Sandberg@ARM.com# The license below extends only to copyright in the software and shall
59428SAndreas.Sandberg@ARM.com# not be construed as granting a license to any other intellectual
69428SAndreas.Sandberg@ARM.com# property including but not limited to intellectual property relating
79428SAndreas.Sandberg@ARM.com# to a hardware implementation of the functionality of the software
89428SAndreas.Sandberg@ARM.com# licensed hereunder.  You may use the software subject to the license
99428SAndreas.Sandberg@ARM.com# terms below provided that you ensure that this notice is replicated
109428SAndreas.Sandberg@ARM.com# unmodified and in its entirety in all distributions of the software,
119428SAndreas.Sandberg@ARM.com# modified or unmodified, in source code or in binary form.
129428SAndreas.Sandberg@ARM.com#
139428SAndreas.Sandberg@ARM.com# Copyright (c) 2005-2007 The Regents of The University of Michigan
149428SAndreas.Sandberg@ARM.com# All rights reserved.
155217Ssaidi@eecs.umich.edu#
165217Ssaidi@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
175217Ssaidi@eecs.umich.edu# modification, are permitted provided that the following conditions are
185217Ssaidi@eecs.umich.edu# met: redistributions of source code must retain the above copyright
195217Ssaidi@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
205217Ssaidi@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
215217Ssaidi@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
225217Ssaidi@eecs.umich.edu# documentation and/or other materials provided with the distribution;
235217Ssaidi@eecs.umich.edu# neither the name of the copyright holders nor the names of its
245217Ssaidi@eecs.umich.edu# contributors may be used to endorse or promote products derived from
255217Ssaidi@eecs.umich.edu# this software without specific prior written permission.
265217Ssaidi@eecs.umich.edu#
275217Ssaidi@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
285217Ssaidi@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
295217Ssaidi@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
305217Ssaidi@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
315217Ssaidi@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
325217Ssaidi@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
335217Ssaidi@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
345217Ssaidi@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
355217Ssaidi@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365217Ssaidi@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
375217Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
385217Ssaidi@eecs.umich.edu#
395217Ssaidi@eecs.umich.edu# Authors: Nathan Binkert
405217Ssaidi@eecs.umich.edu#          Glenn Bergmans
415217Ssaidi@eecs.umich.edu
425217Ssaidi@eecs.umich.edufrom m5.params import *
435217Ssaidi@eecs.umich.edufrom m5.proxy import *
4411793Sbrandon.potter@amd.comfrom m5.util.fdthelper import *
4511793Sbrandon.potter@amd.com
4611627Smichael.lebeane@amd.comfrom m5.objects.MemObject import MemObject
4712334Sgabeblack@google.com
485217Ssaidi@eecs.umich.educlass PioDevice(MemObject):
496658Snate@binkert.org    type = 'PioDevice'
509441SAndreas.Sandberg@ARM.com    cxx_header = "dev/io_device.hh"
519441SAndreas.Sandberg@ARM.com    abstract = True
528232Snate@binkert.org    pio = SlavePort("Programmed I/O port")
5311627Smichael.lebeane@amd.com    system = Param.System(Parent.any, "System this device is part of")
5411627Smichael.lebeane@amd.com
559441SAndreas.Sandberg@ARM.com    def generateBasicPioDeviceNode(self, state, name, pio_addr,
565217Ssaidi@eecs.umich.edu                                   size, interrupts = None):
575217Ssaidi@eecs.umich.edu        node = FdtNode("%s@%x" % (name, long(pio_addr)))
585217Ssaidi@eecs.umich.edu        node.append(FdtPropertyWords("reg",
595217Ssaidi@eecs.umich.edu            state.addrCells(pio_addr) +
605217Ssaidi@eecs.umich.edu            state.sizeCells(size) ))
615217Ssaidi@eecs.umich.edu
625217Ssaidi@eecs.umich.edu        if interrupts:
635217Ssaidi@eecs.umich.edu            if any([i < 32 for i in interrupts]):
6413557Sgabeblack@google.com                raise(("Interrupt number smaller than 32 "+
6513557Sgabeblack@google.com                       " in PioDevice %s") % name)
665217Ssaidi@eecs.umich.edu
675217Ssaidi@eecs.umich.edu            # subtracting 32 because Linux assumes that SPIs start at 0, while
685217Ssaidi@eecs.umich.edu            # gem5 uses the internal GIC numbering (SPIs start at 32)
695217Ssaidi@eecs.umich.edu            node.append(FdtPropertyWords("interrupts", sum(
705217Ssaidi@eecs.umich.edu                [[0, i  - 32, 4] for i in interrupts], []) ))
715217Ssaidi@eecs.umich.edu
725217Ssaidi@eecs.umich.edu        return node
7313557Sgabeblack@google.com
7413557Sgabeblack@google.comclass BasicPioDevice(PioDevice):
755217Ssaidi@eecs.umich.edu    type = 'BasicPioDevice'
765217Ssaidi@eecs.umich.edu    cxx_header = "dev/io_device.hh"
775217Ssaidi@eecs.umich.edu    abstract = True
785217Ssaidi@eecs.umich.edu    pio_addr = Param.Addr("Device Address")
7912109SRekai.GonzalezAlberquilla@arm.com    pio_latency = Param.Latency('100ns', "Programmed IO latency")
8012109SRekai.GonzalezAlberquilla@arm.com
8112109SRekai.GonzalezAlberquilla@arm.comclass DmaDevice(PioDevice):
8212109SRekai.GonzalezAlberquilla@arm.com    type = 'DmaDevice'
8312109SRekai.GonzalezAlberquilla@arm.com    cxx_header = "dev/dma_device.hh"
8412109SRekai.GonzalezAlberquilla@arm.com    abstract = True
8512109SRekai.GonzalezAlberquilla@arm.com    dma = MasterPort("DMA port")
8612109SRekai.GonzalezAlberquilla@arm.com
8712109SRekai.GonzalezAlberquilla@arm.com
8812109SRekai.GonzalezAlberquilla@arm.comclass IsaFake(BasicPioDevice):
895217Ssaidi@eecs.umich.edu    type = 'IsaFake'
9013557Sgabeblack@google.com    cxx_header = "dev/isa_fake.hh"
9113557Sgabeblack@google.com    pio_size = Param.Addr(0x8, "Size of address range")
925217Ssaidi@eecs.umich.edu    ret_data8 = Param.UInt8(0xFF, "Default data to return")
935217Ssaidi@eecs.umich.edu    ret_data16 = Param.UInt16(0xFFFF, "Default data to return")
945217Ssaidi@eecs.umich.edu    ret_data32 = Param.UInt32(0xFFFFFFFF, "Default data to return")
955217Ssaidi@eecs.umich.edu    ret_data64 = Param.UInt64(0xFFFFFFFFFFFFFFFF, "Default data to return")
965217Ssaidi@eecs.umich.edu    ret_bad_addr = Param.Bool(False, "Return pkt status bad address on access")
979920Syasuko.eckert@amd.com    update_data = Param.Bool(False, "Update the data that is returned on writes")
989920Syasuko.eckert@amd.com    warn_access = Param.String("", "String to print when device is accessed")
999920Syasuko.eckert@amd.com    fake_mem = Param.Bool(False,
1009920Syasuko.eckert@amd.com      "Is this device acting like a memory and thus may get a cache line sized req")
1019920Syasuko.eckert@amd.com
1029920Syasuko.eckert@amd.comclass BadAddr(IsaFake):
1039920Syasuko.eckert@amd.com    pio_addr = 0
1049920Syasuko.eckert@amd.com    ret_bad_addr = Param.Bool(True, "Return pkt status bad address on access")
1057720Sgblack@eecs.umich.edu
1067720Sgblack@eecs.umich.edu
1075712Shsul@eecs.umich.edu