d2e96fa868ed18c06c4dcff24e343ed19a519fb8
[des2015.git] / mart / ex10 / ex10d2.c
1 #include <stdio.h>
2 #include <signal.h>
3 #include <unistd.h>
4 #include <sys/mman.h>
5 #include <sys/io.h>
6
7 #include <native/task.h>
8 #include <native/timer.h>
9 #include <native/intr.h>
10
11 #include <rtdk.h>
12
13 #define LPT1IRQ 7
14
15 RT_TASK task;
16
17 void taskf(void *arg)
18 {
19 RT_INTR intr;
20 rt_intr_create(&intr, "lpt1 handler", LPT1IRQ, 0);
21
22 while(1){
23 rt_intr_wait(&intr, TM_INFINITE);
24 outb(inb(0x378) & 0xFE, 0x378);
25 outb(inb(0x378) | 0x01, 0x378);
26 }
27 }
28
29 int main(int argc, char* argv[])
30 {
31 rt_print_auto_init(1);
32 mlockall(MCL_CURRENT | MCL_FUTURE);
33
34 ioperm(0x37A, 1, 1);
35 outb(inb(0x37A) | 0x10, 0x37A);
36 ioperm(0x378, 1, 1);
37 outb(inb(0x378) | 0x01, 0x378);
38
39 rt_task_create(&task, "task", 0, 50, 0);
40 rt_task_start(&task, &taskf, 0);
41
42 rt_printf("CRTL+C to quit\n");
43 pause();
44 }