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