2 * Copyright (c) 2001-2005 The Regents of The University of Michigan
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.
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.
28 * Authors: Daniel Sanchez
31 #ifndef __RUBY_MEMORY_HH__
32 #define __RUBY_MEMORY_HH__
37 #include "base/callback.hh"
38 #include "mem/packet.hh"
39 #include "mem/physical.hh"
40 #include "mem/ruby/system/RubyPort.hh"
41 #include "params/RubyMemory.hh"
43 class RubyMemory : public PhysicalMemory
46 std::vector<RubyPort *> ruby_ports;
47 class Port : public MemoryPort
49 friend void ruby_hit_callback(int64_t req_id);
54 Port(const std::string &_name, RubyMemory *_memory);
55 void sendTiming(PacketPtr pkt);
58 virtual bool recvTiming(PacketPtr pkt);
61 class RubyEvent : public Event
65 RubyEvent(RubyMemory *p)
66 : Event(), ruby_ptr(p) {}
68 virtual void process() { ruby_ptr->tick(); }
70 virtual const char *description() const { return "ruby tick"; }
73 struct SenderState : public Packet::SenderState
76 Packet::SenderState *saved;
78 SenderState(Port *p, Packet::SenderState *s = NULL)
84 // prevent copying of a RubyMemory object
85 RubyMemory(const RubyMemory &specmem);
86 const RubyMemory &operator=(const RubyMemory &specmem);
88 RubyEvent* rubyTickEvent;
91 typedef RubyMemoryParams Params;
92 RubyMemory(const Params *p);
93 virtual ~RubyMemory();
98 return safe_cast<const Params *>(_params);
102 virtual ::Port *getPort(const std::string &if_name, int idx = -1);
105 //Ruby-related specifics
106 void printConfigStats(); //dsm: Maybe this function should
107 //disappear once the configuration
108 //options change & M5 determines the
111 void hitCallback(PacketPtr pkt, Port *port);
113 void printStats(std::ostream & out) const;
115 void printConfig(std::ostream & out) const;
124 static std::map<int64_t, PacketPtr> pending_requests;
127 void ruby_hit_callback(int64_t);
129 class RubyExitCallback : public Callback
136 * virtualize the destructor to make sure that the correct one
140 virtual ~RubyExitCallback() {};
142 RubyExitCallback(RubyMemory* rm) {ruby=rm;};
145 * virtual process function that is invoked when the callback
148 virtual void process() {ruby->printConfigStats(); /*delete ruby; was doing double delete...*/};
152 #endif //__RUBY_MEMORY_HH__