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, then issues an EOI
13/// message to the system interrupt controller so that subsequent interrupts can be delivered.
14///
15/// ## Safety
16///
17/// This function must only be called when handling an interrupt. It should _never_ be called by
18/// other Rust code.
19#[no_mangle]
20unsafe extern "cdecl" fn handle_external_interrupt(num: u32) {
21 unsafe {
22 InterruptPoller::set_pending(num);
23 pic::eoi(num);
24 }
25}