interrupt.rs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. use alloc::vec::Vec;
  2. #[derive(Debug)]
  3. pub struct IoApic {
  4. pub id: u8,
  5. pub address: u32,
  6. pub global_system_interrupt_base: u32,
  7. }
  8. #[derive(Debug)]
  9. pub struct NmiLine {
  10. pub processor: NmiProcessor,
  11. pub line: LocalInterruptLine,
  12. }
  13. #[derive(Debug)]
  14. pub enum LocalInterruptLine {
  15. Lint0,
  16. Lint1,
  17. }
  18. #[derive(Debug)]
  19. pub enum NmiProcessor {
  20. All,
  21. /// Refers to a processor with the given UID. This is stored as a `u32`, but should be casted to `u8` when the
  22. /// DSDT uses the deprecated `DefProcessor` operator to define processor UIDs.
  23. ProcessorUid(u32),
  24. }
  25. #[derive(Debug)]
  26. pub enum Polarity {
  27. SameAsBus,
  28. ActiveHigh,
  29. ActiveLow,
  30. }
  31. #[derive(Debug)]
  32. pub enum TriggerMode {
  33. SameAsBus,
  34. Edge,
  35. Level,
  36. }
  37. /// Describes a difference in the mapping of an ISA interrupt to how it's mapped in other interrupt
  38. /// models. For example, if a device is connected to ISA IRQ 0 and IOAPIC input 2, an override will
  39. /// appear mapping source 0 to GSI 2. Currently these will only be created for ISA interrupt
  40. /// sources.
  41. #[derive(Debug)]
  42. pub struct InterruptSourceOverride {
  43. pub isa_source: u8,
  44. pub global_system_interrupt: u32,
  45. pub polarity: Polarity,
  46. pub trigger_mode: TriggerMode,
  47. }
  48. /// Describes a Global System Interrupt that should be enabled as non-maskable. Any source that is
  49. /// non-maskable can not be used by devices.
  50. #[derive(Debug)]
  51. pub struct NmiSource {
  52. pub global_system_interrupt: u32,
  53. pub polarity: Polarity,
  54. pub trigger_mode: TriggerMode,
  55. }
  56. #[derive(Debug)]
  57. pub struct Apic {
  58. pub local_apic_address: u64,
  59. pub io_apics: Vec<IoApic>,
  60. pub local_apic_nmi_lines: Vec<NmiLine>,
  61. pub interrupt_source_overrides: Vec<InterruptSourceOverride>,
  62. pub nmi_sources: Vec<NmiSource>,
  63. /// If this field is set, you must remap and mask all the lines of the legacy PIC, even if
  64. /// you choose to use the APIC. It's recommended that you do this even if ACPI does not
  65. /// require you to.
  66. pub also_has_legacy_pics: bool,
  67. }
  68. #[derive(Debug)]
  69. #[non_exhaustive]
  70. pub enum InterruptModel {
  71. /// This model is only chosen when the MADT does not describe another interrupt model. On `x86_64` platforms,
  72. /// this probably means only the legacy i8259 PIC is present.
  73. Unknown,
  74. /// Describes an interrupt controller based around the Advanced Programmable Interrupt
  75. /// Controllers. These are likely to be found on x86 and x86_64 systems and are made up of a
  76. /// Local APIC for each core and one or more I/O APICs to handle external interrupts.
  77. Apic(Apic),
  78. }