Skip to content

Commit a85c1e2

Browse files
RestiosonFreax13
authored andcommitted
fmt (i always forget this...)
1 parent c03a90a commit a85c1e2

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

src/structures/gdt.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
//! Types for the Global Descriptor Table and segment selectors.
22
33
pub use crate::registers::segmentation::SegmentSelector;
4-
use crate::structures::tss::TaskStateSegment;
4+
use crate::structures::tss::{InvalidIoMap, TaskStateSegment};
55
use crate::PrivilegeLevel;
66
use bit_field::BitField;
77
use bitflags::bitflags;
88
use core::{cmp, fmt, mem};
99
// imports for intra-doc links
1010
#[cfg(doc)]
1111
use crate::registers::segmentation::{Segment, CS, SS};
12-
use crate::structures::tss::InvalidIoMap;
1312

1413
#[cfg(all(feature = "instructions", target_arch = "x86_64"))]
1514
use core::sync::atomic::{AtomicU64 as EntryValue, Ordering};
@@ -450,23 +449,23 @@ impl Descriptor {
450449
iomap: &'static [u8],
451450
) -> Result<Descriptor, InvalidIoMap> {
452451
if iomap.len() > 8193 {
453-
return Err(InvalidIoMap::TooLong { len: iomap.len() })
452+
return Err(InvalidIoMap::TooLong { len: iomap.len() });
454453
}
455454

456455
let base = iomap.as_ptr() as usize - tss as *const _ as usize;
457456
if base > 0xdfff {
458-
return Err(InvalidIoMap::TooFarFromTss { distance: base })
457+
return Err(InvalidIoMap::TooFarFromTss { distance: base });
459458
}
460459

461460
let last_byte = *iomap.last().unwrap_or(&0xff);
462461
if last_byte != 0xff {
463-
return Err(InvalidIoMap::InvalidTerminatingByte { byte: last_byte })
462+
return Err(InvalidIoMap::InvalidTerminatingByte { byte: last_byte });
464463
}
465464

466465
if tss.iomap_base != base as u16 {
467466
return Err(InvalidIoMap::InvalidBase {
468467
expected: base as u16,
469-
got: tss.iomap_base
468+
got: tss.iomap_base,
470469
});
471470
}
472471

@@ -481,10 +480,7 @@ impl Descriptor {
481480
/// There must be a valid IO map at `(tss as *const u8).offset(tss.iomap_base)`
482481
/// of length `iomap_size`, with the terminating `0xFF` byte. Additionally, `iomap_base` must
483482
/// not exceed `0xDFFF`.
484-
unsafe fn tss_segment_raw(
485-
tss: *const TaskStateSegment,
486-
iomap_size: u16,
487-
) -> Descriptor {
483+
unsafe fn tss_segment_raw(tss: *const TaskStateSegment, iomap_size: u16) -> Descriptor {
488484
use self::DescriptorFlags as Flags;
489485

490486
let ptr = tss as u64;

src/structures/tss.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,13 @@ impl Default for TaskStateSegment {
5757
pub enum InvalidIoMap {
5858
/// The IO permissions bitmap is too far from the TSS. It must be within `0xdfff` bytes of the
5959
/// start of the TSS.
60-
TooFarFromTss {
61-
distance: usize,
62-
},
60+
TooFarFromTss { distance: usize },
6361
/// The final byte of the IO permissions bitmap was not 0xff
64-
InvalidTerminatingByte {
65-
byte: u8,
66-
},
62+
InvalidTerminatingByte { byte: u8 },
6763
/// The IO permissions bitmap exceeds the maximum length (8193).
68-
TooLong {
69-
len: usize
70-
},
64+
TooLong { len: usize },
7165
/// The `iomap_base` in the `TaskStateSegment` struct was not what was expected.
72-
InvalidBase {
73-
expected: u16,
74-
got: u16,
75-
}
66+
InvalidBase { expected: u16, got: u16 },
7667
}
7768

7869
#[cfg(test)]

0 commit comments

Comments
 (0)