ARM Linux中断机制分析
ector_irq+ stubs_offset
W(b) vector_fiq+ stubs_offset
.LCvswi:
.word vector_swi
由于系统调用异常的代码编译在其他文件中,其入口地址与异常向量相隔较远,使用b指令无法跳转过去(b指令只能相对当前pc跳转32M范围)。因此将其地址存放到LCvswi中,并从内存地址中加载其入口地址,原理与其他调用是一样的。这也就是为什么系统调用的速度稍微慢一点的原因。
问题6:为什么ARM能处理中断?
因为ARM架构的CPU有一个机制,只要中断产生了,CPU就会根据中断类型自动跳转到某个特定的地址(即中断向量表中的某个地址)。如下表所示,既是中断向量表。
ARM中断向量表及地址
问题7:什么是High vector?
A:在Linux3.1.0,arch/arm/include/asm/system.hline121 有定义如下:
#if __LINUX_ARM_ARCH__ >=4
#define vectors_high() (cr_alignment & CR_V)
#else
#define vectors_high() (0)
#endif
意思就是,如果使用的ARM架构大于等于4,则定义vectors_high()=cr_alignment&CR_V,该值就等于0xffff0000
在Linux3.1.0,arch/arm/include/asm/system.hline33有定义如下:
#define CR_V (1 < 13) /* Vectors relocated to 0xffff0000 */
arm下规定,在0x00000000或0xffff0000的地址处必须存放一张跳转表。
问题8:中断向量表是如何存放到0x00000000或0xffff0000地址的?
A:Uboot执行结束后会把Linux内核拷贝到内存中开始执行,linux内核执行的第一条指令是linux/arch/arm/kernel/head.S,此文件中执行一些参数设置等操作后跳入linux/init/main.c文件的start_kernel函数,此函数调用一系列初始化函数,其中trip_init()函数实现向量表的设定操作。
参考文献
1. ARM Linux中断向量表搬移设计过程http://blog.chinaunix.net/uid-361890-id-175347.html
2. 《LINUX3.0内核源代码分析》第二章:中断和异常 http://blog.chinaunix.net/uid-25845340-id-2982887.html
3. Kernel Memory Layout on ARM Linuxhttp://www.arm.linux.org.uk/developer/memory.txt
4.http://emblinux.sinaapp.com/ar01s16.html#id3603818
5. Linux中断(interrupt)子系统之二:arch相关的硬件封装层http://blog.csdn.net/droidphone/article/details/7467436
附录1
Kernel Memory Layout on ARM Linux
Start End Use
--------------------------------------------------------------------------
ffff8000 ffffffff copy_user_page / clear_user_page use.
ForSA11xx and Xscale, this is used to
setupa minicache mapping.
ffff1000 ffff7fff Reserved.
Platformsmust not use this address range.
ffff0000 ffff0fff CPUvector page.
The CPU vectors are mapped here ifthe
CPU supports vector relocation(control
register V bit.)
ffc00000 fffeffff DMA memory mapping region. Memory returned
bythe dma_alloc_xxx functions will be
dynamicallymapped here.
ff000000 ffbfffff Reserved for future expansion of DMA
mappingregion.
VMALLOC_END feffffff Free for platform use, recommended.
VMALLOC_ENDmust be aligned to a 2MB
boundary.
VMALLOC_START VMALLOC_END-1 vmalloc() /ioremap() space.
Memoryreturned by vmalloc/ioremap will
bedynamically placed in this region.
VMALLOC_STARTmay be based upon the value
ofthe high_memory variable.
PAGE_OFFSET high_memory-1 Kernel direct-mapped RAM region.
Thismaps the platforms RAM, and typically
mapsall platform RAM in a 1:1 relationship.
TASK_SIZE PAGE_OFFSET-1 Kernel module space
Kernelmodules inserted via insmod are
placedhere using dynamic mappings.
00001000 TASK_SIZE-1 User space mappings
Per-threadmappings are placed here via
themmap() system call.
00000000 00000fff CPU vector page / null pointer trap
CPUswhich do not support vector remapping
placetheir vector page here. NULL pointer
dereferencesby both the kernel and user
spaceare also caught via this mapping.
Please note that mappings which collidewith the above areas may result
in a non-bootable kernel, or may cause thekernel to (eventually) panic
at run time.
Since future CPUs may impact the kernelmapping layout, user programs
must not access any memory which is notmapped inside their 0x0001000
to TASK_SIZE address range. If the
ARMLinux中断机 相关文章:
- ARM Linux中断机制之中断的初始化(11-10)
- ARM Linux中断机制之中断的申请(11-10)
- ARM Linux中断机制之中断处理(11-09)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)