physical.hh revision 2914
12391SN/A/* 22391SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan 32391SN/A * All rights reserved. 42391SN/A * 52391SN/A * Redistribution and use in source and binary forms, with or without 62391SN/A * modification, are permitted provided that the following conditions are 72391SN/A * met: redistributions of source code must retain the above copyright 82391SN/A * notice, this list of conditions and the following disclaimer; 92391SN/A * redistributions in binary form must reproduce the above copyright 102391SN/A * notice, this list of conditions and the following disclaimer in the 112391SN/A * documentation and/or other materials provided with the distribution; 122391SN/A * neither the name of the copyright holders nor the names of its 132391SN/A * contributors may be used to endorse or promote products derived from 142391SN/A * this software without specific prior written permission. 152391SN/A * 162391SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172391SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182391SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192391SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202391SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212391SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222391SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232391SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242391SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252391SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262391SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Ron Dreslinski 292391SN/A */ 302391SN/A 312391SN/A/* @file 322391SN/A */ 332391SN/A 342391SN/A#ifndef __PHYSICAL_MEMORY_HH__ 352391SN/A#define __PHYSICAL_MEMORY_HH__ 362391SN/A 372391SN/A#include "base/range.hh" 382462SN/A#include "mem/mem_object.hh" 392414SN/A#include "mem/packet.hh" 402914Ssaidi@eecs.umich.edu#include "mem/tport.hh" 412415SN/A#include "sim/eventq.hh" 422416SN/A#include <map> 432416SN/A#include <string> 442462SN/A 452391SN/A// 462391SN/A// Functional model for a contiguous block of physical memory. (i.e. RAM) 472391SN/A// 482462SN/Aclass PhysicalMemory : public MemObject 492391SN/A{ 502914Ssaidi@eecs.umich.edu class MemoryPort : public SimpleTimingPort 512413SN/A { 522413SN/A PhysicalMemory *memory; 532413SN/A 542413SN/A public: 552413SN/A 562640Sstever@eecs.umich.edu MemoryPort(const std::string &_name, PhysicalMemory *_memory); 572413SN/A 582413SN/A protected: 592413SN/A 602630SN/A virtual bool recvTiming(Packet *pkt); 612413SN/A 622630SN/A virtual Tick recvAtomic(Packet *pkt); 632413SN/A 642630SN/A virtual void recvFunctional(Packet *pkt); 652413SN/A 662413SN/A virtual void recvStatusChange(Status status); 672413SN/A 682521SN/A virtual void getDeviceAddressRanges(AddrRangeList &resp, 692521SN/A AddrRangeList &snoop); 702413SN/A 712413SN/A virtual int deviceBlockSize(); 722413SN/A }; 732413SN/A 742416SN/A int numPorts; 752416SN/A 762413SN/A 772391SN/A private: 782391SN/A // prevent copying of a MainMemory object 792391SN/A PhysicalMemory(const PhysicalMemory &specmem); 802391SN/A const PhysicalMemory &operator=(const PhysicalMemory &specmem); 812391SN/A 822391SN/A protected: 832391SN/A Addr base_addr; 842391SN/A Addr pmem_size; 852391SN/A uint8_t *pmem_addr; 862499SN/A MemoryPort *port; 872391SN/A int page_ptr; 882565SN/A Tick lat; 892391SN/A 902391SN/A public: 912391SN/A Addr new_page(); 922391SN/A uint64_t size() { return pmem_size; } 932391SN/A 942391SN/A public: 952565SN/A PhysicalMemory(const std::string &n, Tick latency); 962391SN/A virtual ~PhysicalMemory(); 972391SN/A 982391SN/A public: 992415SN/A int deviceBlockSize(); 1002521SN/A void getAddressRanges(AddrRangeList &resp, AddrRangeList &snoop); 1012738Sstever@eecs.umich.edu virtual Port *getPort(const std::string &if_name, int idx = -1); 1022541SN/A void virtual init(); 1032914Ssaidi@eecs.umich.edu unsigned int drain(Event *de); 1042391SN/A 1052413SN/A private: 1062914Ssaidi@eecs.umich.edu Tick doFunctionalAccess(Packet *pkt); 1072413SN/A 1082413SN/A void recvStatusChange(Port::Status status); 1092391SN/A 1102391SN/A public: 1112391SN/A virtual void serialize(std::ostream &os); 1122391SN/A virtual void unserialize(Checkpoint *cp, const std::string §ion); 1132497SN/A 1142391SN/A}; 1152391SN/A 1162391SN/A#endif //__PHYSICAL_MEMORY_HH__ 117