smmu_v3_cmdexec.cc revision 14039:4991b2a345a1
12SN/A/*
21762SN/A * Copyright (c) 2013, 2018-2019 ARM Limited
32SN/A * All rights reserved
42SN/A *
52SN/A * The license below extends only to copyright in the software and shall
62SN/A * not be construed as granting a license to any other intellectual
72SN/A * property including but not limited to intellectual property relating
82SN/A * to a hardware implementation of the functionality of the software
92SN/A * licensed hereunder.  You may use the software subject to the license
102SN/A * terms below provided that you ensure that this notice is replicated
112SN/A * unmodified and in its entirety in all distributions of the software,
122SN/A * modified or unmodified, in source code or in binary form.
132SN/A *
142SN/A * Redistribution and use in source and binary forms, with or without
152SN/A * modification, are permitted provided that the following conditions are
162SN/A * met: redistributions of source code must retain the above copyright
172SN/A * notice, this list of conditions and the following disclaimer;
182SN/A * redistributions in binary form must reproduce the above copyright
192SN/A * notice, this list of conditions and the following disclaimer in the
202SN/A * documentation and/or other materials provided with the distribution;
212SN/A * neither the name of the copyright holders nor the names of its
222SN/A * contributors may be used to endorse or promote products derived from
232SN/A * this software without specific prior written permission.
242SN/A *
252SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
262SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
272665SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
282665SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
292665SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
302665SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
312665SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
322SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
332SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
341722SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
355480Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
362SN/A *
372SN/A * Authors: Stan Czerniawski
38146SN/A */
392SN/A
402SN/A#include "dev/arm/smmu_v3_cmdexec.hh"
412158SN/A
42146SN/A#include "base/bitfield.hh"
431805SN/A#include "dev/arm/smmu_v3.hh"
44146SN/A
451717SN/Avoid
462680SN/ASMMUCommandExecProcess::main(Yield &yield)
478232Snate@binkert.org{
485480Snate@binkert.org    SMMUAction a;
498741Sgblack@eecs.umich.edu    a.type = ACTION_INITIAL_NOP;
508741Sgblack@eecs.umich.edu    a.pkt = NULL;
518741Sgblack@eecs.umich.edu    a.ifc = nullptr;
522521SN/A    a.delay = 0;
5356SN/A    yield(a);
545478SN/A
553348SN/A    while (true) {
563348SN/A        busy = true;
572521SN/A
585480Snate@binkert.org        while (true) {
591805SN/A            int sizeMask =
602SN/A                mask(smmu.regs.cmdq_base & Q_BASE_SIZE_MASK) & Q_CONS_PROD_MASK;
612SN/A
622107SN/A            if ((smmu.regs.cmdq_cons & sizeMask) ==
632SN/A                    (smmu.regs.cmdq_prod & sizeMask))
645480Snate@binkert.org                break; // command queue empty
655478SN/A
668806Sgblack@eecs.umich.edu            Addr cmdAddr =
672SN/A                (smmu.regs.cmdq_base & Q_BASE_ADDR_MASK) +
68545SN/A                (smmu.regs.cmdq_cons & sizeMask) * sizeof(SMMUCommand);
692521SN/A
702521SN/A            // This deliberately resets the error field in cmdq_cons!
712521SN/A            smmu.regs.cmdq_cons = (smmu.regs.cmdq_cons + 1) & sizeMask;
722521SN/A
732SN/A            doRead(yield, cmdAddr, &cmd, sizeof(SMMUCommand));
742SN/A            smmu.processCommand(cmd);
752SN/A        }
76926SN/A
77926SN/A        busy = false;
78926SN/A
79926SN/A        doSleep(yield);
80926SN/A    }
81926SN/A}
82926SN/A