Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1254 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
1441 giacomo 4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
1254 giacomo 5
 *
1441 giacomo 6
 * Authors     : Mauro Marinoni <mauro.marinoni@unipv.it>
7
 * (see authors.txt for full list of hartik's authors)
1254 giacomo 8
 *
9
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
10
 *
11
 * http://www.sssup.it
12
 * http://retis.sssup.it
1441 giacomo 13
 * http://hartik.sssup.it
1254 giacomo 14
 */
15
 
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
 
1441 giacomo 32
 
33
#include <kernel/kern.h>
34
 
1554 trimarchi 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"
1254 giacomo 40
 
1554 trimarchi 41
#include "posix/posix/posix.h"
1441 giacomo 42
#include "grubstar.h"
1538 trimarchi 43
#include "fsf_basic_types.h"
44
#include "fsf_core.h"
1254 giacomo 45
 
1554 trimarchi 46
#include "pi/pi/pi.h"
47
#include "pc/pc/pc.h"
1254 giacomo 48
 
1441 giacomo 49
#include "pthread.h"
50
 
1554 trimarchi 51
#include "sem/sem/sem.h"
52
#include "hartport/hartport/hartport.h"
53
#include "nop/nop/nop.h"
1441 giacomo 54
 
55
#include <drivers/shark_linuxc26.h>
56
#include <drivers/shark_pci26.h>
57
 
58
/*+ sysyem tick in us +*/
1254 giacomo 59
#define TICK 0
60
 
1441 giacomo 61
/*+ RR tick in us +*/
1254 giacomo 62
#define RRTICK 10000
63
 
1441 giacomo 64
/*+ Interrupt Server +*/
65
#define INTDRIVE_Q 1000
1567 mauro 66
#define INTDRIVE_U 1000
1441 giacomo 67
#define INTDRIVE_FLAG 0
68
 
69
void call_shutdown_task(void *arg);
70
int device_drivers_init();
71
int device_drivers_close();
72
void set_shutdown_task();
73
TASK shutdown_task_body(void *arg);
74
 
75
PID shutdown_task_PID = 1;
76
 
1254 giacomo 77
TIME __kernel_register_levels__(void *arg)
78
{
1441 giacomo 79
        struct multiboot_info *mb = (struct multiboot_info *)arg;
80
        int grubstar_level;
1538 trimarchi 81
        int posix_level;
1539 trimarchi 82
        int pi_level;
83
        int pc_level;
1254 giacomo 84
 
1567 mauro 85
        INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG);
1441 giacomo 86
        EDF_register_level(EDF_ENABLE_ALL);
1539 trimarchi 87
        posix_level=POSIX_register_level(RRTICK, 1, mb, 32);    
1441 giacomo 88
        grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 1);
1467 trimarchi 89
 
1538 trimarchi 90
        FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH * 0.8));
1441 giacomo 91
        dummy_register_level();
1539 trimarchi 92
        //posix_level=POSIX_register_level(RRTICK, 1, mb, 32);                                                                                                                
1441 giacomo 93
        CBS_register_level(CBS_ENABLE_ALL,1);
94
 
95
        SEM_register_module();
96
 
1539 trimarchi 97
        pi_level=PI_register_module();
98
        pc_level=PC_register_module();
1467 trimarchi 99
        NOP_register_module();
1441 giacomo 100
 
1539 trimarchi 101
        PTHREAD_register_module(2, pi_level, pc_level);
1254 giacomo 102
 
1441 giacomo 103
        return TICK;
104
}
1254 giacomo 105
 
1441 giacomo 106
int device_drivers_close() {
107
 
108
        return 0;
109
 
110
}
1254 giacomo 111
 
1441 giacomo 112
int device_drivers_init() {
1254 giacomo 113
 
1567 mauro 114
        LINUXC26_register_module(TRUE);
1441 giacomo 115
        PCI26_init();
1254 giacomo 116
 
1441 giacomo 117
        return 0;
1254 giacomo 118
}
119
 
1441 giacomo 120
TASK shutdown_task_body(void *arg) {
121
 
122
        device_drivers_close();
123
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
124
        return NULL;
125
}
126
 
127
#define SHUTDOWN_TIMEOUT_SEC 3
128
 
129
void set_shutdown_task() {
130
 
131
        NRT_TASK_MODEL nrt;
132
 
133
        nrt_task_default_model(nrt);
134
        nrt_task_def_system(nrt);
135
 
136
        shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
137
        if (shutdown_task_PID == NIL) {
138
                sys_shutdown_message("Error: Cannot create shutdown task\n");
1548 pj 139
                exit(0);
1441 giacomo 140
        }
141
 
142
}
143
 
144
void call_shutdown_task(void *arg) {
145
 
146
        struct timespec t;
147
 
148
        sys_gettime(&t);
149
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
150
 
151
        /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
152
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
153
 
154
        task_activate(shutdown_task_PID);
155
}
156
 
1254 giacomo 157
TASK __init__(void *arg)
158
{
1441 giacomo 159
        struct multiboot_info *mb = (struct multiboot_info *)arg;
1254 giacomo 160
 
1441 giacomo 161
        HARTPORT_init();
1254 giacomo 162
 
1441 giacomo 163
        set_shutdown_task();
1254 giacomo 164
 
1441 giacomo 165
        device_drivers_init();
166
 
167
        sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
168
 
169
        __call_main__(mb);
170
 
171
        return (void *)0;
1254 giacomo 172
}
173
 
174
int main() {
175
 
176
  return start_environment();
1441 giacomo 177
 
1254 giacomo 178
}
179