Project

General

Profile

Revision 6

Poll finished-no sys_call count

View differences:

lab3/lab3.c
29 29
  // handles control over to LCF
30 30
  // [LCF handles command line arguments and invokes the right function]
31 31
  if (lcf_start(argc, argv))
32
     return 1;
32
    return 1;
33 33

  
34 34
  // LCF clean up tasks
35 35
  // [must be the last statement before return]
......
49 49
  uint8_t scan_arr[2] = {0, 0};
50 50
  scan_arr[0] = scancode & 0xFF;
51 51
  scan_arr[1] = scancode & 0xFF00;
52
  int flag=0;
52
  int flag = 0;
53 53

  
54 54
  printf("%d\n",
55 55
         sys_irqsetpolicy(IRQ_KB, IRQ_REENABLE | IRQ_EXCLUSIVE, &hook_id));
......
67 67
  printf("%x\n", scancode);
68 68
  kbc_ih();
69 69
  printf("\n");
70
  while ((scancode & 0xFF) !=
70
  while (scancode !=
71 71
         EXIT_CODE) { /* You may want to use a different condition */
72 72
    /* Get a request message. */
73 73
    // printf("1\n");
......
84 84
          sys_inb(0x64, &scancode);
85 85
          if (scancode & 0x01) {
86 86
            sys_inb(0x60, &scancode);
87
          }
88
          
89
          if(scancode !=0xe0 && flag==0)
90
          {
91
            //tickdelay(micros_to_ticks(DELAY_US));
87
          if (scancode != 0xe0 && flag == 0) {
88
            // tickdelay(micros_to_ticks(DELAY_US));
92 89
            scan_arr[0] = scancode;
93 90
            kbd_print_scancode(!(scancode & 0x80), 1, scan_arr);
94 91
          }
95 92

  
96
          else if(scancode==0xe0)
97
          {
98
            scan_arr[0]=scancode;
99
            flag=1;
93
          else if (scancode == 0xe0) {
94
            scan_arr[0] = scancode;
95
            flag = 1;
100 96
          }
101 97

  
102
          else if(flag==1)
103
          {
98
          else if (flag == 1) {
104 99
            scan_arr[1] = scancode;
105 100
            kbd_print_scancode(!(scancode & 0x80), 2, scan_arr);
106
            flag=0;
101
            flag = 0;
107 102
          }
103
          }
108 104

  
109 105
        }
110 106
        // printf("msg:%x\n",msg.m_notify.interrupts);
......
126 122

  
127 123
int(kbd_test_poll)() {
128 124
  /* To be completed by the students */
129
  printf("%s is not yet implemented!\n", __func__);
125
  uint8_t scan_arr[2] = {0, 0};
126
  int flag = 0;
127
  while(scancode != EXIT_CODE)
128
  {
129
    tickdelay(micros_to_ticks(DELAY_US));
130
    sys_inb(0x64, &scancode);
131
          if (scancode & 0x01) {
132
            sys_inb(0x60, &scancode);
133
          if (scancode != 0xe0 && flag == 0) {
134
            scan_arr[0] = scancode;
135
            kbd_print_scancode(!(scancode & 0x80), 1, scan_arr);
136
          }
130 137

  
138
          else if (scancode == 0xe0) {
139
            scan_arr[0] = scancode;
140
            flag = 1;
141
          }
142

  
143
          else if (flag == 1) {
144
            scan_arr[1] = scancode;
145
            kbd_print_scancode(!(scancode & 0x80), 2, scan_arr);
146
            flag = 0;
147
          }
148
        }
149

  
150
  }
151

  
131 152
  return 1;
132 153
}
133 154

  

Also available in: Unified diff