在ARM的Cortex A9处理器间Interrrupts(软件生成的Linux的中断(ARM)如何写一个处理程序?) [英] Inter processor Interrrupts in ARM cortex A9 ( How To write an handler for Software generated Interrupt ( ARM) in Linux? )
问题描述
我看了,在ARM的软件产生的中断用作处理器间中断。我还可以看到,那些中断5已经在使用。我也知道,ARM提供16软件产生的中断。
在我的应用程序正在运行在ARM的内核皮质和Linux上其他的裸机应用。我想从运行裸机应用程序是运行Linux核心的核心服务器通信的一些数据。我打算将数据复制到芯片上的内存(这是共享),我将触发核心(运行Linux)的一个SGI,表明一些数据可供它来处理。现在,我能够从核心生成SGI(运行裸机应用程序)。但是对于处理在Linux方面的中断,我不知道在SGI IRQ编号这是免费的,我也没把握是否可以直接使用的IRQ号(一般SGI从0-15)。没有任何一个有一个想法,如何写在Linux中对SGI的处理程序?
编辑:这是上面的文字进行重新措辞,因为这个问题被关闭 SSCE原因。皮质-A处理器在多CPU系统中使用。一个ARM的通用中断控制器的(GIC)监测所有全局中断并将它们分派到一个特定的CPU。为了让各个CPU信号对方,一个的软件产生的中断的(SGI)是由一个核心到另一个发送;这里采用的外围私人中断的(PPI)。这个问题是,
如何实现可接收SGI作为PPI Linux内核驱动程序?
块引用>解决方案
没有任何一个有一个想法,如何写在Linux中对SGI的处理程序?
块引用>由于你没有给Linux版本,我会假设你有最新的(或至少最近的)工作。 ARM的GIC有<一个href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/arm/gic.txt\"相对=nofollow>设备树的绑定的。通常情况下,你需要在设备树节点指定SGI中断号,
IPC:IPC @地址{
兼容=公司董事会-IPC / *您的驱动器* /
章= LT;地址范围取代;
中断=。1 SGI 0X02取代; / * SGI是你的CPU中断。 * /
状态=已启用;
};在第一号的中断的节表示的 PPI 的。在 SGI 的可能会是0-15之间,因为这是那里的SGI中断路由(至少在的Cortex-A5)。
然后,你可以使用
platform_get_irq()
在驱动程序中获得的 PPI 的(外围私人中断)。我猜的地址的是你希望做通信的共享内存(物理);也许章
是不恰当的,但我认为它会工作。该区域将被Linux的MMU被重新映射,你可以使用它,解析度= platform_get_resource(PDEV,IORESOURCE_MEM,0);
纪念品= devm_ioremap_resource(DEV,RES);以上的地址的设备树是物理地址的十六进制值。在
platform_get_irq()
应返回的 IRQ号的,你可以用的request_irq使用()
系列函数。就在这个连接到你的日常。编辑:不幸的是,中断低于16由Linux <一个被禁止href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-gic.c\"相对=nofollow> IRQ-gic.c 。例如,<一href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-gic.c#n282\"相对=nofollow>
gic_handle_irq()
,限制处理程序,以16和1020如果SMP之间的中断使能,那么handle_IPI( )
被称为感兴趣的中断。 <一href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-gic.c#n651\"相对=nofollow>gic_raise_softirq()
可以用来产生中断信号。为了处理在 SGI 与当前的Linux,的 smp.c 需要额外的<一个href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/kernel/smp.c#n63\"相对=nofollow>枚举ipi_msg_type
价值观和code在处理这些<一个href=\"https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/kernel/smp.c#n544\"相对=nofollow>handle_IPI()
。它看起来像新的内核(3.14+吧?)可能会在set_ipi_handler()
添加到的 smp.c 的做出这样的修改不必要的。I read that the the Software generated interrupts in ARM are used as Inter-processor interrupts. I can also see that 5 of those interrupts are already in use. I also know that ARM provides 16 Software generated interrupts.
In my application i am running a bare metal application on of the ARM-cortex cores and Linux on the other. I want to communicate some data from the core running bare metal application to the core which is running Linux. I plan to copy the data to the on chip memory ( which is shared) and I will trigger a SGI on the Core ( running linux) to indicate some data is available for it to process. Now I am able to generate the SGI from the core ( running bare-metal application ). But for handling the interrupt in the linux side, I am not sure of the SGI IRQ numbers which are free and I am also not sure whether i can use the IRQ number directly ( in general SGI are from 0-15). Does any one have an idea how to write a handler for SGI in Linux?
Edit: This is a re-wording of the above text, because the question was closed for SSCE reasons. The Cortex-A CPUs are used in multi-CPU systems. An ARM generic interrupt controller (GIC) monitors all global interrupts and dispatches them to a particular CPU. In order for individual CPUs to signal each other, a software generated interrupt (SGI) is sent from one core to the other; this uses peripheral private interrupts (PPI). This question is,
How to implement a Linux kernel driver that can receive an SGI as a PPI?
解决方案Does any one have an idea how to write a handler for SGI in Linux?
As you didn't give the Linux version, I will assume you work with the latest (or at least recent). The ARM GIC has device tree bindings. Typically, you need to specify the SGI interrupt number in a device tree node,
ipc: ipc@address { compatible = "company,board-ipc"; /* Your driver */ reg = <address range>; interrupts = <1 SGI 0x02>; /* SGI is your CPU interrupt. */ status = "enabled"; };
The first number in the interrupt stanza denotes a PPI. The SGI will probably be between 0-15 as this is where the SGI interrupts are routed (at least on a Cortex-A5).
Then you can just use the
platform_get_irq()
in your driver to get the PPI (peripheral private interrupt). I guess that address is the shared memory (physical) where you wish to do the communications; maybereg
is not appropriate, but I think it will work. This area will be remapped by the Linux MMU and you can use it with,res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = devm_ioremap_resource(dev, res);
The address in the device tree above is a hex value of the physical address. The
platform_get_irq()
should return an irq number which you can use with therequest_irq()
family of functions. Just connect this to your routine.Edit: Unfortunately, interrupts below 16 are forbidden by the Linux irq-gic.c. For example,
gic_handle_irq()
, limits handler to interrupts between 16 and 1020. If SMP is enabled, thenhandle_IPI()
is called for the interrupts of interest.gic_raise_softirq()
can be used to signal an interrupt. To handle the SGI with the current Linux, smp.c needs additionalenum ipi_msg_type
values and code to handle these inhandle_IPI()
. It looks like newer kernels (3.14+ perhaps?) may add aset_ipi_handler()
to smp.c to make such a modification unneeded.这篇关于在ARM的Cortex A9处理器间Interrrupts(软件生成的Linux的中断(ARM)如何写一个处理程序?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!