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