Initial version of interrupt info and move code.
authorAlbert Lee <trisk@forkgnu.org>
Mon, 19 Apr 2010 14:46:01 -0400
changeset 2 ee32231c211b
parent 1 6c022a2f0c47
child 3 380ada8fd621
Initial version of interrupt info and move code.
intrs.c
intrs.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/intrs.c	Mon Apr 19 14:46:01 2010 -0400
@@ -0,0 +1,97 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates.  All rights reserved.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/pci.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stropts.h>
+#include <errno.h>
+#include <string.h>
+
+/* Non-shipping header */
+#include <pci_tools.h>
+
+static int
+open_dev(const char *path)
+{
+	char intrpath[MAXPATHLEN];
+
+	(void) strcpy(intrpath, "/devices");
+	(void) strlcat(intrpath, path, sizeof (intrpath));
+	(void) strlcat(intrpath, ":intr", sizeof (intrpath));
+	return (open(intrpath, O_RDWR));
+}
+
+int
+intrmove(const char *path, int ino, int cpu, int num_ino)
+{
+	int fd, ret;
+	pcitool_intr_set_t iset;
+
+	if ((fd = open_dev(path)) == -1) {
+		return fd;
+	}
+	iset.ino = ino;
+	iset.cpu_id = cpu;
+	iset.flags = (num_ino > 1) ? PCITOOL_INTR_FLAG_SET_GROUP : 0;
+	iset.user_version = PCITOOL_VERSION;
+
+	ret = ioctl(fd, PCITOOL_DEVICE_SET_INTR, &iset);
+	(void) close(fd);
+
+	if (ret == -1) {
+		return ret;
+	}
+	return 1;
+}
+
+int
+intrinfo(const char *path, int *num_intr)
+{
+	int fd, ret;
+	pcitool_intr_info_t iinfo;
+
+	if ((fd = open_dev(path)) == -1) {
+		return fd;
+	}
+	iinfo.user_version = PCITOOL_VERSION;
+
+	ret = ioctl(fd, PCITOOL_SYSTEM_INTR_INFO, &iinfo);
+	(void) close(fd);
+
+	if (ret == -1) {
+		return ret;
+	}
+
+	*num_intr = iinfo.num_intr;
+
+	if (iinfo.ctlr_type == PCITOOL_CTLR_TYPE_PCPLUSMP) {
+		return 1;
+	}
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/intrs.h	Mon Apr 19 14:46:01 2010 -0400
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates.  All rights reserved.
+ */
+
+#ifndef _INTRS_H
+#define _INTRS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int intrmove(const char *path, int ino, int cpu, int num_ino);
+
+int intrinfo(const char *path, int *num_intr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _INTRS_H */