114184Sgabeblack@google.com
214184Sgabeblack@google.com/*
314184Sgabeblack@google.com * Copyright (c) 1999-2005 Mark D. Hill and David A. Wood
414184Sgabeblack@google.com * All rights reserved.
514184Sgabeblack@google.com *
614184Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
714184Sgabeblack@google.com * modification, are permitted provided that the following conditions are
814184Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
914184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
1014184Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1114184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1214184Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1314184Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1414184Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1514184Sgabeblack@google.com * this software without specific prior written permission.
1614184Sgabeblack@google.com *
1714184Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1814184Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1914184Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2014184Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2114184Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2214184Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2314184Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2414184Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2514184Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2614184Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2714184Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2814184Sgabeblack@google.com */
2914184Sgabeblack@google.com
3014184Sgabeblack@google.com
3114184Sgabeblack@google.com// CoherenceRequestType
3214184Sgabeblack@google.comenumeration(CoherenceRequestType, desc="...") {
3314184Sgabeblack@google.com  GETX,      desc="Get eXclusive";
3414184Sgabeblack@google.com  UPGRADE,   desc="UPGRADE to exclusive";
3514184Sgabeblack@google.com  GETS,      desc="Get Shared";
3614184Sgabeblack@google.com  GET_INSTR, desc="Get Instruction";
3714184Sgabeblack@google.com  INV,       desc="INValidate";
3814184Sgabeblack@google.com  PUTX,      desc="Replacement message";
3914184Sgabeblack@google.com
4014184Sgabeblack@google.com  WB_ACK,    desc="Writeback ack";
4114184Sgabeblack@google.com
4214184Sgabeblack@google.com  DMA_READ, desc="DMA Read";
4314184Sgabeblack@google.com  DMA_WRITE, desc="DMA Write";
4414184Sgabeblack@google.com}
4514184Sgabeblack@google.com
4614184Sgabeblack@google.com// CoherenceResponseType
4714184Sgabeblack@google.comenumeration(CoherenceResponseType, desc="...") {
4814184Sgabeblack@google.com  MEMORY_ACK, desc="Ack from memory controller";
4914184Sgabeblack@google.com  DATA, desc="Data block for L1 cache in S state";
5014184Sgabeblack@google.com  DATA_EXCLUSIVE, desc="Data block for L1 cache in M/E state";
5114184Sgabeblack@google.com  MEMORY_DATA, desc="Data block from / to main memory";
5214184Sgabeblack@google.com  ACK, desc="Generic invalidate ack";
5314184Sgabeblack@google.com  WB_ACK, desc="writeback ack";
5414184Sgabeblack@google.com  UNBLOCK, desc="unblock";
5514184Sgabeblack@google.com  EXCLUSIVE_UNBLOCK, desc="exclusive unblock";
5614184Sgabeblack@google.com  INV, desc="Invalidate from directory";
5714184Sgabeblack@google.com}
5814184Sgabeblack@google.com
5914184Sgabeblack@google.com// RequestMsg
6014184Sgabeblack@google.comstructure(RequestMsg, desc="...", interface="Message") {
6114184Sgabeblack@google.com  Addr addr,              desc="Physical address for this request";
6214184Sgabeblack@google.com  CoherenceRequestType Type,    desc="Type of request (GetS, GetX, PutX, etc)";
6314184Sgabeblack@google.com  RubyAccessMode AccessMode,    desc="user/supervisor access type";
6414184Sgabeblack@google.com  MachineID Requestor      ,    desc="What component request";
6514184Sgabeblack@google.com  NetDest Destination,          desc="What components receive the request, includes MachineType and num";
6614184Sgabeblack@google.com  MessageSizeType MessageSize,  desc="size category of the message";
6714184Sgabeblack@google.com  DataBlock DataBlk,            desc="Data for the cache line (if PUTX)";
6814184Sgabeblack@google.com  int Len;
6914184Sgabeblack@google.com  bool Dirty, default="false",  desc="Dirty bit";
7014184Sgabeblack@google.com  PrefetchBit Prefetch,         desc="Is this a prefetch request";
7114184Sgabeblack@google.com
7214184Sgabeblack@google.com  bool functionalRead(Packet *pkt) {
7314184Sgabeblack@google.com    // Only PUTX messages contains the data block
7414184Sgabeblack@google.com    if (Type == CoherenceRequestType:PUTX) {
7514184Sgabeblack@google.com        return testAndRead(addr, DataBlk, pkt);
7614184Sgabeblack@google.com    }
7714184Sgabeblack@google.com
7814184Sgabeblack@google.com    return false;
7914184Sgabeblack@google.com  }
8014184Sgabeblack@google.com
8114184Sgabeblack@google.com  bool functionalWrite(Packet *pkt) {
8214184Sgabeblack@google.com    // No check on message type required since the protocol should
8314184Sgabeblack@google.com    // read data from those messages that contain the block
8414184Sgabeblack@google.com    return testAndWrite(addr, DataBlk, pkt);
8514184Sgabeblack@google.com  }
8614184Sgabeblack@google.com}
8714184Sgabeblack@google.com
8814184Sgabeblack@google.com// ResponseMsg
8914184Sgabeblack@google.comstructure(ResponseMsg, desc="...", interface="Message") {
9014184Sgabeblack@google.com  Addr addr,              desc="Physical address for this request";
9114184Sgabeblack@google.com  CoherenceResponseType Type,   desc="Type of response (Ack, Data, etc)";
9214184Sgabeblack@google.com  MachineID Sender,             desc="What component sent the data";
9314184Sgabeblack@google.com  NetDest Destination,          desc="Node to whom the data is sent";
9414184Sgabeblack@google.com  DataBlock DataBlk,            desc="Data for the cache line";
9514184Sgabeblack@google.com  bool Dirty, default="false",  desc="Dirty bit";
9614184Sgabeblack@google.com  int AckCount, default="0",  desc="number of acks in this message";
9714184Sgabeblack@google.com  MessageSizeType MessageSize,  desc="size category of the message";
9814184Sgabeblack@google.com
9914184Sgabeblack@google.com  bool functionalRead(Packet *pkt) {
10014184Sgabeblack@google.com    // Valid data block is only present in message with following types
10114184Sgabeblack@google.com    if (Type == CoherenceResponseType:DATA ||
10214184Sgabeblack@google.com        Type == CoherenceResponseType:DATA_EXCLUSIVE ||
10314184Sgabeblack@google.com        Type == CoherenceResponseType:MEMORY_DATA) {
10414184Sgabeblack@google.com
10514184Sgabeblack@google.com        return testAndRead(addr, DataBlk, pkt);
10614184Sgabeblack@google.com    }
10714184Sgabeblack@google.com
10814184Sgabeblack@google.com    return false;
10914184Sgabeblack@google.com  }
11014184Sgabeblack@google.com
11114184Sgabeblack@google.com  bool functionalWrite(Packet *pkt) {
11214184Sgabeblack@google.com    // No check on message type required since the protocol should
11314184Sgabeblack@google.com    // read data from those messages that contain the block
11414184Sgabeblack@google.com    return testAndWrite(addr, DataBlk, pkt);
11514184Sgabeblack@google.com  }
11614184Sgabeblack@google.com}
117