Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1672 tullio 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *
6
 * Authors     :
7
 *   Mauro Marinoni      <mauro.marinoni@unipv.it>
8
 *   Tullio Facchinetti  <tullio.facchinetti@unipv.it>
9
 * (see authors.txt for full list of hartik's authors)
10
 *
11
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
12
 *
13
 * http://www.sssup.it
14
 * http://retis.sssup.it
15
 * http://hartik.sssup.it
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
 
34
 
35
#include <kernel/kern.h>
36
 
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"
42
 
43
#include "posix/posix/posix.h"
44
#include "grubstar.h"
45
#include "fsf_basic_types.h"
46
#include "fsf_core.h"
47
 
48
#include "pi/pi/pi.h"
49
#include "pc/pc/pc.h"
50
 
51
#include "pthread.h"
52
 
53
#include "sem/sem/sem.h"
54
#include "hartport/hartport/hartport.h"
55
#include "nop/nop/nop.h"
56
 
57
#include <drivers/shark_linuxc26.h>
58
#include <drivers/shark_pci26.h>
59
 
60
/*+ sysyem tick in us +*/
61
#define TICK 0
62
 
63
/*+ RR tick in us +*/
64
#define RRTICK 10000
65
 
66
/*+ Interrupt Server +*/
67
#define INTDRIVE_Q 1000
68
#define INTDRIVE_U 0.1*MAX_BANDWIDTH
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
 
79
TIME __kernel_register_levels__(void *arg)
80
{
81
        struct multiboot_info *mb = (struct multiboot_info *)arg;
82
        int grubstar_level;
83
        int posix_level;
84
        int pi_level;
85
        int pc_level;
86
        LEVEL EDF_level;
87
 
88
        INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG);
89
        EDF_level = EDF_register_level(EDF_ENABLE_ALL);
90
        posix_level=POSIX_register_level(RRTICK, 1, mb, 32);    
91
        grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 1);
92
 
93
        FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH * 0.8));
94
        dummy_register_level();
95
        //posix_level=POSIX_register_level(RRTICK, 1, mb, 32);                                                                                                                
96
        CBS_register_level(CBS_ENABLE_ALL,EDF_level);
97
 
98
        SEM_register_module();
99
 
100
        pi_level=PI_register_module();
101
        pc_level=PC_register_module();
102
        NOP_register_module();
103
 
104
        PTHREAD_register_module(2, pi_level, pc_level);
105
 
106
        return TICK;
107
}
108
 
109
int device_drivers_close() {
110
 
111
        return 0;
112
 
113
}
114
 
115
int device_drivers_init() {
116
 
117
        LINUXC26_register_module(TRUE);
118
        PCI26_init();
119
 
120
        return 0;
121
}
122
 
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");
142
                exit(0);
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
 
160
TASK __init__(void *arg)
161
{
162
        struct multiboot_info *mb = (struct multiboot_info *)arg;
163
 
164
        HARTPORT_init();
165
 
166
        set_shutdown_task();
167
 
168
        device_drivers_init();
169
 
170
        sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
171
 
172
        __call_main__(mb);
173
 
174
        return (void *)0;
175
}
176
 
177
int main() {
178
 
179
  return start_environment();
180
 
181
}
182