device.hh revision 845
16019SN/A/*
26019SN/A * Copyright (c) 2003 The Regents of The University of Michigan
37134Sgblack@eecs.umich.edu * All rights reserved.
47134Sgblack@eecs.umich.edu *
57134Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67134Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77134Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87134Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97134Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107134Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117134Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127134Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137134Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
147134Sgblack@eecs.umich.edu * this software without specific prior written permission.
156019SN/A *
166019SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176019SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186019SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196019SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206019SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216019SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226019SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236019SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246019SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256019SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266019SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276019SN/A */
286019SN/A
296019SN/A/* @file
306019SN/A * Interface for devices using PCI configuration
316019SN/A */
326019SN/A
336019SN/A#ifndef __PCI_DEV_HH__
346019SN/A#define __PCI_DEV_HH__
356019SN/A
366019SN/A#include "dev/pcireg.h"
376019SN/A#include "dev/io_device.hh"
386019SN/A
396019SN/Aclass PciConfigAll;
406019SN/Aclass MemoryController;
416019SN/A
426308SN/Aclass PciConfigData : public SimObject
436308SN/A{
446309SN/A  public:
456309SN/A    PciConfigData(const std::string &name)
466309SN/A        : SimObject(name)
476309SN/A    {
486309SN/A        memset(config.data, 0, sizeof(config.data));
497134Sgblack@eecs.umich.edu        memset(BARAddrs, 0, sizeof(BARAddrs));
507296Sgblack@eecs.umich.edu        memset(BARSize, 0, sizeof(BARSize));
516309SN/A    }
526309SN/A
537296Sgblack@eecs.umich.edu    PCIConfig config;
547134Sgblack@eecs.umich.edu    uint32_t BARSize[6];
556309SN/A    Addr BARAddrs[6];
566309SN/A};
576309SN/A
587342Sgblack@eecs.umich.edu/**
597174Sgblack@eecs.umich.edu * PCI device, base implemnation is only config space.
607639Sgblack@eecs.umich.edu * Each device is connected to a PCIConfigSpace device
617639Sgblack@eecs.umich.edu * which returns -1 for everything but the pcidevs that
627644Sali.saidi@arm.com * register with it. This object registers with the PCIConfig space
637639Sgblack@eecs.umich.edu * object.
647639Sgblack@eecs.umich.edu */
657639Sgblack@eecs.umich.educlass PciDev : public DmaDevice
667639Sgblack@eecs.umich.edu{
677639Sgblack@eecs.umich.edu  protected:
687639Sgblack@eecs.umich.edu    MemoryController *MMU;
697639Sgblack@eecs.umich.edu    PciConfigAll *ConfigSpace;
707639Sgblack@eecs.umich.edu    PciConfigData *ConfigData;
717644Sali.saidi@arm.com    uint32_t BusNum;
727639Sgblack@eecs.umich.edu    uint32_t DeviceNum;
737639Sgblack@eecs.umich.edu    uint32_t FunctionNum;
747639Sgblack@eecs.umich.edu
757639Sgblack@eecs.umich.edu    PCIConfig config;
767639Sgblack@eecs.umich.edu    uint32_t BARSize[6];
777639Sgblack@eecs.umich.edu    Addr BARAddrs[6];
787639Sgblack@eecs.umich.edu
797639Sgblack@eecs.umich.edu  public:
807639Sgblack@eecs.umich.edu    PciDev(const std::string &name, MemoryController *mmu, PciConfigAll *cf,
817639Sgblack@eecs.umich.edu           PciConfigData *cd, uint32_t bus, uint32_t dev, uint32_t func);
827644Sali.saidi@arm.com
837639Sgblack@eecs.umich.edu    virtual Fault read(MemReqPtr &req, uint8_t *data) {
847639Sgblack@eecs.umich.edu        return No_Fault;
857639Sgblack@eecs.umich.edu    }
867639Sgblack@eecs.umich.edu    virtual Fault write(MemReqPtr &req, const uint8_t *data) {
877639Sgblack@eecs.umich.edu        return No_Fault;
887174Sgblack@eecs.umich.edu    }
896754SN/A
907296Sgblack@eecs.umich.edu    virtual void WriteConfig(int offset, int size, uint32_t data);
917400SAli.Saidi@ARM.com    virtual void ReadConfig(int offset, int size, uint8_t *data);
927134Sgblack@eecs.umich.edu
937400SAli.Saidi@ARM.com    virtual void serialize(std::ostream &os);
947134Sgblack@eecs.umich.edu    virtual void unserialize(Checkpoint *cp, const std::string &section);
957134Sgblack@eecs.umich.edu};
967296Sgblack@eecs.umich.edu
976754SN/A#endif // __PCI_DEV_HH__
986754SN/A