smmu_v3_proc.hh revision 14039:4991b2a345a1
18442Sgblack@eecs.umich.edu/* 28442Sgblack@eecs.umich.edu * Copyright (c) 2013, 2018-2019 ARM Limited 311328Ssteve.reinhardt@amd.com * All rights reserved 48442Sgblack@eecs.umich.edu * 58442Sgblack@eecs.umich.edu * The license below extends only to copyright in the software and shall 68442Sgblack@eecs.umich.edu * not be construed as granting a license to any other intellectual 78442Sgblack@eecs.umich.edu * property including but not limited to intellectual property relating 88442Sgblack@eecs.umich.edu * to a hardware implementation of the functionality of the software 98442Sgblack@eecs.umich.edu * licensed hereunder. You may use the software subject to the license 108442Sgblack@eecs.umich.edu * terms below provided that you ensure that this notice is replicated 118442Sgblack@eecs.umich.edu * unmodified and in its entirety in all distributions of the software, 128442Sgblack@eecs.umich.edu * modified or unmodified, in source code or in binary form. 138442Sgblack@eecs.umich.edu * 148442Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 158442Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 168442Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 178442Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 188442Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 198442Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 208442Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 218442Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 228442Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 238442Sgblack@eecs.umich.edu * this software without specific prior written permission. 248442Sgblack@eecs.umich.edu * 258442Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 268442Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 278442Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 288442Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 298442Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 308442Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 318442Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 328442Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 338442Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 348442Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3511328Ssteve.reinhardt@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3611328Ssteve.reinhardt@amd.com * 378442Sgblack@eecs.umich.edu * Authors: Stan Czerniawski 3812234Sgabeblack@google.com */ 398442Sgblack@eecs.umich.edu 408442Sgblack@eecs.umich.edu#ifndef __DEV_ARM_SMMU_V3_PROC_HH__ 418442Sgblack@eecs.umich.edu#define __DEV_ARM_SMMU_V3_PROC_HH__ 428442Sgblack@eecs.umich.edu 438442Sgblack@eecs.umich.edu#include <list> 448442Sgblack@eecs.umich.edu#include <queue> 4511303Ssteve.reinhardt@amd.com#include <string> 4612234Sgabeblack@google.com 4712234Sgabeblack@google.com#include "base/coroutine.hh" 4811608Snikos.nikoleris@arm.com#include "base/types.hh" 498442Sgblack@eecs.umich.edu#include "mem/packet.hh" 5011303Ssteve.reinhardt@amd.com 518442Sgblack@eecs.umich.educlass SMMUv3SlaveInterface; 528442Sgblack@eecs.umich.edu 5311328Ssteve.reinhardt@amd.com/* 5411328Ssteve.reinhardt@amd.com * The meaning of these becomes apparent when you 5511328Ssteve.reinhardt@amd.com * look at runProcessAtomic()/runProcessTiming(). 568442Sgblack@eecs.umich.edu */ 578442Sgblack@eecs.umich.eduenum SMMUActionType { 588442Sgblack@eecs.umich.edu ACTION_INITIAL_NOP, 598442Sgblack@eecs.umich.edu ACTION_SEND_REQ, 608442Sgblack@eecs.umich.edu ACTION_SEND_REQ_FINAL, 618442Sgblack@eecs.umich.edu ACTION_SEND_RESP, 628442Sgblack@eecs.umich.edu ACTION_SEND_RESP_ATS, 638442Sgblack@eecs.umich.edu ACTION_DELAY, 648442Sgblack@eecs.umich.edu ACTION_SLEEP, 658442Sgblack@eecs.umich.edu ACTION_TERMINATE, 668442Sgblack@eecs.umich.edu}; 678442Sgblack@eecs.umich.edu 688442Sgblack@eecs.umich.edustruct SMMUAction 698442Sgblack@eecs.umich.edu{ 708442Sgblack@eecs.umich.edu SMMUActionType type; 718442Sgblack@eecs.umich.edu PacketPtr pkt; 728442Sgblack@eecs.umich.edu SMMUv3SlaveInterface *ifc; 738442Sgblack@eecs.umich.edu Tick delay; 748442Sgblack@eecs.umich.edu}; 758442Sgblack@eecs.umich.edu 768442Sgblack@eecs.umich.educlass SMMUv3; 7711328Ssteve.reinhardt@amd.comclass SMMUProcess; 7811328Ssteve.reinhardt@amd.com 7911328Ssteve.reinhardt@amd.comstruct SMMUSemaphore 8011328Ssteve.reinhardt@amd.com{ 8111328Ssteve.reinhardt@amd.com explicit SMMUSemaphore(unsigned _max) : 8211328Ssteve.reinhardt@amd.com count(_max), max(_max) 8311328Ssteve.reinhardt@amd.com {} 8411328Ssteve.reinhardt@amd.com 8511328Ssteve.reinhardt@amd.com unsigned count; 8611328Ssteve.reinhardt@amd.com unsigned max; 8711328Ssteve.reinhardt@amd.com std::queue<SMMUProcess *> queue; 8811328Ssteve.reinhardt@amd.com}; 8911328Ssteve.reinhardt@amd.com 9011328Ssteve.reinhardt@amd.comstruct SMMUSignal 9111328Ssteve.reinhardt@amd.com{ 9211328Ssteve.reinhardt@amd.com std::list<SMMUProcess *> waiting; 9311328Ssteve.reinhardt@amd.com}; 9411328Ssteve.reinhardt@amd.com 9511328Ssteve.reinhardt@amd.comclass SMMUProcess : public Packet::SenderState 9611328Ssteve.reinhardt@amd.com{ 9711328Ssteve.reinhardt@amd.com private: 9811328Ssteve.reinhardt@amd.com typedef m5::Coroutine<PacketPtr, SMMUAction> Coroutine; 9911328Ssteve.reinhardt@amd.com 10012234Sgabeblack@google.com Coroutine *coroutine; 10112234Sgabeblack@google.com std::string myName; 10212234Sgabeblack@google.com 1038442Sgblack@eecs.umich.edu void wakeup(); 1048442Sgblack@eecs.umich.edu 10511301Ssteve.reinhardt@amd.com protected: 1068442Sgblack@eecs.umich.edu typedef Coroutine::CallerType Yield; 1078442Sgblack@eecs.umich.edu 1088442Sgblack@eecs.umich.edu SMMUv3 &smmu; 1098442Sgblack@eecs.umich.edu 1108442Sgblack@eecs.umich.edu void reinit(); 1118442Sgblack@eecs.umich.edu 1128442Sgblack@eecs.umich.edu virtual void main(Yield &yield) = 0; 1138442Sgblack@eecs.umich.edu 1148442Sgblack@eecs.umich.edu void doRead(Yield &yield, Addr addr, void *ptr, size_t size); 1158442Sgblack@eecs.umich.edu void doWrite(Yield &yield, Addr addr, const void *ptr, size_t size); 1168442Sgblack@eecs.umich.edu void doDelay(Yield &yield, Cycles cycles); 11712234Sgabeblack@google.com void doSleep(Yield &yield); 11811328Ssteve.reinhardt@amd.com 11912234Sgabeblack@google.com void doSemaphoreDown(Yield &yield, SMMUSemaphore &sem); 12011328Ssteve.reinhardt@amd.com void doSemaphoreUp(SMMUSemaphore &sem); 12111328Ssteve.reinhardt@amd.com 12211328Ssteve.reinhardt@amd.com void doWaitForSignal(Yield &yield, SMMUSignal &sig); 12311328Ssteve.reinhardt@amd.com void doBroadcastSignal(SMMUSignal &sig); 12411328Ssteve.reinhardt@amd.com 12511328Ssteve.reinhardt@amd.com void scheduleWakeup(Tick when); 12611328Ssteve.reinhardt@amd.com 12711328Ssteve.reinhardt@amd.com public: 12811328Ssteve.reinhardt@amd.com SMMUProcess(const std::string &name, SMMUv3 &_smmu); 12911328Ssteve.reinhardt@amd.com virtual ~SMMUProcess(); 13011328Ssteve.reinhardt@amd.com 13111328Ssteve.reinhardt@amd.com SMMUAction run(PacketPtr pkt); 13211328Ssteve.reinhardt@amd.com 13311328Ssteve.reinhardt@amd.com const std::string name() const { return myName; }; 13411328Ssteve.reinhardt@amd.com}; 13511328Ssteve.reinhardt@amd.com 13611328Ssteve.reinhardt@amd.com#endif /* __DEV_ARM_SMMU_V3_PROC_HH__ */ 13711328Ssteve.reinhardt@amd.com