mm_disk.hh revision 8229
15584Snate@binkert.org/* 25584Snate@binkert.org * Copyright (c) 2006 The Regents of The University of Michigan 35584Snate@binkert.org * All rights reserved. 45584Snate@binkert.org * 55584Snate@binkert.org * Redistribution and use in source and binary forms, with or without 65584Snate@binkert.org * modification, are permitted provided that the following conditions are 75584Snate@binkert.org * met: redistributions of source code must retain the above copyright 85584Snate@binkert.org * notice, this list of conditions and the following disclaimer; 95584Snate@binkert.org * redistributions in binary form must reproduce the above copyright 105584Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 115584Snate@binkert.org * documentation and/or other materials provided with the distribution; 125584Snate@binkert.org * neither the name of the copyright holders nor the names of its 135584Snate@binkert.org * contributors may be used to endorse or promote products derived from 145584Snate@binkert.org * this software without specific prior written permission. 155584Snate@binkert.org * 165584Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175584Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185584Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195584Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205584Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215584Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225584Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235584Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245584Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255584Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265584Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275584Snate@binkert.org * 285584Snate@binkert.org * Authors: Ali Saidi 295584Snate@binkert.org */ 305584Snate@binkert.org 315584Snate@binkert.org/** @file 325584Snate@binkert.org * This device acts as a disk similar to the memory mapped disk device 337768SAli.Saidi@ARM.com * in legion. Any access is translated to an offset in the disk image. 347768SAli.Saidi@ARM.com */ 357768SAli.Saidi@ARM.com 367841Sgblack@eecs.umich.edu#ifndef __DEV_SPARC_MM_DISK_HH__ 377841Sgblack@eecs.umich.edu#define __DEV_SPARC_MM_DISK_HH__ 385584Snate@binkert.org 395584Snate@binkert.org#include "base/range.hh" 405584Snate@binkert.org#include "dev/disk_image.hh" 415584Snate@binkert.org#include "dev/io_device.hh" 425584Snate@binkert.org#include "params/MmDisk.hh" 435584Snate@binkert.org 445584Snate@binkert.orgclass MmDisk : public BasicPioDevice 455584Snate@binkert.org{ 465584Snate@binkert.org private: 475584Snate@binkert.org DiskImage *image; 485584Snate@binkert.org off_t curSector; 497824Sgblack@eecs.umich.edu bool dirty; 505584Snate@binkert.org uint8_t diskData[SectorSize]; 518951Sgblack@eecs.umich.edu 528235Snate@binkert.org public: 538235Snate@binkert.org typedef MmDiskParams Params; 548235Snate@binkert.org MmDisk(const Params *p); 558235Snate@binkert.org 568235Snate@binkert.org const Params * 575584Snate@binkert.org params() const 585584Snate@binkert.org { 595584Snate@binkert.org return dynamic_cast<const Params *>(_params); 60 } 61 62 virtual Tick read(PacketPtr pkt); 63 virtual Tick write(PacketPtr pkt); 64 65 virtual void serialize(std::ostream &os); 66}; 67 68#endif //__DEV_SPARC_MM_DISK_HH__ 69 70