开关中断与cpsid/cpsie指令

开关中断与cpsid/cpsie指令

在汇编代码中,CPSID   CPSIE  用于快速的开关中断。

CPSID

I

;PRIMASK=1,

;关中断

CPSIE

I

;PRIMASK=0,

;开中断

CPSID 

CPSIE

F

F

;FAULTMASK=1,

;FAULTMASK=0

;关异常

;开异常


I:IRQ中断;    F:FIQ中断

最常见的这两个命令的使用处是在关中断、开中断的实现中,我们经常用的local_irq_save和local_irq_restore最终都是调用了以下两个实现,即关/开中断只是操作了CPSR中的中断标志位而已,并没有去对GIC做操作,只是简单的不让CPU响应中断,具体实现在arch/arm/include/asm/irqflags.h文件中。

static inline void arch_local_irq_enable(void)
{
	asm volatile(
		"	cpsie i			@ arch_local_irq_enable"
		:
		:
		: "<span id="1_nwp" style="padding: 0px; width: auto; height: auto; float: none;"><a target=_blank id="1_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=6369bf7b1bc3af2e&k=memory&k0=memory&kdi0=0&luki=1&n=10&p=baidu&q=65035100_cpr&rb=0&rs=1&seller_id=1&sid=2eafc31b7bbf6963&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1836545&u=http%3A%2F%2Fwww%2Ebubuko%2Ecom%2Finfodetail%2D376398%2Ehtml&urlid=0" target="_blank" mpid="1" style="padding: 0px; color: rgb(51, 51, 51); text-decoration: none;"><span style="padding: 0px; color: rgb(0, 0, 255); width: auto; height: auto;">memory</span></a></span>", "cc");
}
static inline void arch_local_irq_disable(void)
{
	asm volatile(
		"	cpsid i			@ arch_local_irq_disable"
		:
		:
		: "memory", "cc");
}
#define local_fiq_enable()  __asm__("cpsie f	@ __stf" : : : "memory", "cc")
#define local_fiq_disable() __asm__("cpsid f	@ __clf" : : : "memory", "cc")
http://dirlt.com/gcc-asm.html
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值