1
1
//! Types for the Global Descriptor Table and segment selectors.
2
2
3
+ use crate :: structures:: tss:: InvalidIoMap ;
3
4
use crate :: structures:: { tss:: TaskStateSegment , DescriptorTablePointer } ;
4
5
use crate :: PrivilegeLevel ;
5
6
use bit_field:: BitField ;
6
7
use bitflags:: bitflags;
7
8
use core:: { cmp, fmt, mem} ;
8
- use crate :: structures:: tss:: InvalidIoMap ;
9
9
10
10
/// Specifies which element to load into a segment from
11
11
/// descriptor tables (i.e., is a index to LDT or GDT table
@@ -317,23 +317,23 @@ impl Descriptor {
317
317
iomap : & ' static [ u8 ] ,
318
318
) -> Result < Descriptor , InvalidIoMap > {
319
319
if iomap. len ( ) > 8193 {
320
- return Err ( InvalidIoMap :: TooLong { len : iomap. len ( ) } )
320
+ return Err ( InvalidIoMap :: TooLong { len : iomap. len ( ) } ) ;
321
321
}
322
322
323
323
let base = iomap. as_ptr ( ) as usize - tss as * const _ as usize ;
324
324
if base > 0xdfff {
325
- return Err ( InvalidIoMap :: TooFarFromTss { distance : base } )
325
+ return Err ( InvalidIoMap :: TooFarFromTss { distance : base } ) ;
326
326
}
327
327
328
328
let last_byte = * iomap. last ( ) . unwrap_or ( & 0xff ) ;
329
329
if last_byte != 0xff {
330
- return Err ( InvalidIoMap :: InvalidTerminatingByte { byte : last_byte } )
330
+ return Err ( InvalidIoMap :: InvalidTerminatingByte { byte : last_byte } ) ;
331
331
}
332
332
333
333
if tss. iomap_base != base as u16 {
334
334
return Err ( InvalidIoMap :: InvalidBase {
335
335
expected : base as u16 ,
336
- got : tss. iomap_base
336
+ got : tss. iomap_base ,
337
337
} ) ;
338
338
}
339
339
@@ -348,10 +348,7 @@ impl Descriptor {
348
348
/// There must be a valid IO map at `(tss as *const u8).offset(tss.iomap_base)`
349
349
/// of length `iomap_size`, with the terminating `0xFF` byte. Additionally, `iomap_base` must
350
350
/// not exceed `0xDFFF`.
351
- unsafe fn tss_segment_raw (
352
- tss : & ' static TaskStateSegment ,
353
- iomap_size : u16 ,
354
- ) -> Descriptor {
351
+ unsafe fn tss_segment_raw ( tss : & ' static TaskStateSegment , iomap_size : u16 ) -> Descriptor {
355
352
use self :: DescriptorFlags as Flags ;
356
353
357
354
let ptr = tss as * const _ as u64 ;
0 commit comments