baddev.cc revision 3349
14202Sbinkertn@umich.edu/*
24202Sbinkertn@umich.edu * Copyright (c) 2004-2005 The Regents of The University of Michigan
34202Sbinkertn@umich.edu * All rights reserved.
44202Sbinkertn@umich.edu *
54202Sbinkertn@umich.edu * Redistribution and use in source and binary forms, with or without
64202Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are
74202Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright
84202Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer;
94202Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright
104202Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer in the
114202Sbinkertn@umich.edu * documentation and/or other materials provided with the distribution;
124202Sbinkertn@umich.edu * neither the name of the copyright holders nor the names of its
134202Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from
144202Sbinkertn@umich.edu * this software without specific prior written permission.
154202Sbinkertn@umich.edu *
164202Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174202Sbinkertn@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184202Sbinkertn@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194202Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204202Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214202Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224202Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234202Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244202Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254202Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264202Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274202Sbinkertn@umich.edu *
284202Sbinkertn@umich.edu * Authors: Ali Saidi
294202Sbinkertn@umich.edu */
304202Sbinkertn@umich.edu
314202Sbinkertn@umich.edu/** @file
324202Sbinkertn@umich.edu * BadDevice implemenation
334486Sbinkertn@umich.edu */
344486Sbinkertn@umich.edu
354776Sgblack@eecs.umich.edu#include <deque>
364486Sbinkertn@umich.edu#include <string>
374202Sbinkertn@umich.edu#include <vector>
384202Sbinkertn@umich.edu
394202Sbinkertn@umich.edu#include "base/trace.hh"
404202Sbinkertn@umich.edu#include "dev/baddev.hh"
414202Sbinkertn@umich.edu#include "dev/platform.hh"
424202Sbinkertn@umich.edu#include "mem/port.hh"
434202Sbinkertn@umich.edu#include "sim/builder.hh"
444202Sbinkertn@umich.edu#include "sim/system.hh"
454202Sbinkertn@umich.edu
464202Sbinkertn@umich.eduusing namespace std;
474202Sbinkertn@umich.eduusing namespace TheISA;
484202Sbinkertn@umich.edu
494202Sbinkertn@umich.eduBadDevice::BadDevice(Params *p)
504202Sbinkertn@umich.edu    : BasicPioDevice(p), devname(p->device_name)
514202Sbinkertn@umich.edu{
524202Sbinkertn@umich.edu    pioSize = 0xf;
534826Ssaidi@eecs.umich.edu}
544202Sbinkertn@umich.edu
554202Sbinkertn@umich.eduTick
564486Sbinkertn@umich.eduBadDevice::read(PacketPtr pkt)
574486Sbinkertn@umich.edu{
584202Sbinkertn@umich.edu    panic("Device %s not imlpmented\n", devname);
594202Sbinkertn@umich.edu}
60
61Tick
62BadDevice::write(PacketPtr pkt)
63{
64    panic("Device %s not imlpmented\n", devname);
65}
66
67BEGIN_DECLARE_SIM_OBJECT_PARAMS(BadDevice)
68
69    Param<string> devicename;
70    Param<Addr> pio_addr;
71    SimObjectParam<System *> system;
72    SimObjectParam<Platform *> platform;
73    Param<Tick> pio_latency;
74
75END_DECLARE_SIM_OBJECT_PARAMS(BadDevice)
76
77BEGIN_INIT_SIM_OBJECT_PARAMS(BadDevice)
78
79    INIT_PARAM(devicename, "Name of device to error on"),
80    INIT_PARAM(pio_addr, "Device Address"),
81    INIT_PARAM(system, "system object"),
82    INIT_PARAM(platform, "platform"),
83    INIT_PARAM_DFLT(pio_latency, "Programmed IO latency", 1000)
84
85END_INIT_SIM_OBJECT_PARAMS(BadDevice)
86
87CREATE_SIM_OBJECT(BadDevice)
88{
89    BadDevice::Params *p = new BadDevice::Params;
90    p->name =getInstanceName();
91    p->platform = platform;
92    p->pio_addr = pio_addr;
93    p->pio_delay = pio_latency;
94    p->system = system;
95    p->device_name = devicename;
96    return new BadDevice(p);
97}
98
99REGISTER_SIM_OBJECT("BadDevice", BadDevice)
100