RubyRequest.hh revision 9116:9171e26543fa
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#include "mem/packet.hh"
40
41class RubyRequest : public Message
42{
43  public:
44    Address m_PhysicalAddress;
45    Address m_LineAddress;
46    RubyRequestType m_Type;
47    Address m_ProgramCounter;
48    RubyAccessMode m_AccessMode;
49    int m_Size;
50    PrefetchBit m_Prefetch;
51    uint8_t* data;
52    PacketPtr pkt;
53    unsigned m_contextId;
54
55    RubyRequest() {}
56    RubyRequest(uint64_t _paddr, uint8_t* _data, int _len, uint64_t _pc,
57                RubyRequestType _type, RubyAccessMode _access_mode,
58                PacketPtr _pkt, PrefetchBit _pb = PrefetchBit_No,
59                 unsigned _proc_id = 100)
60        : m_PhysicalAddress(_paddr),
61          m_Type(_type),
62          m_ProgramCounter(_pc),
63          m_AccessMode(_access_mode),
64          m_Size(_len),
65          m_Prefetch(_pb),
66          data(_data),
67          pkt(_pkt),
68          m_contextId(_proc_id)
69    {
70      m_LineAddress = m_PhysicalAddress;
71      m_LineAddress.makeLineAddress();
72    }
73
74    static RubyRequest*
75    create()
76    {
77        return new RubyRequest();
78    }
79
80    RubyRequest*
81    clone() const
82    {
83        return new RubyRequest(*this);
84    }
85
86    const Address&
87    getLineAddress() const
88    {
89        return m_LineAddress;
90    }
91
92    const Address&
93    getPhysicalAddress() const
94    {
95        return m_PhysicalAddress;
96    }
97
98    const RubyRequestType&
99    getType() const
100    {
101        return m_Type;
102    }
103
104    const Address&
105    getProgramCounter() const
106    {
107        return m_ProgramCounter;
108    }
109
110    const RubyAccessMode&
111    getAccessMode() const
112    {
113      return m_AccessMode;
114    }
115
116    const int&
117    getSize() const
118    {
119      return m_Size;
120    }
121
122    const PrefetchBit&
123    getPrefetch() const
124    {
125      return m_Prefetch;
126    }
127
128    void print(std::ostream& out) const;
129};
130
131inline std::ostream&
132operator<<(std::ostream& out, const RubyRequest& obj)
133{
134  obj.print(out);
135  out << std::flush;
136  return out;
137}
138
139#endif
140