Rev 1377 | Rev 1387 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1085 | pj | 1 | /* |
1377 | giacomo | 2 | * Project: S.Ha.R.K |
1085 | pj | 3 | * |
1377 | giacomo | 4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
1085 | pj | 5 | * |
6 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
7 | * |
||
8 | * http://www.sssup.it |
||
9 | * http://retis.sssup.it |
||
1377 | giacomo | 10 | * http://hartik.sssup.it |
1085 | pj | 11 | */ |
12 | |||
13 | #include "kernel/kern.h" |
||
14 | #include "modules/edf.h" |
||
15 | #include "modules/cbs.h" |
||
16 | #include "modules/rr.h" |
||
17 | #include "modules/dummy.h" |
||
1377 | giacomo | 18 | #include "modules/intdrive.h" |
1085 | pj | 19 | |
20 | #include "modules/sem.h" |
||
21 | #include "modules/hartport.h" |
||
22 | |||
1382 | giacomo | 23 | #include <drivers/shark_linuxc26.h> |
24 | #include <drivers/shark_input26.h> |
||
25 | #include <drivers/shark_keyb26.h> |
||
26 | |||
27 | #define FRAME_BUFFER_DEVICE 0 |
||
28 | |||
1085 | pj | 29 | /*+ sysyem tick in us +*/ |
30 | #define TICK 0 |
||
31 | |||
32 | /*+ RR tick in us +*/ |
||
33 | #define RRTICK 10000 |
||
34 | |||
1377 | giacomo | 35 | /*+ Interrupt Server +*/ |
36 | #define INTDRIVE_Q 1000 |
||
37 | #define INTDRIVE_T 10000 |
||
38 | #define INTDRIVE_FLAG 0 |
||
39 | |||
1382 | giacomo | 40 | PID shutdown_task_PID = 1; |
41 | |||
1085 | pj | 42 | TIME __kernel_register_levels__(void *arg) |
43 | { |
||
1377 | giacomo | 44 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
1085 | pj | 45 | |
1377 | giacomo | 46 | INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG); |
47 | EDF_register_level(EDF_ENABLE_ALL); |
||
48 | CBS_register_level(CBS_ENABLE_ALL, 1); |
||
49 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
50 | dummy_register_level(); |
||
1085 | pj | 51 | |
1377 | giacomo | 52 | SEM_register_module(); |
1085 | pj | 53 | |
1377 | giacomo | 54 | return TICK; |
1085 | pj | 55 | } |
56 | |||
1382 | giacomo | 57 | int device_drivers_close() { |
58 | |||
59 | KEYB26_close(); |
||
60 | |||
61 | INPUT26_close(); |
||
62 | |||
63 | return 0; |
||
64 | |||
65 | } |
||
66 | |||
67 | int device_drivers_init() { |
||
68 | |||
69 | KEYB_PARMS kparms = BASE_KEYB; |
||
70 | |||
71 | LINUXC26_register_module(); |
||
72 | |||
73 | INPUT26_init(); |
||
74 | |||
75 | keyb_def_ctrlC(kparms, NULL); |
||
76 | |||
77 | KEYB26_init(&kparms); |
||
78 | |||
79 | return 0; |
||
80 | |||
81 | } |
||
82 | |||
83 | TASK shutdown_task_body(void *arg) { |
||
84 | |||
85 | device_drivers_close(); |
||
86 | |||
87 | sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
||
88 | |||
89 | sys_end(); |
||
90 | |||
91 | return NULL; |
||
92 | |||
93 | } |
||
94 | |||
95 | void set_shutdown_task() { |
||
96 | |||
97 | NRT_TASK_MODEL nrt; |
||
98 | |||
99 | nrt_task_default_model(nrt); |
||
100 | nrt_task_def_system(nrt); |
||
101 | nrt_task_def_nokill(nrt); |
||
102 | |||
103 | shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
||
104 | if (shutdown_task_PID == NIL) { |
||
105 | sys_shutdown_message("Error: Cannot create shutdown task\n"); |
||
106 | sys_end(); |
||
107 | } |
||
108 | |||
109 | } |
||
110 | |||
111 | void call_shutdown_task(void *arg) { |
||
112 | |||
113 | task_activate(shutdown_task_PID); |
||
114 | |||
115 | } |
||
116 | |||
1085 | pj | 117 | TASK __init__(void *arg) |
118 | { |
||
1377 | giacomo | 119 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
1085 | pj | 120 | |
1377 | giacomo | 121 | HARTPORT_init(); |
1085 | pj | 122 | |
1382 | giacomo | 123 | set_shutdown_task(); |
124 | |||
125 | device_drivers_init(); |
||
126 | |||
127 | sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
||
128 | |||
1377 | giacomo | 129 | __call_main__(mb); |
1085 | pj | 130 | |
1377 | giacomo | 131 | return (void *)0; |
1085 | pj | 132 | } |