Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: LoadStoreBuffer.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 _LOADSTOREBUFFER_H | |
24 | #define _LOADSTOREBUFFER_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 | #include <assert.h> | |
40 | ||
41 | #include "MemorySyncDefs.h" | |
42 | #include "LoadStoreCmd.h" | |
43 | #include "LoadStoreEntry.h" | |
44 | #include <list> | |
45 | #include <cstring> | |
46 | ||
47 | class LoadStoreBuffer { | |
48 | ||
49 | public: | |
50 | /** | |
51 | * Default constructor | |
52 | */ | |
53 | LoadStoreBuffer(); | |
54 | ||
55 | /** | |
56 | * Copy constructor | |
57 | * | |
58 | * @param orig The LoadStoreBuffer object to copy. | |
59 | */ | |
60 | LoadStoreBuffer( const LoadStoreBuffer &orig ); | |
61 | ||
62 | /** | |
63 | * Destructor | |
64 | */ | |
65 | virtual ~LoadStoreBuffer(); | |
66 | ||
67 | /** | |
68 | * Equality operator | |
69 | * | |
70 | * @param rhs The right hand side of the equality operator | |
71 | * @return Return true if this objec and rhs are equal, | |
72 | * otherwise return false | |
73 | */ | |
74 | bool operator==( const LoadStoreBuffer &rhs ) const; | |
75 | ||
76 | /** | |
77 | * Assignment operator | |
78 | * | |
79 | * @param rhs The right hand side of the assignment operator. | |
80 | * @return The lvalue of the assignment. | |
81 | */ | |
82 | const LoadStoreBuffer & operator=( const LoadStoreBuffer &rhs ); | |
83 | ||
84 | /** | |
85 | * Return a string representation of this LoadStoreBuffer object. | |
86 | */ | |
87 | std::string toString() const; | |
88 | ||
89 | void setBufName (char* name) { strcpy (bufName_, name); } | |
90 | char* getBufName () { return bufName_; } | |
91 | ||
92 | void insert (LoadStoreCmd& cmd); | |
93 | ||
94 | std::list<LoadStoreEntry>::iterator pushBack(LoadStoreEntry& cmd); | |
95 | void erase(std::list<LoadStoreEntry>::iterator ii); | |
96 | void popFront(); | |
97 | void popBack(int count=1); | |
98 | ||
99 | std::list<LoadStoreEntry>::iterator findMatchY2O(uint64_t addr, uint8_t size_vector); | |
100 | std::list<LoadStoreEntry>::iterator findMatchY2O(uint64_t id, uint64_t addr, uint8_t size_vector); | |
101 | std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr, uint8_t size_vector); | |
102 | std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t id, uint64_t addr, uint8_t size_vector); | |
103 | std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr, enum LS_ENTRY_STATE state, uint64_t addrMask); | |
104 | std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr); | |
105 | std::list<LoadStoreEntry>::iterator findNotIssuedO2Y(uint64_t addr); | |
106 | std::list<LoadStoreEntry>::iterator find1stNonExe(); | |
107 | std::list<LoadStoreEntry>::iterator find1stNonExeMatchedAddr(uint64_t addr); | |
108 | std::list<LoadStoreEntry>::iterator find1stNonExeOrMatchedAddrAtomic(uint64_t addr); | |
109 | std::list<LoadStoreEntry>::iterator findNeedTDataO2Y(uint64_t addr); | |
110 | ||
111 | /** | |
112 | * Method to find data bypassing | |
113 | * <p> | |
114 | * This method attempts to find matched entry that satisfies the data access request. | |
115 | * Note that the search is from back to front, i.e., young to old. | |
116 | * <p> | |
117 | * The rule of searching is <br> | |
118 | * - partial fulfill the request, return buf_.end() | |
119 | * - fully comply with the request, return the matched entry's iterator | |
120 | * - no match, try next | |
121 | * @param addr address to be matched, the 3 least significant bits are ignored | |
122 | * @param size_vector valid bytes of data to ask | |
123 | * @return entry iterator that satisfies the request; otherwise, return buf_.end() | |
124 | */ | |
125 | std::list<LoadStoreEntry>::iterator findDataBypassing (uint64_t addr, uint8_t size_vector); | |
126 | std::list<LoadStoreEntry>::iterator findN2DataBypassing (uint64_t addr, uint8_t size_vector); | |
127 | ||
128 | std::list<LoadStoreEntry>::iterator findMatchO2Y(uint64_t addr, bool rmo, uint64_t addrMask); | |
129 | std::list<LoadStoreEntry>::iterator LoadStoreBuffer::find1stNonExeFetch(uint64_t addr); | |
130 | std::list<LoadStoreEntry>::iterator find1stNoLink(uint64_t id, uint64_t addr, uint64_t addrMask); | |
131 | ||
132 | std::list<LoadStoreEntry>::reference front() { return buf_.front(); } | |
133 | std::list<LoadStoreEntry>::iterator end() { return buf_.end(); } | |
134 | std::list<LoadStoreEntry>::iterator begin() { return buf_.begin(); } | |
135 | std::list<LoadStoreEntry>::size_type size() { return buf_.size(); } | |
136 | ||
137 | std::list<LoadStoreEntry>* getBufPtr() { return &buf_; } | |
138 | ||
139 | /* | |
140 | * empty the buffer | |
141 | */ | |
142 | void empty(); | |
143 | std::list<LoadStoreEntry>::iterator queryBack(); | |
144 | /** | |
145 | * | |
146 | */ | |
147 | void markPop(); | |
148 | ||
149 | protected: | |
150 | ||
151 | private: | |
152 | std::list<LoadStoreEntry> buf_; | |
153 | char bufName_[30]; | |
154 | }; | |
155 | ||
156 | #endif /* _LOADSTOREBUFFER_H */ |