2
|
1 |
/*
|
|
2 |
* Copyright 1994-2000 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
* Interrupt dispatch interface
|
|
28 |
*/
|
|
29 |
|
|
30 |
#ifndef _JAVASOFT_INTERRUPT_H_
|
|
31 |
#define _JAVASOFT_INTERRUPT_H_
|
|
32 |
|
|
33 |
/*
|
|
34 |
* Type definitions.
|
|
35 |
*/
|
|
36 |
|
|
37 |
/*-
|
|
38 |
* A function that handles interrupt dispatch requests is of type
|
|
39 |
* intr_handler_t. This type definition is mostly for convenience.
|
|
40 |
* A declaration of a handler function, should look like this:
|
|
41 |
*
|
|
42 |
* void myHandler(int interrupt, void *siginfo, void *context, void *arg);
|
|
43 |
*
|
|
44 |
* An intr_handler_t is constrained:
|
|
45 |
*
|
|
46 |
* - It runs on the exception stack.
|
|
47 |
* - It cannot yield.
|
|
48 |
* - It cannot allocate/free memory.
|
|
49 |
* - It can only call interrupt-safe routines.
|
|
50 |
*
|
|
51 |
* "arg" is set to the "handlerArg" specified in intrRegister().
|
|
52 |
*/
|
|
53 |
typedef void (*intr_handler_t)(int interrupt, void *siginfo,
|
|
54 |
void *context, void *arg);
|
|
55 |
|
|
56 |
/*
|
|
57 |
* Routines.
|
|
58 |
*/
|
|
59 |
|
|
60 |
/* Initialize the interrupt system */
|
|
61 |
void intrInit(void);
|
|
62 |
|
|
63 |
/* Set a handler for a particular interrupt */
|
|
64 |
signal_handler_t intrRegister(int interrupt, intr_handler_t handler,
|
|
65 |
void *handlerArg);
|
|
66 |
|
|
67 |
/* Dispatch an interrupt (called from the low-level handlers) */
|
|
68 |
void intrDispatch(int interrupt, void *siginfo, void *context);
|
|
69 |
|
|
70 |
/*-
|
|
71 |
* The target specific header file should define the following
|
|
72 |
*
|
|
73 |
* Constants
|
|
74 |
*
|
|
75 |
* N_INTERRUPTS - The number of interrupt channels. These
|
|
76 |
* are numbered from 0 to (N_INTERRUPTS - 1).
|
|
77 |
*/
|
|
78 |
#ifdef __linux__
|
|
79 |
#define N_INTERRUPTS NSIG /* 0 to NSIG - 1*/
|
|
80 |
#else
|
|
81 |
#define N_INTERRUPTS 32 /* 0 to 31 */
|
|
82 |
#endif
|
|
83 |
|
|
84 |
/*-
|
|
85 |
* Routines/Macros that control whether interrupts are enabled or
|
|
86 |
* not.
|
|
87 |
*
|
|
88 |
* void intrLock(void) - Disable all interrupts.
|
|
89 |
* void intrUnlock(void) - Enable all interrupts.
|
|
90 |
*
|
|
91 |
* Note: intrLock()/intrUnlock() pairs can be nested.
|
|
92 |
*
|
|
93 |
*/
|
|
94 |
|
|
95 |
void intrLock(void);
|
|
96 |
void intrUnlock(void);
|
|
97 |
|
|
98 |
/*-
|
|
99 |
* intrInitMD() --
|
|
100 |
* Initialize the machine-dependant interrupt software.
|
|
101 |
*
|
|
102 |
* This routine should leave the all interrupts disabled as if
|
|
103 |
* one (1) intrLock() had been called. At the end of the
|
|
104 |
* bootstrap, a single intrUnlock(), will be called to turn
|
|
105 |
* interrupts on.
|
|
106 |
*/
|
|
107 |
|
|
108 |
void intrInitMD(void);
|
|
109 |
|
|
110 |
#if defined(__solaris__) && !defined(SA_SIGINFO)
|
|
111 |
#error signal.h has not been included?
|
|
112 |
#endif
|
|
113 |
|
|
114 |
#ifdef SA_SIGINFO
|
|
115 |
/* Thread implementation dependent interrupt dispatcher. */
|
|
116 |
void intrDispatchMD(int sig, siginfo_t *info, void *uc);
|
|
117 |
#else
|
|
118 |
void intrDispatchMD(int sig);
|
|
119 |
#endif
|
|
120 |
|
|
121 |
/* Whether the signal is used by the HPI implementation */
|
|
122 |
bool_t intrInUse(int sig);
|
|
123 |
|
|
124 |
#endif /* !_JAVASOFT_INTERRUPT_H_ */
|