linux init时初始化中断号

[    6.535890]<3>[I](3)OF: of_irq_parse_one: dev=/soc/xxx@12300000, index=0
[    6.536771]<3>[W](3)CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.9.118+ #356
[    6.537638]<3>[W](3)Hardware name: ATC Inc. AC8x (DT)
[    6.538266]<3>[W](3)Call trace:
[    6.538658]<3>[W](3)[<ffffff800808bb7c>] dump_backtrace+0x0/0x2c0
[    6.539420]<3>[W](3)[<ffffff800808c36c>] show_stack+0x14/0x1c
[    6.540137]<3>[W](3)[<ffffff80083d6bf8>] dump_stack+0x94/0xb4
[    6.540855]<3>[W](3)[<ffffff80087c3c08>] of_irq_parse_one+0x54/0x174
[    6.541648]<3>[W](3)[<ffffff80087c40d8>] of_irq_count+0x3c/0x68
[    6.542387]<3>[W](3)[<ffffff80087c09fc>] of_device_alloc+0x74/0x198
[    6.543170]<3>[W](3)[<ffffff80087c0b74>] of_platform_device_create_pdata+0x54/0xe8
[    6.544115]<3>[W](3)[<ffffff80087c0ce8>] of_platform_bus_create.part.4+0xc4/0x33c
[    6.545050]<3>[W](3)[<ffffff80087c0e98>] of_platform_bus_create.part.4+0x274/0x33c
[    6.545995]<3>[W](3)[<ffffff80087c10ec>] of_platform_populate+0x94/0xec
[    6.546822]<3>[W](3)[<ffffff8008e8bb54>] of_platform_default_populate_init+0x68/0x74
[    6.547789]<3>[W](3)[<ffffff80080837e0>] do_one_initcall+0x58/0x170
[    6.548572]<3>[W](3)[<ffffff8008e50e70>] kernel_init_freeable+0x1a0/0x25c
[    6.549419]<3>[W](3)[<ffffff8008aa2230>] kernel_init+0x10/0x104
[    6.550158]<3>[W](3)[<ffffff8008083570>] ret_from_fork+0x10/0x20

of_irq_to_resource 将中断资源打包到resource

[    6.776374]<3>[I](3)OF: of_irq_parse_one: dev=/soc/xxx@12300000, index=0
[    6.777254]<3>[W](3)CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.9.118+ #356
[    6.778121]<3>[W](3)Hardware name: ATC Inc. AC8x (DT)
[    6.778749]<3>[W](3)Call trace:
[    6.779142]<3>[W](3)[<ffffff800808bb7c>] dump_backtrace+0x0/0x2c0
[    6.779902]<3>[W](3)[<ffffff800808c36c>] show_stack+0x14/0x1c
[    6.780619]<3>[W](3)[<ffffff80083d6bf8>] dump_stack+0x94/0xb4
[    6.781337]<3>[W](3)[<ffffff80087c3c08>] of_irq_parse_one+0x54/0x174
[    6.782130]<3>[W](3)[<ffffff80087c3f6c>] of_irq_to_resource+0x38/0x104
[    6.782945]<3>[W](3)[<ffffff80087c4084>] of_irq_to_resource_table+0x4c/0x64
[    6.783814]<3>[W](3)[<ffffff80087c0a90>] of_device_alloc+0x108/0x198
[    6.784607]<3>[W](3)[<ffffff80087c0b74>] of_platform_device_create_pdata+0x54/0xe8
[    6.785552]<3>[W](3)[<ffffff80087c0ce8>] of_platform_bus_create.part.4+0xc4/0x33c
[    6.786487]<3>[W](3)[<ffffff80087c0e98>] of_platform_bus_create.part.4+0x274/0x33c
[    6.787432]<3>[W](3)[<ffffff80087c10ec>] of_platform_populate+0x94/0xec
[    6.788258]<3>[W](3)[<ffffff8008e8bb54>] of_platform_default_populate_init+0x68/0x74
[    6.789226]<3>[W](3)[<ffffff80080837e0>] do_one_initcall+0x58/0x170
[    6.790008]<3>[W](3)[<ffffff8008e50e70>] kernel_init_freeable+0x1a0/0x25c
[    6.790855]<3>[W](3)[<ffffff8008aa2230>] kernel_init+0x10/0x104
[    6.791593]<3>[W](3)[<ffffff8008083570>] ret_from_fork+0x10/0x20

获取中断号就可以通过如下方式获取

platform_get_resource(pdev,IORESOURCE_IRQ,idx);

platform_get_irq 也是通过platform_get_resource来实现的

/**
 * platform_get_irq - get an IRQ for a device
 * @dev: platform device
 * @num: IRQ number index
 *
 * Gets an IRQ for a platform device and prints an error message if finding the
 * IRQ fails. Device drivers should check the return value for errors so as to
 * not pass a negative integer value to the request_irq() APIs.
 *
 * For example::
 *
 *		int irq = platform_get_irq(pdev, 0);
 *		if (irq < 0)
 *			return irq;
 *
 * Return: non-zero IRQ number on success, negative error number on failure.
 */
int platform_get_irq(struct platform_device *dev, unsigned int num)
{
	int ret;

	ret = platform_get_irq_optional(dev, num);
	if (ret < 0 && ret != -EPROBE_DEFER)
		dev_err(&dev->dev, "IRQ index %u not found\n", num);

	return ret;
}
EXPORT_SYMBOL_GPL(platform_get_irq);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux中断初始化是在内核初始化过程中完成的。具体来说,中断初始化包括三个方面:中断子系统初始化中断或异常处理和中断API的初始化。首先,在中断子系统初始化过程中,内核会对中断处理机制进行初始化,包括中断描述符表的初始化中断请求队列的初始化等。其次,中断或异常处理是实际处理中断或异常的过程。最后,中断API提供一组函数给设备驱动程序使用,包括注册与释放、激活与禁止等操作。在中断描述符表的初始化中,有两个阶段。第一阶段发生在内核引导过程中,主要完成为中断描述符表分配空间和初始化默认值,同将IDT的起始位置存储到IDTR寄存器。第二阶段发生在内核初始化过程中,使用trap_initinit_IRQ函数进行初始化。trap_init函数完成对系统保留中断向量的初始化,而init_IRQ函数完成其余中断向量的初始化。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Linux中断机制:硬件处理,初始化中断处理](https://blog.csdn.net/wads23456/article/details/106105492)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [linux中断系列之中断子系统初始化(三)](https://blog.csdn.net/zhao2272062978/article/details/70272066)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值