Rev 1568 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1489 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
1491 | giacomo | 4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
1489 | giacomo | 5 | * |
1569 | tullio | 6 | * Authors : |
7 | * Mauro Marinoni <mauro.marinoni@unipv.it> |
||
8 | * Tullio Facchinetti <tullio.facchinetti@unipv.it> |
||
1491 | giacomo | 9 | * (see authors.txt for full list of hartik's authors) |
1489 | giacomo | 10 | * |
11 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
12 | * |
||
13 | * http://www.sssup.it |
||
14 | * http://retis.sssup.it |
||
1491 | giacomo | 15 | * http://hartik.sssup.it |
1489 | giacomo | 16 | */ |
17 | |||
1491 | giacomo | 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 | |||
34 | |||
35 | #include <kernel/kern.h> |
||
36 | |||
1552 | pj | 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" |
||
1489 | giacomo | 42 | |
1552 | pj | 43 | #include "sem/sem/sem.h" |
44 | #include "hartport/hartport/hartport.h" |
||
1489 | giacomo | 45 | |
1491 | giacomo | 46 | #include <drivers/shark_linuxc26.h> |
47 | #include <drivers/shark_pci26.h> |
||
48 | #include <drivers/shark_input26.h> |
||
49 | #include <drivers/shark_keyb26.h> |
||
50 | |||
1489 | giacomo | 51 | /*+ sysyem tick in us +*/ |
52 | #define TICK 0 |
||
53 | |||
54 | /*+ RR tick in us +*/ |
||
55 | #define RRTICK 10000 |
||
56 | |||
1491 | giacomo | 57 | /*+ Interrupt Server +*/ |
58 | #define INTDRIVE_Q 1000 |
||
1568 | tullio | 59 | #define INTDRIVE_U 0.1*MAX_BANDWIDTH |
1491 | giacomo | 60 | #define INTDRIVE_FLAG 0 |
61 | |||
62 | void call_shutdown_task(void *arg); |
||
63 | int device_drivers_init(); |
||
64 | int device_drivers_close(); |
||
65 | void set_shutdown_task(); |
||
66 | TASK shutdown_task_body(void *arg); |
||
67 | |||
68 | PID shutdown_task_PID = 1; |
||
69 | |||
1489 | giacomo | 70 | TIME __kernel_register_levels__(void *arg) |
71 | { |
||
1491 | giacomo | 72 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
1568 | tullio | 73 | LEVEL EDF_level; |
1489 | giacomo | 74 | |
1568 | tullio | 75 | INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG); |
76 | EDF_level = EDF_register_level(EDF_ENABLE_ALL); |
||
77 | CBS_register_level(CBS_ENABLE_ALL, EDF_level); |
||
1491 | giacomo | 78 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
79 | dummy_register_level(); |
||
1489 | giacomo | 80 | |
1491 | giacomo | 81 | SEM_register_module(); |
1489 | giacomo | 82 | |
1491 | giacomo | 83 | return TICK; |
84 | } |
||
1489 | giacomo | 85 | |
1491 | giacomo | 86 | int device_drivers_close() { |
87 | |||
88 | return 0; |
||
89 | |||
1489 | giacomo | 90 | } |
91 | |||
1491 | giacomo | 92 | int device_drivers_init() { |
93 | |||
1567 | mauro | 94 | LINUXC26_register_module(TRUE); |
1491 | giacomo | 95 | PCI26_init(); |
96 | |||
97 | return 0; |
||
98 | } |
||
99 | |||
100 | TASK shutdown_task_body(void *arg) { |
||
101 | |||
102 | device_drivers_close(); |
||
103 | sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
||
104 | |||
105 | return NULL; |
||
106 | } |
||
107 | |||
108 | #define SHUTDOWN_TIMEOUT_SEC 3 |
||
109 | |||
110 | void set_shutdown_task() { |
||
111 | |||
112 | NRT_TASK_MODEL nrt; |
||
113 | |||
114 | nrt_task_default_model(nrt); |
||
115 | nrt_task_def_system(nrt); |
||
116 | |||
117 | shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL); |
||
118 | if (shutdown_task_PID == NIL) { |
||
119 | sys_shutdown_message("Error: Cannot create shutdown task\n"); |
||
1550 | pj | 120 | exit(1); |
1491 | giacomo | 121 | } |
122 | |||
123 | } |
||
124 | |||
125 | void call_shutdown_task(void *arg) { |
||
126 | |||
127 | struct timespec t; |
||
128 | |||
129 | sys_gettime(&t); |
||
130 | t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
||
131 | |||
132 | /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
||
133 | kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
||
134 | |||
135 | task_activate(shutdown_task_PID); |
||
136 | } |
||
137 | |||
1489 | giacomo | 138 | TASK __init__(void *arg) |
139 | { |
||
1491 | giacomo | 140 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
1489 | giacomo | 141 | |
1491 | giacomo | 142 | HARTPORT_init(); |
1489 | giacomo | 143 | |
1491 | giacomo | 144 | set_shutdown_task(); |
1489 | giacomo | 145 | |
1491 | giacomo | 146 | device_drivers_init(); |
147 | |||
148 | sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
||
149 | |||
150 | __call_main__(mb); |
||
151 | |||
152 | return (void *)0; |
||
1489 | giacomo | 153 | } |