DMASequencer.hh revision 10913
17008Snate@binkert.org/*
27008Snate@binkert.org * Copyright (c) 2008 Mark D. Hill and David A. Wood
37008Snate@binkert.org * All rights reserved.
47008Snate@binkert.org *
57008Snate@binkert.org * Redistribution and use in source and binary forms, with or without
67008Snate@binkert.org * modification, are permitted provided that the following conditions are
77008Snate@binkert.org * met: redistributions of source code must retain the above copyright
87008Snate@binkert.org * notice, this list of conditions and the following disclaimer;
97008Snate@binkert.org * redistributions in binary form must reproduce the above copyright
107008Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
117008Snate@binkert.org * documentation and/or other materials provided with the distribution;
127008Snate@binkert.org * neither the name of the copyright holders nor the names of its
137008Snate@binkert.org * contributors may be used to endorse or promote products derived from
147008Snate@binkert.org * this software without specific prior written permission.
157008Snate@binkert.org *
167008Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177008Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187008Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197008Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207008Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217008Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227008Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237008Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247008Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257008Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
267008Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277008Snate@binkert.org */
286285Snate@binkert.org
297039Snate@binkert.org#ifndef __MEM_RUBY_SYSTEM_DMASEQUENCER_HH__
307039Snate@binkert.org#define __MEM_RUBY_SYSTEM_DMASEQUENCER_HH__
316285Snate@binkert.org
3210706Spower.jg@gmail.com#include <memory>
336285Snate@binkert.org#include <ostream>
347039Snate@binkert.org
359104Shestness@cs.utexas.edu#include "mem/protocol/DMASequencerRequestType.hh"
3610518Snilay@cs.wisc.edu#include "mem/protocol/RequestStatus.hh"
376285Snate@binkert.org#include "mem/ruby/common/DataBlock.hh"
3810518Snilay@cs.wisc.edu#include "mem/ruby/network/MessageBuffer.hh"
3910518Snilay@cs.wisc.edu#include "mem/ruby/system/System.hh"
4010518Snilay@cs.wisc.edu#include "mem/mem_object.hh"
4110706Spower.jg@gmail.com#include "mem/simple_mem.hh"
4210518Snilay@cs.wisc.edu#include "mem/tport.hh"
436876Ssteve.reinhardt@amd.com#include "params/DMASequencer.hh"
446876Ssteve.reinhardt@amd.com
4510518Snilay@cs.wisc.educlass AbstractController;
4610518Snilay@cs.wisc.edu
477039Snate@binkert.orgstruct DMARequest
487039Snate@binkert.org{
497039Snate@binkert.org    uint64_t start_paddr;
507039Snate@binkert.org    int len;
517039Snate@binkert.org    bool write;
527039Snate@binkert.org    int bytes_completed;
537039Snate@binkert.org    int bytes_issued;
549208Snilay@cs.wisc.edu    uint8_t *data;
557039Snate@binkert.org    PacketPtr pkt;
566285Snate@binkert.org};
576285Snate@binkert.org
5810518Snilay@cs.wisc.educlass DMASequencer : public MemObject
597039Snate@binkert.org{
607039Snate@binkert.org  public:
616876Ssteve.reinhardt@amd.com    typedef DMASequencerParams Params;
627039Snate@binkert.org    DMASequencer(const Params *);
637039Snate@binkert.org    void init();
6410518Snilay@cs.wisc.edu
6510518Snilay@cs.wisc.edu  public:
6610518Snilay@cs.wisc.edu    class MemSlavePort : public QueuedSlavePort
6710518Snilay@cs.wisc.edu    {
6810518Snilay@cs.wisc.edu      private:
6910713Sandreas.hansson@arm.com        RespPacketQueue queue;
7010706Spower.jg@gmail.com        RubySystem* ruby_system;
7110706Spower.jg@gmail.com        bool access_backing_store;
7210518Snilay@cs.wisc.edu
7310518Snilay@cs.wisc.edu      public:
7410518Snilay@cs.wisc.edu        MemSlavePort(const std::string &_name, DMASequencer *_port,
7510706Spower.jg@gmail.com                     PortID id, RubySystem *_ruby_system,
7610706Spower.jg@gmail.com                     bool _access_backing_store);
7710518Snilay@cs.wisc.edu        void hitCallback(PacketPtr pkt);
7810518Snilay@cs.wisc.edu        void evictionCallback(const Address& address);
7910518Snilay@cs.wisc.edu
8010518Snilay@cs.wisc.edu      protected:
8110518Snilay@cs.wisc.edu        bool recvTimingReq(PacketPtr pkt);
8210518Snilay@cs.wisc.edu
8310518Snilay@cs.wisc.edu        Tick recvAtomic(PacketPtr pkt)
8410518Snilay@cs.wisc.edu        { panic("DMASequencer::MemSlavePort::recvAtomic() not implemented!\n"); }
8510518Snilay@cs.wisc.edu
8610518Snilay@cs.wisc.edu        void recvFunctional(PacketPtr pkt)
8710518Snilay@cs.wisc.edu        { panic("DMASequencer::MemSlavePort::recvFunctional() not implemented!\n"); }
8810518Snilay@cs.wisc.edu
8910518Snilay@cs.wisc.edu        AddrRangeList getAddrRanges() const
9010518Snilay@cs.wisc.edu        { AddrRangeList ranges; return ranges; }
9110518Snilay@cs.wisc.edu
9210518Snilay@cs.wisc.edu      private:
9310518Snilay@cs.wisc.edu        bool isPhysMemAddress(Addr addr) const;
9410518Snilay@cs.wisc.edu    };
9510518Snilay@cs.wisc.edu
9610518Snilay@cs.wisc.edu    BaseSlavePort &getSlavePort(const std::string &if_name,
9710518Snilay@cs.wisc.edu                                PortID idx = InvalidPortID);
9810518Snilay@cs.wisc.edu
997039Snate@binkert.org    /* external interface */
1008615Snilay@cs.wisc.edu    RequestStatus makeRequest(PacketPtr pkt);
1017039Snate@binkert.org    bool busy() { return m_is_busy;}
1028688Snilay@cs.wisc.edu    int outstandingCount() const { return (m_is_busy ? 1 : 0); }
1038688Snilay@cs.wisc.edu    bool isDeadlockEventScheduled() const { return false; }
1048688Snilay@cs.wisc.edu    void descheduleDeadlockEvent() {}
1056285Snate@binkert.org
10610518Snilay@cs.wisc.edu    // Called by the controller to give the sequencer a pointer.
10710518Snilay@cs.wisc.edu    // A pointer to the controller is needed for atomic support.
10810518Snilay@cs.wisc.edu    void setController(AbstractController* _cntrl) { m_controller = _cntrl; }
10910518Snilay@cs.wisc.edu    uint32_t getId() { return m_version; }
11010913Sandreas.sandberg@arm.com    DrainState drain() M5_ATTR_OVERRIDE;
11110518Snilay@cs.wisc.edu
1127039Snate@binkert.org    /* SLICC callback */
1137039Snate@binkert.org    void dataCallback(const DataBlock & dblk);
1147039Snate@binkert.org    void ackCallback();
1156285Snate@binkert.org
1169104Shestness@cs.utexas.edu    void recordRequestType(DMASequencerRequestType requestType);
1179104Shestness@cs.utexas.edu
1187039Snate@binkert.org  private:
1197039Snate@binkert.org    void issueNext();
12010518Snilay@cs.wisc.edu    void ruby_hit_callback(PacketPtr pkt);
12110518Snilay@cs.wisc.edu    void testDrainComplete();
12210518Snilay@cs.wisc.edu
12310518Snilay@cs.wisc.edu    /**
12410518Snilay@cs.wisc.edu     * Called by the PIO port when receiving a timing response.
12510518Snilay@cs.wisc.edu     *
12610518Snilay@cs.wisc.edu     * @param pkt Response packet
12710518Snilay@cs.wisc.edu     * @param master_port_id Port id of the PIO port
12810518Snilay@cs.wisc.edu     *
12910518Snilay@cs.wisc.edu     * @return Whether successfully sent
13010518Snilay@cs.wisc.edu     */
13110518Snilay@cs.wisc.edu    bool recvTimingResp(PacketPtr pkt, PortID master_port_id);
13210913Sandreas.sandberg@arm.com    unsigned int getChildDrainCount();
1336285Snate@binkert.org
1347039Snate@binkert.org  private:
13510518Snilay@cs.wisc.edu    uint32_t m_version;
13610518Snilay@cs.wisc.edu    AbstractController* m_controller;
13710518Snilay@cs.wisc.edu    MessageBuffer* m_mandatory_q_ptr;
13810518Snilay@cs.wisc.edu    bool m_usingRubyTester;
13910518Snilay@cs.wisc.edu
14010518Snilay@cs.wisc.edu    MemSlavePort slave_port;
14110518Snilay@cs.wisc.edu
14210518Snilay@cs.wisc.edu    System* system;
14310518Snilay@cs.wisc.edu
14410518Snilay@cs.wisc.edu    bool retry;
1457039Snate@binkert.org    bool m_is_busy;
1467039Snate@binkert.org    uint64_t m_data_block_mask;
1477039Snate@binkert.org    DMARequest active_request;
1486285Snate@binkert.org};
1496285Snate@binkert.org
1507039Snate@binkert.org#endif // __MEM_RUBY_SYSTEM_DMASEQUENCER_HH__
151