1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #include <sys/types.h> 28 #include <sys/stat.h> 29 #include <sys/pci.h> 30 #include <fcntl.h> 31 #include <unistd.h> 32 #include <stropts.h> 33 #include <stdio.h> 34 #include <errno.h> 35 36 /* Non-shipping header - see Makefile.PL */ 37 #include <pci_tools.h> 38 39 #include "EXTERN.h" 40 #include "perl.h" 41 #include "XSUB.h" 42 43 static int 44 open_dev(char *path) 45 { 46 char intrpath[MAXPATHLEN]; 47 48 (void) strcpy(intrpath, "/devices"); 49 (void) strcat(intrpath, path); 50 (void) strcat(intrpath, ":intr"); 51 return (open(intrpath, O_RDWR)); 52 } 53 54 MODULE = Sun::Solaris::Intrs PACKAGE = Sun::Solaris::Intrs 55 PROTOTYPES: ENABLE 56 57 int 58 intrmove(path, ino, cpu, num_ino) 59 char *path 60 int ino 61 int cpu 62 int num_ino 63 INIT: 64 int fd, ret; 65 pcitool_intr_set_t iset; 66 67 CODE: 68 if ((fd = open_dev(path)) == -1) { 69 XSRETURN_UNDEF; 70 } 71 iset.ino = ino; 72 iset.cpu_id = cpu; 73 iset.flags = (num_ino > 1) ? PCITOOL_INTR_FLAG_SET_GROUP : 0; 74 iset.user_version = PCITOOL_VERSION; 75 76 ret = ioctl(fd, PCITOOL_DEVICE_SET_INTR, &iset); 77 78 if (ret == -1) { 79 XSRETURN_UNDEF; 80 } 81 (void) close(fd); 82 XSRETURN_YES; 83 84 int 85 is_pcplusmp(path) 86 char *path 87 88 INIT: 89 int fd, ret; 90 pcitool_intr_info_t iinfo; 91 92 CODE: 93 if ((fd = open_dev(path)) == -1) { 94 XSRETURN_UNDEF; 95 } 96 iinfo.user_version = PCITOOL_VERSION; 97 98 ret = ioctl(fd, PCITOOL_SYSTEM_INTR_INFO, &iinfo); 99 (void) close(fd); 100 101 if (ret == -1) { 102 XSRETURN_UNDEF; 103 } 104 105 if (iinfo.ctlr_type == PCITOOL_CTLR_TYPE_PCPLUSMP) { 106 XSRETURN_YES; 107 } 108 109 XSRETURN_NO; 110