-
Notifications
You must be signed in to change notification settings - Fork 0
/
int-proc.c
68 lines (48 loc) · 996 Bytes
/
int-proc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// SYS86 project
// Generic interrupt handling
#include "types.h"
#include "int.h"
#include "task.h"
#include "timer.h"
#include "serial.h"
#include "heap.h"
// Asynchronous interrupt nesting level
int int_level;
// Asynchronous interrupt stack
// Allow smaller task stacks
byte_t * int_stack_base;
byte_t * int_stack_top;
// Interrupt procedure
void int_proc (byte_t vect)
{
// No scheduling in interrupt
// if any task event occurs
task_lock ();
switch (vect)
{
case VECT_TIMER0:
timer0_proc ();
break;
case VECT_SERIAL:
serial_proc ();
break;
}
int_end (vect);
task_unlock ();
}
void int_init (void)
{
int_stack_base = heap_alloc (INT_STACK_SIZE, HEAP_TAG_STACK);
int_stack_top = int_stack_base + INT_STACK_SIZE;
vect_set (VECT_SYSTEM, int_system);
}
void int_set_timer (void)
{
vect_set (VECT_TIMER0, int_timer0);
int_enable (VECT_TIMER0);
}
void int_set_serial (void)
{
vect_set (VECT_SERIAL, int_serial);
int_enable (VECT_SERIAL);
}