pci.hh revision 11260
110388SAndreas.Sandberg@ARM.com/* 210388SAndreas.Sandberg@ARM.com * Copyright (c) 2014 ARM Limited 310388SAndreas.Sandberg@ARM.com * All rights reserved 410388SAndreas.Sandberg@ARM.com * 510388SAndreas.Sandberg@ARM.com * The license below extends only to copyright in the software and shall 610388SAndreas.Sandberg@ARM.com * not be construed as granting a license to any other intellectual 710388SAndreas.Sandberg@ARM.com * property including but not limited to intellectual property relating 810388SAndreas.Sandberg@ARM.com * to a hardware implementation of the functionality of the software 910388SAndreas.Sandberg@ARM.com * licensed hereunder. You may use the software subject to the license 1010388SAndreas.Sandberg@ARM.com * terms below provided that you ensure that this notice is replicated 1110388SAndreas.Sandberg@ARM.com * unmodified and in its entirety in all distributions of the software, 1210388SAndreas.Sandberg@ARM.com * modified or unmodified, in source code or in binary form. 1310388SAndreas.Sandberg@ARM.com * 1410388SAndreas.Sandberg@ARM.com * Redistribution and use in source and binary forms, with or without 1510388SAndreas.Sandberg@ARM.com * modification, are permitted provided that the following conditions are 1610388SAndreas.Sandberg@ARM.com * met: redistributions of source code must retain the above copyright 1710388SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer; 1810388SAndreas.Sandberg@ARM.com * redistributions in binary form must reproduce the above copyright 1910388SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer in the 2010388SAndreas.Sandberg@ARM.com * documentation and/or other materials provided with the distribution; 2110388SAndreas.Sandberg@ARM.com * neither the name of the copyright holders nor the names of its 2210388SAndreas.Sandberg@ARM.com * contributors may be used to endorse or promote products derived from 2310388SAndreas.Sandberg@ARM.com * this software without specific prior written permission. 2410388SAndreas.Sandberg@ARM.com * 2510388SAndreas.Sandberg@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2610388SAndreas.Sandberg@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2710388SAndreas.Sandberg@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2810388SAndreas.Sandberg@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2910388SAndreas.Sandberg@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3010388SAndreas.Sandberg@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3110388SAndreas.Sandberg@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3210388SAndreas.Sandberg@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3310388SAndreas.Sandberg@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3410388SAndreas.Sandberg@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3510388SAndreas.Sandberg@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3610388SAndreas.Sandberg@ARM.com * 3710388SAndreas.Sandberg@ARM.com * Authors: Andreas Sandberg 3810388SAndreas.Sandberg@ARM.com */ 3910388SAndreas.Sandberg@ARM.com 4010388SAndreas.Sandberg@ARM.com#ifndef __DEV_VIRTIO_PCI_HH__ 4110388SAndreas.Sandberg@ARM.com#define __DEV_VIRTIO_PCI_HH__ 4210388SAndreas.Sandberg@ARM.com 4310388SAndreas.Sandberg@ARM.com#include "base/statistics.hh" 4410388SAndreas.Sandberg@ARM.com#include "dev/virtio/base.hh" 4511260Sandreas.sandberg@arm.com#include "dev/pci/device.hh" 4610388SAndreas.Sandberg@ARM.com 4710388SAndreas.Sandberg@ARM.comstruct PciVirtIOParams; 4810388SAndreas.Sandberg@ARM.com 4910388SAndreas.Sandberg@ARM.comclass PciVirtIO : public PciDevice 5010388SAndreas.Sandberg@ARM.com{ 5110388SAndreas.Sandberg@ARM.com public: 5210388SAndreas.Sandberg@ARM.com typedef PciVirtIOParams Params; 5310388SAndreas.Sandberg@ARM.com PciVirtIO(const Params *params); 5410388SAndreas.Sandberg@ARM.com virtual ~PciVirtIO(); 5510388SAndreas.Sandberg@ARM.com 5610388SAndreas.Sandberg@ARM.com Tick read(PacketPtr pkt); 5710388SAndreas.Sandberg@ARM.com Tick write(PacketPtr pkt); 5810388SAndreas.Sandberg@ARM.com 5910388SAndreas.Sandberg@ARM.com void kick(); 6010388SAndreas.Sandberg@ARM.com 6110388SAndreas.Sandberg@ARM.com protected: 6210388SAndreas.Sandberg@ARM.com /** @{ */ 6310388SAndreas.Sandberg@ARM.com /** Offsets into VirtIO header (BAR0 relative). */ 6410388SAndreas.Sandberg@ARM.com 6510388SAndreas.Sandberg@ARM.com static const Addr OFF_DEVICE_FEATURES = 0x00; 6610388SAndreas.Sandberg@ARM.com static const Addr OFF_GUEST_FEATURES = 0x04; 6710388SAndreas.Sandberg@ARM.com static const Addr OFF_QUEUE_ADDRESS = 0x08; 6810388SAndreas.Sandberg@ARM.com static const Addr OFF_QUEUE_SIZE = 0x0C; 6910388SAndreas.Sandberg@ARM.com static const Addr OFF_QUEUE_SELECT = 0x0E; 7010388SAndreas.Sandberg@ARM.com static const Addr OFF_QUEUE_NOTIFY = 0x10; 7110388SAndreas.Sandberg@ARM.com static const Addr OFF_DEVICE_STATUS = 0x12; 7210388SAndreas.Sandberg@ARM.com static const Addr OFF_ISR_STATUS = 0x13; 7310388SAndreas.Sandberg@ARM.com static const Addr OFF_VIO_DEVICE = 0x14; 7410388SAndreas.Sandberg@ARM.com 7510388SAndreas.Sandberg@ARM.com /** @} */ 7610388SAndreas.Sandberg@ARM.com 7710388SAndreas.Sandberg@ARM.com static const Addr BAR0_SIZE_BASE = OFF_VIO_DEVICE; 7810388SAndreas.Sandberg@ARM.com 7910388SAndreas.Sandberg@ARM.com 8010388SAndreas.Sandberg@ARM.com VirtIODeviceBase::QueueID queueNotify; 8110388SAndreas.Sandberg@ARM.com 8210388SAndreas.Sandberg@ARM.com bool interruptDeliveryPending; 8310388SAndreas.Sandberg@ARM.com 8410388SAndreas.Sandberg@ARM.com VirtIODeviceBase &vio; 8510388SAndreas.Sandberg@ARM.com 8610388SAndreas.Sandberg@ARM.com MakeCallback<PciVirtIO, &PciVirtIO::kick> callbackKick; 8710388SAndreas.Sandberg@ARM.com}; 8810388SAndreas.Sandberg@ARM.com 8910388SAndreas.Sandberg@ARM.com#endif // __DEV_VIRTIO_PCI_HH__ 90