mirror of https://gitee.com/openkylin/qemu.git
pc,virtio,pci: fixes and updates
Most notably, this includes the TCO support for ICH: the last feature for 2.4 as we are entering the hard freeze. Bugfixes only from now on. virtio pci also gained cfg access capability - arguably a bugfix since virtio spec makes it mandatory, but it's a big patch. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJVnO/3AAoJECgfDbjSjVRp6lAH/2RAlzoopHDNMCj5r3wHygnA WD1rjugftcQNJ5HkL1Oe9heQnjUcx4jdaskrTyP8vElY1zheGPYYqtPYjMB3Kfsu fIQUhjhU6lKjF+0Q9QeyOyz9uvHWgTwtiQsHdFj+fsw7qMpiiADgGmlXoin01ZF9 yGaGZ5GcLNEHXGWyzEpKOml1UxtMFZRe649KV1tqLBoOSLdw+c3SzrGvKYjUtGnG luMHPAJcKS7khSTyCVJN8un6SjbC/aB22mlh7TgxeNBANsGJVCH09lLCmczkIKAJ 73sut/+2f2aS9qGaSJiI5ElENDhSlWlSjNG/x4dp07fvurxpojde+bYS9veSo3c= =cQ0D -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging pc,virtio,pci: fixes and updates Most notably, this includes the TCO support for ICH: the last feature for 2.4 as we are entering the hard freeze. Bugfixes only from now on. virtio pci also gained cfg access capability - arguably a bugfix since virtio spec makes it mandatory, but it's a big patch. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Wed Jul 8 10:40:07 2015 BST using RSA key ID D28D5469 # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" * remotes/mst/tags/for_upstream: tco-test: fix up config accesses and re-enable virtio fix cfg endian-ness for BE targets virtio-pci: implement cfg capability virtio: define virtio_pci_cfg_cap in header. pcie: Set the "link active" in the link status register pci_regs.h: import from linux virtio_net: reuse constants from linux hw/i386/pc: don't carry FDC from pc_basic_device_init() to pc_cmos_init() hw/i386/pc: reflect any FDC @ ioport 0x3f0 in the CMOS hw/i386/pc: factor out pc_cmos_init_floppy() ich9: implement strap SPKR pin logic tests: add testcase for TCO watchdog emulation ich9: add TCO interface emulation acpi: split out ICH ACPI support Revert "dataplane: allow virtio-1 devices" dataplane: fix cross-endian issues Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
c8232b39bb
|
@ -16,6 +16,7 @@ CONFIG_PCKBD=y
|
|||
CONFIG_FDC=y
|
||||
CONFIG_ACPI=y
|
||||
CONFIG_ACPI_X86=y
|
||||
CONFIG_ACPI_X86_ICH=y
|
||||
CONFIG_ACPI_MEMORY_HOTPLUG=y
|
||||
CONFIG_ACPI_CPU_HOTPLUG=y
|
||||
CONFIG_APM=y
|
||||
|
|
|
@ -17,6 +17,7 @@ CONFIG_PCKBD=y
|
|||
CONFIG_FDC=y
|
||||
CONFIG_ACPI=y
|
||||
CONFIG_ACPI_X86=y
|
||||
CONFIG_ACPI_X86_ICH=y
|
||||
CONFIG_ACPI_MEMORY_HOTPLUG=y
|
||||
CONFIG_ACPI_CPU_HOTPLUG=y
|
||||
CONFIG_APM=y
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o ich9.o pcihp.o
|
||||
common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
|
||||
common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
|
||||
common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
|
||||
common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
|
||||
common-obj-$(CONFIG_ACPI) += acpi_interface.o
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "qemu/timer.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "hw/acpi/acpi.h"
|
||||
#include "hw/acpi/tco.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "exec/address-spaces.h"
|
||||
|
||||
|
@ -92,8 +93,16 @@ static void ich9_smi_writel(void *opaque, hwaddr addr, uint64_t val,
|
|||
unsigned width)
|
||||
{
|
||||
ICH9LPCPMRegs *pm = opaque;
|
||||
TCOIORegs *tr = &pm->tco_regs;
|
||||
uint64_t tco_en;
|
||||
|
||||
switch (addr) {
|
||||
case 0:
|
||||
tco_en = pm->smi_en & ICH9_PMIO_SMI_EN_TCO_EN;
|
||||
/* once TCO_LOCK bit is set, TCO_EN bit cannot be overwritten */
|
||||
if (tr->tco.cnt1 & TCO_LOCK) {
|
||||
val = (val & ~ICH9_PMIO_SMI_EN_TCO_EN) | tco_en;
|
||||
}
|
||||
pm->smi_en &= ~pm->smi_en_wmask;
|
||||
pm->smi_en |= (val & pm->smi_en_wmask);
|
||||
break;
|
||||
|
@ -159,6 +168,25 @@ static const VMStateDescription vmstate_memhp_state = {
|
|||
}
|
||||
};
|
||||
|
||||
static bool vmstate_test_use_tco(void *opaque)
|
||||
{
|
||||
ICH9LPCPMRegs *s = opaque;
|
||||
return s->enable_tco;
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_tco_io_state = {
|
||||
.name = "ich9_pm/tco",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.minimum_version_id_old = 1,
|
||||
.needed = vmstate_test_use_tco,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_STRUCT(tco_regs, ICH9LPCPMRegs, 1, vmstate_tco_io_sts,
|
||||
TCOIORegs),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
const VMStateDescription vmstate_ich9_pm = {
|
||||
.name = "ich9_pm",
|
||||
.version_id = 1,
|
||||
|
@ -179,6 +207,10 @@ const VMStateDescription vmstate_ich9_pm = {
|
|||
.subsections = (const VMStateDescription*[]) {
|
||||
&vmstate_memhp_state,
|
||||
NULL
|
||||
},
|
||||
.subsections = (const VMStateDescription*[]) {
|
||||
&vmstate_tco_io_state,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -209,7 +241,8 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
|
|||
acpi_pm1_evt_power_down(&pm->acpi_regs);
|
||||
}
|
||||
|
||||
void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, bool smm_enabled,
|
||||
void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
|
||||
bool smm_enabled, bool enable_tco,
|
||||
qemu_irq sci_irq)
|
||||
{
|
||||
memory_region_init(&pm->io, OBJECT(lpc_pci), "ich9-pm", ICH9_PMIO_SIZE);
|
||||
|
@ -232,6 +265,12 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, bool smm_enabled,
|
|||
memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi);
|
||||
|
||||
pm->smm_enabled = smm_enabled;
|
||||
|
||||
pm->enable_tco = enable_tco;
|
||||
if (pm->enable_tco) {
|
||||
acpi_pm_tco_init(&pm->tco_regs, &pm->io);
|
||||
}
|
||||
|
||||
pm->irq = sci_irq;
|
||||
qemu_register_reset(pm_reset, pm);
|
||||
pm->powerdown_notifier.notify = pm_powerdown_req;
|
||||
|
@ -352,6 +391,18 @@ out:
|
|||
error_propagate(errp, local_err);
|
||||
}
|
||||
|
||||
static bool ich9_pm_get_enable_tco(Object *obj, Error **errp)
|
||||
{
|
||||
ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
|
||||
return s->pm.enable_tco;
|
||||
}
|
||||
|
||||
static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp)
|
||||
{
|
||||
ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
|
||||
s->pm.enable_tco = value;
|
||||
}
|
||||
|
||||
void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp)
|
||||
{
|
||||
static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
|
||||
|
@ -383,6 +434,10 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp)
|
|||
ich9_pm_get_s4_val,
|
||||
ich9_pm_set_s4_val,
|
||||
NULL, pm, NULL);
|
||||
object_property_add_bool(obj, ACPI_PM_PROP_TCO_ENABLED,
|
||||
ich9_pm_get_enable_tco,
|
||||
ich9_pm_set_enable_tco,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp)
|
||||
|
|
|
@ -0,0 +1,264 @@
|
|||
/*
|
||||
* QEMU ICH9 TCO emulation
|
||||
*
|
||||
* Copyright (c) 2015 Paulo Alcantara <pcacjr@zytor.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
#include "qemu-common.h"
|
||||
#include "sysemu/watchdog.h"
|
||||
#include "hw/i386/ich9.h"
|
||||
|
||||
#include "hw/acpi/tco.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define TCO_DEBUG(fmt, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "%s "fmt, __func__, ## __VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define TCO_DEBUG(fmt, ...) do { } while (0)
|
||||
#endif
|
||||
|
||||
enum {
|
||||
TCO_RLD_DEFAULT = 0x0000,
|
||||
TCO_DAT_IN_DEFAULT = 0x00,
|
||||
TCO_DAT_OUT_DEFAULT = 0x00,
|
||||
TCO1_STS_DEFAULT = 0x0000,
|
||||
TCO2_STS_DEFAULT = 0x0000,
|
||||
TCO1_CNT_DEFAULT = 0x0000,
|
||||
TCO2_CNT_DEFAULT = 0x0008,
|
||||
TCO_MESSAGE1_DEFAULT = 0x00,
|
||||
TCO_MESSAGE2_DEFAULT = 0x00,
|
||||
TCO_WDCNT_DEFAULT = 0x00,
|
||||
TCO_TMR_DEFAULT = 0x0004,
|
||||
SW_IRQ_GEN_DEFAULT = 0x03,
|
||||
};
|
||||
|
||||
static inline void tco_timer_reload(TCOIORegs *tr)
|
||||
{
|
||||
tr->expire_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
|
||||
((int64_t)(tr->tco.tmr & TCO_TMR_MASK) * TCO_TICK_NSEC);
|
||||
timer_mod(tr->tco_timer, tr->expire_time);
|
||||
}
|
||||
|
||||
static inline void tco_timer_stop(TCOIORegs *tr)
|
||||
{
|
||||
tr->expire_time = -1;
|
||||
}
|
||||
|
||||
static void tco_timer_expired(void *opaque)
|
||||
{
|
||||
TCOIORegs *tr = opaque;
|
||||
ICH9LPCPMRegs *pm = container_of(tr, ICH9LPCPMRegs, tco_regs);
|
||||
ICH9LPCState *lpc = container_of(pm, ICH9LPCState, pm);
|
||||
uint32_t gcs = pci_get_long(lpc->chip_config + ICH9_CC_GCS);
|
||||
|
||||
tr->tco.rld = 0;
|
||||
tr->tco.sts1 |= TCO_TIMEOUT;
|
||||
if (++tr->timeouts_no == 2) {
|
||||
tr->tco.sts2 |= TCO_SECOND_TO_STS;
|
||||
tr->tco.sts2 |= TCO_BOOT_STS;
|
||||
tr->timeouts_no = 0;
|
||||
|
||||
if (!lpc->pin_strap.spkr_hi && !(gcs & ICH9_CC_GCS_NO_REBOOT)) {
|
||||
watchdog_perform_action();
|
||||
tco_timer_stop(tr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pm->smi_en & ICH9_PMIO_SMI_EN_TCO_EN) {
|
||||
ich9_generate_smi();
|
||||
} else {
|
||||
ich9_generate_nmi();
|
||||
}
|
||||
tr->tco.rld = tr->tco.tmr;
|
||||
tco_timer_reload(tr);
|
||||
}
|
||||
|
||||
/* NOTE: values of 0 or 1 will be ignored by ICH */
|
||||
static inline int can_start_tco_timer(TCOIORegs *tr)
|
||||
{
|
||||
return !(tr->tco.cnt1 & TCO_TMR_HLT) && tr->tco.tmr > 1;
|
||||
}
|
||||
|
||||
static uint32_t tco_ioport_readw(TCOIORegs *tr, uint32_t addr)
|
||||
{
|
||||
uint16_t rld;
|
||||
|
||||
switch (addr) {
|
||||
case TCO_RLD:
|
||||
if (tr->expire_time != -1) {
|
||||
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
int64_t elapsed = (tr->expire_time - now) / TCO_TICK_NSEC;
|
||||
rld = (uint16_t)elapsed | (tr->tco.rld & ~TCO_RLD_MASK);
|
||||
} else {
|
||||
rld = tr->tco.rld;
|
||||
}
|
||||
return rld;
|
||||
case TCO_DAT_IN:
|
||||
return tr->tco.din;
|
||||
case TCO_DAT_OUT:
|
||||
return tr->tco.dout;
|
||||
case TCO1_STS:
|
||||
return tr->tco.sts1;
|
||||
case TCO2_STS:
|
||||
return tr->tco.sts2;
|
||||
case TCO1_CNT:
|
||||
return tr->tco.cnt1;
|
||||
case TCO2_CNT:
|
||||
return tr->tco.cnt2;
|
||||
case TCO_MESSAGE1:
|
||||
return tr->tco.msg1;
|
||||
case TCO_MESSAGE2:
|
||||
return tr->tco.msg2;
|
||||
case TCO_WDCNT:
|
||||
return tr->tco.wdcnt;
|
||||
case TCO_TMR:
|
||||
return tr->tco.tmr;
|
||||
case SW_IRQ_GEN:
|
||||
return tr->sw_irq_gen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tco_ioport_writew(TCOIORegs *tr, uint32_t addr, uint32_t val)
|
||||
{
|
||||
switch (addr) {
|
||||
case TCO_RLD:
|
||||
tr->timeouts_no = 0;
|
||||
if (can_start_tco_timer(tr)) {
|
||||
tr->tco.rld = tr->tco.tmr;
|
||||
tco_timer_reload(tr);
|
||||
} else {
|
||||
tr->tco.rld = val;
|
||||
}
|
||||
break;
|
||||
case TCO_DAT_IN:
|
||||
tr->tco.din = val;
|
||||
tr->tco.sts1 |= SW_TCO_SMI;
|
||||
ich9_generate_smi();
|
||||
break;
|
||||
case TCO_DAT_OUT:
|
||||
tr->tco.dout = val;
|
||||
tr->tco.sts1 |= TCO_INT_STS;
|
||||
/* TODO: cause an interrupt, as selected by the TCO_INT_SEL bits */
|
||||
break;
|
||||
case TCO1_STS:
|
||||
tr->tco.sts1 = val & TCO1_STS_MASK;
|
||||
break;
|
||||
case TCO2_STS:
|
||||
tr->tco.sts2 = val & TCO2_STS_MASK;
|
||||
break;
|
||||
case TCO1_CNT:
|
||||
val &= TCO1_CNT_MASK;
|
||||
/*
|
||||
* once TCO_LOCK bit is set, it can not be cleared by software. a reset
|
||||
* is required to change this bit from 1 to 0 -- it defaults to 0.
|
||||
*/
|
||||
tr->tco.cnt1 = val | (tr->tco.cnt1 & TCO_LOCK);
|
||||
if (can_start_tco_timer(tr)) {
|
||||
tr->tco.rld = tr->tco.tmr;
|
||||
tco_timer_reload(tr);
|
||||
} else {
|
||||
tco_timer_stop(tr);
|
||||
}
|
||||
break;
|
||||
case TCO2_CNT:
|
||||
tr->tco.cnt2 = val;
|
||||
break;
|
||||
case TCO_MESSAGE1:
|
||||
tr->tco.msg1 = val;
|
||||
break;
|
||||
case TCO_MESSAGE2:
|
||||
tr->tco.msg2 = val;
|
||||
break;
|
||||
case TCO_WDCNT:
|
||||
tr->tco.wdcnt = val;
|
||||
break;
|
||||
case TCO_TMR:
|
||||
tr->tco.tmr = val;
|
||||
break;
|
||||
case SW_IRQ_GEN:
|
||||
tr->sw_irq_gen = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t tco_io_readw(void *opaque, hwaddr addr, unsigned width)
|
||||
{
|
||||
TCOIORegs *tr = opaque;
|
||||
return tco_ioport_readw(tr, addr);
|
||||
}
|
||||
|
||||
static void tco_io_writew(void *opaque, hwaddr addr, uint64_t val,
|
||||
unsigned width)
|
||||
{
|
||||
TCOIORegs *tr = opaque;
|
||||
tco_ioport_writew(tr, addr, val);
|
||||
}
|
||||
|
||||
static const MemoryRegionOps tco_io_ops = {
|
||||
.read = tco_io_readw,
|
||||
.write = tco_io_writew,
|
||||
.valid.min_access_size = 1,
|
||||
.valid.max_access_size = 4,
|
||||
.impl.min_access_size = 1,
|
||||
.impl.max_access_size = 2,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
void acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion *parent)
|
||||
{
|
||||
*tr = (TCOIORegs) {
|
||||
.tco = {
|
||||
.rld = TCO_RLD_DEFAULT,
|
||||
.din = TCO_DAT_IN_DEFAULT,
|
||||
.dout = TCO_DAT_OUT_DEFAULT,
|
||||
.sts1 = TCO1_STS_DEFAULT,
|
||||
.sts2 = TCO2_STS_DEFAULT,
|
||||
.cnt1 = TCO1_CNT_DEFAULT,
|
||||
.cnt2 = TCO2_CNT_DEFAULT,
|
||||
.msg1 = TCO_MESSAGE1_DEFAULT,
|
||||
.msg2 = TCO_MESSAGE2_DEFAULT,
|
||||
.wdcnt = TCO_WDCNT_DEFAULT,
|
||||
.tmr = TCO_TMR_DEFAULT,
|
||||
},
|
||||
.sw_irq_gen = SW_IRQ_GEN_DEFAULT,
|
||||
.tco_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, tco_timer_expired, tr),
|
||||
.expire_time = -1,
|
||||
.timeouts_no = 0,
|
||||
};
|
||||
memory_region_init_io(&tr->io, memory_region_owner(parent),
|
||||
&tco_io_ops, tr, "sm-tco", ICH9_PMIO_TCO_LEN);
|
||||
memory_region_add_subregion(parent, ICH9_PMIO_TCO_RLD, &tr->io);
|
||||
}
|
||||
|
||||
const VMStateDescription vmstate_tco_io_sts = {
|
||||
.name = "tco io device status",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.minimum_version_id_old = 1,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT16(tco.rld, TCOIORegs),
|
||||
VMSTATE_UINT8(tco.din, TCOIORegs),
|
||||
VMSTATE_UINT8(tco.dout, TCOIORegs),
|
||||
VMSTATE_UINT16(tco.sts1, TCOIORegs),
|
||||
VMSTATE_UINT16(tco.sts2, TCOIORegs),
|
||||
VMSTATE_UINT16(tco.cnt1, TCOIORegs),
|
||||
VMSTATE_UINT16(tco.cnt2, TCOIORegs),
|
||||
VMSTATE_UINT8(tco.msg1, TCOIORegs),
|
||||
VMSTATE_UINT8(tco.msg2, TCOIORegs),
|
||||
VMSTATE_UINT8(tco.wdcnt, TCOIORegs),
|
||||
VMSTATE_UINT16(tco.tmr, TCOIORegs),
|
||||
VMSTATE_UINT8(sw_irq_gen, TCOIORegs),
|
||||
VMSTATE_TIMER_PTR(tco_timer, TCOIORegs),
|
||||
VMSTATE_INT64(expire_time, TCOIORegs),
|
||||
VMSTATE_UINT8(timeouts_no, TCOIORegs),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
129
hw/i386/pc.c
129
hw/i386/pc.c
|
@ -293,11 +293,82 @@ static void pc_boot_set(void *opaque, const char *boot_device, Error **errp)
|
|||
set_boot_dev(opaque, boot_device, errp);
|
||||
}
|
||||
|
||||
static void pc_cmos_init_floppy(ISADevice *rtc_state, ISADevice *floppy)
|
||||
{
|
||||
int val, nb, i;
|
||||
FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE };
|
||||
|
||||
/* floppy type */
|
||||
if (floppy) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
fd_type[i] = isa_fdc_get_drive_type(floppy, i);
|
||||
}
|
||||
}
|
||||
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
|
||||
cmos_get_fd_drive_type(fd_type[1]);
|
||||
rtc_set_memory(rtc_state, 0x10, val);
|
||||
|
||||
val = rtc_get_memory(rtc_state, REG_EQUIPMENT_BYTE);
|
||||
nb = 0;
|
||||
if (fd_type[0] < FDRIVE_DRV_NONE) {
|
||||
nb++;
|
||||
}
|
||||
if (fd_type[1] < FDRIVE_DRV_NONE) {
|
||||
nb++;
|
||||
}
|
||||
switch (nb) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
val |= 0x01; /* 1 drive, ready for boot */
|
||||
break;
|
||||
case 2:
|
||||
val |= 0x41; /* 2 drives, ready for boot */
|
||||
break;
|
||||
}
|
||||
rtc_set_memory(rtc_state, REG_EQUIPMENT_BYTE, val);
|
||||
}
|
||||
|
||||
typedef struct pc_cmos_init_late_arg {
|
||||
ISADevice *rtc_state;
|
||||
BusState *idebus[2];
|
||||
} pc_cmos_init_late_arg;
|
||||
|
||||
typedef struct check_fdc_state {
|
||||
ISADevice *floppy;
|
||||
bool multiple;
|
||||
} CheckFdcState;
|
||||
|
||||
static int check_fdc(Object *obj, void *opaque)
|
||||
{
|
||||
CheckFdcState *state = opaque;
|
||||
Object *fdc;
|
||||
uint32_t iobase;
|
||||
Error *local_err = NULL;
|
||||
|
||||
fdc = object_dynamic_cast(obj, TYPE_ISA_FDC);
|
||||
if (!fdc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
iobase = object_property_get_int(obj, "iobase", &local_err);
|
||||
if (local_err || iobase != 0x3f0) {
|
||||
error_free(local_err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (state->floppy) {
|
||||
state->multiple = true;
|
||||
} else {
|
||||
state->floppy = ISA_DEVICE(obj);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * const fdc_container_path[] = {
|
||||
"/unattached", "/peripheral", "/peripheral-anon"
|
||||
};
|
||||
|
||||
static void pc_cmos_init_late(void *opaque)
|
||||
{
|
||||
pc_cmos_init_late_arg *arg = opaque;
|
||||
|
@ -306,6 +377,8 @@ static void pc_cmos_init_late(void *opaque)
|
|||
int8_t heads, sectors;
|
||||
int val;
|
||||
int i, trans;
|
||||
Object *container;
|
||||
CheckFdcState state = { 0 };
|
||||
|
||||
val = 0;
|
||||
if (ide_get_geometry(arg->idebus[0], 0,
|
||||
|
@ -335,16 +408,32 @@ static void pc_cmos_init_late(void *opaque)
|
|||
}
|
||||
rtc_set_memory(s, 0x39, val);
|
||||
|
||||
/*
|
||||
* Locate the FDC at IO address 0x3f0, and configure the CMOS registers
|
||||
* accordingly.
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
|
||||
container = container_get(qdev_get_machine(), fdc_container_path[i]);
|
||||
object_child_foreach(container, check_fdc, &state);
|
||||
}
|
||||
|
||||
if (state.multiple) {
|
||||
error_report("warning: multiple floppy disk controllers with "
|
||||
"iobase=0x3f0 have been found;\n"
|
||||
"the one being picked for CMOS setup might not reflect "
|
||||
"your intent");
|
||||
}
|
||||
pc_cmos_init_floppy(s, state.floppy);
|
||||
|
||||
qemu_unregister_reset(pc_cmos_init_late, opaque);
|
||||
}
|
||||
|
||||
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
||||
const char *boot_device, MachineState *machine,
|
||||
ISADevice *floppy, BusState *idebus0, BusState *idebus1,
|
||||
BusState *idebus0, BusState *idebus1,
|
||||
ISADevice *s)
|
||||
{
|
||||
int val, nb, i;
|
||||
FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE };
|
||||
int val;
|
||||
static pc_cmos_init_late_arg arg;
|
||||
PCMachineState *pc_machine = PC_MACHINE(machine);
|
||||
Error *local_err = NULL;
|
||||
|
@ -401,39 +490,12 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* floppy type */
|
||||
if (floppy) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
fd_type[i] = isa_fdc_get_drive_type(floppy, i);
|
||||
}
|
||||
}
|
||||
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
|
||||
cmos_get_fd_drive_type(fd_type[1]);
|
||||
rtc_set_memory(s, 0x10, val);
|
||||
|
||||
val = 0;
|
||||
nb = 0;
|
||||
if (fd_type[0] < FDRIVE_DRV_NONE) {
|
||||
nb++;
|
||||
}
|
||||
if (fd_type[1] < FDRIVE_DRV_NONE) {
|
||||
nb++;
|
||||
}
|
||||
switch (nb) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
val |= 0x01; /* 1 drive, ready for boot */
|
||||
break;
|
||||
case 2:
|
||||
val |= 0x41; /* 2 drives, ready for boot */
|
||||
break;
|
||||
}
|
||||
val |= 0x02; /* FPU is there */
|
||||
val |= 0x04; /* PS/2 mouse installed */
|
||||
rtc_set_memory(s, REG_EQUIPMENT_BYTE, val);
|
||||
|
||||
/* hard drives */
|
||||
/* hard drives and FDC */
|
||||
arg.rtc_state = s;
|
||||
arg.idebus[0] = idebus0;
|
||||
arg.idebus[1] = idebus1;
|
||||
|
@ -1401,7 +1463,6 @@ static const MemoryRegionOps ioportF0_io_ops = {
|
|||
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||
ISADevice **rtc_state,
|
||||
bool create_fdctrl,
|
||||
ISADevice **floppy,
|
||||
bool no_vmport,
|
||||
uint32 hpet_irqs)
|
||||
{
|
||||
|
@ -1497,7 +1558,9 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
|||
fd[i] = drive_get(IF_FLOPPY, 0, i);
|
||||
create_fdctrl |= !!fd[i];
|
||||
}
|
||||
*floppy = create_fdctrl ? fdctrl_init_isa(isa_bus, fd) : NULL;
|
||||
if (create_fdctrl) {
|
||||
fdctrl_init_isa(isa_bus, fd);
|
||||
}
|
||||
}
|
||||
|
||||
void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)
|
||||
|
|
|
@ -94,7 +94,6 @@ static void pc_init1(MachineState *machine)
|
|||
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
||||
BusState *idebus[MAX_IDE_BUS];
|
||||
ISADevice *rtc_state;
|
||||
ISADevice *floppy;
|
||||
MemoryRegion *ram_memory;
|
||||
MemoryRegion *pci_memory;
|
||||
MemoryRegion *rom_memory;
|
||||
|
@ -241,7 +240,7 @@ static void pc_init1(MachineState *machine)
|
|||
}
|
||||
|
||||
/* init basic PC hardware */
|
||||
pc_basic_device_init(isa_bus, gsi, &rtc_state, true, &floppy,
|
||||
pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
|
||||
(pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);
|
||||
|
||||
pc_nic_init(isa_bus, pci_bus);
|
||||
|
@ -273,7 +272,7 @@ static void pc_init1(MachineState *machine)
|
|||
}
|
||||
|
||||
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
|
||||
machine, floppy, idebus[0], idebus[1], rtc_state);
|
||||
machine, idebus[0], idebus[1], rtc_state);
|
||||
|
||||
if (pci_enabled && usb_enabled()) {
|
||||
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
|
||||
|
|
|
@ -73,7 +73,6 @@ static void pc_q35_init(MachineState *machine)
|
|||
PCIDevice *lpc;
|
||||
BusState *idebus[MAX_SATA_PORTS];
|
||||
ISADevice *rtc_state;
|
||||
ISADevice *floppy;
|
||||
MemoryRegion *pci_memory;
|
||||
MemoryRegion *rom_memory;
|
||||
MemoryRegion *ram_memory;
|
||||
|
@ -249,11 +248,11 @@ static void pc_q35_init(MachineState *machine)
|
|||
}
|
||||
|
||||
/* init basic PC hardware */
|
||||
pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy, &floppy,
|
||||
pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy,
|
||||
(pc_machine->vmport != ON_OFF_AUTO_ON), 0xff0104);
|
||||
|
||||
/* connect pm stuff to lpc */
|
||||
ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pc_machine));
|
||||
ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pc_machine), !mc->no_tco);
|
||||
|
||||
/* ahci and SATA device, for q35 1 ahci controller is built-in */
|
||||
ahci = pci_create_simple_multifunction(host_bus,
|
||||
|
@ -278,7 +277,7 @@ static void pc_q35_init(MachineState *machine)
|
|||
8, NULL, 0);
|
||||
|
||||
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
|
||||
machine, floppy, idebus[0], idebus[1], rtc_state);
|
||||
machine, idebus[0], idebus[1], rtc_state);
|
||||
|
||||
/* the rest devices to which pci devfn is automatically assigned */
|
||||
pc_vga_init(isa_bus, host_bus);
|
||||
|
@ -399,6 +398,7 @@ static void pc_q35_2_4_machine_options(MachineClass *m)
|
|||
m->default_machine_opts = "firmware=bios-256k.bin";
|
||||
m->default_display = "std";
|
||||
m->no_floppy = 1;
|
||||
m->no_tco = 0;
|
||||
m->alias = "q35";
|
||||
}
|
||||
|
||||
|
@ -410,6 +410,7 @@ static void pc_q35_2_3_machine_options(MachineClass *m)
|
|||
{
|
||||
pc_q35_2_4_machine_options(m);
|
||||
m->no_floppy = 0;
|
||||
m->no_tco = 1;
|
||||
m->alias = NULL;
|
||||
SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ static void ich9_cc_reset(ICH9LPCState *lpc)
|
|||
pci_set_long(c + ICH9_CC_D27IR, ICH9_CC_DIR_DEFAULT);
|
||||
pci_set_long(c + ICH9_CC_D26IR, ICH9_CC_DIR_DEFAULT);
|
||||
pci_set_long(c + ICH9_CC_D25IR, ICH9_CC_DIR_DEFAULT);
|
||||
pci_set_long(c + ICH9_CC_GCS, ICH9_CC_GCS_DEFAULT);
|
||||
|
||||
ich9_cc_update(lpc);
|
||||
}
|
||||
|
@ -313,6 +314,16 @@ PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin)
|
|||
return route;
|
||||
}
|
||||
|
||||
void ich9_generate_smi(void)
|
||||
{
|
||||
cpu_interrupt(first_cpu, CPU_INTERRUPT_SMI);
|
||||
}
|
||||
|
||||
void ich9_generate_nmi(void)
|
||||
{
|
||||
cpu_interrupt(first_cpu, CPU_INTERRUPT_NMI);
|
||||
}
|
||||
|
||||
static int ich9_lpc_sci_irq(ICH9LPCState *lpc)
|
||||
{
|
||||
switch (lpc->d.config[ICH9_LPC_ACPI_CTRL] &
|
||||
|
@ -357,13 +368,13 @@ static void ich9_set_sci(void *opaque, int irq_num, int level)
|
|||
}
|
||||
}
|
||||
|
||||
void ich9_lpc_pm_init(PCIDevice *lpc_pci, bool smm_enabled)
|
||||
void ich9_lpc_pm_init(PCIDevice *lpc_pci, bool smm_enabled, bool enable_tco)
|
||||
{
|
||||
ICH9LPCState *lpc = ICH9_LPC_DEVICE(lpc_pci);
|
||||
qemu_irq sci_irq;
|
||||
|
||||
sci_irq = qemu_allocate_irq(ich9_set_sci, lpc, 0);
|
||||
ich9_pm_init(lpc_pci, &lpc->pm, smm_enabled, sci_irq);
|
||||
ich9_pm_init(lpc_pci, &lpc->pm, smm_enabled, enable_tco, sci_irq);
|
||||
ich9_lpc_reset(&lpc->d.qdev);
|
||||
}
|
||||
|
||||
|
@ -681,6 +692,11 @@ static const VMStateDescription vmstate_ich9_lpc = {
|
|||
}
|
||||
};
|
||||
|
||||
static Property ich9_lpc_properties[] = {
|
||||
DEFINE_PROP_BOOL("noreboot", ICH9LPCState, pin_strap.spkr_hi, true),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void ich9_lpc_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
@ -692,6 +708,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
|
|||
dc->reset = ich9_lpc_reset;
|
||||
k->init = ich9_lpc_init;
|
||||
dc->vmsd = &vmstate_ich9_lpc;
|
||||
dc->props = ich9_lpc_properties;
|
||||
k->config_write = ich9_lpc_config_write;
|
||||
dc->desc = "ICH9 LPC bridge";
|
||||
k->vendor_id = PCI_VENDOR_ID_INTEL;
|
||||
|
|
|
@ -78,7 +78,7 @@ int pcie_cap_init(PCIDevice *dev, uint8_t offset, uint8_t type, uint8_t port)
|
|||
PCI_EXP_LNK_LS_25);
|
||||
|
||||
pci_set_word(exp_cap + PCI_EXP_LNKSTA,
|
||||
PCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25);
|
||||
PCI_EXP_LNK_MLW_1 | PCI_EXP_LNK_LS_25 |PCI_EXP_LNKSTA_DLLLA);
|
||||
|
||||
pci_set_long(exp_cap + PCI_EXP_DEVCAP2,
|
||||
PCI_EXP_DEVCAP2_EFF | PCI_EXP_DEVCAP2_EETLPP);
|
||||
|
|
|
@ -153,22 +153,20 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring)
|
|||
return true;
|
||||
}
|
||||
|
||||
return vring_need_event(vring_used_event(&vring->vr), new, old);
|
||||
return vring_need_event(virtio_tswap16(vdev, vring_used_event(&vring->vr)),
|
||||
new, old);
|
||||
}
|
||||
|
||||
|
||||
static int get_desc(VirtIODevice *vdev, Vring *vring, VirtQueueElement *elem,
|
||||
static int get_desc(Vring *vring, VirtQueueElement *elem,
|
||||
struct vring_desc *desc)
|
||||
{
|
||||
unsigned *num;
|
||||
struct iovec *iov;
|
||||
hwaddr *addr;
|
||||
MemoryRegion *mr;
|
||||
int is_write = virtio_tswap16(vdev, desc->flags) & VRING_DESC_F_WRITE;
|
||||
uint32_t len = virtio_tswap32(vdev, desc->len);
|
||||
uint64_t desc_addr = virtio_tswap64(vdev, desc->addr);
|
||||
|
||||
if (is_write) {
|
||||
if (desc->flags & VRING_DESC_F_WRITE) {
|
||||
num = &elem->in_num;
|
||||
iov = &elem->in_sg[*num];
|
||||
addr = &elem->in_addr[*num];
|
||||
|
@ -192,17 +190,18 @@ static int get_desc(VirtIODevice *vdev, Vring *vring, VirtQueueElement *elem,
|
|||
}
|
||||
|
||||
/* TODO handle non-contiguous memory across region boundaries */
|
||||
iov->iov_base = vring_map(&mr, desc_addr, len, is_write);
|
||||
iov->iov_base = vring_map(&mr, desc->addr, desc->len,
|
||||
desc->flags & VRING_DESC_F_WRITE);
|
||||
if (!iov->iov_base) {
|
||||
error_report("Failed to map descriptor addr %#" PRIx64 " len %u",
|
||||
(uint64_t)desc_addr, len);
|
||||
(uint64_t)desc->addr, desc->len);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
/* The MemoryRegion is looked up again and unref'ed later, leave the
|
||||
* ref in place. */
|
||||
iov->iov_len = len;
|
||||
*addr = desc_addr;
|
||||
iov->iov_len = desc->len;
|
||||
*addr = desc->addr;
|
||||
*num += 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -224,23 +223,21 @@ static int get_indirect(VirtIODevice *vdev, Vring *vring,
|
|||
struct vring_desc desc;
|
||||
unsigned int i = 0, count, found = 0;
|
||||
int ret;
|
||||
uint32_t len = virtio_tswap32(vdev, indirect->len);
|
||||
uint64_t addr = virtio_tswap64(vdev, indirect->addr);
|
||||
|
||||
/* Sanity check */
|
||||
if (unlikely(len % sizeof(desc))) {
|
||||
if (unlikely(indirect->len % sizeof(desc))) {
|
||||
error_report("Invalid length in indirect descriptor: "
|
||||
"len %#x not multiple of %#zx",
|
||||
len, sizeof(desc));
|
||||
indirect->len, sizeof(desc));
|
||||
vring->broken = true;
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
count = len / sizeof(desc);
|
||||
count = indirect->len / sizeof(desc);
|
||||
/* Buffers are chained via a 16 bit next field, so
|
||||
* we can have at most 2^16 of these. */
|
||||
if (unlikely(count > USHRT_MAX + 1)) {
|
||||
error_report("Indirect buffer length too big: %d", len);
|
||||
error_report("Indirect buffer length too big: %d", indirect->len);
|
||||
vring->broken = true;
|
||||
return -EFAULT;
|
||||
}
|
||||
|
@ -251,12 +248,12 @@ static int get_indirect(VirtIODevice *vdev, Vring *vring,
|
|||
|
||||
/* Translate indirect descriptor */
|
||||
desc_ptr = vring_map(&mr,
|
||||
addr + found * sizeof(desc),
|
||||
indirect->addr + found * sizeof(desc),
|
||||
sizeof(desc), false);
|
||||
if (!desc_ptr) {
|
||||
error_report("Failed to map indirect descriptor "
|
||||
"addr %#" PRIx64 " len %zu",
|
||||
(uint64_t)addr + found * sizeof(desc),
|
||||
(uint64_t)indirect->addr + found * sizeof(desc),
|
||||
sizeof(desc));
|
||||
vring->broken = true;
|
||||
return -EFAULT;
|
||||
|
@ -274,20 +271,19 @@ static int get_indirect(VirtIODevice *vdev, Vring *vring,
|
|||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (unlikely(virtio_tswap16(vdev, desc.flags)
|
||||
& VRING_DESC_F_INDIRECT)) {
|
||||
if (unlikely(desc.flags & VRING_DESC_F_INDIRECT)) {
|
||||
error_report("Nested indirect descriptor");
|
||||
vring->broken = true;
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
ret = get_desc(vdev, vring, elem, &desc);
|
||||
ret = get_desc(vring, elem, &desc);
|
||||
if (ret < 0) {
|
||||
vring->broken |= (ret == -EFAULT);
|
||||
return ret;
|
||||
}
|
||||
i = virtio_tswap16(vdev, desc.next);
|
||||
} while (virtio_tswap16(vdev, desc.flags) & VRING_DESC_F_NEXT);
|
||||
i = desc.next;
|
||||
} while (desc.flags & VRING_DESC_F_NEXT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -388,7 +384,7 @@ int vring_pop(VirtIODevice *vdev, Vring *vring,
|
|||
/* Ensure descriptor is loaded before accessing fields */
|
||||
barrier();
|
||||
|
||||
if (virtio_tswap16(vdev, desc.flags) & VRING_DESC_F_INDIRECT) {
|
||||
if (desc.flags & VRING_DESC_F_INDIRECT) {
|
||||
ret = get_indirect(vdev, vring, elem, &desc);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
|
@ -396,18 +392,19 @@ int vring_pop(VirtIODevice *vdev, Vring *vring,
|
|||
continue;
|
||||
}
|
||||
|
||||
ret = get_desc(vdev, vring, elem, &desc);
|
||||
ret = get_desc(vring, elem, &desc);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
i = virtio_tswap16(vdev, desc.next);
|
||||
} while (virtio_tswap16(vdev, desc.flags) & VRING_DESC_F_NEXT);
|
||||
i = desc.next;
|
||||
} while (desc.flags & VRING_DESC_F_NEXT);
|
||||
|
||||
/* On success, increment avail index. */
|
||||
vring->last_avail_idx++;
|
||||
if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||
vring_avail_event(&vring->vr) = vring->last_avail_idx;
|
||||
vring_avail_event(&vring->vr) =
|
||||
virtio_tswap16(vdev, vring->last_avail_idx);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
|
|
@ -443,11 +443,89 @@ static const MemoryRegionOps virtio_pci_config_ops = {
|
|||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
/* Below are generic functions to do memcpy from/to an address space,
|
||||
* without byteswaps, with input validation.
|
||||
*
|
||||
* As regular address_space_* APIs all do some kind of byteswap at least for
|
||||
* some host/target combinations, we are forced to explicitly convert to a
|
||||
* known-endianness integer value.
|
||||
* It doesn't really matter which endian format to go through, so the code
|
||||
* below selects the endian that causes the least amount of work on the given
|
||||
* host.
|
||||
*
|
||||
* Note: host pointer must be aligned.
|
||||
*/
|
||||
static
|
||||
void virtio_address_space_write(AddressSpace *as, hwaddr addr,
|
||||
const uint8_t *buf, int len)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
/* address_space_* APIs assume an aligned address.
|
||||
* As address is under guest control, handle illegal values.
|
||||
*/
|
||||
addr &= ~(len - 1);
|
||||
|
||||
/* Make sure caller aligned buf properly */
|
||||
assert(!(((uintptr_t)buf) & (len - 1)));
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
val = pci_get_byte(buf);
|
||||
address_space_stb(as, addr, val, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
break;
|
||||
case 2:
|
||||
val = pci_get_word(buf);
|
||||
address_space_stw_le(as, addr, val, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
break;
|
||||
case 4:
|
||||
val = pci_get_long(buf);
|
||||
address_space_stl_le(as, addr, val, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
break;
|
||||
default:
|
||||
/* As length is under guest control, handle illegal values. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virtio_address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
/* address_space_* APIs assume an aligned address.
|
||||
* As address is under guest control, handle illegal values.
|
||||
*/
|
||||
addr &= ~(len - 1);
|
||||
|
||||
/* Make sure caller aligned buf properly */
|
||||
assert(!(((uintptr_t)buf) & (len - 1)));
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
val = address_space_ldub(as, addr, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
pci_set_byte(buf, val);
|
||||
break;
|
||||
case 2:
|
||||
val = address_space_lduw_le(as, addr, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
pci_set_word(buf, val);
|
||||
break;
|
||||
case 4:
|
||||
val = address_space_ldl_le(as, addr, MEMTXATTRS_UNSPECIFIED, NULL);
|
||||
pci_set_long(buf, val);
|
||||
break;
|
||||
default:
|
||||
/* As length is under guest control, handle illegal values. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
|
||||
uint32_t val, int len)
|
||||
{
|
||||
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
|
||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
||||
struct virtio_pci_cfg_cap *cfg;
|
||||
|
||||
pci_default_write_config(pci_dev, address, val, len);
|
||||
|
||||
|
@ -456,6 +534,49 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
|
|||
virtio_pci_stop_ioeventfd(proxy);
|
||||
virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK);
|
||||
}
|
||||
|
||||
if (proxy->config_cap &&
|
||||
ranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap,
|
||||
pci_cfg_data),
|
||||
sizeof cfg->pci_cfg_data)) {
|
||||
uint32_t off;
|
||||
uint32_t len;
|
||||
|
||||
cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
|
||||
off = le32_to_cpu(cfg->cap.offset);
|
||||
len = le32_to_cpu(cfg->cap.length);
|
||||
|
||||
if (len <= sizeof cfg->pci_cfg_data) {
|
||||
virtio_address_space_write(&proxy->modern_as, off,
|
||||
cfg->pci_cfg_data, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t virtio_read_config(PCIDevice *pci_dev,
|
||||
uint32_t address, int len)
|
||||
{
|
||||
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
|
||||
struct virtio_pci_cfg_cap *cfg;
|
||||
|
||||
if (proxy->config_cap &&
|
||||
ranges_overlap(address, len, proxy->config_cap + offsetof(struct virtio_pci_cfg_cap,
|
||||
pci_cfg_data),
|
||||
sizeof cfg->pci_cfg_data)) {
|
||||
uint32_t off;
|
||||
uint32_t len;
|
||||
|
||||
cfg = (void *)(proxy->pci_dev.config + proxy->config_cap);
|
||||
off = le32_to_cpu(cfg->cap.offset);
|
||||
len = le32_to_cpu(cfg->cap.length);
|
||||
|
||||
if (len <= sizeof cfg->pci_cfg_data) {
|
||||
virtio_address_space_read(&proxy->modern_as, off,
|
||||
cfg->pci_cfg_data, len);
|
||||
}
|
||||
}
|
||||
|
||||
return pci_default_read_config(pci_dev, address, len);
|
||||
}
|
||||
|
||||
static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy *proxy,
|
||||
|
@ -942,7 +1063,7 @@ static int virtio_pci_query_nvectors(DeviceState *d)
|
|||
return proxy->nvectors;
|
||||
}
|
||||
|
||||
static void virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
|
||||
static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
|
||||
struct virtio_pci_cap *cap)
|
||||
{
|
||||
PCIDevice *dev = &proxy->pci_dev;
|
||||
|
@ -954,6 +1075,8 @@ static void virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
|
|||
assert(cap->cap_len >= sizeof *cap);
|
||||
memcpy(dev->config + offset + PCI_CAP_FLAGS, &cap->cap_len,
|
||||
cap->cap_len - PCI_CAP_FLAGS);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr,
|
||||
|
@ -1329,6 +1452,11 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
|
|||
.notify_off_multiplier =
|
||||
cpu_to_le32(QEMU_VIRTIO_PCI_QUEUE_MEM_MULT),
|
||||
};
|
||||
struct virtio_pci_cfg_cap cfg = {
|
||||
.cap.cap_len = sizeof cfg,
|
||||
.cap.cfg_type = VIRTIO_PCI_CAP_PCI_CFG,
|
||||
};
|
||||
struct virtio_pci_cfg_cap *cfg_mask;
|
||||
|
||||
/* TODO: add io access for speed */
|
||||
|
||||
|
@ -1338,11 +1466,19 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
|
|||
virtio_pci_modern_region_map(proxy, &proxy->isr, &cap);
|
||||
virtio_pci_modern_region_map(proxy, &proxy->device, &cap);
|
||||
virtio_pci_modern_region_map(proxy, &proxy->notify, ¬ify.cap);
|
||||
|
||||
pci_register_bar(&proxy->pci_dev, proxy->modern_mem_bar,
|
||||
PCI_BASE_ADDRESS_SPACE_MEMORY |
|
||||
PCI_BASE_ADDRESS_MEM_PREFETCH |
|
||||
PCI_BASE_ADDRESS_MEM_TYPE_64,
|
||||
&proxy->modern_bar);
|
||||
|
||||
proxy->config_cap = virtio_pci_add_mem_cap(proxy, &cfg.cap);
|
||||
cfg_mask = (void *)(proxy->pci_dev.wmask + proxy->config_cap);
|
||||
pci_set_byte(&cfg_mask->cap.bar, ~0x0);
|
||||
pci_set_long((uint8_t *)&cfg_mask->cap.offset, ~0x0);
|
||||
pci_set_long((uint8_t *)&cfg_mask->cap.length, ~0x0);
|
||||
pci_set_long(cfg_mask->pci_cfg_data, ~0x0);
|
||||
}
|
||||
|
||||
if (proxy->nvectors &&
|
||||
|
@ -1354,6 +1490,7 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
|
|||
}
|
||||
|
||||
proxy->pci_dev.config_write = virtio_write_config;
|
||||
proxy->pci_dev.config_read = virtio_read_config;
|
||||
|
||||
if (legacy) {
|
||||
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev)
|
||||
|
@ -1424,6 +1561,15 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
|
|||
2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
|
||||
VIRTIO_QUEUE_MAX);
|
||||
|
||||
memory_region_init_alias(&proxy->modern_cfg,
|
||||
OBJECT(proxy),
|
||||
"virtio-pci-cfg",
|
||||
&proxy->modern_bar,
|
||||
0,
|
||||
memory_region_size(&proxy->modern_bar));
|
||||
|
||||
address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as");
|
||||
|
||||
virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy);
|
||||
if (k->realize) {
|
||||
k->realize(proxy, errp);
|
||||
|
@ -1432,7 +1578,10 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
|
|||
|
||||
static void virtio_pci_exit(PCIDevice *pci_dev)
|
||||
{
|
||||
VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev);
|
||||
|
||||
msix_uninit_exclusive_bar(pci_dev);
|
||||
address_space_destroy(&proxy->modern_as);
|
||||
}
|
||||
|
||||
static void virtio_pci_reset(DeviceState *qdev)
|
||||
|
|
|
@ -112,9 +112,12 @@ struct VirtIOPCIProxy {
|
|||
VirtIOPCIRegion device;
|
||||
VirtIOPCIRegion notify;
|
||||
MemoryRegion modern_bar;
|
||||
MemoryRegion modern_cfg;
|
||||
AddressSpace modern_as;
|
||||
uint32_t legacy_io_bar;
|
||||
uint32_t msix_bar;
|
||||
uint32_t modern_mem_bar;
|
||||
int config_cap;
|
||||
uint32_t flags;
|
||||
uint32_t class_code;
|
||||
uint32_t nvectors;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "hw/acpi/cpu_hotplug.h"
|
||||
#include "hw/acpi/memory_hotplug.h"
|
||||
#include "hw/acpi/acpi_dev_interface.h"
|
||||
#include "hw/acpi/tco.h"
|
||||
|
||||
typedef struct ICH9LPCPMRegs {
|
||||
/*
|
||||
|
@ -55,10 +56,15 @@ typedef struct ICH9LPCPMRegs {
|
|||
uint8_t disable_s4;
|
||||
uint8_t s4_val;
|
||||
uint8_t smm_enabled;
|
||||
bool enable_tco;
|
||||
TCOIORegs tco_regs;
|
||||
} ICH9LPCPMRegs;
|
||||
|
||||
void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
|
||||
bool smm_enabled, qemu_irq sci_irq);
|
||||
bool smm_enabled,
|
||||
bool enable_tco,
|
||||
qemu_irq sci_irq);
|
||||
|
||||
void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base);
|
||||
extern const VMStateDescription vmstate_ich9_pm;
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* QEMU ICH9 TCO emulation
|
||||
*
|
||||
* Copyright (c) 2015 Paulo Alcantara <pcacjr@zytor.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
#ifndef HW_ACPI_TCO_H
|
||||
#define HW_ACPI_TCO_H
|
||||
|
||||
#include "qemu/typedefs.h"
|
||||
#include "qemu-common.h"
|
||||
|
||||
/* As per ICH9 spec, the internal timer has an error of ~0.6s on every tick */
|
||||
#define TCO_TICK_NSEC 600000000LL
|
||||
|
||||
/* TCO I/O register offsets */
|
||||
enum {
|
||||
TCO_RLD = 0x00,
|
||||
TCO_DAT_IN = 0x02,
|
||||
TCO_DAT_OUT = 0x03,
|
||||
TCO1_STS = 0x04,
|
||||
TCO2_STS = 0x06,
|
||||
TCO1_CNT = 0x08,
|
||||
TCO2_CNT = 0x0a,
|
||||
TCO_MESSAGE1 = 0x0c,
|
||||
TCO_MESSAGE2 = 0x0d,
|
||||
TCO_WDCNT = 0x0e,
|
||||
SW_IRQ_GEN = 0x10,
|
||||
TCO_TMR = 0x12,
|
||||
};
|
||||
|
||||
/* TCO I/O register control/status bits */
|
||||
enum {
|
||||
SW_TCO_SMI = 1 << 1,
|
||||
TCO_INT_STS = 1 << 2,
|
||||
TCO_LOCK = 1 << 12,
|
||||
TCO_TMR_HLT = 1 << 11,
|
||||
TCO_TIMEOUT = 1 << 3,
|
||||
TCO_SECOND_TO_STS = 1 << 1,
|
||||
TCO_BOOT_STS = 1 << 2,
|
||||
};
|
||||
|
||||
/* TCO I/O registers mask bits */
|
||||
enum {
|
||||
TCO_RLD_MASK = 0x3ff,
|
||||
TCO1_STS_MASK = 0xe870,
|
||||
TCO2_STS_MASK = 0xfff8,
|
||||
TCO1_CNT_MASK = 0xfeff,
|
||||
TCO_TMR_MASK = 0x3ff,
|
||||
};
|
||||
|
||||
typedef struct TCOIORegs {
|
||||
struct {
|
||||
uint16_t rld;
|
||||
uint8_t din;
|
||||
uint8_t dout;
|
||||
uint16_t sts1;
|
||||
uint16_t sts2;
|
||||
uint16_t cnt1;
|
||||
uint16_t cnt2;
|
||||
uint8_t msg1;
|
||||
uint8_t msg2;
|
||||
uint8_t wdcnt;
|
||||
uint16_t tmr;
|
||||
} tco;
|
||||
uint8_t sw_irq_gen;
|
||||
|
||||
QEMUTimer *tco_timer;
|
||||
int64_t expire_time;
|
||||
uint8_t timeouts_no;
|
||||
|
||||
MemoryRegion io;
|
||||
} TCOIORegs;
|
||||
|
||||
/* tco.c */
|
||||
void acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion *parent);
|
||||
|
||||
extern const VMStateDescription vmstate_tco_io_sts;
|
||||
|
||||
#endif /* HW_ACPI_TCO_H */
|
|
@ -99,7 +99,8 @@ struct MachineClass {
|
|||
no_floppy:1,
|
||||
no_cdrom:1,
|
||||
no_sdcard:1,
|
||||
has_dynamic_sysbus:1;
|
||||
has_dynamic_sysbus:1,
|
||||
no_tco:1;
|
||||
int is_default;
|
||||
const char *default_machine_opts;
|
||||
const char *default_boot_order;
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
|
||||
int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
|
||||
PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin);
|
||||
void ich9_lpc_pm_init(PCIDevice *pci_lpc, bool smm_enabled);
|
||||
void ich9_lpc_pm_init(PCIDevice *pci_lpc, bool smm_enabled, bool enable_tco);
|
||||
I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
|
||||
|
||||
void ich9_generate_smi(void);
|
||||
void ich9_generate_nmi(void);
|
||||
|
||||
#define ICH9_CC_SIZE (16 * 1024) /* 16KB */
|
||||
|
||||
#define TYPE_ICH9_LPC_DEVICE "ICH9-LPC"
|
||||
|
@ -43,6 +46,11 @@ typedef struct ICH9LPCState {
|
|||
ICH9LPCPMRegs pm;
|
||||
uint32_t sci_level; /* track sci level */
|
||||
|
||||
/* 2.24 Pin Straps */
|
||||
struct {
|
||||
bool spkr_hi;
|
||||
} pin_strap;
|
||||
|
||||
/* 10.1 Chipset Configuration registers(Memory Space)
|
||||
which is pointed by RCBA */
|
||||
uint8_t chip_config[ICH9_CC_SIZE];
|
||||
|
@ -90,6 +98,9 @@ Object *ich9_lpc_find(void);
|
|||
#define ICH9_CC_DIR_MASK 0x7
|
||||
#define ICH9_CC_OIC 0x31FF
|
||||
#define ICH9_CC_OIC_AEN 0x1
|
||||
#define ICH9_CC_GCS 0x3410
|
||||
#define ICH9_CC_GCS_DEFAULT 0x00000020
|
||||
#define ICH9_CC_GCS_NO_REBOOT (1 << 5)
|
||||
|
||||
/* D28:F[0-5] */
|
||||
#define ICH9_PCIE_DEV 28
|
||||
|
@ -186,7 +197,10 @@ Object *ich9_lpc_find(void);
|
|||
#define ICH9_PMIO_GPE0_LEN 16
|
||||
#define ICH9_PMIO_SMI_EN 0x30
|
||||
#define ICH9_PMIO_SMI_EN_APMC_EN (1 << 5)
|
||||
#define ICH9_PMIO_SMI_EN_TCO_EN (1 << 13)
|
||||
#define ICH9_PMIO_SMI_STS 0x34
|
||||
#define ICH9_PMIO_TCO_RLD 0x60
|
||||
#define ICH9_PMIO_TCO_LEN 32
|
||||
|
||||
/* FADT ACPI_ENABLE/ACPI_DISABLE */
|
||||
#define ICH9_APM_ACPI_ENABLE 0x2
|
||||
|
|
|
@ -88,6 +88,7 @@ typedef struct PcPciInfo {
|
|||
#define ACPI_PM_PROP_PM_IO_BASE "pm_io_base"
|
||||
#define ACPI_PM_PROP_GPE0_BLK "gpe0_blk"
|
||||
#define ACPI_PM_PROP_GPE0_BLK_LEN "gpe0_blk_len"
|
||||
#define ACPI_PM_PROP_TCO_ENABLED "enable_tco"
|
||||
|
||||
struct PcGuestInfo {
|
||||
bool isapc_ram_fw;
|
||||
|
@ -198,13 +199,12 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
|
|||
void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
|
||||
ISADevice **rtc_state,
|
||||
bool create_fdctrl,
|
||||
ISADevice **floppy,
|
||||
bool no_vmport,
|
||||
uint32 hpet_irqs);
|
||||
void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
|
||||
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
||||
const char *boot_device, MachineState *machine,
|
||||
ISADevice *floppy, BusState *ide0, BusState *ide1,
|
||||
BusState *ide0, BusState *ide1,
|
||||
ISADevice *s);
|
||||
void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus);
|
||||
void pc_pci_device_init(PCIBus *pci_bus);
|
||||
|
|
|
@ -1,719 +1 @@
|
|||
/*
|
||||
* pci_regs.h
|
||||
*
|
||||
* PCI standard defines
|
||||
* Copyright 1994, Drew Eckhardt
|
||||
* Copyright 1997--1999 Martin Mares <mj@ucw.cz>
|
||||
*
|
||||
* For more information, please consult the following manuals (look at
|
||||
* http://www.pcisig.com/ for how to get them):
|
||||
*
|
||||
* PCI BIOS Specification
|
||||
* PCI Local Bus Specification
|
||||
* PCI to PCI Bridge Specification
|
||||
* PCI System Design Guide
|
||||
*
|
||||
* For hypertransport information, please consult the following manuals
|
||||
* from http://www.hypertransport.org
|
||||
*
|
||||
* The Hypertransport I/O Link Specification
|
||||
*/
|
||||
|
||||
#ifndef LINUX_PCI_REGS_H
|
||||
#define LINUX_PCI_REGS_H
|
||||
|
||||
/*
|
||||
* Under PCI, each device has 256 bytes of configuration address space,
|
||||
* of which the first 64 bytes are standardized as follows:
|
||||
*/
|
||||
#define PCI_VENDOR_ID 0x00 /* 16 bits */
|
||||
#define PCI_DEVICE_ID 0x02 /* 16 bits */
|
||||
#define PCI_COMMAND 0x04 /* 16 bits */
|
||||
#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
|
||||
#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
|
||||
#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
|
||||
#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */
|
||||
#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */
|
||||
#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */
|
||||
#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */
|
||||
#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */
|
||||
#define PCI_COMMAND_SERR 0x100 /* Enable SERR */
|
||||
#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
|
||||
#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
|
||||
|
||||
#define PCI_STATUS 0x06 /* 16 bits */
|
||||
#define PCI_STATUS_INTERRUPT 0x08 /* Interrupt status */
|
||||
#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
|
||||
#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
|
||||
#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
|
||||
#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
|
||||
#define PCI_STATUS_PARITY 0x100 /* Detected parity error */
|
||||
#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
|
||||
#define PCI_STATUS_DEVSEL_FAST 0x000
|
||||
#define PCI_STATUS_DEVSEL_MEDIUM 0x200
|
||||
#define PCI_STATUS_DEVSEL_SLOW 0x400
|
||||
#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
|
||||
#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */
|
||||
#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */
|
||||
#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */
|
||||
#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */
|
||||
|
||||
#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */
|
||||
#define PCI_REVISION_ID 0x08 /* Revision ID */
|
||||
#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */
|
||||
#define PCI_CLASS_DEVICE 0x0a /* Device class */
|
||||
|
||||
#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */
|
||||
#define PCI_LATENCY_TIMER 0x0d /* 8 bits */
|
||||
#define PCI_HEADER_TYPE 0x0e /* 8 bits */
|
||||
#define PCI_HEADER_TYPE_NORMAL 0
|
||||
#define PCI_HEADER_TYPE_BRIDGE 1
|
||||
#define PCI_HEADER_TYPE_CARDBUS 2
|
||||
|
||||
#define PCI_BIST 0x0f /* 8 bits */
|
||||
#define PCI_BIST_CODE_MASK 0x0f /* Return result */
|
||||
#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */
|
||||
#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */
|
||||
|
||||
/*
|
||||
* Base addresses specify locations in memory or I/O space.
|
||||
* Decoded size can be determined by writing a value of
|
||||
* 0xffffffff to the register, and reading it back. Only
|
||||
* 1 bits are decoded.
|
||||
*/
|
||||
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */
|
||||
#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */
|
||||
#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */
|
||||
#define PCI_BASE_ADDRESS_SPACE_IO 0x01
|
||||
#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
|
||||
#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
|
||||
#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL)
|
||||
#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL)
|
||||
/* bit 1 is reserved if address_space = 1 */
|
||||
|
||||
/* Header type 0 (normal devices) */
|
||||
#define PCI_CARDBUS_CIS 0x28
|
||||
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
|
||||
#define PCI_SUBSYSTEM_ID 0x2e
|
||||
#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
|
||||
#define PCI_ROM_ADDRESS_ENABLE 0x01
|
||||
#define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
|
||||
|
||||
#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
|
||||
|
||||
/* 0x35-0x3b are reserved */
|
||||
#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
|
||||
#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
|
||||
#define PCI_MIN_GNT 0x3e /* 8 bits */
|
||||
#define PCI_MAX_LAT 0x3f /* 8 bits */
|
||||
|
||||
/* Header type 1 (PCI-to-PCI bridges) */
|
||||
#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
|
||||
#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
|
||||
#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
|
||||
#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */
|
||||
#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
|
||||
#define PCI_IO_LIMIT 0x1d
|
||||
#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */
|
||||
#define PCI_IO_RANGE_TYPE_16 0x00
|
||||
#define PCI_IO_RANGE_TYPE_32 0x01
|
||||
#define PCI_IO_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
|
||||
#define PCI_MEMORY_BASE 0x20 /* Memory range behind */
|
||||
#define PCI_MEMORY_LIMIT 0x22
|
||||
#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL
|
||||
#define PCI_MEMORY_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
|
||||
#define PCI_PREF_MEMORY_LIMIT 0x26
|
||||
#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL
|
||||
#define PCI_PREF_RANGE_TYPE_32 0x00
|
||||
#define PCI_PREF_RANGE_TYPE_64 0x01
|
||||
#define PCI_PREF_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
|
||||
#define PCI_PREF_LIMIT_UPPER32 0x2c
|
||||
#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
|
||||
#define PCI_IO_LIMIT_UPPER16 0x32
|
||||
/* 0x34 same as for htype 0 */
|
||||
/* 0x35-0x3b is reserved */
|
||||
#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
|
||||
/* 0x3c-0x3d are same as for htype 0 */
|
||||
#define PCI_BRIDGE_CONTROL 0x3e
|
||||
#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
|
||||
#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
|
||||
#define PCI_BRIDGE_CTL_ISA 0x04 /* Enable ISA mode */
|
||||
#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
|
||||
#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
|
||||
#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
|
||||
#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
|
||||
|
||||
/* Header type 2 (CardBus bridges) */
|
||||
#define PCI_CB_CAPABILITY_LIST 0x14
|
||||
/* 0x15 reserved */
|
||||
#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */
|
||||
#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */
|
||||
#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */
|
||||
#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */
|
||||
#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */
|
||||
#define PCI_CB_MEMORY_BASE_0 0x1c
|
||||
#define PCI_CB_MEMORY_LIMIT_0 0x20
|
||||
#define PCI_CB_MEMORY_BASE_1 0x24
|
||||
#define PCI_CB_MEMORY_LIMIT_1 0x28
|
||||
#define PCI_CB_IO_BASE_0 0x2c
|
||||
#define PCI_CB_IO_BASE_0_HI 0x2e
|
||||
#define PCI_CB_IO_LIMIT_0 0x30
|
||||
#define PCI_CB_IO_LIMIT_0_HI 0x32
|
||||
#define PCI_CB_IO_BASE_1 0x34
|
||||
#define PCI_CB_IO_BASE_1_HI 0x36
|
||||
#define PCI_CB_IO_LIMIT_1 0x38
|
||||
#define PCI_CB_IO_LIMIT_1_HI 0x3a
|
||||
#define PCI_CB_IO_RANGE_MASK (~0x03UL)
|
||||
/* 0x3c-0x3d are same as for htype 0 */
|
||||
#define PCI_CB_BRIDGE_CONTROL 0x3e
|
||||
#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */
|
||||
#define PCI_CB_BRIDGE_CTL_SERR 0x02
|
||||
#define PCI_CB_BRIDGE_CTL_ISA 0x04
|
||||
#define PCI_CB_BRIDGE_CTL_VGA 0x08
|
||||
#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20
|
||||
#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
|
||||
#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
|
||||
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */
|
||||
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
|
||||
#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
|
||||
#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40
|
||||
#define PCI_CB_SUBSYSTEM_ID 0x42
|
||||
#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */
|
||||
/* 0x48-0x7f reserved */
|
||||
|
||||
/* Capability lists */
|
||||
|
||||
#define PCI_CAP_LIST_ID 0 /* Capability ID */
|
||||
#define PCI_CAP_ID_PM 0x01 /* Power Management */
|
||||
#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */
|
||||
#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */
|
||||
#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */
|
||||
#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
|
||||
#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
|
||||
#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */
|
||||
#define PCI_CAP_ID_HT 0x08 /* HyperTransport */
|
||||
#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific */
|
||||
#define PCI_CAP_ID_DBG 0x0A /* Debug port */
|
||||
#define PCI_CAP_ID_CCRC 0x0B /* CompactPCI Central Resource Control */
|
||||
#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */
|
||||
#define PCI_CAP_ID_SSVID 0x0D /* Bridge subsystem vendor/device ID */
|
||||
#define PCI_CAP_ID_AGP3 0x0E /* AGP Target PCI-PCI bridge */
|
||||
#define PCI_CAP_ID_EXP 0x10 /* PCI Express */
|
||||
#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */
|
||||
#define PCI_CAP_ID_SATA 0x12 /* Serial ATA */
|
||||
#define PCI_CAP_ID_AF 0x13 /* PCI Advanced Features */
|
||||
#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
|
||||
#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */
|
||||
#define PCI_CAP_SIZEOF 4
|
||||
|
||||
/* Power Management Registers */
|
||||
|
||||
#define PCI_PM_PMC 2 /* PM Capabilities Register */
|
||||
#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
|
||||
#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
|
||||
#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
|
||||
#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
|
||||
#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxiliary power support mask */
|
||||
#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
|
||||
#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
|
||||
#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
|
||||
#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */
|
||||
#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */
|
||||
#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */
|
||||
#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */
|
||||
#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */
|
||||
#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */
|
||||
#define PCI_PM_CAP_PME_SHIFT 11 /* Start of the PME Mask in PMC */
|
||||
#define PCI_PM_CTRL 4 /* PM control and status register */
|
||||
#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
|
||||
#define PCI_PM_CTRL_NO_SOFT_RESET 0x0008 /* No reset for D3hot->D0 */
|
||||
#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
|
||||
#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
|
||||
#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
|
||||
#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
|
||||
#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
|
||||
#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
|
||||
#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
|
||||
#define PCI_PM_DATA_REGISTER 7 /* (??) */
|
||||
#define PCI_PM_SIZEOF 8
|
||||
|
||||
/* AGP registers */
|
||||
|
||||
#define PCI_AGP_VERSION 2 /* BCD version number */
|
||||
#define PCI_AGP_RFU 3 /* Rest of capability flags */
|
||||
#define PCI_AGP_STATUS 4 /* Status register */
|
||||
#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
|
||||
#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */
|
||||
#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
|
||||
#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */
|
||||
#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */
|
||||
#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */
|
||||
#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */
|
||||
#define PCI_AGP_COMMAND 8 /* Control register */
|
||||
#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */
|
||||
#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */
|
||||
#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */
|
||||
#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
|
||||
#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */
|
||||
#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */
|
||||
#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */
|
||||
#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */
|
||||
#define PCI_AGP_SIZEOF 12
|
||||
|
||||
/* Vital Product Data */
|
||||
|
||||
#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */
|
||||
#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */
|
||||
#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */
|
||||
#define PCI_VPD_DATA 4 /* 32-bits of data returned here */
|
||||
|
||||
/* Slot Identification */
|
||||
|
||||
#define PCI_SID_ESR 2 /* Expansion Slot Register */
|
||||
#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
|
||||
#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
|
||||
#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
|
||||
|
||||
/* Message Signalled Interrupts registers */
|
||||
|
||||
#define PCI_MSI_FLAGS 2 /* Various flags */
|
||||
#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
|
||||
#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */
|
||||
#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */
|
||||
#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */
|
||||
#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */
|
||||
#define PCI_MSI_RFU 3 /* Rest of capability flags */
|
||||
#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
|
||||
#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
|
||||
#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
|
||||
#define PCI_MSI_MASK_32 12 /* Mask bits register for 32-bit devices */
|
||||
#define PCI_MSI_PENDING_32 16 /* Pending bits register for 32-bit devices */
|
||||
#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
|
||||
#define PCI_MSI_MASK_64 16 /* Mask bits register for 64-bit devices */
|
||||
#define PCI_MSI_PENDING_64 20 /* Pending bits register for 32-bit devices */
|
||||
|
||||
/* MSI-X registers */
|
||||
#define PCI_MSIX_FLAGS 2
|
||||
#define PCI_MSIX_FLAGS_QSIZE 0x7FF
|
||||
#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
|
||||
#define PCI_MSIX_FLAGS_MASKALL (1 << 14)
|
||||
#define PCI_MSIX_TABLE 4
|
||||
#define PCI_MSIX_PBA 8
|
||||
#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
|
||||
|
||||
/* MSI-X entry's format */
|
||||
#define PCI_MSIX_ENTRY_SIZE 16
|
||||
#define PCI_MSIX_ENTRY_LOWER_ADDR 0
|
||||
#define PCI_MSIX_ENTRY_UPPER_ADDR 4
|
||||
#define PCI_MSIX_ENTRY_DATA 8
|
||||
#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
|
||||
#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
|
||||
|
||||
/* CompactPCI Hotswap Register */
|
||||
|
||||
#define PCI_CHSWP_CSR 2 /* Control and Status Register */
|
||||
#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */
|
||||
#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */
|
||||
#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */
|
||||
#define PCI_CHSWP_LOO 0x08 /* LED On / Off */
|
||||
#define PCI_CHSWP_PI 0x30 /* Programming Interface */
|
||||
#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */
|
||||
#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */
|
||||
|
||||
/* PCI Advanced Feature registers */
|
||||
|
||||
#define PCI_AF_LENGTH 2
|
||||
#define PCI_AF_CAP 3
|
||||
#define PCI_AF_CAP_TP 0x01
|
||||
#define PCI_AF_CAP_FLR 0x02
|
||||
#define PCI_AF_CTRL 4
|
||||
#define PCI_AF_CTRL_FLR 0x01
|
||||
#define PCI_AF_STATUS 5
|
||||
#define PCI_AF_STATUS_TP 0x01
|
||||
|
||||
/* PCI-X registers */
|
||||
|
||||
#define PCI_X_CMD 2 /* Modes & Features */
|
||||
#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */
|
||||
#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */
|
||||
#define PCI_X_CMD_READ_512 0x0000 /* 512 byte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_1K 0x0004 /* 1Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_2K 0x0008 /* 2Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_4K 0x000c /* 4Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */
|
||||
/* Max # of outstanding split transactions */
|
||||
#define PCI_X_CMD_SPLIT_1 0x0000 /* Max 1 */
|
||||
#define PCI_X_CMD_SPLIT_2 0x0010 /* Max 2 */
|
||||
#define PCI_X_CMD_SPLIT_3 0x0020 /* Max 3 */
|
||||
#define PCI_X_CMD_SPLIT_4 0x0030 /* Max 4 */
|
||||
#define PCI_X_CMD_SPLIT_8 0x0040 /* Max 8 */
|
||||
#define PCI_X_CMD_SPLIT_12 0x0050 /* Max 12 */
|
||||
#define PCI_X_CMD_SPLIT_16 0x0060 /* Max 16 */
|
||||
#define PCI_X_CMD_SPLIT_32 0x0070 /* Max 32 */
|
||||
#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */
|
||||
#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */
|
||||
#define PCI_X_STATUS 4 /* PCI-X capabilities */
|
||||
#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */
|
||||
#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */
|
||||
#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */
|
||||
#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */
|
||||
#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */
|
||||
#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */
|
||||
#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */
|
||||
#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */
|
||||
#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */
|
||||
#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */
|
||||
#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */
|
||||
#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */
|
||||
#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */
|
||||
|
||||
/* PCI Bridge Subsystem ID registers */
|
||||
|
||||
#define PCI_SSVID_VENDOR_ID 4 /* PCI-Bridge subsystem vendor id register */
|
||||
#define PCI_SSVID_DEVICE_ID 6 /* PCI-Bridge subsystem device id register */
|
||||
|
||||
/* PCI Express capability registers */
|
||||
|
||||
#define PCI_EXP_FLAGS 2 /* Capabilities register */
|
||||
#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */
|
||||
#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */
|
||||
#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */
|
||||
#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */
|
||||
#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */
|
||||
#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */
|
||||
#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */
|
||||
#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */
|
||||
#define PCI_EXP_TYPE_PCIE_BRIDGE 0x8 /* PCI/PCI-X to PCIE Bridge */
|
||||
#define PCI_EXP_TYPE_RC_END 0x9 /* Root Complex Integrated Endpoint */
|
||||
#define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */
|
||||
#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */
|
||||
#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */
|
||||
#define PCI_EXP_DEVCAP 4 /* Device capabilities */
|
||||
#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */
|
||||
#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */
|
||||
#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */
|
||||
#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */
|
||||
#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */
|
||||
#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
|
||||
#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
|
||||
#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
|
||||
#define PCI_EXP_DEVCAP_RBER 0x8000 /* Role-Based Error Reporting */
|
||||
#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
|
||||
#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
|
||||
#define PCI_EXP_DEVCAP_FLR 0x10000000 /* Function Level Reset */
|
||||
#define PCI_EXP_DEVCTL 8 /* Device Control */
|
||||
#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */
|
||||
#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
|
||||
#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */
|
||||
#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */
|
||||
#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
|
||||
#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */
|
||||
#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
|
||||
#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */
|
||||
#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
|
||||
#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */
|
||||
#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */
|
||||
#define PCI_EXP_DEVCTL_BCR_FLR 0x8000 /* Bridge Configuration Retry / FLR */
|
||||
#define PCI_EXP_DEVSTA 10 /* Device Status */
|
||||
#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */
|
||||
#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */
|
||||
#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */
|
||||
#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */
|
||||
#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
|
||||
#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
|
||||
#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
|
||||
#define PCI_EXP_LNKCAP_SLS 0x0000000f /* Supported Link Speeds */
|
||||
#define PCI_EXP_LNKCAP_MLW 0x000003f0 /* Maximum Link Width */
|
||||
#define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */
|
||||
#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */
|
||||
#define PCI_EXP_LNKCAP_L1EL 0x00038000 /* L1 Exit Latency */
|
||||
#define PCI_EXP_LNKCAP_CLKPM 0x00040000 /* L1 Clock Power Management */
|
||||
#define PCI_EXP_LNKCAP_SDERC 0x00080000 /* Surprise Down Error Reporting Capable */
|
||||
#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */
|
||||
#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */
|
||||
#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */
|
||||
#define PCI_EXP_LNKCTL 16 /* Link Control */
|
||||
#define PCI_EXP_LNKCTL_ASPMC 0x0003 /* ASPM Control */
|
||||
#define PCI_EXP_LNKCTL_RCB 0x0008 /* Read Completion Boundary */
|
||||
#define PCI_EXP_LNKCTL_LD 0x0010 /* Link Disable */
|
||||
#define PCI_EXP_LNKCTL_RL 0x0020 /* Retrain Link */
|
||||
#define PCI_EXP_LNKCTL_CCC 0x0040 /* Common Clock Configuration */
|
||||
#define PCI_EXP_LNKCTL_ES 0x0080 /* Extended Synch */
|
||||
#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */
|
||||
#define PCI_EXP_LNKCTL_HAWD 0x0200 /* Hardware Autonomous Width Disable */
|
||||
#define PCI_EXP_LNKCTL_LBMIE 0x0400 /* Link Bandwidth Management Interrupt Enable */
|
||||
#define PCI_EXP_LNKCTL_LABIE 0x0800 /* Lnk Autonomous Bandwidth Interrupt Enable */
|
||||
#define PCI_EXP_LNKSTA 18 /* Link Status */
|
||||
#define PCI_EXP_LNKSTA_CLS 0x000f /* Current Link Speed */
|
||||
#define PCI_EXP_LNKSTA_CLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */
|
||||
#define PCI_EXP_LNKSTA_CLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */
|
||||
#define PCI_EXP_LNKSTA_NLW 0x03f0 /* Nogotiated Link Width */
|
||||
#define PCI_EXP_LNKSTA_NLW_SHIFT 4 /* start of NLW mask in link status */
|
||||
#define PCI_EXP_LNKSTA_LT 0x0800 /* Link Training */
|
||||
#define PCI_EXP_LNKSTA_SLC 0x1000 /* Slot Clock Configuration */
|
||||
#define PCI_EXP_LNKSTA_DLLLA 0x2000 /* Data Link Layer Link Active */
|
||||
#define PCI_EXP_LNKSTA_LBMS 0x4000 /* Link Bandwidth Management Status */
|
||||
#define PCI_EXP_LNKSTA_LABS 0x8000 /* Link Autonomous Bandwidth Status */
|
||||
#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
|
||||
#define PCI_EXP_SLTCAP_ABP 0x00000001 /* Attention Button Present */
|
||||
#define PCI_EXP_SLTCAP_PCP 0x00000002 /* Power Controller Present */
|
||||
#define PCI_EXP_SLTCAP_MRLSP 0x00000004 /* MRL Sensor Present */
|
||||
#define PCI_EXP_SLTCAP_AIP 0x00000008 /* Attention Indicator Present */
|
||||
#define PCI_EXP_SLTCAP_PIP 0x00000010 /* Power Indicator Present */
|
||||
#define PCI_EXP_SLTCAP_HPS 0x00000020 /* Hot-Plug Surprise */
|
||||
#define PCI_EXP_SLTCAP_HPC 0x00000040 /* Hot-Plug Capable */
|
||||
#define PCI_EXP_SLTCAP_SPLV 0x00007f80 /* Slot Power Limit Value */
|
||||
#define PCI_EXP_SLTCAP_SPLS 0x00018000 /* Slot Power Limit Scale */
|
||||
#define PCI_EXP_SLTCAP_EIP 0x00020000 /* Electromechanical Interlock Present */
|
||||
#define PCI_EXP_SLTCAP_NCCS 0x00040000 /* No Command Completed Support */
|
||||
#define PCI_EXP_SLTCAP_PSN 0xfff80000 /* Physical Slot Number */
|
||||
#define PCI_EXP_SLTCTL 24 /* Slot Control */
|
||||
#define PCI_EXP_SLTCTL_ABPE 0x0001 /* Attention Button Pressed Enable */
|
||||
#define PCI_EXP_SLTCTL_PFDE 0x0002 /* Power Fault Detected Enable */
|
||||
#define PCI_EXP_SLTCTL_MRLSCE 0x0004 /* MRL Sensor Changed Enable */
|
||||
#define PCI_EXP_SLTCTL_PDCE 0x0008 /* Presence Detect Changed Enable */
|
||||
#define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */
|
||||
#define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */
|
||||
#define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */
|
||||
#define PCI_EXP_SLTCTL_PIC 0x0300 /* Power Indicator Control */
|
||||
#define PCI_EXP_SLTCTL_PCC 0x0400 /* Power Controller Control */
|
||||
#define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */
|
||||
#define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */
|
||||
#define PCI_EXP_SLTSTA 26 /* Slot Status */
|
||||
#define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */
|
||||
#define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */
|
||||
#define PCI_EXP_SLTSTA_MRLSC 0x0004 /* MRL Sensor Changed */
|
||||
#define PCI_EXP_SLTSTA_PDC 0x0008 /* Presence Detect Changed */
|
||||
#define PCI_EXP_SLTSTA_CC 0x0010 /* Command Completed */
|
||||
#define PCI_EXP_SLTSTA_MRLSS 0x0020 /* MRL Sensor State */
|
||||
#define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */
|
||||
#define PCI_EXP_SLTSTA_EIS 0x0080 /* Electromechanical Interlock Status */
|
||||
#define PCI_EXP_SLTSTA_DLLSC 0x0100 /* Data Link Layer State Changed */
|
||||
#define PCI_EXP_RTCTL 28 /* Root Control */
|
||||
#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */
|
||||
#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */
|
||||
#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */
|
||||
#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */
|
||||
#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
|
||||
#define PCI_EXP_RTCAP 30 /* Root Capabilities */
|
||||
#define PCI_EXP_RTSTA 32 /* Root Status */
|
||||
#define PCI_EXP_RTSTA_PME 0x10000 /* PME status */
|
||||
#define PCI_EXP_RTSTA_PENDING 0x20000 /* PME pending */
|
||||
#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
|
||||
#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#define PCI_EXP_DEVCAP2_LTR 0x800 /* Latency tolerance reporting */
|
||||
#define PCI_EXP_OBFF_MASK 0xc0000 /* OBFF support mechanism */
|
||||
#define PCI_EXP_OBFF_MSG 0x40000 /* New message signaling */
|
||||
#define PCI_EXP_OBFF_WAKE 0x80000 /* Re-use WAKE# for OBFF */
|
||||
#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
|
||||
#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#define PCI_EXP_IDO_REQ_EN 0x100 /* ID-based ordering request enable */
|
||||
#define PCI_EXP_IDO_CMP_EN 0x200 /* ID-based ordering completion enable */
|
||||
#define PCI_EXP_LTR_EN 0x400 /* Latency tolerance reporting */
|
||||
#define PCI_EXP_OBFF_MSGA_EN 0x2000 /* OBFF enable with Message type A */
|
||||
#define PCI_EXP_OBFF_MSGB_EN 0x4000 /* OBFF enable with Message type B */
|
||||
#define PCI_EXP_OBFF_WAKE_EN 0x6000 /* OBFF using WAKE# signaling */
|
||||
#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
|
||||
#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */
|
||||
|
||||
/* Extended Capabilities (PCI-X 2.0 and Express) */
|
||||
#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
|
||||
#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf)
|
||||
#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
|
||||
|
||||
#define PCI_EXT_CAP_ID_ERR 1
|
||||
#define PCI_EXT_CAP_ID_VC 2
|
||||
#define PCI_EXT_CAP_ID_DSN 3
|
||||
#define PCI_EXT_CAP_ID_PWR 4
|
||||
#define PCI_EXT_CAP_ID_VNDR 11
|
||||
#define PCI_EXT_CAP_ID_ACS 13
|
||||
#define PCI_EXT_CAP_ID_ARI 14
|
||||
#define PCI_EXT_CAP_ID_ATS 15
|
||||
#define PCI_EXT_CAP_ID_SRIOV 16
|
||||
#define PCI_EXT_CAP_ID_LTR 24
|
||||
|
||||
/* Advanced Error Reporting */
|
||||
#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */
|
||||
#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */
|
||||
#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */
|
||||
#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */
|
||||
#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */
|
||||
#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */
|
||||
#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */
|
||||
#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */
|
||||
#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */
|
||||
#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */
|
||||
#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */
|
||||
#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */
|
||||
#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */
|
||||
#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */
|
||||
#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */
|
||||
#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */
|
||||
#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */
|
||||
#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */
|
||||
#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */
|
||||
#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */
|
||||
#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */
|
||||
#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */
|
||||
#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */
|
||||
#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */
|
||||
#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */
|
||||
#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */
|
||||
/* Correctable Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_COR_EN 0x00000001
|
||||
/* Non-fatal Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_NONFATAL_EN 0x00000002
|
||||
/* Fatal Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_FATAL_EN 0x00000004
|
||||
#define PCI_ERR_ROOT_STATUS 48
|
||||
#define PCI_ERR_ROOT_COR_RCV 0x00000001 /* ERR_COR Received */
|
||||
/* Multi ERR_COR Received */
|
||||
#define PCI_ERR_ROOT_MULTI_COR_RCV 0x00000002
|
||||
/* ERR_FATAL/NONFATAL Recevied */
|
||||
#define PCI_ERR_ROOT_UNCOR_RCV 0x00000004
|
||||
/* Multi ERR_FATAL/NONFATAL Recevied */
|
||||
#define PCI_ERR_ROOT_MULTI_UNCOR_RCV 0x00000008
|
||||
#define PCI_ERR_ROOT_FIRST_FATAL 0x00000010 /* First Fatal */
|
||||
#define PCI_ERR_ROOT_NONFATAL_RCV 0x00000020 /* Non-Fatal Received */
|
||||
#define PCI_ERR_ROOT_FATAL_RCV 0x00000040 /* Fatal Received */
|
||||
#define PCI_ERR_ROOT_ERR_SRC 52 /* Error Source Identification */
|
||||
|
||||
/* Virtual Channel */
|
||||
#define PCI_VC_PORT_REG1 4
|
||||
#define PCI_VC_PORT_REG2 8
|
||||
#define PCI_VC_PORT_CTRL 12
|
||||
#define PCI_VC_PORT_STATUS 14
|
||||
#define PCI_VC_RES_CAP 16
|
||||
#define PCI_VC_RES_CTRL 20
|
||||
#define PCI_VC_RES_STATUS 26
|
||||
|
||||
/* Power Budgeting */
|
||||
#define PCI_PWR_DSR 4 /* Data Select Register */
|
||||
#define PCI_PWR_DATA 8 /* Data Register */
|
||||
#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */
|
||||
#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */
|
||||
#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */
|
||||
#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */
|
||||
#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */
|
||||
#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */
|
||||
#define PCI_PWR_CAP 12 /* Capability */
|
||||
#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */
|
||||
|
||||
/*
|
||||
* Hypertransport sub capability types
|
||||
*
|
||||
* Unfortunately there are both 3 bit and 5 bit capability types defined
|
||||
* in the HT spec, catering for that is a little messy. You probably don't
|
||||
* want to use these directly, just use pci_find_ht_capability() and it
|
||||
* will do the right thing for you.
|
||||
*/
|
||||
#define HT_3BIT_CAP_MASK 0xE0
|
||||
#define HT_CAPTYPE_SLAVE 0x00 /* Slave/Primary link configuration */
|
||||
#define HT_CAPTYPE_HOST 0x20 /* Host/Secondary link configuration */
|
||||
|
||||
#define HT_5BIT_CAP_MASK 0xF8
|
||||
#define HT_CAPTYPE_IRQ 0x80 /* IRQ Configuration */
|
||||
#define HT_CAPTYPE_REMAPPING_40 0xA0 /* 40 bit address remapping */
|
||||
#define HT_CAPTYPE_REMAPPING_64 0xA2 /* 64 bit address remapping */
|
||||
#define HT_CAPTYPE_UNITID_CLUMP 0x90 /* Unit ID clumping */
|
||||
#define HT_CAPTYPE_EXTCONF 0x98 /* Extended Configuration Space Access */
|
||||
#define HT_CAPTYPE_MSI_MAPPING 0xA8 /* MSI Mapping Capability */
|
||||
#define HT_MSI_FLAGS 0x02 /* Offset to flags */
|
||||
#define HT_MSI_FLAGS_ENABLE 0x1 /* Mapping enable */
|
||||
#define HT_MSI_FLAGS_FIXED 0x2 /* Fixed mapping only */
|
||||
#define HT_MSI_FIXED_ADDR 0x00000000FEE00000ULL /* Fixed addr */
|
||||
#define HT_MSI_ADDR_LO 0x04 /* Offset to low addr bits */
|
||||
#define HT_MSI_ADDR_LO_MASK 0xFFF00000 /* Low address bit mask */
|
||||
#define HT_MSI_ADDR_HI 0x08 /* Offset to high addr bits */
|
||||
#define HT_CAPTYPE_DIRECT_ROUTE 0xB0 /* Direct routing configuration */
|
||||
#define HT_CAPTYPE_VCSET 0xB8 /* Virtual Channel configuration */
|
||||
#define HT_CAPTYPE_ERROR_RETRY 0xC0 /* Retry on error configuration */
|
||||
#define HT_CAPTYPE_GEN3 0xD0 /* Generation 3 hypertransport configuration */
|
||||
#define HT_CAPTYPE_PM 0xE0 /* Hypertransport powermanagement configuration */
|
||||
|
||||
/* Alternative Routing-ID Interpretation */
|
||||
#define PCI_ARI_CAP 0x04 /* ARI Capability Register */
|
||||
#define PCI_ARI_CAP_MFVC 0x0001 /* MFVC Function Groups Capability */
|
||||
#define PCI_ARI_CAP_ACS 0x0002 /* ACS Function Groups Capability */
|
||||
#define PCI_ARI_CAP_NFN(x) (((x) >> 8) & 0xff) /* Next Function Number */
|
||||
#define PCI_ARI_CTRL 0x06 /* ARI Control Register */
|
||||
#define PCI_ARI_CTRL_MFVC 0x0001 /* MFVC Function Groups Enable */
|
||||
#define PCI_ARI_CTRL_ACS 0x0002 /* ACS Function Groups Enable */
|
||||
#define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7) /* Function Group */
|
||||
|
||||
/* Address Translation Service */
|
||||
#define PCI_ATS_CAP 0x04 /* ATS Capability Register */
|
||||
#define PCI_ATS_CAP_QDEP(x) ((x) & 0x1f) /* Invalidate Queue Depth */
|
||||
#define PCI_ATS_MAX_QDEP 32 /* Max Invalidate Queue Depth */
|
||||
#define PCI_ATS_CTRL 0x06 /* ATS Control Register */
|
||||
#define PCI_ATS_CTRL_ENABLE 0x8000 /* ATS Enable */
|
||||
#define PCI_ATS_CTRL_STU(x) ((x) & 0x1f) /* Smallest Translation Unit */
|
||||
#define PCI_ATS_MIN_STU 12 /* shift of minimum STU block */
|
||||
|
||||
/* Single Root I/O Virtualization */
|
||||
#define PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */
|
||||
#define PCI_SRIOV_CAP_VFM 0x01 /* VF Migration Capable */
|
||||
#define PCI_SRIOV_CAP_INTR(x) ((x) >> 21) /* Interrupt Message Number */
|
||||
#define PCI_SRIOV_CTRL 0x08 /* SR-IOV Control */
|
||||
#define PCI_SRIOV_CTRL_VFE 0x01 /* VF Enable */
|
||||
#define PCI_SRIOV_CTRL_VFM 0x02 /* VF Migration Enable */
|
||||
#define PCI_SRIOV_CTRL_INTR 0x04 /* VF Migration Interrupt Enable */
|
||||
#define PCI_SRIOV_CTRL_MSE 0x08 /* VF Memory Space Enable */
|
||||
#define PCI_SRIOV_CTRL_ARI 0x10 /* ARI Capable Hierarchy */
|
||||
#define PCI_SRIOV_STATUS 0x0a /* SR-IOV Status */
|
||||
#define PCI_SRIOV_STATUS_VFM 0x01 /* VF Migration Status */
|
||||
#define PCI_SRIOV_INITIAL_VF 0x0c /* Initial VFs */
|
||||
#define PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
|
||||
#define PCI_SRIOV_NUM_VF 0x10 /* Number of VFs */
|
||||
#define PCI_SRIOV_FUNC_LINK 0x12 /* Function Dependency Link */
|
||||
#define PCI_SRIOV_VF_OFFSET 0x14 /* First VF Offset */
|
||||
#define PCI_SRIOV_VF_STRIDE 0x16 /* Following VF Stride */
|
||||
#define PCI_SRIOV_VF_DID 0x1a /* VF Device ID */
|
||||
#define PCI_SRIOV_SUP_PGSIZE 0x1c /* Supported Page Sizes */
|
||||
#define PCI_SRIOV_SYS_PGSIZE 0x20 /* System Page Size */
|
||||
#define PCI_SRIOV_BAR 0x24 /* VF BAR0 */
|
||||
#define PCI_SRIOV_NUM_BARS 6 /* Number of VF BARs */
|
||||
#define PCI_SRIOV_VFM 0x3c /* VF Migration State Array Offset*/
|
||||
#define PCI_SRIOV_VFM_BIR(x) ((x) & 7) /* State BIR */
|
||||
#define PCI_SRIOV_VFM_OFFSET(x) ((x) & ~7) /* State Offset */
|
||||
#define PCI_SRIOV_VFM_UA 0x0 /* Inactive.Unavailable */
|
||||
#define PCI_SRIOV_VFM_MI 0x1 /* Dormant.MigrateIn */
|
||||
#define PCI_SRIOV_VFM_MO 0x2 /* Active.MigrateOut */
|
||||
#define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */
|
||||
|
||||
#define PCI_LTR_MAX_SNOOP_LAT 0x4
|
||||
#define PCI_LTR_MAX_NOSNOOP_LAT 0x6
|
||||
#define PCI_LTR_VALUE_MASK 0x000003ff
|
||||
#define PCI_LTR_SCALE_MASK 0x00001c00
|
||||
#define PCI_LTR_SCALE_SHIFT 10
|
||||
|
||||
/* Access Control Service */
|
||||
#define PCI_ACS_CAP 0x04 /* ACS Capability Register */
|
||||
#define PCI_ACS_SV 0x01 /* Source Validation */
|
||||
#define PCI_ACS_TB 0x02 /* Translation Blocking */
|
||||
#define PCI_ACS_RR 0x04 /* P2P Request Redirect */
|
||||
#define PCI_ACS_CR 0x08 /* P2P Completion Redirect */
|
||||
#define PCI_ACS_UF 0x10 /* Upstream Forwarding */
|
||||
#define PCI_ACS_EC 0x20 /* P2P Egress Control */
|
||||
#define PCI_ACS_DT 0x40 /* Direct Translated P2P */
|
||||
#define PCI_ACS_CTRL 0x06 /* ACS Control Register */
|
||||
#define PCI_ACS_EGRESS_CTL_V 0x08 /* ACS Egress Control Vector */
|
||||
|
||||
#endif /* LINUX_PCI_REGS_H */
|
||||
#include "standard-headers/linux/pci_regs.h"
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
#define VIRTIO_NET(obj) \
|
||||
OBJECT_CHECK(VirtIONet, (obj), TYPE_VIRTIO_NET)
|
||||
|
||||
#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Control channel offload
|
||||
* configuration support */
|
||||
|
||||
#define TX_TIMER_INTERVAL 150000 /* 150 us */
|
||||
|
||||
/* Limit the number of packets that can be sent via a single flush
|
||||
|
@ -100,15 +97,6 @@ typedef struct VirtIONet {
|
|||
int announce_counter;
|
||||
} VirtIONet;
|
||||
|
||||
/*
|
||||
* Control network offloads
|
||||
*
|
||||
* Dynamic offloads are available with the
|
||||
* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit.
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
|
||||
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
|
||||
|
||||
void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
|
||||
const char *type);
|
||||
|
||||
|
|
|
@ -0,0 +1,719 @@
|
|||
/*
|
||||
* pci_regs.h
|
||||
*
|
||||
* PCI standard defines
|
||||
* Copyright 1994, Drew Eckhardt
|
||||
* Copyright 1997--1999 Martin Mares <mj@ucw.cz>
|
||||
*
|
||||
* For more information, please consult the following manuals (look at
|
||||
* http://www.pcisig.com/ for how to get them):
|
||||
*
|
||||
* PCI BIOS Specification
|
||||
* PCI Local Bus Specification
|
||||
* PCI to PCI Bridge Specification
|
||||
* PCI System Design Guide
|
||||
*
|
||||
* For hypertransport information, please consult the following manuals
|
||||
* from http://www.hypertransport.org
|
||||
*
|
||||
* The Hypertransport I/O Link Specification
|
||||
*/
|
||||
|
||||
#ifndef LINUX_PCI_REGS_H
|
||||
#define LINUX_PCI_REGS_H
|
||||
|
||||
/*
|
||||
* Under PCI, each device has 256 bytes of configuration address space,
|
||||
* of which the first 64 bytes are standardized as follows:
|
||||
*/
|
||||
#define PCI_VENDOR_ID 0x00 /* 16 bits */
|
||||
#define PCI_DEVICE_ID 0x02 /* 16 bits */
|
||||
#define PCI_COMMAND 0x04 /* 16 bits */
|
||||
#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
|
||||
#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
|
||||
#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
|
||||
#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */
|
||||
#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */
|
||||
#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */
|
||||
#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */
|
||||
#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */
|
||||
#define PCI_COMMAND_SERR 0x100 /* Enable SERR */
|
||||
#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
|
||||
#define PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
|
||||
|
||||
#define PCI_STATUS 0x06 /* 16 bits */
|
||||
#define PCI_STATUS_INTERRUPT 0x08 /* Interrupt status */
|
||||
#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
|
||||
#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
|
||||
#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
|
||||
#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
|
||||
#define PCI_STATUS_PARITY 0x100 /* Detected parity error */
|
||||
#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
|
||||
#define PCI_STATUS_DEVSEL_FAST 0x000
|
||||
#define PCI_STATUS_DEVSEL_MEDIUM 0x200
|
||||
#define PCI_STATUS_DEVSEL_SLOW 0x400
|
||||
#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
|
||||
#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */
|
||||
#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */
|
||||
#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */
|
||||
#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */
|
||||
|
||||
#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */
|
||||
#define PCI_REVISION_ID 0x08 /* Revision ID */
|
||||
#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */
|
||||
#define PCI_CLASS_DEVICE 0x0a /* Device class */
|
||||
|
||||
#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */
|
||||
#define PCI_LATENCY_TIMER 0x0d /* 8 bits */
|
||||
#define PCI_HEADER_TYPE 0x0e /* 8 bits */
|
||||
#define PCI_HEADER_TYPE_NORMAL 0
|
||||
#define PCI_HEADER_TYPE_BRIDGE 1
|
||||
#define PCI_HEADER_TYPE_CARDBUS 2
|
||||
|
||||
#define PCI_BIST 0x0f /* 8 bits */
|
||||
#define PCI_BIST_CODE_MASK 0x0f /* Return result */
|
||||
#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */
|
||||
#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */
|
||||
|
||||
/*
|
||||
* Base addresses specify locations in memory or I/O space.
|
||||
* Decoded size can be determined by writing a value of
|
||||
* 0xffffffff to the register, and reading it back. Only
|
||||
* 1 bits are decoded.
|
||||
*/
|
||||
#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */
|
||||
#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */
|
||||
#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
|
||||
#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */
|
||||
#define PCI_BASE_ADDRESS_SPACE_IO 0x01
|
||||
#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
|
||||
#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
|
||||
#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
|
||||
#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL)
|
||||
#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL)
|
||||
/* bit 1 is reserved if address_space = 1 */
|
||||
|
||||
/* Header type 0 (normal devices) */
|
||||
#define PCI_CARDBUS_CIS 0x28
|
||||
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
|
||||
#define PCI_SUBSYSTEM_ID 0x2e
|
||||
#define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
|
||||
#define PCI_ROM_ADDRESS_ENABLE 0x01
|
||||
#define PCI_ROM_ADDRESS_MASK (~0x7ffUL)
|
||||
|
||||
#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
|
||||
|
||||
/* 0x35-0x3b are reserved */
|
||||
#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
|
||||
#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
|
||||
#define PCI_MIN_GNT 0x3e /* 8 bits */
|
||||
#define PCI_MAX_LAT 0x3f /* 8 bits */
|
||||
|
||||
/* Header type 1 (PCI-to-PCI bridges) */
|
||||
#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
|
||||
#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
|
||||
#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
|
||||
#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */
|
||||
#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
|
||||
#define PCI_IO_LIMIT 0x1d
|
||||
#define PCI_IO_RANGE_TYPE_MASK 0x0fUL /* I/O bridging type */
|
||||
#define PCI_IO_RANGE_TYPE_16 0x00
|
||||
#define PCI_IO_RANGE_TYPE_32 0x01
|
||||
#define PCI_IO_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
|
||||
#define PCI_MEMORY_BASE 0x20 /* Memory range behind */
|
||||
#define PCI_MEMORY_LIMIT 0x22
|
||||
#define PCI_MEMORY_RANGE_TYPE_MASK 0x0fUL
|
||||
#define PCI_MEMORY_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
|
||||
#define PCI_PREF_MEMORY_LIMIT 0x26
|
||||
#define PCI_PREF_RANGE_TYPE_MASK 0x0fUL
|
||||
#define PCI_PREF_RANGE_TYPE_32 0x00
|
||||
#define PCI_PREF_RANGE_TYPE_64 0x01
|
||||
#define PCI_PREF_RANGE_MASK (~0x0fUL)
|
||||
#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
|
||||
#define PCI_PREF_LIMIT_UPPER32 0x2c
|
||||
#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
|
||||
#define PCI_IO_LIMIT_UPPER16 0x32
|
||||
/* 0x34 same as for htype 0 */
|
||||
/* 0x35-0x3b is reserved */
|
||||
#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
|
||||
/* 0x3c-0x3d are same as for htype 0 */
|
||||
#define PCI_BRIDGE_CONTROL 0x3e
|
||||
#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
|
||||
#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
|
||||
#define PCI_BRIDGE_CTL_ISA 0x04 /* Enable ISA mode */
|
||||
#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
|
||||
#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
|
||||
#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
|
||||
#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
|
||||
|
||||
/* Header type 2 (CardBus bridges) */
|
||||
#define PCI_CB_CAPABILITY_LIST 0x14
|
||||
/* 0x15 reserved */
|
||||
#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */
|
||||
#define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */
|
||||
#define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */
|
||||
#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */
|
||||
#define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */
|
||||
#define PCI_CB_MEMORY_BASE_0 0x1c
|
||||
#define PCI_CB_MEMORY_LIMIT_0 0x20
|
||||
#define PCI_CB_MEMORY_BASE_1 0x24
|
||||
#define PCI_CB_MEMORY_LIMIT_1 0x28
|
||||
#define PCI_CB_IO_BASE_0 0x2c
|
||||
#define PCI_CB_IO_BASE_0_HI 0x2e
|
||||
#define PCI_CB_IO_LIMIT_0 0x30
|
||||
#define PCI_CB_IO_LIMIT_0_HI 0x32
|
||||
#define PCI_CB_IO_BASE_1 0x34
|
||||
#define PCI_CB_IO_BASE_1_HI 0x36
|
||||
#define PCI_CB_IO_LIMIT_1 0x38
|
||||
#define PCI_CB_IO_LIMIT_1_HI 0x3a
|
||||
#define PCI_CB_IO_RANGE_MASK (~0x03UL)
|
||||
/* 0x3c-0x3d are same as for htype 0 */
|
||||
#define PCI_CB_BRIDGE_CONTROL 0x3e
|
||||
#define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */
|
||||
#define PCI_CB_BRIDGE_CTL_SERR 0x02
|
||||
#define PCI_CB_BRIDGE_CTL_ISA 0x04
|
||||
#define PCI_CB_BRIDGE_CTL_VGA 0x08
|
||||
#define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20
|
||||
#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
|
||||
#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
|
||||
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */
|
||||
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
|
||||
#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
|
||||
#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40
|
||||
#define PCI_CB_SUBSYSTEM_ID 0x42
|
||||
#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */
|
||||
/* 0x48-0x7f reserved */
|
||||
|
||||
/* Capability lists */
|
||||
|
||||
#define PCI_CAP_LIST_ID 0 /* Capability ID */
|
||||
#define PCI_CAP_ID_PM 0x01 /* Power Management */
|
||||
#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */
|
||||
#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */
|
||||
#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */
|
||||
#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
|
||||
#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
|
||||
#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */
|
||||
#define PCI_CAP_ID_HT 0x08 /* HyperTransport */
|
||||
#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific */
|
||||
#define PCI_CAP_ID_DBG 0x0A /* Debug port */
|
||||
#define PCI_CAP_ID_CCRC 0x0B /* CompactPCI Central Resource Control */
|
||||
#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */
|
||||
#define PCI_CAP_ID_SSVID 0x0D /* Bridge subsystem vendor/device ID */
|
||||
#define PCI_CAP_ID_AGP3 0x0E /* AGP Target PCI-PCI bridge */
|
||||
#define PCI_CAP_ID_EXP 0x10 /* PCI Express */
|
||||
#define PCI_CAP_ID_MSIX 0x11 /* MSI-X */
|
||||
#define PCI_CAP_ID_SATA 0x12 /* Serial ATA */
|
||||
#define PCI_CAP_ID_AF 0x13 /* PCI Advanced Features */
|
||||
#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
|
||||
#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */
|
||||
#define PCI_CAP_SIZEOF 4
|
||||
|
||||
/* Power Management Registers */
|
||||
|
||||
#define PCI_PM_PMC 2 /* PM Capabilities Register */
|
||||
#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
|
||||
#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
|
||||
#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
|
||||
#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
|
||||
#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxiliary power support mask */
|
||||
#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
|
||||
#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
|
||||
#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
|
||||
#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */
|
||||
#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */
|
||||
#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */
|
||||
#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */
|
||||
#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */
|
||||
#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */
|
||||
#define PCI_PM_CAP_PME_SHIFT 11 /* Start of the PME Mask in PMC */
|
||||
#define PCI_PM_CTRL 4 /* PM control and status register */
|
||||
#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
|
||||
#define PCI_PM_CTRL_NO_SOFT_RESET 0x0008 /* No reset for D3hot->D0 */
|
||||
#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
|
||||
#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
|
||||
#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
|
||||
#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
|
||||
#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
|
||||
#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
|
||||
#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
|
||||
#define PCI_PM_DATA_REGISTER 7 /* (??) */
|
||||
#define PCI_PM_SIZEOF 8
|
||||
|
||||
/* AGP registers */
|
||||
|
||||
#define PCI_AGP_VERSION 2 /* BCD version number */
|
||||
#define PCI_AGP_RFU 3 /* Rest of capability flags */
|
||||
#define PCI_AGP_STATUS 4 /* Status register */
|
||||
#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
|
||||
#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */
|
||||
#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
|
||||
#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */
|
||||
#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */
|
||||
#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */
|
||||
#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */
|
||||
#define PCI_AGP_COMMAND 8 /* Control register */
|
||||
#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */
|
||||
#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */
|
||||
#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */
|
||||
#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
|
||||
#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */
|
||||
#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */
|
||||
#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */
|
||||
#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */
|
||||
#define PCI_AGP_SIZEOF 12
|
||||
|
||||
/* Vital Product Data */
|
||||
|
||||
#define PCI_VPD_ADDR 2 /* Address to access (15 bits!) */
|
||||
#define PCI_VPD_ADDR_MASK 0x7fff /* Address mask */
|
||||
#define PCI_VPD_ADDR_F 0x8000 /* Write 0, 1 indicates completion */
|
||||
#define PCI_VPD_DATA 4 /* 32-bits of data returned here */
|
||||
|
||||
/* Slot Identification */
|
||||
|
||||
#define PCI_SID_ESR 2 /* Expansion Slot Register */
|
||||
#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
|
||||
#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
|
||||
#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
|
||||
|
||||
/* Message Signalled Interrupts registers */
|
||||
|
||||
#define PCI_MSI_FLAGS 2 /* Various flags */
|
||||
#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
|
||||
#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */
|
||||
#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */
|
||||
#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */
|
||||
#define PCI_MSI_FLAGS_MASKBIT 0x100 /* 64-bit mask bits allowed */
|
||||
#define PCI_MSI_RFU 3 /* Rest of capability flags */
|
||||
#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
|
||||
#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
|
||||
#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
|
||||
#define PCI_MSI_MASK_32 12 /* Mask bits register for 32-bit devices */
|
||||
#define PCI_MSI_PENDING_32 16 /* Pending bits register for 32-bit devices */
|
||||
#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
|
||||
#define PCI_MSI_MASK_64 16 /* Mask bits register for 64-bit devices */
|
||||
#define PCI_MSI_PENDING_64 20 /* Pending bits register for 32-bit devices */
|
||||
|
||||
/* MSI-X registers */
|
||||
#define PCI_MSIX_FLAGS 2
|
||||
#define PCI_MSIX_FLAGS_QSIZE 0x7FF
|
||||
#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
|
||||
#define PCI_MSIX_FLAGS_MASKALL (1 << 14)
|
||||
#define PCI_MSIX_TABLE 4
|
||||
#define PCI_MSIX_PBA 8
|
||||
#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
|
||||
|
||||
/* MSI-X entry's format */
|
||||
#define PCI_MSIX_ENTRY_SIZE 16
|
||||
#define PCI_MSIX_ENTRY_LOWER_ADDR 0
|
||||
#define PCI_MSIX_ENTRY_UPPER_ADDR 4
|
||||
#define PCI_MSIX_ENTRY_DATA 8
|
||||
#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
|
||||
#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
|
||||
|
||||
/* CompactPCI Hotswap Register */
|
||||
|
||||
#define PCI_CHSWP_CSR 2 /* Control and Status Register */
|
||||
#define PCI_CHSWP_DHA 0x01 /* Device Hiding Arm */
|
||||
#define PCI_CHSWP_EIM 0x02 /* ENUM# Signal Mask */
|
||||
#define PCI_CHSWP_PIE 0x04 /* Pending Insert or Extract */
|
||||
#define PCI_CHSWP_LOO 0x08 /* LED On / Off */
|
||||
#define PCI_CHSWP_PI 0x30 /* Programming Interface */
|
||||
#define PCI_CHSWP_EXT 0x40 /* ENUM# status - extraction */
|
||||
#define PCI_CHSWP_INS 0x80 /* ENUM# status - insertion */
|
||||
|
||||
/* PCI Advanced Feature registers */
|
||||
|
||||
#define PCI_AF_LENGTH 2
|
||||
#define PCI_AF_CAP 3
|
||||
#define PCI_AF_CAP_TP 0x01
|
||||
#define PCI_AF_CAP_FLR 0x02
|
||||
#define PCI_AF_CTRL 4
|
||||
#define PCI_AF_CTRL_FLR 0x01
|
||||
#define PCI_AF_STATUS 5
|
||||
#define PCI_AF_STATUS_TP 0x01
|
||||
|
||||
/* PCI-X registers */
|
||||
|
||||
#define PCI_X_CMD 2 /* Modes & Features */
|
||||
#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */
|
||||
#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */
|
||||
#define PCI_X_CMD_READ_512 0x0000 /* 512 byte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_1K 0x0004 /* 1Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_2K 0x0008 /* 2Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_READ_4K 0x000c /* 4Kbyte maximum read byte count */
|
||||
#define PCI_X_CMD_MAX_READ 0x000c /* Max Memory Read Byte Count */
|
||||
/* Max # of outstanding split transactions */
|
||||
#define PCI_X_CMD_SPLIT_1 0x0000 /* Max 1 */
|
||||
#define PCI_X_CMD_SPLIT_2 0x0010 /* Max 2 */
|
||||
#define PCI_X_CMD_SPLIT_3 0x0020 /* Max 3 */
|
||||
#define PCI_X_CMD_SPLIT_4 0x0030 /* Max 4 */
|
||||
#define PCI_X_CMD_SPLIT_8 0x0040 /* Max 8 */
|
||||
#define PCI_X_CMD_SPLIT_12 0x0050 /* Max 12 */
|
||||
#define PCI_X_CMD_SPLIT_16 0x0060 /* Max 16 */
|
||||
#define PCI_X_CMD_SPLIT_32 0x0070 /* Max 32 */
|
||||
#define PCI_X_CMD_MAX_SPLIT 0x0070 /* Max Outstanding Split Transactions */
|
||||
#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */
|
||||
#define PCI_X_STATUS 4 /* PCI-X capabilities */
|
||||
#define PCI_X_STATUS_DEVFN 0x000000ff /* A copy of devfn */
|
||||
#define PCI_X_STATUS_BUS 0x0000ff00 /* A copy of bus nr */
|
||||
#define PCI_X_STATUS_64BIT 0x00010000 /* 64-bit device */
|
||||
#define PCI_X_STATUS_133MHZ 0x00020000 /* 133 MHz capable */
|
||||
#define PCI_X_STATUS_SPL_DISC 0x00040000 /* Split Completion Discarded */
|
||||
#define PCI_X_STATUS_UNX_SPL 0x00080000 /* Unexpected Split Completion */
|
||||
#define PCI_X_STATUS_COMPLEX 0x00100000 /* Device Complexity */
|
||||
#define PCI_X_STATUS_MAX_READ 0x00600000 /* Designed Max Memory Read Count */
|
||||
#define PCI_X_STATUS_MAX_SPLIT 0x03800000 /* Designed Max Outstanding Split Transactions */
|
||||
#define PCI_X_STATUS_MAX_CUM 0x1c000000 /* Designed Max Cumulative Read Size */
|
||||
#define PCI_X_STATUS_SPL_ERR 0x20000000 /* Rcvd Split Completion Error Msg */
|
||||
#define PCI_X_STATUS_266MHZ 0x40000000 /* 266 MHz capable */
|
||||
#define PCI_X_STATUS_533MHZ 0x80000000 /* 533 MHz capable */
|
||||
|
||||
/* PCI Bridge Subsystem ID registers */
|
||||
|
||||
#define PCI_SSVID_VENDOR_ID 4 /* PCI-Bridge subsystem vendor id register */
|
||||
#define PCI_SSVID_DEVICE_ID 6 /* PCI-Bridge subsystem device id register */
|
||||
|
||||
/* PCI Express capability registers */
|
||||
|
||||
#define PCI_EXP_FLAGS 2 /* Capabilities register */
|
||||
#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */
|
||||
#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */
|
||||
#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */
|
||||
#define PCI_EXP_TYPE_LEG_END 0x1 /* Legacy Endpoint */
|
||||
#define PCI_EXP_TYPE_ROOT_PORT 0x4 /* Root Port */
|
||||
#define PCI_EXP_TYPE_UPSTREAM 0x5 /* Upstream Port */
|
||||
#define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */
|
||||
#define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */
|
||||
#define PCI_EXP_TYPE_PCIE_BRIDGE 0x8 /* PCI/PCI-X to PCIE Bridge */
|
||||
#define PCI_EXP_TYPE_RC_END 0x9 /* Root Complex Integrated Endpoint */
|
||||
#define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */
|
||||
#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */
|
||||
#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */
|
||||
#define PCI_EXP_DEVCAP 4 /* Device capabilities */
|
||||
#define PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */
|
||||
#define PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */
|
||||
#define PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */
|
||||
#define PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */
|
||||
#define PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */
|
||||
#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
|
||||
#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
|
||||
#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
|
||||
#define PCI_EXP_DEVCAP_RBER 0x8000 /* Role-Based Error Reporting */
|
||||
#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
|
||||
#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
|
||||
#define PCI_EXP_DEVCAP_FLR 0x10000000 /* Function Level Reset */
|
||||
#define PCI_EXP_DEVCTL 8 /* Device Control */
|
||||
#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */
|
||||
#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
|
||||
#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */
|
||||
#define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */
|
||||
#define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
|
||||
#define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */
|
||||
#define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
|
||||
#define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */
|
||||
#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
|
||||
#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */
|
||||
#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */
|
||||
#define PCI_EXP_DEVCTL_BCR_FLR 0x8000 /* Bridge Configuration Retry / FLR */
|
||||
#define PCI_EXP_DEVSTA 10 /* Device Status */
|
||||
#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */
|
||||
#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */
|
||||
#define PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */
|
||||
#define PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */
|
||||
#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
|
||||
#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
|
||||
#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
|
||||
#define PCI_EXP_LNKCAP_SLS 0x0000000f /* Supported Link Speeds */
|
||||
#define PCI_EXP_LNKCAP_MLW 0x000003f0 /* Maximum Link Width */
|
||||
#define PCI_EXP_LNKCAP_ASPMS 0x00000c00 /* ASPM Support */
|
||||
#define PCI_EXP_LNKCAP_L0SEL 0x00007000 /* L0s Exit Latency */
|
||||
#define PCI_EXP_LNKCAP_L1EL 0x00038000 /* L1 Exit Latency */
|
||||
#define PCI_EXP_LNKCAP_CLKPM 0x00040000 /* L1 Clock Power Management */
|
||||
#define PCI_EXP_LNKCAP_SDERC 0x00080000 /* Surprise Down Error Reporting Capable */
|
||||
#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */
|
||||
#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */
|
||||
#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */
|
||||
#define PCI_EXP_LNKCTL 16 /* Link Control */
|
||||
#define PCI_EXP_LNKCTL_ASPMC 0x0003 /* ASPM Control */
|
||||
#define PCI_EXP_LNKCTL_RCB 0x0008 /* Read Completion Boundary */
|
||||
#define PCI_EXP_LNKCTL_LD 0x0010 /* Link Disable */
|
||||
#define PCI_EXP_LNKCTL_RL 0x0020 /* Retrain Link */
|
||||
#define PCI_EXP_LNKCTL_CCC 0x0040 /* Common Clock Configuration */
|
||||
#define PCI_EXP_LNKCTL_ES 0x0080 /* Extended Synch */
|
||||
#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */
|
||||
#define PCI_EXP_LNKCTL_HAWD 0x0200 /* Hardware Autonomous Width Disable */
|
||||
#define PCI_EXP_LNKCTL_LBMIE 0x0400 /* Link Bandwidth Management Interrupt Enable */
|
||||
#define PCI_EXP_LNKCTL_LABIE 0x0800 /* Lnk Autonomous Bandwidth Interrupt Enable */
|
||||
#define PCI_EXP_LNKSTA 18 /* Link Status */
|
||||
#define PCI_EXP_LNKSTA_CLS 0x000f /* Current Link Speed */
|
||||
#define PCI_EXP_LNKSTA_CLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */
|
||||
#define PCI_EXP_LNKSTA_CLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */
|
||||
#define PCI_EXP_LNKSTA_NLW 0x03f0 /* Nogotiated Link Width */
|
||||
#define PCI_EXP_LNKSTA_NLW_SHIFT 4 /* start of NLW mask in link status */
|
||||
#define PCI_EXP_LNKSTA_LT 0x0800 /* Link Training */
|
||||
#define PCI_EXP_LNKSTA_SLC 0x1000 /* Slot Clock Configuration */
|
||||
#define PCI_EXP_LNKSTA_DLLLA 0x2000 /* Data Link Layer Link Active */
|
||||
#define PCI_EXP_LNKSTA_LBMS 0x4000 /* Link Bandwidth Management Status */
|
||||
#define PCI_EXP_LNKSTA_LABS 0x8000 /* Link Autonomous Bandwidth Status */
|
||||
#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
|
||||
#define PCI_EXP_SLTCAP_ABP 0x00000001 /* Attention Button Present */
|
||||
#define PCI_EXP_SLTCAP_PCP 0x00000002 /* Power Controller Present */
|
||||
#define PCI_EXP_SLTCAP_MRLSP 0x00000004 /* MRL Sensor Present */
|
||||
#define PCI_EXP_SLTCAP_AIP 0x00000008 /* Attention Indicator Present */
|
||||
#define PCI_EXP_SLTCAP_PIP 0x00000010 /* Power Indicator Present */
|
||||
#define PCI_EXP_SLTCAP_HPS 0x00000020 /* Hot-Plug Surprise */
|
||||
#define PCI_EXP_SLTCAP_HPC 0x00000040 /* Hot-Plug Capable */
|
||||
#define PCI_EXP_SLTCAP_SPLV 0x00007f80 /* Slot Power Limit Value */
|
||||
#define PCI_EXP_SLTCAP_SPLS 0x00018000 /* Slot Power Limit Scale */
|
||||
#define PCI_EXP_SLTCAP_EIP 0x00020000 /* Electromechanical Interlock Present */
|
||||
#define PCI_EXP_SLTCAP_NCCS 0x00040000 /* No Command Completed Support */
|
||||
#define PCI_EXP_SLTCAP_PSN 0xfff80000 /* Physical Slot Number */
|
||||
#define PCI_EXP_SLTCTL 24 /* Slot Control */
|
||||
#define PCI_EXP_SLTCTL_ABPE 0x0001 /* Attention Button Pressed Enable */
|
||||
#define PCI_EXP_SLTCTL_PFDE 0x0002 /* Power Fault Detected Enable */
|
||||
#define PCI_EXP_SLTCTL_MRLSCE 0x0004 /* MRL Sensor Changed Enable */
|
||||
#define PCI_EXP_SLTCTL_PDCE 0x0008 /* Presence Detect Changed Enable */
|
||||
#define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */
|
||||
#define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */
|
||||
#define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */
|
||||
#define PCI_EXP_SLTCTL_PIC 0x0300 /* Power Indicator Control */
|
||||
#define PCI_EXP_SLTCTL_PCC 0x0400 /* Power Controller Control */
|
||||
#define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */
|
||||
#define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */
|
||||
#define PCI_EXP_SLTSTA 26 /* Slot Status */
|
||||
#define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */
|
||||
#define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */
|
||||
#define PCI_EXP_SLTSTA_MRLSC 0x0004 /* MRL Sensor Changed */
|
||||
#define PCI_EXP_SLTSTA_PDC 0x0008 /* Presence Detect Changed */
|
||||
#define PCI_EXP_SLTSTA_CC 0x0010 /* Command Completed */
|
||||
#define PCI_EXP_SLTSTA_MRLSS 0x0020 /* MRL Sensor State */
|
||||
#define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */
|
||||
#define PCI_EXP_SLTSTA_EIS 0x0080 /* Electromechanical Interlock Status */
|
||||
#define PCI_EXP_SLTSTA_DLLSC 0x0100 /* Data Link Layer State Changed */
|
||||
#define PCI_EXP_RTCTL 28 /* Root Control */
|
||||
#define PCI_EXP_RTCTL_SECEE 0x01 /* System Error on Correctable Error */
|
||||
#define PCI_EXP_RTCTL_SENFEE 0x02 /* System Error on Non-Fatal Error */
|
||||
#define PCI_EXP_RTCTL_SEFEE 0x04 /* System Error on Fatal Error */
|
||||
#define PCI_EXP_RTCTL_PMEIE 0x08 /* PME Interrupt Enable */
|
||||
#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
|
||||
#define PCI_EXP_RTCAP 30 /* Root Capabilities */
|
||||
#define PCI_EXP_RTSTA 32 /* Root Status */
|
||||
#define PCI_EXP_RTSTA_PME 0x10000 /* PME status */
|
||||
#define PCI_EXP_RTSTA_PENDING 0x20000 /* PME pending */
|
||||
#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
|
||||
#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#define PCI_EXP_DEVCAP2_LTR 0x800 /* Latency tolerance reporting */
|
||||
#define PCI_EXP_OBFF_MASK 0xc0000 /* OBFF support mechanism */
|
||||
#define PCI_EXP_OBFF_MSG 0x40000 /* New message signaling */
|
||||
#define PCI_EXP_OBFF_WAKE 0x80000 /* Re-use WAKE# for OBFF */
|
||||
#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
|
||||
#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#define PCI_EXP_IDO_REQ_EN 0x100 /* ID-based ordering request enable */
|
||||
#define PCI_EXP_IDO_CMP_EN 0x200 /* ID-based ordering completion enable */
|
||||
#define PCI_EXP_LTR_EN 0x400 /* Latency tolerance reporting */
|
||||
#define PCI_EXP_OBFF_MSGA_EN 0x2000 /* OBFF enable with Message type A */
|
||||
#define PCI_EXP_OBFF_MSGB_EN 0x4000 /* OBFF enable with Message type B */
|
||||
#define PCI_EXP_OBFF_WAKE_EN 0x6000 /* OBFF using WAKE# signaling */
|
||||
#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
|
||||
#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */
|
||||
|
||||
/* Extended Capabilities (PCI-X 2.0 and Express) */
|
||||
#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
|
||||
#define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf)
|
||||
#define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
|
||||
|
||||
#define PCI_EXT_CAP_ID_ERR 1
|
||||
#define PCI_EXT_CAP_ID_VC 2
|
||||
#define PCI_EXT_CAP_ID_DSN 3
|
||||
#define PCI_EXT_CAP_ID_PWR 4
|
||||
#define PCI_EXT_CAP_ID_VNDR 11
|
||||
#define PCI_EXT_CAP_ID_ACS 13
|
||||
#define PCI_EXT_CAP_ID_ARI 14
|
||||
#define PCI_EXT_CAP_ID_ATS 15
|
||||
#define PCI_EXT_CAP_ID_SRIOV 16
|
||||
#define PCI_EXT_CAP_ID_LTR 24
|
||||
|
||||
/* Advanced Error Reporting */
|
||||
#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */
|
||||
#define PCI_ERR_UNC_TRAIN 0x00000001 /* Training */
|
||||
#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */
|
||||
#define PCI_ERR_UNC_POISON_TLP 0x00001000 /* Poisoned TLP */
|
||||
#define PCI_ERR_UNC_FCP 0x00002000 /* Flow Control Protocol */
|
||||
#define PCI_ERR_UNC_COMP_TIME 0x00004000 /* Completion Timeout */
|
||||
#define PCI_ERR_UNC_COMP_ABORT 0x00008000 /* Completer Abort */
|
||||
#define PCI_ERR_UNC_UNX_COMP 0x00010000 /* Unexpected Completion */
|
||||
#define PCI_ERR_UNC_RX_OVER 0x00020000 /* Receiver Overflow */
|
||||
#define PCI_ERR_UNC_MALF_TLP 0x00040000 /* Malformed TLP */
|
||||
#define PCI_ERR_UNC_ECRC 0x00080000 /* ECRC Error Status */
|
||||
#define PCI_ERR_UNC_UNSUP 0x00100000 /* Unsupported Request */
|
||||
#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */
|
||||
#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */
|
||||
#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */
|
||||
#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */
|
||||
#define PCI_ERR_COR_REP_ROLL 0x00000100 /* REPLAY_NUM Rollover */
|
||||
#define PCI_ERR_COR_REP_TIMER 0x00001000 /* Replay Timer Timeout */
|
||||
#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */
|
||||
/* Same bits as above */
|
||||
#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */
|
||||
#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */
|
||||
#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */
|
||||
#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */
|
||||
#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */
|
||||
#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */
|
||||
#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */
|
||||
#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */
|
||||
/* Correctable Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_COR_EN 0x00000001
|
||||
/* Non-fatal Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_NONFATAL_EN 0x00000002
|
||||
/* Fatal Err Reporting Enable */
|
||||
#define PCI_ERR_ROOT_CMD_FATAL_EN 0x00000004
|
||||
#define PCI_ERR_ROOT_STATUS 48
|
||||
#define PCI_ERR_ROOT_COR_RCV 0x00000001 /* ERR_COR Received */
|
||||
/* Multi ERR_COR Received */
|
||||
#define PCI_ERR_ROOT_MULTI_COR_RCV 0x00000002
|
||||
/* ERR_FATAL/NONFATAL Recevied */
|
||||
#define PCI_ERR_ROOT_UNCOR_RCV 0x00000004
|
||||
/* Multi ERR_FATAL/NONFATAL Recevied */
|
||||
#define PCI_ERR_ROOT_MULTI_UNCOR_RCV 0x00000008
|
||||
#define PCI_ERR_ROOT_FIRST_FATAL 0x00000010 /* First Fatal */
|
||||
#define PCI_ERR_ROOT_NONFATAL_RCV 0x00000020 /* Non-Fatal Received */
|
||||
#define PCI_ERR_ROOT_FATAL_RCV 0x00000040 /* Fatal Received */
|
||||
#define PCI_ERR_ROOT_ERR_SRC 52 /* Error Source Identification */
|
||||
|
||||
/* Virtual Channel */
|
||||
#define PCI_VC_PORT_REG1 4
|
||||
#define PCI_VC_PORT_REG2 8
|
||||
#define PCI_VC_PORT_CTRL 12
|
||||
#define PCI_VC_PORT_STATUS 14
|
||||
#define PCI_VC_RES_CAP 16
|
||||
#define PCI_VC_RES_CTRL 20
|
||||
#define PCI_VC_RES_STATUS 26
|
||||
|
||||
/* Power Budgeting */
|
||||
#define PCI_PWR_DSR 4 /* Data Select Register */
|
||||
#define PCI_PWR_DATA 8 /* Data Register */
|
||||
#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */
|
||||
#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */
|
||||
#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */
|
||||
#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */
|
||||
#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */
|
||||
#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */
|
||||
#define PCI_PWR_CAP 12 /* Capability */
|
||||
#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */
|
||||
|
||||
/*
|
||||
* Hypertransport sub capability types
|
||||
*
|
||||
* Unfortunately there are both 3 bit and 5 bit capability types defined
|
||||
* in the HT spec, catering for that is a little messy. You probably don't
|
||||
* want to use these directly, just use pci_find_ht_capability() and it
|
||||
* will do the right thing for you.
|
||||
*/
|
||||
#define HT_3BIT_CAP_MASK 0xE0
|
||||
#define HT_CAPTYPE_SLAVE 0x00 /* Slave/Primary link configuration */
|
||||
#define HT_CAPTYPE_HOST 0x20 /* Host/Secondary link configuration */
|
||||
|
||||
#define HT_5BIT_CAP_MASK 0xF8
|
||||
#define HT_CAPTYPE_IRQ 0x80 /* IRQ Configuration */
|
||||
#define HT_CAPTYPE_REMAPPING_40 0xA0 /* 40 bit address remapping */
|
||||
#define HT_CAPTYPE_REMAPPING_64 0xA2 /* 64 bit address remapping */
|
||||
#define HT_CAPTYPE_UNITID_CLUMP 0x90 /* Unit ID clumping */
|
||||
#define HT_CAPTYPE_EXTCONF 0x98 /* Extended Configuration Space Access */
|
||||
#define HT_CAPTYPE_MSI_MAPPING 0xA8 /* MSI Mapping Capability */
|
||||
#define HT_MSI_FLAGS 0x02 /* Offset to flags */
|
||||
#define HT_MSI_FLAGS_ENABLE 0x1 /* Mapping enable */
|
||||
#define HT_MSI_FLAGS_FIXED 0x2 /* Fixed mapping only */
|
||||
#define HT_MSI_FIXED_ADDR 0x00000000FEE00000ULL /* Fixed addr */
|
||||
#define HT_MSI_ADDR_LO 0x04 /* Offset to low addr bits */
|
||||
#define HT_MSI_ADDR_LO_MASK 0xFFF00000 /* Low address bit mask */
|
||||
#define HT_MSI_ADDR_HI 0x08 /* Offset to high addr bits */
|
||||
#define HT_CAPTYPE_DIRECT_ROUTE 0xB0 /* Direct routing configuration */
|
||||
#define HT_CAPTYPE_VCSET 0xB8 /* Virtual Channel configuration */
|
||||
#define HT_CAPTYPE_ERROR_RETRY 0xC0 /* Retry on error configuration */
|
||||
#define HT_CAPTYPE_GEN3 0xD0 /* Generation 3 hypertransport configuration */
|
||||
#define HT_CAPTYPE_PM 0xE0 /* Hypertransport powermanagement configuration */
|
||||
|
||||
/* Alternative Routing-ID Interpretation */
|
||||
#define PCI_ARI_CAP 0x04 /* ARI Capability Register */
|
||||
#define PCI_ARI_CAP_MFVC 0x0001 /* MFVC Function Groups Capability */
|
||||
#define PCI_ARI_CAP_ACS 0x0002 /* ACS Function Groups Capability */
|
||||
#define PCI_ARI_CAP_NFN(x) (((x) >> 8) & 0xff) /* Next Function Number */
|
||||
#define PCI_ARI_CTRL 0x06 /* ARI Control Register */
|
||||
#define PCI_ARI_CTRL_MFVC 0x0001 /* MFVC Function Groups Enable */
|
||||
#define PCI_ARI_CTRL_ACS 0x0002 /* ACS Function Groups Enable */
|
||||
#define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7) /* Function Group */
|
||||
|
||||
/* Address Translation Service */
|
||||
#define PCI_ATS_CAP 0x04 /* ATS Capability Register */
|
||||
#define PCI_ATS_CAP_QDEP(x) ((x) & 0x1f) /* Invalidate Queue Depth */
|
||||
#define PCI_ATS_MAX_QDEP 32 /* Max Invalidate Queue Depth */
|
||||
#define PCI_ATS_CTRL 0x06 /* ATS Control Register */
|
||||
#define PCI_ATS_CTRL_ENABLE 0x8000 /* ATS Enable */
|
||||
#define PCI_ATS_CTRL_STU(x) ((x) & 0x1f) /* Smallest Translation Unit */
|
||||
#define PCI_ATS_MIN_STU 12 /* shift of minimum STU block */
|
||||
|
||||
/* Single Root I/O Virtualization */
|
||||
#define PCI_SRIOV_CAP 0x04 /* SR-IOV Capabilities */
|
||||
#define PCI_SRIOV_CAP_VFM 0x01 /* VF Migration Capable */
|
||||
#define PCI_SRIOV_CAP_INTR(x) ((x) >> 21) /* Interrupt Message Number */
|
||||
#define PCI_SRIOV_CTRL 0x08 /* SR-IOV Control */
|
||||
#define PCI_SRIOV_CTRL_VFE 0x01 /* VF Enable */
|
||||
#define PCI_SRIOV_CTRL_VFM 0x02 /* VF Migration Enable */
|
||||
#define PCI_SRIOV_CTRL_INTR 0x04 /* VF Migration Interrupt Enable */
|
||||
#define PCI_SRIOV_CTRL_MSE 0x08 /* VF Memory Space Enable */
|
||||
#define PCI_SRIOV_CTRL_ARI 0x10 /* ARI Capable Hierarchy */
|
||||
#define PCI_SRIOV_STATUS 0x0a /* SR-IOV Status */
|
||||
#define PCI_SRIOV_STATUS_VFM 0x01 /* VF Migration Status */
|
||||
#define PCI_SRIOV_INITIAL_VF 0x0c /* Initial VFs */
|
||||
#define PCI_SRIOV_TOTAL_VF 0x0e /* Total VFs */
|
||||
#define PCI_SRIOV_NUM_VF 0x10 /* Number of VFs */
|
||||
#define PCI_SRIOV_FUNC_LINK 0x12 /* Function Dependency Link */
|
||||
#define PCI_SRIOV_VF_OFFSET 0x14 /* First VF Offset */
|
||||
#define PCI_SRIOV_VF_STRIDE 0x16 /* Following VF Stride */
|
||||
#define PCI_SRIOV_VF_DID 0x1a /* VF Device ID */
|
||||
#define PCI_SRIOV_SUP_PGSIZE 0x1c /* Supported Page Sizes */
|
||||
#define PCI_SRIOV_SYS_PGSIZE 0x20 /* System Page Size */
|
||||
#define PCI_SRIOV_BAR 0x24 /* VF BAR0 */
|
||||
#define PCI_SRIOV_NUM_BARS 6 /* Number of VF BARs */
|
||||
#define PCI_SRIOV_VFM 0x3c /* VF Migration State Array Offset*/
|
||||
#define PCI_SRIOV_VFM_BIR(x) ((x) & 7) /* State BIR */
|
||||
#define PCI_SRIOV_VFM_OFFSET(x) ((x) & ~7) /* State Offset */
|
||||
#define PCI_SRIOV_VFM_UA 0x0 /* Inactive.Unavailable */
|
||||
#define PCI_SRIOV_VFM_MI 0x1 /* Dormant.MigrateIn */
|
||||
#define PCI_SRIOV_VFM_MO 0x2 /* Active.MigrateOut */
|
||||
#define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */
|
||||
|
||||
#define PCI_LTR_MAX_SNOOP_LAT 0x4
|
||||
#define PCI_LTR_MAX_NOSNOOP_LAT 0x6
|
||||
#define PCI_LTR_VALUE_MASK 0x000003ff
|
||||
#define PCI_LTR_SCALE_MASK 0x00001c00
|
||||
#define PCI_LTR_SCALE_SHIFT 10
|
||||
|
||||
/* Access Control Service */
|
||||
#define PCI_ACS_CAP 0x04 /* ACS Capability Register */
|
||||
#define PCI_ACS_SV 0x01 /* Source Validation */
|
||||
#define PCI_ACS_TB 0x02 /* Translation Blocking */
|
||||
#define PCI_ACS_RR 0x04 /* P2P Request Redirect */
|
||||
#define PCI_ACS_CR 0x08 /* P2P Completion Redirect */
|
||||
#define PCI_ACS_UF 0x10 /* Upstream Forwarding */
|
||||
#define PCI_ACS_EC 0x20 /* P2P Egress Control */
|
||||
#define PCI_ACS_DT 0x40 /* Direct Translated P2P */
|
||||
#define PCI_ACS_CTRL 0x06 /* ACS Control Register */
|
||||
#define PCI_ACS_EGRESS_CTL_V 0x08 /* ACS Egress Control Vector */
|
||||
|
||||
#endif /* LINUX_PCI_REGS_H */
|
|
@ -34,6 +34,7 @@
|
|||
/* The feature bitmap for virtio net */
|
||||
#define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */
|
||||
#define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */
|
||||
#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */
|
||||
#define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
|
||||
#define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */
|
||||
#define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */
|
||||
|
@ -226,4 +227,19 @@ struct virtio_net_ctrl_mq {
|
|||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
|
||||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
|
||||
|
||||
/*
|
||||
* Control network offloads
|
||||
*
|
||||
* Reconfigures the network offloads that Guest can handle.
|
||||
*
|
||||
* Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit.
|
||||
*
|
||||
* Command data format matches the feature bit mask exactly.
|
||||
*
|
||||
* See VIRTIO_NET_F_GUEST_* for the list of offloads
|
||||
* that can be enabled/disabled.
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
|
||||
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
|
||||
|
||||
#endif /* _LINUX_VIRTIO_NET_H */
|
||||
|
|
|
@ -157,6 +157,12 @@ struct virtio_pci_common_cfg {
|
|||
uint32_t queue_used_hi; /* read-write */
|
||||
};
|
||||
|
||||
/* Fields in VIRTIO_PCI_CAP_PCI_CFG: */
|
||||
struct virtio_pci_cfg_cap {
|
||||
struct virtio_pci_cap cap;
|
||||
uint8_t pci_cfg_data[4]; /* Data for BAR access. */
|
||||
};
|
||||
|
||||
/* Macro versions of offsets for the Old Timers! */
|
||||
#define VIRTIO_PCI_CAP_VNDR 0
|
||||
#define VIRTIO_PCI_CAP_NEXT 1
|
||||
|
|
|
@ -31,7 +31,7 @@ fi
|
|||
cp_virtio() {
|
||||
from=$1
|
||||
to=$2
|
||||
virtio=$(find "$from" -name '*virtio*h' -o -name "input.h")
|
||||
virtio=$(find "$from" -name '*virtio*h' -o -name "input.h" -o -name "pci_regs.h")
|
||||
if [ "$virtio" ]; then
|
||||
rm -rf "$to"
|
||||
mkdir -p "$to"
|
||||
|
|
|
@ -155,6 +155,7 @@ check-qtest-i386-y += tests/i440fx-test$(EXESUF)
|
|||
check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
|
||||
check-qtest-i386-y += tests/drive_del-test$(EXESUF)
|
||||
check-qtest-i386-y += tests/wdt_ib700-test$(EXESUF)
|
||||
check-qtest-i386-y += tests/tco-test$(EXESUF)
|
||||
gcov-files-i386-y += hw/watchdog/watchdog.c hw/watchdog/wdt_ib700.c
|
||||
check-qtest-i386-y += $(check-qtest-pci-y)
|
||||
gcov-files-i386-y += $(gcov-files-pci-y)
|
||||
|
@ -373,6 +374,7 @@ tests/eepro100-test$(EXESUF): tests/eepro100-test.o
|
|||
tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o
|
||||
tests/ne2000-test$(EXESUF): tests/ne2000-test.o
|
||||
tests/wdt_ib700-test$(EXESUF): tests/wdt_ib700-test.o
|
||||
tests/tco-test$(EXESUF): tests/tco-test.o $(libqos-pc-obj-y)
|
||||
tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o
|
||||
tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o $(libqos-virtio-obj-y)
|
||||
tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o $(libqos-pc-obj-y)
|
||||
|
|
|
@ -0,0 +1,465 @@
|
|||
/*
|
||||
* QEMU ICH9 TCO emulation tests
|
||||
*
|
||||
* Copyright (c) 2015 Paulo Alcantara <pcacjr@zytor.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libqtest.h"
|
||||
#include "libqos/pci.h"
|
||||
#include "libqos/pci-pc.h"
|
||||
#include "hw/pci/pci_regs.h"
|
||||
#include "hw/i386/ich9.h"
|
||||
#include "hw/acpi/ich9.h"
|
||||
#include "hw/acpi/tco.h"
|
||||
|
||||
#define RCBA_BASE_ADDR 0xfed1c000
|
||||
#define PM_IO_BASE_ADDR 0xb000
|
||||
|
||||
enum {
|
||||
TCO_RLD_DEFAULT = 0x0000,
|
||||
TCO_DAT_IN_DEFAULT = 0x00,
|
||||
TCO_DAT_OUT_DEFAULT = 0x00,
|
||||
TCO1_STS_DEFAULT = 0x0000,
|
||||
TCO2_STS_DEFAULT = 0x0000,
|
||||
TCO1_CNT_DEFAULT = 0x0000,
|
||||
TCO2_CNT_DEFAULT = 0x0008,
|
||||
TCO_MESSAGE1_DEFAULT = 0x00,
|
||||
TCO_MESSAGE2_DEFAULT = 0x00,
|
||||
TCO_WDCNT_DEFAULT = 0x00,
|
||||
TCO_TMR_DEFAULT = 0x0004,
|
||||
SW_IRQ_GEN_DEFAULT = 0x03,
|
||||
};
|
||||
|
||||
#define TCO_SECS_TO_TICKS(secs) (((secs) * 10) / 6)
|
||||
#define TCO_TICKS_TO_SECS(ticks) (((ticks) * 6) / 10)
|
||||
|
||||
typedef struct {
|
||||
const char *args;
|
||||
bool noreboot;
|
||||
QPCIDevice *dev;
|
||||
void *tco_io_base;
|
||||
} TestData;
|
||||
|
||||
static void test_init(TestData *d)
|
||||
{
|
||||
QPCIBus *bus;
|
||||
QTestState *qs;
|
||||
char *s;
|
||||
|
||||
s = g_strdup_printf("-machine q35 %s %s",
|
||||
d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
|
||||
!d->args ? "" : d->args);
|
||||
qs = qtest_start(s);
|
||||
qtest_irq_intercept_in(qs, "ioapic");
|
||||
g_free(s);
|
||||
|
||||
bus = qpci_init_pc();
|
||||
d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00));
|
||||
g_assert(d->dev != NULL);
|
||||
|
||||
qpci_device_enable(d->dev);
|
||||
|
||||
/* set ACPI PM I/O space base address */
|
||||
qpci_config_writel(d->dev, ICH9_LPC_PMBASE, PM_IO_BASE_ADDR | 0x1);
|
||||
/* enable ACPI I/O */
|
||||
qpci_config_writeb(d->dev, ICH9_LPC_ACPI_CTRL, 0x80);
|
||||
/* set Root Complex BAR */
|
||||
qpci_config_writel(d->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1);
|
||||
|
||||
d->tco_io_base = (void *)((uintptr_t)PM_IO_BASE_ADDR + 0x60);
|
||||
}
|
||||
|
||||
static void stop_tco(const TestData *d)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
val = qpci_io_readw(d->dev, d->tco_io_base + TCO1_CNT);
|
||||
val |= TCO_TMR_HLT;
|
||||
qpci_io_writew(d->dev, d->tco_io_base + TCO1_CNT, val);
|
||||
}
|
||||
|
||||
static void start_tco(const TestData *d)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
val = qpci_io_readw(d->dev, d->tco_io_base + TCO1_CNT);
|
||||
val &= ~TCO_TMR_HLT;
|
||||
qpci_io_writew(d->dev, d->tco_io_base + TCO1_CNT, val);
|
||||
}
|
||||
|
||||
static void load_tco(const TestData *d)
|
||||
{
|
||||
qpci_io_writew(d->dev, d->tco_io_base + TCO_RLD, 4);
|
||||
}
|
||||
|
||||
static void set_tco_timeout(const TestData *d, uint16_t ticks)
|
||||
{
|
||||
qpci_io_writew(d->dev, d->tco_io_base + TCO_TMR, ticks);
|
||||
}
|
||||
|
||||
static void clear_tco_status(const TestData *d)
|
||||
{
|
||||
qpci_io_writew(d->dev, d->tco_io_base + TCO1_STS, 0x0008);
|
||||
qpci_io_writew(d->dev, d->tco_io_base + TCO2_STS, 0x0002);
|
||||
qpci_io_writew(d->dev, d->tco_io_base + TCO2_STS, 0x0004);
|
||||
}
|
||||
|
||||
static void reset_on_second_timeout(bool enable)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
val = readl(RCBA_BASE_ADDR + ICH9_CC_GCS);
|
||||
if (enable) {
|
||||
val &= ~ICH9_CC_GCS_NO_REBOOT;
|
||||
} else {
|
||||
val |= ICH9_CC_GCS_NO_REBOOT;
|
||||
}
|
||||
writel(RCBA_BASE_ADDR + ICH9_CC_GCS, val);
|
||||
}
|
||||
|
||||
static void test_tco_defaults(void)
|
||||
{
|
||||
TestData d;
|
||||
|
||||
d.args = NULL;
|
||||
d.noreboot = true;
|
||||
test_init(&d);
|
||||
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO_RLD), ==,
|
||||
TCO_RLD_DEFAULT);
|
||||
/* TCO_DAT_IN & TCO_DAT_OUT */
|
||||
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO_DAT_IN), ==,
|
||||
(TCO_DAT_OUT_DEFAULT << 8) | TCO_DAT_IN_DEFAULT);
|
||||
/* TCO1_STS & TCO2_STS */
|
||||
g_assert_cmpint(qpci_io_readl(d.dev, d.tco_io_base + TCO1_STS), ==,
|
||||
(TCO2_STS_DEFAULT << 16) | TCO1_STS_DEFAULT);
|
||||
/* TCO1_CNT & TCO2_CNT */
|
||||
g_assert_cmpint(qpci_io_readl(d.dev, d.tco_io_base + TCO1_CNT), ==,
|
||||
(TCO2_CNT_DEFAULT << 16) | TCO1_CNT_DEFAULT);
|
||||
/* TCO_MESSAGE1 & TCO_MESSAGE2 */
|
||||
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO_MESSAGE1), ==,
|
||||
(TCO_MESSAGE2_DEFAULT << 8) | TCO_MESSAGE1_DEFAULT);
|
||||
g_assert_cmpint(qpci_io_readb(d.dev, d.tco_io_base + TCO_WDCNT), ==,
|
||||
TCO_WDCNT_DEFAULT);
|
||||
g_assert_cmpint(qpci_io_readb(d.dev, d.tco_io_base + SW_IRQ_GEN), ==,
|
||||
SW_IRQ_GEN_DEFAULT);
|
||||
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO_TMR), ==,
|
||||
TCO_TMR_DEFAULT);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco_timeout(void)
|
||||
{
|
||||
TestData d;
|
||||
const uint16_t ticks = TCO_SECS_TO_TICKS(4);
|
||||
uint32_t val;
|
||||
int ret;
|
||||
|
||||
d.args = NULL;
|
||||
d.noreboot = true;
|
||||
test_init(&d);
|
||||
|
||||
stop_tco(&d);
|
||||
clear_tco_status(&d);
|
||||
reset_on_second_timeout(false);
|
||||
set_tco_timeout(&d, ticks);
|
||||
load_tco(&d);
|
||||
start_tco(&d);
|
||||
clock_step(ticks * TCO_TICK_NSEC);
|
||||
|
||||
/* test first timeout */
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
|
||||
ret = val & TCO_TIMEOUT ? 1 : 0;
|
||||
g_assert(ret == 1);
|
||||
|
||||
/* test clearing timeout bit */
|
||||
val |= TCO_TIMEOUT;
|
||||
qpci_io_writew(d.dev, d.tco_io_base + TCO1_STS, val);
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
|
||||
ret = val & TCO_TIMEOUT ? 1 : 0;
|
||||
g_assert(ret == 0);
|
||||
|
||||
/* test second timeout */
|
||||
clock_step(ticks * TCO_TICK_NSEC);
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
|
||||
ret = val & TCO_TIMEOUT ? 1 : 0;
|
||||
g_assert(ret == 1);
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);
|
||||
ret = val & TCO_SECOND_TO_STS ? 1 : 0;
|
||||
g_assert(ret == 1);
|
||||
|
||||
stop_tco(&d);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco_max_timeout(void)
|
||||
{
|
||||
TestData d;
|
||||
const uint16_t ticks = 0xffff;
|
||||
uint32_t val;
|
||||
int ret;
|
||||
|
||||
d.args = NULL;
|
||||
d.noreboot = true;
|
||||
test_init(&d);
|
||||
|
||||
stop_tco(&d);
|
||||
clear_tco_status(&d);
|
||||
reset_on_second_timeout(false);
|
||||
set_tco_timeout(&d, ticks);
|
||||
load_tco(&d);
|
||||
start_tco(&d);
|
||||
clock_step(((ticks & TCO_TMR_MASK) - 1) * TCO_TICK_NSEC);
|
||||
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO_RLD);
|
||||
g_assert_cmpint(val & TCO_RLD_MASK, ==, 1);
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
|
||||
ret = val & TCO_TIMEOUT ? 1 : 0;
|
||||
g_assert(ret == 0);
|
||||
clock_step(TCO_TICK_NSEC);
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
|
||||
ret = val & TCO_TIMEOUT ? 1 : 0;
|
||||
g_assert(ret == 1);
|
||||
|
||||
stop_tco(&d);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static QDict *get_watchdog_action(void)
|
||||
{
|
||||
QDict *ev = qmp("");
|
||||
QDict *data;
|
||||
g_assert(!strcmp(qdict_get_str(ev, "event"), "WATCHDOG"));
|
||||
|
||||
data = qdict_get_qdict(ev, "data");
|
||||
QINCREF(data);
|
||||
QDECREF(ev);
|
||||
return data;
|
||||
}
|
||||
|
||||
static void test_tco_second_timeout_pause(void)
|
||||
{
|
||||
TestData td;
|
||||
const uint16_t ticks = TCO_SECS_TO_TICKS(32);
|
||||
QDict *ad;
|
||||
|
||||
td.args = "-watchdog-action pause";
|
||||
td.noreboot = false;
|
||||
test_init(&td);
|
||||
|
||||
stop_tco(&td);
|
||||
clear_tco_status(&td);
|
||||
reset_on_second_timeout(true);
|
||||
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
|
||||
load_tco(&td);
|
||||
start_tco(&td);
|
||||
clock_step(ticks * TCO_TICK_NSEC * 2);
|
||||
ad = get_watchdog_action();
|
||||
g_assert(!strcmp(qdict_get_str(ad, "action"), "pause"));
|
||||
QDECREF(ad);
|
||||
|
||||
stop_tco(&td);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco_second_timeout_reset(void)
|
||||
{
|
||||
TestData td;
|
||||
const uint16_t ticks = TCO_SECS_TO_TICKS(16);
|
||||
QDict *ad;
|
||||
|
||||
td.args = "-watchdog-action reset";
|
||||
td.noreboot = false;
|
||||
test_init(&td);
|
||||
|
||||
stop_tco(&td);
|
||||
clear_tco_status(&td);
|
||||
reset_on_second_timeout(true);
|
||||
set_tco_timeout(&td, TCO_SECS_TO_TICKS(16));
|
||||
load_tco(&td);
|
||||
start_tco(&td);
|
||||
clock_step(ticks * TCO_TICK_NSEC * 2);
|
||||
ad = get_watchdog_action();
|
||||
g_assert(!strcmp(qdict_get_str(ad, "action"), "reset"));
|
||||
QDECREF(ad);
|
||||
|
||||
stop_tco(&td);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco_second_timeout_shutdown(void)
|
||||
{
|
||||
TestData td;
|
||||
const uint16_t ticks = TCO_SECS_TO_TICKS(128);
|
||||
QDict *ad;
|
||||
|
||||
td.args = "-watchdog-action shutdown";
|
||||
td.noreboot = false;
|
||||
test_init(&td);
|
||||
|
||||
stop_tco(&td);
|
||||
clear_tco_status(&td);
|
||||
reset_on_second_timeout(true);
|
||||
set_tco_timeout(&td, ticks);
|
||||
load_tco(&td);
|
||||
start_tco(&td);
|
||||
clock_step(ticks * TCO_TICK_NSEC * 2);
|
||||
ad = get_watchdog_action();
|
||||
g_assert(!strcmp(qdict_get_str(ad, "action"), "shutdown"));
|
||||
QDECREF(ad);
|
||||
|
||||
stop_tco(&td);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco_second_timeout_none(void)
|
||||
{
|
||||
TestData td;
|
||||
const uint16_t ticks = TCO_SECS_TO_TICKS(256);
|
||||
QDict *ad;
|
||||
|
||||
td.args = "-watchdog-action none";
|
||||
td.noreboot = false;
|
||||
test_init(&td);
|
||||
|
||||
stop_tco(&td);
|
||||
clear_tco_status(&td);
|
||||
reset_on_second_timeout(true);
|
||||
set_tco_timeout(&td, ticks);
|
||||
load_tco(&td);
|
||||
start_tco(&td);
|
||||
clock_step(ticks * TCO_TICK_NSEC * 2);
|
||||
ad = get_watchdog_action();
|
||||
g_assert(!strcmp(qdict_get_str(ad, "action"), "none"));
|
||||
QDECREF(ad);
|
||||
|
||||
stop_tco(&td);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco_ticks_counter(void)
|
||||
{
|
||||
TestData d;
|
||||
uint16_t ticks = TCO_SECS_TO_TICKS(8);
|
||||
uint16_t rld;
|
||||
|
||||
d.args = NULL;
|
||||
d.noreboot = true;
|
||||
test_init(&d);
|
||||
|
||||
stop_tco(&d);
|
||||
clear_tco_status(&d);
|
||||
reset_on_second_timeout(false);
|
||||
set_tco_timeout(&d, ticks);
|
||||
load_tco(&d);
|
||||
start_tco(&d);
|
||||
|
||||
do {
|
||||
rld = qpci_io_readw(d.dev, d.tco_io_base + TCO_RLD) & TCO_RLD_MASK;
|
||||
g_assert_cmpint(rld, ==, ticks);
|
||||
clock_step(TCO_TICK_NSEC);
|
||||
ticks--;
|
||||
} while (!(qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS) & TCO_TIMEOUT));
|
||||
|
||||
stop_tco(&d);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco1_control_bits(void)
|
||||
{
|
||||
TestData d;
|
||||
uint16_t val;
|
||||
|
||||
d.args = NULL;
|
||||
d.noreboot = true;
|
||||
test_init(&d);
|
||||
|
||||
val = TCO_LOCK;
|
||||
qpci_io_writew(d.dev, d.tco_io_base + TCO1_CNT, val);
|
||||
val &= ~TCO_LOCK;
|
||||
qpci_io_writew(d.dev, d.tco_io_base + TCO1_CNT, val);
|
||||
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO1_CNT), ==,
|
||||
TCO_LOCK);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco1_status_bits(void)
|
||||
{
|
||||
TestData d;
|
||||
uint16_t ticks = 8;
|
||||
uint16_t val;
|
||||
int ret;
|
||||
|
||||
d.args = NULL;
|
||||
d.noreboot = true;
|
||||
test_init(&d);
|
||||
|
||||
stop_tco(&d);
|
||||
clear_tco_status(&d);
|
||||
reset_on_second_timeout(false);
|
||||
set_tco_timeout(&d, ticks);
|
||||
load_tco(&d);
|
||||
start_tco(&d);
|
||||
clock_step(ticks * TCO_TICK_NSEC);
|
||||
|
||||
qpci_io_writeb(d.dev, d.tco_io_base + TCO_DAT_IN, 0);
|
||||
qpci_io_writeb(d.dev, d.tco_io_base + TCO_DAT_OUT, 0);
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS);
|
||||
ret = val & (TCO_TIMEOUT | SW_TCO_SMI | TCO_INT_STS) ? 1 : 0;
|
||||
g_assert(ret == 1);
|
||||
qpci_io_writew(d.dev, d.tco_io_base + TCO1_STS, val);
|
||||
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO1_STS), ==, 0);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
static void test_tco2_status_bits(void)
|
||||
{
|
||||
TestData d;
|
||||
uint16_t ticks = 8;
|
||||
uint16_t val;
|
||||
int ret;
|
||||
|
||||
d.args = NULL;
|
||||
d.noreboot = true;
|
||||
test_init(&d);
|
||||
|
||||
stop_tco(&d);
|
||||
clear_tco_status(&d);
|
||||
reset_on_second_timeout(true);
|
||||
set_tco_timeout(&d, ticks);
|
||||
load_tco(&d);
|
||||
start_tco(&d);
|
||||
clock_step(ticks * TCO_TICK_NSEC * 2);
|
||||
|
||||
val = qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS);
|
||||
ret = val & (TCO_SECOND_TO_STS | TCO_BOOT_STS) ? 1 : 0;
|
||||
g_assert(ret == 1);
|
||||
qpci_io_writew(d.dev, d.tco_io_base + TCO2_STS, val);
|
||||
g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO2_STS), ==, 0);
|
||||
qtest_end();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
||||
qtest_add_func("tco/defaults", test_tco_defaults);
|
||||
qtest_add_func("tco/timeout/no_action", test_tco_timeout);
|
||||
qtest_add_func("tco/timeout/no_action/max", test_tco_max_timeout);
|
||||
qtest_add_func("tco/second_timeout/pause", test_tco_second_timeout_pause);
|
||||
qtest_add_func("tco/second_timeout/reset", test_tco_second_timeout_reset);
|
||||
qtest_add_func("tco/second_timeout/shutdown",
|
||||
test_tco_second_timeout_shutdown);
|
||||
qtest_add_func("tco/second_timeout/none", test_tco_second_timeout_none);
|
||||
qtest_add_func("tco/counter", test_tco_ticks_counter);
|
||||
qtest_add_func("tco/tco1_control/bits", test_tco1_control_bits);
|
||||
qtest_add_func("tco/tco1_status/bits", test_tco1_status_bits);
|
||||
qtest_add_func("tco/tco2_status/bits", test_tco2_status_bits);
|
||||
return g_test_run();
|
||||
}
|
Loading…
Reference in New Issue