device.hh revision 793
15124Sgblack@eecs.umich.edu/* 25124Sgblack@eecs.umich.edu * Copyright (c) 2003 The Regents of The University of Michigan 35124Sgblack@eecs.umich.edu * All rights reserved. 45124Sgblack@eecs.umich.edu * 55124Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 65124Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 75124Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 85124Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 95124Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 105124Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 115124Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 125124Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 135124Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 145124Sgblack@eecs.umich.edu * this software without specific prior written permission. 155124Sgblack@eecs.umich.edu * 165124Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175124Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185124Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195124Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205124Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215124Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225124Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235124Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245124Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255124Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265124Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275124Sgblack@eecs.umich.edu */ 285124Sgblack@eecs.umich.edu 295124Sgblack@eecs.umich.edu/* @file 305124Sgblack@eecs.umich.edu * PCI configspace devices 315124Sgblack@eecs.umich.edu */ 325124Sgblack@eecs.umich.edu 335124Sgblack@eecs.umich.edu#ifndef __PCI_DEV_HH__ 345124Sgblack@eecs.umich.edu#define __PCI_DEV_HH__ 355124Sgblack@eecs.umich.edu 365124Sgblack@eecs.umich.edu#include "mem/functional_mem/mmap_device.hh" 375124Sgblack@eecs.umich.edu#include "dev/pcireg.h" 385124Sgblack@eecs.umich.educlass PCIConfigAll; 395124Sgblack@eecs.umich.edu 405124Sgblack@eecs.umich.edu/* 415124Sgblack@eecs.umich.edu * PCI device configuration device. 425124Sgblack@eecs.umich.edu * Each device is connected to a PCIConfigSpace device 435124Sgblack@eecs.umich.edu * which returns -1 for everything but the pcidevs that 445124Sgblack@eecs.umich.edu * register with it. This object registers with the PCIConfig space 455124Sgblack@eecs.umich.edu * object. 465124Sgblack@eecs.umich.edu */ 475124Sgblack@eecs.umich.educlass PciDev : public MMapDevice 485124Sgblack@eecs.umich.edu{ 495124Sgblack@eecs.umich.edu private: 505124Sgblack@eecs.umich.edu uint32_t Bus; 515124Sgblack@eecs.umich.edu uint32_t Device; 525124Sgblack@eecs.umich.edu uint32_t Function; 535124Sgblack@eecs.umich.edu public: 545124Sgblack@eecs.umich.edu PciDev(const std::string &name, PCIConfigAll *cf, uint32_t bus, 555124Sgblack@eecs.umich.edu uint32_t dev, uint32_t func); 565124Sgblack@eecs.umich.edu 575124Sgblack@eecs.umich.edu PCIConfigAll *ConfigSpace; 585124Sgblack@eecs.umich.edu PCIConfig config; 595124Sgblack@eecs.umich.edu uint32_t BARSize[6]; 605124Sgblack@eecs.umich.edu 615124Sgblack@eecs.umich.edu virtual void WriteConfig(int offset, int size, uint32_t data); 625124Sgblack@eecs.umich.edu virtual void ReadConfig(int offset, int size, uint8_t *data); 635124Sgblack@eecs.umich.edu 645124Sgblack@eecs.umich.edu 655124Sgblack@eecs.umich.edu virtual void serialize(std::ostream &os); 665124Sgblack@eecs.umich.edu virtual void unserialize(Checkpoint *cp, const std::string §ion); 675124Sgblack@eecs.umich.edu}; 685124Sgblack@eecs.umich.edu 695124Sgblack@eecs.umich.edu#endif // __PCI_DEV_HH__ 705124Sgblack@eecs.umich.edu