eCos系统的VSR支持(VSR Support)

来源:互联网 发布:mac免费软件下载网站 编辑:程序博客网 时间:2024/05/22 15:29

eCos系统为应用开发人员提供了抽象的中断处理机制,在这种抽象机制的帮助下,应用开发人员不需要知道特定硬件架构的中断机制就可以编写中断处理函数(ISR),但是这种机制会增加中断延迟,如果某个中断的实时性要求非常高,eCos可以提供替换掉这种机制直接处理中断从而最小化中断延迟的解决办法。

eCos官网:http://ecos.sourceware.org
eCos中文技术网:http://www.52ecos.net
eCos交流QQ群:144940146。
原文:http://ecos.sourceware.org/docs-latest/ref/kernel-interrupts.html
译文:http://blog.csdn.net/zoomdy/article/details/19250557
mingdu.zheng<at>gmail<dot>com

当产生中断时,硬件将跳转到一段被称作VSR的代码处执行,VSR也就是向量服务例程(Vector Service Routine)。默认情况下,VSR代码是由eCos系统提供的,通常使用汇编语言编写,但是某些架构也可以使用C语言实现VSR例程,这需要在作为VSR例程的C函数上添加interrupt属性。关于如何使用C语言实现VSR的更多内容可以查阅编译器文档。eCos系统的默认VSR将计算出哪个ISR函数应当处理当前产生的中断,然后创建一个适合该ISR函数执行的C运行时环境。

某些应用可能希望替换掉默认的VSR直接处理部分中断,这将最小化中断延迟,但是需要应用开发人员在更低的层次上进行编程。通常情况下,编写自定义VSR的最佳途径是拷贝一份eCos提供的现成的VSR代码,然后在这基础上进行适当地修改。cyg_interrupt_get_vsr函数可以用来获取指定中断向量的当前VSR,当自定义VSR不再需要时,可以恢复默认的VSR。cyg_interrupt_set_vsr函数可以用来安装替换默认VSR的自定义VSR,通常该函数的vsr参数对应于某个汇编源文件导出的符号。

When an interrupt occurs the hardware will transfer control to a piece of code known as the VSR, or Vector Service Routine. By default this code is provided by eCos. Usually it is written in assembler, but on some architectures it may be possible to implement VSRs in C by specifying an interrupt attribute. Compiler documentation should be consulted for more information on this. The default eCos VSR will work out which ISR function should process the interrupt, and set up a C environment suitable for this ISR.

For some applications it may be desirable to replace the default eCos VSR and handle some interrupts directly. This minimizes interrupt latency, but it requires application developers to program at a lower level. Usually the best way to write a custom VSR is to copy the existing one supplied by eCos and then make appropriate modifications. The function cyg_interrupt_get_vsr can be used to get hold of the current VSR for a given interrupt vector, allowing it to be restored if the custom VSR is no longer required. cyg_interrupt_set_vsr can be used to install a replacement VSR. Usually the vsr argument will correspond to an exported label in an assembler source file.


原文见:http://blog.csdn.net/zoomdy/article/details/19250557

0 0