Subversion Repositories shark

Rev

Rev 1569 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1363 mauro 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
 *
1569 tullio 7
 * Authors     :
8
 *   Mauro Marinoni      <mauro.marinoni@unipv.it>
9
 *   Tullio Facchinetti  <tullio.facchinetti@unipv.it>
1363 mauro 10
 * (see authors.txt for full list of hartik's authors)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://hartik.sssup.it
17
 */
18
 
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
#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"
1363 mauro 42
 
1552 pj 43
#include "sem/sem/sem.h"
44
#include "hartport/hartport/hartport.h"
1363 mauro 45
 
46
#include <drivers/shark_linuxc26.h>
47
#include <drivers/shark_input26.h>
48
#include <drivers/shark_mouse26.h>
49
#include <drivers/shark_keyb26.h>
50
 
51
/*+ sysyem tick in us +*/
52
#define TICK 0
53
 
54
/*+ RR tick in us +*/
55
#define RRTICK 10000
56
 
1389 mauro 57
/*+ Interrupt Server +*/
58
#define INTDRIVE_Q 1000
1569 tullio 59
#define INTDRIVE_U 0.1*MAX_BANDWIDTH
1389 mauro 60
#define INTDRIVE_FLAG 0
1363 mauro 61
 
1399 giacomo 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
 
1389 mauro 68
PID shutdown_task_PID = 1;
1363 mauro 69
 
70
TIME __kernel_register_levels__(void *arg)
71
{
72
        struct multiboot_info *mb = (struct multiboot_info *)arg;
1569 tullio 73
        LEVEL EDF_level;
1363 mauro 74
 
1569 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);
1363 mauro 78
        RR_register_level(RRTICK, RR_MAIN_YES, mb);
79
        dummy_register_level();
80
 
81
        SEM_register_module();
82
 
83
        return TICK;
84
}
85
 
1389 mauro 86
int device_drivers_close() {
87
 
88
        MOUSE26_close();
89
        KEYB26_close();
90
        INPUT26_close();
91
 
1399 giacomo 92
        return 0;
1389 mauro 93
}
94
 
95
int device_drivers_init() {
96
 
1363 mauro 97
        KEYB_PARMS  kparms = BASE_KEYB;
98
        MOUSE_PARMS mparms = BASE_MOUSE;
1389 mauro 99
 
1569 tullio 100
        LINUXC26_register_module(TRUE);
1389 mauro 101
        INPUT26_init();
1363 mauro 102
 
103
        /*keyb_def_map(kparms, KEYMAP_IT);*/
104
        keyb_def_ctrlC(kparms, NULL);
105
        KEYB26_init(&kparms);
106
 
1389 mauro 107
        MOUSE26_init(&mparms);
108
 
109
        return 0;
110
 
111
}
112
 
113
TASK shutdown_task_body(void *arg) {
114
 
115
        device_drivers_close();
116
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
117
        return NULL;
118
}
119
 
120
void set_shutdown_task() {
121
 
122
        NRT_TASK_MODEL nrt;
123
 
124
        nrt_task_default_model(nrt);
125
        nrt_task_def_system(nrt);
126
 
127
        shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
128
        if (shutdown_task_PID == NIL) {
129
                sys_shutdown_message("Error: Cannot create shutdown task\n");
1550 pj 130
                exit(1);
1389 mauro 131
        }
132
 
133
}
134
 
1399 giacomo 135
#define SHUTDOWN_TIMEOUT_SEC 3
136
 
1389 mauro 137
void call_shutdown_task(void *arg) {
1399 giacomo 138
        struct timespec t;
139
 
140
        sys_gettime(&t);
141
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
142
 
143
        /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
144
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
145
 
1389 mauro 146
        task_activate(shutdown_task_PID);
147
}
148
 
149
TASK __init__(void *arg)
150
{
151
        struct multiboot_info *mb = (struct multiboot_info *)arg;
152
 
153
        HARTPORT_init();
154
 
155
        set_shutdown_task();
156
 
157
        device_drivers_init();
158
 
159
        sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
160
 
1363 mauro 161
        __call_main__(mb);
162
 
163
        return (void *)0;
164
}