我正在尝试从用户那里读取输入,在按下g的情况下,我输出"完成",而当按下任何其他按钮时,终端正常工作。我现在拥有的是,当按下 g 时它确实打印完成,但我无法将消息传递给 tty 以继续处理。我当前的方法遇到以下错误:"安全复制失败:授予者182819失败:-106
"void kbd_interrupt(message *(m_ptr))
{
/* A keyboard interrupt has occurred. Process it. */
int isaux, x;void kbd_interrupt(message *(m_ptr))
{
/* A keyboard interrupt has occurred. Process it. */
int isaux, x;
//puts("2");
unsigned char scode;
scan_keyboard(&scode, &isaux);
//printf("%d n", DEV_IOCTL);
x = (int) scode;
m_ptr-> m_type = DEV_WRITE_S; //HARD_INT;//DEV_WRITE;
m_ptr->TTY_LINE = KBDAUX_MINOR;
m_ptr->USER_ENDPT=TTY_PROC_NR;
if(scode ==34 | scode == 162) //190
{
printf(" DONEn");
// sys_irqdisable(&irq_hook_id2);
shut =1;
}
else
{
for(int i=0;i<1000;i++)
{
m_ptr->IO_GRANT=i;
// printf("%d n",i);
//printf("%d %dn",m_ptr->m_source, m_ptr->m_type);
send(5,m_ptr);
}
}
return;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////scan_keyboard //////////////////////////////////
//////////////////////////////////////////////////////////////////////////
int scan_keyboard(bp, isauxp)
unsigned char *bp;
int *isauxp;
{
unsigned long b;
if(sys_inb(KEYBD, &b) != OK)
printf("scan_keyboard: 2 sys_inb failedn");
//printf("got ACK from keyboardn");
if (bp)
*bp= b;
return 1;
}
//puts("2");
unsigned char scode;
scan_keyboard(&scode, &isaux);
//printf("%d n", DEV_IOCTL);
x = (int) scode;
m_ptr-> m_type = DEV_WRITE_S; //HARD_INT;//DEV_WRITE;
m_ptr->TTY_LINE = KBDAUX_MINOR;
m_ptr->USER_ENDPT=TTY_PROC_NR;
if(scode ==34 | scode == 162) //190
{
printf(" DONEn");
// sys_irqdisable(&irq_hook_id2);
shut =1;
}
else
{
for(int i=0;i<1000;i++)
{
m_ptr->IO_GRANT=i;
// printf("%d n",i);
//printf("%d %dn",m_ptr->m_source, m_ptr->m_type);
send(5,m_ptr);
}
}
return;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////scan_keyboard //////////////////////////////////
//////////////////////////////////////////////////////////////////////////
int scan_keyboard(bp, isauxp)
unsigned char *bp;
int *isauxp;
{
unsigned long b;
if(sys_inb(KEYBD, &b) != OK)
printf("scan_keyboard: 2 sys_inb failedn");
//printf("got ACK from keyboardn");
if (bp)
*bp= b;
return 1;
}
好的,
在对 tty 驱动程序进行一些研究后,我的队友发现消息类型应该不同,以便将字母注入外壳。所以以下是向tty发送消息的代码:
msg.m_type = INPUT_EVENT;
msg.INPUT_TYPE = INPUT_EV_KEY;
msg.INPUT_VALUE =1;
msg.INPUT_CODE = scode;
send(5, & msg);
scode 是之前检索到的字符代码,5 是 tty 驱动程序地址。希望它对某人有所帮助:)
学分:艾哈迈德·巴西奥尼