1
1
//! Types for the Global Descriptor Table and segment selectors.
2
2
3
3
pub use crate :: registers:: segmentation:: SegmentSelector ;
4
- use crate :: structures:: tss:: TaskStateSegment ;
4
+ use crate :: structures:: tss:: { InvalidIoMap , TaskStateSegment } ;
5
5
use crate :: PrivilegeLevel ;
6
6
use bit_field:: BitField ;
7
7
use bitflags:: bitflags;
8
8
use core:: { cmp, fmt, mem} ;
9
9
// imports for intra-doc links
10
10
#[ cfg( doc) ]
11
11
use crate :: registers:: segmentation:: { Segment , CS , SS } ;
12
- use crate :: structures:: tss:: InvalidIoMap ;
13
12
14
13
#[ cfg( all( feature = "instructions" , target_arch = "x86_64" ) ) ]
15
14
use core:: sync:: atomic:: { AtomicU64 as EntryValue , Ordering } ;
@@ -450,23 +449,23 @@ impl Descriptor {
450
449
iomap : & ' static [ u8 ] ,
451
450
) -> Result < Descriptor , InvalidIoMap > {
452
451
if iomap. len ( ) > 8193 {
453
- return Err ( InvalidIoMap :: TooLong { len : iomap. len ( ) } )
452
+ return Err ( InvalidIoMap :: TooLong { len : iomap. len ( ) } ) ;
454
453
}
455
454
456
455
let base = iomap. as_ptr ( ) as usize - tss as * const _ as usize ;
457
456
if base > 0xdfff {
458
- return Err ( InvalidIoMap :: TooFarFromTss { distance : base } )
457
+ return Err ( InvalidIoMap :: TooFarFromTss { distance : base } ) ;
459
458
}
460
459
461
460
let last_byte = * iomap. last ( ) . unwrap_or ( & 0xff ) ;
462
461
if last_byte != 0xff {
463
- return Err ( InvalidIoMap :: InvalidTerminatingByte { byte : last_byte } )
462
+ return Err ( InvalidIoMap :: InvalidTerminatingByte { byte : last_byte } ) ;
464
463
}
465
464
466
465
if tss. iomap_base != base as u16 {
467
466
return Err ( InvalidIoMap :: InvalidBase {
468
467
expected : base as u16 ,
469
- got : tss. iomap_base
468
+ got : tss. iomap_base ,
470
469
} ) ;
471
470
}
472
471
@@ -481,10 +480,7 @@ impl Descriptor {
481
480
/// There must be a valid IO map at `(tss as *const u8).offset(tss.iomap_base)`
482
481
/// of length `iomap_size`, with the terminating `0xFF` byte. Additionally, `iomap_base` must
483
482
/// 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 {
488
484
use self :: DescriptorFlags as Flags ;
489
485
490
486
let ptr = tss as u64 ;
0 commit comments