1 |
2 |
idiolatrie |
/******************************************************************************
|
2 |
|
|
* Interrupts *
|
3 |
|
|
******************************************************************************
|
4 |
|
|
* Copyright (C)2011 Mathias Hörtnagl <mathias.hoertnagl@gmail.com> *
|
5 |
|
|
* *
|
6 |
|
|
* This program is free software: you can redistribute it and/or modify *
|
7 |
|
|
* it under the terms of the GNU General Public License as published by *
|
8 |
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
9 |
|
|
* (at your option) any later version. *
|
10 |
|
|
* *
|
11 |
|
|
* This program is distributed in the hope that it will be useful, *
|
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
14 |
|
|
* GNU General Public License for more details. *
|
15 |
|
|
* *
|
16 |
|
|
* You should have received a copy of the GNU General Public License *
|
17 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
18 |
|
|
******************************************************************************/
|
19 |
|
|
#include "stddef.h"
|
20 |
|
|
|
21 |
|
|
#ifndef _INTERRUPT_H
|
22 |
|
|
#define _INTERRUPT_H
|
23 |
|
|
|
24 |
|
|
/* Register a callback at line IRQ_X. */
|
25 |
|
|
#define IRQ_PIT0 0
|
26 |
|
|
#define IRQ_1 1
|
27 |
|
|
#define IRQ_2 2
|
28 |
|
|
#define IRQ_3 3
|
29 |
|
|
#define IRQ_4 4
|
30 |
|
|
#define IRQ_5 5
|
31 |
|
|
#define IRQ_6 6
|
32 |
|
|
#define IRQ_KEYB 7
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/* Enable or disable interrupt handling. */
|
36 |
|
|
|
37 |
|
|
#define INTR_EN 0x0001 /* Global interrupt enable. */
|
38 |
|
|
#define INTR_PIT0 0x0100 /* Possible interrupt line masks. */
|
39 |
|
|
#define INTR_1 0x0200
|
40 |
|
|
#define INTR_2 0x0400
|
41 |
|
|
#define INTR_3 0x0800
|
42 |
|
|
#define INTR_4 0x1000
|
43 |
|
|
#define INTR_5 0x2000
|
44 |
|
|
#define INTR_6 0x4000
|
45 |
|
|
#define INTR_KEYB 0x8000
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
/* Type definition for the interrupt callback routines. A callback routine is
|
49 |
|
|
a function with no arguments and no return value. */
|
50 |
|
|
typedef void (*callback)();
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
/******************************************************************************
|
54 |
|
|
* Status Register Operations *
|
55 |
|
|
******************************************************************************/
|
56 |
|
|
/* Set interrupts of mask. */
|
57 |
|
|
extern void set_intr(ushort mask);
|
58 |
|
|
|
59 |
|
|
/* Unset interrupts of mask. */
|
60 |
|
|
extern void unset_intr(ushort mask);
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
/******************************************************************************
|
64 |
|
|
* Callback Functions *
|
65 |
|
|
******************************************************************************/
|
66 |
|
|
/* Set a interrupt callback to NULL. If a interrupt callback points to NULL,
|
67 |
|
|
the interrupt will be ignored. */
|
68 |
|
|
extern void register_callback(int irq_line, callback c);
|
69 |
|
|
|
70 |
|
|
/* Call the interrupt routines one by one starting with the interrupt at INTR_0
|
71 |
|
|
(or IRQ_0). Interrupts with NULL interrupt routines are ignored. */
|
72 |
|
|
extern void free_callback(int irq_line);
|
73 |
|
|
|
74 |
|
|
#endif
|