Subversion Repositories shark

Rev

Rev 1441 | 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"
1254 giacomo 43
#include "fsf_contract.h"
44
 
45
#include "modules/pi.h"
46
#include "modules/pc.h"
47
 
1441 giacomo 48
#include "pthread.h"
49
 
50
#include "modules/sem.h"
51
#include "modules/hartport.h"
1467 trimarchi 52
#include "modules/nop.h"
1441 giacomo 53
 
54
#include <drivers/shark_linuxc26.h>
55
#include <drivers/shark_pci26.h>
56
 
57
/*+ sysyem tick in us +*/
1254 giacomo 58
#define TICK 0
59
 
1441 giacomo 60
/*+ RR tick in us +*/
1254 giacomo 61
#define RRTICK 10000
62
 
1441 giacomo 63
/*+ Interrupt Server +*/
64
#define INTDRIVE_Q 1000
65
#define INTDRIVE_T 10000
66
#define INTDRIVE_FLAG 0
67
 
68
void call_shutdown_task(void *arg);
69
int device_drivers_init();
70
int device_drivers_close();
71
void set_shutdown_task();
72
TASK shutdown_task_body(void *arg);
73
 
74
PID shutdown_task_PID = 1;
75
 
1254 giacomo 76
TIME __kernel_register_levels__(void *arg)
77
{
1441 giacomo 78
        struct multiboot_info *mb = (struct multiboot_info *)arg;
79
        int grubstar_level;
1254 giacomo 80
 
1441 giacomo 81
        INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
82
        EDF_register_level(EDF_ENABLE_ALL);
83
        POSIX_register_level(RRTICK, 1, mb, 32);
84
        grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 1);
1467 trimarchi 85
 
86
        FSF_register_module(grubstar_level, (int)(MAX_BANDWIDTH * 0.8));
1441 giacomo 87
        dummy_register_level();
88
 
89
        CBS_register_level(CBS_ENABLE_ALL,1);
90
 
91
        SEM_register_module();
92
 
93
        PI_register_module();
94
        PC_register_module();
1467 trimarchi 95
        NOP_register_module();
1441 giacomo 96
 
97
        PTHREAD_register_module(2, 0, 1);
1254 giacomo 98
 
1441 giacomo 99
        return TICK;
100
}
1254 giacomo 101
 
1441 giacomo 102
int device_drivers_close() {
103
 
104
        return 0;
105
 
106
}
1254 giacomo 107
 
1441 giacomo 108
int device_drivers_init() {
1254 giacomo 109
 
1441 giacomo 110
        LINUXC26_register_module();
111
        PCI26_init();
1254 giacomo 112
 
1441 giacomo 113
        return 0;
1254 giacomo 114
}
115
 
1441 giacomo 116
TASK shutdown_task_body(void *arg) {
117
 
118
        device_drivers_close();
119
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
120
        sys_abort_shutdown(0);
121
 
122
        return NULL;
123
}
124
 
125
#define SHUTDOWN_TIMEOUT_SEC 3
126
 
127
void set_shutdown_task() {
128
 
129
        NRT_TASK_MODEL nrt;
130
 
131
        nrt_task_default_model(nrt);
132
        nrt_task_def_system(nrt);
133
 
134
        shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
135
        if (shutdown_task_PID == NIL) {
136
                sys_shutdown_message("Error: Cannot create shutdown task\n");
137
                sys_end();
138
        }
139
 
140
}
141
 
142
void call_shutdown_task(void *arg) {
143
 
144
        struct timespec t;
145
 
146
        sys_gettime(&t);
147
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
148
 
149
        /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
150
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
151
 
152
        task_activate(shutdown_task_PID);
153
}
154
 
1254 giacomo 155
TASK __init__(void *arg)
156
{
1441 giacomo 157
        struct multiboot_info *mb = (struct multiboot_info *)arg;
1254 giacomo 158
 
1441 giacomo 159
        HARTPORT_init();
1254 giacomo 160
 
1441 giacomo 161
        set_shutdown_task();
1254 giacomo 162
 
1441 giacomo 163
        device_drivers_init();
164
 
165
        sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
166
 
167
        __call_main__(mb);
168
 
169
        return (void *)0;
1254 giacomo 170
}
171
 
172
int main() {
173
 
174
  return start_environment();
1441 giacomo 175
 
1254 giacomo 176
}
177