From 9c832c214c1f3dda362e7b316100d9c9915d2bef Mon Sep 17 00:00:00 2001 From: liaocj Date: Sun, 24 Nov 2024 18:00:59 +0800 Subject: [PATCH] Update submodules --- .../msi_domain_alloc.md" | 0 ...55\345\217\267\346\230\240\345\260\204.md" | 46 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 "linux/\345\206\205\346\240\270-\351\251\261\345\212\250/\344\270\255\346\226\255/msi_domain_alloc.md" diff --git "a/linux/\345\206\205\346\240\270-\351\251\261\345\212\250/\344\270\255\346\226\255/msi_domain_alloc.md" "b/linux/\345\206\205\346\240\270-\351\251\261\345\212\250/\344\270\255\346\226\255/msi_domain_alloc.md" new file mode 100755 index 0000000..e69de29 diff --git "a/linux/\345\206\205\346\240\270-\351\251\261\345\212\250/\344\270\255\346\226\255/\347\241\254\344\270\255\346\226\255--\344\270\255\346\226\255\345\217\267\346\230\240\345\260\204.md" "b/linux/\345\206\205\346\240\270-\351\251\261\345\212\250/\344\270\255\346\226\255/\347\241\254\344\270\255\346\226\255--\344\270\255\346\226\255\345\217\267\346\230\240\345\260\204.md" index ea9e70e..f9e5f9d 100755 --- "a/linux/\345\206\205\346\240\270-\351\251\261\345\212\250/\344\270\255\346\226\255/\347\241\254\344\270\255\346\226\255--\344\270\255\346\226\255\345\217\267\346\230\240\345\260\204.md" +++ "b/linux/\345\206\205\346\240\270-\351\251\261\345\212\250/\344\270\255\346\226\255/\347\241\254\344\270\255\346\226\255--\344\270\255\346\226\255\345\217\267\346\230\240\345\260\204.md" @@ -273,4 +273,48 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, return 0; } -``` \ No newline at end of file +``` + +# 完成硬件中断号到软件中断号的映射 +通过IRQ 中断号和 irq_domain获取struct irq_data 数据结构, 然后把硬件中断号 hwirq设置到 struct irq_data 数据结构中的hwirq 成员中, 这样就完成了硬件中断号到软件中断号的映射(!!!). +```c +/** + * irq_domain_set_info - Set the complete data for a @virq in @domain + * @domain: Interrupt domain to match + * @virq: IRQ number + * @hwirq: The hardware interrupt number + * @chip: The associated interrupt chip + * @chip_data: The associated interrupt chip data + * @handler: The interrupt flow handler + * @handler_data: The interrupt flow handler data + * @handler_name: The interrupt handler name + */ +void irq_domain_set_info(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq, struct irq_chip *chip, + void *chip_data, irq_flow_handler_t handler, + void *handler_data, const char *handler_name) +{ + irq_domain_set_hwirq_and_chip(domain, virq, hwirq, chip, chip_data); + __irq_set_handler(virq, handler, 0, handler_name); + irq_set_handler_data(virq, handler_data); +} +EXPORT_SYMBOL(irq_domain_set_info); + +[kernel/irq/irqdomain.c] +int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq, struct irq_chip *chip, + void *chip_data) +{ + struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq); + + if (!irq_data) + return -ENOENT; + + irq_data->hwirq = hwirq; + irq_data->chip = chip ? chip : &no_irq_chip; + irq_data->chip_data = chip_data; + + return 0; +} + +```