📄 int.c
字号:
/* *---------------------------------------------------------------------- * T-Kernel * * Copyright (C) 2004 by Ken Sakamura. All rights reserved. * T-Kernel is distributed under the T-License. *---------------------------------------------------------------------- * * Version: 1.01.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2004/6/28. * *---------------------------------------------------------------------- *//* * @(#)int.c (libtk/SH7751R) * * Interrupt controller */#include <basic.h>#include <tk/syslib.h>#include <tk/sysdef.h>typedef struct { INTVEC vec:16; INT shift:16; INT port;} INTCTBL;LOCAL INTCTBL intctbl[] = { { IV_SCI, 4, IPRB }, { IV_GPIO, 12, IPRC }, { IV_DMAC, 8, IPRC }, { IV_SCIF, 4, IPRC }, { IV_PCIC0, 0, INTPRI00 }, { IV_PCIC1, 4, INTPRI00 }, { IV_TMU0, 12, IPRA }, { IV_TMU1, 8, IPRA }, { IV_TMU2, 4, IPRA }, { IV_TMU3, 8, INTPRI00 }, { IV_TMU4, 12, INTPRI00 }, { IV_RTC, 0, IPRA }, { IV_WDT, 12, IPRB }, { IV_REF, 8, IPRB }, { IV_HUDI, 0, IPRC }, { 0 }};/* * Interrupt disable/enable */Inline UINT _disint( void ){ UINT imask; Asm(" stc sr, r0 \n" " mov r0, %0 \n" " or %1, r0 \n" " ldc r0, sr " : "=r"(imask) : "i"(SR_I(15)) : "r0" ); return imask;}Inline void _enaint( UINT imask ){ Asm(" ldc %0, sr" :: "r"(imask | SR_FD));}#define _DI(imask) ( imask = _disint() )#define _EI(imask) ( _enaint(imask) )/* * Enable interrupt * Enable the interrupt specified by 'intvec' by setting priority * level to 'level'. '1'-'15' is valid for 'level' and '15' is the * highest priority. If 'level' is invalid value, operation is not * guaranteed. * INTMSK00 register is not changed automatically, so it must be set * if necessary. */EXPORT void EnableInt( INTVEC intvec, INT level ){ INTCTBL *tbl; UINT msk, imask; for ( tbl = intctbl; tbl->vec != 0; tbl++ ) { if ( tbl->vec != intvec ) continue; msk = ~(0xf << tbl->shift); level <<= tbl->shift; _DI(imask); if ( tbl->port >= IPRA ) { out_h(tbl->port, (in_h(tbl->port) & msk) | level); } else { out_w(tbl->port, (in_w(tbl->port) & msk) | level); } _EI(imask); break; }}/* Disable interrupt * Disable the interrupt specified by 'intvec' by setting its priority * level to '0'. INTMSK00 register is not changed automatically, so it * must be set if necessary. */EXPORT void DisableInt( INTVEC intvec ){ return EnableInt(intvec, 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -