baddev.cc revision 3349
112841Sgabeblack@google.com/* 212841Sgabeblack@google.com * Copyright (c) 2004-2005 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 * Authors: Ali Saidi 2912841Sgabeblack@google.com */ 3012841Sgabeblack@google.com 3112841Sgabeblack@google.com/** @file 3212841Sgabeblack@google.com * BadDevice implemenation 3312841Sgabeblack@google.com */ 3412841Sgabeblack@google.com 3513054Sgabeblack@google.com#include <deque> 3613269Sgabeblack@google.com#include <string> 3712841Sgabeblack@google.com#include <vector> 3813245Sgabeblack@google.com 3912841Sgabeblack@google.com#include "base/trace.hh" 4012841Sgabeblack@google.com#include "dev/baddev.hh" 4112841Sgabeblack@google.com#include "dev/platform.hh" 4212841Sgabeblack@google.com#include "mem/port.hh" 4312841Sgabeblack@google.com#include "sim/builder.hh" 4412841Sgabeblack@google.com#include "sim/system.hh" 4512841Sgabeblack@google.com 4612841Sgabeblack@google.comusing namespace std; 4712841Sgabeblack@google.comusing namespace TheISA; 4812841Sgabeblack@google.com 4912841Sgabeblack@google.comBadDevice::BadDevice(Params *p) 5012841Sgabeblack@google.com : BasicPioDevice(p), devname(p->device_name) 5112841Sgabeblack@google.com{ 5213054Sgabeblack@google.com pioSize = 0xf; 5313054Sgabeblack@google.com} 5413054Sgabeblack@google.com 5513054Sgabeblack@google.comTick 5613054Sgabeblack@google.comBadDevice::read(PacketPtr pkt) 5713054Sgabeblack@google.com{ 5812841Sgabeblack@google.com panic("Device %s not imlpmented\n", devname); 5912841Sgabeblack@google.com} 6012868Sgabeblack@google.com 6112868Sgabeblack@google.comTick 6213054Sgabeblack@google.comBadDevice::write(PacketPtr pkt) 6313054Sgabeblack@google.com{ 6412868Sgabeblack@google.com panic("Device %s not imlpmented\n", devname); 6512868Sgabeblack@google.com} 6613054Sgabeblack@google.com 6713054Sgabeblack@google.comBEGIN_DECLARE_SIM_OBJECT_PARAMS(BadDevice) 6812868Sgabeblack@google.com 6912868Sgabeblack@google.com Param<string> devicename; 7013054Sgabeblack@google.com Param<Addr> pio_addr; 7113054Sgabeblack@google.com SimObjectParam<System *> system; 7212868Sgabeblack@google.com SimObjectParam<Platform *> platform; 7312868Sgabeblack@google.com Param<Tick> pio_latency; 7413054Sgabeblack@google.com 7513054Sgabeblack@google.comEND_DECLARE_SIM_OBJECT_PARAMS(BadDevice) 7612868Sgabeblack@google.com 7712868Sgabeblack@google.comBEGIN_INIT_SIM_OBJECT_PARAMS(BadDevice) 7813054Sgabeblack@google.com 7913054Sgabeblack@google.com INIT_PARAM(devicename, "Name of device to error on"), 8012868Sgabeblack@google.com INIT_PARAM(pio_addr, "Device Address"), 8112868Sgabeblack@google.com INIT_PARAM(system, "system object"), 8213054Sgabeblack@google.com INIT_PARAM(platform, "platform"), 8313054Sgabeblack@google.com INIT_PARAM_DFLT(pio_latency, "Programmed IO latency", 1000) 8412868Sgabeblack@google.com 8512868Sgabeblack@google.comEND_INIT_SIM_OBJECT_PARAMS(BadDevice) 8612841Sgabeblack@google.com 8713054Sgabeblack@google.comCREATE_SIM_OBJECT(BadDevice) 8812841Sgabeblack@google.com{ 8913054Sgabeblack@google.com BadDevice::Params *p = new BadDevice::Params; 9013054Sgabeblack@google.com p->name =getInstanceName(); 9113054Sgabeblack@google.com p->platform = platform; 9213054Sgabeblack@google.com p->pio_addr = pio_addr; 9313054Sgabeblack@google.com p->pio_delay = pio_latency; 9413054Sgabeblack@google.com p->system = system; 9513054Sgabeblack@google.com p->device_name = devicename; 9613054Sgabeblack@google.com return new BadDevice(p); 9713054Sgabeblack@google.com} 9812841Sgabeblack@google.com 9912841Sgabeblack@google.comREGISTER_SIM_OBJECT("BadDevice", BadDevice) 10013054Sgabeblack@google.com