[PATCH 3/4] solaris: Implement I/O port API
Adam Jackson
ajax at redhat.com
Wed Sep 22 13:10:51 PDT 2010
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
src/solx_devfs.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 95 insertions(+), 1 deletions(-)
diff --git a/src/solx_devfs.c b/src/solx_devfs.c
index 73538b2..b935fcb 100644
--- a/src/solx_devfs.c
+++ b/src/solx_devfs.c
@@ -1,6 +1,7 @@
/*
* (C) Copyright IBM Corporation 2006
* Copyright 2007, 2009 Sun Microsystems, Inc.
+ * Copyright 2010 Red Hat, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,6 +36,7 @@
#include <sys/mman.h>
#include <errno.h>
#include <sys/pci.h>
+#include <sys/sysi86.h>
#include <libdevinfo.h>
#include "pci_tools.h"
@@ -132,6 +134,86 @@ static int get_config_header(int fd, uint8_t bus_no, uint8_t dev_no,
int pci_system_solx_devfs_create( void );
+#if defined(__x86)
+
+static int iopl_refcnt;
+
+static struct pci_io_handle *
+pci_device_solx_open_legacy_io(struct pci_io_handle *ret,
+ struct pci_device *dev, pciaddr_t base,
+ pciaddr_t size)
+{
+ if (!iopl_refcnt) {
+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
+ return NULL;
+ }
+ iopl_refcnt++;
+
+ ret->base = base;
+ ret->size = size;
+
+ return ret;
+}
+
+static struct pci_io_handle *
+pci_device_solx_open_device_io(struct pci_io_handle *ret,
+ struct pci_device *dev, int bar,
+ pciaddr_t base, pciaddr_t size)
+{
+ return pci_device_solx_open_legacy_io(ret, dev,
+ dev->regions[bar].base + base, size);
+
+}
+
+static void
+pci_device_solx_close_io(struct pci_device *dev,
+ struct pci_io_handle *handle)
+{
+ if (--iopl_refcnt == 0)
+ sysi86(SI86V86, V86SC_IOPL, 0);
+}
+
+static uint32_t
+pci_device_solx_read32(struct pci_io_handle *handle, uint32_t port)
+{
+ return inl(port + handle->base);
+}
+
+static uint16_t
+pci_device_solx_read16(struct pci_io_handle *handle, uint32_t port)
+{
+ return inw(port + handle->base);
+}
+
+static uint8_t
+pci_device_solx_read8(struct pci_io_handle *handle, uint32_t port)
+{
+ return inb(port + handle->base);
+}
+
+static void
+pci_device_solx_write32(struct pci_io_handle *handle, uint32_t port,
+ uint32_t data)
+{
+ outl(data, port + handle->base);
+}
+
+static void
+pci_device_solx_write16(struct pci_io_handle *handle, uint32_t port,
+ uint16_t data)
+{
+ outw(data, port + handle->base);
+}
+
+static void
+pci_device_solx_write8(struct pci_io_handle *handle, uint32_t port,
+ uint8_t data)
+{
+ outb(data, port + handle->base);
+}
+
+#endif
+
static const struct pci_system_methods solx_devfs_methods = {
.destroy = pci_system_solx_devfs_destroy,
.destroy_device = NULL,
@@ -143,7 +225,19 @@ static const struct pci_system_methods solx_devfs_methods = {
.read = pci_device_solx_devfs_read,
.write = pci_device_solx_devfs_write,
- .fill_capabilities = pci_fill_capabilities_generic
+ .fill_capabilities = pci_fill_capabilities_generic,
+
+#if defined(__x86)
+ .open_device_io = pci_device_solx_open_device_io,
+ .open_legacy_io = pci_device_solx_open_legacy_io,
+ .close_io = pci_device_solx_close_io,
+ .read32 = pci_device_solx_read32,
+ .read16 = pci_device_solx_read16,
+ .read8 = pci_device_solx_read8,
+ .write32 = pci_device_solx_write32,
+ .write16 = pci_device_solx_write16,
+ .write8 = pci_device_solx_write8,
+#endif
};
static nexus_t *
--
1.7.2.2
More information about the xorg-devel
mailing list