2 * arch/s390/kernel/s390_ext.c
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Holger Smolinski (Holger.Smolinski@de.ibm.com),
7 * Martin Schwidefsky (schwidefsky@de.ibm.com)
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
13 #include <linux/ftrace.h>
14 #include <linux/errno.h>
15 #include <linux/kernel_stat.h>
16 #include <linux/interrupt.h>
17 #include <asm/cputime.h>
18 #include <asm/lowcore.h>
19 #include <asm/s390_ext.h>
20 #include <asm/irq_regs.h>
25 * ext_int_hash[index] is the start of the list for all external interrupts
26 * that hash to this index. With the current set of external interrupts
27 * (0x1202 external call, 0x1004 cpu timer, 0x2401 hwc console, 0x4000
28 * iucv and 0x2603 pfault) this is always the first element.
30 ext_int_info_t
*ext_int_hash
[256] = { NULL
, };
32 static inline int ext_hash(__u16 code
)
34 return (code
+ (code
>> 9)) & 0xff;
37 int register_external_interrupt(__u16 code
, ext_int_handler_t handler
)
42 p
= kmalloc(sizeof(ext_int_info_t
), GFP_ATOMIC
);
47 index
= ext_hash(code
);
48 p
->next
= ext_int_hash
[index
];
49 ext_int_hash
[index
] = p
;
53 int register_early_external_interrupt(__u16 code
, ext_int_handler_t handler
,
62 index
= ext_hash(code
);
63 p
->next
= ext_int_hash
[index
];
64 ext_int_hash
[index
] = p
;
68 int unregister_external_interrupt(__u16 code
, ext_int_handler_t handler
)
70 ext_int_info_t
*p
, *q
;
73 index
= ext_hash(code
);
75 p
= ext_int_hash
[index
];
77 if (p
->code
== code
&& p
->handler
== handler
)
87 ext_int_hash
[index
] = p
->next
;
92 int unregister_early_external_interrupt(__u16 code
, ext_int_handler_t handler
,
98 if (p
== NULL
|| p
->code
!= code
|| p
->handler
!= handler
)
100 index
= ext_hash(code
);
101 q
= ext_int_hash
[index
];
112 ext_int_hash
[index
] = p
->next
;
116 void __irq_entry
do_extint(struct pt_regs
*regs
, unsigned short code
)
120 struct pt_regs
*old_regs
;
122 old_regs
= set_irq_regs(regs
);
125 if (S390_lowcore
.int_clock
>= S390_lowcore
.clock_comparator
)
126 /* Serve timer interrupts first. */
127 clock_comparator_work();
128 kstat_cpu(smp_processor_id()).irqs
[EXTERNAL_INTERRUPT
]++;
129 index
= ext_hash(code
);
130 for (p
= ext_int_hash
[index
]; p
; p
= p
->next
) {
131 if (likely(p
->code
== code
))
135 set_irq_regs(old_regs
);
138 EXPORT_SYMBOL(register_external_interrupt
);
139 EXPORT_SYMBOL(unregister_external_interrupt
);