QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1388|回复: 2

请教有关中断安装

[复制链接]
发表于 2004-2-17 12:05:07 | 显示全部楼层 |阅读模式
在AT91_init.c中有如下中断安装函数,有如下不解之处请指教
void install_irqhandler(void * isr)
{
        /* ARM irq exception vector addr is 0x00000018  */
        unsigned int * irq_vec_addr = ( unsigned int * ) 0x18;
        /* this is isr entry address, could be another address like 0x3c, 0x58... */
        unsigned int * isr_entry_addr = ( unsigned int * ) 0x38;

        unsigned int instruction;
       
        /* set the ISR entry at 0x38  */
        *isr_entry_addr = (unsigned int)isr;
       
        /* make an instruction: it is machine-code for "ldr  pc, [pc, #(38-18-]"  */
        instruction = ((unsigned int) isr_entry_addr  - (unsigned int)irq_vec_addr - 0x0 | 0xe59ff000;
       
        /* set this instruction at 0x18  */
        *irq_vec_addr = instruction;       
}
上面程序中 instruction = ((unsigned int) isr_entry_addr  - (unsigned int)irq_vec_addr - 0x0 | 0xe59ff000;//看不懂是什么用意,谁能够解释一下多谢!!
发表于 2004-2-20 09:36:44 | 显示全部楼层
instruction的内容是一个指令,即,ldr pc, [pc, #(38-18-]
然后把这条指令放到irq_vec_addr地址处。
这样但产生中断后,会执行此处的指令,这样可以把pc指向真正的中断处理程序入口。
回复

使用道具 举报

 楼主| 发表于 2004-2-20 16:14:38 | 显示全部楼层
明白了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-8 19:13 , Processed in 0.068184 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表