-
Notifications
You must be signed in to change notification settings - Fork 10
/
irq.rs
51 lines (46 loc) · 1.19 KB
/
irq.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* diosix top-level code for handling hardware interrupts and software exceptions
*
* (c) Chris Williams, 2018.
*
* See LICENSE for usage and copying.
*/
/* platform-specific code must implement all this */
use platform;
use platform::common::IRQType;
use platform::common::IRQContext;
use platform::common::PrivilegeMode;
use platform::common::IRQ;
/* kernel_irq_handler
entry point for hardware interrupts and software exceptions, collectively known as IRQs.
call down into platform-specific handlers
=> context = platform-specific context of the IRQ
*/
#[no_mangle]
pub extern "C" fn kernel_irq_handler(context: IRQContext)
{
let irq = platform::common::irq::dispatch(context);
match irq.irq_type
{
IRQType::Exception => exception(irq),
IRQType::Interrupt => interrupt(irq),
};
}
/* handle software exception */
fn exception(irq: IRQ)
{
match (irq.fatal, irq.privilege_mode)
{
(true, PrivilegeMode::Kernel) =>
{
kalert!("Fatal exception in kernel: {}", irq.debug_cause());
loop {}
},
(_, _) => () /* ignore everything else */
}
}
/* handle hardware interrupt */
fn interrupt(_irq: platform::common::IRQ)
{
kalert!("Hardware interrupt");
loop {}
}