1172Sesolom /*
2172Sesolom * CDDL HEADER START
3172Sesolom *
4172Sesolom * The contents of this file are subject to the terms of the
51277Salanbur * Common Development and Distribution License (the "License").
61277Salanbur * You may not use this file except in compliance with the License.
7172Sesolom *
8172Sesolom * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9172Sesolom * or http://www.opensolaris.org/os/licensing.
10172Sesolom * See the License for the specific language governing permissions
11172Sesolom * and limitations under the License.
12172Sesolom *
13172Sesolom * When distributing Covered Code, include this CDDL HEADER in each
14172Sesolom * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15172Sesolom * If applicable, add the following below this CDDL HEADER, with the
16172Sesolom * fields enclosed by brackets "[]" replaced with your own identifying
17172Sesolom * information: Portions Copyright [yyyy] [name of copyright owner]
18172Sesolom *
19172Sesolom * CDDL HEADER END
20172Sesolom */
21172Sesolom
22172Sesolom /*
2312639SJohn.Sonnenschein@Oracle.com * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24172Sesolom */
25172Sesolom
26172Sesolom #include <sys/types.h>
27172Sesolom #include <sys/stat.h>
28172Sesolom #include <sys/pci.h>
29172Sesolom #include <fcntl.h>
30172Sesolom #include <unistd.h>
31172Sesolom #include <stropts.h>
32172Sesolom #include <stdio.h>
33172Sesolom #include <errno.h>
34172Sesolom
351277Salanbur /* Non-shipping header - see Makefile.PL */
3612639SJohn.Sonnenschein@Oracle.com #include <sys/pci_tools.h>
37172Sesolom
38172Sesolom #include "EXTERN.h"
39172Sesolom #include "perl.h"
40172Sesolom #include "XSUB.h"
41172Sesolom
424397Sschwartz static int
open_dev(char * path)434397Sschwartz open_dev(char *path)
444397Sschwartz {
454397Sschwartz char intrpath[MAXPATHLEN];
464397Sschwartz
474397Sschwartz (void) strcpy(intrpath, "/devices");
484397Sschwartz (void) strcat(intrpath, path);
494397Sschwartz (void) strcat(intrpath, ":intr");
504397Sschwartz return (open(intrpath, O_RDWR));
514397Sschwartz }
524397Sschwartz
53172Sesolom MODULE = Sun::Solaris::Intrs PACKAGE = Sun::Solaris::Intrs
54172Sesolom PROTOTYPES: ENABLE
55172Sesolom
56172Sesolom int
intrmove(path,oldcpu,ino,cpu,num_ino)57*12683SJimmy.Vetayases@oracle.com intrmove(path, oldcpu, ino, cpu, num_ino)
58172Sesolom char *path
59*12683SJimmy.Vetayases@oracle.com int oldcpu
60172Sesolom int ino
61172Sesolom int cpu
624397Sschwartz int num_ino
63172Sesolom INIT:
644397Sschwartz int fd, ret;
65172Sesolom pcitool_intr_set_t iset;
66172Sesolom
67172Sesolom CODE:
684397Sschwartz if ((fd = open_dev(path)) == -1) {
694397Sschwartz XSRETURN_UNDEF;
70172Sesolom }
71*12683SJimmy.Vetayases@oracle.com iset.old_cpu = oldcpu;
72172Sesolom iset.ino = ino;
73172Sesolom iset.cpu_id = cpu;
7410053SEvan.Yan@Sun.COM iset.flags = (num_ino > 1) ? PCITOOL_INTR_FLAG_SET_GROUP : 0;
754397Sschwartz iset.user_version = PCITOOL_VERSION;
76172Sesolom
77172Sesolom ret = ioctl(fd, PCITOOL_DEVICE_SET_INTR, &iset);
78172Sesolom
79172Sesolom if (ret == -1) {
80172Sesolom XSRETURN_UNDEF;
81172Sesolom }
824397Sschwartz (void) close(fd);
83172Sesolom XSRETURN_YES;
844397Sschwartz
854397Sschwartz int
86*12683SJimmy.Vetayases@oracle.com is_apic(path)
874397Sschwartz char *path
884397Sschwartz
894397Sschwartz INIT:
904397Sschwartz int fd, ret;
914397Sschwartz pcitool_intr_info_t iinfo;
924397Sschwartz
934397Sschwartz CODE:
944397Sschwartz if ((fd = open_dev(path)) == -1) {
954397Sschwartz XSRETURN_UNDEF;
964397Sschwartz }
974397Sschwartz iinfo.user_version = PCITOOL_VERSION;
984397Sschwartz
994397Sschwartz ret = ioctl(fd, PCITOOL_SYSTEM_INTR_INFO, &iinfo);
1004397Sschwartz (void) close(fd);
1014397Sschwartz
1024397Sschwartz if (ret == -1) {
1034397Sschwartz XSRETURN_UNDEF;
1044397Sschwartz }
1054397Sschwartz
106*12683SJimmy.Vetayases@oracle.com if (iinfo.ctlr_type == PCITOOL_CTLR_TYPE_PCPLUSMP ||
107*12683SJimmy.Vetayases@oracle.com iinfo.ctlr_type == PCITOOL_CTLR_TYPE_APIX) {
1084397Sschwartz XSRETURN_YES;
1094397Sschwartz }
1104397Sschwartz
1114397Sschwartz XSRETURN_NO;
112