Rev 1567 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1346 | giacomo | 1 | /* |
1356 | giacomo | 2 | * Project: S.Ha.R.K |
1346 | giacomo | 3 | * |
1356 | giacomo | 4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
1346 | giacomo | 5 | * |
6 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
7 | * |
||
8 | * http://www.sssup.it |
||
9 | * http://retis.sssup.it |
||
1356 | giacomo | 10 | * http://hartik.sssup.it |
1346 | giacomo | 11 | */ |
12 | |||
1606 | tullio | 13 | /* |
14 | * This program is free software; you can redistribute it and/or modify |
||
15 | * it under the terms of the GNU General Public License as published by |
||
16 | * the Free Software Foundation; either version 2 of the License, or |
||
17 | * (at your option) any later version. |
||
18 | * |
||
19 | * This program is distributed in the hope that it will be useful, |
||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
22 | * GNU General Public License for more details. |
||
23 | * |
||
24 | * You should have received a copy of the GNU General Public License |
||
25 | * along with this program; if not, write to the Free Software |
||
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
27 | * |
||
28 | */ |
||
29 | |||
30 | |||
1346 | giacomo | 31 | #include "kernel/kern.h" |
1552 | pj | 32 | #include "edf/edf/edf.h" |
33 | #include "hardcbs/hardcbs/hardcbs.h" |
||
34 | #include "rr/rr/rr.h" |
||
35 | #include "dummy/dummy/dummy.h" |
||
36 | #include "intdrive/intdrive/intdrive.h" |
||
1346 | giacomo | 37 | |
1552 | pj | 38 | #include "sem/sem/sem.h" |
39 | #include "hartport/hartport/hartport.h" |
||
1346 | giacomo | 40 | |
1382 | giacomo | 41 | #include "drivers/shark_linuxc26.h" |
42 | #include "drivers/shark_pci26.h" |
||
43 | |||
1346 | giacomo | 44 | /*+ sysyem tick in us +*/ |
45 | #define TICK 0 |
||
46 | |||
47 | /*+ RR tick in us +*/ |
||
48 | #define RRTICK 10000 |
||
49 | |||
1377 | giacomo | 50 | /*+ Interrupt Server +*/ |
1356 | giacomo | 51 | #define INTDRIVE_Q 1000 |
1567 | mauro | 52 | #define INTDRIVE_U 1000 |
1356 | giacomo | 53 | #define INTDRIVE_FLAG 0 |
54 | |||
1383 | giacomo | 55 | void call_shutdown_task(void *arg); |
56 | int device_drivers_init(); |
||
57 | int device_drivers_close(); |
||
58 | void set_shutdown_task(); |
||
59 | TASK shutdown_task_body(void *arg); |
||
60 | |||
1463 | giacomo | 61 | PID shutdown_task_PID = -1; |
1382 | giacomo | 62 | |
1356 | giacomo | 63 | TIME __kernel_register_levels__(void *arg) |
64 | { |
||
65 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
1346 | giacomo | 66 | |
1567 | mauro | 67 | INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG); |
1356 | giacomo | 68 | EDF_register_level(EDF_ENABLE_ALL); |
69 | HCBS_register_level(HCBS_ENABLE_ALL, 1); |
||
70 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
||
71 | dummy_register_level(); |
||
1346 | giacomo | 72 | |
1356 | giacomo | 73 | SEM_register_module(); |
74 | |||
75 | return TICK; |
||
1346 | giacomo | 76 | } |
77 | |||
1383 | giacomo | 78 | TASK __init__(void *arg) |
79 | { |
||
80 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
81 | |||
82 | HARTPORT_init(); |
||
83 | |||
84 | set_shutdown_task(); |
||
85 | |||
86 | device_drivers_init(); |
||
87 | |||
88 | sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
||
89 | |||
90 | __call_main__(mb); |
||
91 | |||
92 | return (void *)0; |
||
93 | } |
||
94 | |||
95 | void set_shutdown_task() { |
||
96 | |||
97 | NRT_TASK_MODEL nrt; |
||
98 | |||
99 | nrt_task_default_model(nrt); |
||
100 | nrt_task_def_system(nrt); |
||
101 | |||
102 | shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
||
103 | if (shutdown_task_PID == NIL) { |
||
104 | sys_shutdown_message("Error: Cannot create shutdown task\n"); |
||
1547 | pj | 105 | exit(1); |
1383 | giacomo | 106 | } |
107 | |||
108 | } |
||
109 | |||
1382 | giacomo | 110 | int device_drivers_init() { |
111 | |||
1567 | mauro | 112 | LINUXC26_register_module(TRUE); |
1382 | giacomo | 113 | |
114 | PCI26_init(); |
||
115 | |||
116 | return 0; |
||
117 | |||
118 | } |
||
119 | |||
120 | int device_drivers_close() { |
||
121 | |||
122 | return 0; |
||
123 | |||
124 | } |
||
125 | |||
126 | TASK shutdown_task_body(void *arg) { |
||
127 | |||
128 | device_drivers_close(); |
||
129 | |||
130 | sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
||
131 | |||
132 | return NULL; |
||
133 | |||
134 | } |
||
135 | |||
1383 | giacomo | 136 | #define SHUTDOWN_TIMEOUT_SEC 3 |
137 | |||
1382 | giacomo | 138 | void call_shutdown_task(void *arg) { |
139 | |||
1383 | giacomo | 140 | struct timespec t; |
141 | |||
142 | sys_gettime(&t); |
||
143 | t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
||
144 | |||
145 | kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
||
146 | |||
1382 | giacomo | 147 | task_activate(shutdown_task_PID); |
148 | |||
149 | } |