dev-arm: Implement Arm MHU (Message Handling Unit)
JIRA: https://gem5.atlassian.net/browse/GEM5-768 Change-Id: I895eba1a3421746a602e6a4f88916da9054169a8 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34378 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
113
src/dev/arm/css/MHU.py
Normal file
113
src/dev/arm/css/MHU.py
Normal file
@@ -0,0 +1,113 @@
|
||||
# Copyright (c) 2020 ARM Limited
|
||||
# All rights reserved.
|
||||
#
|
||||
# The license below extends only to copyright in the software and shall
|
||||
# not be construed as granting a license to any other intellectual
|
||||
# property including but not limited to intellectual property relating
|
||||
# to a hardware implementation of the functionality of the software
|
||||
# licensed hereunder. You may use the software subject to the license
|
||||
# terms below provided that you ensure that this notice is replicated
|
||||
# unmodified and in its entirety in all distributions of the software,
|
||||
# modified or unmodified, in source code or in binary form.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from m5.objects.Device import BasicPioDevice
|
||||
from m5.objects.Doorbell import Doorbell
|
||||
from m5.params import *
|
||||
from m5.proxy import *
|
||||
from m5.util.fdthelper import *
|
||||
|
||||
class MhuDoorbell(Doorbell):
|
||||
type = 'MhuDoorbell'
|
||||
abstract = True
|
||||
cxx_header = "dev/arm/css/mhu.hh"
|
||||
|
||||
class Scp2ApDoorbell(MhuDoorbell):
|
||||
type = 'Scp2ApDoorbell'
|
||||
cxx_header = "dev/arm/css/mhu.hh"
|
||||
|
||||
interrupt = Param.ArmInterruptPin("Interrupt Pin")
|
||||
|
||||
class Ap2ScpDoorbell(MhuDoorbell):
|
||||
type = 'Ap2ScpDoorbell'
|
||||
cxx_header = "dev/arm/css/mhu.hh"
|
||||
|
||||
# Message Handling Unit
|
||||
class MHU(BasicPioDevice):
|
||||
type = 'MHU'
|
||||
cxx_header = "dev/arm/css/mhu.hh"
|
||||
pio_size = Param.Unsigned(0x1000, "MHU pio size")
|
||||
|
||||
lowp_scp2ap = Param.Scp2ApDoorbell(
|
||||
"Low Priority doorbell channel for communications "
|
||||
"from the System Control Processor (SCP) to the "
|
||||
"Application Processor (AP)")
|
||||
highp_scp2ap = Param.Scp2ApDoorbell(
|
||||
"High Priority doorbell channel for communications "
|
||||
"from the System Control Processor (SCP) to the "
|
||||
"Application Processor (AP)")
|
||||
sec_scp2ap = Param.Scp2ApDoorbell(
|
||||
"Secure doorbell channel for communications "
|
||||
"from the System Control Processor (SCP) to the "
|
||||
"Application Processor (AP)")
|
||||
|
||||
lowp_ap2scp = Param.Ap2ScpDoorbell(
|
||||
"Low Priority doorbell channel for communications "
|
||||
"from the Application Processor (AP) to the "
|
||||
"System Control Processor (SCP)")
|
||||
highp_ap2scp = Param.Ap2ScpDoorbell(
|
||||
"High Priority doorbell channel for communications "
|
||||
"from the Application Processor (AP) to the "
|
||||
"System Control Processor (SCP)")
|
||||
sec_ap2scp = Param.Ap2ScpDoorbell(
|
||||
"Secure doorbell channel for communications "
|
||||
"from the Application Processor (AP) to the "
|
||||
"System Control Processor (SCP)")
|
||||
|
||||
scp = Param.Scp(Parent.any, "System Control Processor")
|
||||
|
||||
def generateDeviceTree(self, state):
|
||||
node = FdtNode("mailbox@%x" % long(self.pio_addr))
|
||||
node.appendCompatible(["arm,mhu", "arm,primecell"])
|
||||
node.append(FdtPropertyWords("reg",
|
||||
state.addrCells(self.pio_addr) +
|
||||
state.sizeCells(self.pio_size) ))
|
||||
node.append(FdtPropertyWords("#mbox-cells", 1))
|
||||
|
||||
node.append(FdtPropertyWords("interrupts", [
|
||||
0, int(self.lowp_scp2ap.interrupt.num) - 32, 1,
|
||||
0, int(self.highp_scp2ap.interrupt.num) - 32, 1,
|
||||
0, int(self.sec_scp2ap.interrupt.num) - 32, 1,
|
||||
]))
|
||||
|
||||
realview = self._parent.unproxy(self)
|
||||
node.append(FdtPropertyWords("clocks",
|
||||
[state.phandle(realview.mcc.osc_peripheral),
|
||||
state.phandle(realview.dcc.osc_smb)]))
|
||||
node.append(FdtPropertyStrings("clock-names", ["apb_pclk"]))
|
||||
|
||||
node.appendPhandle(self)
|
||||
|
||||
yield node
|
||||
46
src/dev/arm/css/SConscript
Normal file
46
src/dev/arm/css/SConscript
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- mode:python -*-
|
||||
|
||||
# Copyright (c) 2020 ARM Limited
|
||||
# All rights reserved.
|
||||
#
|
||||
# The license below extends only to copyright in the software and shall
|
||||
# not be construed as granting a license to any other intellectual
|
||||
# property including but not limited to intellectual property relating
|
||||
# to a hardware implementation of the functionality of the software
|
||||
# licensed hereunder. You may use the software subject to the license
|
||||
# terms below provided that you ensure that this notice is replicated
|
||||
# unmodified and in its entirety in all distributions of the software,
|
||||
# modified or unmodified, in source code or in binary form.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Import('*')
|
||||
|
||||
if env['TARGET_ISA'] == 'arm':
|
||||
SimObject('MHU.py')
|
||||
SimObject('Scp.py')
|
||||
|
||||
Source('mhu.cc')
|
||||
|
||||
DebugFlag('MHU')
|
||||
42
src/dev/arm/css/Scp.py
Normal file
42
src/dev/arm/css/Scp.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2020 ARM Limited
|
||||
# All rights reserved.
|
||||
#
|
||||
# The license below extends only to copyright in the software and shall
|
||||
# not be construed as granting a license to any other intellectual
|
||||
# property including but not limited to intellectual property relating
|
||||
# to a hardware implementation of the functionality of the software
|
||||
# licensed hereunder. You may use the software subject to the license
|
||||
# terms below provided that you ensure that this notice is replicated
|
||||
# unmodified and in its entirety in all distributions of the software,
|
||||
# modified or unmodified, in source code or in binary form.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met: redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer;
|
||||
# redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution;
|
||||
# neither the name of the copyright holders nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from m5.objects.ClockedObject import ClockedObject
|
||||
from m5.params import *
|
||||
|
||||
class Scp(ClockedObject):
|
||||
type = 'Scp'
|
||||
abstract = True
|
||||
cxx_header = "dev/arm/css/scp.hh"
|
||||
241
src/dev/arm/css/mhu.cc
Normal file
241
src/dev/arm/css/mhu.cc
Normal file
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2020 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "dev/arm/css/mhu.hh"
|
||||
|
||||
#include "debug/MHU.hh"
|
||||
#include "dev/arm/base_gic.hh"
|
||||
#include "dev/arm/css/scp.hh"
|
||||
#include "mem/packet_access.hh"
|
||||
#include "params/Ap2ScpDoorbell.hh"
|
||||
#include "params/MHU.hh"
|
||||
#include "params/Scp2ApDoorbell.hh"
|
||||
|
||||
Scp2ApDoorbell::Scp2ApDoorbell(const Scp2ApDoorbellParams &p)
|
||||
: MhuDoorbell(p), interrupt(p.interrupt->get())
|
||||
{}
|
||||
|
||||
Ap2ScpDoorbell::Ap2ScpDoorbell(const Ap2ScpDoorbellParams &p)
|
||||
: MhuDoorbell(p)
|
||||
{}
|
||||
|
||||
MHU::MHU(const MHUParams &p)
|
||||
: BasicPioDevice(p, p.pio_size),
|
||||
scpLow(p.lowp_scp2ap),
|
||||
scpHigh(p.highp_scp2ap),
|
||||
scpSec(p.sec_scp2ap),
|
||||
apLow(p.lowp_ap2scp),
|
||||
apHigh(p.highp_ap2scp),
|
||||
apSec(p.sec_ap2scp),
|
||||
pid{ 0x98, 0xb0, 0x1b, 0x0, 0x4 },
|
||||
compid{ 0x0d, 0xf0, 0x05, 0xb1 },
|
||||
scfg(0)
|
||||
{
|
||||
apLow->setScp(p.scp);
|
||||
apHigh->setScp(p.scp);
|
||||
apSec->setScp(p.scp);
|
||||
}
|
||||
|
||||
AddrRangeList
|
||||
MHU::getAddrRanges() const
|
||||
{
|
||||
return AddrRangeList({ RangeSize(pioAddr, pioSize) });
|
||||
}
|
||||
|
||||
Tick
|
||||
MHU::read(PacketPtr pkt)
|
||||
{
|
||||
const Addr addr = pkt->getAddr() - pioAddr;
|
||||
const bool secure = pkt->isSecure();
|
||||
|
||||
uint32_t value = read32(addr, secure);
|
||||
|
||||
DPRINTF(MHU, "Reading %#x at address: %#x\n", value, addr);
|
||||
|
||||
pkt->setUintX(value, ByteOrder::little);
|
||||
pkt->makeAtomicResponse();
|
||||
return pioDelay;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MHU::read32(const Addr addr, bool secure_access)
|
||||
{
|
||||
switch (addr) {
|
||||
case SCP_INTR_L_STAT:
|
||||
return scpLow->channel;
|
||||
case SCP_INTR_H_STAT:
|
||||
return scpHigh->channel;
|
||||
case CPU_INTR_L_STAT:
|
||||
return apLow->channel;
|
||||
case CPU_INTR_H_STAT:
|
||||
return apHigh->channel;
|
||||
case SCP_INTR_S_STAT:
|
||||
if (secure_access) {
|
||||
return scpSec->channel;
|
||||
} else {
|
||||
if (!bits(scfg, 0))
|
||||
scpSec->set(SVI_INT);
|
||||
return 0;
|
||||
}
|
||||
case CPU_INTR_S_STAT:
|
||||
if (secure_access) {
|
||||
return apSec->channel;
|
||||
} else {
|
||||
if (!bits(scfg, 0))
|
||||
scpSec->set(SVI_INT);
|
||||
return 0;
|
||||
}
|
||||
case MHU_SCFG:
|
||||
return scfg;
|
||||
case PID4:
|
||||
return pid[4];
|
||||
case PID0:
|
||||
return pid[0];
|
||||
case PID1:
|
||||
return pid[1];
|
||||
case PID2:
|
||||
return pid[2];
|
||||
case PID3:
|
||||
return pid[3];
|
||||
case COMPID0:
|
||||
return compid[0];
|
||||
case COMPID1:
|
||||
return compid[1];
|
||||
case COMPID2:
|
||||
return compid[2];
|
||||
case COMPID3:
|
||||
return compid[3];
|
||||
default:
|
||||
panic("Invalid register read at address: %#x\n", addr);
|
||||
}
|
||||
}
|
||||
|
||||
Tick
|
||||
MHU::write(PacketPtr pkt)
|
||||
{
|
||||
const Addr addr = pkt->getAddr() - pioAddr;
|
||||
|
||||
assert(pkt->getSize() == sizeof(uint32_t));
|
||||
const uint32_t value = pkt->getLE<uint32_t>();
|
||||
|
||||
DPRINTF(MHU, "Writing %#x at address: %#x\n", value, addr);
|
||||
|
||||
switch (addr) {
|
||||
case SCP_INTR_L_SET:
|
||||
scpLow->set(value);
|
||||
break;
|
||||
case SCP_INTR_L_CLEAR:
|
||||
scpLow->clear(value);
|
||||
break;
|
||||
case SCP_INTR_H_SET:
|
||||
scpHigh->set(value);
|
||||
break;
|
||||
case SCP_INTR_H_CLEAR:
|
||||
scpHigh->clear(value);
|
||||
break;
|
||||
case CPU_INTR_L_SET:
|
||||
apLow->set(value);
|
||||
break;
|
||||
case CPU_INTR_L_CLEAR:
|
||||
apLow->clear(value);
|
||||
break;
|
||||
case CPU_INTR_H_SET:
|
||||
apHigh->set(value);
|
||||
break;
|
||||
case CPU_INTR_H_CLEAR:
|
||||
apHigh->clear(value);
|
||||
break;
|
||||
case SCP_INTR_S_SET:
|
||||
scpSec->set(value);
|
||||
break;
|
||||
case SCP_INTR_S_CLEAR:
|
||||
scpSec->clear(value);
|
||||
break;
|
||||
case CPU_INTR_S_SET:
|
||||
apSec->set(value);
|
||||
break;
|
||||
case CPU_INTR_S_CLEAR:
|
||||
apSec->clear(value);
|
||||
break;
|
||||
case MHU_SCFG:
|
||||
scfg = value;
|
||||
break;
|
||||
default:
|
||||
panic("Invalid register write at address: %#x\n", addr);
|
||||
}
|
||||
|
||||
pkt->makeAtomicResponse();
|
||||
return pioDelay;
|
||||
}
|
||||
|
||||
void
|
||||
MhuDoorbell::update(uint32_t new_val)
|
||||
{
|
||||
const bool int_old = channel != 0;
|
||||
const bool int_new = new_val != 0;
|
||||
|
||||
channel = new_val;
|
||||
if (int_old && !int_new) {
|
||||
clearInterrupt();
|
||||
} else if (!int_old && int_new) {
|
||||
raiseInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Scp2ApDoorbell::raiseInterrupt()
|
||||
{
|
||||
interrupt->raise();
|
||||
}
|
||||
|
||||
void
|
||||
Scp2ApDoorbell::clearInterrupt()
|
||||
{
|
||||
interrupt->clear();
|
||||
}
|
||||
|
||||
void
|
||||
Ap2ScpDoorbell::raiseInterrupt()
|
||||
{
|
||||
scp->raiseInterrupt(this);
|
||||
}
|
||||
|
||||
void
|
||||
Ap2ScpDoorbell::clearInterrupt()
|
||||
{
|
||||
scp->clearInterrupt(this);
|
||||
}
|
||||
169
src/dev/arm/css/mhu.hh
Normal file
169
src/dev/arm/css/mhu.hh
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2020 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __DEV_ARM_CSS_MHU_H__
|
||||
#define __DEV_ARM_CSS_MHU_H__
|
||||
|
||||
#include "dev/arm/doorbell.hh"
|
||||
#include "dev/io_device.hh"
|
||||
|
||||
class Ap2ScpDoorbellParams;
|
||||
class ArmInterruptPin;
|
||||
class MHU;
|
||||
class MHUParams;
|
||||
class Scp;
|
||||
class Scp2ApDoorbellParams;
|
||||
|
||||
class MhuDoorbell : public Doorbell
|
||||
{
|
||||
public:
|
||||
friend class MHU;
|
||||
|
||||
MhuDoorbell(const DoorbellParams &p)
|
||||
: Doorbell(p), channel(0)
|
||||
{}
|
||||
|
||||
void set(uint32_t val) { update(channel | val); }
|
||||
void clear(uint32_t val) { update(channel & ~val); }
|
||||
|
||||
protected:
|
||||
void update(uint32_t new_val);
|
||||
|
||||
virtual void raiseInterrupt() = 0;
|
||||
virtual void clearInterrupt() = 0;
|
||||
|
||||
uint32_t channel;
|
||||
};
|
||||
|
||||
class Scp2ApDoorbell : public MhuDoorbell
|
||||
{
|
||||
public:
|
||||
Scp2ApDoorbell(const Scp2ApDoorbellParams &p);
|
||||
|
||||
void raiseInterrupt() override;
|
||||
void clearInterrupt() override;
|
||||
|
||||
private:
|
||||
ArmInterruptPin *interrupt;
|
||||
};
|
||||
|
||||
class Ap2ScpDoorbell : public MhuDoorbell
|
||||
{
|
||||
public:
|
||||
Ap2ScpDoorbell(const Ap2ScpDoorbellParams &p);
|
||||
|
||||
void setScp(Scp *_scp) { scp = _scp; }
|
||||
|
||||
void raiseInterrupt() override;
|
||||
void clearInterrupt() override;
|
||||
|
||||
private:
|
||||
Scp *scp;
|
||||
};
|
||||
|
||||
/** Message Handling Unit */
|
||||
class MHU : public BasicPioDevice
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
/** From SCP to Application Processor */
|
||||
SCP_INTR_L_STAT = 0x0,
|
||||
SCP_INTR_L_SET = 0x8,
|
||||
SCP_INTR_L_CLEAR = 0x10,
|
||||
SCP_INTR_H_STAT = 0x20,
|
||||
SCP_INTR_H_SET = 0x28,
|
||||
SCP_INTR_H_CLEAR = 0x30,
|
||||
|
||||
/** From Application Processor to SCP */
|
||||
CPU_INTR_L_STAT = 0x100,
|
||||
CPU_INTR_L_SET = 0x108,
|
||||
CPU_INTR_L_CLEAR = 0x110,
|
||||
CPU_INTR_H_STAT = 0x120,
|
||||
CPU_INTR_H_SET = 0x128,
|
||||
CPU_INTR_H_CLEAR = 0x130,
|
||||
|
||||
SCP_INTR_S_STAT = 0x200,
|
||||
SCP_INTR_S_SET = 0x208,
|
||||
SCP_INTR_S_CLEAR = 0x210,
|
||||
CPU_INTR_S_STAT = 0x300,
|
||||
CPU_INTR_S_SET = 0x308,
|
||||
CPU_INTR_S_CLEAR = 0x310,
|
||||
|
||||
MHU_SCFG = 0x400,
|
||||
|
||||
PID4 = 0xfd0,
|
||||
PID0 = 0xfe0,
|
||||
PID1 = 0xfe4,
|
||||
PID2 = 0xfe8,
|
||||
PID3 = 0xfec,
|
||||
|
||||
COMPID0 = 0xff0,
|
||||
COMPID1 = 0xff4,
|
||||
COMPID2 = 0xff8,
|
||||
COMPID3 = 0xffc
|
||||
};
|
||||
|
||||
// Secure Violation Interrupt: used when accessing
|
||||
// a secure channel in non secure mode
|
||||
static const uint32_t SVI_INT = 0x80000000;
|
||||
|
||||
MHU(const MHUParams &p);
|
||||
|
||||
AddrRangeList getAddrRanges() const override;
|
||||
|
||||
Tick read(PacketPtr pkt) override;
|
||||
Tick write(PacketPtr pkt) override;
|
||||
|
||||
uint32_t read32(const Addr addr, bool secure_access);
|
||||
|
||||
Scp2ApDoorbell *scpLow;
|
||||
Scp2ApDoorbell *scpHigh;
|
||||
Scp2ApDoorbell *scpSec;
|
||||
|
||||
Ap2ScpDoorbell *apLow;
|
||||
Ap2ScpDoorbell *apHigh;
|
||||
Ap2ScpDoorbell *apSec;
|
||||
|
||||
// MHU.PIDn, MHU.COMPIDn registers
|
||||
uint32_t pid[5];
|
||||
uint32_t compid[4];
|
||||
|
||||
uint32_t scfg;
|
||||
};
|
||||
|
||||
#endif // __DEV_ARM_CSS_MHU_H__
|
||||
58
src/dev/arm/css/scp.hh
Normal file
58
src/dev/arm/css/scp.hh
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2020 ARM Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __DEV_ARM_CSS_SCP_H__
|
||||
#define __DEV_ARM_CSS_SCP_H__
|
||||
|
||||
#include "sim/clocked_object.hh"
|
||||
|
||||
class Doorbell;
|
||||
|
||||
class Scp : public ClockedObject
|
||||
{
|
||||
public:
|
||||
Scp(const ClockedObjectParams &p)
|
||||
: ClockedObject(p)
|
||||
{}
|
||||
|
||||
virtual ~Scp() {}
|
||||
|
||||
virtual void raiseInterrupt(const Doorbell *doorbell) = 0;
|
||||
virtual void clearInterrupt(const Doorbell *doorbell) = 0;
|
||||
};
|
||||
|
||||
#endif // __DEV_ARM_CSS_SCP_H__
|
||||
Reference in New Issue
Block a user