Question

I'm trying to read input from the user and in the case the g is pressed I output "Done" while when any other button is pressed the terminal works normally. What I have now is that it does print done when g is pressed but I can't pass the message to the tty to continue processing. I am getting the following error with my current approach: "safecopy failed: granter 182819 failed: -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(" 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;
}
Was it helpful?

Solution

Ok so after some research into the tty driver my team mate found out that the message type should be different to inject letters onto the shell. So the following is the code to send a message to the tty:

msg.m_type = INPUT_EVENT;
msg.INPUT_TYPE = INPUT_EV_KEY;
msg.INPUT_VALUE =1;
msg.INPUT_CODE = scode;
send(5, & msg);

The scode is the character code retrieved earlier and 5 is the tty driver address. Hope it helps Someone :)

Credit: Ahmed Bassiouny

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top