interrupt.rs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 enum LocalInterruptLine {
  10. Lint0,
  11. Lint1,
  12. }
  13. #[derive(Debug)]
  14. pub enum Polarity {
  15. SameAsBus,
  16. ActiveHigh,
  17. ActiveLow,
  18. }
  19. #[derive(Debug)]
  20. pub enum TriggerMode {
  21. SameAsBus,
  22. Edge,
  23. Level,
  24. }
  25. /// Describes a difference in the mapping of an ISA interrupt to how it's mapped in other interrupt
  26. /// models. For example, if a device is connected to ISA IRQ 0 and IOAPIC input 2, an override will
  27. /// appear mapping source 0 to GSI 2. Currently these will only be created for ISA interrupt
  28. /// sources.
  29. #[derive(Debug)]
  30. pub struct InterruptSourceOverride {
  31. pub isa_source: u8,
  32. pub global_system_interrupt: u32,
  33. pub polarity: Polarity,
  34. pub trigger_mode: TriggerMode,
  35. }
  36. /// Describes a Global System Interrupt that should be enabled as non-maskable. Any source that is
  37. /// non-maskable can not be used by devices.
  38. #[derive(Debug)]
  39. pub struct NmiSource {
  40. pub global_system_interrupt: u32,
  41. pub polarity: Polarity,
  42. pub trigger_mode: TriggerMode,
  43. }
  44. #[derive(Debug)]
  45. pub enum InterruptModel {
  46. /// This model is only chosen when a newer one can not be found and the system supports the
  47. /// legacy dual-8259 PIC.
  48. Pic,
  49. /// Describes an interrupt controller based around the Advanced Programmable Interrupt
  50. /// Controllers. These are likely to be found on x86 and x86_64 systems and are made up of a
  51. /// Local APIC for each core and one or more I/O APICs to handle external interrupts.
  52. Apic {
  53. local_apic_address: u64,
  54. io_apics: Vec<IoApic>,
  55. local_apic_nmi_line: LocalInterruptLine,
  56. interrupt_source_overrides: Vec<InterruptSourceOverride>,
  57. nmi_sources: Vec<NmiSource>,
  58. /// If this field is set, you must remap and mask all the lines of the legacy PIC, even if
  59. /// you choose to use the APIC. It's recommended that you do this even if ACPI does not
  60. /// require you to.
  61. also_has_legacy_pics: bool,
  62. },
  63. }