@@ -458,25 +458,21 @@ impl InterruptDescriptorTable {
458
458
}
459
459
}
460
460
461
- /// Returns a normalized and ranged check slice range from a RangeBounds trait object
461
+ /// Returns a normalized and ranged check slice range from a RangeBounds trait object.
462
462
///
463
- /// Panics if range is outside the range of user interrupts (i.e. greater than 255) or if the entry is an
464
- /// exception
465
- fn condition_slice_bounds ( & self , bounds : impl RangeBounds < usize > ) -> ( usize , usize ) {
463
+ /// Panics if the entry is an exception.
464
+ fn condition_slice_bounds ( & self , bounds : impl RangeBounds < u8 > ) -> ( usize , usize ) {
466
465
let lower_idx = match bounds. start_bound ( ) {
467
- Included ( start) => * start,
468
- Excluded ( start) => * start + 1 ,
466
+ Included ( start) => ( * start as usize ) ,
467
+ Excluded ( start) => ( * start as usize ) + 1 ,
469
468
Unbounded => 0 ,
470
469
} ;
471
470
let upper_idx = match bounds. end_bound ( ) {
472
- Included ( end) => * end + 1 ,
473
- Excluded ( end) => * end,
471
+ Included ( end) => ( * end as usize ) + 1 ,
472
+ Excluded ( end) => ( * end as usize ) ,
474
473
Unbounded => 256 ,
475
474
} ;
476
475
477
- if lower_idx > 256 || upper_idx > 256 {
478
- panic ! ( "Index out of range [{}..{}]" , lower_idx, upper_idx) ;
479
- }
480
476
if lower_idx < 32 {
481
477
panic ! ( "Cannot return slice from traps, faults, and exception handlers" ) ;
482
478
}
@@ -485,20 +481,18 @@ impl InterruptDescriptorTable {
485
481
486
482
/// Returns slice of IDT entries with the specified range.
487
483
///
488
- /// Panics if range is outside the range of user interrupts (i.e. greater than 255) or if the entry is an
489
- /// exception
484
+ /// Panics if the entry is an exception.
490
485
#[ inline]
491
- pub fn slice ( & self , bounds : impl RangeBounds < usize > ) -> & [ Entry < HandlerFunc > ] {
486
+ pub fn slice ( & self , bounds : impl RangeBounds < u8 > ) -> & [ Entry < HandlerFunc > ] {
492
487
let ( lower_idx, upper_idx) = self . condition_slice_bounds ( bounds) ;
493
488
& self . interrupts [ ( lower_idx - 32 ) ..( upper_idx - 32 ) ]
494
489
}
495
490
496
491
/// Returns a mutable slice of IDT entries with the specified range.
497
492
///
498
- /// Panics if range is outside the range of user interrupts (i.e. greater than 255) or if the entry is an
499
- /// exception
493
+ /// Panics if the entry is an exception.
500
494
#[ inline]
501
- pub fn slice_mut ( & mut self , bounds : impl RangeBounds < usize > ) -> & mut [ Entry < HandlerFunc > ] {
495
+ pub fn slice_mut ( & mut self , bounds : impl RangeBounds < u8 > ) -> & mut [ Entry < HandlerFunc > ] {
502
496
let ( lower_idx, upper_idx) = self . condition_slice_bounds ( bounds) ;
503
497
& mut self . interrupts [ ( lower_idx - 32 ) ..( upper_idx - 32 ) ]
504
498
}
0 commit comments