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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 */ 25 26 #include <sys/types.h> 27 #include <sys/stat.h> 28 #include <sys/pci.h> 29 #include <fcntl.h> 30 #include <unistd.h> 31 #include <stropts.h> 32 #include <stdio.h> 33 #include <errno.h> 34 35 /* Non-shipping header - see Makefile.PL */ 36 #include <sys/pci_tools.h> 37 38 #include "EXTERN.h" 39 #include "perl.h" 40 #include "XSUB.h" 41 42 static int 43 open_dev(char *path) 44 { 45 char intrpath[MAXPATHLEN]; 46 47 (void) strcpy(intrpath, "/devices"); 48 (void) strcat(intrpath, path); 49 (void) strcat(intrpath, ":intr"); 50 return (open(intrpath, O_RDWR)); 51 } 52 53 MODULE = Sun::Solaris::Intrs PACKAGE = Sun::Solaris::Intrs 54 PROTOTYPES: ENABLE 55 56 int 57 intrmove(path, ino, cpu, num_ino) 58 char *path 59 int ino 60 int cpu 61 int num_ino 62 INIT: 63 int fd, ret; 64 pcitool_intr_set_t iset; 65 66 CODE: 67 if ((fd = open_dev(path)) == -1) { 68 XSRETURN_UNDEF; 69 } 70 iset.ino = ino; 71 iset.cpu_id = cpu; 72 iset.flags = (num_ino > 1) ? PCITOOL_INTR_FLAG_SET_GROUP : 0; 73 iset.user_version = PCITOOL_VERSION; 74 75 ret = ioctl(fd, PCITOOL_DEVICE_SET_INTR, &iset); 76 77 if (ret == -1) { 78 XSRETURN_UNDEF; 79 } 80 (void) close(fd); 81 XSRETURN_YES; 82 83 int 84 is_pcplusmp(path) 85 char *path 86 87 INIT: 88 int fd, ret; 89 pcitool_intr_info_t iinfo; 90 91 CODE: 92 if ((fd = open_dev(path)) == -1) { 93 XSRETURN_UNDEF; 94 } 95 iinfo.user_version = PCITOOL_VERSION; 96 97 ret = ioctl(fd, PCITOOL_SYSTEM_INTR_INFO, &iinfo); 98 (void) close(fd); 99 100 if (ret == -1) { 101 XSRETURN_UNDEF; 102 } 103 104 if (iinfo.ctlr_type == PCITOOL_CTLR_TYPE_PCPLUSMP) { 105 XSRETURN_YES; 106 } 107 108 XSRETURN_NO; 109