Rev 1567 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1254 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
1441 | giacomo | 4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
1254 | giacomo | 5 | * |
1569 | tullio | 6 | * Authors : |
7 | * Mauro Marinoni <mauro.marinoni@unipv.it> |
||
8 | * Tullio Facchinetti <tullio.facchinetti@unipv.it> |
||
1441 | giacomo | 9 | * (see authors.txt for full list of hartik's authors) |
1254 | giacomo | 10 | * |
11 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
12 | * |
||
13 | * http://www.sssup.it |
||
14 | * http://retis.sssup.it |
||
1441 | giacomo | 15 | * http://hartik.sssup.it |
1254 | giacomo | 16 | */ |
17 | |||
18 | /* |
||
19 | * This program is free software; you can redistribute it and/or modify |
||
20 | * it under the terms of the GNU General Public License as published by |
||
21 | * the Free Software Foundation; either version 2 of the License, or |
||
22 | * (at your option) any later version. |
||
23 | * |
||
24 | * This program is distributed in the hope that it will be useful, |
||
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
27 | * GNU General Public License for more details. |
||
28 | * |
||
29 | * You should have received a copy of the GNU General Public License |
||
30 | * along with this program; if not, write to the Free Software |
||
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
32 | */ |
||
33 | |||
1441 | giacomo | 34 | |
35 | #include <kernel/kern.h> |
||
36 | |||
1554 | trimarchi | 37 | #include "edf/edf/edf.h" |
38 | #include "cbs/cbs/cbs.h" |
||
39 | #include "rr/rr/rr.h" |
||
40 | #include "dummy/dummy/dummy.h" |
||
41 | #include "intdrive/intdrive/intdrive.h" |
||
1254 | giacomo | 42 | |
1554 | trimarchi | 43 | #include "posix/posix/posix.h" |
1441 | giacomo | 44 | #include "grubstar.h" |
1538 | trimarchi | 45 | #include "fsf_basic_types.h" |
46 | #include "fsf_core.h" |
||
1254 | giacomo | 47 | |
1554 | trimarchi | 48 | #include "pi/pi/pi.h" |
49 | #include "pc/pc/pc.h" |
||
1254 | giacomo | 50 | |
1441 | giacomo | 51 | #include "pthread.h" |
52 | |||
1554 | trimarchi | 53 | #include "sem/sem/sem.h" |
54 | #include "hartport/hartport/hartport.h" |
||
55 | #include "nop/nop/nop.h" |
||
1441 | giacomo | 56 | |
57 | #include <drivers/shark_linuxc26.h> |
||
58 | #include <drivers/shark_pci26.h> |
||
59 | |||
60 | /*+ sysyem tick in us +*/ |
||
1254 | giacomo | 61 | #define TICK 0 |
62 | |||
1441 | giacomo | 63 | /*+ RR tick in us +*/ |
1254 | giacomo | 64 | #define RRTICK 10000 |
65 | |||
1441 | giacomo | 66 | /*+ Interrupt Server +*/ |
67 | #define INTDRIVE_Q 1000 |
||
1569 | tullio | 68 | #define INTDRIVE_U 0.1*MAX_BANDWIDTH |
1441 | giacomo | 69 | #define INTDRIVE_FLAG 0 |
70 | |||
71 | void call_shutdown_task(void *arg); |
||
72 | int device_drivers_init(); |
||
73 | int device_drivers_close(); |
||
74 | void set_shutdown_task(); |
||
75 | TASK shutdown_task_body(void *arg); |
||
76 | |||
77 | PID shutdown_task_PID = 1; |
||
78 | |||
1254 | giacomo | 79 | TIME __kernel_register_levels__(void *arg) |
80 | { |
||
1441 | giacomo | 81 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
82 | int grubstar_level; |
||
1538 | trimarchi | 83 | int posix_level; |
1539 | trimarchi | 84 | int pi_level; |
85 | int pc_level; |
||
1569 | tullio | 86 | LEVEL EDF_level; |
1254 | giacomo | 87 | |
1567 | mauro | 88 | INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG); |
1569 | tullio | 89 | EDF_level = EDF_register_level(EDF_ENABLE_ALL); |
1539 | trimarchi | 90 | posix_level=POSIX_register_level(RRTICK, 1, mb, 32); |
1441 | giacomo | 91 | grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 1); |
1467 | trimarchi | 92 | |
1538 | trimarchi | 93 | FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH * 0.8)); |
1441 | giacomo | 94 | dummy_register_level(); |
1539 | trimarchi | 95 | //posix_level=POSIX_register_level(RRTICK, 1, mb, 32); |
1569 | tullio | 96 | CBS_register_level(CBS_ENABLE_ALL,EDF_level); |
1441 | giacomo | 97 | |
98 | SEM_register_module(); |
||
99 | |||
1539 | trimarchi | 100 | pi_level=PI_register_module(); |
101 | pc_level=PC_register_module(); |
||
1467 | trimarchi | 102 | NOP_register_module(); |
1441 | giacomo | 103 | |
1539 | trimarchi | 104 | PTHREAD_register_module(2, pi_level, pc_level); |
1254 | giacomo | 105 | |
1441 | giacomo | 106 | return TICK; |
107 | } |
||
1254 | giacomo | 108 | |
1441 | giacomo | 109 | int device_drivers_close() { |
110 | |||
111 | return 0; |
||
112 | |||
113 | } |
||
1254 | giacomo | 114 | |
1441 | giacomo | 115 | int device_drivers_init() { |
1254 | giacomo | 116 | |
1567 | mauro | 117 | LINUXC26_register_module(TRUE); |
1441 | giacomo | 118 | PCI26_init(); |
1254 | giacomo | 119 | |
1441 | giacomo | 120 | return 0; |
1254 | giacomo | 121 | } |
122 | |||
1441 | giacomo | 123 | TASK shutdown_task_body(void *arg) { |
124 | |||
125 | device_drivers_close(); |
||
126 | sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
||
127 | return NULL; |
||
128 | } |
||
129 | |||
130 | #define SHUTDOWN_TIMEOUT_SEC 3 |
||
131 | |||
132 | void set_shutdown_task() { |
||
133 | |||
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"); |
||
1548 | pj | 142 | exit(0); |
1441 | giacomo | 143 | } |
144 | |||
145 | } |
||
146 | |||
147 | void call_shutdown_task(void *arg) { |
||
148 | |||
149 | struct timespec t; |
||
150 | |||
151 | sys_gettime(&t); |
||
152 | t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
||
153 | |||
154 | /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
||
155 | kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
||
156 | |||
157 | task_activate(shutdown_task_PID); |
||
158 | } |
||
159 | |||
1254 | giacomo | 160 | TASK __init__(void *arg) |
161 | { |
||
1441 | giacomo | 162 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
1254 | giacomo | 163 | |
1441 | giacomo | 164 | HARTPORT_init(); |
1254 | giacomo | 165 | |
1441 | giacomo | 166 | set_shutdown_task(); |
1254 | giacomo | 167 | |
1441 | giacomo | 168 | device_drivers_init(); |
169 | |||
170 | sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
||
171 | |||
172 | __call_main__(mb); |
||
173 | |||
174 | return (void *)0; |
||
1254 | giacomo | 175 | } |
176 | |||
177 | int main() { |
||
178 | |||
179 | return start_environment(); |
||
1441 | giacomo | 180 | |
1254 | giacomo | 181 | } |
182 |