Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: MemoryAccessBuffer.h | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #ifndef _MEMORYACCESSBUFFER_H | |
24 | #define _MEMORYACCESSBUFFER_H | |
25 | /************************************************************************ | |
26 | ** | |
27 | ** Copyright (C) 2002, Sun Microsystems, Inc. | |
28 | ** | |
29 | ** Sun considers its source code as an unpublished, proprietary | |
30 | ** trade secret and it is available only under strict license provisions. | |
31 | ** This copyright notice is placed here only to protect Sun in the event | |
32 | ** the source is deemed a published work. Disassembly, decompilation, | |
33 | ** or other means of reducing the object code to human readable form | |
34 | ** is prohibited by the license agreement under which this code is | |
35 | ** provided to the user or company in possession of this copy." | |
36 | ** | |
37 | *************************************************************************/ | |
38 | #include <iostream> | |
39 | ||
40 | #include <list> | |
41 | #include <vector> | |
42 | #include "MemorySyncDefs.h" | |
43 | #include "LoadStoreCmd.h" | |
44 | #include "MemoryAccessEntry.h" | |
45 | #include "TsoChecker.h" | |
46 | ||
47 | using namespace Tso; | |
48 | ||
49 | class MemoryAccessBuffer { | |
50 | ||
51 | public: | |
52 | /** | |
53 | * Default constructor | |
54 | */ | |
55 | MemoryAccessBuffer(); | |
56 | ||
57 | /** | |
58 | * Copy constructor | |
59 | * | |
60 | * @param orig The MemoryAccessBuffer object to copy. | |
61 | */ | |
62 | MemoryAccessBuffer( const MemoryAccessBuffer &orig ); | |
63 | ||
64 | /** | |
65 | * Destructor | |
66 | */ | |
67 | virtual ~MemoryAccessBuffer(); | |
68 | ||
69 | /** | |
70 | * Equality operator | |
71 | * | |
72 | * @param rhs The right hand side of the equality operator | |
73 | * @return Return true if this objec and rhs are equal, | |
74 | * otherwise return false | |
75 | */ | |
76 | bool operator==( const MemoryAccessBuffer &rhs ) const; | |
77 | ||
78 | /** | |
79 | * Assignment operator | |
80 | * | |
81 | * @param rhs The right hand side of the assignment operator. | |
82 | * @return The lvalue of the assignment. | |
83 | */ | |
84 | const MemoryAccessBuffer & operator=( const MemoryAccessBuffer &rhs ); | |
85 | ||
86 | /** | |
87 | * Return a string representation of this MemoryAccessBuffer object. | |
88 | */ | |
89 | std::string toString() const; | |
90 | ||
91 | std::list<MemoryAccessEntry>::iterator end() { return buf_.end(); } | |
92 | std::list<MemoryAccessEntry>::iterator begin() { return buf_.begin(); } | |
93 | void insert(enum MEM_CMD cmd); | |
94 | void dequeue(std::list<MemoryAccessEntry>::iterator ii); | |
95 | std::list<MemoryAccessEntry>::iterator findL1InstrEntry(LoadStoreCmd& cmd); | |
96 | std::list<MemoryAccessEntry>::iterator findL1DataEntry(LoadStoreCmd& cmd); | |
97 | std::list<MemoryAccessEntry>::iterator | |
98 | findL2DataEntry(std::list<MemoryAccessEntry>::iterator from, LoadStoreCmd& cmd); | |
99 | std::list<MemoryAccessEntry>::iterator findStoreInvStoreUpdateSrc(LoadStoreCmd& cmd); | |
100 | std::list<MemoryAccessEntry>::iterator findStoreAckSrc(LoadStoreCmd& cmd); | |
101 | std::list<MemoryAccessEntry>::iterator findLoadFillSrc(LoadStoreCmd& cmd); | |
102 | std::list<MemoryAccessEntry>::iterator findFetchFillSrc(LoadStoreCmd& cmd); | |
103 | std::list<MemoryAccessEntry>::iterator findEvictInvSrc(LoadStoreCmd& cmd); | |
104 | ||
105 | std::list<MemoryAccessEntry>::iterator matchedL2Miss(std::list<MemoryAccessEntry>::iterator ii); | |
106 | ||
107 | std::list<MemoryAccessEntry>::iterator pushBack(MemoryAccessEntry& entry); | |
108 | void popFront(std::vector<MemoryAccessEntry>* wdbuf, | |
109 | Tso::TsoChecker* tsoChecker); | |
110 | ||
111 | /** | |
112 | * erase entries of specified strand-id | |
113 | */ | |
114 | void empty(int tid=-1); | |
115 | /** | |
116 | * pop the last load entry of a particular strand out of the queue | |
117 | */ | |
118 | void popBack(int tid, int count=1); | |
119 | void popBackStore(std::list<MemoryAccessEntry>::iterator& jj); | |
120 | ||
121 | /** | |
122 | * functions to ensure load entries maintain correct data after a store | |
123 | * entry is poped due to error injection | |
124 | */ | |
125 | std::list<MemoryAccessEntry>::iterator findL1DataEntry(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr); | |
126 | std::list<MemoryAccessEntry>::iterator findL2DataEntry(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr, bool executed=false); | |
127 | std::list<MemoryAccessEntry>::iterator findLoadFillSrc(std::list<MemoryAccessEntry>::iterator endMark, uint32_t cid, uint32_t tid, uint64_t addr, bool noFault=false); | |
128 | uint64_t getL1Data(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr); | |
129 | uint64_t getL2Data(std::list<MemoryAccessEntry>::iterator from, uint32_t cid, uint32_t tid, uint64_t addr, bool executed=false); | |
130 | void refreshLoadEntry(std::list<MemoryAccessEntry>::iterator fromMark); | |
131 | void setRieslingInterface(RieslingInterface* rs) { rif_ = rs; } | |
132 | uint64_t merge (uint64_t todata, uint64_t fromdata, uint8_t mgvec); | |
133 | uint64_t byteMask(const uint8_t vbyte); | |
134 | ||
135 | /** | |
136 | * search for the first matching dma_store entry with inv_vec==0 | |
137 | */ | |
138 | std::list<MemoryAccessEntry>::iterator findDmaStoreEntry(LoadStoreCmd& cmd, int type); | |
139 | std::list<MemoryAccessEntry>::iterator findDmaStoreStart(LoadStoreCmd& cmd, int type); | |
140 | ||
141 | bool updateMemory(std::list<MemoryAccessEntry>::iterator stCommit); | |
142 | ||
143 | protected: | |
144 | ||
145 | ||
146 | private: | |
147 | std::list<MemoryAccessEntry> buf_; | |
148 | RieslingInterface* rif_; | |
149 | }; | |
150 | ||
151 | #endif /* _MEMORYACCESSBUFFER_H */ |