Skip to content
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

release v0.15 #446

Closed
wants to merge 97 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
885977a
replace software_interrupt! macro with generic function (#259)
Freax13 Jun 4, 2021
33e8c3b
software_interrupt: Add additional testing (#260)
josephlr Jun 4, 2021
69a6b1e
fix typo in docs (#265)
Freax13 Jun 4, 2021
66952eb
Resubmission of #226 (#261)
josephlr Jun 12, 2021
2313b30
Use SegmentSelector in InterruptStackFrame (#263)
josephlr Jun 12, 2021
fb8c5e5
Merge branch 'master' into next
josephlr Jul 18, 2021
3b8a597
Merge branch 'master' into next
josephlr Aug 2, 2021
8fe252f
add `PcidTooBig` error
Freax13 Oct 25, 2021
9b1773c
add `InvalidStarSegmentSelectors`
Freax13 Oct 25, 2021
ddf7a68
fix grammar
Freax13 Oct 25, 2021
a96abb2
Merge pull request #317 from Freax13/proper-star-error
phil-opp Nov 6, 2021
734c419
Merge pull request #316 from Freax13/proper-pcid-error
phil-opp Nov 6, 2021
8294882
activate `feature(abi_x86_interrupt)`
Freax13 Nov 8, 2021
37f8b0d
Merge pull request #320 from Freax13/fix-asm-const-operands
Freax13 Nov 8, 2021
88fee50
change `Index<usize>` to `Index<u8>`
Nov 7, 2021
99a334c
use `u8` instead of `usize` for `slice`
Nov 7, 2021
5be7446
implement ranged index for idt
Nov 7, 2021
6eee5a8
use `usize::from` instead of casting
Freax13 Nov 8, 2021
9ce47b3
Merge pull request #319 from Freax13/index-idt-with-u8
Freax13 Nov 8, 2021
338d3d4
fix `load_tss` and `GlobalDescriptorTable`
Freax13 Nov 9, 2021
aefd432
revert to old GDT but take &mut in `load` instead
Freax13 Nov 10, 2021
597ff85
add `Singleton<T>`
Freax13 Nov 10, 2021
96e0917
fix test
Freax13 Nov 10, 2021
c49a3b3
change `cpu_flags`'s type to `RFlags`
Freax13 Nov 10, 2021
9f2114c
Merge pull request #324 from Freax13/interrupt-stack-frame-types
josephlr Nov 11, 2021
f677c78
use swap and fix ordering
Freax13 Nov 14, 2021
df498d8
change Singleton's name to SingleUseCell
Freax13 Nov 14, 2021
23cf4c5
add `Send` bound for `SingleUseCell`'s `Sync` impl
Freax13 Nov 14, 2021
230c303
Merge pull request #323 from Freax13/mutable-gdt
Freax13 Nov 15, 2021
0aa7b93
add an immutable getter for the level 4 page table
Freax13 Dec 2, 2021
0dd0f56
Merge pull request #327 from Freax13/page-table-getter
Freax13 Dec 5, 2021
c449106
Merge branch 'master' into next
phil-opp Feb 3, 2022
ea00bfd
Unsafe blocks are now required in `unsafe fn`s too (since #328)
phil-opp Feb 3, 2022
5efea6a
Page table are now indexed with `u8` instead of `usize`
phil-opp Feb 3, 2022
d9eb7f6
Update test for new `InterruptStackFrame` format
phil-opp Feb 3, 2022
b820a2e
The `level_4_table` function only returns an immutable reference sinc…
phil-opp Feb 3, 2022
64a7ca7
Merge pull request #338 from rust-osdev/next-with-master
phil-opp Feb 3, 2022
11f64f6
make `Cr2::read` return a result
Freax13 Jan 16, 2022
3de203e
add errors section in doc comments
Freax13 Feb 5, 2022
5475d89
wrap comment
Freax13 Feb 6, 2022
628b913
Merge pull request #335 from Freax13/cr2-read-returns-result
phil-opp Feb 6, 2022
33194b6
Merge remote-tracking branch 'origin/master' into next
Freax13 Feb 25, 2022
c521e73
Merge pull request #344 from Freax13/next
Freax13 Feb 25, 2022
f7b2e90
remove `external_asm` and `inline_asm` features
Freax13 Feb 25, 2022
2da1eb6
Merge pull request #345 from Freax13/remove-asm-features
Freax13 Feb 25, 2022
89662dc
Merge branch 'master' into next
josephlr Mar 26, 2022
45d2f3b
Merge branch 'master' into next
josephlr Mar 26, 2022
518e43c
Update "next" MSRV for stable features to 1.59
josephlr Mar 26, 2022
8c3f123
Allow the GDT to be of any length
josephlr Mar 24, 2022
f411496
gdt: Update comments and assert message
josephlr Mar 27, 2022
c739493
Merge pull request #360 from rust-osdev/dyn_gdt
josephlr Mar 27, 2022
cfd24c7
Remove software_interrupt! macro
josephlr Mar 28, 2022
d8edd3f
Merge pull request #363 from rust-osdev/macro
josephlr Mar 28, 2022
5bbc76e
Remove usize trait impls
josephlr Mar 28, 2022
bce9ff5
Update bootloader tests
josephlr Mar 28, 2022
2e65c45
Merge pull request #364 from rust-osdev/usize
josephlr Mar 28, 2022
941c50d
gdt: Check that MAX is in range
josephlr Mar 29, 2022
b070bb6
Remove deprecated functions/flags
josephlr Mar 29, 2022
50b918d
Merge pull request #368 from rust-osdev/depr
josephlr Mar 30, 2022
d4e330f
Merge pull request #365 from rust-osdev/gdt1
josephlr Mar 30, 2022
3c48283
VirtAddr: Remove 32-bit conversion
josephlr Mar 31, 2022
b0d47b3
VirtAddr: don't succeed on non-canonical addresses
josephlr Mar 31, 2022
49b41c8
VirtAddr: make new() and try_new() const
josephlr Mar 31, 2022
872edf7
Update VirtAddr documentation and fix typos
josephlr Mar 31, 2022
3847259
Merge pull request #370 from rust-osdev/addr
josephlr Mar 31, 2022
92f6a82
Merge branch 'master' into next
josephlr Apr 5, 2022
272ff04
Conditionally import bit_field
josephlr Apr 5, 2022
48dbe8f
Add structures::gdt::Entry type
josephlr Apr 15, 2022
255124a
Add PartialEq, Eq, and Debug impls
josephlr Apr 15, 2022
07f7ebf
Make from_raw_entries safe
josephlr Apr 15, 2022
49b5295
Fix nits/warnings in docs
josephlr Apr 15, 2022
b61f341
Use AtomicU64 for Entry type
josephlr Apr 15, 2022
8792dc9
Fix Clippy warning about const item used to construct array
josephlr Apr 15, 2022
055d014
Allow GDT to be loaded with shared reference
josephlr Apr 15, 2022
b2fadb8
Remove SignleUseCell
josephlr Apr 15, 2022
8bb01e8
Add additional tests for TSS entry
josephlr Apr 15, 2022
e70b8a3
Merge pull request #380 from rust-osdev/gdt_entry
josephlr Apr 16, 2022
156cfda
Merge pull request #381 from rust-osdev/gdt_atomic
josephlr Apr 16, 2022
e1945fa
Merge branch 'master' into next
josephlr Apr 20, 2022
62a4ce0
fix `Page::from_page_table_indices`
Freax13 Dec 25, 2022
a268e7a
Merge pull request #398 from Freax13/fix/from-indices
phil-opp Dec 26, 2022
d4a780e
create unified `Sealed` trait
Freax13 Mar 8, 2023
b568699
seal off the `PageSize` trait
Freax13 Mar 8, 2023
ed4b978
Merge pull request #404 from Freax13/seal-page-size
josephlr Mar 8, 2023
f5c2b06
Merge remote-tracking branch 'upstream/next' into release/v0.15
Freax13 Jan 14, 2024
ee78cc0
fix date for 0.14.11 release
Freax13 Jan 14, 2024
5133c37
update changelog for 0.15.0 release
Freax13 Jan 14, 2024
c34c84a
bump version
Freax13 Jan 14, 2024
47a11c9
Merge pull request #447 from rust-osdev/update-next-with-master
phil-opp Jan 14, 2024
e24d811
remove deprecated from_bits_unchecked functions
Freax13 Jan 14, 2024
e7f53ac
make `HandlerFuncType` unsafe
Freax13 Jan 14, 2024
4fc44a6
Merge pull request #449 from Freax13/enhancement/remove-deprecate
Freax13 Jan 14, 2024
fb5416c
Merge pull request #450 from Freax13/enhancement/idt
Freax13 Jan 14, 2024
5384bd1
Update docs to clarify new defaults for `set_handler_fn`
phil-opp Jan 14, 2024
0c368ad
List new IDT defaults as breaking change in changelog
phil-opp Jan 14, 2024
32ed8fc
Merge pull request #451 from rust-osdev/update-docs
phil-opp Jan 14, 2024
8e13191
mark as beta-release
Freax13 Feb 8, 2024
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
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
rust:
- nightly
- 1.59
- 1.57
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -31,7 +30,6 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true
- name: Run cargo build for stable
if: matrix.rust != 1.57
uses: actions-rs/cargo@v1
with:
command: build
Expand All @@ -42,7 +40,6 @@ jobs:
command: build
args: --no-default-features
- name: Run cargo doc for stable
if: matrix.rust != 1.57
uses: actions-rs/cargo@v1
with:
command: doc
Expand All @@ -53,7 +50,6 @@ jobs:
command: doc
args: --no-default-features
- name: Run cargo test for stable
if: matrix.rust != 1.57
uses: actions-rs/cargo@v1
with:
command: test
Expand Down
12 changes: 4 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ license = "MIT/Apache-2.0"
name = "x86_64"
readme = "README.md"
repository = "https://github.com/rust-osdev/x86_64"
version = "0.14.11"
version = "0.15.0-beta"
edition = "2018"
rust-version = "1.57" # Needed to support panic! in const fns
rust-version = "1.59" # Needed to support inline asm and default const generics

[dependencies]
bit_field = "0.10.1"
Expand All @@ -28,17 +28,13 @@ rustversion = "1.0.5"
[features]
default = ["nightly", "instructions"]
instructions = []
nightly = ["const_fn", "step_trait", "abi_x86_interrupt"]
nightly = [ "const_fn", "step_trait", "abi_x86_interrupt", "asm_const" ]
abi_x86_interrupt = []
const_fn = []
asm_const = []
step_trait = []
doc_auto_cfg = []

# These features are no longer used and only there for backwards compatibility.
external_asm = []
inline_asm = []
doc_cfg = []

[package.metadata.docs.rs]
all-features = true

Expand Down
33 changes: 32 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
# Unreleased

# 0.15.0-beta – 2024-02-08

## Breaking changes

- [replace software_interrupt! macro with generic function](https://github.com/rust-osdev/x86_64/pull/259)
- [Use SegmentSelector in InterruptStackFrame](https://github.com/rust-osdev/x86_64/pull/263)
- [add `InvalidStarSegmentSelectors` error](https://github.com/rust-osdev/x86_64/pull/317)
- [add `PcidTooBig` error](https://github.com/rust-osdev/x86_64/pull/316)
- [implement `Index<u8>` for IDT instead of `Index<usize>`](https://github.com/rust-osdev/x86_64/pull/319)
- [change `cpu_flags`'s type to `RFlags`](https://github.com/rust-osdev/x86_64/pull/324)
- [fix `load_tss` and `GlobalDescriptorTable`](https://github.com/rust-osdev/x86_64/pull/323)
- [add an immutable getter for the level 4 page table](https://github.com/rust-osdev/x86_64/pull/327)
- [make `Cr2::read` return a result](https://github.com/rust-osdev/x86_64/pull/335)
- [remove `external_asm` and `inline_asm` features](https://github.com/rust-osdev/x86_64/pull/345)
- [Allow the GDT to be of any length](https://github.com/rust-osdev/x86_64/pull/360)
- [Remove software_interrupt! macro](https://github.com/rust-osdev/x86_64/pull/363)
- [Remove usize trait impls](https://github.com/rust-osdev/x86_64/pull/364)
- [Remove deprecated functions/flags](https://github.com/rust-osdev/x86_64/pull/368)
- [VirtAddr improvements](https://github.com/rust-osdev/x86_64/pull/370)
- [Add structures::gdt::Entry type](https://github.com/rust-osdev/x86_64/pull/380)
- [Allow GDT to be loaded with shared reference](https://github.com/rust-osdev/x86_64/pull/381)
- [seal off the `PageSize` trait](https://github.com/rust-osdev/x86_64/pull/404)
- [idt: Fixup Options structure and cleanup set_handler_fn](https://github.com/rust-osdev/x86_64/pull/226)

## New Features

- [Add `HandlerFuncType` trait](https://github.com/rust-osdev/x86_64/pull/439)

# 0.14.11 – 2022-09-15
## Fixes

- [fix typo in docs](https://github.com/rust-osdev/x86_64/pull/265)
- [activate `feature(asm_const)`](https://github.com/rust-osdev/x86_64/pull/320)
- [gdt: Check that MAX is in range](https://github.com/rust-osdev/x86_64/pull/365)
- [fix `Page::from_page_table_indices`](https://github.com/rust-osdev/x86_64/pull/398)

# 0.14.11 – 2023-09-15

## New Features

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ Support for x86_64 specific instructions (e.g. TLB flush), registers (e.g. contr

## Minimum Supported Rust Version (MSRV)

If no features are enabled (`--no-default-features`), Rust 1.57.0 is required.
If no nightly features are enabled, Rust 1.59.0 is required.
This can be done by either:
- `--no-default-features --features instructions`
- `--no-default-features`

If only the `instructions` feature is enabled (`--no-default-features --features instructions`), Rust 1.59.0 is required.

If the `nightly` feature or any of its sub-features is enabled, a recent nightly is required.
If the `nightly` feature or any of its sub-features is enabled (which is the
default), a recent nightly is required.

## Other OS development crates

Expand All @@ -37,4 +39,4 @@ useful crates in this space include:
[`read_volatile`](https://doc.rust-lang.org/std/ptr/fn.read_volatile.html) and
[`write_volatile`](https://doc.rust-lang.org/std/ptr/fn.write_volatile.html)
- Makes it easier to program [MMIO](https://en.wikipedia.org/wiki/Memory-mapped_I/O) interfaces and devices.
- Works on any Rust target.
- Works on any Rust target.
120 changes: 26 additions & 94 deletions src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use crate::structures::paging::{PageOffset, PageTableIndex};
use bit_field::BitField;

const ADDRESS_SPACE_SIZE: u64 = 0x1_0000_0000_0000;

Check warning on line 13 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

constant `ADDRESS_SPACE_SIZE` is never used

Check warning on line 13 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

constant `ADDRESS_SPACE_SIZE` is never used

Check warning on line 13 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

constant is never used: `ADDRESS_SPACE_SIZE`

Check warning on line 13 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

constant is never used: `ADDRESS_SPACE_SIZE`

/// A canonical 64-bit virtual memory address.
///
Expand All @@ -20,7 +20,7 @@
/// between `u64` and `usize`.
///
/// On `x86_64`, only the 48 lower bits of a virtual address can be used. The top 16 bits need
/// to be copies of bit 47, i.e. the most significant bit. Addresses that fulfil this criterium
/// to be copies of bit 47, i.e. the most significant bit. Addresses that fulfil this criterion
/// are called “canonical”. This type guarantees that it always represents a canonical address.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
Expand Down Expand Up @@ -60,39 +60,43 @@
impl VirtAddr {
/// Creates a new canonical virtual address.
///
/// This function performs sign extension of bit 47 to make the address canonical.
/// The provided address should already be canonical. If you want to check
/// whether an address is canonical, use [`try_new`](Self::try_new).
///
/// ## Panics
///
/// This function panics if the bits in the range 48 to 64 contain data (i.e. are not null and no sign extension).
/// This function panics if the bits in the range 48 to 64 are invalid
/// (i.e. are not a proper sign extension of bit 47).
#[inline]
pub fn new(addr: u64) -> VirtAddr {
Self::try_new(addr).expect(
"address passed to VirtAddr::new must not contain any data \
in bits 48 to 64",
)
pub const fn new(addr: u64) -> VirtAddr {
// TODO: Replace with .ok().expect(msg) when that works on stable.
match Self::try_new(addr) {
Ok(v) => v,
Err(_) => panic!("virtual address must be sign extended in bits 48 to 64"),
}
}

/// Tries to create a new canonical virtual address.
///
/// This function tries to performs sign
/// extension of bit 47 to make the address canonical. It succeeds if bits 48 to 64 are
/// either a correct sign extension (i.e. copies of bit 47) or all null. Else, an error
/// is returned.
#[inline]
pub fn try_new(addr: u64) -> Result<VirtAddr, VirtAddrNotValid> {
match addr.get_bits(47..64) {
0 | 0x1ffff => Ok(VirtAddr(addr)), // address is canonical
1 => Ok(VirtAddr::new_truncate(addr)), // address needs sign extension
_ => Err(VirtAddrNotValid(addr)),
/// This function checks wether the given address is canonical
/// and returns an error otherwise. An address is canonical
/// if bits 48 to 64 are a correct sign
/// extension (i.e. copies of bit 47).
#[inline]
pub const fn try_new(addr: u64) -> Result<VirtAddr, VirtAddrNotValid> {
let v = Self::new_truncate(addr);
if v.0 == addr {
Ok(v)
} else {
Err(VirtAddrNotValid(addr))
}
}

/// Creates a new canonical virtual address, throwing out bits 48..64.
///
/// This function performs sign extension of bit 47 to make the address canonical, so
/// bits 48 to 64 are overwritten. If you want to check that these bits contain no data,
/// use `new` or `try_new`.
/// This function performs sign extension of bit 47 to make the address
/// canonical, overwriting bits 48 to 64. If you want to check whether an
/// address is canonical, use [`new`](Self::new) or [`try_new`](Self::try_new).
#[inline]
pub const fn new_truncate(addr: u64) -> VirtAddr {
// By doing the right shift as a signed operation (on a i64), it will
Expand Down Expand Up @@ -123,11 +127,7 @@
}

/// Creates a virtual address from the given pointer
// cfg(target_pointer_width = "32") is only here for backwards
// compatibility: Earlier versions of this crate did not have any `cfg()`
// on this function. At least for 32- and 64-bit we know the `as u64` cast
// doesn't truncate.
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
#[cfg(target_pointer_width = "64")]
#[inline]
pub fn from_ptr<T: ?Sized>(ptr: *const T) -> Self {
Self::new(ptr as *const () as u64)
Expand Down Expand Up @@ -226,7 +226,7 @@
}

// FIXME: Move this into the `Step` impl, once `Step` is stabilized.
pub(crate) fn steps_between_impl(start: &Self, end: &Self) -> Option<usize> {

Check warning on line 229 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

associated functions `steps_between_impl` and `forward_checked_impl` are never used

Check warning on line 229 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (nightly)

associated functions `steps_between_impl` and `forward_checked_impl` are never used

Check warning on line 229 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `steps_between_impl`

Check warning on line 229 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `steps_between_impl`
let mut steps = end.0.checked_sub(start.0)?;

// Check if we jumped the gap.
Expand All @@ -238,7 +238,7 @@
}

// FIXME: Move this into the `Step` impl, once `Step` is stabilized.
pub(crate) fn forward_checked_impl(start: Self, count: usize) -> Option<Self> {

Check warning on line 241 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `forward_checked_impl`

Check warning on line 241 in src/addr.rs

View workflow job for this annotation

GitHub Actions / Test MSRV and Stable Features (1.59)

associated function is never used: `forward_checked_impl`
let offset = u64::try_from(count).ok()?;
if offset > ADDRESS_SPACE_SIZE {
return None;
Expand Down Expand Up @@ -320,23 +320,6 @@
}
}

#[cfg(target_pointer_width = "64")]
impl Add<usize> for VirtAddr {
type Output = Self;
#[inline]
fn add(self, rhs: usize) -> Self::Output {
self + rhs as u64
}
}

#[cfg(target_pointer_width = "64")]
impl AddAssign<usize> for VirtAddr {
#[inline]
fn add_assign(&mut self, rhs: usize) {
self.add_assign(rhs as u64)
}
}

impl Sub<u64> for VirtAddr {
type Output = Self;
#[inline]
Expand All @@ -352,23 +335,6 @@
}
}

#[cfg(target_pointer_width = "64")]
impl Sub<usize> for VirtAddr {
type Output = Self;
#[inline]
fn sub(self, rhs: usize) -> Self::Output {
self - rhs as u64
}
}

#[cfg(target_pointer_width = "64")]
impl SubAssign<usize> for VirtAddr {
#[inline]
fn sub_assign(&mut self, rhs: usize) {
self.sub_assign(rhs as u64)
}
}

impl Sub<VirtAddr> for VirtAddr {
type Output = u64;
#[inline]
Expand Down Expand Up @@ -583,23 +549,6 @@
}
}

#[cfg(target_pointer_width = "64")]
impl Add<usize> for PhysAddr {
type Output = Self;
#[inline]
fn add(self, rhs: usize) -> Self::Output {
self + rhs as u64
}
}

#[cfg(target_pointer_width = "64")]
impl AddAssign<usize> for PhysAddr {
#[inline]
fn add_assign(&mut self, rhs: usize) {
self.add_assign(rhs as u64)
}
}

impl Sub<u64> for PhysAddr {
type Output = Self;
#[inline]
Expand All @@ -615,23 +564,6 @@
}
}

#[cfg(target_pointer_width = "64")]
impl Sub<usize> for PhysAddr {
type Output = Self;
#[inline]
fn sub(self, rhs: usize) -> Self::Output {
self - rhs as u64
}
}

#[cfg(target_pointer_width = "64")]
impl SubAssign<usize> for PhysAddr {
#[inline]
fn sub_assign(&mut self, rhs: usize) {
self.sub_assign(rhs as u64)
}
}

impl Sub<PhysAddr> for PhysAddr {
type Output = u64;
#[inline]
Expand Down
23 changes: 15 additions & 8 deletions src/instructions/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,19 @@ 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.
#[macro_export]
macro_rules! software_interrupt {
($x:expr) => {{
asm!("int {id}", id = const $x, options(nomem, nostack));
}};
/// ## 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 = "asm_const")]
#[cfg_attr(
feature = "doc_cfg",
doc(cfg(any(feature = "nightly", feature = "asm_const")))
)]
pub unsafe fn software_interrupt<const NUM: u8>() {
unsafe {
asm!("int {num}", num = const NUM, options(nomem, nostack));
}
}
Loading
Loading