-
Notifications
You must be signed in to change notification settings - Fork 22
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
Interrupt abstractions #71
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"coverage_score": 91.4, | ||
"coverage_score": 87.3, | ||
"exclude_path": "", | ||
"crate_features": "" | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2021 Amazon.com, Inc. or its affiliates. | ||
// All Rights Reserved. | ||
|
||
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause | ||
|
||
//! Traits and Structs to manage legacy interrupt sources for devices. | ||
//! | ||
//! Legacy interrupt sources typically include pin based interrupt lines. | ||
|
||
use crate::interrupt::ConfigurableInterrupt; | ||
|
||
/// Definition for PCI INTx pins. | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd)] | ||
pub enum IntXPin { | ||
/// INTA | ||
IntA = 0x1, | ||
/// INTB | ||
IntB = 0x2, | ||
/// INTC | ||
IntC = 0x3, | ||
/// INTD | ||
IntD = 0x4, | ||
} | ||
|
||
/// Standard configuration for Legacy interrupts. | ||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] | ||
pub struct LegacyIrqConfig { | ||
/// Input of the system interrupt controllers the device's interrupt pin is connected to. | ||
/// Implemented by any device that makes use of an interrupt pin. | ||
pub interrupt_line: Option<u32>, | ||
/// Specifies which interrupt pin the device uses. | ||
pub interrupt_pin: Option<IntXPin>, | ||
} | ||
|
||
/// Trait for defining properties of Legacy interrupts. | ||
pub trait LegacyInterrupt: ConfigurableInterrupt<Cfg = LegacyIrqConfig> {} | ||
|
||
/// Blanket implementation for Interrupts that use a LegacyIrqConfig. | ||
impl<T> LegacyInterrupt for T where T: ConfigurableInterrupt<Cfg = LegacyIrqConfig> {} |
Oops, something went wrong.
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.
Would this be used by PCI devices to set their interrupt line field or are there other uses? Typically, the interrupt line field in the config space is just a normal R/W field that is written during boot by firmware. So device emulation should not be concerned with this value.
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.
For a PCI device using an INTx interrupt interrupt_line may not be of significance for device emulation. But this value is of significance for setting up other components like the MPtable.
Also you would use
interrupt_line
to configure a specific line that you want the interrupt assigned to (see https://github.com/alsrdn/firecracker/blob/ab0c9642162f8c749c516d02b43b144a91baa33e/src/vmm/src/device_manager/legacy.rs#L89).