Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/instructions/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ pub fn int3() {

/// Generate a software interrupt by invoking the `int` instruction.
///
/// This currently needs to be a macro because the `int` argument needs to be an
/// immediate. This macro will be replaced by a generic function when support for
/// const generics is implemented in Rust.
/// ## Safety
///
/// Invoking an arbitrary interrupt is unsafe. It can cause your system to
/// crash if you invoke a double-fault (#8) or machine-check (#18) exception.
/// It can also cause memory/register corruption depending on the interrupt
/// implementation (if it expects values/pointers to be passed in registers).
#[cfg(feature = "inline_asm")]
#[cfg_attr(docsrs, doc(cfg(any(feature = "nightly", feature = "inline_asm"))))]
#[macro_export]
macro_rules! software_interrupt {
($x:expr) => {{
asm!("int {id}", id = const $x, options(nomem, nostack));
}};
pub unsafe fn software_interrupt<const NUM: u8>() {
asm!("int {num}", num = const NUM, options(nomem, nostack));
}