x86_q35/interrupts.rs
1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright Tock Contributors 2024.
4
5use x86::InterruptPoller;
6
7use super::pic;
8
9/// Handler for external interrupts.
10///
11/// This function is called by the [`x86`] crate to handle interrupts from external devices.
12/// It calls [`InterruptPoller::set_pending`] to mark the interrupt as pending, masks the specific
13/// interrupt, then issues an EOI message to the system interrupt controller so that subsequent
14/// interrupts can be delivered.
15///
16/// ## Safety
17///
18/// This function must only be called when handling an interrupt. It should _never_ be called by
19/// other Rust code.
20#[no_mangle]
21unsafe extern "cdecl" fn handle_external_interrupt(num: u32) {
22 unsafe {
23 InterruptPoller::set_pending(num);
24 pic::mask(num);
25 pic::eoi(num);
26 }
27}