packet.hh revision 2423
12381SN/A/*
22592SN/A * Copyright (c) 2003 The Regents of The University of Michigan
32381SN/A * All rights reserved.
42381SN/A *
52381SN/A * Redistribution and use in source and binary forms, with or without
62381SN/A * modification, are permitted provided that the following conditions are
72381SN/A * met: redistributions of source code must retain the above copyright
82381SN/A * notice, this list of conditions and the following disclaimer;
92381SN/A * redistributions in binary form must reproduce the above copyright
102381SN/A * notice, this list of conditions and the following disclaimer in the
112381SN/A * documentation and/or other materials provided with the distribution;
122381SN/A * neither the name of the copyright holders nor the names of its
132381SN/A * contributors may be used to endorse or promote products derived from
142381SN/A * this software without specific prior written permission.
152381SN/A *
162381SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu */
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu/**
302665Ssaidi@eecs.umich.edu * @file
312381SN/A * Declaration of the Packet Class, a packet is a transaction occuring
322381SN/A * between a single level of the memory heirarchy (ie L1->L2).
332381SN/A */
342381SN/A
352662Sstever@eecs.umich.edu#ifndef __MEM_PACKET_HH__
362381SN/A#define __MEM_PACKET_HH__
372381SN/A
382381SN/A#include "mem/request.hh"
392381SN/A#include "arch/isa_traits.hh"
402381SN/A#include "sim/root.hh"
413348Sbinkertn@umich.edu
423348Sbinkertn@umich.edustruct Packet;
434022Sstever@eecs.umich.edutypedef Packet* PacketPtr;
443348Sbinkertn@umich.edutypedef uint8_t* PacketDataPtr;
455735Snate@binkert.org
464024Sbinkertn@umich.edu/** List of all commands associated with a packet. */
474610Ssaidi@eecs.umich.eduenum Command
485735Snate@binkert.org{
493940Ssaidi@eecs.umich.edu    Read,
505314Sstever@gmail.com    Write
516216Snate@binkert.org};
522392SN/A
534167Sbinkertn@umich.edu/** The result of a particular pakets request. */
542394SN/Aenum PacketResult
552394SN/A{
563349Sbinkertn@umich.edu    Success,
572394SN/A    BadAddress
582812Srdreslin@umich.edu};
592812Srdreslin@umich.edu
604022Sstever@eecs.umich.educlass SenderState{};
614022Sstever@eecs.umich.educlass Coherence{};
625735Snate@binkert.org
635735Snate@binkert.org/**
644022Sstever@eecs.umich.edu * A Packet is the structure to handle requests between two levels
655735Snate@binkert.org * of the memory system.  The Request is a global object that trancends
665735Snate@binkert.org * all of the memory heirarchy, but at each levels interface a packet
675735Snate@binkert.org * is created to transfer data/requests.  For example, a request would
684022Sstever@eecs.umich.edu * be used to initiate a request to go to memory/IOdevices, as the request
694022Sstever@eecs.umich.edu * passes through the memory system several packets will be created.  One
704022Sstever@eecs.umich.edu * will be created to go between the L1 and L2 caches and another to go to
714022Sstever@eecs.umich.edu * the next level and so forth.
724473Sstever@eecs.umich.edu *
735319Sstever@gmail.com * Packets are assumed to be returned in the case of a single response.  If
744022Sstever@eecs.umich.edu * the transaction has no response, then the consumer will delete the packet.
754022Sstever@eecs.umich.edu */
764022Sstever@eecs.umich.edustruct Packet
774022Sstever@eecs.umich.edu{
784022Sstever@eecs.umich.edu    /** The address of the request, could be virtual or physical (depending on
794022Sstever@eecs.umich.edu        cache configurations). */
804022Sstever@eecs.umich.edu    Addr addr;
814022Sstever@eecs.umich.edu
824022Sstever@eecs.umich.edu    /** Flag structure to hold flags for this particular packet */
834022Sstever@eecs.umich.edu    uint64_t flags;
844628Sstever@eecs.umich.edu
854022Sstever@eecs.umich.edu    /** A pointer to the overall request. */
864022Sstever@eecs.umich.edu    RequestPtr req;
874626Sstever@eecs.umich.edu
884626Sstever@eecs.umich.edu    /** A virtual base opaque structure used to hold
894626Sstever@eecs.umich.edu        coherence status messages. */
904040Ssaidi@eecs.umich.edu    Coherence *coherence;  // virtual base opaque,
914040Ssaidi@eecs.umich.edu                           // assert(dynamic_cast<Foo>) etc.
925650Sgblack@eecs.umich.edu
935650Sgblack@eecs.umich.edu    /** A virtual base opaque structure used to hold the senders state. */
944870Sstever@eecs.umich.edu    SenderState *senderState; // virtual base opaque,
954870Sstever@eecs.umich.edu                           // assert(dynamic_cast<Foo>) etc.
964870Sstever@eecs.umich.edu
974870Sstever@eecs.umich.edu    /** A pointer to the data being transfered.  It can be differnt sizes
984870Sstever@eecs.umich.edu        at each level of the heirarchy so it belongs in the packet,
994870Sstever@eecs.umich.edu        not request*/
1004870Sstever@eecs.umich.edu    PacketDataPtr data;
1015314Sstever@gmail.com
1025314Sstever@gmail.com    /** Indicates the size of the request. */
1034022Sstever@eecs.umich.edu    int size;
1044022Sstever@eecs.umich.edu
1054022Sstever@eecs.umich.edu    /** A index of the source of the transaction. */
1064022Sstever@eecs.umich.edu    short src;
1075735Snate@binkert.org
1085735Snate@binkert.org    /** A index to the destination of the transaction. */
1095735Snate@binkert.org    short dest;
1104022Sstever@eecs.umich.edu
1114022Sstever@eecs.umich.edu    /** The command of the transaction. */
1124626Sstever@eecs.umich.edu    Command cmd;
1134626Sstever@eecs.umich.edu
1144626Sstever@eecs.umich.edu    /** The result of the packet transaction. */
1154022Sstever@eecs.umich.edu    PacketResult result;
1164626Sstever@eecs.umich.edu
1174626Sstever@eecs.umich.edu    /** Accessor function that returns the source index of the packet. */
1184626Sstever@eecs.umich.edu    short getSrc() const { return src; }
1194626Sstever@eecs.umich.edu
1204022Sstever@eecs.umich.edu    /** Accessor function that returns the destination index of
1214022Sstever@eecs.umich.edu        the packet. */
1226076Sgblack@eecs.umich.edu    short getDest() const { return dest; }
1234626Sstever@eecs.umich.edu};
1244870Sstever@eecs.umich.edu
1255314Sstever@gmail.com#endif //__MEM_PACKET_HH
1264022Sstever@eecs.umich.edu