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