Rev 1569 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1162 | tavani | 1 | /* |
1349 | giacomo | 2 | * Project: S.Ha.R.K |
1162 | tavani | 3 | * |
4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
5 | * |
||
6 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
7 | * |
||
1569 | tullio | 8 | * Authors: |
9 | * ... |
||
10 | * Tullio Facchinetti <tullio.facchinetti@unipv.it> |
||
11 | * |
||
1162 | tavani | 12 | * http://www.sssup.it |
13 | * http://retis.sssup.it |
||
14 | * http://hartik.sssup.it |
||
15 | */ |
||
16 | |||
17 | #include "kernel/kern.h" |
||
1552 | pj | 18 | #include "edf/edf/edf.h" |
19 | #include "hardcbs/hardcbs/hardcbs.h" |
||
20 | #include "rr/rr/rr.h" |
||
21 | #include "dummy/dummy/dummy.h" |
||
22 | #include "intdrive/intdrive/intdrive.h" |
||
1162 | tavani | 23 | |
1552 | pj | 24 | #include "sem/sem/sem.h" |
25 | #include "hartport/hartport/hartport.h" |
||
1349 | giacomo | 26 | |
1392 | giacomo | 27 | #include <drivers/shark_linuxc26.h> |
28 | #include <drivers/shark_pci26.h> |
||
29 | #include <drivers/shark_input26.h> |
||
30 | #include <drivers/shark_keyb26.h> |
||
31 | #include <drivers/shark_fb26.h> |
||
32 | |||
33 | #define FRAME_BUFFER_DEVICE 0 |
||
34 | |||
1162 | tavani | 35 | /*+ sysyem tick in us +*/ |
1349 | giacomo | 36 | #define TICK 0 |
1162 | tavani | 37 | |
38 | /*+ RR tick in us +*/ |
||
1349 | giacomo | 39 | #define RRTICK 10000 |
1162 | tavani | 40 | |
1349 | giacomo | 41 | /*+ Interrup Server */ |
42 | #define INTDRIVE_Q 1000 |
||
1569 | tullio | 43 | #define INTDRIVE_U 0.1*MAX_BANDWIDTH |
1349 | giacomo | 44 | #define INTDRIVE_FLAG 0 |
45 | |||
1392 | giacomo | 46 | void call_shutdown_task(void *arg); |
47 | int device_drivers_init(); |
||
48 | int device_drivers_close(); |
||
49 | void set_shutdown_task(); |
||
50 | TASK shutdown_task_body(void *arg); |
||
51 | |||
52 | PID shutdown_task_PID = -1; |
||
53 | |||
1162 | tavani | 54 | TIME __kernel_register_levels__(void *arg) |
55 | { |
||
56 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
1569 | tullio | 57 | LEVEL EDF_level; |
1162 | tavani | 58 | |
1567 | mauro | 59 | INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG); |
1569 | tullio | 60 | EDF_level = EDF_register_level(EDF_ENABLE_ALL); |
61 | HCBS_register_level(HCBS_ENABLE_ALL, EDF_level); |
||
1162 | tavani | 62 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
63 | dummy_register_level(); |
||
64 | |||
65 | SEM_register_module(); |
||
66 | |||
67 | return TICK; |
||
68 | } |
||
69 | |||
70 | TASK __init__(void *arg) |
||
71 | { |
||
1392 | giacomo | 72 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
1162 | tavani | 73 | |
1392 | giacomo | 74 | HARTPORT_init(); |
1162 | tavani | 75 | |
1392 | giacomo | 76 | set_shutdown_task(); |
1162 | tavani | 77 | |
1392 | giacomo | 78 | device_drivers_init(); |
79 | |||
80 | sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
||
81 | |||
82 | __call_main__(mb); |
||
83 | |||
84 | return (void *)0; |
||
1162 | tavani | 85 | } |
1392 | giacomo | 86 | |
87 | void set_shutdown_task() { |
||
88 | |||
89 | NRT_TASK_MODEL nrt; |
||
90 | |||
91 | nrt_task_default_model(nrt); |
||
92 | nrt_task_def_system(nrt); |
||
93 | |||
94 | shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
||
95 | if (shutdown_task_PID == NIL) { |
||
96 | sys_shutdown_message("Error: Cannot create shutdown task\n"); |
||
1550 | pj | 97 | exit(1); |
1392 | giacomo | 98 | } |
99 | |||
100 | } |
||
101 | |||
102 | int device_drivers_init() { |
||
103 | |||
104 | int res; |
||
105 | KEYB_PARMS kparms = BASE_KEYB; |
||
106 | |||
1567 | mauro | 107 | LINUXC26_register_module(TRUE); |
1392 | giacomo | 108 | |
109 | PCI26_init(); |
||
110 | |||
111 | INPUT26_init(); |
||
112 | |||
113 | keyb_def_ctrlC(kparms, NULL); |
||
114 | |||
115 | KEYB26_init(&kparms); |
||
116 | |||
117 | FB26_init(); |
||
118 | |||
119 | res = FB26_open(FRAME_BUFFER_DEVICE); |
||
120 | if (res) { |
||
121 | cprintf("Error: Cannot open graphical mode\n"); |
||
122 | KEYB26_close(); |
||
123 | INPUT26_close(); |
||
1550 | pj | 124 | exit(1); |
1392 | giacomo | 125 | } |
126 | |||
127 | FB26_use_grx(FRAME_BUFFER_DEVICE); |
||
128 | |||
129 | FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
||
130 | |||
131 | return 0; |
||
132 | |||
133 | } |
||
134 | |||
135 | int device_drivers_close() { |
||
136 | |||
137 | FB26_close(FRAME_BUFFER_DEVICE); |
||
138 | |||
139 | KEYB26_close(); |
||
140 | |||
141 | INPUT26_close(); |
||
142 | |||
143 | return 0; |
||
144 | |||
145 | } |
||
146 | |||
147 | #define SHUTDOWN_TIMEOUT_SEC 3 |
||
148 | |||
149 | void call_shutdown_task(void *arg) |
||
150 | { |
||
151 | struct timespec t; |
||
152 | |||
153 | sys_gettime(&t); |
||
154 | t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
||
155 | |||
156 | /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
||
157 | kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
||
158 | |||
159 | task_activate(shutdown_task_PID); |
||
160 | } |
||
161 | |||
162 | TASK shutdown_task_body(void *arg) { |
||
163 | |||
164 | device_drivers_close(); |
||
165 | |||
166 | sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
||
167 | |||
168 | return NULL; |
||
169 | |||
170 | } |