2 * Copyright (c) 2007 The Hewlett-Packard Development Company
5 * Redistribution and use of this software in source and binary forms,
6 * with or without modification, are permitted provided that the
7 * following conditions are met:
9 * The software must be used only for Non-Commercial Use which means any
10 * use which is NOT directed to receiving any direct monetary
11 * compensation for, or commercial advantage from such use. Illustrative
12 * examples of non-commercial use are academic research, personal study,
13 * teaching, education and corporate research & development.
14 * Illustrative examples of commercial use are distributing products for
15 * commercial advantage and providing services using the software for
16 * commercial advantage.
18 * If you wish to use this software or functionality therein that may be
19 * covered by patents for commercial use, please contact:
20 * Director of Intellectual Property Licensing
21 * Office of Strategy and Technology
22 * Hewlett-Packard Company
24 * Palo Alto, California 94304
26 * Redistributions of source code must retain the above copyright notice,
27 * this list of conditions and the following disclaimer. Redistributions
28 * in binary form must reproduce the above copyright notice, this list of
29 * conditions and the following disclaimer in the documentation and/or
30 * other materials provided with the distribution. Neither the name of
31 * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
32 * contributors may be used to endorse or promote products derived from
33 * this software without specific prior written permission. No right of
34 * sublicense is granted herewith. Derivatives of the software and
35 * output created using the software may be prepared, but only for
36 * Non-Commercial Uses. Derivatives of the software may be shared with
37 * others provided: (i) the others agree to abide by the list of
38 * conditions herein which includes the Non-Commercial Use restrictions;
39 * and (ii) such Derivatives of the software include the above copyright
40 * notice to acknowledge the contribution from this software where
41 * applicable, this list of conditions and the disclaimer below.
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58 #ifndef __ARCH_X86_PAGE_TABLE_WALKER_HH__
59 #define __ARCH_X86_PAGE_TABLE_WALKER_HH__
63 #include "arch/x86/pagetable.hh"
64 #include "arch/x86/tlb.hh"
65 #include "mem/mem_object.hh"
66 #include "mem/packet.hh"
67 #include "params/X86PagetableWalker.hh"
68 #include "sim/host.hh"
74 class Walker : public MemObject
81 LongPML4, LongPDP, LongPD, LongPTE,
83 PAEPDP, PAEPD, PAEPTE,
84 // Non PAE legacy mode with and without PSE
88 // Act on the current state and determine what to do next. read
89 // should be the packet that just came back from a read and write
90 // should be NULL. When the function returns, read is either NULL
91 // if the machine is finished, or points to a packet to initiate
92 // the next read. If any write is required to update an "accessed"
93 // bit, write will point to a packet to do the write. Otherwise it
95 void doNext(PacketPtr &read, PacketPtr &write);
97 // Kick off the state machine.
98 void start(ThreadContext * _tc, Addr vaddr);
103 * State having to do with sending packets.
106 std::vector<PacketPtr> writes;
108 // How many memory operations are in flight.
114 * Functions for dealing with packets.
116 bool recvTiming(PacketPtr pkt);
122 * Port for accessing memory
124 class WalkerPort : public Port
127 WalkerPort(const std::string &_name, Walker * _walker) :
128 Port(_name, _walker), walker(_walker),
129 snoopRangeSent(false)
137 bool recvTiming(PacketPtr pkt);
138 Tick recvAtomic(PacketPtr pkt);
139 void recvFunctional(PacketPtr pkt);
140 void recvStatusChange(Status status);
142 void getDeviceAddressRanges(AddrRangeList &resp,
150 Port *getPort(const std::string &if_name, int idx = -1);
152 friend class WalkerPort;
156 // The TLB we're supposed to load.
161 * State machine state.
172 void setTLB(TLB * _tlb)
177 typedef X86PagetableWalkerParams Params;
179 Walker(const Params *params) :
181 read(NULL), inflight(0), retrying(false),
182 port(name() + ".port", this),
183 tlb(NULL), sys(params->system),
184 tc(NULL), state(Ready), nextState(Ready)
189 #endif // __ARCH_X86_PAGE_TABLE_WALKER_HH__