Project

General

Profile

Revision 11

Added function 5.2, must check for errors

View differences:

keyboard.c
26 26
  if(util_sys_inb(STATUS_REG,&status_reg)!=0){ //checks if there is an error
27 27
    return;
28 28
  }
29
  if(((status_reg & STAT_REG_OBF)==0) ||((status_reg&(STAT_REG_PAR|STAT_REG_TIMEOUT))!=0)){ //checks if there is a parity or timeout error (mask -> 0xC0, bit 7 and 6 set) and checks if output buffer is empty
29
  if(((status_reg & STAT_REG_OBF)==0) ||((status_reg&(STAT_REG_PAR|STAT_REG_TIMEOUT))!=0)|| ((status_reg&STAT_REG_AUX)!=0)){ //checks if there is a parity or timeout error (mask -> 0xC0, bit 7 and 6 set), checks if output buffer is empty and checks if there is data coming from the mouse
30 30
    return;
31 31
  }
32 32
  util_sys_inb(OUTPUT_BUF,&scan_code);
33 33

  
34 34
}
35 35

  
36

  
36 37
int (kbc_subscribe_int)(uint8_t *bit_no) {    //similar function to that of timer_subscribe_int
37 38
    *bit_no = BIT(keyboard_id);
38 39
    if(sys_irqsetpolicy(KEYBOARD_IRQ,(IRQ_REENABLE|IRQ_EXCLUSIVE),&keyboard_id)==1){      //operation to subscribe int
......
49 50
  }
50 51
  return 0;
51 52
}
53

  
54
int (enable_interrupt)()
55
{
56
  uint8_t command;
57

  
58
  if(sys_outb(STATUS_REG,READ_COMMAND)!=0){
59
    printf("Error writing read-command\n");
60
    return 1;
61
  }
62

  
63
  if(util_sys_inb(OUTPUT_BUF, &command)!=0){
64
    printf("Error reading output buffer\n");
65
    return 1;
66
  }
67

  
68
  command = command | INT_ENABLE;
69

  
70
  if(sys_outb(STATUS_REG,OUTPUT_BUF)!=0){
71
    printf("Error writing output buffer\n");
72
    return 1;
73
  }
74

  
75
  if(sys_outb(OUTPUT_BUF,command)!=0){
76
    printf("Error writing new buffer status\n");
77
    return 1;
78
  }
79

  
80
  return 0;
81
}

Also available in: Unified diff