Subversion Repositories shark

Rev

Rev 1538 | Rev 1548 | Go to most recent revision | 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
 
1254 giacomo 35
#include "modules/edf.h"
36
#include "modules/cbs.h"
1441 giacomo 37
#include "modules/rr.h"
1254 giacomo 38
#include "modules/dummy.h"
1441 giacomo 39
#include "modules/intdrive.h"
1254 giacomo 40
 
1441 giacomo 41
#include "modules/posix.h"
42
#include "grubstar.h"
1538 trimarchi 43
#include "fsf_basic_types.h"
44
#include "fsf_core.h"
1254 giacomo 45
 
46
#include "modules/pi.h"
47
#include "modules/pc.h"
48
 
1441 giacomo 49
#include "pthread.h"
50
 
51
#include "modules/sem.h"
52
#include "modules/hartport.h"
1467 trimarchi 53
#include "modules/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
66
#define INTDRIVE_T 10000
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
 
1441 giacomo 85
        INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
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
 
1441 giacomo 114
        LINUXC26_register_module();
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
        sys_abort_shutdown(0);
125
 
126
        return NULL;
127
}
128
 
129
#define SHUTDOWN_TIMEOUT_SEC 3
130
 
131
void set_shutdown_task() {
132
 
133
        NRT_TASK_MODEL nrt;
134
 
135
        nrt_task_default_model(nrt);
136
        nrt_task_def_system(nrt);
137
 
138
        shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
139
        if (shutdown_task_PID == NIL) {
140
                sys_shutdown_message("Error: Cannot create shutdown task\n");
141
                sys_end();
142
        }
143
 
144
}
145
 
146
void call_shutdown_task(void *arg) {
147
 
148
        struct timespec t;
149
 
150
        sys_gettime(&t);
151
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
152
 
153
        /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
154
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
155
 
156
        task_activate(shutdown_task_PID);
157
}
158
 
1254 giacomo 159
TASK __init__(void *arg)
160
{
1441 giacomo 161
        struct multiboot_info *mb = (struct multiboot_info *)arg;
1254 giacomo 162
 
1441 giacomo 163
        HARTPORT_init();
1254 giacomo 164
 
1441 giacomo 165
        set_shutdown_task();
1254 giacomo 166
 
1441 giacomo 167
        device_drivers_init();
168
 
169
        sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
170
 
171
        __call_main__(mb);
172
 
173
        return (void *)0;
1254 giacomo 174
}
175
 
176
int main() {
177
 
178
  return start_environment();
1441 giacomo 179
 
1254 giacomo 180
}
181