@@ -317,18 +317,20 @@ fn address_space_descriptor<T>(bytes: &[u8]) -> Result<Resource, AmlError> {
317
317
} ) )
318
318
}
319
319
320
+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
321
+ pub enum Irq {
322
+ Single ( u32 ) ,
323
+ Multiple ( Vec < u32 > )
324
+ }
325
+
320
326
#[ derive( Debug , PartialEq , Eq , Clone ) ]
321
327
pub struct IrqDescriptor {
322
328
pub is_consumer : bool ,
323
329
pub trigger : InterruptTrigger ,
324
330
pub polarity : InterruptPolarity ,
325
331
pub is_shared : bool ,
326
332
pub is_wake_capable : bool ,
327
- /*
328
- * NOTE: We currently only support the cases where a descriptor only contains a single interrupt
329
- * number.
330
- */
331
- pub irq : u32 ,
333
+ pub irq : Irq ,
332
334
}
333
335
334
336
fn irq_format_descriptor ( bytes : & [ u8 ] ) -> Result < Resource , AmlError > {
@@ -369,7 +371,7 @@ fn irq_format_descriptor(bytes: &[u8]) -> Result<Resource, AmlError> {
369
371
let irq = LittleEndian :: read_u16 ( & bytes[ 1 ..=2 ] ) ;
370
372
371
373
Ok ( Resource :: Irq ( IrqDescriptor {
372
- irq : irq as u32 ,
374
+ irq : Irq :: Single ( irq as u32 ) ,
373
375
is_wake_capable : false ,
374
376
is_shared : false ,
375
377
polarity : InterruptPolarity :: ActiveHigh ,
@@ -395,7 +397,7 @@ fn irq_format_descriptor(bytes: &[u8]) -> Result<Resource, AmlError> {
395
397
} ;
396
398
397
399
Ok ( Resource :: Irq ( IrqDescriptor {
398
- irq : irq as u32 ,
400
+ irq : Irq :: Single ( irq as u32 ) ,
399
401
is_wake_capable,
400
402
is_shared,
401
403
polarity,
@@ -551,8 +553,25 @@ fn extended_interrupt_descriptor(bytes: &[u8]) -> Result<Resource, AmlError> {
551
553
}
552
554
553
555
let number_of_interrupts = bytes[ 4 ] as usize ;
554
- assert_eq ! ( number_of_interrupts, 1 ) ;
555
- let irq = LittleEndian :: read_u32 ( & [ bytes[ 5 ] , bytes[ 6 ] , bytes[ 7 ] , bytes[ 8 ] ] ) ;
556
+
557
+ let irq = if number_of_interrupts == 1 {
558
+ let irq = LittleEndian :: read_u32 ( & bytes[ 5 ..9 ] ) ;
559
+
560
+ Irq :: Single ( irq)
561
+ } else {
562
+ let mut irqs = Vec :: with_capacity ( number_of_interrupts) ;
563
+
564
+ for i in 0 ..number_of_interrupts {
565
+ let start = 5 + i * size_of :: < u32 > ( ) ;
566
+ let end = start + 4 ;
567
+
568
+ let irq = LittleEndian :: read_u32 ( & bytes[ start..end] ) ;
569
+
570
+ irqs. push ( irq) ;
571
+ }
572
+
573
+ Irq :: Multiple ( irqs)
574
+ } ;
556
575
557
576
Ok ( Resource :: Irq ( IrqDescriptor {
558
577
is_consumer : bytes[ 3 ] . get_bit ( 0 ) ,
@@ -625,7 +644,7 @@ mod tests {
625
644
polarity: InterruptPolarity :: ActiveHigh ,
626
645
is_shared: false ,
627
646
is_wake_capable: false ,
628
- irq: ( 1 << 1 )
647
+ irq: Irq :: Single ( 1 << 1 )
629
648
} )
630
649
] )
631
650
) ;
@@ -836,7 +855,7 @@ mod tests {
836
855
polarity: InterruptPolarity :: ActiveHigh ,
837
856
is_shared: false ,
838
857
is_wake_capable: false ,
839
- irq: ( 1 << 6 )
858
+ irq: Irq :: Single ( 1 << 6 )
840
859
} ) ,
841
860
Resource :: Dma ( DMADescriptor {
842
861
channel_mask: 1 << 2 ,
0 commit comments