baddev.cc revision 2539
112838Sgabeblack@google.com/*
212838Sgabeblack@google.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
312838Sgabeblack@google.com * All rights reserved.
412838Sgabeblack@google.com *
512838Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
612838Sgabeblack@google.com * modification, are permitted provided that the following conditions are
712838Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
812838Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
912838Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1012838Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1112838Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1212838Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1312838Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1412838Sgabeblack@google.com * this software without specific prior written permission.
1512838Sgabeblack@google.com *
1612838Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712838Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812838Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912838Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012838Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112838Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212838Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312838Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412838Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512838Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612838Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712838Sgabeblack@google.com */
2812838Sgabeblack@google.com
2912838Sgabeblack@google.com/** @file
3012838Sgabeblack@google.com * BadDevice implemenation
3112838Sgabeblack@google.com */
3212838Sgabeblack@google.com
3312838Sgabeblack@google.com#include <deque>
3412838Sgabeblack@google.com#include <string>
3512838Sgabeblack@google.com#include <vector>
3612852Sgabeblack@google.com
3712852Sgabeblack@google.com#include "base/trace.hh"
3812852Sgabeblack@google.com#include "cpu/exec_context.hh"
3912852Sgabeblack@google.com#include "dev/baddev.hh"
4012852Sgabeblack@google.com#include "dev/platform.hh"
4112852Sgabeblack@google.com#include "mem/bus/bus.hh"
4212852Sgabeblack@google.com#include "mem/bus/pio_interface.hh"
4312838Sgabeblack@google.com#include "mem/bus/pio_interface_impl.hh"
4412838Sgabeblack@google.com#include "mem/functional/memory_control.hh"
4512838Sgabeblack@google.com#include "sim/builder.hh"
4612838Sgabeblack@google.com#include "sim/system.hh"
4712838Sgabeblack@google.com
4812838Sgabeblack@google.comusing namespace std;
4912838Sgabeblack@google.comusing namespace TheISA;
5012838Sgabeblack@google.com
5112838Sgabeblack@google.comBadDevice::BadDevice(Params *p)
5212838Sgabeblack@google.com    : BasicPioDevice(p), devname(p->devic_ename)
5312838Sgabeblack@google.com{
5412838Sgabeblack@google.com    pioSize = 0xf;
5512838Sgabeblack@google.com}
5612838Sgabeblack@google.com
5712838Sgabeblack@google.comTick
5812838Sgabeblack@google.comBadDevice::read(Packet &pkt)
5912838Sgabeblack@google.com{
6012838Sgabeblack@google.com    panic("Device %s not imlpmented\n", devname);
6112838Sgabeblack@google.com}
6212838Sgabeblack@google.com
6312838Sgabeblack@google.comTick
6412838Sgabeblack@google.comBadDevice::write(Packet &pkt)
6512838Sgabeblack@google.com{
6612838Sgabeblack@google.com    panic("Device %s not imlpmented\n", devname);
6712838Sgabeblack@google.com}
6812838Sgabeblack@google.com
6912838Sgabeblack@google.comBEGIN_DECLARE_SIM_OBJECT_PARAMS(BadDevice)
7012838Sgabeblack@google.com
7112838Sgabeblack@google.com    Param<string> devicename;
7212838Sgabeblack@google.com    Param<Addr> pio_addr;
7312838Sgabeblack@google.com    SimObjectParam<AlphaSystem *> system;
7412838Sgabeblack@google.com    SimObjectParam<Platform *> platform;
7512838Sgabeblack@google.com    Param<Tick> pio_latency;
7612838Sgabeblack@google.com
7712852Sgabeblack@google.comEND_DECLARE_SIM_OBJECT_PARAMS(BadDevice)
7812852Sgabeblack@google.com
7912852Sgabeblack@google.comBEGIN_INIT_SIM_OBJECT_PARAMS(BadDevice)
8012838Sgabeblack@google.com
8112838Sgabeblack@google.com    INIT_PARAM(devicename, "Name of device to error on"),
8212838Sgabeblack@google.com    INIT_PARAM(pio_addr, "Device Address"),
8312838Sgabeblack@google.com    INIT_PARAM(system, "system object"),
8412838Sgabeblack@google.com    INIT_PARAM(platform, "platform"),
8512838Sgabeblack@google.com    INIT_PARAM_DFLT(pio_latency, "Programmed IO latency", 1000)
8612852Sgabeblack@google.com
8712852Sgabeblack@google.comEND_INIT_SIM_OBJECT_PARAMS(BadDevice)
8812852Sgabeblack@google.com
8912852Sgabeblack@google.comCREATE_SIM_OBJECT(BadDevice)
9012852Sgabeblack@google.com{
9112852Sgabeblack@google.com    BadDevice::Params *p = new BadDevice::Params;
9212852Sgabeblack@google.com    p->name =getInstanceName();
9312852Sgabeblack@google.com    p->platform = platform;
9412852Sgabeblack@google.com    p->pio_addr = pio_addr;
9512852Sgabeblack@google.com    p->pio_delay = pio_latency;
9612852Sgabeblack@google.com    p->system = system;
9712838Sgabeblack@google.com    p->devicename = devicename;
9812838Sgabeblack@google.com    return new BadDevice(p);
9912838Sgabeblack@google.com}
10012838Sgabeblack@google.com
10112838Sgabeblack@google.comREGISTER_SIM_OBJECT("BadDevice", BadDevice)
10212838Sgabeblack@google.com