Subversion Repositories shark

Rev

Rev 1467 | Rev 1539 | 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;
1254 giacomo 82
 
1441 giacomo 83
        INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
84
        EDF_register_level(EDF_ENABLE_ALL);
1538 trimarchi 85
        posix_level=POSIX_register_level(RRTICK, 1, mb, 32);
1441 giacomo 86
        grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 1);
1467 trimarchi 87
 
1538 trimarchi 88
        FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH * 0.8));
1441 giacomo 89
        dummy_register_level();
90
 
91
        CBS_register_level(CBS_ENABLE_ALL,1);
92
 
93
        SEM_register_module();
94
 
95
        PI_register_module();
96
        PC_register_module();
1467 trimarchi 97
        NOP_register_module();
1441 giacomo 98
 
99
        PTHREAD_register_module(2, 0, 1);
1254 giacomo 100
 
1441 giacomo 101
        return TICK;
102
}
1254 giacomo 103
 
1441 giacomo 104
int device_drivers_close() {
105
 
106
        return 0;
107
 
108
}
1254 giacomo 109
 
1441 giacomo 110
int device_drivers_init() {
1254 giacomo 111
 
1441 giacomo 112
        LINUXC26_register_module();
113
        PCI26_init();
1254 giacomo 114
 
1441 giacomo 115
        return 0;
1254 giacomo 116
}
117
 
1441 giacomo 118
TASK shutdown_task_body(void *arg) {
119
 
120
        device_drivers_close();
121
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
122
        sys_abort_shutdown(0);
123
 
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");
139
                sys_end();
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