Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | |
2 | /* Project: OSLib |
||
3 | * Description: The OS Construction Kit |
||
4 | * Date: 1.6.2000 |
||
5 | * Idea by: Luca Abeni & Gerardo Lamastra |
||
6 | * |
||
7 | * OSLib is an SO project aimed at developing a common, easy-to-use |
||
8 | * low-level infrastructure for developing OS kernels and Embedded |
||
9 | * Applications; it partially derives from the HARTIK project but it |
||
10 | * currently is independently developed. |
||
11 | * |
||
12 | * OSLib is distributed under GPL License, and some of its code has |
||
13 | * been derived from the Linux kernel source; also some important |
||
14 | * ideas come from studying the DJGPP go32 extender. |
||
15 | * |
||
16 | * We acknowledge the Linux Community, Free Software Foundation, |
||
17 | * D.J. Delorie and all the other developers who believe in the |
||
18 | * freedom of software and ideas. |
||
19 | * |
||
20 | * For legalese, check out the included GPL license. |
||
21 | */ |
||
22 | |||
23 | /* Interrupt Events */ |
||
24 | |||
25 | #include <ll/i386/stdlib.h> |
||
26 | #include <ll/i386/mem.h> |
||
27 | #include <ll/i386/error.h> |
||
28 | #include <ll/i386/hw-arch.h> |
||
29 | #include <ll/i386/pit.h> |
||
30 | #include <ll/sys/ll/ll-data.h> |
||
31 | #include <ll/sys/ll/ll-instr.h> |
||
32 | #include <ll/sys/ll/time.h> |
||
33 | #include <ll/sys/ll/event.h> |
||
34 | |||
35 | FILE(IntEvent); |
||
36 | |||
37 | extern int activeInt; |
||
38 | void (*evt_prol) (void) = NULL; |
||
39 | void (*evt_epil) (void) = NULL; |
||
40 | |||
41 | struct intentry irqs[16]; |
||
42 | |||
43 | void irq_init(void) |
||
44 | { |
||
45 | int i; |
||
46 | |||
47 | /* Initialize the interrupt handlers list!!! */ |
||
48 | for (i = 0; i < 16; i++) { |
||
49 | irqs[i].status = INTSTAT_FREE; |
||
50 | irqs[i].index = i; |
||
51 | irqs[i].handler = NULL; /* Paranoia */ |
||
52 | irqs[i].par = NULL; /* Paranoia */ |
||
53 | } |
||
54 | activeInt = 0; |
||
55 | } |
||
56 | |||
57 | int ll_ActiveInt(void) |
||
58 | { |
||
59 | return activeInt; |
||
60 | } |
||
61 | |||
62 | int irq_bind(int irq, void (*handler) (void *p), DWORD flags) |
||
63 | { |
||
64 | |||
65 | cli(); /* Warning!!! Need to be changed... |
||
66 | Protect or not to protect??? |
||
67 | Probably save_flags??? */ |
||
68 | if ((irqs[irq].status != INTSTAT_FREE) && |
||
69 | ((flags & INT_FORCE) != INT_FORCE)) { |
||
70 | return -1; |
||
71 | } |
||
72 | |||
73 | irqs[irq].status = INTSTAT_ASSIGNED; |
||
74 | sti(); |
||
75 | |||
76 | if (handler != NULL) { |
||
77 | irqs[irq].handler = handler; |
||
78 | irqs[irq].par = &(irqs[irq].index); |
||
79 | irqs[irq].flags = flags; |
||
80 | } else { |
||
81 | irqs[irq].status = INTSTAT_FREE; |
||
82 | } |
||
83 | |||
84 | return 1; |
||
85 | } |
||
86 | |||
87 | void act_int(BYTE n) |
||
88 | { |
||
89 | static int ai_called = 0; |
||
90 | |||
91 | activeInt++; |
||
92 | if (activeInt == 1 && evt_prol != NULL) { |
||
93 | evt_prol(); |
||
94 | } |
||
95 | if (irqs[n].status == INTSTAT_ASSIGNED) { |
||
96 | irqs[n].status = INTSTAT_BUSY; |
||
97 | if (irqs[n].flags & INT_PREEMPTABLE) { |
||
98 | sti(); |
||
99 | } |
||
100 | irqs[n].handler(irqs[n].par); |
||
101 | if (irqs[n].flags & INT_PREEMPTABLE) { |
||
102 | cli(); |
||
103 | } |
||
104 | irqs[n].status = INTSTAT_ASSIGNED; |
||
105 | } |
||
106 | ai_called++; |
||
107 | if (activeInt == 1 && evt_epil != NULL) { |
||
108 | evt_epil(); |
||
109 | } |
||
110 | activeInt--; |
||
111 | } |