2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
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.
29 #ifndef __MEM_RUBY_SYSTEM_SEQUENCER_HH__
30 #define __MEM_RUBY_SYSTEM_SEQUENCER_HH__
34 #include "base/hashmap.hh"
35 #include "mem/protocol/GenericMachineType.hh"
36 #include "mem/protocol/RubyRequestType.hh"
37 #include "mem/ruby/common/Address.hh"
38 #include "mem/ruby/common/Consumer.hh"
39 #include "mem/ruby/system/RubyPort.hh"
44 struct RubySequencerParams;
46 struct SequencerRequest
49 RubyRequestType m_type;
52 SequencerRequest(PacketPtr _pkt, RubyRequestType _m_type, Time _issue_time)
53 : pkt(_pkt), m_type(_m_type), issue_time(_issue_time)
57 std::ostream& operator<<(std::ostream& out, const SequencerRequest& obj);
59 class Sequencer : public RubyPort, public Consumer
62 typedef RubySequencerParams Params;
63 Sequencer(const Params *);
67 void wakeup(); // Used only for deadlock detection
69 void printConfig(std::ostream& out) const;
71 void printProgress(std::ostream& out) const;
73 void writeCallback(const Address& address, DataBlock& data);
75 void writeCallback(const Address& address,
76 GenericMachineType mach,
79 void writeCallback(const Address& address,
80 GenericMachineType mach,
82 Time initialRequestTime,
83 Time forwardRequestTime,
84 Time firstResponseTime);
86 void readCallback(const Address& address, DataBlock& data);
88 void readCallback(const Address& address,
89 GenericMachineType mach,
92 void readCallback(const Address& address,
93 GenericMachineType mach,
95 Time initialRequestTime,
96 Time forwardRequestTime,
97 Time firstResponseTime);
99 RequestStatus makeRequest(PacketPtr pkt);
101 int outstandingCount() const { return m_outstanding_count; }
103 isDeadlockEventScheduled() const
105 return deadlockCheckEvent.scheduled();
109 descheduleDeadlockEvent()
111 deschedule(deadlockCheckEvent);
114 void print(std::ostream& out) const;
115 void printStats(std::ostream& out) const;
116 void checkCoherence(const Address& address);
119 void removeRequest(SequencerRequest* request);
120 void evictionCallback(const Address& address);
123 void issueRequest(PacketPtr pkt, RubyRequestType type);
125 void hitCallback(SequencerRequest* request,
126 GenericMachineType mach,
129 Time initialRequestTime,
130 Time forwardRequestTime,
131 Time firstResponseTime);
133 RequestStatus insertRequest(PacketPtr pkt, RubyRequestType request_type);
135 bool handleLlsc(const Address& address, SequencerRequest* request);
137 // Private copy constructor and assignment operator
138 Sequencer(const Sequencer& obj);
139 Sequencer& operator=(const Sequencer& obj);
142 int m_max_outstanding_requests;
143 int m_deadlock_threshold;
145 CacheMemory* m_dataCache_ptr;
146 CacheMemory* m_instCache_ptr;
148 typedef m5::hash_map<Address, SequencerRequest*> RequestTable;
149 RequestTable m_writeRequestTable;
150 RequestTable m_readRequestTable;
151 // Global outstanding request count, across all request tables
152 int m_outstanding_count;
153 bool m_deadlock_check_scheduled;
155 int m_store_waiting_on_load_cycles;
156 int m_store_waiting_on_store_cycles;
157 int m_load_waiting_on_store_cycles;
158 int m_load_waiting_on_load_cycles;
160 bool m_usingNetworkTester;
162 class SequencerWakeupEvent : public Event
165 Sequencer *m_sequencer_ptr;
168 SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {}
169 void process() { m_sequencer_ptr->wakeup(); }
170 const char *description() const { return "Sequencer deadlock check"; }
173 SequencerWakeupEvent deadlockCheckEvent;
177 operator<<(std::ostream& out, const Sequencer& obj)
184 #endif // __MEM_RUBY_SYSTEM_SEQUENCER_HH__