mm_disk.hh revision 11168:f98eb2da15a4
113245Sgabeblack@google.com/* 213245Sgabeblack@google.com * Copyright (c) 2006 The Regents of The University of Michigan 313245Sgabeblack@google.com * All rights reserved. 413245Sgabeblack@google.com * 513245Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 613245Sgabeblack@google.com * modification, are permitted provided that the following conditions are 713245Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 813245Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 913245Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1013245Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1113245Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1213245Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1313245Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1413245Sgabeblack@google.com * this software without specific prior written permission. 1513245Sgabeblack@google.com * 1613245Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1713245Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1813245Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1913245Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2013245Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2113245Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2213245Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2313245Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2413245Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2513245Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2613245Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2713245Sgabeblack@google.com * 2813245Sgabeblack@google.com * Authors: Ali Saidi 2913245Sgabeblack@google.com */ 3013245Sgabeblack@google.com 3113245Sgabeblack@google.com/** @file 3213245Sgabeblack@google.com * This device acts as a disk similar to the memory mapped disk device 3313245Sgabeblack@google.com * in legion. Any access is translated to an offset in the disk image. 3413245Sgabeblack@google.com */ 3513245Sgabeblack@google.com 3613245Sgabeblack@google.com#ifndef __DEV_SPARC_MM_DISK_HH__ 3713245Sgabeblack@google.com#define __DEV_SPARC_MM_DISK_HH__ 3813245Sgabeblack@google.com 3913245Sgabeblack@google.com#include "dev/disk_image.hh" 4013245Sgabeblack@google.com#include "dev/io_device.hh" 4113245Sgabeblack@google.com#include "params/MmDisk.hh" 4213245Sgabeblack@google.com 4313245Sgabeblack@google.comclass MmDisk : public BasicPioDevice 4413245Sgabeblack@google.com{ 4513245Sgabeblack@google.com private: 4613245Sgabeblack@google.com DiskImage *image; 4713245Sgabeblack@google.com off_t curSector; 4813245Sgabeblack@google.com bool dirty; 4913245Sgabeblack@google.com uint8_t diskData[SectorSize]; 5013245Sgabeblack@google.com 5113245Sgabeblack@google.com public: 5213245Sgabeblack@google.com typedef MmDiskParams Params; 5313245Sgabeblack@google.com MmDisk(const Params *p); 5413245Sgabeblack@google.com 5513245Sgabeblack@google.com const Params * 5613245Sgabeblack@google.com params() const 5713245Sgabeblack@google.com { 5813245Sgabeblack@google.com return dynamic_cast<const Params *>(_params); 5913245Sgabeblack@google.com } 6013245Sgabeblack@google.com 6113245Sgabeblack@google.com virtual Tick read(PacketPtr pkt); 6213245Sgabeblack@google.com virtual Tick write(PacketPtr pkt); 6313245Sgabeblack@google.com 6413245Sgabeblack@google.com void serialize(CheckpointOut &cp) const override; 6513245Sgabeblack@google.com}; 6613245Sgabeblack@google.com 6713245Sgabeblack@google.com#endif //__DEV_SPARC_MM_DISK_HH__ 6813245Sgabeblack@google.com 6913245Sgabeblack@google.com