a9scu.cc revision 14082
112841Sgabeblack@google.com/*
212841Sgabeblack@google.com * Copyright (c) 2010,2019 ARM Limited
312841Sgabeblack@google.com * All rights reserved
412841Sgabeblack@google.com *
512841Sgabeblack@google.com * The license below extends only to copyright in the software and shall
612841Sgabeblack@google.com * not be construed as granting a license to any other intellectual
712841Sgabeblack@google.com * property including but not limited to intellectual property relating
812841Sgabeblack@google.com * to a hardware implementation of the functionality of the software
912841Sgabeblack@google.com * licensed hereunder.  You may use the software subject to the license
1012841Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated
1112841Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software,
1212841Sgabeblack@google.com * modified or unmodified, in source code or in binary form.
1312841Sgabeblack@google.com *
1412841Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
1512841Sgabeblack@google.com * modification, are permitted provided that the following conditions are
1612841Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
1712841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
1812841Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1912841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
2012841Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
2112841Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
2212841Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
2312841Sgabeblack@google.com * this software without specific prior written permission.
2412841Sgabeblack@google.com *
2512841Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2612841Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2712841Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2812841Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2912841Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3012841Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3112841Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3212841Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3312841Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3412841Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3512841Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3612841Sgabeblack@google.com *
3712841Sgabeblack@google.com * Authors: Ali Saidi
3812841Sgabeblack@google.com */
3912841Sgabeblack@google.com
4012841Sgabeblack@google.com#include "dev/arm/a9scu.hh"
4112841Sgabeblack@google.com
4212841Sgabeblack@google.com#include "base/intmath.hh"
4312841Sgabeblack@google.com#include "base/trace.hh"
4412841Sgabeblack@google.com#include "mem/packet.hh"
4512841Sgabeblack@google.com#include "mem/packet_access.hh"
4612841Sgabeblack@google.com#include "sim/system.hh"
4712841Sgabeblack@google.com
4812841Sgabeblack@google.comA9SCU::A9SCU(Params *p)
4912841Sgabeblack@google.com    : BasicPioDevice(p, 0x60)
5012841Sgabeblack@google.com{
5112841Sgabeblack@google.com}
5212841Sgabeblack@google.com
5312841Sgabeblack@google.comTick
5412841Sgabeblack@google.comA9SCU::read(PacketPtr pkt)
5512841Sgabeblack@google.com{
5612841Sgabeblack@google.com    assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
5712841Sgabeblack@google.com    assert(pkt->getSize() == 4);
5812841Sgabeblack@google.com    Addr daddr = pkt->getAddr() - pioAddr;
5912841Sgabeblack@google.com
6012841Sgabeblack@google.com    switch(daddr) {
6112841Sgabeblack@google.com      case Control:
6212841Sgabeblack@google.com        pkt->setLE(1); // SCU already enabled
6312841Sgabeblack@google.com        break;
6412841Sgabeblack@google.com      case Config:
6512841Sgabeblack@google.com        /* Without making a completely new SCU, we can use the core count field
6612841Sgabeblack@google.com         * as 4 bits and inform the OS of up to 16 CPUs.  Although the core
6712841Sgabeblack@google.com         * count is technically bits [1:0] only, bits [3:2] are SBZ for future
6812841Sgabeblack@google.com         * expansion like this.
6912841Sgabeblack@google.com         */
7012841Sgabeblack@google.com        if (sys->numContexts() > 4) {
7112841Sgabeblack@google.com            warn_once("A9SCU with >4 CPUs is unsupported\n");
7212841Sgabeblack@google.com            if (sys->numContexts() > 15)
7312841Sgabeblack@google.com                fatal("Too many CPUs (%d) for A9SCU!\n", sys->numContexts());
7412841Sgabeblack@google.com        }
7512841Sgabeblack@google.com        int smp_bits, core_cnt;
7612841Sgabeblack@google.com        smp_bits = (1 << sys->numContexts()) - 1;
7712841Sgabeblack@google.com        core_cnt = sys->numContexts() - 1;
7812841Sgabeblack@google.com        pkt->setLE(smp_bits << 4 | core_cnt);
7912841Sgabeblack@google.com        break;
8012841Sgabeblack@google.com      default:
8112841Sgabeblack@google.com        // Only configuration register is implemented
8212841Sgabeblack@google.com        panic("Tried to read SCU at offset %#x\n", daddr);
8312841Sgabeblack@google.com        break;
8412841Sgabeblack@google.com    }
8512841Sgabeblack@google.com    pkt->makeAtomicResponse();
8612841Sgabeblack@google.com    return pioDelay;
8712841Sgabeblack@google.com
8812841Sgabeblack@google.com}
8912841Sgabeblack@google.com
9012841Sgabeblack@google.comTick
9112841Sgabeblack@google.comA9SCU::write(PacketPtr pkt)
9212841Sgabeblack@google.com{
9312841Sgabeblack@google.com    assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
9412841Sgabeblack@google.com
9512841Sgabeblack@google.com    Addr daddr = pkt->getAddr() - pioAddr;
96    switch (daddr) {
97      default:
98        // Nothing implemented at this point
99        warn("Tried to write SCU at offset %#x\n", daddr);
100        break;
101    }
102    pkt->makeAtomicResponse();
103    return pioDelay;
104}
105
106A9SCU *
107A9SCUParams::create()
108{
109    return new A9SCU(this);
110}
111