Skip to content

feat(idt): make it available in the stable Rust #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 7, 2021
27 changes: 12 additions & 15 deletions src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
// except according to those terms.

//! Provides types for the Interrupt Descriptor Table and its entries.
//!
//! # For the users who use this module with the stable Rust
//!
//! The following types are not used and not constructable.
//!
//! - [`DivergingHandlerFunc`]
//! - [`DivergingHandlerFuncWithErrCode`]
//! - [`HandlerFunc`]
//! - [`HandlerFuncWithErrCode`]
//! - [`PageFaultHandlerFunc`]
//!
//! These types are defined for the compatibility with the Nightly Rust.

use crate::{PrivilegeLevel, VirtAddr};
use bit_field::BitField;
Expand Down Expand Up @@ -595,47 +607,32 @@ impl<T> PartialEq for Entry<T> {
/// A handler function for an interrupt or an exception without error code.
#[cfg(feature = "abi_x86_interrupt")]
pub type HandlerFunc = extern "x86-interrupt" fn(InterruptStackFrame);
/// This type is a dummy.
///
/// This type alias is not used for builds which do not use the `abi_x86_interrupt` feature.
#[cfg(not(feature = "abi_x86_interrupt"))]
pub type HandlerFunc = ();

/// A handler function for an exception that pushes an error code.
#[cfg(feature = "abi_x86_interrupt")]
pub type HandlerFuncWithErrCode = extern "x86-interrupt" fn(InterruptStackFrame, error_code: u64);
/// This type is a dummy.
///
/// This type alias is not used for builds which do not use the `abi_x86_interrupt` feature.
#[cfg(not(feature = "abi_x86_interrupt"))]
pub type HandlerFuncWithErrCode = ();

/// A page fault handler function that pushes a page fault error code.
#[cfg(feature = "abi_x86_interrupt")]
pub type PageFaultHandlerFunc =
extern "x86-interrupt" fn(InterruptStackFrame, error_code: PageFaultErrorCode);
/// This type is a dummy.
///
/// This type alias is not used for builds which do not use the `abi_x86_interrupt` feature.
#[cfg(not(feature = "abi_x86_interrupt"))]
pub type PageFaultHandlerFunc = ();

/// A handler function that must not return, e.g. for a machine check exception.
#[cfg(feature = "abi_x86_interrupt")]
pub type DivergingHandlerFunc = extern "x86-interrupt" fn(InterruptStackFrame) -> !;
/// This type is a dummy.
///
/// This type alias is not used for builds which do not use the `abi_x86_interrupt` feature.
#[cfg(not(feature = "abi_x86_interrupt"))]
pub type DivergingHandlerFunc = ();

/// A handler function with an error code that must not return, e.g. for a double fault exception.
#[cfg(feature = "abi_x86_interrupt")]
pub type DivergingHandlerFuncWithErrCode =
extern "x86-interrupt" fn(InterruptStackFrame, error_code: u64) -> !;
/// This type is a dummy.
///
/// This type alias is not used for builds which do not use the `abi_x86_interrupt` feature.
#[cfg(not(feature = "abi_x86_interrupt"))]
pub type DivergingHandlerFuncWithErrCode = ();

Expand Down