[PATCH 2/4] x86: Implement I/O port API
Adam Jackson
ajax at redhat.com
Wed Sep 22 13:10:50 PDT 2010
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
src/x86_pci.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/src/x86_pci.c b/src/x86_pci.c
index c42d3e0..731a8e8 100644
--- a/src/x86_pci.c
+++ b/src/x86_pci.c
@@ -5,6 +5,7 @@
* (C) Copyright IBM Corporation 2006
* Copyright (c) 2008 Juan Romero Pardines
* Copyright (c) 2008 Mark Kettenis
+ * Copyright 2010 Red Hat, Inc.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -544,6 +545,72 @@ pci_device_x86_write(struct pci_device *dev, const void *data,
return 0;
}
+static struct pci_io_handle *
+pci_device_x86_open_legacy_io(struct pci_io_handle *ret,
+ struct pci_device *dev, pciaddr_t base,
+ pciaddr_t size)
+{
+ ret->base = base;
+ ret->size = size;
+
+ return ret;
+}
+
+static struct pci_io_handle *
+pci_device_x86_open_device_io(struct pci_io_handle *ret,
+ struct pci_device *dev, int bar,
+ pciaddr_t base, pciaddr_t size)
+{
+ return pci_device_x86_open_legacy_io(ret, dev,
+ dev->regions[bar].base + base, size);
+
+}
+
+static void
+pci_device_x86_close_io(struct pci_device *dev,
+ struct pci_io_handle *handle)
+{
+}
+
+static uint32_t
+pci_device_x86_read32(struct pci_io_handle *handle, uint32_t port)
+{
+ return inl(port + handle->base);
+}
+
+static uint16_t
+pci_device_x86_read16(struct pci_io_handle *handle, uint32_t port)
+{
+ return inw(port + handle->base);
+}
+
+static uint8_t
+pci_device_x86_read8(struct pci_io_handle *handle, uint32_t port)
+{
+ return inb(port + handle->base);
+}
+
+static void
+pci_device_x86_write32(struct pci_io_handle *handle, uint32_t port,
+ uint32_t data)
+{
+ outl(data, port + handle->base);
+}
+
+static void
+pci_device_x86_write16(struct pci_io_handle *handle, uint32_t port,
+ uint16_t data)
+{
+ outw(data, port + handle->base);
+}
+
+static void
+pci_device_x86_write8(struct pci_io_handle *handle, uint32_t port,
+ uint8_t data)
+{
+ outb(data, port + handle->base);
+}
+
static void
pci_system_x86_destroy(void)
{
@@ -559,6 +626,15 @@ static const struct pci_system_methods x86_pci_methods = {
.read = pci_device_x86_read,
.write = pci_device_x86_write,
.fill_capabilities = pci_fill_capabilities_generic,
+ .open_device_io = pci_device_x86_open_device_io,
+ .open_legacy_io = pci_device_x86_open_legacy_io,
+ .close_io = pci_device_x86_close_io,
+ .read32 = pci_device_x86_read32,
+ .read16 = pci_device_x86_read16,
+ .read8 = pci_device_x86_read8,
+ .write32 = pci_device_x86_write32,
+ .write16 = pci_device_x86_write16,
+ .write8 = pci_device_x86_write8,
};
static int pci_probe(struct pci_system_x86 *pci_sys_x86)
--
1.7.2.2
More information about the xorg-devel
mailing list