xref: /DragonOS/kernel/src/arch/x86_64/msi.rs (revision a8753f8fffb992e4d3bbd21eda431081b395af6b)
1 use crate::driver::pci::pci_irq::TriggerMode;
2 /// @brief 获得MSI Message Address
3 /// @param processor 目标CPU ID号
4 /// @return MSI Message Address
5 pub fn arch_msi_message_address(processor: u16) -> u32 {
6     0xfee00000 | ((processor as u32) << 12)
7 }
8 /// @brief 获得MSI Message Data
9 /// @param vector 分配的中断向量号
10 /// @param processor 目标CPU ID号
11 /// @param trigger  申请中断的触发模式,MSI默认为边沿触发
12 /// @return MSI Message Address
13 pub fn arch_msi_message_data(vector: u16, _processor: u16, trigger: TriggerMode) -> u32 {
14     match trigger {
15         TriggerMode::EdgeTrigger => vector as u32,
16         TriggerMode::AssertHigh => vector as u32 | 1 << 15 | 1 << 14,
17         TriggerMode::AssertLow => vector as u32 | 1 << 15,
18     }
19 }
20