2012-05-12 46 views
0

我试图读取用户的输入,并在g被按下的情况下输出“完成”,而当任何其他按钮被按下时,终端正常工作。我现在所拥有的是它在按g时完成了打印,但我无法将消息传递给tty继续处理。我收到以下错误与我目前的做法:“safecopy失败:失败的授予者182819:-106”从驱动程序发送信息到MINIX 3.2中的TTY

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(" DONE\n"); 
    // 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 %d\n",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 failed\n"); 
    //printf("got ACK from keyboard\n"); 
    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(" DONE\n"); 
    // 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 %d\n",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 failed\n"); 
    //printf("got ACK from keyboard\n"); 
    if (bp) 
     *bp= b; 
    return 1; 
} 

回答

0

好了,所以经过一番研究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驱动地址。 希望它可以帮助某人:)

Credit:Ahmed Bassiouny