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