pci.hh revision 10388
14202Sbinkertn@umich.edu/*
24202Sbinkertn@umich.edu * Copyright (c) 2014 ARM Limited
34202Sbinkertn@umich.edu * All rights reserved
44202Sbinkertn@umich.edu *
54202Sbinkertn@umich.edu * The license below extends only to copyright in the software and shall
64202Sbinkertn@umich.edu * not be construed as granting a license to any other intellectual
74202Sbinkertn@umich.edu * property including but not limited to intellectual property relating
84202Sbinkertn@umich.edu * to a hardware implementation of the functionality of the software
94202Sbinkertn@umich.edu * licensed hereunder.  You may use the software subject to the license
104202Sbinkertn@umich.edu * terms below provided that you ensure that this notice is replicated
114202Sbinkertn@umich.edu * unmodified and in its entirety in all distributions of the software,
124202Sbinkertn@umich.edu * modified or unmodified, in source code or in binary form.
134202Sbinkertn@umich.edu *
144202Sbinkertn@umich.edu * Redistribution and use in source and binary forms, with or without
154202Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are
164202Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright
174202Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer;
184202Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright
194202Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer in the
204202Sbinkertn@umich.edu * documentation and/or other materials provided with the distribution;
214202Sbinkertn@umich.edu * neither the name of the copyright holders nor the names of its
224202Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from
234202Sbinkertn@umich.edu * this software without specific prior written permission.
244202Sbinkertn@umich.edu *
254202Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
264202Sbinkertn@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
274202Sbinkertn@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
284202Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
294202Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
304202Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
314202Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
324202Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
334486Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
344486Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
354202Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
364202Sbinkertn@umich.edu *
374202Sbinkertn@umich.edu * Authors: Andreas Sandberg
385192Ssaidi@eecs.umich.edu */
395192Ssaidi@eecs.umich.edu
405192Ssaidi@eecs.umich.edu#ifndef __DEV_VIRTIO_PCI_HH__
415192Ssaidi@eecs.umich.edu#define __DEV_VIRTIO_PCI_HH__
425192Ssaidi@eecs.umich.edu
43#include "base/statistics.hh"
44#include "dev/virtio/base.hh"
45#include "dev/pcidev.hh"
46
47struct PciVirtIOParams;
48
49class PciVirtIO : public PciDevice
50{
51  public:
52    typedef PciVirtIOParams Params;
53    PciVirtIO(const Params *params);
54    virtual ~PciVirtIO();
55
56    Tick read(PacketPtr pkt);
57    Tick write(PacketPtr pkt);
58
59    void kick();
60
61  protected:
62    /** @{ */
63    /** Offsets into VirtIO header (BAR0 relative). */
64
65    static const Addr OFF_DEVICE_FEATURES = 0x00;
66    static const Addr OFF_GUEST_FEATURES = 0x04;
67    static const Addr OFF_QUEUE_ADDRESS = 0x08;
68    static const Addr OFF_QUEUE_SIZE = 0x0C;
69    static const Addr OFF_QUEUE_SELECT = 0x0E;
70    static const Addr OFF_QUEUE_NOTIFY = 0x10;
71    static const Addr OFF_DEVICE_STATUS = 0x12;
72    static const Addr OFF_ISR_STATUS = 0x13;
73    static const Addr OFF_VIO_DEVICE = 0x14;
74
75    /** @} */
76
77    static const Addr BAR0_SIZE_BASE = OFF_VIO_DEVICE;
78
79
80    VirtIODeviceBase::QueueID queueNotify;
81
82    bool interruptDeliveryPending;
83
84    VirtIODeviceBase &vio;
85
86    MakeCallback<PciVirtIO, &PciVirtIO::kick> callbackKick;
87};
88
89#endif // __DEV_VIRTIO_PCI_HH__
90