📄 s9_intrl.c
字号:
#include "vxWorks.h"
#include "arch/arm/ivArm.h"
#include "intLib.h"
#include "stdio.h"
static VOIDFUNCPTR *vector;
static FUNCPTR old_handler;
#define KEYBD 0x60 /*I/O port for keyboard data */
#define PORT_B 0x61 /*I/O port for 8255 port B (kbd, beeper...)*/
#define KBIT 0X80 /*bit used to ack characters to keyboard */
static void outb_p(unsigned char value,unsigned short port)
{
/* _asm__volatile_("out" "b" " %" "b" "0,%" "w" "1" "\n\t"
"outb %%a1,$0x80"
:
: "a" (value),"Nd" (port)
);
*/
}
static unsigned char inb_p (unsigned short port)
{
/* unsigned char _v;
_asm__volatile_("in" "b" "%" "w" "1,%" "" "0" "\n\t"
"outb %%a1,$0x80"
: "=a" (_v)
:"Nd" (port)
);
return _v;
*/
}
static int scan_keyboard()
{
int code,val;
code = inb_p(KEYBD); /* get the scan code for the key struck */
val = inb_p(PORT_B); /*strobe the keyboard to ack the char */
outb_p (val|KBIT,PORT_B); /*strobe the bit high */
outb_p (val,PORT_B); /*now strobe it low */
return code;
}
static void mykbintr(int arg)
{
int code;
logMsg("I am in mykbintr.\n");
/* A keyboard interrupt has occurred. proces it.*/
/* Fetch the character from the keyboard harware and acknowledge it.*/
code = scan_keyboard();
if ((code&0x7F) == 0x01)
{
logMsg("ESC is pressed,I recover the keyboard intr.\n");
intVecSet((FUNCPTR*)vector,(FUNCPTR)old_handler);
}
else
{
logMsg("I get a scancode:%x(%s).\n",code&0x7F,(code&0x80)?"DOWN":"UP");
}
}
void s9_intrl(void)
{
vector = (VOIDFUNCPTR *)(INUM_TO_IVEC(33));
old_handler = intVecGet((FUNCPTR*)vector);
if (intConnect(vector,mykbintr,0) == OK)
{
logMsg("intConnect OK.\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -