-
-
Notifications
You must be signed in to change notification settings - Fork 87
Add Support for Multiple IRQs in IrqDescriptor #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
newcomb-luke
wants to merge
1
commit into
rust-osdev:main
from
newcomb-luke:feat/multiple-irqs-in-descriptor
+32
−13
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -317,18 +317,20 @@ fn address_space_descriptor<T>(bytes: &[u8]) -> Result<Resource, AmlError> { | |
| })) | ||
| } | ||
|
|
||
| #[derive(Debug, PartialEq, Eq, Clone)] | ||
| pub enum Irq { | ||
| Single(u32), | ||
| Multiple(Vec<u32>) | ||
| } | ||
|
|
||
| #[derive(Debug, PartialEq, Eq, Clone)] | ||
| pub struct IrqDescriptor { | ||
| pub is_consumer: bool, | ||
| pub trigger: InterruptTrigger, | ||
| pub polarity: InterruptPolarity, | ||
| pub is_shared: bool, | ||
| pub is_wake_capable: bool, | ||
| /* | ||
| * NOTE: We currently only support the cases where a descriptor only contains a single interrupt | ||
| * number. | ||
| */ | ||
| pub irq: u32, | ||
| pub irq: Irq, | ||
| } | ||
|
|
||
| fn irq_format_descriptor(bytes: &[u8]) -> Result<Resource, AmlError> { | ||
|
|
@@ -369,7 +371,7 @@ fn irq_format_descriptor(bytes: &[u8]) -> Result<Resource, AmlError> { | |
| let irq = LittleEndian::read_u16(&bytes[1..=2]); | ||
|
|
||
| Ok(Resource::Irq(IrqDescriptor { | ||
| irq: irq as u32, | ||
| irq: Irq::Single(irq as u32), | ||
| is_wake_capable: false, | ||
| is_shared: false, | ||
| polarity: InterruptPolarity::ActiveHigh, | ||
|
|
@@ -395,7 +397,7 @@ fn irq_format_descriptor(bytes: &[u8]) -> Result<Resource, AmlError> { | |
| }; | ||
|
|
||
| Ok(Resource::Irq(IrqDescriptor { | ||
| irq: irq as u32, | ||
| irq: Irq::Single(irq as u32), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same incorrect here. |
||
| is_wake_capable, | ||
| is_shared, | ||
| polarity, | ||
|
|
@@ -551,8 +553,25 @@ fn extended_interrupt_descriptor(bytes: &[u8]) -> Result<Resource, AmlError> { | |
| } | ||
|
|
||
| let number_of_interrupts = bytes[4] as usize; | ||
| assert_eq!(number_of_interrupts, 1); | ||
| let irq = LittleEndian::read_u32(&[bytes[5], bytes[6], bytes[7], bytes[8]]); | ||
|
|
||
| let irq = if number_of_interrupts == 1 { | ||
| let irq = LittleEndian::read_u32( &bytes[5..9]); | ||
|
|
||
| Irq::Single(irq) | ||
| } else { | ||
| let mut irqs = Vec::with_capacity(number_of_interrupts); | ||
|
|
||
| for i in 0..number_of_interrupts { | ||
| let start = 5 + i * size_of::<u32>(); | ||
| let end = start + 4; | ||
|
|
||
| let irq = LittleEndian::read_u32(&bytes[start..end]); | ||
|
|
||
| irqs.push(irq); | ||
| } | ||
|
|
||
| Irq::Multiple(irqs) | ||
| }; | ||
|
|
||
| Ok(Resource::Irq(IrqDescriptor { | ||
| is_consumer: bytes[3].get_bit(0), | ||
|
|
@@ -625,7 +644,7 @@ mod tests { | |
| polarity: InterruptPolarity::ActiveHigh, | ||
| is_shared: false, | ||
| is_wake_capable: false, | ||
| irq: (1 << 1) | ||
| irq: Irq::Single(1 << 1) | ||
| }) | ||
| ]) | ||
| ); | ||
|
|
@@ -836,7 +855,7 @@ mod tests { | |
| polarity: InterruptPolarity::ActiveHigh, | ||
| is_shared: false, | ||
| is_wake_capable: false, | ||
| irq: (1 << 6) | ||
| irq: Irq::Single(1 << 6) | ||
| }), | ||
| Resource::Dma(DMADescriptor { | ||
| channel_mask: 1 << 2, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes the irq is encoded as a single number when it is actually encoded as a bit mask. See #330 and https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html#irq-descriptor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on a fix to this. I will fork your branch.