OSDN Git Service

34d8abfd3f79aaa0e618e69d15d678124e8dc816
[vaneos/vaneosmain.git] / Kernel / Interrupt.c
1 /*!
2         Interrupt.c
3         Interrupt Handler and so on.
4         (C) 2014 VOSystems.
5 */
6
7 #include<VaneOS.h>
8 #include<KeyBoard.h>
9 #include<Interrupt.h>
10 #include<scancode.h>
11 #include<Message.h>
12 #include<timer.h>
13
14 #define UINT_MAX 0x100000000
15
16 static volatile unsigned int timer_tick;
17 int system_key_code_flag,break_flag;
18 unsigned long long input;
19
20 struct msg_data kernel;
21 int kernelbuf[32];
22
23 void timer_interrupt( void )
24 {
25         /*count tick*/
26         timer_tick++;
27         
28         if(timer.next>timer.count)
29         {
30                 return;
31         }
32         int i;
33         for(i=0;i<timer.using;i++)
34         {
35                 if(timer.timers[i]->timeout>timer.count)
36                 {
37                         break;
38                 }
39                 timer.timers[i]->flags=TIMER_FLAGS_ALLOC;
40                 msg_put(timer.timers[i]->msg,timer.timers[i]->data);
41         }
42         int j;
43         timer.using-=i;
44         for(j=0;j<timer.using;j++)
45         {
46                 timer.timers[j]=timer.timers[j+i];
47         }
48         if(timer.using>0){
49                 timer.next=timer.timers[0]->timeout;
50         }else{
51                 timer.next=0xffffffff;
52         }
53         return;
54 }
55
56 void keyboard_interrupt( void )
57 {
58         msg_put(&kernel,readKbdEncBuffer()+buf_separate_keyboard);
59 }
60
61 inline void enable()
62 {
63   __asm__ __volatile__ ("sti");
64 }
65
66 inline void disable()
67 {
68   __asm__ __volatile__ ("cli");
69 }