Rev 1567 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1505 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
5 | * Gerardo Lamastra <gerardo@sssup.it> |
||
6 | * |
||
7 | * Authors : Giacomo Guidi <giacomo@gandalf.sssup.it> |
||
8 | * |
||
9 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
10 | * |
||
11 | * http://www.sssup.it |
||
12 | * http://retis.sssup.it |
||
13 | * http://hartik.sssup.it |
||
14 | */ |
||
15 | |||
16 | /* |
||
17 | * This program is free software; you can redistribute it and/or modify |
||
18 | * it under the terms of the GNU General Public License as published by |
||
19 | * the Free Software Foundation; either version 2 of the License, or |
||
20 | * (at your option) any later version. |
||
21 | * |
||
22 | * This program is distributed in the hope that it will be useful, |
||
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
25 | * GNU General Public License for more details. |
||
26 | * |
||
27 | * You should have received a copy of the GNU General Public License |
||
28 | * along with this program; if not, write to the Free Software |
||
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
30 | * |
||
31 | */ |
||
32 | |||
33 | |||
34 | #include "kernel/kern.h" |
||
35 | |||
1552 | pj | 36 | #include "intdrive/intdrive/intdrive.h" |
37 | #include "edf/edf/edf.h" |
||
38 | #include "hardcbs/hardcbs/hardcbs.h" |
||
39 | #include "rr/rr/rr.h" |
||
40 | #include "dummy/dummy/dummy.h" |
||
1505 | giacomo | 41 | |
1552 | pj | 42 | #include "sem/sem/sem.h" |
43 | #include "hartport/hartport/hartport.h" |
||
44 | #include "cabs/cabs/cabs.h" |
||
1505 | giacomo | 45 | |
46 | #include <drivers/shark_linuxc26.h> |
||
47 | #include <drivers/shark_pci26.h> |
||
48 | |||
49 | #include <drivers/shark_input26.h> |
||
50 | #include <drivers/shark_keyb26.h> |
||
51 | #include <drivers/shark_mouse26.h> |
||
52 | |||
53 | #include <drivers/shark_fb26.h> |
||
54 | |||
55 | #include <tracer.h> |
||
56 | |||
57 | #define FRAME_BUFFER_DEVICE 0 |
||
58 | |||
59 | /*+ sysyem tick in us +*/ |
||
60 | #define TICK 0 |
||
61 | |||
62 | /*+ RR tick in us +*/ |
||
63 | #define RRTICK 2000 |
||
64 | |||
65 | /*+ Interrupt Server +*/ |
||
66 | #define INTDRIVE_Q 1000 |
||
1568 | tullio | 67 | #define INTDRIVE_U 0.1*MAX_BANDWIDTH |
1505 | giacomo | 68 | #define INTDRIVE_FLAG 0 |
69 | |||
70 | void call_shutdown_task(void *arg); |
||
71 | int device_drivers_init(); |
||
72 | int device_drivers_close(); |
||
73 | void set_shutdown_task(); |
||
74 | TASK shutdown_task_body(void *arg); |
||
75 | |||
76 | PID shutdown_task_PID = -1; |
||
77 | int a = -1; |
||
78 | |||
1519 | giacomo | 79 | extern unsigned int clk_per_msec; |
80 | |||
1505 | giacomo | 81 | TIME __kernel_register_levels__(void *arg) |
82 | { |
||
83 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
1568 | tullio | 84 | LEVEL EDF_level; |
85 | |||
1567 | mauro | 86 | INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG); |
1568 | tullio | 87 | EDF_level = EDF_register_level(EDF_ENABLE_ALL); |
88 | HCBS_register_level(HCBS_ENABLE_ALL, EDF_level); |
||
1505 | giacomo | 89 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
90 | dummy_register_level(); |
||
91 | |||
92 | SEM_register_module(); |
||
93 | CABS_register_module(); |
||
94 | |||
95 | return TICK; |
||
96 | } |
||
97 | |||
98 | TASK __init__(void *arg) |
||
99 | { |
||
100 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
101 | |||
102 | HARTPORT_init(); |
||
103 | |||
104 | /* Create the shutdown task. It will be activated at RUNLEVEL SHUTDOWN */ |
||
105 | set_shutdown_task(); |
||
106 | |||
107 | /* Init the drivers */ |
||
108 | device_drivers_init(); |
||
109 | |||
110 | /* Set the shutdown task activation */ |
||
111 | sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
||
112 | |||
113 | /* Tracer init: 10MB single tracer chunk */ |
||
114 | a = FTrace_chunk_create(10000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
||
115 | |||
116 | FTrace_actual_chunk_select(a); |
||
117 | |||
118 | FTrace_enable(); |
||
119 | |||
1519 | giacomo | 120 | TRACER_LOGEVENT(FTrace_EVT_trace_start,proc_table[exec_shadow].context,clk_per_msec); |
1505 | giacomo | 121 | |
1508 | giacomo | 122 | for (i=0;i<10;i++) |
123 | if (proc_table[i].context != 0) TRACER_LOGEVENT(FTrace_EVT_id, |
||
124 | (unsigned short int)proc_table[i].context,i); |
||
125 | |||
1505 | giacomo | 126 | __call_main__(mb); |
127 | |||
128 | return (void *)0; |
||
129 | } |
||
130 | |||
131 | void set_shutdown_task() |
||
132 | { |
||
133 | /* WARNING: the shutdown task is a background thread. It cannot execute if the system is overloaded */ |
||
134 | NRT_TASK_MODEL nrt; |
||
135 | |||
136 | nrt_task_default_model(nrt); |
||
137 | nrt_task_def_system(nrt); |
||
138 | |||
139 | shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
||
140 | if (shutdown_task_PID == NIL) { |
||
141 | sys_shutdown_message("Error: Cannot create shutdown task\n"); |
||
1550 | pj | 142 | exit(1); |
1505 | giacomo | 143 | } |
144 | } |
||
145 | |||
146 | int device_drivers_init() |
||
147 | { |
||
148 | int res; |
||
149 | KEYB_PARMS kparms = BASE_KEYB; |
||
150 | MOUSE_PARMS mparms = BASE_MOUSE; |
||
151 | |||
1567 | mauro | 152 | LINUXC26_register_module(TRUE); |
1505 | giacomo | 153 | |
154 | PCI26_init(); |
||
155 | |||
156 | INPUT26_init(); |
||
157 | |||
158 | /* keyb_def_map(kparms, KEYMAP_IT);*/ |
||
159 | keyb_def_ctrlC(kparms, NULL); |
||
160 | KEYB26_init(&kparms); |
||
161 | |||
162 | mouse_def_threshold(mparms, 5); |
||
163 | mouse_def_xmin(mparms, 0); |
||
164 | mouse_def_ymin(mparms, 0); |
||
165 | mouse_def_xmax(mparms, 639); |
||
166 | mouse_def_ymax(mparms, 479); |
||
167 | MOUSE26_init(&mparms); |
||
168 | |||
169 | FB26_init(); |
||
170 | res = FB26_open(FRAME_BUFFER_DEVICE); |
||
171 | if (res) { |
||
172 | cprintf("Error: Cannot open graphical mode\n"); |
||
173 | MOUSE26_close(); |
||
174 | KEYB26_close(); |
||
175 | INPUT26_close(); |
||
1550 | pj | 176 | exit(1); |
1505 | giacomo | 177 | } |
178 | |||
179 | FB26_use_grx(FRAME_BUFFER_DEVICE); |
||
180 | FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
||
181 | |||
182 | return 0; |
||
183 | } |
||
184 | |||
185 | int device_drivers_close() { |
||
186 | |||
187 | TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0); |
||
188 | |||
189 | FTrace_disable(); |
||
190 | |||
191 | FTrace_OSD_init_udp(1, "192.168.1.10", "192.168.1.1"); |
||
192 | |||
193 | FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
||
194 | |||
195 | mouse_grxcursor(DISABLE, 0); |
||
196 | |||
197 | FB26_close(FRAME_BUFFER_DEVICE); |
||
198 | |||
199 | MOUSE26_close(); |
||
200 | KEYB26_close(); |
||
201 | INPUT26_close(); |
||
202 | |||
203 | return 0; |
||
204 | } |
||
205 | |||
1507 | giacomo | 206 | #define SHUTDOWN_TIMEOUT_SEC 120 |
1505 | giacomo | 207 | |
208 | void call_shutdown_task(void *arg) |
||
209 | { |
||
210 | struct timespec t; |
||
211 | |||
212 | sys_gettime(&t); |
||
213 | t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
||
214 | |||
215 | /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
||
216 | kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
||
217 | |||
218 | task_activate(shutdown_task_PID); |
||
219 | } |
||
220 | |||
221 | TASK shutdown_task_body(void *arg) |
||
222 | { |
||
223 | device_drivers_close(); |
||
224 | |||
225 | sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
||
226 | |||
227 | return NULL; |
||
228 | } |