baddev.cc revision 909
112841Sgabeblack@google.com/* 212841Sgabeblack@google.com * Copyright (c) 2004 The Regents of The University of Michigan 312841Sgabeblack@google.com * All rights reserved. 412841Sgabeblack@google.com * 512841Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 612841Sgabeblack@google.com * modification, are permitted provided that the following conditions are 712841Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 812841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 912841Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1012841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1112841Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1212841Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1312841Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1412841Sgabeblack@google.com * this software without specific prior written permission. 1512841Sgabeblack@google.com * 1612841Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712841Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812841Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912841Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012841Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112841Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212841Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312841Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412841Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512841Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612841Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712841Sgabeblack@google.com */ 2812841Sgabeblack@google.com 2912841Sgabeblack@google.com/* @file 3012841Sgabeblack@google.com * BadDevice implemenation 3112841Sgabeblack@google.com */ 3212841Sgabeblack@google.com 3313199Sgabeblack@google.com#include <deque> 3412841Sgabeblack@google.com#include <string> 3513199Sgabeblack@google.com#include <vector> 3612841Sgabeblack@google.com 3712841Sgabeblack@google.com#include "base/trace.hh" 3812841Sgabeblack@google.com#include "cpu/exec_context.hh" 3912841Sgabeblack@google.com#include "dev/baddev.hh" 4012841Sgabeblack@google.com#include "mem/bus/bus.hh" 4112841Sgabeblack@google.com#include "mem/bus/pio_interface.hh" 4212841Sgabeblack@google.com#include "mem/bus/pio_interface_impl.hh" 4312841Sgabeblack@google.com#include "mem/functional_mem/memory_control.hh" 4412841Sgabeblack@google.com#include "sim/builder.hh" 4512841Sgabeblack@google.com#include "sim/system.hh" 4612841Sgabeblack@google.com 4712841Sgabeblack@google.comusing namespace std; 4812841Sgabeblack@google.com 4912841Sgabeblack@google.comBadDevice::BadDevice(const string &name, Addr a, MemoryController *mmu, 5012841Sgabeblack@google.com HierParams *hier, Bus *bus, const string &devicename) 5113199Sgabeblack@google.com : PioDevice(name), addr(a), devname(devicename) 5212841Sgabeblack@google.com{ 5312841Sgabeblack@google.com mmu->add_child(this, Range<Addr>(addr, addr + size)); 5412841Sgabeblack@google.com 5512841Sgabeblack@google.com if (bus) { 5612841Sgabeblack@google.com pioInterface = newPioInterface(name, hier, bus, this, 5713199Sgabeblack@google.com &BadDevice::cacheAccess); 5813199Sgabeblack@google.com pioInterface->addAddrRange(addr, addr + size - 1); 5913303Sgabeblack@google.com } 6012841Sgabeblack@google.com 6112841Sgabeblack@google.com} 6212841Sgabeblack@google.com 6312841Sgabeblack@google.comFault 6412841Sgabeblack@google.comBadDevice::read(MemReqPtr &req, uint8_t *data) 65{ 66 67 panic("Device %s not imlpmented\n", devname); 68 return No_Fault; 69} 70 71Fault 72BadDevice::write(MemReqPtr &req, const uint8_t *data) 73{ 74 panic("Device %s not imlpmented\n", devname); 75 return No_Fault; 76} 77 78Tick 79BadDevice::cacheAccess(MemReqPtr &req) 80{ 81 return curTick + 1000; 82} 83 84BEGIN_DECLARE_SIM_OBJECT_PARAMS(BadDevice) 85 86 SimObjectParam<MemoryController *> mmu; 87 Param<Addr> addr; 88 SimObjectParam<HierParams *> hier; 89 SimObjectParam<Bus*> io_bus; 90 Param<string> devicename; 91 92END_DECLARE_SIM_OBJECT_PARAMS(BadDevice) 93 94BEGIN_INIT_SIM_OBJECT_PARAMS(BadDevice) 95 96 INIT_PARAM(mmu, "Memory Controller"), 97 INIT_PARAM(addr, "Device Address"), 98 INIT_PARAM_DFLT(hier, "Hierarchy global variables", &defaultHierParams), 99 INIT_PARAM_DFLT(io_bus, "The IO Bus to attach to", NULL), 100 INIT_PARAM(devicename, "Name of device to error on") 101 102END_INIT_SIM_OBJECT_PARAMS(BadDevice) 103 104CREATE_SIM_OBJECT(BadDevice) 105{ 106 return new BadDevice(getInstanceName(), addr, mmu, hier, io_bus, devicename); 107} 108 109REGISTER_SIM_OBJECT("BadDevice", BadDevice) 110