intr.c

来自「TI OMAP 1510上mcbsp的驱动程序」· C语言 代码 · 共 30 行

C
30
字号
/******************************************************************//* intr.c V0.00                                                   *//* Copyright (c) Texas Instruments , Incorporated  1997           *//******************************************************************//******************************************************************//* Define temp location for storing interrupt vector locations    *//******************************************************************/#include <intr.h>
extern interrupt void _intr_handler();
extern int _vectors;	 //Start label of vector table
void hook_interrupt(unsigned int trap, Ip func)
{
	unsigned long _branch = 0x6a00ul;
	unsigned long _func = (unsigned long)func;
	unsigned long *_addr = (unsigned long *)(((unsigned long)&_vectors + (trap * 0x8)) >> 1);

	*_addr = (_branch << 16) | _func;
}

void unhook_interrupt(unsigned int trap)
{
	unsigned long _branch = 0x6a00ul;
	unsigned long _func = (unsigned long)_intr_handler;
	unsigned long *_addr = (unsigned long *)(((unsigned long)&_vectors + (trap * 0x8)) >> 1);

	*_addr = (_branch << 16) | _func;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?