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