InvalidateGenerator.cc revision 10566:c99c8d2a7c31
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * Copyright (c) 2009-2010 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution; 13 * neither the name of the copyright holders nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#include "cpu/testers/directedtest/DirectedGenerator.hh" 31#include "cpu/testers/directedtest/InvalidateGenerator.hh" 32#include "cpu/testers/directedtest/RubyDirectedTester.hh" 33#include "debug/DirectedTest.hh" 34 35InvalidateGenerator::InvalidateGenerator(const Params *p) 36 : DirectedGenerator(p) 37{ 38 // 39 // First, issue loads to bring the block into S state 40 // 41 m_status = InvalidateGeneratorStatus_Load_Waiting; 42 m_active_read_node = 0; 43 m_active_inv_node = 0; 44 m_address = 0x0; 45 m_addr_increment_size = p->addr_increment_size; 46} 47 48InvalidateGenerator::~InvalidateGenerator() 49{ 50} 51 52bool 53InvalidateGenerator::initiate() 54{ 55 MasterPort* port; 56 Request::Flags flags; 57 PacketPtr pkt; 58 Packet::Command cmd; 59 60 // For simplicity, requests are assumed to be 1 byte-sized 61 Request *req = new Request(m_address, 1, flags, masterId); 62 63 // 64 // Based on the current state, issue a load or a store 65 // 66 if (m_status == InvalidateGeneratorStatus_Load_Waiting) { 67 DPRINTF(DirectedTest, "initiating read\n"); 68 cmd = MemCmd::ReadReq; 69 port = m_directed_tester->getCpuPort(m_active_read_node); 70 pkt = new Packet(req, cmd); 71 } else if (m_status == InvalidateGeneratorStatus_Inv_Waiting) { 72 DPRINTF(DirectedTest, "initiating invalidating write\n"); 73 cmd = MemCmd::WriteReq; 74 port = m_directed_tester->getCpuPort(m_active_inv_node); 75 pkt = new Packet(req, cmd); 76 } else { 77 panic("initiate was unexpectedly called\n"); 78 } 79 pkt->allocate(); 80 81 if (port->sendTimingReq(pkt)) { 82 DPRINTF(DirectedTest, "initiating request - successful\n"); 83 if (m_status == InvalidateGeneratorStatus_Load_Waiting) { 84 m_status = InvalidateGeneratorStatus_Load_Pending; 85 } else { 86 m_status = InvalidateGeneratorStatus_Inv_Pending; 87 } 88 return true; 89 } else { 90 // If the packet did not issue, must delete 91 // Note: No need to delete the data, the packet destructor 92 // will delete it 93 delete pkt->req; 94 delete pkt; 95 96 DPRINTF(DirectedTest, "failed to issue request - sequencer not ready\n"); 97 return false; 98 } 99} 100 101void 102InvalidateGenerator::performCallback(uint32_t proc, Addr address) 103{ 104 assert(m_address == address); 105 106 if (m_status == InvalidateGeneratorStatus_Load_Pending) { 107 assert(m_active_read_node == proc); 108 m_active_read_node++; 109 // 110 // Once all cpus have the block in S state, issue the invalidate 111 // 112 if (m_active_read_node == m_num_cpus) { 113 m_status = InvalidateGeneratorStatus_Inv_Waiting; 114 m_active_read_node = 0; 115 } else { 116 m_status = InvalidateGeneratorStatus_Load_Waiting; 117 } 118 } else if (m_status == InvalidateGeneratorStatus_Inv_Pending) { 119 assert(m_active_inv_node == proc); 120 m_active_inv_node++; 121 if (m_active_inv_node == m_num_cpus) { 122 m_address += m_addr_increment_size; 123 m_active_inv_node = 0; 124 } 125 // 126 // Invalidate completed, send that info to the tester and restart 127 // the cycle 128 // 129 m_directed_tester->incrementCycleCompletions(); 130 m_status = InvalidateGeneratorStatus_Load_Waiting; 131 } 132 133} 134 135InvalidateGenerator * 136InvalidateGeneratorParams::create() 137{ 138 return new InvalidateGenerator(this); 139} 140