baddev.hh revision 1722
15818Sgblack@eecs.umich.edu/*
25818Sgblack@eecs.umich.edu * Copyright (c) 2004 The Regents of The University of Michigan
35818Sgblack@eecs.umich.edu * All rights reserved.
45818Sgblack@eecs.umich.edu *
55818Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
65818Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
75818Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
85818Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
95818Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
105818Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
115818Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
125818Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
135818Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
145818Sgblack@eecs.umich.edu * this software without specific prior written permission.
155818Sgblack@eecs.umich.edu *
165818Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175818Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185818Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195818Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205818Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215818Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225818Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235818Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245818Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255818Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265818Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275818Sgblack@eecs.umich.edu */
285818Sgblack@eecs.umich.edu
295818Sgblack@eecs.umich.edu/** @file
305818Sgblack@eecs.umich.edu * This devices just panics when touched. For example if you have a
315818Sgblack@eecs.umich.edu * kernel that touches the frame buffer which isn't allowed.
325818Sgblack@eecs.umich.edu */
335818Sgblack@eecs.umich.edu
345818Sgblack@eecs.umich.edu#ifndef __DEV_BADDEV_HH__
355818Sgblack@eecs.umich.edu#define __DEV_BADDEV_HH__
365818Sgblack@eecs.umich.edu
375818Sgblack@eecs.umich.edu#include "base/range.hh"
385818Sgblack@eecs.umich.edu#include "dev/io_device.hh"
395818Sgblack@eecs.umich.edu
405818Sgblack@eecs.umich.edu/**
415818Sgblack@eecs.umich.edu * BadDevice
425818Sgblack@eecs.umich.edu * This device just panics when accessed. It is supposed to warn
435818Sgblack@eecs.umich.edu * the user that the kernel they are running has unsupported
445818Sgblack@eecs.umich.edu * options (i.e. frame buffer)
455818Sgblack@eecs.umich.edu */
465818Sgblack@eecs.umich.educlass BadDevice : public PioDevice
475818Sgblack@eecs.umich.edu{
485818Sgblack@eecs.umich.edu  private:
495818Sgblack@eecs.umich.edu    Addr addr;
505818Sgblack@eecs.umich.edu    static const Addr size = 0xf;
515818Sgblack@eecs.umich.edu
525818Sgblack@eecs.umich.edu    std::string devname;
535818Sgblack@eecs.umich.edu
545818Sgblack@eecs.umich.edu  public:
555818Sgblack@eecs.umich.edu     /**
565818Sgblack@eecs.umich.edu      * Constructor for the Baddev Class.
575818Sgblack@eecs.umich.edu      * @param name name of the object
585818Sgblack@eecs.umich.edu      * @param a base address of the write
595818Sgblack@eecs.umich.edu      * @param mmu the memory controller
605818Sgblack@eecs.umich.edu      * @param hier object to store parameters universal the device hierarchy
615818Sgblack@eecs.umich.edu      * @param bus The bus that this device is attached to
625818Sgblack@eecs.umich.edu      * @param devicename device that is not implemented
635818Sgblack@eecs.umich.edu      */
645818Sgblack@eecs.umich.edu    BadDevice(const std::string &name, Addr a, MemoryController *mmu,
655818Sgblack@eecs.umich.edu              HierParams *hier, Bus *bus, const std::string &devicename);
665818Sgblack@eecs.umich.edu
67    /**
68      * On a read event we just panic aand hopefully print a
69      * meaningful error message.
70      * @param req Contains the address to read from.
71      * @param data A pointer to write the read data to.
72      * @return The fault condition of the access.
73      */
74    virtual Fault read(MemReqPtr &req, uint8_t *data);
75
76    /**
77      * On a write event we just panic aand hopefully print a
78      * meaningful error message.
79      * @param req Contains the address to write to.
80      * @param data The data to write.
81      * @return The fault condition of the access.
82      */
83    virtual Fault write(MemReqPtr &req, const uint8_t *data);
84
85    /**
86     * Return how long this access will take.
87     * @param req the memory request to calcuate
88     * @return Tick when the request is done
89     */
90    Tick cacheAccess(MemReqPtr &req);
91};
92
93#endif // __DEV_BADDEV_HH__
94