RubyRequest.hh revision 11025:4872dbdea907
1/*
2 * Copyright (c) 2009 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBY_REQUEST_HH__
30#define __MEM_RUBY_SLICC_INTERFACE_RUBY_REQUEST_HH__
31
32#include <ostream>
33
34#include "mem/protocol/Message.hh"
35#include "mem/protocol/PrefetchBit.hh"
36#include "mem/protocol/RubyAccessMode.hh"
37#include "mem/protocol/RubyRequestType.hh"
38#include "mem/ruby/common/Address.hh"
39
40class RubyRequest : public Message
41{
42  public:
43    Addr m_PhysicalAddress;
44    Addr m_LineAddress;
45    RubyRequestType m_Type;
46    Addr m_ProgramCounter;
47    RubyAccessMode m_AccessMode;
48    int m_Size;
49    PrefetchBit m_Prefetch;
50    uint8_t* data;
51    PacketPtr pkt;
52    ContextID m_contextId;
53
54    RubyRequest(Tick curTime, uint64_t _paddr, uint8_t* _data, int _len,
55        uint64_t _pc, RubyRequestType _type, RubyAccessMode _access_mode,
56        PacketPtr _pkt, PrefetchBit _pb = PrefetchBit_No,
57        ContextID _proc_id = 100)
58        : Message(curTime),
59          m_PhysicalAddress(_paddr),
60          m_Type(_type),
61          m_ProgramCounter(_pc),
62          m_AccessMode(_access_mode),
63          m_Size(_len),
64          m_Prefetch(_pb),
65          data(_data),
66          pkt(_pkt),
67          m_contextId(_proc_id)
68    {
69      m_LineAddress = makeLineAddress(m_PhysicalAddress);
70    }
71
72    RubyRequest(Tick curTime) : Message(curTime) {}
73    MsgPtr clone() const
74    { return std::shared_ptr<Message>(new RubyRequest(*this)); }
75
76    Addr getLineAddress() const { return m_LineAddress; }
77    Addr getPhysicalAddress() const { return m_PhysicalAddress; }
78    const RubyRequestType& getType() const { return m_Type; }
79    Addr getProgramCounter() const { return m_ProgramCounter; }
80    const RubyAccessMode& getAccessMode() const { return m_AccessMode; }
81    const int& getSize() const { return m_Size; }
82    const PrefetchBit& getPrefetch() const { return m_Prefetch; }
83
84    void print(std::ostream& out) const;
85    bool functionalRead(Packet *pkt);
86    bool functionalWrite(Packet *pkt);
87};
88
89inline std::ostream&
90operator<<(std::ostream& out, const RubyRequest& obj)
91{
92  obj.print(out);
93  out << std::flush;
94  return out;
95}
96
97#endif  // __MEM_RUBY_SLICC_INTERFACE_RUBY_REQUEST_HH__
98