diff options
author | 2019-10-11 19:11:38 -0700 | |
---|---|---|
committer | 2019-10-11 19:11:55 -0700 | |
commit | 1962925cdc9e8146329cee5662e80cfe6f6fab74 (patch) | |
tree | c732b3a7eeec98e598a8e1cd4e89f22f1c5f2d1c | |
parent | 292fab7b00a741b1eb60361b2efb4b3a6eff2720 (diff) | |
download | rust-x86-1962925cdc9e8146329cee5662e80cfe6f6fab74.tar.gz rust-x86-1962925cdc9e8146329cee5662e80cfe6f6fab74.tar.zst rust-x86-1962925cdc9e8146329cee5662e80cfe6f6fab74.zip |
Add ist() method for DescriptorBuilder.
-rw-r--r-- | src/bits64/segmentation.rs | 12 | ||||
-rw-r--r-- | src/segmentation.rs | 11 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/bits64/segmentation.rs b/src/bits64/segmentation.rs index d246f0f..6d58a80 100644 --- a/src/bits64/segmentation.rs +++ b/src/bits64/segmentation.rs @@ -59,9 +59,10 @@ impl Descriptor64 { impl GateDescriptorBuilder<u64> for DescriptorBuilder { fn tss_descriptor(base: u64, limit: u64, available: bool) -> DescriptorBuilder { - let typ = match available { - true => DescriptorType::System64(SystemDescriptorTypes64::TssAvailable), - false => DescriptorType::System64(SystemDescriptorTypes64::TssBusy), + let typ = if available { + DescriptorType::System64(SystemDescriptorTypes64::TssAvailable) + } else { + DescriptorType::System64(SystemDescriptorTypes64::TssBusy) }; DescriptorBuilder::with_base_limit(base, limit).set_type(typ) @@ -105,6 +106,11 @@ impl BuildDescriptor<Descriptor64> for DescriptorBuilder { { assert!(!self.db); } + + if typ == SystemDescriptorTypes64::InterruptGate { + desc.set_ist(self.ist); + } + typ as u8 } Some(DescriptorType::System32(_typ)) => { diff --git a/src/segmentation.rs b/src/segmentation.rs index a9cc684..c58403e 100644 --- a/src/segmentation.rs +++ b/src/segmentation.rs @@ -239,6 +239,8 @@ pub struct DescriptorBuilder { pub(crate) limit_granularity_4k: bool, /// 64-bit code segment (IA-32e mode only) pub(crate) l: bool, + /// Interrupt stack table (IST) selector (IA-32e mode only) + pub(crate) ist: u8, } impl DescriptorBuilder { @@ -254,6 +256,7 @@ impl DescriptorBuilder { db: false, limit_granularity_4k: false, l: false, + ist: 0, } } @@ -272,6 +275,7 @@ impl DescriptorBuilder { db: false, limit_granularity_4k: false, l: false, + ist: 0, } } @@ -317,6 +321,13 @@ impl DescriptorBuilder { self.l = true; self } + + /// Set a the interrupt stack table index (only if this ends up being a 64-bit interrupt descriptor). + pub fn ist(mut self, index: u8) -> DescriptorBuilder { + debug_assert!(index <= 7); + self.ist = index; + self + } } impl GateDescriptorBuilder<u32> for DescriptorBuilder { |