From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, ddutile@redhat.com, gleb@redhat.com,
mst@redhat.com
Subject: [Qemu-devel] [PATCH 5/6] acpi_piix4: Use pci_get/set_byte
Date: Tue, 06 Mar 2012 17:15:11 -0700 [thread overview]
Message-ID: <20120307001457.3079.22760.stgit@bling.home> (raw)
In-Reply-To: <20120307000340.3079.87515.stgit@bling.home>
Remove stray direct access
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/acpi_piix4.c | 53 +++++++++++++++++++++++++++--------------------------
1 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 7e766e5..4640e2e 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -178,11 +178,12 @@ static const IORangeOps pm_iorange_ops = {
static void apm_ctrl_changed(uint32_t val, void *arg)
{
PIIX4PMState *s = arg;
+ PCIDevice *dev = &s->dev;
/* ACPI specs 3.0, 4.7.2.5 */
acpi_pm1_cnt_update(&s->pm1_cnt, val == ACPI_ENABLE, val == ACPI_DISABLE);
- if (s->dev.config[0x5b] & (1 << 1)) {
+ if (pci_get_byte(dev->config + 0x5b) & (1 << 1)) {
if (s->smi_irq) {
qemu_irq_raise(s->smi_irq);
}
@@ -196,10 +197,11 @@ static void acpi_dbg_writel(void *opaque, uint32_t addr, uint32_t val)
static void pm_io_space_update(PIIX4PMState *s)
{
+ PCIDevice *dev = &s->dev;
uint32_t pm_io_base;
- if (s->dev.config[0x80] & 1) {
- pm_io_base = le32_to_cpu(*(uint32_t *)(s->dev.config + 0x40));
+ if (pci_get_byte(dev->config + 0x80) & 1) {
+ pm_io_base = pci_get_long(dev->config + 0x40);
pm_io_base &= 0xffc0;
/* XXX: need to improve memory and ioport allocation */
@@ -302,16 +304,16 @@ static void piix4_update_hotplug(PIIX4PMState *s)
static void piix4_reset(void *opaque)
{
PIIX4PMState *s = opaque;
- uint8_t *pci_conf = s->dev.config;
+ PCIDevice *dev = &s->dev;
- pci_conf[0x58] = 0;
- pci_conf[0x59] = 0;
- pci_conf[0x5a] = 0;
- pci_conf[0x5b] = 0;
+ pci_set_byte(dev->config + 0x58, 0);
+ pci_set_byte(dev->config + 0x59, 0);
+ pci_set_byte(dev->config + 0x5a, 0);
+ pci_set_byte(dev->config + 0x5b, 0);
if (s->kvm_enabled) {
/* Mark SMM as already inited (until KVM supports SMM). */
- pci_conf[0x5B] = 0x02;
+ pci_set_byte(dev->config + 0x5B, 0x02);
}
piix4_update_hotplug(s);
}
@@ -328,13 +330,14 @@ static void piix4_powerdown(void *opaque, int irq, int power_failing)
static void piix4_pm_machine_ready(Notifier *n, void *opaque)
{
PIIX4PMState *s = container_of(n, PIIX4PMState, machine_ready);
- uint8_t *pci_conf;
+ PCIDevice *dev = &s->dev;
- pci_conf = s->dev.config;
- pci_conf[0x5f] = (isa_is_ioport_assigned(0x378) ? 0x80 : 0) | 0x10;
- pci_conf[0x63] = 0x60;
- pci_conf[0x67] = (isa_is_ioport_assigned(0x3f8) ? 0x08 : 0) |
- (isa_is_ioport_assigned(0x2f8) ? 0x90 : 0);
+ pci_set_byte(dev->config + 0x5f,
+ (isa_is_ioport_assigned(0x378) ? 0x80 : 0) | 0x10);
+ pci_set_byte(dev->config + 0x63, 0x60);
+ pci_set_byte(dev->config + 0x67,
+ (isa_is_ioport_assigned(0x3f8) ? 0x08 : 0) |
+ (isa_is_ioport_assigned(0x2f8) ? 0x90 : 0));
}
@@ -353,18 +356,16 @@ static PIIX4PMState *global_piix4_pm_state; /* cpu hotadd */
static int piix4_pm_initfn(PCIDevice *dev)
{
PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev);
- uint8_t *pci_conf;
/* for cpu hotadd */
global_piix4_pm_state = s;
- pci_conf = s->dev.config;
- pci_conf[0x06] = 0x80;
- pci_conf[0x07] = 0x02;
- pci_conf[0x09] = 0x00;
- pci_conf[0x3d] = 0x01; // interrupt pin 1
+ pci_set_byte(dev->config + 0x06, 0x80);
+ pci_set_byte(dev->config + 0x07, 0x02);
+ pci_set_byte(dev->config + 0x09, 0x00);
+ pci_set_byte(dev->config + 0x3d, 0x01); /* interrupt pin 1 */
- pci_conf[0x40] = 0x01; /* PM io base read only bit */
+ pci_set_byte(dev->config + 0x40, 0x01); /* PM io base read only bit */
/* APM */
apm_init(&s->apm, apm_ctrl_changed, s);
@@ -374,14 +375,14 @@ static int piix4_pm_initfn(PCIDevice *dev)
if (s->kvm_enabled) {
/* Mark SMM as already inited to prevent SMM from running. KVM does not
* support SMM mode. */
- pci_conf[0x5B] = 0x02;
+ pci_set_byte(dev->config + 0x5B, 0x02);
}
/* XXX: which specification is used ? The i82731AB has different
mappings */
- pci_conf[0x90] = s->smb_io_base | 1;
- pci_conf[0x91] = s->smb_io_base >> 8;
- pci_conf[0xd2] = 0x09;
+ pci_set_byte(dev->config + 0x90, s->smb_io_base | 1);
+ pci_set_byte(dev->config + 0x91, s->smb_io_base >> 8);
+ pci_set_byte(dev->config + 0xd2, 0x09);
register_ioport_write(s->smb_io_base, 64, 1, smb_ioport_writeb, &s->smb);
register_ioport_read(s->smb_io_base, 64, 1, smb_ioport_readb, &s->smb);
next prev parent reply other threads:[~2012-03-07 0:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 0:13 [Qemu-devel] [PATCH 0/6] PCI hotplug improvements Alex Williamson
2012-03-07 0:13 ` [Qemu-devel] [PATCH 1/6] acpi_piix4: Disallow write to up/down PCI hotplug registers Alex Williamson
2012-03-07 0:14 ` [Qemu-devel] [PATCH 2/6] acpi_piix4: Only allow writes to PCI hotplug eject register Alex Williamson
2012-03-07 0:14 ` [Qemu-devel] [PATCH 3/6] pci: Add notifier for device probing Alex Williamson
2012-03-07 9:19 ` Paolo Bonzini
2012-03-07 20:12 ` Alex Williamson
2012-03-07 0:14 ` [Qemu-devel] [PATCH 4/6] acpi_piix4: Track PCI hotplug status and allow non-ACPI remove path Alex Williamson
2012-03-11 21:57 ` Michael S. Tsirkin
2012-03-07 0:15 ` Alex Williamson [this message]
2012-03-07 0:15 ` [Qemu-devel] [PATCH 6/6] api_piix4: Remove PCI_RMV_BASE write code Alex Williamson
2012-03-07 12:43 ` [Qemu-devel] [PATCH 0/6] PCI hotplug improvements Gleb Natapov
2012-03-07 17:20 ` Alex Williamson
2012-03-07 18:59 ` Gleb Natapov
2012-03-07 19:51 ` Alex Williamson
2012-03-07 21:00 ` Gleb Natapov
2012-03-07 21:44 ` Alex Williamson
2012-03-07 22:17 ` Gleb Natapov
2012-03-07 22:46 ` Alex Williamson
2012-03-08 12:39 ` Gleb Natapov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120307001457.3079.22760.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=ddutile@redhat.com \
--cc=gleb@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).